summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Sterna <tomek@xiaoka.com>2015-05-18 09:35:38 +0200
committerTomasz Sterna <tomek@xiaoka.com>2015-05-18 09:39:42 +0200
commit7116e096e1288170da3820c77e41e377f9bd69be (patch)
treed6f826b7703a388018894033b95d61d745448588
parent37bc0ef733843f27eb6228f3ee149094e7f62383 (diff)
Save default settings to DConf if not present
-rw-r--r--app/qml/pages/ManagerPage.qml22
-rw-r--r--daemon/manager.cpp3
-rw-r--r--daemon/musicmanager.cpp4
-rw-r--r--daemon/notificationmanager.cpp21
-rw-r--r--daemon/settings.h19
5 files changed, 37 insertions, 32 deletions
diff --git a/app/qml/pages/ManagerPage.qml b/app/qml/pages/ManagerPage.qml
index b989c64..a69bc89 100644
--- a/app/qml/pages/ManagerPage.qml
+++ b/app/qml/pages/ManagerPage.qml
@@ -12,17 +12,17 @@ Page {
path: "/org/pebbled/settings"
property string profileWhenConnected: ""
property string profileWhenDisconnected: ""
- property bool transliterateMessage: false
- property bool useSystemVolume: true
- property bool incomingCallNotification: true
- property bool notificationsCommhistoryd: true
- property bool notificationsMissedCall: true
- property bool notificationsEmails: false
- property bool notificationsMitakuuluu: true
- property bool notificationsTwitter: true
- property bool notificationsFacebook: true
- property bool notificationsOther: true
- property bool notificationsAll: false
+ property bool transliterateMessage
+ property bool useSystemVolume
+ property bool incomingCallNotification
+ property bool notificationsCommhistoryd
+ property bool notificationsMissedCall
+ property bool notificationsEmails
+ property bool notificationsMitakuuluu
+ property bool notificationsTwitter
+ property bool notificationsFacebook
+ property bool notificationsOther
+ property bool notificationsAll
}
DBusInterface {
diff --git a/daemon/manager.cpp b/daemon/manager.cpp
index e6ebf26..93b6b13 100644
--- a/daemon/manager.cpp
+++ b/daemon/manager.cpp
@@ -130,8 +130,7 @@ void Manager::onActiveVoiceCallChanged()
{
qCDebug(l) << "Manager::onActiveVoiceCallChanged()";
- QVariant incomingCallNotification = settings->property("incomingCallNotification");
- if (incomingCallNotification.isValid() && !incomingCallNotification.toBool()) {
+ if (!settings->property("incomingCallNotification").toBool()) {
qCDebug(l) << "Ignoring ActiveVoiceCallChanged because of setting!";
return;
}
diff --git a/daemon/musicmanager.cpp b/daemon/musicmanager.cpp
index 5ae1786..2a426db 100644
--- a/daemon/musicmanager.cpp
+++ b/daemon/musicmanager.cpp
@@ -148,11 +148,9 @@ void MusicManager::callMprisMethod(const QString &method)
void MusicManager::handleMusicControl(WatchConnector::MusicControl operation)
{
qCDebug(l) << "operation from watch:" << operation;
- QVariant useSystemVolumeVar = settings->property("useSystemVolume");
- bool useSystemVolume = (useSystemVolumeVar.isValid() && useSystemVolumeVar.toBool());
// System volume controls
- if (useSystemVolume && _pulseBus != NULL &&
+ if (settings->property("useSystemVolume").toBool() && _pulseBus != NULL &&
(operation == WatchConnector::musicVOLUME_UP || operation == WatchConnector::musicVOLUME_DOWN)) {
// Query current volume
QDBusMessage call = QDBusMessage::createMethodCall("com.Meego.MainVolume2", "/com/meego/mainvolume2",
diff --git a/daemon/notificationmanager.cpp b/daemon/notificationmanager.cpp
index d983539..d357a3c 100644
--- a/daemon/notificationmanager.cpp
+++ b/daemon/notificationmanager.cpp
@@ -126,8 +126,7 @@ uint NotificationManager::Notify(const QString &app_name, uint replaces_id, cons
setDelayedReply(true);
if (app_name == "messageserver5") {
- QVariant notificationsEmails = settings->property("notificationsEmails");
- if (!notificationsEmails.isValid() || !notificationsEmails.toBool()) {
+ if (!settings->property("notificationsEmails").toBool()) {
qCDebug(l) << "Ignoring email notification because of setting!";
return 0;
}
@@ -149,14 +148,12 @@ uint NotificationManager::Notify(const QString &app_name, uint replaces_id, cons
QString category = hints.value("category", "").toString();
if (category == "x-nemo.call.missed") {
- QVariant notificationsMissedCall = settings->property("notificationsMissedCall");
- if (notificationsMissedCall.isValid() && !notificationsMissedCall.toBool()) {
+ if (!settings->property("notificationsMissedCall").toBool()) {
qCDebug(l) << "Ignoring MissedCall notification because of setting!";
return 0;
}
} else {
- QVariant notificationsCommhistoryd = settings->property("notificationsCommhistoryd");
- if (notificationsCommhistoryd.isValid() && !notificationsCommhistoryd.toBool()) {
+ if (!settings->property("notificationsCommhistoryd").toBool()) {
qCDebug(l) << "Ignoring commhistoryd notification because of setting!";
return 0;
}
@@ -166,8 +163,7 @@ uint NotificationManager::Notify(const QString &app_name, uint replaces_id, cons
);
}
} else if (app_name == "harbour-mitakuuluu2-server") {
- QVariant notificationsMitakuuluu = settings->property("notificationsMitakuuluu");
- if (notificationsMitakuuluu.isValid() && !notificationsMitakuuluu.toBool()) {
+ if (!settings->property("notificationsMitakuuluu").toBool()) {
qCDebug(l) << "Ignoring mitakuuluu notification because of setting!";
return 0;
}
@@ -176,8 +172,7 @@ uint NotificationManager::Notify(const QString &app_name, uint replaces_id, cons
hints.value("x-nemo-preview-summary", "default").toString()
);
} else if (app_name == "twitter-notifications-client") {
- QVariant notificationsTwitter = settings->property("notificationsTwitter");
- if (notificationsTwitter.isValid() && !notificationsTwitter.toBool()) {
+ if (!settings->property("notificationsTwitter").toBool()) {
qCDebug(l) << "Ignoring twitter notification because of setting!";
return 0;
}
@@ -195,14 +190,12 @@ uint NotificationManager::Notify(const QString &app_name, uint replaces_id, cons
qCDebug(l) << "MSG Prio:" << prio;
- QVariant notificationsAll = settings->property("notificationsAll");
- if ((!notificationsAll.isValid() || !notificationsAll.toBool()) && prio <= 10) {
+ if (!settings->property("notificationsAll").toBool() && prio <= 10) {
qCDebug(l) << "Ignoring notification because of setting! (all)";
return 0;
}
- QVariant notificationsOther = settings->property("notificationsOther");
- if (notificationsOther.isValid() && !notificationsOther.toBool() && prio < 90) {
+ if (!settings->property("notificationsOther").toBool() && prio < 90) {
qCDebug(l) << "Ignoring notification because of setting! (other)";
return 0;
}
diff --git a/daemon/settings.h b/daemon/settings.h
index 3c38473..a247dc5 100644
--- a/daemon/settings.h
+++ b/daemon/settings.h
@@ -39,8 +39,23 @@ class Settings : public MDConfGroup
public:
explicit Settings(QObject *parent = 0) :
- MDConfGroup("/org/pebbled/settings", parent, BindProperties)
- { resolveMetaObject(); }
+ MDConfGroup("/org/pebbled/settings", parent, BindProperties),
+ transliterateMessage(false),
+ useSystemVolume(true),
+ incomingCallNotification(true),
+ notificationsCommhistoryd(true),
+ notificationsMissedCall(true),
+ notificationsEmails(false),
+ notificationsMitakuuluu(true),
+ notificationsTwitter(true),
+ notificationsFacebook(true),
+ notificationsOther(true),
+ notificationsAll(false)
+ {
+ resolveMetaObject();
+ QMetaObject::invokeMethod(this, "propertyChanged", Qt::DirectConnection);
+ sync();
+ }
signals:
void profileWhenConnectedChanged();