From 635c2a3eef336f0710c24434901d953cd16bf844 Mon Sep 17 00:00:00 2001 From: Mikko Vedru Date: Mon, 11 Jan 2021 06:38:46 +0200 Subject: [PATCH 1/4] Add info about flameshot.ini config file --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 60afe623..d181a2d6 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ - [Features](#features) - [Usage](#usage) - [CLI configuration](#cli-configuration) + - [Config file](#config-file) - [Keyboard Shortcuts](#keyboard-shortcuts) - [Local](#local) - [Global](#global) @@ -161,6 +162,10 @@ You can use the graphical menu to configure Flameshot, but alternatively you can flameshot config -h ``` +### Config file +You can also edit some of the settings (like overriding the default colors) in the configuration file located at `~/.config/flameshot/flameshot.ini`. + + ## Keyboard shortcuts ### Local From e07829ec55c7d7ba39565beeded5d029a2aff7ce Mon Sep 17 00:00:00 2001 From: brimston3 Date: Thu, 14 Jan 2021 18:45:00 -0500 Subject: [PATCH 2/4] Emit dbus captureSaved signal when saving files New captureSaved signal contains the request ID and canonical path of the saved file. This allows a dbus listener interested in postprocessing files access to the path most recently written. --- src/core/capturerequest.cpp | 4 ++-- src/core/controller.cpp | 5 +++++ src/core/controller.h | 3 +++ src/core/flameshotdbusadapter.cpp | 4 ++++ src/core/flameshotdbusadapter.h | 1 + src/utils/screenshotsaver.cpp | 21 ++++++++++++++++++++- src/utils/screenshotsaver.h | 4 ++++ src/widgets/capture/capturewidget.cpp | 5 +++-- 8 files changed, 42 insertions(+), 5 deletions(-) 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(); } From e2bd91a1de91f8ce6b0ccca1f34896b22ec609cf Mon Sep 17 00:00:00 2001 From: brimston3 Date: Thu, 14 Jan 2021 19:35:17 -0500 Subject: [PATCH 3/4] Add captureSaved to dbus interface description --- data/dbus/org.flameshot.Flameshot.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/data/dbus/org.flameshot.Flameshot.xml b/data/dbus/org.flameshot.Flameshot.xml index 3a3beedc..2a922026 100644 --- a/data/dbus/org.flameshot.Flameshot.xml +++ b/data/dbus/org.flameshot.Flameshot.xml @@ -115,5 +115,17 @@ + + + + + + From 7f55d0c672c9b2d04c45eaaca70e98c61f7dabd0 Mon Sep 17 00:00:00 2001 From: brimston3 Date: Thu, 14 Jan 2021 22:22:21 -0500 Subject: [PATCH 4/4] Simplify canonical path generation slightly --- src/utils/screenshotsaver.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/utils/screenshotsaver.cpp b/src/utils/screenshotsaver.cpp index 508bc677..3a0d40d0 100644 --- a/src/utils/screenshotsaver.cpp +++ b/src/utils/screenshotsaver.cpp @@ -70,12 +70,8 @@ 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); + m_id, QFileInfo(completePath).canonicalFilePath()); } else { saveMessage = messagePrefix + QObject::tr("Error trying to save as ") + completePath; @@ -116,8 +112,6 @@ 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()) { @@ -128,9 +122,7 @@ bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap& capture) } SystemNotification().sendMessage(msg, savePath); Controller::getInstance()->sendCaptureSaved( - m_id, - QFileInfo(savePath).canonicalPath() + QLatin1String("/") + - fileNoPath); + m_id, QFileInfo(savePath).canonicalFilePath()); } else { QString msg = QObject::tr("Error trying to save as ") + savePath; QMessageBox saveErrBox(