[vlc-commits] [Git][videolan/vlc][master] qt: fix hotkey precedence over TextInput widgets

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sat Aug 31 13:59:39 UTC 2024



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
3b8d9779 by Pierre Lamot at 2024-08-31T13:46:28+00:00
qt: fix hotkey precedence over TextInput widgets

- - - - -


1 changed file:

- modules/gui/qt/maininterface/interface_window_handler.cpp


Changes:

=====================================
modules/gui/qt/maininterface/interface_window_handler.cpp
=====================================
@@ -404,9 +404,26 @@ bool InterfaceWindowHandler::applyKeyEvent(QKeyEvent * event) const
 
     // NOTE: When the item has visual focus we let it handle the key. When the item does not
     //       inherit from QQuickControl we have to declare the 'visualFocus' property ourselves.
-    if (item && QQmlProperty(item, "visualFocus", qmlContext(item)).read().toBool())
+    if (item)
     {
-        return false;
+
+        QVariant visualFocus = QQmlProperty::read(item, "visualFocus", qmlContext(item));
+        if (visualFocus.isValid())
+        {
+            if (visualFocus.toBool())
+                return false;
+        }
+        //while being QuickControls TextField and TextArea don't provide visualFocus property
+        //here we check their (non control) parent class, this should cover all text input widgets
+        else if (item->inherits("QQuickTextInput") || item->inherits("QQuickTextEdit"))
+        {
+            QVariant activeFocus = QQmlProperty::read(item, "activeFocus", qmlContext(item));
+            if (activeFocus.isValid())
+            {
+                if (activeFocus.toBool())
+                    return false;
+            }
+        }
     }
 
     event->accept();



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/3b8d97797e8e3690ad5ff6ed4b1b38959058214a

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/3b8d97797e8e3690ad5ff6ed4b1b38959058214a
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list