diff options
| author | Roman Inflianskas <[email protected]> | 2018-03-07 14:35:17 +0300 |
|---|---|---|
| committer | Roman Inflianskas <[email protected]> | 2018-03-11 20:41:54 +0300 |
| commit | 68a924af05e7adf1c36b8139ee33a739298fe36d (patch) | |
| tree | 562914a72b4854a5cf29f7e23a99df2baf003fab /src/panels/terminal/terminalpanel.cpp | |
| parent | c0797e8adef58bc57254d86d6f1abaa46d732f19 (diff) | |
Show a message if Konsole part is not installed
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
Diffstat (limited to 'src/panels/terminal/terminalpanel.cpp')
| -rw-r--r-- | src/panels/terminal/terminalpanel.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/panels/terminal/terminalpanel.cpp b/src/panels/terminal/terminalpanel.cpp index 4f77f6136..d2d569c9f 100644 --- a/src/panels/terminal/terminalpanel.cpp +++ b/src/panels/terminal/terminalpanel.cpp @@ -19,9 +19,12 @@ #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> @@ -29,8 +32,12 @@ #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) { |
