mirror of
https://github.com/fergalmoran/flameshot.git
synced 2025-12-30 13:49:48 +00:00
Fixed it so a notification is always sent when saved to clipboard
This commit is contained in:
@@ -95,7 +95,7 @@ CaptureRequest::exportCapture(const QPixmap& p)
|
||||
if (m_path.isEmpty()) {
|
||||
ScreenshotSaver().saveToFilesystemGUI(p);
|
||||
} else {
|
||||
ScreenshotSaver().saveToFilesystem(p, m_path);
|
||||
ScreenshotSaver().saveToFilesystem(p, m_path, "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ SaveTool::pressed(const CaptureContext& context)
|
||||
}
|
||||
} else {
|
||||
bool ok = ScreenshotSaver().saveToFilesystem(
|
||||
context.selectedScreenshotArea(), context.savePath);
|
||||
context.selectedScreenshotArea(), context.savePath, "");
|
||||
if (ok) {
|
||||
emit requestAction(REQ_CAPTURE_DONE_OK);
|
||||
}
|
||||
|
||||
@@ -30,19 +30,27 @@ ScreenshotSaver::ScreenshotSaver() {}
|
||||
void
|
||||
ScreenshotSaver::saveToClipboard(const QPixmap& capture)
|
||||
{
|
||||
if (ConfigHandler().saveAfterCopyValue()) {
|
||||
if (!ConfigHandler().saveAfterCopyPathValue().isEmpty()) {
|
||||
saveToFilesystem(capture, ConfigHandler().saveAfterCopyPathValue());
|
||||
}
|
||||
} else {
|
||||
|
||||
// If we are able to properly save the file, save the file and copy to
|
||||
// clipboard.
|
||||
if ((ConfigHandler().saveAfterCopyValue()) &&
|
||||
(!ConfigHandler().saveAfterCopyPathValue().isEmpty())) {
|
||||
QApplication::clipboard()->setPixmap(capture);
|
||||
saveToFilesystem(capture,
|
||||
ConfigHandler().saveAfterCopyPathValue(),
|
||||
QObject::tr("Capture saved to clipboard. "));
|
||||
}
|
||||
// Otherwise only save to clipboard
|
||||
else {
|
||||
QApplication::clipboard()->setPixmap(capture);
|
||||
SystemNotification().sendMessage(QObject::tr("Capture saved to clipboard"));
|
||||
}
|
||||
|
||||
QApplication::clipboard()->setPixmap(capture);
|
||||
}
|
||||
|
||||
bool
|
||||
ScreenshotSaver::saveToFilesystem(const QPixmap& capture, const QString& path)
|
||||
ScreenshotSaver::saveToFilesystem(const QPixmap& capture,
|
||||
const QString& path,
|
||||
const QString& messagePrefix)
|
||||
{
|
||||
QString completePath = FileNameHandler().generateAbsolutePath(path);
|
||||
completePath += QLatin1String(".png");
|
||||
@@ -52,9 +60,11 @@ ScreenshotSaver::saveToFilesystem(const QPixmap& capture, const QString& path)
|
||||
|
||||
if (ok) {
|
||||
ConfigHandler().setSavePath(path);
|
||||
saveMessage = QObject::tr("Capture saved as ") + completePath;
|
||||
saveMessage =
|
||||
messagePrefix + QObject::tr("Capture saved as ") + completePath;
|
||||
} else {
|
||||
saveMessage = QObject::tr("Error trying to save as ") + completePath;
|
||||
saveMessage =
|
||||
messagePrefix + QObject::tr("Error trying to save as ") + completePath;
|
||||
notificationPath = "";
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ public:
|
||||
ScreenshotSaver();
|
||||
|
||||
void saveToClipboard(const QPixmap& capture);
|
||||
bool saveToFilesystem(const QPixmap& capture, const QString& path);
|
||||
bool saveToFilesystem(const QPixmap& capture,
|
||||
const QString& path,
|
||||
const QString& messagePrefix);
|
||||
bool saveToFilesystemGUI(const QPixmap& capture);
|
||||
};
|
||||
|
||||
@@ -1011,7 +1011,7 @@ CaptureWidget::saveScreenshot()
|
||||
if (m_context.savePath.isEmpty()) {
|
||||
ScreenshotSaver().saveToFilesystemGUI(pixmap());
|
||||
} else {
|
||||
ScreenshotSaver().saveToFilesystem(pixmap(), m_context.savePath);
|
||||
ScreenshotSaver().saveToFilesystem(pixmap(), m_context.savePath, "");
|
||||
}
|
||||
close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user