[vlc-commits] [Git][videolan/vlc][master] 2 commits: qt: add static `qtQuickControlRejectsHoverEvents()` method to `MainCtx`

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Jul 25 18:01:51 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
22bae564 by Fatih Uzunoglu at 2024-07-25T17:49:03+00:00
qt: add static `qtQuickControlRejectsHoverEvents()` method to `MainCtx`

- - - - -
4d0fb01f by Fatih Uzunoglu at 2024-07-25T17:49:03+00:00
qml: fix context menu button twitching in TableViewDelegate with Qt 6.2

This is a problem with Qt 6.2. When a control within another
control is hovered, the bigger control is no longer considered
hovered.

- - - - -


2 changed files:

- modules/gui/qt/maininterface/mainctx.hpp
- modules/gui/qt/widgets/qml/TableViewDelegate.qml


Changes:

=====================================
modules/gui/qt/maininterface/mainctx.hpp
=====================================
@@ -252,6 +252,13 @@ public:
                                                                         unsigned char patch)
                                                                        { return QT_VERSION_CHECK(major, minor, patch); }
 
+    Q_INVOKABLE static /*constexpr*/ inline bool qtQuickControlRejectsHoverEvents() {
+        // QTBUG-100543
+        return (QT_VERSION < QT_VERSION_CHECK(6, 3, 0) && QT_VERSION >= QT_VERSION_CHECK(6, 2, 5)) ||
+               (QT_VERSION < QT_VERSION_CHECK(6, 4, 0) && QT_VERSION >= QT_VERSION_CHECK(6, 3, 1)) ||
+               (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0));
+    }
+
     /**
      * @brief ask for the application to terminate
      * @return true if the application can be close right away, false if it will be delayed


=====================================
modules/gui/qt/widgets/qml/TableViewDelegate.qml
=====================================
@@ -252,6 +252,21 @@ T.Control {
 
                 visible: delegate.hovered
 
+                // NOTE: QTBUG-100543
+                // Hover handling in controls is blocking in Qt 6.2, meaning if this
+                // control handles the hover, delegate itself won't have its `hovered`
+                // set. Since this control is visible when delegate is hovered, there
+                // becomes an infinite loop of visibility when this control is hovered.
+
+                // 1) When delegate is hovered, delegate's hovered property becomes set.
+                // 2) This control becomes visible.
+                // 3) When this control is hovered, delegate's hovered property becomes unset.
+                // 4) This control becomes invisible. Delegate's hovered property becomes set.
+                // * Infinite loop *
+
+                // Disable hovering in this control to prevent twitching due to infinite loop:
+                hoverEnabled: MainCtx.qtQuickControlRejectsHoverEvents()
+
                 onClicked: {
                     if (!delegate.selected)
                         delegate.selectAndFocus(Qt.NoModifier, Qt.MouseFocusReason)



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/0beba970a61c2905c541ed8fd821565250acc771...4d0fb01f3b2024216a33492ffc4d18e5cafbfde1

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/0beba970a61c2905c541ed8fd821565250acc771...4d0fb01f3b2024216a33492ffc4d18e5cafbfde1
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