[vlc-commits] qml: factorize key handling in the Player

Pierre Lamot git at videolan.org
Tue Nov 19 16:49:59 CET 2019


vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Mon Oct 28 14:56:06 2019 +0100| [d434790c587e6923a8ea9f5d9304b1ac02187bec] | committer: Jean-Baptiste Kempf

qml: factorize key handling in the Player

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d434790c587e6923a8ea9f5d9304b1ac02187bec
---

 modules/gui/qt/qml/player/Player.qml | 65 +++++++++++++++---------------------
 1 file changed, 27 insertions(+), 38 deletions(-)

diff --git a/modules/gui/qt/qml/player/Player.qml b/modules/gui/qt/qml/player/Player.qml
index 4ca5695fd0..f01f4fbe1b 100644
--- a/modules/gui/qt/qml/player/Player.qml
+++ b/modules/gui/qt/qml/player/Player.qml
@@ -39,6 +39,33 @@ Utils.NavigableFocusScope {
             _menu.dismiss()
     }
 
+    Keys.priority: Keys.AfterItem
+    Keys.onPressed: {
+        if (event.accepted)
+            return
+        defaultKeyAction(event, 0)
+    }
+
+    Keys.onReleased: {
+        if (event.accepted)
+            return
+        if (event.key === Qt.Key_Menu) {
+            toolbarAutoHide.toggleForceVisible()
+        } else if (KeyHelper.matchCancel(event)) {
+
+            if (player.playingState === PlayerController.PLAYING_STATE_PAUSED) {
+               mainPlaylistController.stop()
+            }
+            history.previous(History.Go)
+        } else {
+            defaultKeyReleaseAction(event, 0)
+        }
+
+        //unhandled keys are forwarded as hotkeys
+        if (!event.accepted)
+            rootWindow.sendHotkey(event.key, event.modifiers);
+    }
+
     //center image
     Rectangle {
         visible: !rootWindow.hasEmbededVideo
@@ -128,18 +155,6 @@ Utils.NavigableFocusScope {
 
         property point mousePosition: Qt.point(0,0)
 
-        Keys.onPressed: {
-            if (event.key === Qt.Key_Menu
-                    || event.key === Qt.Key_Back
-                    || event.key === Qt.Key_Backspace
-                    || event.matches(StandardKey.Back)
-                    || event.matches(StandardKey.Cancel)) {
-                toolbarAutoHide.toggleForceVisible()
-            } else {
-                rootWindow.sendHotkey(event.key, event.modifiers);
-            }
-        }
-
         onMouseMoved:{
             //short interval for mouse events
             toolbarAutoHide.setVisible(1000)
@@ -181,19 +196,6 @@ Utils.NavigableFocusScope {
 
             navigationParent: rootPlayer
             navigationDownItem: playlistpopup.showPlaylist ? playlistpopup : controlBarView
-
-            Keys.onPressed: {
-                if (event.accepted)
-                    return
-                if (event.key === Qt.Key_Menu
-                        || event.key === Qt.Key_Backspace
-                        || event.matches(StandardKey.Back)
-                        || event.matches(StandardKey.Cancel)) {
-                    toolbarAutoHide.toggleForceVisible()
-                } else {
-                    rootWindow.sendHotkey(event.key, event.modifiers);
-                }
-            }
         }
     }
 
@@ -280,19 +282,6 @@ Utils.NavigableFocusScope {
 
                     navigationParent: rootPlayer
                     navigationUpItem: playlistpopup.showPlaylist ? playlistpopup : topcontrolView
-
-                    //unhandled keys are forwarded as hotkeys
-                    Keys.onPressed: {
-                        if (event.accepted)
-                            return
-                        if (event.key === Qt.Key_Menu
-                                || event.key === Qt.Key_Backspace
-                                || event.matches(StandardKey.Back)
-                                || event.matches(StandardKey.Cancel))
-                            toolbarAutoHide.toggleForceVisible()
-                        else
-                            rootWindow.sendHotkey(event.key, event.modifiers);
-                    }
                 }
             }
         }



More information about the vlc-commits mailing list