~macslow/unity8/use-set-progress-api

« back to all changes in this revision

Viewing changes to Dash/DashHome.qml

  • Committer: Nick Dedekind
  • Date: 2013-07-08 11:30:25 UTC
  • mfrom: (2.5.97 8.indicators-client.control)
  • mto: This revision was merged to the branch mainline in revision 149.
  • Revision ID: nicholas.dedekind@gmail.com-20130708113025-bs6k7b3tgn2ayc4k
merged with parent

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
    ListModel {
33
33
        id: categoryListModel
34
34
        // specifies page's content categories, type of delegate and model used in each category
35
 
        ListElement { category: "Frequent Apps";         component: "AppsGrid";       modelName: "AppsModel" }
36
 
        ListElement { category: "Recent Music";          component: "MusicGrid";      modelName: "MusicModel" }
37
 
        ListElement { category: "Videos Popular Online"; component: "VideosGrid";     modelName: "VideosModel" }
 
35
        ListElement { category: "Frequent Apps";         component: "Apps/ApplicationsFilterGrid.qml";  modelName: "AppsModel" }
 
36
        ListElement { category: "Recent Music";          component: "Music/MusicFilterGrid.qml";        modelName: "MusicModel" }
 
37
        ListElement { category: "Videos Popular Online"; component: "Video/VideosFilterGrid.qml";       modelName: "VideosModel" }
38
38
        function getCategory(category1) {
39
39
            if (category1 === "Frequent Apps") {
40
40
                return i18n.tr("Frequent Apps");
110
110
                                  "VideosModel": videosFilter,
111
111
                                 }
112
112
 
113
 
    /* Workaround for bug: https://bugreports.qt-project.org/browse/QTBUG-28403
114
 
       When using Loader to load external QML file in the list deelgate, the ListView has
115
 
       a bug where it can position the delegate content to overlap the section header
116
 
       of the ListView - a workaround is to use sourceComponent of Loader instead */
117
 
    Component {
118
 
        id: applicationsFilterGrid
119
 
        ApplicationsFilterGrid {
120
 
            objectName: "dashHomeApplicationsGrid"
121
 
            onClicked: shell.activateApplication(data);
122
 
        }
123
 
    }
124
 
 
125
 
    Component { id: musicGrid;      MusicFilterGrid {}  }
126
 
    Component { id: videosGrid;     VideosFilterGrid {} }
127
 
    property var componentModels: {
128
 
                "AppsGrid": applicationsFilterGrid,
129
 
                "MusicGrid": musicGrid,
130
 
                "VideosGrid": videosGrid,
131
 
    }
132
 
 
133
113
    ScopeListView {
134
114
        id: listView
135
115
        anchors.fill: parent
145
125
 
146
126
            Loader {
147
127
                anchors { top: parent.top; left: parent.left; right: parent.right }
148
 
                sourceComponent: componentModels[component]
 
128
                source: component
149
129
                onLoaded: {
150
130
                    item.model = categoryModels[modelName]
151
131
 
152
132
                    //FIXME: workaround for lack of previews for videos in Home scope.
153
133
                    //Need to connect to the clicked() signal here and act upon it here instead.
154
 
                    if (component === "VideosGrid") {
 
134
                    if (modelName === "VideosModel") {
155
135
                        function playVideo(index, data) {
156
136
                            if (data.fileUri) {
157
137
                                shell.activateApplication('/usr/share/applications/mediaplayer-app.desktop', "/usr/share/demo-assets/videos/" + data.fileUri);
159
139
                        }
160
140
 
161
141
                        item.clicked.connect(playVideo);
 
142
                    } else if (modelName === "AppsModel") {
 
143
                        function activateApplication(index, data) {
 
144
                            shell.activateApplication(data);
 
145
                        }
 
146
 
 
147
                        item.objectName = "dashHomeApplicationsGrid";
 
148
                        item.clicked.connect(activateApplication);
162
149
                    }
163
150
                }
164
151
            }