diff --git a/src/ExportManager.h b/src/ExportManager.h --- a/src/ExportManager.h +++ b/src/ExportManager.h @@ -74,6 +74,7 @@ void errorMessage(const QString &str); void pixmapChanged(const QPixmap &pixmap); void imageSaved(const QUrl &savedAt); + void imageCopied(); void imageSavedAndCopied(const QUrl &savedAt); void forceNotify(const QUrl &savedAt); @@ -86,7 +87,7 @@ void doSave(const QUrl &url = QUrl(), bool notify = false); bool doSaveAs(QWidget *parentWindow = nullptr, bool notify = false); void doSaveAndCopy(const QUrl &url = QUrl()); - void doCopyToClipboard(bool notify); + void doCopyToClipboard(bool notify = false); void doPrint(QPrinter *printer); private: diff --git a/src/ExportManager.cpp b/src/ExportManager.cpp --- a/src/ExportManager.cpp +++ b/src/ExportManager.cpp @@ -530,7 +530,7 @@ data->setImageData(mSavePixmap.toImage()); data->setData(QStringLiteral("x-kde-force-image-copy"), QByteArray()); QApplication::clipboard()->setMimeData(data, QClipboard::Clipboard); - + emit imageCopied(); if (notify) { emit forceNotify(QUrl()); } diff --git a/src/Gui/KSMainWindow.h b/src/Gui/KSMainWindow.h --- a/src/Gui/KSMainWindow.h +++ b/src/Gui/KSMainWindow.h @@ -52,27 +52,26 @@ Persistent }; - void showInlineMessage(const QString& message, - const KMessageWidget::MessageType messageType, - const MessageDuration messageDuration = MessageDuration::AutoHide, - const QList& actions = {}); - private: enum class QuitBehavior { QuitImmediately, QuitExternally }; void quit(const QuitBehavior quitBehavior = QuitBehavior::QuitImmediately); + void showInlineMessage(const QString& message, + const KMessageWidget::MessageType messageType, + const MessageDuration messageDuration = MessageDuration::AutoHide, + const QList& actions = {}); private Q_SLOTS: void captureScreenshot(Spectacle::CaptureMode theCaptureMode, int theTimeout, bool theIncludePointer, bool theIncludeDecorations); void showPrintDialog(); void openScreenshotsFolder(); void showPreferencesDialog(); void showImageSharedFeedback(bool error, const QString &message); - void sendToClipboard(); + void imageCopied(); void init(); void setDefaultSaveAction(); void save(); diff --git a/src/Gui/KSMainWindow.cpp b/src/Gui/KSMainWindow.cpp --- a/src/Gui/KSMainWindow.cpp +++ b/src/Gui/KSMainWindow.cpp @@ -125,6 +125,7 @@ // change window title on save and on autosave connect(ExportManager::instance(), &ExportManager::imageSaved, this, &KSMainWindow::imageSaved); + connect(ExportManager::instance(), &ExportManager::imageCopied, this, &KSMainWindow::imageCopied); connect(ExportManager::instance(), &ExportManager::imageSavedAndCopied, this, &KSMainWindow::imageSavedAndCopied); // the KSGWidget @@ -152,7 +153,7 @@ mSendToButton->setIcon(QIcon::fromTheme(QStringLiteral("document-share"))); mDialogButtonBox->addButton(mSendToButton, QDialogButtonBox::ActionRole); - mClipboardButton->setDefaultAction(KStandardAction::copy(this, SLOT(sendToClipboard()), this)); + mClipboardButton->setDefaultAction(KStandardAction::copy(ExportManager::instance(), &ExportManager::doCopyToClipboard, this)); mClipboardButton->setText(i18n("Copy to Clipboard")); mClipboardButton->setToolTip(i18n("Copy the current screenshot image to the clipboard.")); mClipboardButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); @@ -461,11 +462,8 @@ } } -void KSMainWindow::sendToClipboard() +void KSMainWindow::imageCopied() { - bool notify = false; - ExportManager::instance()->doCopyToClipboard(notify); - SpectacleConfig::instance()->quitAfterSaveOrCopyChecked() ? quit() : showInlineMessage(i18n("The screenshot has been copied to the clipboard."), diff --git a/src/SpectacleCore.cpp b/src/SpectacleCore.cpp --- a/src/SpectacleCore.cpp +++ b/src/SpectacleCore.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -273,8 +272,6 @@ lExportManager->doSave(); } else if (copyImageToClipboard) { lExportManager->doCopyToClipboard(false); - mMainWindow->showInlineMessage(i18n("The screenshot has been copied to the clipboard."), - KMessageWidget::Information); } } }