~ubuntu-sdk-team/ubuntu-ui-toolkit/kickLocaleTemplate

« back to all changes in this revision

Viewing changes to examples/ubuntu-ui-toolkit-gallery/MainPage.qml

  • Committer: Tarmac
  • Author(s): Tim Peeters
  • Date: 2015-10-23 18:15:19 UTC
  • mfrom: (1700.3.5 90-gallery-PageHeader)
  • Revision ID: tarmac-20151023181519-8vyg404rfr08adxv
Use PageHeader in the UITK gallery.

Approved by Zsombor Egri, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    id: mainPage
22
22
    title: "Ubuntu UI Toolkit"
23
23
 
24
 
    head.actions: [
25
 
        Action {
26
 
            text: i18n.tr('Right to Left')
27
 
            iconName: 'flash-on'
28
 
            visible: !gallery.rtl
29
 
            onTriggered: gallery.rtl = !gallery.rtl
30
 
        },
31
 
        Action {
32
 
            text: i18n.tr('Left to Right')
33
 
            iconName: 'flash-off'
34
 
            visible: gallery.rtl
35
 
            onTriggered: gallery.rtl = !gallery.rtl
36
 
        },
37
 
        Action {
38
 
            text: i18n.tr('Use dark theme')
39
 
            iconName: 'torch-on'
40
 
            visible: gallery.theme.name == 'Ubuntu.Components.Themes.Ambiance'
41
 
            onTriggered: gallery.theme.name = 'Ubuntu.Components.Themes.SuruDark'
42
 
        },
43
 
        Action {
44
 
            text: i18n.tr('Use light theme')
45
 
            iconName: 'torch-off'
46
 
            visible: gallery.theme.name == 'Ubuntu.Components.Themes.SuruDark'
47
 
            onTriggered: gallery.theme.name = 'Ubuntu.Components.Themes.Ambiance'
48
 
        },
49
 
        Action {
50
 
            text: i18n.tr('About')
51
 
            iconName: "info"
52
 
            onTriggered: mainPage.pageStack.addPageToCurrentColumn(mainPage, Qt.resolvedUrl("About.qml"))
53
 
        }
54
 
    ]
 
24
    header: PageHeader {
 
25
        title: mainPage.title
 
26
        flickable: layout.columns === 1 ? widgetList : null
 
27
        trailingActionBar.actions: [
 
28
            Action {
 
29
                text: i18n.tr('Right to Left')
 
30
                iconName: 'flash-on'
 
31
                visible: !gallery.rtl
 
32
                onTriggered: gallery.rtl = !gallery.rtl
 
33
            },
 
34
            Action {
 
35
                text: i18n.tr('Left to Right')
 
36
                iconName: 'flash-off'
 
37
                visible: gallery.rtl
 
38
                onTriggered: gallery.rtl = !gallery.rtl
 
39
            },
 
40
            Action {
 
41
                text: i18n.tr('Use dark theme')
 
42
                iconName: 'torch-on'
 
43
                visible: gallery.theme.name == 'Ubuntu.Components.Themes.Ambiance'
 
44
                onTriggered: gallery.theme.name = 'Ubuntu.Components.Themes.SuruDark'
 
45
            },
 
46
            Action {
 
47
                text: i18n.tr('Use light theme')
 
48
                iconName: 'torch-off'
 
49
                visible: gallery.theme.name == 'Ubuntu.Components.Themes.SuruDark'
 
50
                onTriggered: gallery.theme.name = 'Ubuntu.Components.Themes.Ambiance'
 
51
            },
 
52
            Action {
 
53
                text: i18n.tr('About')
 
54
                iconName: "info"
 
55
                onTriggered: mainPage.pageStack.addPageToCurrentColumn(mainPage, Qt.resolvedUrl("About.qml"))
 
56
            }
 
57
        ]
 
58
    }
55
59
 
56
60
    onActiveChanged: {
57
61
        if (layout.columns < 2) {
62
66
        }
63
67
    }
64
68
 
65
 
    Rectangle {
66
 
        color: Qt.rgba(0.0, 0.0, 0.0, 0.01)
67
 
        anchors.fill: parent
68
 
 
69
 
        UbuntuListView {
70
 
            id: widgetList
71
 
            objectName: "widgetList"
72
 
            anchors.fill: parent
73
 
            model: WidgetsModel {}
74
 
            currentIndex: -1
75
 
 
76
 
            onCurrentIndexChanged: openPage()
77
 
 
78
 
            function openPage() {
79
 
                if (!mainPage.active || currentIndex < 0) return;
80
 
                var modelData = model.get(currentIndex);
81
 
                var source = Qt.resolvedUrl(modelData.source);
82
 
                mainPage.pageStack.addPageToNextColumn(mainPage, source, {title: modelData.label});
83
 
            }
84
 
 
85
 
            delegate: ListItem {
86
 
                objectName: model.objectName
87
 
                contentItem {
88
 
                    anchors.leftMargin: units.gu(2)
89
 
                    anchors.rightMargin: units.gu(2)
90
 
                }
91
 
                enabled: source != ""
92
 
                // Used by Autopilot
93
 
                property string text: label
94
 
                onClicked: widgetList.currentIndex = index
95
 
                Label {
96
 
                    id: labelItem
97
 
                    anchors {
98
 
                        fill: parent
99
 
                        rightMargin: units.gu(4)
100
 
                    }
101
 
                    text: label
102
 
                    verticalAlignment: Text.AlignVCenter
103
 
                }
104
 
                Icon {
105
 
                    name: "next"
106
 
                    width: units.gu(2)
107
 
                    height: units.gu(2)
108
 
                    anchors {
109
 
                        verticalCenter: parent.verticalCenter
110
 
                        right: parent.right
111
 
                    }
112
 
                }
113
 
            }
114
 
            highlight: Rectangle {
115
 
                color: theme.palette.selected.background
116
 
            }
117
 
            highlightMoveDuration: 0
118
 
        }
 
69
    UbuntuListView {
 
70
        id: widgetList
 
71
        objectName: "widgetList"
 
72
        anchors {
 
73
            fill: parent
 
74
            topMargin: mainPage.header.flickable ? 0 : mainPage.header.height
 
75
        }
 
76
 
 
77
        model: WidgetsModel {}
 
78
        currentIndex: -1
 
79
 
 
80
        onCurrentIndexChanged: openPage()
 
81
 
 
82
        function openPage() {
 
83
            if (!mainPage.active || currentIndex < 0) return;
 
84
            var modelData = model.get(currentIndex);
 
85
            var source = Qt.resolvedUrl(modelData.source);
 
86
            mainPage.pageStack.addPageToNextColumn(mainPage, source, {title: modelData.label});
 
87
        }
 
88
 
 
89
        delegate: ListItem {
 
90
            objectName: model.objectName
 
91
            contentItem {
 
92
                anchors.leftMargin: units.gu(2)
 
93
                anchors.rightMargin: units.gu(2)
 
94
            }
 
95
            enabled: source != ""
 
96
            // Used by Autopilot
 
97
            property string text: label
 
98
            onClicked: widgetList.currentIndex = index
 
99
            Label {
 
100
                id: labelItem
 
101
                anchors {
 
102
                    fill: parent
 
103
                    rightMargin: units.gu(4)
 
104
                }
 
105
                text: label
 
106
                verticalAlignment: Text.AlignVCenter
 
107
            }
 
108
            Icon {
 
109
                name: "next"
 
110
                width: units.gu(2)
 
111
                height: units.gu(2)
 
112
                anchors {
 
113
                    verticalCenter: parent.verticalCenter
 
114
                    right: parent.right
 
115
                }
 
116
            }
 
117
        }
 
118
        highlight: Rectangle {
 
119
            color: theme.palette.selected.background
 
120
        }
 
121
        highlightMoveDuration: 0
119
122
    }
120
123
}