diff --git a/src/SpectacleCore.cpp b/src/SpectacleCore.cpp --- a/src/SpectacleCore.cpp +++ b/src/SpectacleCore.cpp @@ -184,7 +184,7 @@ case DBusMode: { if (mNotify) { - connect(mExportManager, &ExportManager::imageSaved, this, &SpectacleCore::doNotify); + connect(mExportManager, &ExportManager::imageSaved, this, &SpectacleCore::doNotify, Qt::UniqueConnection); } QUrl savePath = (mStartMode == BackgroundMode && mFileNameUrl.isValid() && mFileNameUrl.isLocalFile()) ? @@ -219,7 +219,9 @@ void SpectacleCore::doNotify(const QUrl &savedAt) { - KNotification *notify = new KNotification(QStringLiteral("newScreenshotSaved")); + static KNotification *notify = new KNotification(QStringLiteral("newScreenshotSaved"), + KNotification::CloseOnTimeout|KNotification::SkipGrouping); + static bool notified = false; switch(mImageGrabber->grabMode()) { case ImageGrabber::GrabMode::FullScreen: @@ -253,12 +255,18 @@ notify->setActions({i18nc("Open the screenshot we just saved", "Open")}); notify->setUrls({savedAt}); - connect(notify, &KNotification::action1Activated, this, [this, savedAt] { - new KRun(savedAt, nullptr); - QTimer::singleShot(250, this, &SpectacleCore::allDone); + connect(notify, &KNotification::action1Activated, this, [this] { + connect(new KRun(mExportManager->lastSavePath(), nullptr), + &KRun::finished, this, &SpectacleCore::allDone); }); - connect(notify, &QObject::destroyed, this, &SpectacleCore::allDone); + if(notified) { + notify->close(); + } + + notified = true; + + connect(notify, &KNotification::closed, this, &SpectacleCore::allDone); notify->sendEvent(); }