[vlc-commits] qml: forward unhanlded keys from player view as hotkeys

Pierre Lamot git at videolan.org
Tue Jul 16 10:13:34 CEST 2019


vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Wed Jul 10 10:43:08 2019 +0200| [6c28e8da96367951536eb21eadaf26a7436a6c69] | committer: Jean-Baptiste Kempf

qml: forward unhanlded keys from player view as hotkeys

fixes #22157

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

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

 modules/gui/qt/main_interface.cpp    | 10 ++++++++++
 modules/gui/qt/main_interface.hpp    |  2 ++
 modules/gui/qt/qml/player/Player.qml | 13 +++++++++----
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/modules/gui/qt/main_interface.cpp b/modules/gui/qt/main_interface.cpp
index b9613aab01..6b633dea55 100644
--- a/modules/gui/qt/main_interface.cpp
+++ b/modules/gui/qt/main_interface.cpp
@@ -316,6 +316,16 @@ void MainInterface::onInputChanged( bool hasInput )
     emit askRaise();
 }
 
+#ifdef KeyPress
+#undef KeyPress
+#endif
+void MainInterface::sendHotkey( Qt::Key key )
+{
+    QKeyEvent event(QEvent::KeyPress, key, Qt::NoModifier);
+    int vlckey = qtEventToVLCKey(&event);
+    var_SetInteger(vlc_object_instance(p_intf), "key-pressed", vlckey);
+}
+
 void MainInterface::createMainWidget( QSettings * )
 {
     qRegisterMetaType<VLCTick>();
diff --git a/modules/gui/qt/main_interface.hpp b/modules/gui/qt/main_interface.hpp
index 61a11ec4bf..d15a47405d 100644
--- a/modules/gui/qt/main_interface.hpp
+++ b/modules/gui/qt/main_interface.hpp
@@ -234,6 +234,8 @@ protected slots:
     void setFullScreen( bool );
     void onInputChanged( bool );
 
+    void sendHotkey( Qt::Key key );
+
 signals:
     void askGetVideo( bool );
     void askReleaseVideo( );
diff --git a/modules/gui/qt/qml/player/Player.qml b/modules/gui/qt/qml/player/Player.qml
index f690731b4a..83eb46e98f 100644
--- a/modules/gui/qt/qml/player/Player.qml
+++ b/modules/gui/qt/qml/player/Player.qml
@@ -99,7 +99,7 @@ Utils.NavigableFocusScope {
 
         property point mousePosition: Qt.point(0,0)
 
-        Keys.onReleased: {
+        Keys.onPressed: {
             if (event.key === Qt.Key_Menu) {
                 toolbarAutoHide.toggleForceVisible()
             }
@@ -201,15 +201,20 @@ Utils.NavigableFocusScope {
                     onActionRight: root.actionRight(index)
                     onActionCancel: root.actionCancel(index)
 
-                    //unhandled keys are forwarded to the vout window
-                    Keys.forwardTo: videoSurface
+                    //unhandled keys are forwarded as hotkeys
+                    Keys.onPressed: {
+                        if (event.key === Qt.Key_Menu)
+                            toolbarAutoHide.toggleForceVisible()
+                        else
+                            rootWindow.sendHotkey(event.key);
+                    }
 
                     //filter global events to keep toolbar
                     //visible when user navigates within the control bar
                     EventFilter {
                         id: filter
                         source: rootQMLView
-                        filterEnabled: controllerId.activeFocus
+                        filterEnabled: controlBarView.state === "visible"
                         Keys.onPressed: toolbarAutoHide.setVisible(5000)
                     }
                 }



More information about the vlc-commits mailing list