Allow notification to be dragged and dropped (#473)

* Set x-kde-urls for notifications

The x-kde-urls field in the hints map allows us to provide a direct URL
to the saved screenshot. The notification server may then use this hint
to provide extra functionality, such as drag and drop support and
thumbnails.

For more information see https://community.kde.org/Plasma/Notifications#File_Path

Fixes #256

Note that other notification servers may ignore this hint.

* Avoid branching twice for ok
This commit is contained in:
Magnus Groß
2019-03-20 22:41:55 +01:00
committed by Dharkael
parent a653d5a6d2
commit 5174f8dc1b
3 changed files with 18 additions and 6 deletions

View File

@@ -41,15 +41,17 @@ bool ScreenshotSaver::saveToFilesystem(const QPixmap &capture,
completePath += QLatin1String(".png");
bool ok = capture.save(completePath);
QString saveMessage;
QString notificationPath = completePath;
if (ok) {
ConfigHandler().setSavePath(path);
saveMessage = QObject::tr("Capture saved as ") + completePath;
} else {
saveMessage = QObject::tr("Error trying to save as ") + completePath;
notificationPath = "";
}
SystemNotification().sendMessage(saveMessage);
SystemNotification().sendMessage(saveMessage, notificationPath);
return ok;
}
@@ -80,7 +82,7 @@ bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap &capture) {
QString pathNoFile = savePath.left(savePath.lastIndexOf(QLatin1String("/")));
ConfigHandler().setSavePath(pathNoFile);
QString msg = QObject::tr("Capture saved as ") + savePath;
SystemNotification().sendMessage(msg);
SystemNotification().sendMessage(msg, savePath);
} else {
QString msg = QObject::tr("Error trying to save as ") + savePath;
QMessageBox saveErrBox(