[vlc-commits] qml: add MCNetworksSection and MCNetworksSectionSelectableDM
Abel Tesfaye
git at videolan.org
Wed Aug 21 15:09:03 CEST 2019
vlc | branch: master | Abel Tesfaye <Abeltesfaye45 at gmail.com> | Mon Aug 19 17:21:04 2019 +0300| [5ab69010bb351f4b84a6dfa584070533e43ca651] | committer: Jean-Baptiste Kempf
qml: add MCNetworksSection and MCNetworksSectionSelectableDM
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5ab69010bb351f4b84a6dfa584070533e43ca651
---
modules/gui/qt/Makefile.am | 2 +
.../gui/qt/qml/mediacenter/MCNetworksSection.qml | 143 +++++++++++++++++++++
.../mediacenter/MCNetworksSectionSelectableDM.qml | 79 ++++++++++++
modules/gui/qt/vlc.qrc | 2 +
4 files changed, 226 insertions(+)
diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index d61af2993f..a218dc2c60 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -612,6 +612,8 @@ libqt_plugin_la_QML = \
gui/qt/qml/mediacenter/MCVideoDisplay.qml \
gui/qt/qml/mediacenter/MCVideoListDisplay.qml \
gui/qt/qml/mediacenter/MCNetworkDisplay.qml \
+ gui/qt/qml/mediacenter/MCNetworksSection.qml \
+ gui/qt/qml/mediacenter/MCNetworksSectionSelectableDM.qml \
gui/qt/qml/mediacenter/MusicAlbumsDisplay.qml \
gui/qt/qml/mediacenter/MusicAlbumsGridExpandDelegate.qml \
gui/qt/qml/mediacenter/MusicArtistsDisplay.qml \
diff --git a/modules/gui/qt/qml/mediacenter/MCNetworksSection.qml b/modules/gui/qt/qml/mediacenter/MCNetworksSection.qml
new file mode 100644
index 0000000000..8d255d6058
--- /dev/null
+++ b/modules/gui/qt/qml/mediacenter/MCNetworksSection.qml
@@ -0,0 +1,143 @@
+/*****************************************************************************
+ * Copyright (C) 2019 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 QtQml.Models 2.2
+import QtQml 2.11
+import "qrc:///utils/" as Utils
+import "qrc:///style/"
+
+Rectangle {
+ id: networkSection
+
+ property var selectableDelegateModel: null
+ property alias text: sectionSeparator.text
+ property alias currentIndex: sectionListView.currentIndex
+
+ signal actionDown(int index)
+ signal actionUp(int index)
+
+ function shiftX(index){
+ return sectionListView.shiftX(index)
+ }
+ function adjustTopFlickableViewBound(){
+
+ const itemTop = networkSection.y + sectionListView.currentItem.y
+ const itemBottom = sectionSeparator.height + networkSection.y + sectionListView.currentItem.y + sectionListView.currentItem.height
+ if (itemTop < flickable.contentY)
+ flickable.contentY = itemTop
+
+ else if (itemBottom > (flickable.contentY + flickable.height))
+ flickable.contentY = itemBottom - flickable.height
+ }
+ anchors {
+ left: parent.left
+ right: parent.right
+ }
+ implicitHeight: childrenRect.height
+ color: "transparent"
+ enabled: visible
+
+ /*
+ *define the intial position/selection
+ * This is done on activeFocus rather than Component.onCompleted because delegateModel.
+ * selectedGroup update itself after this event
+ */
+ onActiveFocusChanged: {
+ if(activeFocus){
+ sectionListView.forceActiveFocus()
+ }
+
+ if (networkSection.selectableDelegateModel.items.count > 0 && networkSection.selectableDelegateModel.selectedGroup.count === 0) {
+ var initialIndex = 0
+ if (view[networkSection.selectableDelegateModel.viewIndexPropertyName] !== -1)
+ initialIndex = view.currentIndexProvider
+ networkSection.selectableDelegateModel.items.get(initialIndex).inSelected = true
+ view[networkSection.selectableDelegateModel.viewIndexPropertyName] = initialIndex
+ }
+
+ adjustTopFlickableViewBound()
+ }
+
+ Utils.LabelSeparator {
+ id: sectionSeparator
+ }
+ Rectangle{
+ id: sectionRect
+ anchors {
+ left: parent.left
+ right: parent.right
+ top: sectionSeparator.bottom
+ }
+ height: gridRect.height
+ color: "transparent"
+
+ Rectangle {
+ id: gridRect
+ color: VLCStyle.colors.bg
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.leftMargin: VLCStyle.margin_large
+ anchors.rightMargin: VLCStyle.margin_large
+ height: sectionListView.contentHeight
+ Utils.KeyNavigableListView {
+ id: sectionListView
+ anchors.fill: parent
+
+ model: networkSection.selectableDelegateModel.parts.grid
+ modelCount: networkSection.selectableDelegateModel.items.count
+ currentIndex: networkSection.currentIndex
+ orientation: ListView.Horizontal
+ onCurrentItemChanged: adjustTopFlickableViewBound()
+
+ onSelectAll: networkSection.selectableDelegateModel.selectAll()
+ onSelectionUpdated: networkSection.selectableDelegateModel.updateSelection( keyModifiers, oldIndex, newIndex )
+ onActionAtIndex: networkSection.selectableDelegateModel.actionAtIndex(index)
+
+ onActionLeft: root.actionLeft(index)
+ onActionRight: root.actionRight(index)
+ onActionUp: networkSection.actionUp(index)
+ onActionDown: networkSection.actionDown(index)
+ onActionCancel: root.actionCancel(index)
+
+ }
+
+ }
+
+ Utils.RoundButton{
+ id: leftBtn
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.left: parent.left
+ text:"<"
+ onClicked: sectionListView.prevPage()
+ visible: sectionListView.contentWidth > sectionListView.width
+ enabled: visible
+ }
+
+
+ Utils.RoundButton{
+ id: rightBtn
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.right: parent.right
+ text:">"
+ onClicked: sectionListView.nextPage()
+ visible: sectionListView.contentWidth > sectionListView.width
+ enabled: visible
+ }
+ }
+}
diff --git a/modules/gui/qt/qml/mediacenter/MCNetworksSectionSelectableDM.qml b/modules/gui/qt/qml/mediacenter/MCNetworksSectionSelectableDM.qml
new file mode 100644
index 0000000000..a113eb01d2
--- /dev/null
+++ b/modules/gui/qt/qml/mediacenter/MCNetworksSectionSelectableDM.qml
@@ -0,0 +1,79 @@
+/*****************************************************************************
+ * Copyright (C) 2019 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 QtQml.Models 2.2
+import QtQml 2.11
+
+import org.videolan.vlc 0.1
+import org.videolan.medialib 0.1
+
+import "qrc:///utils/" as Utils
+import "qrc:///style/"
+
+Utils.SelectableDelegateModel {
+ id: delegateModel
+ property string viewIndexPropertyName: "currentIndex"
+ delegate: Package {
+ id: element
+ Loader {
+ id: delegateLoaderGrid
+ focus: true
+ Package.name: "grid"
+ source: model.type == MLNetworkModel.TYPE_FILE ?
+ "qrc:///mediacenter/NetworkFileDisplayGrid.qml" :
+ "qrc:///mediacenter/NetworkDriveDisplayGrid.qml";
+ }
+
+ Loader {
+ id: delegateLoader
+ focus: true
+ Package.name: "list"
+ source: model.type == MLNetworkModel.TYPE_FILE ?
+ "qrc:///mediacenter/NetworkFileDisplay.qml" :
+ "qrc:///mediacenter/NetworkDriveDisplay.qml";
+ }
+ Connections {
+ target: delegateLoader.item
+ onActionLeft: root.actionLeft(0)
+ onActionRight: root.actionRight(0)
+ }
+
+ }
+
+ function actionAtIndex(index) {
+ if ( delegateModel.selectedGroup.count > 1 ) {
+ var list = []
+ for (var i = 0; i < delegateModel.selectedGroup.count; i++) {
+ var type = delegateModel.selectedGroup.get(i).model.type;
+ var mrl = delegateModel.selectedGroup.get(i).model.mrl;
+ if (type == MLNetworkModel.TYPE_FILE)
+ list.push(mrl)
+ }
+ medialib.addAndPlay( list )
+ } else {
+ if (delegateModel.items.get(index).model.type != MLNetworkModel.TYPE_FILE) {
+ console.log("not file")
+ root.tree = delegateModel.items.get(index).model.tree
+ history.push(["mc", "network", { tree: delegateModel.items.get(index).model.tree }], History.Go);
+ } else {
+ medialib.addAndPlay( delegateModel.items.get(index).model.mrl );
+ }
+ }
+ }
+}
diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc
index 778c0159ad..ef72a51955 100644
--- a/modules/gui/qt/vlc.qrc
+++ b/modules/gui/qt/vlc.qrc
@@ -209,6 +209,8 @@
<file alias="MCMusicDisplay.qml">qml/mediacenter/MCMusicDisplay.qml</file>
<file alias="MCVideoDisplay.qml">qml/mediacenter/MCVideoDisplay.qml</file>
<file alias="MCNetworkDisplay.qml">qml/mediacenter/MCNetworkDisplay.qml</file>
+ <file alias="MCNetworksSection.qml">qml/mediacenter/MCNetworksSection.qml</file>
+ <file alias="MCNetworksSectionSelectableDM.qml">qml/mediacenter/MCNetworksSectionSelectableDM.qml</file>
<file alias="MusicAlbumsDisplay.qml">qml/mediacenter/MusicAlbumsDisplay.qml</file>
<file alias="MusicAlbumsGridExpandDelegate.qml">qml/mediacenter/MusicAlbumsGridExpandDelegate.qml</file>
<file alias="MusicArtistsDisplay.qml">qml/mediacenter/MusicArtistsDisplay.qml</file>
More information about the vlc-commits
mailing list