[vlc-commits] qml: don't steal focus on mouse hover in SearchBox

Pierre Lamot git at videolan.org
Fri Jan 10 15:06:36 CET 2020


vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Thu Jan  9 13:50:58 2020 +0100| [52e1fb3ca7e2804e0b20333b03b85646f95914eb] | committer: Jean-Baptiste Kempf

qml: don't steal focus on mouse hover in SearchBox

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

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

 modules/gui/qt/widgets/qml/SearchBox.qml | 87 +++++++++++++-------------------
 1 file changed, 35 insertions(+), 52 deletions(-)

diff --git a/modules/gui/qt/widgets/qml/SearchBox.qml b/modules/gui/qt/widgets/qml/SearchBox.qml
index c1d04be940..0ff86cac15 100644
--- a/modules/gui/qt/widgets/qml/SearchBox.qml
+++ b/modules/gui/qt/widgets/qml/SearchBox.qml
@@ -17,6 +17,7 @@
  *****************************************************************************/
 import QtQuick 2.11
 import QtQuick.Controls 2.4
+import QtQuick.Layouts 1.3
 
 import "qrc:///style/"
 import "qrc:///widgets/" as Widgets
@@ -41,7 +42,8 @@ Widgets.NavigableFocusScope {
         else {
             searchBox.placeholderText = ""
             searchBox.text = ""
-            icon.forceActiveFocus()
+            icon.focus = true
+            searchBox.focus = false
             icon.KeyNavigation.right = null
             animateRetract.start()
         }
@@ -71,71 +73,52 @@ Widgets.NavigableFocusScope {
         to: 0
     }
 
-    MouseArea {
-        id: mouseArea
-        hoverEnabled: true
-        anchors.fill: parent
 
-        onClicked: {
-            searchBox.forceActiveFocus()
-        }
-
-        onEntered: {
-            expanded = true
-        }
-
-        onExited: {
-            if (searchBox.text == "")
-                expanded = false
-        }
+    Row {
+        id: content
 
+        Widgets.IconToolButton {
+            id: icon
 
-        Row {
-            id: content
+            size: VLCStyle.icon_normal
+            iconText: VLCIcons.search
+            text: i18n.qtr("Filter")
 
-            Widgets.IconToolButton {
-                id: icon
+            focus: true
 
-                size: VLCStyle.icon_normal
-                iconText: VLCIcons.search
-                text: i18n.qtr("Filter")
-
-                focus: true
-
-                onClicked: {
-                    if (searchBox.text == "")
-                        expanded = !expanded
-                }
+            onClicked: {
+                if (searchBox.text == "")
+                    expanded = !expanded
             }
+        }
 
-            TextField {
-                id: searchBox
+        TextField {
+            id: searchBox
 
-                anchors.verticalCenter: parent.verticalCenter
+            anchors.verticalCenter: parent.verticalCenter
 
-                font.pixelSize: VLCStyle.fontSize_normal
+            font.pixelSize: VLCStyle.fontSize_normal
 
-                color: VLCStyle.colors.buttonText
-                width: 0
+            color: VLCStyle.colors.buttonText
+            width: 0
 
-                selectByMouse: true
+            selectByMouse: true
 
-                background: Rectangle {
-                    color: VLCStyle.colors.button
-                    border.color: {
-                        if ( searchBox.text.length < 3 && searchBox.text.length !== 0 )
-                            return VLCStyle.colors.alert
-                        else if ( searchBox.activeFocus )
-                            return VLCStyle.colors.accent
-                        else
-                            return VLCStyle.colors.buttonBorder
-                    }
+            background: Rectangle {
+                color: VLCStyle.colors.button
+                border.color: {
+                    if ( searchBox.text.length < 3 && searchBox.text.length !== 0 )
+                        return VLCStyle.colors.alert
+                    else if ( searchBox.activeFocus )
+                        return VLCStyle.colors.accent
+                    else
+                        return VLCStyle.colors.buttonBorder
                 }
+            }
 
-                onTextChanged: {
-                    if (contentModel !== undefined)
-                        contentModel.searchPattern = text;
-                }
+            onTextChanged: {
+                if (contentModel !== undefined)
+                    contentModel.searchPattern = text;
             }
         }
     }



More information about the vlc-commits mailing list