Use nemonotifications-qt5 instead of lipstick-qt5-tools for notifications
This commit is contained in:
parent
56e39608e7
commit
082030f1fa
4 changed files with 18 additions and 27 deletions
|
@ -18,8 +18,11 @@ License: GPLv3
|
|||
URL: http://example.org/
|
||||
Source0: %{name}-%{version}.tar.bz2
|
||||
Requires: sailfishsilica-qt5 >= 0.10.9
|
||||
Requires: lipstick-qt5-tools
|
||||
Requires: nemo-qml-plugin-dbus-qt5
|
||||
Requires: nemo-qml-plugin-configuration-qt5
|
||||
Requires: nemo-qml-plugin-notifications-qt5
|
||||
BuildRequires: pkgconfig(sailfishapp) >= 1.0.2
|
||||
BuildRequires: pkgconfig(nemonotifications-qt5)
|
||||
BuildRequires: pkgconfig(Qt5Core)
|
||||
BuildRequires: pkgconfig(Qt5Qml)
|
||||
BuildRequires: pkgconfig(Qt5Quick)
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
TARGET = harbour-batterybuddy-daemon
|
||||
|
||||
CONFIG = qt console c++11 sailfish_build
|
||||
CONFIG = sailfishapp qt console c++11 sailfish_build
|
||||
|
||||
QT = core network
|
||||
QT = core network dbus
|
||||
|
||||
PKGCONFIG += nemonotifications-qt5
|
||||
|
||||
# Keep this in sync with "application.pro"
|
||||
VER = 3.6
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
|
||||
Notification::Notification(QObject* parent) : QObject(parent)
|
||||
{
|
||||
|
||||
notification.setAppName("Battery Buddy");
|
||||
notification.setAppIcon("harbour-batterybuddy");
|
||||
}
|
||||
|
||||
Notification::~Notification()
|
||||
|
@ -34,13 +35,6 @@ void Notification::send(QString title, QString body, QString soundFile)
|
|||
|
||||
QStringList args;
|
||||
|
||||
// Using 'update' works always; it creates a new notification if the ID doesn't match.
|
||||
// notificationtol
|
||||
args << "-o" << "update"
|
||||
<< "-i" << noteID
|
||||
<< "-I" << "/usr/share/icons/hicolor/128x128/apps/harbour-batterybuddy.png"
|
||||
<< "-A" << "\"Battery Buddy\"" << title << body << title << body;
|
||||
|
||||
QProcess aplay;
|
||||
if(!soundFile.isEmpty()) {
|
||||
QStringList aplayArgs;
|
||||
|
@ -48,13 +42,11 @@ void Notification::send(QString title, QString body, QString soundFile)
|
|||
aplay.start("paplay", aplayArgs);
|
||||
}
|
||||
|
||||
QProcess notificationtool;
|
||||
notificationtool.start("notificationtool", args);
|
||||
notificationtool.waitForFinished();
|
||||
|
||||
QString result(notificationtool.readAll());
|
||||
if(!result.isEmpty())
|
||||
noteID = result.split(' ').last().trimmed();
|
||||
notification.setSummary(title);
|
||||
notification.setBody(body);
|
||||
notification.setPreviewSummary(title);
|
||||
notification.setPreviewBody(body);
|
||||
notification.publish();
|
||||
|
||||
// Playing the sound may take a while, so let's do this as late as possible.
|
||||
// Shouldn't matter though, because the minimum delay is 1:00
|
||||
|
@ -65,14 +57,6 @@ void Notification::send(QString title, QString body, QString soundFile)
|
|||
|
||||
void Notification::close()
|
||||
{
|
||||
if(noteID == "1")
|
||||
return;
|
||||
|
||||
QStringList args;
|
||||
args << "-o" << "remove" << "-i" << noteID;
|
||||
QProcess proc;
|
||||
proc.start("notificationtool", args);
|
||||
noteID = 1;
|
||||
proc.waitForFinished();
|
||||
notification.close();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <QObject>
|
||||
#include <QProcess>
|
||||
#include <QTimer>
|
||||
#include <nemonotifications-qt5/notification.h>
|
||||
#include <QDebug>
|
||||
|
||||
class Notification : public QObject
|
||||
|
@ -37,6 +38,7 @@ public slots:
|
|||
|
||||
private:
|
||||
QString noteID = "1";
|
||||
Notification notification;
|
||||
};
|
||||
|
||||
#endif // NOTIFICATION_H
|
||||
|
|
Loading…
Reference in a new issue