~bhdouglass/ubuntu-touch-tweak-tool/fix-disappearing-options

« back to all changes in this revision

Viewing changes to src/app/qml/main.qml

  • Committer: Stefano Verzegnassi
  • Date: 2016-04-16 17:04:08 UTC
  • Revision ID: stefano92.100@gmail.com-20160416170408-t0ck3hoi0qifmehw
Stable codebase for 0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import QtQuick 2.4
19
19
import Ubuntu.Components 1.3
20
20
import com.ubuntu.PamAuthentication 0.1
21
 
 
22
 
// For making scripts executable
23
 
import StorageManager 1.0
24
 
 
25
 
import "components"
26
 
import "components/Models" as Models
 
21
import QtQml.Models 2.1
27
22
 
28
23
MainView {
29
24
    id: mainView
30
25
    objectName: "mainView"
31
26
    applicationName: "ut-tweak-tool.sverzegnassi"
32
27
 
33
 
    function showNotification(args) {
34
 
        var component = Qt.createComponent("Toast.qml")
35
 
        var toast = component.createObject(mainView, args);
36
 
 
37
 
        return toast;
38
 
    }
39
 
 
40
 
    function showNotificationWithAction(args) {
41
 
        var component = Qt.createComponent("ToastWithAction.qml")
42
 
        var toast = component.createObject(mainView, args);
43
 
 
44
 
        return toast;
45
 
    }
46
 
 
47
28
    width: units.gu(100)
48
29
    height: units.gu(76)
49
 
    theme.name: "TweakTool.OrangeTheme"
 
30
 
 
31
    Component.onCompleted: {
 
32
        window.minimumWidth = units.gu(100)
 
33
        window.minimumHeight = units.gu(60)
 
34
    }
50
35
 
51
36
    AdaptivePageLayout {
52
37
        id: pageStack
53
38
        anchors.fill: parent
54
39
 
55
40
        function push(page, properties) {
56
 
            // This function is called 'push' so we don't need to update
57
 
            // all the code.
58
41
            return pageStack.addPageToNextColumn(primaryPage, page, properties)
59
42
        }
60
43
 
61
44
        primaryPage: Page {
62
45
            id: mainPage
63
 
 
64
 
            property alias currentSectionIndex: view.currentIndex
65
 
 
66
 
            title: i18n.tr("UT Tweak Tool")
67
 
 
68
 
            head.sections.model: [ i18n.tr("Behavior"), i18n.tr("Apps & Scopes"), i18n.tr("System") ]
 
46
            header: PageHeader {
 
47
                title: i18n.tr("Tweak Tool")
 
48
                sections {
 
49
                    model: [ i18n.tr("Behavior"), i18n.tr("Apps & Scopes"), i18n.tr("System") ]
 
50
                    onSelectedIndexChanged: {
 
51
                        // Current section has changed, if there was an opened page
 
52
                        // in the second column, it is not anymore related to the
 
53
                        // new current section.
 
54
                        mainPage.pageStack.removePages(mainPage)
 
55
                    }
 
56
                }
 
57
            }
69
58
 
70
59
            ListView {
71
60
                id: view
72
 
                anchors.fill: parent
 
61
                anchors {
 
62
                    top: mainPage.header.bottom
 
63
                    bottom: parent.bottom
 
64
                    left: parent.left
 
65
                    right: parent.right
 
66
                }
73
67
 
74
68
                clip: true
75
 
 
76
69
                orientation: ListView.Horizontal
77
70
                interactive: false
78
71
                snapMode: ListView.SnapOneItem
79
 
 
80
72
                highlightMoveDuration: UbuntuAnimation.FastDuration
81
 
 
82
 
                currentIndex: mainPage.head.sections.selectedIndex
83
 
 
84
 
                onCurrentIndexChanged: {
85
 
                    // Current section has changed, if there was an opened page
86
 
                    // in the second column, it is not anymore related to the
87
 
                    // new current section.
88
 
                    mainPage.pageStack.removePages(mainPage)
89
 
                }
90
 
 
91
 
                delegate: Loader {
92
 
                    width: view.width
93
 
                    height: view.height
94
 
 
95
 
                    source: modelData
96
 
                }
97
 
 
98
 
                model: [
99
 
                    Qt.resolvedUrl("behaviourTab/BehaviourTab.qml"),
100
 
                    Qt.resolvedUrl("applicationsTab/ApplicationsTab.qml"),
101
 
                    Qt.resolvedUrl("systemTab/SystemTab.qml")
102
 
                ]
 
73
                currentIndex: mainPage.header.sections.selectedIndex
 
74
 
 
75
                model: ObjectModel {
 
76
                    Loader {
 
77
                        width: view.width
 
78
                        height: view.height
 
79
                        asynchronous: true
 
80
                        source: Qt.resolvedUrl("behaviourTab/BehaviourTab.qml")
 
81
                    }
 
82
                    Loader {
 
83
                        width: view.width
 
84
                        height: view.height
 
85
                        asynchronous: true
 
86
                        source: Qt.resolvedUrl("applicationsTab/ApplicationsTab.qml")
 
87
                    }
 
88
                    Loader {
 
89
                        width: view.width
 
90
                        height: view.height
 
91
                        asynchronous: true
 
92
                        source: Qt.resolvedUrl("systemTab/SystemTab.qml")
 
93
                    }
 
94
                }
103
95
            }
104
96
        }
105
97
    }
106
98
 
107
 
    Models.ClickModel { id: clickModel }
108
 
 
109
 
    AuthenticationService {
110
 
                id: pam
111
 
        serviceName: "ut-tweak-tool"
112
 
        onDenied: Qt.quit();
 
99
    property alias pam: pamLoader.item
 
100
    Loader {
 
101
        id: pamLoader
 
102
        // A bit nonsense, but we're not using pam for security
 
103
        asynchronous: true
 
104
        sourceComponent: AuthenticationService {
 
105
            id: pam
 
106
            serviceName: "ut-tweak-tool"
 
107
            onDenied: Qt.quit();
 
108
        }
113
109
    }
114
110
}
115
111