2 * Copyright (C) 2013 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 * Author: Michael Terry <michael.terry@canonical.com>
20#include <QDBusPendingCall>
21#include <QDBusConnection>
23void autoBrightnessChanged(GSettings *settings, const gchar *key, Powerd * instance)
25 const bool value = g_settings_get_boolean(settings, key);
26 instance->performAsyncCall("userAutobrightnessEnable", {value});
29void activityTimeoutChanged(GSettings *settings, const gchar *key, Powerd * instance)
31 const int value = g_settings_get_int(settings, key);
32 instance->performAsyncCall("setInactivityTimeouts", {value, -1});
35void dimTimeoutChanged(GSettings *settings, const gchar *key, Powerd * instance)
37 const int value = g_settings_get_int(settings, key);
38 instance->performAsyncCall("setInactivityTimeouts", {-1, value});
41Powerd::Powerd(QObject* parent)
43 cachedStatus(Status::On)
45 QDBusConnection::SM_BUSNAME().connect("com.canonical.Unity.Screen",
46 "/com/canonical/Unity/Screen",
47 "com.canonical.Unity.Screen",
48 "DisplayPowerStateChange",
50 SLOT(handleDisplayPowerStateChange(int, int)));
52 systemSettings = g_settings_new("com.ubuntu.touch.system");
53 g_signal_connect(systemSettings, "changed::auto-brightness", G_CALLBACK(autoBrightnessChanged), this);
54 g_signal_connect(systemSettings, "changed::activity-timeout", G_CALLBACK(activityTimeoutChanged), this);
55 g_signal_connect(systemSettings, "changed::dim-timeout", G_CALLBACK(dimTimeoutChanged), this);
56 autoBrightnessChanged(systemSettings, "auto-brightness", this);
57 activityTimeoutChanged(systemSettings, "activity-timeout", this);
58 dimTimeoutChanged(systemSettings, "dim-timeout", this);
63 g_signal_handlers_disconnect_by_data(systemSettings, this);
64 g_object_unref(systemSettings);
67Powerd::Status Powerd::status() const
72void Powerd::handleDisplayPowerStateChange(int status, int reason)
74 if (cachedStatus != (Status)status) {
75 cachedStatus = (Status)status;
76 Q_EMIT statusChanged((DisplayStateChangeReason)reason);
80void Powerd::performAsyncCall(const QString &method, const QVariantList &args)
82 QDBusMessage msg = QDBusMessage::createMethodCall("com.canonical.Unity.Screen",
83 "/com/canonical/Unity/Screen",
84 "com.canonical.Unity.Screen",
86 msg.setArguments(args);
87 QDBusConnection::SM_BUSNAME().asyncCall(msg);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list