From 3f64297af4e7a070b4f62ebf3f17105ee6b0a3a8 Mon Sep 17 00:00:00 2001 From: Tomasz Sterna Date: Thu, 30 Apr 2015 16:33:09 +0200 Subject: Implemented profile changes on watch (dis)connection --- daemon/manager.cpp | 36 +++--------------------------------- 1 file changed, 3 insertions(+), 33 deletions(-) (limited to 'daemon/manager.cpp') diff --git a/daemon/manager.cpp b/daemon/manager.cpp index 567316e..262fb4b 100644 --- a/daemon/manager.cpp +++ b/daemon/manager.cpp @@ -24,7 +24,6 @@ Manager::Manager(Settings *settings, QObject *parent) : { connect(settings, SIGNAL(valueChanged(QString)), SLOT(onSettingChanged(const QString&))); connect(settings, SIGNAL(valuesChanged()), SLOT(onSettingsChanged())); - //connect(settings, SIGNAL(silentWhenConnectedChanged(bool)), SLOT(onSilentWhenConnectedChanged(bool))); // We don't need to handle presence changes, so report them separately and ignore them QMap parameters; @@ -75,8 +74,6 @@ Manager::Manager(Settings *settings, QObject *parent) : connect(bank, &BankManager::slotsChanged, proxy, &PebbledProxy::AppSlotsChanged); connect(apps, &AppManager::appsChanged, proxy, &PebbledProxy::AllAppsChanged); - QString currentProfile = getCurrentProfile(); - defaultProfile = currentProfile.isEmpty() ? "ambience" : currentProfile; connect(watch, SIGNAL(connectedChanged()), SLOT(applyProfile())); // Set BT icon for notification @@ -259,38 +256,11 @@ void Manager::onEmailNotify(const QString &sender, const QString &data,const QSt watch->sendEmailNotification(sender, data, subject); } -QString Manager::getCurrentProfile() const -{ - QDBusReply profile = QDBusConnection::sessionBus().call( - QDBusMessage::createMethodCall("com.nokia.profiled", "/com/nokia/profiled", "com.nokia.profiled", "get_profile")); - if (profile.isValid()) { - QString currentProfile = profile.value(); - qCDebug(l) << "Got profile" << currentProfile; - return currentProfile; - } - - qCCritical(l) << profile.error().message(); - return QString(); -} - void Manager::applyProfile() { - QString currentProfile = getCurrentProfile(); - QString newProfile; - - if (settings->property("silentWhenConnected").toBool()) { - if (watch->isConnected() && currentProfile != "silent") { - newProfile = "silent"; - defaultProfile = currentProfile; - } - if (!watch->isConnected() && currentProfile == "silent" && defaultProfile != "silent") { - newProfile = defaultProfile; - } - } - else if (currentProfile != defaultProfile) { - newProfile = defaultProfile; - } - + QString newProfile = settings->property( + watch->isConnected() ? "profileWhenConnected" + : "profileWhenDisconnected").toString(); if (!newProfile.isEmpty()) { QDBusReply res = QDBusConnection::sessionBus().call( QDBusMessage::createMethodCall("com.nokia.profiled", "/com/nokia/profiled", "com.nokia.profiled", "set_profile") -- cgit v1.2.3