diff --git a/src/ExportManager.h b/src/ExportManager.h --- a/src/ExportManager.h +++ b/src/ExportManager.h @@ -81,7 +81,7 @@ void doSave(const QUrl &url = QUrl(), bool notify = false); bool doSaveAs(QWidget *parentWindow = nullptr, bool notify = false); - void doCopyToClipboard(); + void doCopyToClipboard(bool notify); void doPrint(QPrinter *printer); private: diff --git a/src/ExportManager.cpp b/src/ExportManager.cpp --- a/src/ExportManager.cpp +++ b/src/ExportManager.cpp @@ -487,9 +487,13 @@ // misc helpers -void ExportManager::doCopyToClipboard() +void ExportManager::doCopyToClipboard(bool notify) { QApplication::clipboard()->setPixmap(mSavePixmap, QClipboard::Clipboard); + + if (notify) { + emit forceNotify(QUrl()); + } } void ExportManager::doPrint(QPrinter *printer) diff --git a/src/Gui/KSMainWindow.cpp b/src/Gui/KSMainWindow.cpp --- a/src/Gui/KSMainWindow.cpp +++ b/src/Gui/KSMainWindow.cpp @@ -389,7 +389,8 @@ void KSMainWindow::sendToClipboard() { - ExportManager::instance()->doCopyToClipboard(); + bool notify = false; + ExportManager::instance()->doCopyToClipboard(notify); SpectacleConfig::instance()->quitAfterSaveOrCopyChecked() ? quit() diff --git a/src/SpectacleCore.cpp b/src/SpectacleCore.cpp --- a/src/SpectacleCore.cpp +++ b/src/SpectacleCore.cpp @@ -219,12 +219,12 @@ } if (copyToClipboard) { - mExportManager->doCopyToClipboard(); + mExportManager->doCopyToClipboard(mNotify); } else { QUrl savePath = (mStartMode == BackgroundMode && mFileNameUrl.isValid() && mFileNameUrl.isLocalFile()) ? mFileNameUrl : QUrl(); mExportManager->doSave(savePath); - } + } // if we notify, we emit allDone only if the user either dismissed the notification or pressed // the "Open" button, otherwise the app closes before it can react to it. @@ -283,15 +283,19 @@ const QString &path = savedAt.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash).path(); - // a speaking message is prettier than a URL, special case for the default pictures location - if (path == QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)) { + // a speaking message is prettier than a URL, special case for copy to clipboard and the default pictures location + if (copyToClipboard) { + notify->setText(i18n("A screenshot was saved to your clipboard.")); + } else if (path == QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)) { notify->setText(i18nc("Placeholder is filename", "A screenshot was saved as '%1' to your Pictures folder.", savedAt.fileName())); } else { notify->setText(i18n("A screenshot was saved as '%1' to '%2'.", savedAt.fileName(), path)); } - notify->setActions({i18nc("Open the screenshot we just saved", "Open")}); - notify->setUrls({savedAt}); + if (!copyToClipboard) { + notify->setActions({i18nc("Open the screenshot we just saved", "Open")}); + notify->setUrls({savedAt}); + } connect(notify, &KNotification::action1Activated, this, [this, savedAt] { new KRun(savedAt, nullptr);