[vlc-commits] qml: clear search on cancel in SearchBox
Pierre Lamot
git at videolan.org
Fri Jan 10 15:06:37 CET 2020
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Thu Jan 9 13:58:59 2020 +0100| [258f98b44e3b4a475c117aa347055c455bb8a0c1] | committer: Jean-Baptiste Kempf
qml: clear search on cancel in SearchBox
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=258f98b44e3b4a475c117aa347055c455bb8a0c1
---
modules/gui/qt/widgets/qml/SearchBox.qml | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/modules/gui/qt/widgets/qml/SearchBox.qml b/modules/gui/qt/widgets/qml/SearchBox.qml
index 0ff86cac15..d253a32e9b 100644
--- a/modules/gui/qt/widgets/qml/SearchBox.qml
+++ b/modules/gui/qt/widgets/qml/SearchBox.qml
@@ -18,6 +18,7 @@
import QtQuick 2.11
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.3
+import QtQuick 2.11 as QtQuick
import "qrc:///style/"
import "qrc:///widgets/" as Widgets
@@ -120,6 +121,30 @@ Widgets.NavigableFocusScope {
if (contentModel !== undefined)
contentModel.searchPattern = text;
}
+
+ Keys.onPressed: {
+ //don't use KeyHelper.matchCancel here as we don't want to match Backspace
+ if (event.key === Qt.Key_Back
+ || event.key === Qt.Key_Cancel
+ || event.matches(QtQuick.StandardKey.Back)
+ || event.matches(QtQuick.StandardKey.Cancel))
+ {
+ event.accepted = true
+ }
+ }
+
+ Keys.onReleased: {
+ //don't use KeyHelper.matchCancel here as we don't want to match Backspace
+ if (event.key === Qt.Key_Back
+ || event.key === Qt.Key_Cancel
+ || event.matches(QtQuick.StandardKey.Back)
+ || event.matches(QtQuick.StandardKey.Cancel))
+ {
+ text = ""
+ expanded = false
+ event.accepted = true
+ }
+ }
}
}
}
More information about the vlc-commits
mailing list