Skip to content

Commit 3bb9540

Browse files
author
kate
committed
fix: notification interface
1 parent 1018777 commit 3bb9540

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/notifications.cpp

+15-5
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,19 @@
1818
*/
1919

2020
#include "notifications.h"
21-
#include <QSettings>
22-
#include <QDBusInterface>
23-
#include <QDBusPendingCall>
2421

2522
Notifications::Notifications(QObject *parent)
2623
: QObject(parent)
24+
, m_iface("com.cutefish.Notification",
25+
"/Notification",
26+
"com.cutefish.Notification", QDBusConnection::sessionBus())
2727
{
28-
QSettings settings(QSettings::UserScope, "cutefishos", "notification");
29-
m_doNotDisturb = settings.value("DoNotDisturb", false).toBool();
28+
m_doNotDisturb = m_iface.property("doNotDisturb").toBool();
29+
30+
QDBusConnection::sessionBus().connect("com.cutefish.Notification",
31+
"/Notification",
32+
"com.cutefish.Notification",
33+
"doNotDisturbChanged", this, SLOT(onDBusDoNotDisturbChanged()));
3034
}
3135

3236
bool Notifications::doNotDisturb() const
@@ -48,3 +52,9 @@ void Notifications::setDoNotDisturb(bool enabled)
4852

4953
emit doNotDisturbChanged();
5054
}
55+
56+
void Notifications::onDBusDoNotDisturbChanged()
57+
{
58+
m_doNotDisturb = m_iface.property("doNotDisturb").toBool();
59+
emit doNotDisturbChanged();
60+
}

src/notifications.h

+6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#define NOTIFICATIONS_H
2222

2323
#include <QObject>
24+
#include <QDBusInterface>
25+
#include <QDBusPendingCall>
2426

2527
class Notifications : public QObject
2628
{
@@ -33,10 +35,14 @@ class Notifications : public QObject
3335
bool doNotDisturb() const;
3436
void setDoNotDisturb(bool enabled);
3537

38+
private slots:
39+
void onDBusDoNotDisturbChanged();
40+
3641
signals:
3742
void doNotDisturbChanged();
3843

3944
private:
45+
QDBusInterface m_iface;
4046
bool m_doNotDisturb;
4147
};
4248

0 commit comments

Comments
 (0)