~mterry/unity8/greeter-arrangement

« back to all changes in this revision

Viewing changes to qml/Components/WallpaperResolver.qml

  • Committer: Michael Terry
  • Date: 2016-08-30 14:06:47 UTC
  • Revision ID: michael.terry@canonical.com-20160830140647-0gmw15jq769d2g1q
Use the default system wallpaper instead of our custom one.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 */
16
16
 
17
17
import QtQuick 2.4
18
 
import AccountsService 0.1
19
 
import GSettings 1.0
20
18
import Ubuntu.Components 1.3
21
19
 
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"
 
20
Item {
 
21
    id: root
 
22
 
 
23
    // Provide a list of wallpapers to resolve here, preferred ones first
 
24
    property var candidates: []
 
25
 
 
26
    readonly property url background: {
 
27
        for (var i = 0; i < repeater.count; i++) {
 
28
            if (repeater.itemAt(i).status === Image.Ready)
 
29
                return candidates[i];
 
30
        }
 
31
        if (i > 0) {
 
32
            return candidates[i - 1]; // last item is last resort
 
33
        } else {
 
34
            return "";
 
35
        }
 
36
    }
 
37
 
 
38
    Repeater {
 
39
        id: repeater
 
40
        model: root.candidates
 
41
        delegate: Image {
 
42
            source: modelData
 
43
            height: 0
 
44
            width: 0
 
45
            sourceSize.height: 0
 
46
            sourceSize.width: 0
 
47
        }
62
48
    }
63
49
}