1 /*****************************************************************************
2 * Copyright (C) 2020 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 *****************************************************************************/
20 import QtQuick.Controls 2.4
21 import QtQml.Models 2.2
23 import QtGraphicalEffects 1.0
25 import "qrc:///style/"
26 import "qrc:///playlist/" as Playlist
31 //---------------------------------------------------------------------------------------------
33 //---------------------------------------------------------------------------------------------
35 readonly property int coverSize: VLCStyle.icon_normal
37 property VLCColors colors: VLCStyle.colors
39 //---------------------------------------------------------------------------------------------
42 property var _model: {"covers": [], "title": "", "count": 0}
44 readonly property int _maxCovers: 3
46 readonly property int _displayedCoversCount: Math.min(_model.count, _maxCovers + 1)
48 //---------------------------------------------------------------------------------------------
50 //---------------------------------------------------------------------------------------------
54 width: VLCStyle.colWidth(2)
56 height: coverSize + VLCStyle.margin_small * 2
58 opacity: visible ? 0.90 : 0
62 //---------------------------------------------------------------------------------------------
64 //---------------------------------------------------------------------------------------------
66 Drag.onActiveChanged: {
68 _model = updateComponents(_maxCovers);
69 mainInterface.setCursor(Qt.DragMoveCursor);
71 mainInterface.restoreCursor();
75 //---------------------------------------------------------------------------------------------
77 //---------------------------------------------------------------------------------------------
79 function coversXPos(index) {
80 return VLCStyle.margin_small + (coverSize / 3) * index;
83 //---------------------------------------------------------------------------------------------
86 // return {covers: [{artwork: <string> or cover: <component>},..maxCovers]
87 // , title: <string>, *subtitle: <string>, count: <int> /*all selected*/}
89 function updateComponents(maxCovers) {
90 console.assert(false, "updateComponents is not implemented.");
93 function getSelectedInputItem() {
94 console.assert(false, "getSelectedInputItem is not implemented.");
99 //---------------------------------------------------------------------------------------------
101 //---------------------------------------------------------------------------------------------
103 Behavior on opacity {
105 easing.type: Easing.InOutSine
110 //---------------------------------------------------------------------------------------------
112 //---------------------------------------------------------------------------------------------
118 border.color: colors.buttonBorder
119 border.width: VLCStyle.dp(1, VLCStyle.scale)
120 radius: VLCStyle.dp(6, VLCStyle.scale)
125 glowRadius: VLCStyle.dp(8, VLCStyle.scale)
126 color: colors.glowColor
135 x: dragItem.coversXPos(index)
136 y: (dragItem.height - height) / 2
137 width: dragItem.coverSize
138 height: dragItem.coverSize
143 radius: coverRepeater.count > 1 ? dragItem.coverSize : VLCStyle.dp(2, VLCStyle.scale)
150 verticalOffset: VLCStyle.dp(1, VLCStyle.scale)
151 radius: VLCStyle.dp(3, VLCStyle.scale)
152 samples: 2 * radius + 1
153 color: Qt.rgba(0, 0, 0, .18)
160 verticalOffset: VLCStyle.dp(6, VLCStyle.scale)
161 radius: VLCStyle.dp(14, VLCStyle.scale)
162 samples: 2 * radius + 1
163 color: Qt.rgba(0, 0, 0, .18)
169 // parent may provide extra data with covers
170 property var model: modelData
172 anchors.centerIn: parent
173 sourceComponent: (!modelData.artwork || modelData.artwork.toString() === "") ? modelData.cover : artworkLoader
175 layer.effect: OpacityMask {
176 maskSource: Rectangle {
185 if (modelData.artwork && modelData.artwork.toString() !== "")
186 item.source = modelData.artwork
193 border.width: VLCStyle.dp(1, VLCStyle.scale)
194 border.color: colors.buttonBorder
204 x: dragItem.coversXPos(_maxCovers)
205 y: (dragItem.height - height) / 2
206 width: dragItem.coverSize
207 height: dragItem.coverSize
208 radius: dragItem.coverSize
209 visible: _model.count > dragItem._maxCovers
211 border.width: VLCStyle.dp(1, VLCStyle.scale)
212 border.color: colors.buttonBorder
215 anchors.centerIn: parent
217 text: "+" + (_model.count - dragItem._maxCovers)
223 verticalOffset: VLCStyle.dp(1, VLCStyle.scale)
224 radius: VLCStyle.dp(3, VLCStyle.scale)
225 samples: 2 * radius + 1
226 color: Qt.rgba(0, 0, 0, .18)
227 anchors.fill: extraCovers
229 visible: extraCovers.visible
234 verticalOffset: VLCStyle.dp(6, VLCStyle.scale)
235 radius: VLCStyle.dp(14, VLCStyle.scale)
236 samples: 2 * radius + 1
237 color: Qt.rgba(0, 0, 0, .18)
238 anchors.fill: extraCovers
240 visible: extraCovers.visible
246 anchors.verticalCenter: parent.verticalCenter
247 x: dragItem.coversXPos(_displayedCoversCount - 1) + dragItem.coverSize + VLCStyle.margin_small
248 width: parent.width - x - VLCStyle.margin_small
249 spacing: VLCStyle.margin_xxxsmall
254 height: titleLabel.height
261 visible: text && text !== ""
263 elide: Text.ElideNone
264 font.pixelSize: VLCStyle.fontSize_large
265 color: colors.buttonText
272 visible: text && text !== ""
274 text: _model.subtitle || i18n.qtr("%1 selected").arg(_model.count)
282 fillMode: Image.PreserveAspectCrop