on xenial help sign in
Pass user's preference for auto-brightness on to powerd. Fixes: 1273174
2d174c4Michael Terry
plugins/Powerd/CMakeLists.txt+8
@@ -1,4 +1,11 @@
1include(Plugins)
1include(Plugins)
2+include(FindPkgConfig)
3+
4+pkg_search_module(GIO REQUIRED gio-2.0)
5+
6+include_directories(
7+ ${GIO_INCLUDE_DIRS}
8+)
2
9
3add_definitions(-DSM_BUSNAME=systemBus)
10add_definitions(-DSM_BUSNAME=systemBus)
4
11
@@ -8,6 +15,7 @@ add_library(Powerd-qml MODULE
8 )
15 )
9
16
10qt5_use_modules(Powerd-qml DBus Qml)
17qt5_use_modules(Powerd-qml DBus Qml)
18+target_link_libraries(Powerd-qml ${GIO_LDFLAGS})
11
19
12export_qmlfiles(Powerd Powerd)
20export_qmlfiles(Powerd Powerd)
13export_qmlplugin(Powerd 0.1 Powerd TARGETS Powerd-qml)
21export_qmlplugin(Powerd 0.1 Powerd TARGETS Powerd-qml)
plugins/Powerd/Powerd.cpp+17
@@ -17,6 +17,13 @@
17 */
17 */
18
18
19#include "Powerd.h"
19#include "Powerd.h"
20+#include <QDBusPendingCall>
21+
22+void autoBrightnessChanged(GSettings *settings, const gchar *key, QDBusInterface *powerd)
23+{
24+ bool value = g_settings_get_boolean(settings, key);
25+ powerd->asyncCall("userAutobrightnessEnable", QVariant(value));
26+}
20
27
21Powerd::Powerd(QObject* parent)
28Powerd::Powerd(QObject* parent)
22 : QObject(parent),
29 : QObject(parent),
@@ -33,4 +40,14 @@ Powerd::Powerd(QObject* parent)
33 "DisplayPowerStateChange",
40 "DisplayPowerStateChange",
34 this,
41 this,
35 SIGNAL(displayPowerStateChange(int, unsigned int)));
42 SIGNAL(displayPowerStateChange(int, unsigned int)));
43+
44+ systemSettings = g_settings_new("com.ubuntu.touch.system");
45+ g_signal_connect(systemSettings, "changed::auto-brightness", G_CALLBACK(autoBrightnessChanged), powerd);
46+ autoBrightnessChanged(systemSettings, "auto-brightness", powerd);
47+}
48+
49+Powerd::~Powerd()
50+{
51+ g_signal_handlers_disconnect_by_data(systemSettings, powerd);
52+ g_object_unref(systemSettings);
36}
53}
plugins/Powerd/Powerd.h+3
@@ -20,6 +20,7 @@
20#ifndef UNITY_POWERD_H
20#ifndef UNITY_POWERD_H
21#define UNITY_POWERD_H
21#define UNITY_POWERD_H
22
22
23+#include <gio/gio.h>
23#include <QtCore/QObject>
24#include <QtCore/QObject>
24#include <QtDBus/QDBusInterface>
25#include <QtDBus/QDBusInterface>
25
26
@@ -43,12 +44,14 @@ public:
43 };
44 };
44
45
45 explicit Powerd(QObject *parent = 0);
46 explicit Powerd(QObject *parent = 0);
47+ ~Powerd();
46
48
47Q_SIGNALS:
49Q_SIGNALS:
48 void displayPowerStateChange(int status, unsigned int flags);
50 void displayPowerStateChange(int status, unsigned int flags);
49
51
50private:
52private:
51 QDBusInterface *powerd;
53 QDBusInterface *powerd;
54+ GSettings *systemSettings;
52};
55};
53
56
54#endif
57#endif