[multimedia/elisa] src/qml: MediaPlayerControls: Make right-click open context menu

Nate Graham <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 33aa02d3aac7ea2c60cddc140e551c418fb77cc1 by Nate Graham, on behalf of The Entropyst.
Committed on 22/07/2026 at 14:46.
Pushed by ngraham into branch 'master'.

MediaPlayerControls: Make right-click open context menu

Currently it's only possible to open the context menu of the repeat and
shuffle buttons with a long press no matter the platform feels unnatural
on desktop and laptop where right-click is the widely adopted behavior.

This commit solves this issue by making usage of the ContextMenu QML Type
(https://doc.qt.io/qt-6/qml-qtquick-controls-contextmenu.html) which
adapts its behavior to the platform.

M  +12   -6    src/qml/MediaPlayerControl.qml

https://invent.kde.org/multimedia/elisa/-/commit/33aa02d3aac7ea2c60cddc140e551c418fb77cc1

diff --git a/src/qml/MediaPlayerControl.qml b/src/qml/MediaPlayerControl.qml
index 2658c9d2f..397356501 100644
--- a/src/qml/MediaPlayerControl.qml
+++ b/src/qml/MediaPlayerControl.qml
@@ -188,7 +188,7 @@ BasePlayerControl {
                             return map[ElisaApplication.mediaPlayListProxyModel.shuffleMode]
                         }
 
-                        down: pressed || menu.visible
+                        down: pressed || shuffleMenu.visible
                         Accessible.role: Accessible.ButtonMenu
 
                         checkable: true
@@ -198,10 +198,13 @@ BasePlayerControl {
                             ElisaApplication.mediaPlayListProxyModel.shuffleMode = (ElisaApplication.mediaPlayListProxyModel.shuffleMode + 1) % 3
                         }
                         onPressAndHold: {
-                            (menu as Menu).popup()
+                            shuffleMenu.popup()
                         }
 
-                        menu: Menu {
+                        ContextMenu.menu: shuffleMenu
+
+                        Menu {
+                            id: shuffleMenu
                             ShuffleModeItem {
                                 text: KI18n.i18nc("@action:inmenu", "Track")
                                 mode: MediaPlayListProxyModel.Track
@@ -247,7 +250,7 @@ BasePlayerControl {
                             return map[ElisaApplication.mediaPlayListProxyModel.repeatMode]
                         }
 
-                        down: pressed || menu.visible
+                        down: pressed || repeatMenu.visible
                         Accessible.role: Accessible.ButtonMenu
 
                         checkable: true
@@ -256,10 +259,13 @@ BasePlayerControl {
                             ElisaApplication.mediaPlayListProxyModel.repeatMode = (ElisaApplication.mediaPlayListProxyModel.repeatMode + 1) % 3
                         }
                         onPressAndHold: {
-                            (menu as Menu).popup()
+                            repeatMenu.popup()
                         }
 
-                        menu: Menu {
+                        ContextMenu.menu: repeatMenu
+
+                        Menu {
+                            id: repeatMenu
                             PlaylistModeItem {
                                 text: KI18n.i18nc("@action:inmenu", "Playlist")
                                 mode: MediaPlayListProxyModel.Playlist
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.