From 45048e625c5ed225c2097431a1b8f8daa920e875 Mon Sep 17 00:00:00 2001 From: miruka Date: Thu, 14 May 2020 02:14:54 -0400 Subject: [PATCH] Fix UI parts focus keybind and buttons --- src/gui/Base/HPageHeader.qml | 2 +- src/gui/MainPane/BottomBar.qml | 15 ++------------- src/gui/MainPane/MainPane.qml | 11 +++++++++++ src/gui/Pages/Chat/RoomHeader.qml | 2 +- src/gui/Pages/Chat/RoomPane/RoomPane.qml | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/gui/Base/HPageHeader.qml b/src/gui/Base/HPageHeader.qml index a3b66f62..36041609 100644 --- a/src/gui/Base/HPageHeader.qml +++ b/src/gui/Base/HPageHeader.qml @@ -26,7 +26,7 @@ Rectangle { icon.name: "go-back-to-main-pane" toolTip.text: qsTr("Go back to main pane") - onClicked: mainUI.mainPane.filterRoomsField.toggleFocus() + onClicked: mainUI.mainPane.toggleFocus() Layout.preferredWidth: theme.baseElementsHeight Layout.fillHeight: true diff --git a/src/gui/MainPane/BottomBar.qml b/src/gui/MainPane/BottomBar.qml index b093b0cc..c7bbc053 100644 --- a/src/gui/MainPane/BottomBar.qml +++ b/src/gui/MainPane/BottomBar.qml @@ -16,17 +16,6 @@ Rectangle { readonly property alias filterField: filterField - function toggleFocus() { - if (filterField.activeFocus) { - pageLoader.takeFocus() - return - } - - mainPane.open() - filterField.forceActiveFocus() - } - - HRowLayout { anchors.fill: parent @@ -67,7 +56,7 @@ Rectangle { } Keys.onEscapePressed: { - mainUI.pageLoader.forceActiveFocus() + mainPane.toggleFocus() if (window.settings.clearRoomFilterOnEscape) text = "" } @@ -81,7 +70,7 @@ Rectangle { HShortcut { sequences: window.settings.keys.toggleFocusMainPane - onActivated: toggleFocus() + onActivated: mainPane.toggleFocus() } } } diff --git a/src/gui/MainPane/MainPane.qml b/src/gui/MainPane/MainPane.qml index 5d86ddb0..70d2f0a9 100644 --- a/src/gui/MainPane/MainPane.qml +++ b/src/gui/MainPane/MainPane.qml @@ -15,6 +15,17 @@ HDrawer { readonly property alias bottomBar: bottomBar + function toggleFocus() { + if (bottomBar.filterField.activeFocus) { + pageLoader.takeFocus() + return + } + + mainPane.open() + bottomBar.filterField.forceActiveFocus() + } + + Behavior on opacity { HNumberAnimation {} } Binding on visible { diff --git a/src/gui/Pages/Chat/RoomHeader.qml b/src/gui/Pages/Chat/RoomHeader.qml index 8df4140c..ec4a7a82 100644 --- a/src/gui/Pages/Chat/RoomHeader.qml +++ b/src/gui/Pages/Chat/RoomHeader.qml @@ -34,7 +34,7 @@ Rectangle { icon.name: "go-back-to-main-pane" toolTip.text: qsTr("Go back to main pane") - onClicked: mainUI.mainPane.filterRoomsField.toggleFocus() + onClicked: mainUI.mainPane.toggleFocus() Layout.preferredWidth: showPaneButtons ? avatar.width : 0 Layout.fillHeight: true diff --git a/src/gui/Pages/Chat/RoomPane/RoomPane.qml b/src/gui/Pages/Chat/RoomPane/RoomPane.qml index f9629bc3..7c16fefe 100644 --- a/src/gui/Pages/Chat/RoomPane/RoomPane.qml +++ b/src/gui/Pages/Chat/RoomPane/RoomPane.qml @@ -80,6 +80,6 @@ MultiviewPane { HShortcut { sequences: window.settings.keys.toggleFocusRoomPane - onActivated: toggleFocus() + onActivated: roomPane.toggleFocus() } }