[vlc-commits] qml/VideoAll: Add support for different models
Benjamin Arnaud
git at videolan.org
Tue Apr 20 12:49:10 UTC 2021
vlc | branch: master | Benjamin Arnaud <benjamin.arnaud at videolabs.io> | Thu Mar 25 15:00:38 2021 +0100| [2ad8e3001f7184fa6a0ca749c5ae8c4ce7a2b02a] | committer: Pierre Lamot
qml/VideoAll: Add support for different models
qml/VideoGridItem: Remove the static 'onItemDoubleClicked' behavior
Signed-off-by: Pierre Lamot <pierre at videolabs.io>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2ad8e3001f7184fa6a0ca749c5ae8c4ce7a2b02a
---
modules/gui/qt/medialibrary/qml/VideoAll.qml | 41 ++++++++++++-----------
modules/gui/qt/medialibrary/qml/VideoGridItem.qml | 6 ----
2 files changed, 22 insertions(+), 25 deletions(-)
diff --git a/modules/gui/qt/medialibrary/qml/VideoAll.qml b/modules/gui/qt/medialibrary/qml/VideoAll.qml
index 4427c0d742..b7fbe61ad6 100644
--- a/modules/gui/qt/medialibrary/qml/VideoAll.qml
+++ b/modules/gui/qt/medialibrary/qml/VideoAll.qml
@@ -44,6 +44,8 @@ Widgets.NavigableFocusScope {
property int initialIndex: 0
+ property var model: MLVideoModel { ml: medialib }
+
property var sortModel: [
{ text: i18n.qtr("Alphabetic"), criteria: "title" },
{ text: i18n.qtr("Duration"), criteria: "duration" }
@@ -53,11 +55,6 @@ Widgets.NavigableFocusScope {
// Aliases
//---------------------------------------------------------------------------------------------
- // NOTE: This is used to determine which media(s) shall be displayed.
- property alias parentId: model.parentId
-
- property alias model: model
-
property alias currentItem: view.currentItem
//---------------------------------------------------------------------------------------------
@@ -99,6 +96,16 @@ Widgets.NavigableFocusScope {
}
}
+ Connections {
+ target: model
+
+ onCountChanged: {
+ if (count === 0 || modelSelect.hasSelection) return;
+
+ resetFocus();
+ }
+ }
+
//---------------------------------------------------------------------------------------------
// Functions
//---------------------------------------------------------------------------------------------
@@ -122,7 +129,7 @@ Widgets.NavigableFocusScope {
//---------------------------------------------------------------------------------------------
// Private
- function _actionAtIndex(index) {
+ function _actionAtIndex() {
g_mainDisplay.showPlayer();
medialib.addAndPlay(model.getIdsForIndexes(modelSelect.selectedIndexes));
@@ -132,18 +139,6 @@ Widgets.NavigableFocusScope {
// Childs
//---------------------------------------------------------------------------------------------
- MLVideoModel {
- id: model
-
- ml: medialib
-
- onCountChanged: {
- if (count === 0 || modelSelect.hasSelection) return;
-
- resetFocus();
- }
- }
-
Widgets.StackViewExt {
id: view
@@ -267,6 +262,12 @@ Widgets.NavigableFocusScope {
onItemClicked: gridView.leftClickOnItem(modifier, index)
+ onItemDoubleClicked: {
+ g_mainDisplay.showPlayer();
+
+ medialib.addAndPlay(model.id);
+ }
+
onContextMenuButtonClicked: {
gridView.rightClickOnItem(index);
@@ -296,7 +297,7 @@ Widgets.NavigableFocusScope {
onSelectionUpdated: modelSelect.updateSelection(keyModifiers, oldIndex, newIndex)
- onActionAtIndex: _actionAtIndex(index)
+ onActionAtIndex: _actionAtIndex()
//-------------------------------------------------------------------------------------
// Connections
@@ -337,6 +338,8 @@ Widgets.NavigableFocusScope {
//-------------------------------------------------------------------------------------
// Events
+ onActionForSelection: medialib.addAndPlay(model.getIdsForIndexes(selection))
+
onContextMenuButtonClicked: contextMenu.popup(modelSelect.selectedIndexes,
menuParent.mapToGlobal(0,0))
diff --git a/modules/gui/qt/medialibrary/qml/VideoGridItem.qml b/modules/gui/qt/medialibrary/qml/VideoGridItem.qml
index 86a0e59181..e090035814 100644
--- a/modules/gui/qt/medialibrary/qml/VideoGridItem.qml
+++ b/modules/gui/qt/medialibrary/qml/VideoGridItem.qml
@@ -40,12 +40,6 @@ Widgets.GridItem {
playCoverBorder.width: VLCStyle.gridCover_video_border
titleMargin: VLCStyle.margin_xxsmall
showNewIndicator: true
- onItemDoubleClicked: {
- if ( model.id !== undefined ) {
- g_mainDisplay.showPlayer()
- medialib.addAndPlay( model.id )
- }
- }
onPlayClicked: {
if ( model.id !== undefined ) {
g_mainDisplay.showPlayer()
More information about the vlc-commits
mailing list