2
* Copyright (C) 2013 Canonical, Ltd.
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.
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.
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/>.
18
import Ubuntu.Components 0.1
19
import "../Components"
20
import "../Components/ListItems" as ListItems
25
property alias previewShown: previewLoader.onScreen
28
pageHeader.resetSearch();
31
onMovementStarted: categoryView.showHeader()
35
property: "searchQuery"
36
value: pageHeader.searchQuery
41
onSearchClicked: if (isCurrent) {
42
pageHeader.triggerSearch()
43
categoryView.showHeader()
47
/* Workaround for bug: https://bugreports.qt-project.org/browse/QTBUG-28403
48
When using Loader to load external QML file in the list deelgate, the ListView has
49
a bug where it can position the delegate content to overlap the section header
50
of the ListView - a workaround is to use sourceComponent of Loader instead */
51
Component { id: videosFilterGrid; VideosFilterGrid {} }
52
Component { id: videosCarousel; VideosCarousel {} }
54
function getRenderer(categoryId) {
56
case 0: return videosCarousel
57
default: return videosFilterGrid
65
bottomMargin: -bottomOverflow
67
sourceItem: categoryView
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)
77
property int targetBottomGapPx: height - units.gu(8) - bottomOverflow
78
property real gap: previewLoader.open ? 1.0 : 0.0
83
easing.type: Easing.InOutQuad
85
if (!previewLoader.open && !running) {
86
previewLoader.onScreen = false;
93
ListViewWithPageHeader {
96
model: lensView.categories
97
clipListView: !previewLoader.onScreen
99
onAtYEndChanged: if (atYEnd) endReached()
100
onMovingChanged: if (moving && atYEnd) endReached()
102
delegate: ListItems.Base {
104
highlightWhenPressed: false
105
property int categoryIndex: index
106
property int categoryId: id
110
anchors { top: parent.top; left: parent.left; right: parent.right }
111
sourceComponent: lensView.getRenderer(base.categoryId)
121
// VideosCarousel and VideosFilterGrid have different
122
// clicked signals, accomodate for that
123
if (categoryId == 0) {
124
var fileUri = delegateItem.model.column_0.replace(/^[^:]+:/, "")
125
dataItem = {fileUri: fileUri, nfoUri: delegateItem.model.column_5}
129
if (dataItem.nfoUri != "") {
130
previewLoader.videoData = dataItem;
131
previewLoader.open = true;
132
effect.positionPx = mapToItem(categoryView, 0, itemY).y;
139
sectionProperty: "name"
140
sectionDelegate: ListItems.Header {
141
width: categoryView.width
145
pageHeader: PageHeader {
147
width: categoryView.width
148
text: i18n.tr("Videos")
149
searchEntryEnabled: true
150
searchHistory: lensView.searchHistory
156
height: effect.bottomGapPx - effect.topGapPx
159
topMargin: effect.topGapPx
163
sourceComponent: onScreen ? previewComponent : undefined
165
property bool open: false
166
property bool onScreen: false
167
property var videoData
177
item.item = videoData;
187
onClose: open = false;
191
// TODO: Move as InverseMouseArea to DashPreview
193
enabled: previewLoader.onScreen
196
topMargin: effect.bottomGapPx
199
previewLoader.open = false;