~aaronp/software-center/tests

« back to all changes in this revision

Viewing changes to softwarecenter/ui/qml/sc.qml

  • Committer: Aaron Peachey
  • Date: 2011-06-20 09:50:42 UTC
  • mfrom: (1805.10.18 software-center)
  • Revision ID: alpeachey@gmail.com-20110620095042-a5s30o4vtx9l9fgr
mergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
import QtQuick 1.0
22
22
 
23
 
Rectangle {
 
23
FocusScope {
24
24
    width: 600
25
25
    height: 600
 
26
    focus: true
26
27
 
27
28
    SystemPalette {
28
29
        id: activePalette
29
30
        colorGroup: SystemPalette.Active
30
31
    }
31
32
 
32
 
    function showCategoriesView()
33
 
    {
34
 
        console.log("showCategoryView")
35
 
        catview.x = 0
36
 
        
37
 
        // FIXME: would be nice to do this somewhere else
38
 
        pkglistmodel.setCategory("")
39
 
    }
40
 
 
41
 
    function showListView()
42
 
    {
43
 
        console.log("showListView")
44
 
        catview.x = 0 - listview.width
45
 
    }
46
 
 
47
 
    function showDetailsView()
48
 
    {
49
 
        console.log("showDetailsView")
50
 
        catview.x =  0 - listview.width - detailsview.width
51
 
 
52
 
        // FIXME: actually we could do this on a property change event
53
 
        //        for listview.x, if it changes to "0" trigger load
54
 
        reviewslistmodel.getReviews(list.currentItem.pkgname)
55
 
    }
56
 
 
57
33
    NavigationBar {
58
34
        id: navigation
59
35
        anchors.left: parent.left
60
36
        anchors.right: parent.right
61
37
        anchors.top: parent.top
62
38
        focus: true
63
 
        KeyNavigation.down: (listview.x == 0) ? list : null
 
39
        KeyNavigation.down: (switcher.currentFrame() == listview) ? switcher : null
 
40
 
 
41
        property string searchResults: qsTr("Search Results")
 
42
 
 
43
        property string categoryKey: "category"
 
44
        property string searchresultsKey: "searchresults"
64
45
 
65
46
        Binding {
66
47
            target: pkglistmodel
68
49
            value: navigation.searchQuery
69
50
        }
70
51
 
71
 
        onSearchQueryChanged: if (searchQuery.length > 0) showListView()
72
 
        onSearchActivated: showListView()
73
 
    }
74
 
 
75
 
    CategoriesView {
 
52
        Component.onCompleted: breadcrumbs.addCrumb(qsTr("Get Software"), catview, "")
 
53
 
 
54
        onCrumbClicked: {
 
55
            if (index == 0 ||
 
56
                (index == 1 && navigation.breadcrumbs.model.get(1).key == categoryKey)) {
 
57
                searchQuery = ""
 
58
            }
 
59
            switcher.goToFrame(navigation.breadcrumbs.model.get(index).view)
 
60
        }
 
61
 
 
62
        searchBoxVisible: switcher.currentFrame() != detailsview
 
63
 
 
64
        function doSearch() {
 
65
            if (searchQuery.length > 0) {
 
66
                var bc = navigation.breadcrumbs
 
67
                if (bc.count == 1 ||
 
68
                    (bc.count == 2 && bc.model.get(1).key == categoryKey)) {
 
69
                    bc.addCrumb(searchResults, listview, searchresultsKey)
 
70
                }
 
71
                switcher.goToFrame(listview)
 
72
            }
 
73
        }
 
74
        onSearchQueryChanged: doSearch()
 
75
        onSearchActivated: doSearch()
 
76
    }
 
77
 
 
78
    FrameSwitcher {
 
79
        id: switcher
 
80
        anchors.left: parent.left
 
81
        anchors.right: parent.right
 
82
        anchors.top: navigation.bottom
 
83
        anchors.bottom: parent.bottom
 
84
        duration: 180
 
85
    }
 
86
 
 
87
    Frame {
76
88
        id: catview
77
 
        width: parent.width
78
 
        height: parent.height
79
 
        anchors.top: navigation.bottom
80
 
 
81
 
        Behavior on x {
82
 
            NumberAnimation { duration: 180 }
83
 
        }
84
 
 
85
 
        onCategoryChanged: {
86
 
            pkglistmodel.setCategory(catname)
87
 
            showListView()
 
89
 
 
90
        CategoriesView {
 
91
            anchors.fill: parent
 
92
            focus: true
 
93
            onCategoryChanged: {
 
94
                pkglistmodel.setCategory(catname)
 
95
                navigation.breadcrumbs.addCrumb(catname, listview, navigation.categoryKey)
 
96
                switcher.goToFrame(listview)
 
97
            }
88
98
        }
89
99
    }
90
100
 
91
 
    Rectangle {
 
101
    Frame {
92
102
        id: listview
93
103
 
94
 
        width: parent.width
95
 
        anchors.left: catview.right
96
 
        anchors.top: navigation.bottom
97
 
        anchors.bottom: parent.bottom
98
 
 
99
 
        Behavior on x {
100
 
            NumberAnimation { duration: 180 }
101
 
        }
102
 
 
103
104
        AppListView {
104
105
            id: list
 
106
            focus: true
105
107
            model: pkglistmodel
106
108
            anchors.left: parent.left
107
109
            anchors.right: parent.right
109
111
            anchors.bottom: statusframe.top
110
112
 
111
113
            KeyNavigation.up: navigation
 
114
 
 
115
            onMoreInfoClicked: {
 
116
                navigation.breadcrumbs.addCrumb(currentItem.appname, detailsview, "")
 
117
                switcher.goToFrame(detailsview)
 
118
            }
112
119
        }
113
120
 
114
121
        Rectangle {
136
143
        }
137
144
    }
138
145
 
139
 
    DetailsView {
 
146
    Frame {
140
147
        id: detailsview
141
 
        width: parent.width
142
 
        anchors.left: listview.right
143
 
        anchors.top: navigation.bottom
144
 
        anchors.bottom: parent.bottom
145
148
 
146
 
        Behavior on x {
147
 
            NumberAnimation { duration: 180 }
 
149
        DetailsView {
 
150
            id: details
 
151
            anchors.fill: parent
 
152
            focus: true
 
153
            onBackClicked: {
 
154
                navigation.breadcrumbs.removeCrumb()
 
155
                switcher.goToFrame(listview)
 
156
            }
148
157
        }
 
158
        onShown: { details.loadThumbnail();
 
159
                   details.loadReviews();
 
160
                 }
 
161
        onHidden: details.unloadThumbnail()
 
162
    }
 
163
 
 
164
    Component.onCompleted: {
 
165
        switcher.pushFrame(catview)
 
166
        switcher.pushFrame(listview)
 
167
        switcher.pushFrame(detailsview)
149
168
    }
150
169
}
151
170