@@ -1,201 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.0
18−import Ubuntu.Components 0.1
19−import "../Components"
20−import "../Components/ListItems" as ListItems
21−import "Video"
22−
23−ScopeView {
24− id: scopeView
25− property alias previewShown: previewLoader.onScreen
26−
27− property var categoryNames: [
28− i18n.tr("Featured"),
29− i18n.tr("Recent"),
30− i18n.tr("New Releases"),
31− i18n.tr("Popular Online")
32− ]
33−
34− onIsCurrentChanged: {
35− pageHeader.resetSearch();
36− }
37−
38− onMovementStarted: categoryView.showHeader()
39−
40− Binding {
41− target: scopeView.scope
42− property: "searchQuery"
43− value: pageHeader.searchQuery
44− }
45−
46− Connections {
47− target: panel
48− onSearchClicked: if (isCurrent) {
49− pageHeader.triggerSearch()
50− categoryView.showHeader()
51− }
52− }
53−
54− function getRenderer(categoryId) {
55− switch (categoryId) {
56− case "featured": return "Video/VideosCarousel.qml"
57− default: return "Video/VideosFilterGrid.qml"
58− }
59− }
60−
61− OpenEffect {
62− id: effect
63− anchors {
64− fill: parent
65− bottomMargin: -bottomOverflow
66− }
67− sourceItem: categoryView
68−
69− enabled: gap > 0.0
70−
71− topGapPx: (1 - gap) * positionPx
72− topOpacity: Math.max(0, (1 - gap * 1.2))
73− bottomGapPx: positionPx + gap * (targetBottomGapPx - positionPx)
74− bottomOverflow: units.gu(6)
75− bottomOpacity: 1 - (gap * 0.8)
76−
77− property int targetBottomGapPx: height - units.gu(8) - bottomOverflow
78− property real gap: previewLoader.open ? 1.0 : 0.0
79−
80− Behavior on gap {
81− NumberAnimation {
82− duration: 200
83− easing.type: Easing.InOutQuad
84− onRunningChanged: {
85− if (!previewLoader.open && !running) {
86− previewLoader.onScreen = false;
87− }
88− }
89− }
90− }
91− }
92−
93− ScopeListView {
94− id: categoryView
95− anchors.fill: parent
96− model: scopeView.categories
97− forceNoClip: previewLoader.onScreen
98−
99− onAtYEndChanged: if (atYEnd) endReached()
100− onMovingChanged: if (moving && atYEnd) endReached()
101−
102− delegate: ListItems.Base {
103− id: base
104− highlightWhenPressed: false
105− property string categoryId: model.categoryId
106−
107− Loader {
108− id: loader
109− anchors { top: parent.top; left: parent.left; right: parent.right }
110− source: scopeView.getRenderer(base.categoryId)
111− onLoaded: {
112− item.model = results
113− }
114−
115− Connections {
116− target: loader.item
117− onClicked: {
118− var dataItem;
119− // VideosCarousel and VideosFilterGrid have different
120− // clicked signals, accomodate for that
121− if (categoryId == "featured") {
122− var fileUri = delegateItem.model.uri.replace(/^[^:]+:/, "")
123− dataItem = {fileUri: fileUri, nfoUri: delegateItem.model.comment}
124− } else {
125− dataItem = data;
126− }
127− if (dataItem.nfoUri != "") {
128− previewLoader.videoData = dataItem;
129− previewLoader.open = true;
130− effect.positionPx = mapToItem(categoryView, 0, itemY).y;
131− }
132− }
133− }
134− }
135− }
136−
137− sectionProperty: "name"
138− sectionDelegate: ListItems.Header {
139− width: categoryView.width
140− text: i18n.tr(section)
141− }
142−
143− pageHeader: PageHeader {
144− id: pageHeader
145− width: categoryView.width
146− text: i18n.tr("Videos")
147− searchEntryEnabled: true
148− searchHistory: scopeView.searchHistory
149− }
150− }
151−
152− Loader {
153− id: previewLoader
154− height: effect.bottomGapPx - effect.topGapPx
155− anchors {
156− top: parent.top
157− topMargin: effect.topGapPx
158− left: parent.left
159− right: parent.right
160− }
161− sourceComponent: onScreen ? previewComponent : undefined
162−
163− property bool open: false
164− property bool onScreen: false
165− property var videoData
166−
167−
168− onOpenChanged: {
169− if (open) {
170− onScreen = true;
171− }
172− }
173−
174− onLoaded: {
175− item.item = videoData;
176− }
177− }
178−
179− Component {
180− id: previewComponent
181−
182− VideoPreview {
183− id: preview
184− anchors.fill: parent
185− onClose: open = false;
186− }
187− }
188−
189− // TODO: Move as InverseMouseArea to DashPreview
190− MouseArea {
191− enabled: previewLoader.onScreen
192− anchors {
193− fill: parent
194− topMargin: effect.bottomGapPx
195− }
196− onClicked: {
197− previewLoader.open = false;
198− }
199− }
200−
201−}