Merge lp:~mterry/ubuntu-system-settings/default-wallpaper into lp:ubuntu-system-settings

Proposed by Michael Terry
Status: Merged
Approved by: Michael Terry
Approved revision: 1669
Merged at revision: 1721
Proposed branch: lp:~mterry/ubuntu-system-settings/default-wallpaper
Merge into: lp:ubuntu-system-settings
Diff against target: 322 lines (+100/-42)
6 files modified
debian/control (+1/-0)
plugins/background/MainPage.qml (+2/-19)
plugins/background/Preview.qml (+1/-2)
plugins/background/background.cpp (+90/-20)
plugins/background/background.h (+6/-0)
plugins/cellular/Components/SimEditor.qml (+0/-1)
To merge this branch: bzr merge lp:~mterry/ubuntu-system-settings/default-wallpaper
Reviewer Review Type Date Requested Status
system-apps-ci-bot continuous-integration Approve
Jonas G. Drange (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+297632@code.launchpad.net

Commit message

Use standard default wallpaper instead of unity8's custom one.
Depend on ubuntu-wallpapers, pulling in typical alternate wallpapers too.

And handle such system wallpapers better, by making a copy in case they go away.

Description of the change

And in addition to the above changes, I fixed a couple grey button gradients that I noticed still remained. I couldn't resist.

Regarding making copies of the system wallpapers... I felt this was necessary on Touch because when we upgrade to xenial, for example, the read-only system image will switch from ubuntu-wallpapers-vivid to ubuntu-wallpapers-xenial.

Thus, unlike a normal system upgrade situation on classic Desktop, your system wallpaper can actually disappear. We *could* solve this by growing the installed set of wallpapers every release (i.e. have touch's xenial seed include ubuntu-wallpapers-vivid). But that will quickly become gross.

Instead, I've opted for making a personal copy whenever a system wallpaper is chosen. We delete any copies that are unnecessary (i.e. still on the system) when they are switched away from. And we expose them as custom wallpapers that can be removed once they are no longer on the system (i.e. the user upgraded from vivid to xenial).

Related branches:
- https://code.launchpad.net/~mterry/unity8/default-wallpaper/+merge/297636
- https://code.launchpad.net/~mterry/unity-system-compositor/default-wallpaper/+merge/297791

Silo 23 has all three branches for easier testing.

To post a comment you must log in.
Revision history for this message
Michael Terry (mterry) wrote :

Oooh, had a thought regarding the system-wallpaper-copy issue. What about this:

- When switching wallpapers, if the old wallpaper is still on the system and we also keep a copy, delete the copy. This keeps us from keeping copies of all the wallpapers, if the user tries them all out.
- If we have a copy of a system wallpaper, but it is no longer on the system, treat that wallpaper as a custom wallpaper. That way, the user can delete it.

Thus we have at most one undeleteable wallpaper copy per user. The disadvantage is that it is harder to get back a wallpaper you used to like after we upgrade distros. But that's always true in that case.

Unless I hear otherwise, I'll work on this approach.

1666. By Michael Terry

Merge from trunk

1667. By Michael Terry

Only keep around copies of system wallpapers that we need to

Revision history for this message
Michael Terry (mterry) wrote :

OK, done. The steps in my comment above are implemented.

1668. By Michael Terry

Guard against double-entries in grid list

1669. By Michael Terry

Fix typo

Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

Looks good, works well. Thank you

review: Approve
Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

I've confirmed autopilot tests pass, but I still like a CI run, so I've started one.

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

PASSED: Continuous integration, rev:1669
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/131/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build/1308
    SUCCESS: https://jenkins.canonical.com/system-apps/job/test-0-autopkgtest/label=phone-armhf,release=vivid+overlay,testname=default/292
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1308
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/1174
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/1174
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/1174
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1154
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1154/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1154
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1154/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1154
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1154/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1154
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1154/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1154
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1154/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1154
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1154/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1154
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1154/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1154
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1154/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1154
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1154/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/131/rebuild

review: Approve (continuous-integration)
1670. By Michael Terry

Fix blurriness in wallpaper preview

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2016-08-24 13:50:53 +0000
3+++ debian/control 2016-09-12 15:33:02 +0000
4@@ -104,6 +104,7 @@
5 libsystemsettings1 (= ${binary:Version}),
6 system-image-dbus (>= 3.1),
7 ubuntu-keyboard-data (>= 0.99.trunk.phablet2+15.04.20150421),
8+ ubuntu-wallpapers,
9 urfkill,
10 # for the session-migration script (python3 itself also for the push helper)
11 python3,
12
13=== modified file 'plugins/background/MainPage.qml'
14--- plugins/background/MainPage.qml 2015-11-13 21:14:07 +0000
15+++ plugins/background/MainPage.qml 2016-09-12 15:33:02 +0000
16@@ -36,18 +36,7 @@
17
18 signal save (string uri)
19
20- /* TODO: For now hardcoded paths, later we'll use GSettings */
21- /* TODO: fix bug where rotating in uss will change default
22- background to tablet_back… thus losing track of phone_back… */
23- property string defaultBackground:
24- mainPage.width >= units.gu(60) ?
25- "/usr/share/unity8/graphics/tablet_background.jpg" :
26- "/usr/share/unity8/graphics/phone_background.jpg"
27-
28- /* If there is no uri then use the default */
29- property string welcomeBackground: (backgroundPanel.backgroundFile === "file:") ?
30- "file:///usr/share/unity8/graphics/phone_background.jpg" :
31- backgroundPanel.backgroundFile
32+ readonly property string welcomeBackground: backgroundPanel.backgroundFile
33
34 property var activeTransfer
35
36@@ -88,13 +77,7 @@
37 anchors.left: parent.left
38 anchors.right: parent.right
39 columns: 3
40- bgmodel: {
41- // Make a shallow copy
42- var backgrounds = backgroundPanel.ubuntuArt.slice(0)
43- if (backgroundPanel.fileExists(defaultBackground))
44- backgrounds.push(Qt.resolvedUrl(defaultBackground))
45- return backgrounds
46- }
47+ bgmodel: backgroundPanel.ubuntuArt
48 backgroundPanel: backgroundPanel
49 title: i18n.tr("Ubuntu Art")
50 current: welcomeBackground
51
52=== modified file 'plugins/background/Preview.qml'
53--- plugins/background/Preview.qml 2015-08-10 13:31:45 +0000
54+++ plugins/background/Preview.qml 2016-09-12 15:33:02 +0000
55@@ -73,7 +73,7 @@
56 anchors.fill: parent
57 source: uri
58 sourceSize.height: height
59- sourceSize.width: width
60+ sourceSize.width: 0
61 fillMode: Image.PreserveAspectCrop
62 }
63
64@@ -100,7 +100,6 @@
65 text: preview.imported ?
66 i18n.tr("Remove image") : i18n.tr("Cancel")
67 width: (previewButtons.width-units.gu(2)*4)/2
68- gradient: UbuntuColors.greyGradient
69 onClicked: preview.state = "cancelled"
70 }
71 Button {
72
73=== modified file 'plugins/background/background.cpp'
74--- plugins/background/background.cpp 2014-07-08 09:18:09 +0000
75+++ plugins/background/background.cpp 2016-09-12 15:33:02 +0000
76@@ -27,6 +27,8 @@
77 #include <unistd.h>
78 #include <QDebug>
79
80+#define SYSTEM_BACKGROUND_DIR "/usr/share/backgrounds"
81+
82 Background::Background(QObject *parent) :
83 QObject(parent)
84 {
85@@ -43,11 +45,12 @@
86 QVariant answer = m_accountsService.getUserProperty(
87 "org.freedesktop.Accounts.User",
88 "BackgroundFile");
89-
90- if (answer.isValid())
91- return answer.toString();
92-
93- return QString();
94+ QString filename = answer.toString();
95+
96+ if (filename.isEmpty() || !QFile::exists(filename))
97+ return defaultBackgroundFile();
98+ else
99+ return filename;
100 }
101
102 void Background::setBackgroundFile(QUrl backgroundFile)
103@@ -58,10 +61,21 @@
104 if (backgroundFile.url() == m_backgroundFile)
105 return;
106
107+ QString oldBackgroundFile = m_backgroundFile;
108+
109 m_backgroundFile = backgroundFile.url();
110 m_accountsService.customSetUserProperty("SetBackgroundFile",
111 backgroundFile.path());
112 Q_EMIT backgroundFileChanged();
113+
114+ // If old background was a system copy that we still have on the system,
115+ // delete our copy. We don't need it anymore.
116+ if (oldBackgroundFile.contains(getCopiedSystemBackgroundFolder().path())) {
117+ QString fileName = QUrl(oldBackgroundFile).fileName();
118+ if (QFile::exists(SYSTEM_BACKGROUND_DIR "/" + fileName)) {
119+ rmFile(oldBackgroundFile);
120+ }
121+ }
122 }
123
124 void Background::slotChanged()
125@@ -91,8 +105,23 @@
126 m_customBackgrounds.clear();
127 QFileInfoList tmpList;
128 tmpList << getCustomBackgroundFolder().entryInfoList(QDir::Files | QDir::NoSymLinks);
129- if (getCustomBackgroundFolder() != getContentHubFolder())
130+ if (getCustomBackgroundFolder() != getContentHubFolder()) {
131 tmpList << getContentHubFolder().entryInfoList(QDir::Files | QDir::NoSymLinks);
132+
133+ // If any of our copied system backgrounds are no longer on the system,
134+ // treat them as custom backgrounds. This would only likely happen if
135+ // a user was using a background from vivid-wallpapers and we upgraded
136+ // to xenial-wallpapers. In this case, we want the old paper to show
137+ // as a custom background, so that the user can delete it when done
138+ // with it.
139+ // So scan the copied backgrounds.
140+ QFileInfoList copyList = getCopiedSystemBackgroundFolder().entryInfoList(QDir::Files | QDir::NoSymLinks);
141+ QDir systemDir = QDir(SYSTEM_BACKGROUND_DIR);
142+ foreach (QFileInfo f, copyList) {
143+ if (!systemDir.exists(f.fileName()))
144+ tmpList << f;
145+ }
146+ }
147 if (!tmpList.isEmpty())
148 {
149 foreach (QFileInfo f, tmpList)
150@@ -106,9 +135,18 @@
151 QUrl prepared = url;
152
153 if (getCustomBackgroundFolder() != getContentHubFolder() &&
154- url.path().startsWith(getContentHubFolder().path()))
155+ !url.path().startsWith(getCustomBackgroundFolder().path()) &&
156+ url != QUrl::fromLocalFile(defaultBackgroundFile()))
157 {
158- QDir backgroundFolder = getCustomBackgroundFolder();
159+ QDir backgroundFolder;
160+ bool moveFile = false;
161+ if (url.path().startsWith(getContentHubFolder().path())) {
162+ backgroundFolder = getCustomBackgroundFolder();
163+ moveFile = true;
164+ } else {
165+ backgroundFolder = getCopiedSystemBackgroundFolder();
166+ }
167+
168 QUrl newPath = QUrl::fromLocalFile(backgroundFolder.path() + "/" + url.fileName());
169
170 if (QFile(newPath.path()).exists())
171@@ -123,11 +161,17 @@
172
173 // Move file from local ContentHub dump to shared greeter data folder
174 if (shareWithGreeter &&
175- QDir::root().mkpath(backgroundFolder.path()) &&
176- QFile::rename(url.path(), newPath.path()))
177+ QDir::root().mkpath(backgroundFolder.path()))
178 {
179- updateCustomBackgrounds();
180- prepared = newPath;
181+ if ((moveFile && QFile::rename(url.path(), newPath.path())) ||
182+ (!moveFile && (link(url.path().toUtf8().data(),
183+ newPath.path().toUtf8().data()) == 0 ||
184+ QFile::copy(url.path(), newPath.path()))))
185+ {
186+ updateUbuntuArt();
187+ updateCustomBackgrounds();
188+ prepared = newPath;
189+ }
190 }
191 }
192
193@@ -144,6 +188,11 @@
194 return dataDir + "/ubuntu-system-settings/Pictures";
195 }
196
197+QDir Background::getCopiedSystemBackgroundFolder()
198+{
199+ return getCustomBackgroundFolder().path() + "/System";
200+}
201+
202 QDir Background::getContentHubFolder()
203 {
204 return QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/Pictures";
205@@ -153,26 +202,37 @@
206 {
207 return m_ubuntuArt;
208 }
209+
210 void Background::updateUbuntuArt()
211 {
212-
213 QString envDir(qgetenv("SYSTEM_SETTINGS_UBUNTU_ART_DIR"));
214 QDir dir;
215+ QDir copiedBackgroundDir;
216
217- if (envDir != "")
218+ if (envDir != "") {
219 dir = QDir(envDir);
220- else
221- dir = QDir("/usr/share/backgrounds/");
222+ copiedBackgroundDir = dir;
223+ } else {
224+ dir = QDir(SYSTEM_BACKGROUND_DIR);
225+ copiedBackgroundDir = getCopiedSystemBackgroundFolder();
226+ }
227
228+ m_ubuntuArt.clear();
229
230 dir.setFilter(QDir::Files | QDir::NoSymLinks);
231 dir.setSorting(QDir::Name);
232 QFileInfoList tmpList = dir.entryInfoList();
233 foreach (QFileInfo f, tmpList)
234 {
235- if (f.fileName() != "warty-final-ubuntu.png")
236- m_ubuntuArt.append(QUrl::fromLocalFile(f.absoluteFilePath()).toString());
237+ QString absPath = f.absoluteFilePath();
238+
239+ // Prefer copied versions.
240+ if (copiedBackgroundDir.exists(f.fileName()))
241+ absPath = copiedBackgroundDir.absoluteFilePath(f.fileName());
242+
243+ m_ubuntuArt.append(QUrl::fromLocalFile(absPath).toString());
244 }
245+
246 Q_EMIT ubuntuArtChanged();
247 }
248
249@@ -189,7 +249,9 @@
250 if (file.isEmpty() || file.isNull())
251 return;
252
253- if (!file.contains(getCustomBackgroundFolder().path()) && !file.contains(getContentHubFolder().path()))
254+ if (!file.contains(getCustomBackgroundFolder().path()) &&
255+ !file.contains(getCopiedSystemBackgroundFolder().path()) &&
256+ !file.contains(getContentHubFolder().path()))
257 return;
258
259 QUrl fileUri(file);
260@@ -199,10 +261,18 @@
261 QFile filePath(fileUri.path());
262 if (filePath.exists())
263 {
264- if (filePath.remove())
265+ if (filePath.remove()) {
266+ updateUbuntuArt();
267 updateCustomBackgrounds();
268+ }
269 }
270 }
271
272+QString Background::defaultBackgroundFile() const
273+{
274+ /* TODO: For now hardcoded path, later we'll use GSettings */
275+ return SYSTEM_BACKGROUND_DIR "/warty-final-ubuntu.png";
276+}
277+
278 Background::~Background() {
279 }
280
281=== modified file 'plugins/background/background.h'
282--- plugins/background/background.h 2015-03-16 13:51:36 +0000
283+++ plugins/background/background.h 2016-09-12 15:33:02 +0000
284@@ -45,6 +45,10 @@
285 READ ubuntuArt
286 NOTIFY ubuntuArtChanged )
287
288+ Q_PROPERTY( QString defaultBackgroundFile
289+ READ defaultBackgroundFile
290+ CONSTANT )
291+
292 public:
293 explicit Background(QObject *parent = 0);
294 ~Background();
295@@ -55,6 +59,7 @@
296 Q_INVOKABLE void rmFile(const QString &file);
297 QStringList customBackgrounds();
298 QStringList ubuntuArt();
299+ QString defaultBackgroundFile() const;
300
301 public Q_SLOTS:
302 void slotChanged();
303@@ -73,6 +78,7 @@
304 QString m_backgroundFile;
305 QString getBackgroundFile();
306 QDir getCustomBackgroundFolder();
307+ QDir getCopiedSystemBackgroundFolder();
308 QDir getContentHubFolder();
309 };
310
311
312=== modified file 'plugins/cellular/Components/SimEditor.qml'
313--- plugins/cellular/Components/SimEditor.qml 2015-08-10 13:31:45 +0000
314+++ plugins/cellular/Components/SimEditor.qml 2016-09-12 15:33:02 +0000
315@@ -200,7 +200,6 @@
316 Button {
317 id: cancel
318 objectName: "cancelRename"
319- gradient: UbuntuColors.greyGradient
320 text: i18n.tr("Cancel")
321 width: (editor.width / 2) - units.gu(1)
322 onClicked: {

Subscribers

People subscribed via source and target branches