Skip to content

Commit

Permalink
fix: notification interface
Browse files Browse the repository at this point in the history
  • Loading branch information
kate committed Feb 20, 2022
1 parent 1018777 commit 3bb9540
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/notifications.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@
*/

#include "notifications.h"
#include <QSettings>
#include <QDBusInterface>
#include <QDBusPendingCall>

Notifications::Notifications(QObject *parent)
: QObject(parent)
, m_iface("com.cutefish.Notification",
"/Notification",
"com.cutefish.Notification", QDBusConnection::sessionBus())
{
QSettings settings(QSettings::UserScope, "cutefishos", "notification");
m_doNotDisturb = settings.value("DoNotDisturb", false).toBool();
m_doNotDisturb = m_iface.property("doNotDisturb").toBool();

QDBusConnection::sessionBus().connect("com.cutefish.Notification",
"/Notification",
"com.cutefish.Notification",
"doNotDisturbChanged", this, SLOT(onDBusDoNotDisturbChanged()));
}

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

emit doNotDisturbChanged();
}

void Notifications::onDBusDoNotDisturbChanged()
{
m_doNotDisturb = m_iface.property("doNotDisturb").toBool();
emit doNotDisturbChanged();
}
6 changes: 6 additions & 0 deletions src/notifications.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#define NOTIFICATIONS_H

#include <QObject>
#include <QDBusInterface>
#include <QDBusPendingCall>

class Notifications : public QObject
{
Expand All @@ -33,10 +35,14 @@ class Notifications : public QObject
bool doNotDisturb() const;
void setDoNotDisturb(bool enabled);

private slots:
void onDBusDoNotDisturbChanged();

signals:
void doNotDisturbChanged();

private:
QDBusInterface m_iface;
bool m_doNotDisturb;
};

Expand Down

0 comments on commit 3bb9540

Please sign in to comment.