[vlc-commits] qml: use enum to define states in the playlist
Fatih Uzunoglu
git at videolan.org
Tue Jan 12 13:20:29 UTC 2021
vlc | branch: master | Fatih Uzunoglu <fuzun54 at outlook.com> | Fri Jan 8 00:36:31 2021 +0300| [700fa886179623895afa374986fffc055a52791e] | committer: Pierre Lamot
qml: use enum to define states in the playlist
Signed-off-by: Pierre Lamot <pierre at videolabs.io>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=700fa886179623895afa374986fffc055a52791e
---
modules/gui/qt/playlist/qml/PlaylistListView.qml | 30 +++++++++++++---------
.../gui/qt/playlist/qml/PlaylistOverlayMenu.qml | 4 +--
2 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/modules/gui/qt/playlist/qml/PlaylistListView.qml b/modules/gui/qt/playlist/qml/PlaylistListView.qml
index 72057d285d..6837b1b1b0 100644
--- a/modules/gui/qt/playlist/qml/PlaylistListView.qml
+++ b/modules/gui/qt/playlist/qml/PlaylistListView.qml
@@ -42,6 +42,12 @@ Widgets.NavigableFocusScope {
signal setItemDropIndicatorVisible(int index, bool isVisible, bool top)
+ enum Mode {
+ Normal,
+ Select, // Keyboard item selection mode, activated through PlaylistOverlayMenu
+ Move // Keyboard item move mode, activated through PlaylistOverlayMenu
+ }
+
function isDropAcceptable(drop, index) {
return drop.hasUrls
|| ((!!drop.source && (drop.source instanceof PlaylistDroppable))
@@ -245,7 +251,7 @@ Widgets.NavigableFocusScope {
fadeColor: root.backgroundColor
property int shiftIndex: -1
- property string mode: "normal"
+ property int mode: PlaylistListView.Mode.Normal
Connections {
target: root.plmodel
@@ -356,7 +362,7 @@ Widgets.NavigableFocusScope {
onItemClicked : {
/* to receive keys events */
view.forceActiveFocus()
- if (view.mode == "move") {
+ if (view.mode === PlaylistListView.Mode.Move) {
var selectedIndexes = root.plmodel.getSelection()
if (selectedIndexes.length === 0)
return
@@ -368,7 +374,7 @@ Widgets.NavigableFocusScope {
view.currentIndex = selectedIndexes[0]
root.plmodel.moveItemsPre(selectedIndexes, preTarget)
return
- } else if (view.mode == "select") {
+ } else if (view.mode === PlaylistListView.Mode.Select) {
} else if (!(root.plmodel.isSelected(index) && button === Qt.RightButton)) {
view.updateSelection(modifier, view.currentIndex, index)
view.currentIndex = index
@@ -443,9 +449,9 @@ Widgets.NavigableFocusScope {
onSelectAll: root.plmodel.selectAll()
onSelectionUpdated: {
- if (view.mode === "select") {
+ if (view.mode === PlaylistListView.Mode.Select) {
console.log("update selection select")
- } else if (mode == "move") {
+ } else if (view.mode === PlaylistListView.Mode.Move) {
var selectedIndexes = root.plmodel.getSelection()
if (selectedIndexes.length === 0)
return
@@ -475,17 +481,17 @@ Widgets.NavigableFocusScope {
overlayMenu.open()
}
navigationLeft: function(index) {
- if (mode === "normal") {
+ if (mode === PlaylistListView.Mode.Normal) {
root.navigationLeft(index)
} else {
- mode = "normal"
+ mode = PlaylistListView.Mode.Normal
}
}
navigationCancel: function(index) {
- if (mode === "normal") {
+ if (mode === PlaylistListView.Mode.Normal) {
root.navigationCancel(index)
} else {
- mode = "normal"
+ mode = PlaylistListView.Mode.Normal
}
}
@@ -493,7 +499,7 @@ Widgets.NavigableFocusScope {
if (index < 0)
return
- if (mode === "select")
+ if (mode === PlaylistListView.Mode.Select)
root.plmodel.toggleSelected(index)
else //normal
// play
@@ -621,9 +627,9 @@ Widgets.NavigableFocusScope {
anchors.centerIn: parent
horizontalAlignment: Text.AlignHCenter
- text: (view.mode === "select")
+ text: (view.mode === PlaylistListView.Mode.Select)
? i18n.qtr("Select tracks (%1)").arg(plmodel.selectedCount)
- : (view.mode === "move")
+ : (view.mode === PlaylistListView.Mode.Move)
? i18n.qtr("Move tracks (%1)").arg(plmodel.selectedCount)
: ""
font.pixelSize: VLCStyle.fontSize_large
diff --git a/modules/gui/qt/playlist/qml/PlaylistOverlayMenu.qml b/modules/gui/qt/playlist/qml/PlaylistOverlayMenu.qml
index 6afcbc44ad..e07535caae 100644
--- a/modules/gui/qt/playlist/qml/PlaylistOverlayMenu.qml
+++ b/modules/gui/qt/playlist/qml/PlaylistOverlayMenu.qml
@@ -116,13 +116,13 @@ Widgets.OverlayMenu {
Action {
id: selectTracksAction
text: i18n.qtr("Select Tracks")
- onTriggered: view.mode = "select"
+ onTriggered: view.mode = PlaylistListView.Mode.Select
}
Action {
id: moveTracksAction
text: i18n.qtr("Move Selection")
- onTriggered: view.mode = "move"
+ onTriggered: view.mode = PlaylistListView.Mode.Move
}
Action {
More information about the vlc-commits
mailing list