~mzanetti/unity8/modeswitchwarning

« back to all changes in this revision

Viewing changes to qml/Components/WallpaperResolver.qml

  • Committer: Michael Zanetti
  • Date: 2015-10-26 16:47:52 UTC
  • mfrom: (1978.2.32 trunk)
  • Revision ID: michael.zanetti@canonical.com-20151026164752-8yt7ngcng344mb67
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2015 Canonical, Ltd.
 
3
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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/>.
 
15
 */
 
16
 
 
17
import QtQuick 2.4
 
18
import AccountsService 0.1
 
19
import GSettings 1.0
 
20
import Ubuntu.Components 1.3
 
21
 
 
22
/*
 
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
 
27
 */
 
28
QtObject {
 
29
    // Users should set their UI width here.
 
30
    property real width
 
31
 
 
32
    property url defaultBackground: Qt.resolvedUrl(width >= units.gu(60) ? "../graphics/tablet_background.jpg"
 
33
                                                                         : "../graphics/phone_background.jpg")
 
34
 
 
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
 
38
 
 
39
    // This is a dummy image to detect if the custom AS set wallpaper loads successfully.
 
40
    property var _asImageTester: Image {
 
41
        id: asImageTester
 
42
        source: AccountsService.backgroundFile != undefined && AccountsService.backgroundFile.length > 0 ? AccountsService.backgroundFile : ""
 
43
        height: 0
 
44
        width: 0
 
45
        sourceSize.height: 0
 
46
        sourceSize.width: 0
 
47
    }
 
48
 
 
49
    // This is a dummy image to detect if the custom GSettings set wallpaper loads successfully.
 
50
    property var _gsImageTester: Image {
 
51
        id: gsImageTester
 
52
        source: backgroundSettings.pictureUri && backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : ""
 
53
        height: 0
 
54
        width: 0
 
55
        sourceSize.height: 0
 
56
        sourceSize.width: 0
 
57
    }
 
58
 
 
59
    property var _gsettings: GSettings {
 
60
        id: backgroundSettings
 
61
        schema.id: "org.gnome.desktop.background"
 
62
    }
 
63
}