File tree 2 files changed +21
-5
lines changed
2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change 18
18
*/
19
19
20
20
#include " notifications.h"
21
- #include < QSettings>
22
- #include < QDBusInterface>
23
- #include < QDBusPendingCall>
24
21
25
22
Notifications::Notifications (QObject *parent)
26
23
: QObject(parent)
24
+ , m_iface(" com.cutefish.Notification" ,
25
+ " /Notification" ,
26
+ " com.cutefish.Notification" , QDBusConnection::sessionBus())
27
27
{
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 ()));
30
34
}
31
35
32
36
bool Notifications::doNotDisturb () const
@@ -48,3 +52,9 @@ void Notifications::setDoNotDisturb(bool enabled)
48
52
49
53
emit doNotDisturbChanged ();
50
54
}
55
+
56
+ void Notifications::onDBusDoNotDisturbChanged ()
57
+ {
58
+ m_doNotDisturb = m_iface.property (" doNotDisturb" ).toBool ();
59
+ emit doNotDisturbChanged ();
60
+ }
Original file line number Diff line number Diff line change 21
21
#define NOTIFICATIONS_H
22
22
23
23
#include < QObject>
24
+ #include < QDBusInterface>
25
+ #include < QDBusPendingCall>
24
26
25
27
class Notifications : public QObject
26
28
{
@@ -33,10 +35,14 @@ class Notifications : public QObject
33
35
bool doNotDisturb () const ;
34
36
void setDoNotDisturb (bool enabled);
35
37
38
+ private slots:
39
+ void onDBusDoNotDisturbChanged ();
40
+
36
41
signals:
37
42
void doNotDisturbChanged ();
38
43
39
44
private:
45
+ QDBusInterface m_iface;
40
46
bool m_doNotDisturb;
41
47
};
42
48
You can’t perform that action at this time.
0 commit comments