diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am index 8fd55c87efd479783d9503994d0b224e9668e14e..456f245ae0d9d9a109672d052753f9f72322739b 100644 --- a/modules/gui/qt/Makefile.am +++ b/modules/gui/qt/Makefile.am @@ -698,6 +698,7 @@ libqt_plugin_la_QML = \ gui/qt/medialibrary/qml/MusicAlbumsDisplay.qml \ gui/qt/medialibrary/qml/MusicAlbumsGridExpandDelegate.qml \ gui/qt/medialibrary/qml/MusicArtist.qml \ + gui/qt/medialibrary/qml/MusicArtistDelegate.qml \ gui/qt/medialibrary/qml/MusicArtistsAlbums.qml \ gui/qt/medialibrary/qml/MusicAllArtists.qml \ gui/qt/medialibrary/qml/MusicArtistsDisplay.qml \ diff --git a/modules/gui/qt/medialibrary/qml/MusicArtistDelegate.qml b/modules/gui/qt/medialibrary/qml/MusicArtistDelegate.qml new file mode 100644 index 0000000000000000000000000000000000000000..de7270717b4d90ff908c1009b26efa0365754553 --- /dev/null +++ b/modules/gui/qt/medialibrary/qml/MusicArtistDelegate.qml @@ -0,0 +1,172 @@ +/***************************************************************************** + * Copyright (C) 2020 VLC authors and VideoLAN + * + * Authors: Benjamin Arnaud <bunjee@omega.gg> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * ( at your option ) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +import QtQuick 2.11 +import QtQuick.Controls 2.4 +import QtQuick.Layouts 1.11 + +import org.videolan.controls 0.1 + +import "qrc:///widgets/" as Widgets +import "qrc:///style/" + +Control { + id: root + + // Properties + + /* required */ property var artistModel + + property bool isCurrent: false + + // Aliases + // Private + + property alias _isHover: mouseArea.containsMouse + + // Signals + + signal itemClicked(variant mouse) + + signal itemDoubleClicked(variant mouse) + + // Settings + + height: VLCStyle.play_cover_small + (VLCStyle.margin_xsmall * 2) + + // Childs + + background: Widgets.AnimatedBackground { + id: background + + active: visualFocus + + backgroundColor: { + if (isCurrent) + return VLCStyle.colors.gridSelect; + else if (_isHover) + return VLCStyle.colors.listHover; + else + return VLCStyle.colors.setColorAlpha(VLCStyle.colors.listHover, 0); + } + } + + contentItem: MouseArea { + id: mouseArea + + hoverEnabled: true + + drag.axis: Drag.XAndYAxis + + drag.target: Widgets.DragItem { + function updateComponents(maxCovers) { + return { + covers: [{ artwork: (model.cover) ? model.cover + : VLCStyle.noArtArtistSmall }], + + title: (model.name) ? model.name + : i18n.qtr("Unknown artist"), + + count: 1 + } + } + + function getSelectedInputItem() { + return artistModel.getItemsForIndexes([artistModel.index(index, 0)]); + } + } + + drag.onActiveChanged: { + var dragItem = drag.target; + + if (drag.active == false) + dragItem.Drag.drop(); + + dragItem.Drag.active = drag.active; + } + + onPositionChanged: { + if (drag.active == false) return; + + var pos = drag.target.parent.mapFromItem(root, mouseX, mouseY); + + drag.target.x = pos.x + VLCStyle.dragDelta; + drag.target.y = pos.y + VLCStyle.dragDelta; + } + + onClicked: itemClicked(mouse) + + onDoubleClicked: itemDoubleClicked(mouse) + + Widgets.CurrentIndicator { + height: parent.height - (margin * 2) + + margin: VLCStyle.dp(4, VLCStyle.scale) + + visible: isCurrent + } + + RowLayout { + anchors.fill: parent + + anchors.leftMargin: VLCStyle.margin_normal + anchors.rightMargin: VLCStyle.margin_normal + anchors.topMargin: VLCStyle.margin_xsmall + anchors.bottomMargin: VLCStyle.margin_xsmall + + spacing: VLCStyle.margin_xsmall + + RoundImage { + width: VLCStyle.play_cover_small + height: width + + radius: width + + source: (model.cover) ? model.cover + : VLCStyle.noArtArtistSmall + + Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter + + Rectangle { + anchors.fill: parent + + radius: VLCStyle.play_cover_small + + color: "transparent" + + border.width: VLCStyle.dp(1, VLCStyle.scale) + + border.color: (isCurrent || _isHover) ? VLCStyle.colors.accent + : VLCStyle.colors.roundPlayCoverBorder + } + } + + Widgets.ListLabel { + text: (model.name) ? model.name + : i18n.qtr("Unknown artist") + + color: background.foregroundColor + + Layout.fillWidth: true + Layout.fillHeight: true + } + } + } +} diff --git a/modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml b/modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml index 427a7290d9aab0201cde212c6001c57aff1ef419..b5743a172df83a8821f19ac2b9741036ec2d81da 100644 --- a/modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml +++ b/modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml @@ -141,109 +141,7 @@ FocusScope { topPadding: VLCStyle.margin_xlarge } - delegate: Widgets.AnimatedBackground { - id: item - - property bool _highlighted: mouseArea.containsMouse || this.activeFocus - - height: VLCStyle.play_cover_small + (VLCStyle.margin_xsmall * 2) - width: artistList.width - active: false - backgroundColor: _highlighted ? VLCStyle.colors.bgHover : "transparent" - foregroundColor: _highlighted ? VLCStyle.colors.bgHoverText : VLCStyle.colors.text - - Widgets.CurrentIndicator { - visible: item.ListView.isCurrentItem - } - - RowLayout { - spacing: VLCStyle.margin_xsmall - anchors { - fill: parent - leftMargin: VLCStyle.margin_normal - rightMargin: VLCStyle.margin_normal - topMargin: VLCStyle.margin_xsmall - bottomMargin: VLCStyle.margin_xsmall - } - - RoundImage { - source: model.cover || VLCStyle.noArtArtistSmall - height: VLCStyle.play_cover_small - width: VLCStyle.play_cover_small - radius: VLCStyle.play_cover_small - - Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter - - Rectangle { - anchors.fill: parent - color: "transparent" - radius: VLCStyle.play_cover_small - border.width: VLCStyle.dp(1, VLCStyle.scale) - border.color: !_highlighted ? VLCStyle.colors.roundPlayCoverBorder : VLCStyle.colors.accent - } - } - - Widgets.ListLabel { - text: model.name || i18n.qtr("Unknown artist") - color: item.foregroundColor - - Layout.fillWidth: true - Layout.fillHeight: true - } - } - - MouseArea { - id: mouseArea - - anchors.fill: parent - hoverEnabled: true - - onClicked: { - selectionModel.updateSelection( mouse.modifiers , artistList.currentIndex, index) - artistList.currentIndex = index - artistList.forceActiveFocus() - } - - onDoubleClicked: { - if (mouse.buttons === Qt.LeftButton) - medialib.addAndPlay( model.id ) - else - albumSubView.forceActiveFocus() - } - - drag.axis: Drag.XAndYAxis - drag.target: Widgets.DragItem { - function updateComponents(maxCovers) { - return { - covers: [{artwork: model.cover || VLCStyle.noArtArtistSmall}], - title: model.name || i18n.qtr("Unknown artist"), - count: 1 - } - } - - function getSelectedInputItem() { - return artistModel.getItemsForIndexes([artistModel.index(index, 0)]) - } - } - - drag.onActiveChanged: { - var dragItem = drag.target - - if (!drag.active) - dragItem.Drag.drop() - - dragItem.Drag.active = drag.active - } - - onPositionChanged: { - if (drag.active) { - var pos = drag.target.parent.mapFromItem(item, mouseX, mouseY) - drag.target.x = pos.x + 12 - drag.target.y = pos.y + 12 - } - } - } - } + delegate: MusicArtistDelegate {} Behavior on width { SmoothedAnimation { diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc index 919bbdfe101a12bf67656c757603232931d730ac..dbcc48101d758c4c7a85ddab8ac063f6b9cea284 100644 --- a/modules/gui/qt/vlc.qrc +++ b/modules/gui/qt/vlc.qrc @@ -293,6 +293,7 @@ <file alias="MusicAlbumsDisplay.qml">medialibrary/qml/MusicAlbumsDisplay.qml</file> <file alias="MusicAlbumsGridExpandDelegate.qml">medialibrary/qml/MusicAlbumsGridExpandDelegate.qml</file> <file alias="MusicArtist.qml">medialibrary/qml/MusicArtist.qml</file> + <file alias="MusicArtistDelegate.qml">medialibrary/qml/MusicArtistDelegate.qml</file> <file alias="MusicArtistsAlbums.qml">medialibrary/qml/MusicArtistsAlbums.qml</file> <file alias="MusicAllArtists.qml">medialibrary/qml/MusicAllArtists.qml</file> <file alias="MusicArtistsDisplay.qml">medialibrary/qml/MusicArtistsDisplay.qml</file> diff --git a/po/POTFILES.in b/po/POTFILES.in index 307e44c3617da2551a4d9006fa148df6adc0364b..a61f30ecf29db2582674ebc51e058a1b46b40d42 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -828,6 +828,7 @@ modules/gui/qt/medialibrary/qml/MusicAlbums.qml modules/gui/qt/medialibrary/qml/MusicAlbumsDisplay.qml modules/gui/qt/medialibrary/qml/MusicAlbumsGridExpandDelegate.qml modules/gui/qt/medialibrary/qml/MusicArtist.qml +modules/gui/qt/medialibrary/qml/MusicArtistDelegate.qml modules/gui/qt/medialibrary/qml/MusicAllArtists.qml modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml