Merge lp:~laney/ubuntu-system-settings/private-as-background into lp:ubuntu-system-settings

Proposed by Iain Lane
Status: Merged
Approved by: Ken VanDine
Approved revision: 551
Merged at revision: 550
Proposed branch: lp:~laney/ubuntu-system-settings/private-as-background
Merge into: lp:ubuntu-system-settings
Prerequisite: lp:~laney/ubuntu-system-settings/as-library
Diff against target: 142 lines (+19/-54)
3 files modified
plugins/background/CMakeLists.txt (+2/-1)
plugins/background/background.cpp (+14/-50)
plugins/background/background.h (+3/-3)
To merge this branch: bzr merge lp:~laney/ubuntu-system-settings/private-as-background
Reviewer Review Type Date Requested Status
Ken VanDine Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+200648@code.launchpad.net

Commit message

[background] Drop direct use of AS & use the new private library.

Description of the change

Drop direct use of AS & use the new private library.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ken VanDine (ken-vandine) wrote :

I'm not a fan of adding unneeded whitespace, can you drop the blank line after defining m_accountsService?

review: Needs Fixing
551. By Iain Lane

Remove whitespace after defining m_accountsService

Revision history for this message
Ken VanDine (ken-vandine) wrote :

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/background/CMakeLists.txt'
2--- plugins/background/CMakeLists.txt 2013-11-27 21:21:28 +0000
3+++ plugins/background/CMakeLists.txt 2014-01-07 15:12:03 +0000
4@@ -1,4 +1,3 @@
5-
6 set(QML_SOURCES
7 MainPage.qml
8 OverlayImage.qml
9@@ -13,6 +12,8 @@
10 ${QML_SOURCES}) # So they show up in Qt designer.
11 qt5_use_modules(UbuntuBackgroundPanel Qml Quick DBus)
12
13+target_link_libraries(UbuntuBackgroundPanel uss-accountsservice)
14+
15 set(PLUG_DIR ${PLUGIN_PRIVATE_MODULE_DIR}/Ubuntu/SystemSettings/Background)
16 install(TARGETS UbuntuBackgroundPanel DESTINATION ${PLUG_DIR})
17 install(FILES qmldir DESTINATION ${PLUG_DIR})
18
19=== modified file 'plugins/background/background.cpp'
20--- plugins/background/background.cpp 2013-12-09 17:17:59 +0000
21+++ plugins/background/background.cpp 2014-01-07 15:12:03 +0000
22@@ -19,6 +19,7 @@
23 */
24
25 #include "background.h"
26+
27 #include <QDir>
28 #include <QStandardPaths>
29 #include <QEvent>
30@@ -27,52 +28,24 @@
31 #include <QDebug>
32
33 Background::Background(QObject *parent) :
34- QObject(parent),
35- m_systemBusConnection (QDBusConnection::systemBus()),
36- m_accountsserviceIface ("org.freedesktop.Accounts",
37- "/org/freedesktop/Accounts",
38- "org.freedesktop.Accounts",
39- m_systemBusConnection)
40+ QObject(parent)
41 {
42- if (!m_accountsserviceIface.isValid()) {
43- return;
44- }
45-
46- QDBusReply<QDBusObjectPath> qObjectPath = m_accountsserviceIface.call(
47- "FindUserById", qlonglong(getuid()));
48-
49- if (qObjectPath.isValid()) {
50- m_objectPath = qObjectPath.value().path();
51- }
52-
53- m_systemBusConnection.connect("org.freedesktop.Accounts",
54- m_objectPath,
55- "org.freedesktop.Accounts.User",
56- "Changed",
57- this,
58- SLOT(slotChanged()));
59+ QObject::connect(&m_accountsService,
60+ SIGNAL (changed ()),
61+ this,
62+ SLOT (slotChanged()));
63 updateUbuntuArt();
64 updateCustomBackgrounds();
65 }
66
67 QString Background::getBackgroundFile()
68 {
69- QDBusInterface userInterface (
70- "org.freedesktop.Accounts",
71- m_objectPath,
72- "org.freedesktop.DBus.Properties",
73- m_systemBusConnection,
74- this);
75-
76- if (userInterface.isValid()) {
77- QDBusReply<QDBusVariant> answer = userInterface.call (
78- "Get",
79- "org.freedesktop.Accounts.User",
80- "BackgroundFile");
81-
82- if (answer.isValid())
83- return answer.value().variant().toString();
84- }
85+ QVariant answer = m_accountsService.getUserProperty(
86+ "org.freedesktop.Accounts.User",
87+ "BackgroundFile");
88+
89+ if (answer.isValid())
90+ return answer.toString();
91
92 return QString();
93 }
94@@ -85,18 +58,9 @@
95 if (backgroundFile.url() == m_backgroundFile)
96 return;
97
98- QDBusInterface userInterface (
99- "org.freedesktop.Accounts",
100- m_objectPath,
101- "org.freedesktop.Accounts.User",
102- m_systemBusConnection,
103- this);
104-
105- if (!userInterface.isValid())
106- return;
107-
108 m_backgroundFile = backgroundFile.url();
109- userInterface.call("SetBackgroundFile", backgroundFile.path());
110+ m_accountsService.customSetUserProperty("SetBackgroundFile",
111+ backgroundFile.path());
112 Q_EMIT backgroundFileChanged();
113 }
114
115
116=== modified file 'plugins/background/background.h'
117--- plugins/background/background.h 2013-12-09 17:27:10 +0000
118+++ plugins/background/background.h 2014-01-07 15:12:03 +0000
119@@ -21,6 +21,8 @@
120 #ifndef BACKGROUND_H
121 #define BACKGROUND_H
122
123+#include "accountsservice.h"
124+
125 #include <QDBusInterface>
126 #include <QObject>
127 #include <QProcess>
128@@ -60,14 +62,12 @@
129 void ubuntuArtChanged();
130
131 private:
132+ AccountsService m_accountsService;
133 QStringList m_ubuntuArt;
134 QStringList m_customBackgrounds;
135 void updateCustomBackgrounds();
136 void updateUbuntuArt();
137 QString m_backgroundFile;
138- QDBusConnection m_systemBusConnection;
139- QString m_objectPath;
140- QDBusInterface m_accountsserviceIface;
141 QString getBackgroundFile();
142 };
143

Subscribers

People subscribed via source and target branches