]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Show a message if Konsole part is not installed
authorRoman Inflianskas <infroma@gmail.com>
Wed, 7 Mar 2018 11:35:17 +0000 (14:35 +0300)
committerRoman Inflianskas <infroma@gmail.com>
Sun, 11 Mar 2018 17:41:54 +0000 (20:41 +0300)
Summary:
Show a message if Konsole part is not installed

BUG: 371822
FIXED-IN: 18.04.0

{F5749731}

Reviewers: ngraham, progwolff, elvisangelaccio

Reviewed By: ngraham, progwolff, elvisangelaccio

Subscribers: rkflx, ngraham, elvisangelaccio, broulik, progwolff, #dolphin

Differential Revision: https://phabricator.kde.org/D11118

src/panels/terminal/terminalpanel.cpp
src/panels/terminal/terminalpanel.h

index 4f77f6136c65667e58189b39645eccc7ed5b1009..d2d569c9ff10d57236f220cad9a3e4d47f0e81f1 100644 (file)
 
 #include "terminalpanel.h"
 
+#include <KIO/DesktopExecParser>
 #include <KIO/Job>
 #include <KIO/JobUiDelegate>
 #include <KJobWidgets>
+#include <KLocalizedString>
+#include <KMessageWidget>
 #include <KParts/ReadOnlyPart>
 #include <KPluginFactory>
 #include <KPluginLoader>
 #include <KShell>
 #include <kde_terminal_interface.h>
 
+#include <QAction>
+#include <QDesktopServices>
 #include <QDir>
+#include <QLabel>
 #include <QShowEvent>
+#include <QTimer>
 #include <QVBoxLayout>
 
 TerminalPanel::TerminalPanel(QWidget* parent) :
@@ -132,7 +139,29 @@ void TerminalPanel::showEvent(QShowEvent* event)
             connect(m_konsolePart, &KParts::ReadOnlyPart::destroyed, this, &TerminalPanel::terminalExited);
             m_terminalWidget = m_konsolePart->widget();
             m_layout->addWidget(m_terminalWidget);
+            if (m_konsolePartMissingMessage) {
+                m_layout->removeWidget(m_konsolePartMissingMessage);
+            }
             m_terminal = qobject_cast<TerminalInterface*>(m_konsolePart);
+        } else if (!m_konsolePartMissingMessage) {
+            const auto konsoleInstallUrl = QUrl("appstream://org.kde.konsole.desktop");
+            const auto konsoleNotInstalledText = i18n("Terminal cannot be shown because Konsole is not installed. "
+                                                      "Please install it and then reopen the panel.");
+            m_konsolePartMissingMessage = new KMessageWidget(konsoleNotInstalledText, this);
+            m_konsolePartMissingMessage->setCloseButtonVisible(false);
+            m_konsolePartMissingMessage->hide();
+            if (KIO::DesktopExecParser::hasSchemeHandler(konsoleInstallUrl)) {
+                auto installKonsoleAction = new QAction(i18n("Install Konsole"), this);
+                connect(installKonsoleAction, &QAction::triggered, [konsoleInstallUrl]() {
+                    QDesktopServices::openUrl(konsoleInstallUrl);
+                });
+                m_konsolePartMissingMessage->addAction(installKonsoleAction);
+            }
+            m_layout->addWidget(m_konsolePartMissingMessage);
+            m_layout->addStretch();
+            QTimer::singleShot(0, m_konsolePartMissingMessage, &KMessageWidget::animatedShow);
+        } else {
+            m_konsolePartMissingMessage->animatedShow();
         }
     }
     if (m_terminal) {
index b36f24142f8840616709bbc33bdf2711e2d1f225..a6f93d76721deb48ffd1f65f8a337d89acac32a0 100644 (file)
@@ -25,6 +25,7 @@
 #include <QQueue>
 
 class TerminalInterface;
+class KMessageWidget;
 class QVBoxLayout;
 class QWidget;
 
@@ -93,6 +94,7 @@ private:
     QVBoxLayout* m_layout;
     TerminalInterface* m_terminal;
     QWidget* m_terminalWidget;
+    KMessageWidget* m_konsolePartMissingMessage;
     KParts::ReadOnlyPart* m_konsolePart;
     QString m_konsolePartCurrentDirectory;
     QQueue<QString> m_sendCdToTerminalHistory;