diff --git a/src/core/capturerequest.cpp b/src/core/capturerequest.cpp index dfefac83..c8a560a1 100644 --- a/src/core/capturerequest.cpp +++ b/src/core/capturerequest.cpp @@ -85,9 +85,9 @@ void CaptureRequest::exportCapture(const QPixmap& p) { if ((m_tasks & ExportTask::FILESYSTEM_SAVE_TASK) != ExportTask::NO_TASK) { if (m_path.isEmpty()) { - ScreenshotSaver().saveToFilesystemGUI(p); + ScreenshotSaver(m_id).saveToFilesystemGUI(p); } else { - ScreenshotSaver().saveToFilesystem(p, m_path, ""); + ScreenshotSaver(m_id).saveToFilesystem(p, m_path, ""); } } diff --git a/src/core/controller.cpp b/src/core/controller.cpp index 7003c84c..a29887cd 100644 --- a/src/core/controller.cpp +++ b/src/core/controller.cpp @@ -312,6 +312,11 @@ void Controller::showRecentScreenshots() m_history->show(); } +void Controller::sendCaptureSaved(uint id, const QString& savePath) +{ + emit captureSaved(id, savePath); +} + void Controller::startFullscreenCapture(const uint id) { bool ok = true; diff --git a/src/core/controller.h b/src/core/controller.h index ac5445b1..3302407e 100644 --- a/src/core/controller.h +++ b/src/core/controller.h @@ -50,6 +50,7 @@ public: signals: void captureTaken(uint id, QPixmap p, QRect selection); void captureFailed(uint id); + void captureSaved(uint id, QString savePath); public slots: void requestCapture(const CaptureRequest& request); @@ -68,6 +69,8 @@ public slots: void showRecentScreenshots(); + void sendCaptureSaved(uint id, const QString& savePath); + private slots: void startFullscreenCapture(const uint id = 0); void startVisualCapture(const uint id = 0, diff --git a/src/core/flameshotdbusadapter.cpp b/src/core/flameshotdbusadapter.cpp index 5bfb4f85..260ae9c1 100644 --- a/src/core/flameshotdbusadapter.cpp +++ b/src/core/flameshotdbusadapter.cpp @@ -34,6 +34,10 @@ FlameshotDBusAdapter::FlameshotDBusAdapter(QObject* parent) &Controller::captureTaken, this, &FlameshotDBusAdapter::handleCaptureTaken); + connect(controller, + &Controller::captureSaved, + this, + &FlameshotDBusAdapter::captureSaved); } FlameshotDBusAdapter::~FlameshotDBusAdapter() {} diff --git a/src/core/flameshotdbusadapter.h b/src/core/flameshotdbusadapter.h index 46d522d6..ecd32944 100644 --- a/src/core/flameshotdbusadapter.h +++ b/src/core/flameshotdbusadapter.h @@ -32,6 +32,7 @@ public: signals: void captureTaken(uint id, QByteArray rawImage, QRect selection); void captureFailed(uint id); + void captureSaved(uint id, QString savePath); public slots: Q_NOREPLY void graphicCapture(QString path, int delay, uint id); diff --git a/src/utils/screenshotsaver.cpp b/src/utils/screenshotsaver.cpp index f803987a..508bc677 100644 --- a/src/utils/screenshotsaver.cpp +++ b/src/utils/screenshotsaver.cpp @@ -16,6 +16,7 @@ // along with Flameshot. If not, see . #include "screenshotsaver.h" +#include "src/core/controller.h" #include "src/utils/confighandler.h" #include "src/utils/filenamehandler.h" #include "src/utils/systemnotification.h" @@ -25,7 +26,13 @@ #include #include -ScreenshotSaver::ScreenshotSaver() {} +ScreenshotSaver::ScreenshotSaver() + : m_id(0) +{} + +ScreenshotSaver::ScreenshotSaver(const unsigned id) + : m_id(id) +{} // TODO: If data is saved to the clipboard before the notification is sent via // dbus, the application freezes. @@ -63,6 +70,12 @@ bool ScreenshotSaver::saveToFilesystem(const QPixmap& capture, ConfigHandler().setSavePath(path); saveMessage = messagePrefix + QObject::tr("Capture saved as ") + completePath; + QString fileNoPath = + completePath.right(completePath.lastIndexOf(QLatin1String("/"))); + Controller::getInstance()->sendCaptureSaved( + m_id, + QFileInfo(completePath).canonicalPath() + QLatin1String("/") + + fileNoPath); } else { saveMessage = messagePrefix + QObject::tr("Error trying to save as ") + completePath; @@ -103,6 +116,8 @@ bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap& capture) if (ok) { QString pathNoFile = savePath.left(savePath.lastIndexOf(QLatin1String("/"))); + QString fileNoPath = + savePath.right(savePath.lastIndexOf(QLatin1String("/"))); ConfigHandler().setSavePath(pathNoFile); QString msg = QObject::tr("Capture saved as ") + savePath; if (config.copyPathAfterSaveEnabled()) { @@ -112,6 +127,10 @@ bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap& capture) savePath; } SystemNotification().sendMessage(msg, savePath); + Controller::getInstance()->sendCaptureSaved( + m_id, + QFileInfo(savePath).canonicalPath() + QLatin1String("/") + + fileNoPath); } else { QString msg = QObject::tr("Error trying to save as ") + savePath; QMessageBox saveErrBox( diff --git a/src/utils/screenshotsaver.h b/src/utils/screenshotsaver.h index b528cbd7..7b40b787 100644 --- a/src/utils/screenshotsaver.h +++ b/src/utils/screenshotsaver.h @@ -24,10 +24,14 @@ class ScreenshotSaver { public: ScreenshotSaver(); + ScreenshotSaver(const unsigned id); void saveToClipboard(const QPixmap& capture); bool saveToFilesystem(const QPixmap& capture, const QString& path, const QString& messagePrefix); bool saveToFilesystemGUI(const QPixmap& capture); + +private: + unsigned m_id; }; diff --git a/src/widgets/capture/capturewidget.cpp b/src/widgets/capture/capturewidget.cpp index 700a0518..c91fed61 100644 --- a/src/widgets/capture/capturewidget.cpp +++ b/src/widgets/capture/capturewidget.cpp @@ -1108,9 +1108,10 @@ void CaptureWidget::saveScreenshot() } hide(); if (m_context.savePath.isEmpty()) { - ScreenshotSaver().saveToFilesystemGUI(pixmap()); + ScreenshotSaver(m_id).saveToFilesystemGUI(pixmap()); } else { - ScreenshotSaver().saveToFilesystem(pixmap(), m_context.savePath, ""); + ScreenshotSaver(m_id).saveToFilesystem( + pixmap(), m_context.savePath, ""); } close(); }