[vlc-commits] qml: fix recent play menu items disapearing on mouseover
Pierre Lamot
git at videolan.org
Wed May 29 15:36:05 CEST 2019
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Tue May 28 13:14:26 2019 +0200| [f03042b232637059017ec943d11742d0109fedd4] | committer: Thomas Guillem
qml: fix recent play menu items disapearing on mouseover
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f03042b232637059017ec943d11742d0109fedd4
---
modules/gui/qt/qml/menus/MediaMenu.qml | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/modules/gui/qt/qml/menus/MediaMenu.qml b/modules/gui/qt/qml/menus/MediaMenu.qml
index 8f95dc19ee..e8fb1dbf1c 100644
--- a/modules/gui/qt/qml/menus/MediaMenu.qml
+++ b/modules/gui/qt/qml/menus/MediaMenu.qml
@@ -38,8 +38,19 @@ Utils.MenuExt {
onAboutToShow:{
recentsMenu.hasData = Boolean(recentsMedias.rowCount())
}
- Instantiator {
+
+ function moveItemToPos(item, pos) {
+ for ( var i = 0; i < recentsMenu.count; i++ ) {
+ if (recentsMenu.itemAt(i) == item) {
+ recentsMenu.moveItem(i, pos)
+ return;
+ }
+ }
+ }
+
+ Repeater {
model: recentsMedias
+
Utils.MenuItemExt {
text: mrl
onTriggered:{
@@ -53,13 +64,26 @@ Utils.MenuExt {
context: Qt.ApplicationShortcut
}
}
- onObjectAdded: recentsMenu.insertItem(recentsMenu.count - 2, object)
- onObjectRemoved: recentsMenu.removeItem(object)
+
+ //replace last elements as the repeater won't keep the original
+ //order of the menu when updated
+ onItemAdded: {
+ recentsMenu.moveItemToPos(clearAction, recentsMenu.count - 1)
+ recentsMenu.moveItemToPos(clearSepId, recentsMenu.count - 2)
+ }
+
+ onItemRemoved: {
+ recentsMenu.moveItemToPos(clearAction, recentsMenu.count - 1)
+ recentsMenu.moveItemToPos(clearSepId, recentsMenu.count - 2)
+ }
}
- MenuSeparator{}
+ MenuSeparator {
+ id: clearSepId
+ }
Utils.MenuItemExt {
+ id: clearAction
text: qsTr("Clear")
enabled: recentsMenu.hasData
onTriggered:recentsMedias.clear()
More information about the vlc-commits
mailing list