mirror of
https://github.com/fergalmoran/flameshot.git
synced 2026-02-14 06:24:02 +00:00
Add base system notifications class
This commit is contained in:
30
src/utils/systemnotification.cpp
Normal file
30
src/utils/systemnotification.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "systemnotification.h"
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusMessage>
|
||||
#include <QDBusInterface>
|
||||
#include <QApplication>
|
||||
|
||||
SystemNotification::SystemNotification(QObject *parent) : QObject(parent) {
|
||||
m_interface = new QDBusInterface("org.freedesktop.Notifications",
|
||||
"/org/freedesktop/Notifications",
|
||||
"org.freedesktop.Notifications",
|
||||
QDBusConnection::sessionBus(),
|
||||
this);
|
||||
}
|
||||
|
||||
void SystemNotification::sendMessage(
|
||||
const QString &text,
|
||||
const QString &title,
|
||||
const int timeout)
|
||||
{
|
||||
QList<QVariant> args;
|
||||
args << (qAppName()) //appname
|
||||
<< static_cast<unsigned int>(0) //id
|
||||
<< "flameshot.png" //icon
|
||||
<< title //summary
|
||||
<< text //body
|
||||
<< QStringList() //actions
|
||||
<< QVariantMap() //hints
|
||||
<< timeout; //timeout
|
||||
m_interface->callWithArgumentList(QDBus::AutoDetect, "Notify", args);
|
||||
}
|
||||
Reference in New Issue
Block a user