[vlc-commits] qml: factorize custom cover used in Networkview in separate file
Prince Gupta
git at videolan.org
Thu Dec 10 09:34:45 UTC 2020
vlc | branch: master | Prince Gupta <guptaprince8832 at gmail.com> | Thu Nov 12 20:33:53 2020 +0530| [f626c36de7924803cd01ee9bb72adbe8ee3db584] | committer: Pierre Lamot
qml: factorize custom cover used in Networkview in separate file
Signed-off-by: Pierre Lamot <pierre at videolabs.io>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f626c36de7924803cd01ee9bb72adbe8ee3db584
---
modules/gui/qt/Makefile.am | 1 +
modules/gui/qt/network/qml/NetworkCustomCover.qml | 66 ++++++++++++++++++++++
modules/gui/qt/network/qml/NetworkGridItem.qml | 39 +------------
.../gui/qt/network/qml/NetworkThumbnailItem.qml | 37 ++----------
modules/gui/qt/vlc.qrc | 1 +
5 files changed, 75 insertions(+), 69 deletions(-)
diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index f3ea3f2486..8ac71d4b81 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -653,6 +653,7 @@ libqt_plugin_la_QML = \
gui/qt/network/qml/DiscoverUrlDisplay.qml \
gui/qt/network/qml/NetworkAddressbar.qml \
gui/qt/network/qml/NetworkBrowseDisplay.qml \
+ gui/qt/network/qml/NetworkCustomCover.qml \
gui/qt/network/qml/NetworkDisplay.qml \
gui/qt/network/qml/NetworkGridItem.qml \
gui/qt/network/qml/NetworkHomeDisplay.qml \
diff --git a/modules/gui/qt/network/qml/NetworkCustomCover.qml b/modules/gui/qt/network/qml/NetworkCustomCover.qml
new file mode 100644
index 0000000000..a4b9338f35
--- /dev/null
+++ b/modules/gui/qt/network/qml/NetworkCustomCover.qml
@@ -0,0 +1,66 @@
+/*****************************************************************************
+ * Copyright (C) 2020 VLC authors and VideoLAN
+ *
+ * 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 QtGraphicalEffects 1.0
+
+import org.videolan.vlc 0.1
+
+import "qrc:///widgets/" as Widgets
+import "qrc:///style/"
+
+Item {
+ property var networkModel
+ property alias iconSize: custom_cover.width
+
+ Image {
+ id: custom_cover
+
+ anchors.centerIn: parent
+ visible: !networkModel.artwork || networkModel.artwork.toString() === ""
+ height: iconSize
+ mipmap: true
+ sourceSize: Qt.size(width, height)
+ source: {
+ switch (networkModel.type) {
+ case NetworkMediaModel.TYPE_DISC:
+ return "qrc:///type/disc.svg"
+ case NetworkMediaModel.TYPE_CARD:
+ return "qrc:///type/capture-card.svg"
+ case NetworkMediaModel.TYPE_STREAM:
+ return "qrc:///type/stream.svg"
+ case NetworkMediaModel.TYPE_PLAYLIST:
+ return "qrc:///type/playlist.svg"
+ case NetworkMediaModel.TYPE_FILE:
+ return "qrc:///type/file_black.svg"
+ default:
+ return "qrc:///type/directory_black.svg"
+ }
+ }
+ }
+
+ ColorOverlay {
+ anchors.fill: custom_cover
+ source: custom_cover
+ color: VLCStyle.colors.text
+ visible: custom_cover.visible
+ && networkModel.type !== NetworkMediaModel.TYPE_DISC
+ && networkModel.type !== NetworkMediaModel.TYPE_CARD
+ && networkModel.type !== NetworkMediaModel.TYPE_STREAM
+ }
+}
diff --git a/modules/gui/qt/network/qml/NetworkGridItem.qml b/modules/gui/qt/network/qml/NetworkGridItem.qml
index 52e9fc0496..398b9a0890 100644
--- a/modules/gui/qt/network/qml/NetworkGridItem.qml
+++ b/modules/gui/qt/network/qml/NetworkGridItem.qml
@@ -40,42 +40,9 @@ Widgets.GridItem {
subtitle: model.mrl || ""
title: model.name || i18n.qtr("Unknown share")
- pictureOverlay: Item {
- Image {
- id: custom_cover
-
- x: (pictureWidth - this.width) / 2
- y: (pictureHeight - this.height) / 2
- width: VLCStyle.icon_normal
- height: VLCStyle.icon_normal
- visible: !model.artwork || model.artwork.toString() === ""
- source: {
- switch (model.type){
- case NetworkMediaModel.TYPE_DISC:
- return "qrc:///type/disc.svg"
- case NetworkMediaModel.TYPE_CARD:
- return "qrc:///type/capture-card.svg"
- case NetworkMediaModel.TYPE_STREAM:
- return "qrc:///type/stream.svg"
- case NetworkMediaModel.TYPE_PLAYLIST:
- return "qrc:///type/playlist.svg"
- case NetworkMediaModel.TYPE_FILE:
- return "qrc:///type/file_black.svg"
- default:
- return "qrc:///type/directory_black.svg"
- }
- }
- }
-
- ColorOverlay {
- anchors.fill: custom_cover
- source: custom_cover
- color: VLCStyle.colors.text
- visible: custom_cover.visible
- && model.type !== NetworkMediaModel.TYPE_DISC
- && model.type !== NetworkMediaModel.TYPE_CARD
- && model.type !== NetworkMediaModel.TYPE_STREAM
- }
+ pictureOverlay: NetworkCustomCover {
+ networkModel: model
+ iconSize: VLCStyle.icon_normal
}
}
diff --git a/modules/gui/qt/network/qml/NetworkThumbnailItem.qml b/modules/gui/qt/network/qml/NetworkThumbnailItem.qml
index a031114080..ea23a89497 100644
--- a/modules/gui/qt/network/qml/NetworkThumbnailItem.qml
+++ b/modules/gui/qt/network/qml/NetworkThumbnailItem.qml
@@ -45,39 +45,10 @@ Item {
height: VLCStyle.listAlbumCover_height
visible: !artwork.visible
- Image {
- id: custom_cover
-
- anchors.centerIn: parent
- sourceSize.height: VLCStyle.icon_small
- sourceSize.width: VLCStyle.icon_small
- fillMode: Image.PreserveAspectFit
- mipmap: true
- source: {
- switch (rowModel.type) {
- case NetworkMediaModel.TYPE_DISC:
- return "qrc:///type/disc.svg"
- case NetworkMediaModel.TYPE_CARD:
- return "qrc:///type/capture-card.svg"
- case NetworkMediaModel.TYPE_STREAM:
- return "qrc:///type/stream.svg"
- case NetworkMediaModel.TYPE_PLAYLIST:
- return "qrc:///type/playlist.svg"
- case NetworkMediaModel.TYPE_FILE:
- return "qrc:///type/file_black.svg"
- default:
- return "qrc:///type/directory_black.svg"
- }
- }
- }
-
- ColorOverlay {
- anchors.fill: custom_cover
- source: custom_cover
- color: VLCStyle.colors.text
- visible: rowModel.type !== NetworkMediaModel.TYPE_DISC
- && rowModel.type !== NetworkMediaModel.TYPE_CARD
- && rowModel.type !== NetworkMediaModel.TYPE_STREAM
+ NetworkCustomCover {
+ networkModel: rowModel
+ anchors.fill: parent
+ iconSize: VLCStyle.icon_small
}
}
diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc
index 1200fe382b..3d1cf4284e 100644
--- a/modules/gui/qt/vlc.qrc
+++ b/modules/gui/qt/vlc.qrc
@@ -245,6 +245,7 @@
<file alias="AddressbarButton.qml">network/qml/AddressbarButton.qml</file>
<file alias="DiscoverDisplay.qml">network/qml/DiscoverDisplay.qml</file>
<file alias="DiscoverUrlDisplay.qml">network/qml/DiscoverUrlDisplay.qml</file>
+ <file alias="NetworkCustomCover.qml">network/qml/NetworkCustomCover.qml</file>
<file alias="NetworkDisplay.qml">network/qml/NetworkDisplay.qml</file>
<file alias="NetworkHomeDeviceListView.qml">network/qml/NetworkHomeDeviceListView.qml</file>
<file alias="NetworkHomeDisplay.qml">network/qml/NetworkHomeDisplay.qml</file>
More information about the vlc-commits
mailing list