2 * Copyright (C) 2015 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 import AccountsService 0.1
20 import Ubuntu.Components 1.3
23 Defines the background URL based on several factors, such as:
24 - default, fallback, background
25 - Background set in AccountSettings, if any
26 - Background set in GSettings, if any
29 // Users should set their UI width here.
32 property url defaultBackground: Qt.resolvedUrl(width >= units.gu(60) ? "../graphics/tablet_background.jpg"
33 : "../graphics/phone_background.jpg")
35 // That's the property users of this component are going to consume.
36 readonly property url background: asImageTester.status == Image.Ready ? asImageTester.source
37 : gsImageTester.status == Image.Ready ? gsImageTester.source : defaultBackground
39 // This is a dummy image to detect if the custom AS set wallpaper loads successfully.
40 property var _asImageTester: Image {
42 source: AccountsService.backgroundFile != undefined && AccountsService.backgroundFile.length > 0 ? AccountsService.backgroundFile : ""
49 // This is a dummy image to detect if the custom GSettings set wallpaper loads successfully.
50 property var _gsImageTester: Image {
52 source: backgroundSettings.pictureUri && backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : ""
59 property var _gsettings: GSettings {
60 id: backgroundSettings
61 schema.id: "org.gnome.desktop.background"