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/
|
URL: http://example.org/
|
||||||
Source0: %{name}-%{version}.tar.bz2
|
Source0: %{name}-%{version}.tar.bz2
|
||||||
Requires: sailfishsilica-qt5 >= 0.10.9
|
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(sailfishapp) >= 1.0.2
|
||||||
|
BuildRequires: pkgconfig(nemonotifications-qt5)
|
||||||
BuildRequires: pkgconfig(Qt5Core)
|
BuildRequires: pkgconfig(Qt5Core)
|
||||||
BuildRequires: pkgconfig(Qt5Qml)
|
BuildRequires: pkgconfig(Qt5Qml)
|
||||||
BuildRequires: pkgconfig(Qt5Quick)
|
BuildRequires: pkgconfig(Qt5Quick)
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
TARGET = harbour-batterybuddy-daemon
|
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"
|
# Keep this in sync with "application.pro"
|
||||||
VER = 3.6
|
VER = 3.6
|
||||||
|
|
|
@ -19,7 +19,8 @@
|
||||||
|
|
||||||
Notification::Notification(QObject* parent) : QObject(parent)
|
Notification::Notification(QObject* parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
|
notification.setAppName("Battery Buddy");
|
||||||
|
notification.setAppIcon("harbour-batterybuddy");
|
||||||
}
|
}
|
||||||
|
|
||||||
Notification::~Notification()
|
Notification::~Notification()
|
||||||
|
@ -34,13 +35,6 @@ void Notification::send(QString title, QString body, QString soundFile)
|
||||||
|
|
||||||
QStringList args;
|
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;
|
QProcess aplay;
|
||||||
if(!soundFile.isEmpty()) {
|
if(!soundFile.isEmpty()) {
|
||||||
QStringList aplayArgs;
|
QStringList aplayArgs;
|
||||||
|
@ -48,13 +42,11 @@ void Notification::send(QString title, QString body, QString soundFile)
|
||||||
aplay.start("paplay", aplayArgs);
|
aplay.start("paplay", aplayArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
QProcess notificationtool;
|
notification.setSummary(title);
|
||||||
notificationtool.start("notificationtool", args);
|
notification.setBody(body);
|
||||||
notificationtool.waitForFinished();
|
notification.setPreviewSummary(title);
|
||||||
|
notification.setPreviewBody(body);
|
||||||
QString result(notificationtool.readAll());
|
notification.publish();
|
||||||
if(!result.isEmpty())
|
|
||||||
noteID = result.split(' ').last().trimmed();
|
|
||||||
|
|
||||||
// Playing the sound may take a while, so let's do this as late as possible.
|
// 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
|
// 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()
|
void Notification::close()
|
||||||
{
|
{
|
||||||
if(noteID == "1")
|
notification.close();
|
||||||
return;
|
|
||||||
|
|
||||||
QStringList args;
|
|
||||||
args << "-o" << "remove" << "-i" << noteID;
|
|
||||||
QProcess proc;
|
|
||||||
proc.start("notificationtool", args);
|
|
||||||
noteID = 1;
|
|
||||||
proc.waitForFinished();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <nemonotifications-qt5/notification.h>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
class Notification : public QObject
|
class Notification : public QObject
|
||||||
|
@ -37,6 +38,7 @@ public slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString noteID = "1";
|
QString noteID = "1";
|
||||||
|
Notification notification;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NOTIFICATION_H
|
#endif // NOTIFICATION_H
|
||||||
|
|
Loading…
Reference in a new issue