Fixed it so a notification is always sent when saved to clipboard

This commit is contained in:
Jeremy Borgman
2020-09-10 09:50:24 -05:00
parent 72f52ac3ed
commit 9bc4ea5700
5 changed files with 26 additions and 14 deletions

View File

@@ -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 = "";
}