1 /*****************************************************************************
2 * Copyright (C) 2019 VLC authors and VideoLAN
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; either version 2 of the License, or
7 * ( at your option ) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
17 *****************************************************************************/
19 import QtQuick.Controls 2.4
20 import QtQuick.Layouts 1.3
21 import QtQml.Models 2.2
22 import QtGraphicalEffects 1.0
23 import org.videolan.medialib 0.1
25 import "qrc:///widgets/" as Widgets
26 import "qrc:///style/"
33 property string title: ""
34 property string subtitle: ""
35 property bool selected: false
37 property alias sourceSize: cover.sourceSize
38 property string infoLeft: ""
39 property string resolution: ""
40 property bool isVideo: false
41 property bool isNew: false
42 property double progress: 0
43 property string channel: ""
44 property real pictureWidth: isVideo ? VLCStyle.video_normal_width : VLCStyle.cover_small
45 property real pictureHeight: isVideo ? VLCStyle.video_normal_height : VLCStyle.cover_small
47 height: gridItem.height
50 signal addToPlaylistClicked
51 signal itemClicked(Item menuParent, int key, int modifier)
52 signal itemDoubleClicked(Item menuParent, int keys, int modifier)
53 signal contextMenuButtonClicked(Item menuParent)
55 Keys.onMenuPressed: root.contextMenuButtonClicked(cover_bg)
57 Accessible.role: Accessible.Cell
58 Accessible.name: title
62 width: childrenRect.width
63 height: childrenRect.height
69 if (mouse.button === Qt.RightButton)
70 contextMenuButtonClicked(cover_bg);
72 root.itemClicked(cover_bg,mouse.button, mouse.modifiers);
76 root.itemDoubleClicked(cover_bg,mouse.buttons, mouse.modifiers)
78 width: childrenRect.width
79 height: childrenRect.height
80 acceptedButtons: Qt.RightButton | Qt.LeftButton
81 Keys.onMenuPressed: root.contextMenuButtonClicked(cover_bg)
85 width: root.pictureWidth
86 height: root.pictureHeight
87 anchors.top: mouseArea.top
88 property bool highlighted: selected || root.activeFocus
93 height: picture.height
96 color: VLCStyle.colors.getBgColor(
97 selected, mouseArea.containsMouse,
103 anchors.margins: VLCStyle.margin_normal
106 Behavior on anchors.margins {
114 visible: isVideo && root.progress > 0
116 bottom: parent.bottom
125 visible: root.resolution !== ""
129 topMargin: VLCStyle.margin_xxsmall
130 leftMargin: VLCStyle.margin_xxsmall
132 text: root.resolution
137 left: resolutionLabel.right
138 topMargin: VLCStyle.margin_xxsmall
139 leftMargin: VLCStyle.margin_xxxsmall
141 visible: root.channel !== ""
150 anchors.margins: VLCStyle.margin_xxsmall
152 when: mouseArea.containsMouse
158 anchors.margins: VLCStyle.margin_xxsmall
160 when: !mouseArea.containsMouse
161 && picture.highlighted
167 anchors.margins: VLCStyle.margin_xsmall
169 when: !mouseArea.containsMouse
170 && !picture.highlighted
179 height: childrenRect.height
180 anchors.top: picture.bottom
184 height: childrenRect.height
187 property bool showTooltip: false
191 rightMargin: VLCStyle.margin_small
192 leftMargin: VLCStyle.margin_small
196 visible: textTitleRect.showTooltip
197 x: (parent.width/2) - (width/2)
198 y: (parent.height/2) - (height/2)
205 color: VLCStyle.colors.text
206 font.pixelSize: VLCStyle.fontSize_normal
207 property bool _needsToScroll: (textTitleRect.width < textTitle.width)
209 state: ((mouseArea.containsMouse || picture.highlighted)
210 && textTitle._needsToScroll) ? "HOVERED" : "RELEASED"
217 x: textTitleRect.width - textTitle.width - VLCStyle.margin_small
233 SequentialAnimation {
246 script: textTitle.state = "RELEASED"
258 onClicked: textTitleRect.showTooltip = true
259 onExited: textTitleRect.showTooltip = false
267 top: textTitleRect.bottom
268 rightMargin: VLCStyle.margin_small
269 leftMargin: VLCStyle.margin_small
272 font.weight: Font.Light
273 elide: Text.ElideRight
274 font.pixelSize: VLCStyle.fontSize_small
275 color: VLCStyle.colors.lightText
276 horizontalAlignment: Qt.AlignHCenter
284 rightMargin: VLCStyle.margin_small
285 leftMargin: VLCStyle.margin_small
286 topMargin: VLCStyle.margin_xxxsmall
289 Layout.alignment: Qt.AlignLeft
290 font.pixelSize: VLCStyle.fontSize_small
291 color: VLCStyle.colors.videosGridInfoLeft
296 Layout.alignment: Qt.AlignRight
297 font.pixelSize: VLCStyle.fontSize_small
298 color: VLCStyle.colors.accent