[vlc-commits] [Git][videolan/vlc][master] 4 commits: qml: do not instantiate DragItem within delegate
François Cartegnie (@fcartegnie)
gitlab at videolan.org
Sat Dec 23 11:03:30 UTC 2023
François Cartegnie pushed to branch master at VideoLAN / VLC
Commits:
cc261d50 by Fatih Uzunoglu at 2023-12-23T10:44:57+00:00
qml: do not instantiate DragItem within delegate
- - - - -
feeee547 by Fatih Uzunoglu at 2023-12-23T10:44:57+00:00
qml: fix selection of MusicArtistDelegate
- - - - -
2cead00b by Fatih Uzunoglu at 2023-12-23T10:44:57+00:00
qml: set parent of DragItem to overlay
- - - - -
9d0d305c by Fatih Uzunoglu at 2023-12-23T10:44:57+00:00
qml: do not assign DragItem inline
Implicit visual parent is needed for this item
to be rendered.
- - - - -
6 changed files:
- modules/gui/qt/medialibrary/qml/MusicArtist.qml
- modules/gui/qt/medialibrary/qml/MusicArtistDelegate.qml
- modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
- modules/gui/qt/medialibrary/qml/MusicTrackListDisplay.qml
- modules/gui/qt/playlist/qml/PlaylistListView.qml
- modules/gui/qt/widgets/qml/DragItem.qml
Changes:
=====================================
modules/gui/qt/medialibrary/qml/MusicArtist.qml
=====================================
@@ -484,6 +484,8 @@ FocusScope {
sortModel: (availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
: _modelMedium
+ dragItem: tableDragItem
+
Navigation.parentItem: root
Navigation.upAction: function() {
@@ -496,7 +498,11 @@ FocusScope {
onContextMenuButtonClicked: trackContextMenu.popup(tableView_id.selectionModel.selectedIndexes, globalMousePos)
onRightClick: trackContextMenu.popup(tableView_id.selectionModel.selectedIndexes, globalMousePos)
- dragItem: Widgets.MLDragItem {
+ onDragItemChanged: console.assert(tableView_id.dragItem === tableDragItem)
+
+ Widgets.MLDragItem {
+ id: tableDragItem
+
mlModel: trackModel
indexes: indexesFlat ? tableView_id.selectionModel.selectedIndexesFlat
=====================================
modules/gui/qt/medialibrary/qml/MusicArtistDelegate.qml
=====================================
@@ -21,6 +21,7 @@
import QtQuick 2.12
import QtQuick.Templates 2.12 as T
import QtQuick.Layouts 1.12
+import QtQml.Models 2.12
import org.videolan.medialib 0.1
import org.videolan.controls 0.1
@@ -34,21 +35,21 @@ T.ItemDelegate {
// Properties
+ property ItemView view: ListView.view
+
/* required */ property MLModel mlModel
property bool isCurrent: false
+ property bool selected: false
+
+ /* required */ property Item dragTarget
+
// Aliases
// Private
readonly property bool _isHover: contentItem.containsMouse || root.activeFocus
- // Signals
-
- signal itemClicked(var mouse)
-
- signal itemDoubleClicked(var mouse)
-
// Settings
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
@@ -77,7 +78,7 @@ T.ItemDelegate {
background: Widgets.AnimatedBackground {
enabled: theme.initialized
- color: root.isCurrent ? theme.bg.highlight : theme.bg.primary
+ color: (root.isCurrent || root.selected) ? theme.bg.highlight : theme.bg.primary
border.color: visualFocus ? theme.visualFocus : "transparent"
Widgets.CurrentIndicator {
@@ -99,32 +100,39 @@ T.ItemDelegate {
drag.axis: Drag.XAndYAxis
drag.smoothed: false
- drag.target: Widgets.DragItem {
- indexes: [index]
+ drag.target: root.dragTarget
- onRequestData: {
- console.assert(indexes[0] === index)
- resolve([model])
+ drag.onActiveChanged: {
+ if (drag.target) {
+ const target = drag.target
+ if (drag.active) {
+ if (!selected) {
+ view.selectionModel.select(index, ItemSelectionModel.ClearAndSelect)
+ view.currentIndex = index
+ }
+
+ target.Drag.active = true
+ } else {
+ target.Drag.drop()
+ }
}
+ }
- onRequestInputItems: {
- const idList = data.map((o) => o.id)
- MediaLib.mlInputItem(idList, resolve)
+ onClicked: function(mouse) {
+ if (!(root.selected && mouse.button === Qt.RightButton)) {
+ view.selectionModel.updateSelection(mouse.modifiers, view.currentIndex, index)
+ view.currentIndex = index
}
}
- drag.onActiveChanged: {
- const dragItem = drag.target;
-
- if (drag.active == false)
- dragItem.Drag.drop();
-
- dragItem.Drag.active = drag.active;
+ onDoubleClicked: function(mouse) {
+ if (mouse.button !== Qt.RightButton)
+ MediaLib.addAndPlay(model.id);
}
- onClicked: itemClicked(mouse)
-
- onDoubleClicked: itemDoubleClicked(mouse)
+ onPressed: {
+ root.forceActiveFocus(Qt.MouseFocusReason)
+ }
}
contentItem: RowLayout {
=====================================
modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
=====================================
@@ -188,6 +188,16 @@ FocusScope {
topPadding: VLCStyle.margin_xlarge
}
+ Widgets.MLDragItem {
+ id: musicArtistDragItem
+
+ mlModel: artistModel
+
+ indexes: indexesFlat ? selectionModel.selectedIndexesFlat
+ : selectionModel.selectedIndexes
+ indexesFlat: !!selectionModel.selectedIndexesFlat
+ }
+
delegate: MusicArtistDelegate {
width: artistList.width
@@ -197,21 +207,9 @@ FocusScope {
mlModel: artistModel
- onItemClicked: {
- selectionModel.updateSelection(mouse.modifiers, artistList.currentIndex,
- index);
+ dragTarget: musicArtistDragItem
- artistList.currentIndex = index;
-
- artistList.forceActiveFocus(Qt.MouseFocusReason);
- }
-
- onItemDoubleClicked: {
- if (mouse.buttons === Qt.LeftButton)
- MediaLib.addAndPlay(model.id);
- else
- albumSubView.forceActiveFocus();
- }
+ selected: selectionModel.selectedIndexesFlat.includes(index)
}
Widgets.HorizontalResizeHandle {
=====================================
modules/gui/qt/medialibrary/qml/MusicTrackListDisplay.qml
=====================================
@@ -180,12 +180,18 @@ Widgets.KeyNavigableTableView {
model: rootmodel
rowHeight: VLCStyle.tableCoverRow_height
+ dragItem: tableDragItem
+
+ onDragItemChanged: console.assert(root.dragItem === tableDragItem)
+
onActionForSelection: model.addAndPlay(selection)
onItemDoubleClicked: MediaLib.addAndPlay(model.id)
onContextMenuButtonClicked: contextMenu.popup(selectionModel.selectedIndexes, globalMousePos)
onRightClick: contextMenu.popup(selectionModel.selectedIndexes, globalMousePos)
- dragItem: Widgets.MLDragItem {
+ Widgets.MLDragItem {
+ id: tableDragItem
+
indexes: indexesFlat ? root.selectionModel.selectedIndexesFlat
: root.selectionModel.selectedIndexes
indexesFlat: !!root.selectionModel.selectedIndexesFlat
=====================================
modules/gui/qt/playlist/qml/PlaylistListView.qml
=====================================
@@ -117,8 +117,6 @@ T.Pane {
Widgets.DragItem {
id: dragItem
- parent: (typeof g_mainDisplay !== 'undefined') ? g_mainDisplay : root
-
onRequestData: {
resolve(indexes.map((index) => {
const item = root.model.itemAt(index)
=====================================
modules/gui/qt/widgets/qml/DragItem.qml
=====================================
@@ -63,6 +63,7 @@ Item {
readonly property ColorContext colorContext: ColorContext {
id: theme
+ palette: VLCStyle.palette
colorSet: ColorContext.Window
}
@@ -121,6 +122,8 @@ Item {
// always keep drag item out of view
z: -1
+ parent: T.Overlay.overlay
+
x: parent.width + VLCStyle.margin_large
y: parent.height + VLCStyle.margin_large
@@ -133,8 +136,6 @@ Item {
Drag.hotSpot.y: - VLCStyle.dragDelta
- parent: g_mainDisplay
-
width: padding * 2
+ coversXPos(_displayedCoversCount - 1) + coverSize + VLCStyle.margin_small
+ subtitleLabel.width
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/08e5bcf35185893ac70f95f2332c91b0242f536a...9d0d305cab34812bb8a560f7450ccbcebb58e86b
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/08e5bcf35185893ac70f95f2332c91b0242f536a...9d0d305cab34812bb8a560f7450ccbcebb58e86b
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list