diff --git a/src/Gui/KSMainWindow.h b/src/Gui/KSMainWindow.h --- a/src/Gui/KSMainWindow.h +++ b/src/Gui/KSMainWindow.h @@ -61,7 +61,8 @@ }; void showInlineMessage(const QString& message, const KMessageWidget::MessageType messageType, - const MessageDuration messageDuration = MessageDuration::AutoHide); + const MessageDuration messageDuration = MessageDuration::AutoHide, + const QList& actions = {}); private Q_SLOTS: @@ -80,7 +81,7 @@ public Q_SLOTS: void setScreenshotAndShow(const QPixmap &pixmap); - void setScreenshotWindowTitle(const QUrl &location); + void imageSaved(const QUrl &location); Q_SIGNALS: diff --git a/src/Gui/KSMainWindow.cpp b/src/Gui/KSMainWindow.cpp --- a/src/Gui/KSMainWindow.cpp +++ b/src/Gui/KSMainWindow.cpp @@ -120,7 +120,7 @@ // change window title on save - connect(ExportManager::instance(), &ExportManager::imageSaved, this, &KSMainWindow::setScreenshotWindowTitle); + connect(ExportManager::instance(), &ExportManager::imageSaved, this, &KSMainWindow::imageSaved); // the KSGWidget @@ -339,8 +339,15 @@ // is not working quite right, see Bug #389694 which needs fixing. } -void KSMainWindow::showInlineMessage(const QString& message, const KMessageWidget::MessageType messageType, const MessageDuration messageDuration) +void KSMainWindow::showInlineMessage(const QString& message, const KMessageWidget::MessageType messageType, + const MessageDuration messageDuration, const QList& actions) { + for (QAction* action: mMessageWidget->actions()) { + mMessageWidget->removeAction(action); + } + for (QAction* action : actions) { + mMessageWidget->addAction(action); + } mMessageWidget->setText(message); mMessageWidget->setMessageType(messageType); @@ -398,10 +405,15 @@ prefDialog.exec(); } -void KSMainWindow::setScreenshotWindowTitle(const QUrl &location) +void KSMainWindow::imageSaved(const QUrl &location) { setWindowTitle(location.fileName()); setWindowModified(false); + QAction* openContaining = new QAction(i18n("Open Containing Folder"), mMessageWidget); + connect(openContaining, &QAction::triggered, [=] { KIO::highlightInFileManager({location});}); + showInlineMessage(i18n("The screenshot was saved as %2", + location.toLocalFile(), location.fileName()), KMessageWidget::Positive, + MessageDuration::AutoHide, {openContaining}); } void KSMainWindow::save()