~unity-team/unity-scopes-shell/trunk

« back to all changes in this revision

Viewing changes to tools/dummy.qml

  • Committer: Pete Woods
  • Date: 2014-06-11 17:08:34 UTC
  • mto: (104.1.3 unity-scopes-shell)
  • mto: This revision was merged to the branch mainline in revision 105.
  • Revision ID: pete.woods@canonical.com-20140611170834-8hw3e77gqpq4zg74
Initial commit of scope settings

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import QtQuick 2.0
 
2
import Ubuntu.Components 1.1
 
3
import Unity 0.2
 
4
 
 
5
MainView {
 
6
    id: app
 
7
    applicationName: "example"
 
8
    width: units.gu(40)
 
9
    height: units.gu(60)
 
10
 
 
11
    Scopes {
 
12
        id: scopes
 
13
        onLoadedChanged: {
 
14
            app.scope = scopes.getScope("musicaggregator")
 
15
        }
 
16
    }
 
17
 
 
18
    property var scope: ListModel{}
 
19
 
 
20
    Page {
 
21
        title: "Settings for " + scope.name
 
22
 
 
23
        ListView {
 
24
            anchors.fill: parent
 
25
            spacing: units.gu(1)
 
26
 
 
27
            model: scope.settings
 
28
            delegate: Loader {
 
29
                id: loader
 
30
                source: type + "SettingsWidget.qml"
 
31
                onLoaded: {
 
32
                    item.properties = properties
 
33
                    if (type != "boolean") {
 
34
                        loader.width = parent.width
 
35
                    }
 
36
                    if(type == "list") {
 
37
                        loader.height = units.gu(10)
 
38
                    }
 
39
                }
 
40
                property var value: item.value
 
41
                onValueChanged: {
 
42
                    if (item.properties) {
 
43
                        scope.settings.setValue(settingId, value)
 
44
                    }
 
45
                }
 
46
            }
 
47
            section.property: "displayName"
 
48
            section.delegate: Text {
 
49
                width: parent.width
 
50
                text: section
 
51
            }
 
52
        }
 
53
    }
 
54
}