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
1=== modified file 'plugins/background/MainPage.qml'
2--- plugins/background/MainPage.qml 2013-10-15 12:04:10 +0000
3+++ plugins/background/MainPage.qml 2013-10-17 12:15:08 +0000
4@@ -62,6 +62,19 @@
5 }
6 }
7
8+ function updateWelcome(imageUrl) {
9+ backgroundPanel.backgroundFile = imageUrl
10+ }
11+
12+ function updateHome(imageUrl) {
13+ background.pictureUri = imageUrl
14+ }
15+
16+ function updateBoth(imageUrl) {
17+ updateWelcome(imageUrl)
18+ updateHome(imageUrl)
19+ }
20+
21 /* TODO: We hide the welcome screen parts for v1 -
22 there's a lot of elements to hide */
23
24@@ -89,7 +102,14 @@
25 left: parent.left
26 }
27
28- onClicked: startContentTransfer()
29+ onClicked: startContentTransfer(function(url) {
30+ if (systemSettingsSettings.backgroundDuplicate) {
31+ updateBoth(url)
32+ } else {
33+ updateWelcome(url)
34+ systemSettingsSettings.backgroundSetLast = "welcome"
35+ }
36+ })
37 Component.onCompleted: updateImage(testWelcomeImage,
38 welcomeImage)
39
40@@ -108,7 +128,14 @@
41 horizontalCenter: (showAllUI) ? undefined : parent.horizontalCenter
42 }
43
44- onClicked: startContentTransfer()
45+ onClicked: startContentTransfer(function(url) {
46+ if (systemSettingsSettings.backgroundDuplicate) {
47+ updateBoth(url)
48+ } else {
49+ updateHome(url)
50+ systemSettingsSettings.backgroundSetLast = "home"
51+ }
52+ })
53 Component.onCompleted: updateImage(testHomeImage,
54 homeImage)
55
56@@ -159,7 +186,8 @@
57 text: i18n.tr("Change…")
58 width: parent.width - units.gu(4)
59 anchors.horizontalCenter: parent.horizontalCenter
60- onClicked: startContentTransfer()
61+ Component.onCompleted:
62+ clicked.connect(homeImage.clicked)
63 }
64
65 Button {
66@@ -167,8 +195,13 @@
67 width: parent.width - units.gu(4)
68 anchors.horizontalCenter: parent.horizontalCenter
69 onClicked: {
70+ // Reset all of the settings
71 background.schema.reset('pictureUri')
72- setUpImages()
73+ systemSettingsSettings.backgroundPreviouslySetValue =
74+ background.pictureUri
75+ backgroundPanel.backgroundFile = background.pictureUri
76+ systemSettingsSettings.backgroundSetLast = "home"
77+ optionSelector.selectedIndex = 0 // Same
78 }
79 }
80
81@@ -208,6 +241,12 @@
82
83 Image {
84 id: testWelcomeImage
85+
86+ function update(uri) {
87+ // Will update source
88+ updateWelcome(uri)
89+ }
90+
91 property string fallback: defaultBackground
92 visible: false
93 onStatusChanged: updateImage(testWelcomeImage,
94@@ -216,6 +255,12 @@
95
96 Image {
97 id: testHomeImage
98+
99+ function update(uri) {
100+ // Will update source
101+ updateHome(uri)
102+ }
103+
104 property string fallback: defaultBackground
105 source: background.pictureUri
106 visible: false
107@@ -234,11 +279,11 @@
108 systemSettingsSettings.backgroundPreviouslySetValue =
109 leastRecent.source
110 /* copy most recently changed to least recently changed */
111- leastRecent.source = mostRecent.source
112+ leastRecent.update(mostRecent.source)
113 } else { // different
114 /* restore least recently changed to previous value */
115- leastRecent.source =
116- systemSettingsSettings.backgroundPreviouslySetValue
117+ leastRecent.update(
118+ systemSettingsSettings.backgroundPreviouslySetValue)
119 }
120 }
121
122@@ -256,21 +301,25 @@
123 property var activeTransfer
124
125 Connections {
126+ id: contentHubConnection
127+ property var imageCallback
128 target: activeTransfer ? activeTransfer : null
129 onStateChanged: {
130 if (activeTransfer.state === ContentTransfer.Charged) {
131 if (activeTransfer.items.length > 0) {
132 var imageUrl = activeTransfer.items[0].url;
133- background.pictureUri = imageUrl;
134- setUpImages();
135+ imageCallback(imageUrl);
136 }
137 }
138 }
139 }
140
141- function startContentTransfer() {
142- var transfer = ContentHub.importContent(ContentType.Pictures,
143- ContentHub.defaultSourceForType(ContentType.Pictures));
144+ function startContentTransfer(callback) {
145+ if (callback)
146+ contentHubConnection.imageCallback = callback
147+ var transfer = ContentHub.importContent(
148+ ContentType.Pictures,
149+ ContentHub.defaultSourceForType(ContentType.Pictures));
150 if (transfer != null)
151 {
152 transfer.selectionType = ContentTransfer.Single;
153
154=== modified file 'plugins/background/background.cpp'
155--- plugins/background/background.cpp 2013-07-21 19:25:47 +0000
156+++ plugins/background/background.cpp 2013-10-17 12:15:08 +0000
157@@ -55,12 +55,18 @@
158 QDBusInterface userInterface (
159 "org.freedesktop.Accounts",
160 m_objectPath,
161- "org.freedesktop.Accounts.User",
162+ "org.freedesktop.DBus.Properties",
163 m_systemBusConnection,
164 this);
165
166 if (userInterface.isValid()) {
167- return userInterface.property("BackgroundFile").toString();
168+ QDBusReply<QDBusVariant> answer = userInterface.call (
169+ "Get",
170+ "org.freedesktop.Accounts.User",
171+ "BackgroundFile");
172+
173+ if (answer.isValid())
174+ return answer.value().variant().toString();
175 }
176
177 return QString();
178@@ -84,6 +90,7 @@
179 QString backgroundFileSave = backgroundFile.path();
180 m_backgroundFile = backgroundFileSave;
181 userInterface.call("SetBackgroundFile", backgroundFileSave);
182+ Q_EMIT backgroundFileChanged();
183 }
184
185 void Background::slotChanged()

Subscribers

People subscribed via source and target branches