mirror of
https://github.com/fergalmoran/flameshot.git
synced 2026-02-14 06:24:02 +00:00
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:
@@ -1,6 +1,7 @@
|
||||
#include "systemnotification.h"
|
||||
#include "src/utils/confighandler.h"
|
||||
#include <QApplication>
|
||||
#include <QUrl>
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
#include <QDBusConnection>
|
||||
@@ -24,13 +25,14 @@ SystemNotification::SystemNotification(QObject *parent) : QObject(parent) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void SystemNotification::sendMessage(const QString &text) {
|
||||
sendMessage(text, tr("Flameshot Info"));
|
||||
void SystemNotification::sendMessage(const QString &text, const QString &savePath) {
|
||||
sendMessage(text, tr("Flameshot Info"), savePath);
|
||||
}
|
||||
|
||||
void SystemNotification::sendMessage(
|
||||
const QString &text,
|
||||
const QString &title,
|
||||
const QString &savePath,
|
||||
const int timeout)
|
||||
{
|
||||
if(!ConfigHandler().desktopNotificationValue()) {
|
||||
@@ -39,13 +41,19 @@ void SystemNotification::sendMessage(
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
QList<QVariant> args;
|
||||
QVariantMap hintsMap;
|
||||
if (!savePath.isEmpty()) {
|
||||
QUrl fullPath = QUrl::fromLocalFile(savePath);
|
||||
// allows the notification to be dragged and dropped
|
||||
hintsMap[QStringLiteral("x-kde-urls")] = QStringList({fullPath.toString()});
|
||||
}
|
||||
args << (qAppName()) //appname
|
||||
<< static_cast<unsigned int>(0) //id
|
||||
<< "flameshot" //icon
|
||||
<< title //summary
|
||||
<< text //body
|
||||
<< QStringList() //actions
|
||||
<< QVariantMap() //hints
|
||||
<< hintsMap //hints
|
||||
<< timeout; //timeout
|
||||
m_interface->callWithArgumentList(QDBus::AutoDetect, QStringLiteral("Notify"), args);
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user