[vlc-commits] qml: add a keyboard shortcut to set the focus on the search widget
Pierre Lamot
git at videolan.org
Fri Jan 10 15:06:33 CET 2020
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Tue Dec 17 14:00:20 2019 +0100| [05aa216b2e669bf41207d653ea0d2eb88447f192] | committer: Jean-Baptiste Kempf
qml: add a keyboard shortcut to set the focus on the search widget
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=05aa216b2e669bf41207d653ea0d2eb88447f192
---
modules/gui/qt/maininterface/qml/BannerSources.qml | 5 +++++
modules/gui/qt/medialibrary/qml/MainDisplay.qml | 4 ++++
modules/gui/qt/util/qml/KeyHelper.js | 6 ++++++
3 files changed, 15 insertions(+)
diff --git a/modules/gui/qt/maininterface/qml/BannerSources.qml b/modules/gui/qt/maininterface/qml/BannerSources.qml
index 7fdce97cb2..90da5569a5 100644
--- a/modules/gui/qt/maininterface/qml/BannerSources.qml
+++ b/modules/gui/qt/maininterface/qml/BannerSources.qml
@@ -52,6 +52,11 @@ Widgets.NavigableFocusScope {
medialib.gridView = !medialib.gridView
}
+ function search() {
+ if (searchBox.visible)
+ searchBox.expanded = true
+ }
+
Rectangle {
id: pLBannerSources
diff --git a/modules/gui/qt/medialibrary/qml/MainDisplay.qml b/modules/gui/qt/medialibrary/qml/MainDisplay.qml
index 5af7af0749..200876487b 100644
--- a/modules/gui/qt/medialibrary/qml/MainDisplay.qml
+++ b/modules/gui/qt/medialibrary/qml/MainDisplay.qml
@@ -65,6 +65,10 @@ Widgets.NavigableFocusScope {
}
Keys.onPressed: {
+ if (KeyHelper.matchSearch(event)) {
+ sourcesBanner.search()
+ event.accepted = true
+ }
//unhandled keys are forwarded as hotkeys
if (!event.accepted)
rootWindow.sendHotkey(event.key, event.modifiers);
diff --git a/modules/gui/qt/util/qml/KeyHelper.js b/modules/gui/qt/util/qml/KeyHelper.js
index 5864842fab..0cffe3178a 100644
--- a/modules/gui/qt/util/qml/KeyHelper.js
+++ b/modules/gui/qt/util/qml/KeyHelper.js
@@ -55,6 +55,12 @@ function matchOk( event ) {
|| event.matches(QtQuick.StandardKey.InsertParagraphSeparator)
}
+function matchSearch( event ) {
+ return event.key === Qt.Key_Search
+ || event.key === Qt.Key_Slash
+ || ( (event.modifiers & Qt.ControlModifier) && event.key === Qt.Key_F )
+}
+
function matchCancel(event) {
return event.key === Qt.Key_Backspace
|| event.key === Qt.Key_Back
More information about the vlc-commits
mailing list