[vlc-devel] [PATCH] qml: fix recent play menu items disapearing on mouseover

Thomas Guillem thomas at gllm.fr
Tue May 28 13:23:56 CEST 2019


LGTM

On Tue, May 28, 2019, at 13:14, Pierre Lamot wrote:
> ---
>  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()
> -- 
> 2.17.1
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list