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

Proposed by Iain Lane
Status: Merged
Approved by: Łukasz Zemczak
Approved revision: 475
Merged at revision: 467
Proposed branch: lp:~laney/ubuntu-system-settings/as-background-fixes
Merge into: lp:ubuntu-system-settings
Diff against target: 185 lines (+70/-14)
2 files modified
plugins/background/MainPage.qml (+61/-12)
plugins/background/background.cpp (+9/-2)
To merge this branch: bzr merge lp:~laney/ubuntu-system-settings/as-background-fixes
Reviewer Review Type Date Requested Status
Łukasz Zemczak Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+191589@code.launchpad.net

Commit message

[background] Correctly set the background in accountsservice. Make it update in the UI. Fix the "same/different" toggle. Update the reset button to reset the greeter background too, and to set the toggle back to "same".

Description of the change

Fix setting the greeter background.

We didn't maintain this code once the UI was hidden and it bitrotted (incorrect changes were added).

Correctly set the background in AS. Make it update in the UI. Fix the "same/different" toggle. Update the reset button to reset the greeter background too, and to set the toggle back to "same".

I didn't unhide this UI yet as it should be tested by others a bit first. Also we should decide what to do about the buttons. Probably get rid of "Change" and move the reset one underneath the OptionSelector?

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
Łukasz Zemczak (sil2100) wrote :

Looking good, actually I'm rejecting my previous merge as this one has all the things in it as well. As mentioned on IRC, I'll check if now we can use the .property() thing.

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

I checked if .property() works - and sadly not. It's still returning an empty string for me when doing return userInterface.property("BackgroundFile").toString();, so let's stick with what you have here.

But there are some things that need fixing:

1) In the welcomeImage, you need:

+ source: backgroundPanel.backgroundFile

2) The Change... button needs to have the callback as well, otherwise it doesn't change anything (and breaking v1), so:

- onClicked: startContentTransfer()
+ onClicked: startContentTransfer(function(url) {
+ if (systemSettingsSettings.backgroundDuplicate) {
+ updateBoth(url)
+ } else {
+ updateHome(url)
+ systemSettingsSettings.backgroundSetLast = "home"
+ }
+ })

I guess that's all for now what I saw.

review: Needs Fixing
Revision history for this message
Iain Lane (laney) wrote :

On Thu, Oct 17, 2013 at 11:49:17AM -0000, Łukasz Zemczak wrote:
> […]
> 1) In the welcomeImage, you need:
>
> + source: backgroundPanel.backgroundFile

No. This goes through the test image. Did you see something break?

> 2) The Change... button needs to have the callback as well, otherwise it doesn't change anything (and breaking v1), so:
>
> - onClicked: startContentTransfer()
> + onClicked: startContentTransfer(function(url) {
> + if (systemSettingsSettings.backgroundDuplicate) {
> + updateBoth(url)
> + } else {
> + updateHome(url)
> + systemSettingsSettings.backgroundSetLast = "home"
> + }
> + })

Okay. It should actually be connected to the click action of the image
instead of duplicating the code.

--
Iain Lane [ <email address hidden> ]
Debian Developer [ <email address hidden> ]
Ubuntu Developer [ <email address hidden> ]

474. By Iain Lane

Make the "Change" button do the same as clicking on the home image

Revision history for this message
Iain Lane (laney) wrote :

On Thu, Oct 17, 2013 at 12:55:14PM +0100, Iain Lane wrote:
> […]
> Okay. It should actually be connected to the click action of the image
> instead of duplicating the code.

Fixed r474

--
Iain Lane [ <email address hidden> ]
Debian Developer [ <email address hidden> ]
Ubuntu Developer [ <email address hidden> ]

475. By Iain Lane

Remove {}

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Now it's awesome. Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/background/MainPage.qml'
--- plugins/background/MainPage.qml 2013-10-15 12:04:10 +0000
+++ plugins/background/MainPage.qml 2013-10-17 12:15:08 +0000
@@ -62,6 +62,19 @@
62 }62 }
63 }63 }
6464
65 function updateWelcome(imageUrl) {
66 backgroundPanel.backgroundFile = imageUrl
67 }
68
69 function updateHome(imageUrl) {
70 background.pictureUri = imageUrl
71 }
72
73 function updateBoth(imageUrl) {
74 updateWelcome(imageUrl)
75 updateHome(imageUrl)
76 }
77
65 /* TODO: We hide the welcome screen parts for v1 -78 /* TODO: We hide the welcome screen parts for v1 -
66 there's a lot of elements to hide */79 there's a lot of elements to hide */
6780
@@ -89,7 +102,14 @@
89 left: parent.left102 left: parent.left
90 }103 }
91104
92 onClicked: startContentTransfer()105 onClicked: startContentTransfer(function(url) {
106 if (systemSettingsSettings.backgroundDuplicate) {
107 updateBoth(url)
108 } else {
109 updateWelcome(url)
110 systemSettingsSettings.backgroundSetLast = "welcome"
111 }
112 })
93 Component.onCompleted: updateImage(testWelcomeImage,113 Component.onCompleted: updateImage(testWelcomeImage,
94 welcomeImage)114 welcomeImage)
95115
@@ -108,7 +128,14 @@
108 horizontalCenter: (showAllUI) ? undefined : parent.horizontalCenter128 horizontalCenter: (showAllUI) ? undefined : parent.horizontalCenter
109 }129 }
110130
111 onClicked: startContentTransfer()131 onClicked: startContentTransfer(function(url) {
132 if (systemSettingsSettings.backgroundDuplicate) {
133 updateBoth(url)
134 } else {
135 updateHome(url)
136 systemSettingsSettings.backgroundSetLast = "home"
137 }
138 })
112 Component.onCompleted: updateImage(testHomeImage,139 Component.onCompleted: updateImage(testHomeImage,
113 homeImage)140 homeImage)
114141
@@ -159,7 +186,8 @@
159 text: i18n.tr("Change…")186 text: i18n.tr("Change…")
160 width: parent.width - units.gu(4)187 width: parent.width - units.gu(4)
161 anchors.horizontalCenter: parent.horizontalCenter188 anchors.horizontalCenter: parent.horizontalCenter
162 onClicked: startContentTransfer()189 Component.onCompleted:
190 clicked.connect(homeImage.clicked)
163 }191 }
164192
165 Button {193 Button {
@@ -167,8 +195,13 @@
167 width: parent.width - units.gu(4)195 width: parent.width - units.gu(4)
168 anchors.horizontalCenter: parent.horizontalCenter196 anchors.horizontalCenter: parent.horizontalCenter
169 onClicked: {197 onClicked: {
198 // Reset all of the settings
170 background.schema.reset('pictureUri')199 background.schema.reset('pictureUri')
171 setUpImages()200 systemSettingsSettings.backgroundPreviouslySetValue =
201 background.pictureUri
202 backgroundPanel.backgroundFile = background.pictureUri
203 systemSettingsSettings.backgroundSetLast = "home"
204 optionSelector.selectedIndex = 0 // Same
172 }205 }
173 }206 }
174207
@@ -208,6 +241,12 @@
208241
209 Image {242 Image {
210 id: testWelcomeImage243 id: testWelcomeImage
244
245 function update(uri) {
246 // Will update source
247 updateWelcome(uri)
248 }
249
211 property string fallback: defaultBackground250 property string fallback: defaultBackground
212 visible: false251 visible: false
213 onStatusChanged: updateImage(testWelcomeImage,252 onStatusChanged: updateImage(testWelcomeImage,
@@ -216,6 +255,12 @@
216255
217 Image {256 Image {
218 id: testHomeImage257 id: testHomeImage
258
259 function update(uri) {
260 // Will update source
261 updateHome(uri)
262 }
263
219 property string fallback: defaultBackground264 property string fallback: defaultBackground
220 source: background.pictureUri265 source: background.pictureUri
221 visible: false266 visible: false
@@ -234,11 +279,11 @@
234 systemSettingsSettings.backgroundPreviouslySetValue =279 systemSettingsSettings.backgroundPreviouslySetValue =
235 leastRecent.source280 leastRecent.source
236 /* copy most recently changed to least recently changed */281 /* copy most recently changed to least recently changed */
237 leastRecent.source = mostRecent.source282 leastRecent.update(mostRecent.source)
238 } else { // different283 } else { // different
239 /* restore least recently changed to previous value */284 /* restore least recently changed to previous value */
240 leastRecent.source =285 leastRecent.update(
241 systemSettingsSettings.backgroundPreviouslySetValue286 systemSettingsSettings.backgroundPreviouslySetValue)
242 }287 }
243 }288 }
244289
@@ -256,21 +301,25 @@
256 property var activeTransfer301 property var activeTransfer
257302
258 Connections {303 Connections {
304 id: contentHubConnection
305 property var imageCallback
259 target: activeTransfer ? activeTransfer : null306 target: activeTransfer ? activeTransfer : null
260 onStateChanged: {307 onStateChanged: {
261 if (activeTransfer.state === ContentTransfer.Charged) {308 if (activeTransfer.state === ContentTransfer.Charged) {
262 if (activeTransfer.items.length > 0) {309 if (activeTransfer.items.length > 0) {
263 var imageUrl = activeTransfer.items[0].url;310 var imageUrl = activeTransfer.items[0].url;
264 background.pictureUri = imageUrl;311 imageCallback(imageUrl);
265 setUpImages();
266 }312 }
267 }313 }
268 }314 }
269 }315 }
270316
271 function startContentTransfer() {317 function startContentTransfer(callback) {
272 var transfer = ContentHub.importContent(ContentType.Pictures,318 if (callback)
273 ContentHub.defaultSourceForType(ContentType.Pictures));319 contentHubConnection.imageCallback = callback
320 var transfer = ContentHub.importContent(
321 ContentType.Pictures,
322 ContentHub.defaultSourceForType(ContentType.Pictures));
274 if (transfer != null)323 if (transfer != null)
275 {324 {
276 transfer.selectionType = ContentTransfer.Single;325 transfer.selectionType = ContentTransfer.Single;
277326
=== modified file 'plugins/background/background.cpp'
--- plugins/background/background.cpp 2013-07-21 19:25:47 +0000
+++ plugins/background/background.cpp 2013-10-17 12:15:08 +0000
@@ -55,12 +55,18 @@
55 QDBusInterface userInterface (55 QDBusInterface userInterface (
56 "org.freedesktop.Accounts",56 "org.freedesktop.Accounts",
57 m_objectPath,57 m_objectPath,
58 "org.freedesktop.Accounts.User",58 "org.freedesktop.DBus.Properties",
59 m_systemBusConnection,59 m_systemBusConnection,
60 this);60 this);
6161
62 if (userInterface.isValid()) {62 if (userInterface.isValid()) {
63 return userInterface.property("BackgroundFile").toString();63 QDBusReply<QDBusVariant> answer = userInterface.call (
64 "Get",
65 "org.freedesktop.Accounts.User",
66 "BackgroundFile");
67
68 if (answer.isValid())
69 return answer.value().variant().toString();
64 }70 }
6571
66 return QString();72 return QString();
@@ -84,6 +90,7 @@
84 QString backgroundFileSave = backgroundFile.path();90 QString backgroundFileSave = backgroundFile.path();
85 m_backgroundFile = backgroundFileSave;91 m_backgroundFile = backgroundFileSave;
86 userInterface.call("SetBackgroundFile", backgroundFileSave);92 userInterface.call("SetBackgroundFile", backgroundFileSave);
93 Q_EMIT backgroundFileChanged();
87}94}
8895
89void Background::slotChanged()96void Background::slotChanged()

Subscribers

People subscribed via source and target branches