From c1dd06559c1e063c517dc371ea49084e0d237d87 Mon Sep 17 00:00:00 2001 From: miruka Date: Wed, 13 May 2020 08:03:50 -0400 Subject: [PATCH] Bring back main pane bottom bar --- src/gui/MainPane/BottomBar.qml | 88 +++++++++++++++++++++++++++ src/gui/MainPane/FilterRoomsField.qml | 58 ------------------ src/gui/MainPane/MainPane.qml | 11 ++-- src/gui/MainPane/TopBar.qml | 1 + 4 files changed, 94 insertions(+), 64 deletions(-) create mode 100644 src/gui/MainPane/BottomBar.qml delete mode 100644 src/gui/MainPane/FilterRoomsField.qml diff --git a/src/gui/MainPane/BottomBar.qml b/src/gui/MainPane/BottomBar.qml new file mode 100644 index 00000000..7dd8546c --- /dev/null +++ b/src/gui/MainPane/BottomBar.qml @@ -0,0 +1,88 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later + +import QtQuick 2.12 +import QtQuick.Layouts 1.12 +import "../Base" + +Rectangle { + // Hide filter field overflowing for a sec on size changes + clip: true + implicitHeight: theme.baseElementsHeight + color: theme.mainPane.bottomBar.background + + + property RoomList roomList + readonly property alias addAccountButton: addAccountButton + readonly property alias filterField: filterField + + + function toggleFocus() { + if (filterField.activeFocus) { + pageLoader.takeFocus() + return + } + + mainPane.open() + filterField.forceActiveFocus() + } + + + HRowLayout { + anchors.fill: parent + + HButton { + id: addAccountButton + icon.name: "add-account" + toolTip.text: qsTr("Add another account") + backgroundColor: theme.mainPane.bottomBar.settingsButtonBackground + onClicked: pageLoader.showPage("AddAccount/AddAccount") + + Layout.fillHeight: true + + HShortcut { + sequences: window.settings.keys.addNewAccount + onActivated: addAccountButton.clicked() + } + } + + HTextField { + id: filterField + saveName: "roomFilterField" + + placeholderText: qsTr("Filter rooms") + backgroundColor: theme.accountView.bottomBar.filterFieldBackground + bordered: false + opacity: width >= 16 * theme.uiScale ? 1 : 0 + + Layout.fillWidth: true + Layout.fillHeight: true + + Keys.onUpPressed: roomList.decrementCurrentIndex() + Keys.onDownPressed: roomList.incrementCurrentIndex() + + Keys.onEnterPressed: Keys.onReturnPressed(event) + Keys.onReturnPressed: { + roomList.showItemAtIndex() + if (window.settings.clearRoomFilterOnEnter) text = "" + } + + Keys.onEscapePressed: { + mainUI.pageLoader.forceActiveFocus() + if (window.settings.clearRoomFilterOnEscape) text = "" + } + + + Behavior on opacity { HNumberAnimation {} } + + HShortcut { + sequences: window.settings.keys.clearRoomFilter + onActivated: filterField.text = "" + } + + HShortcut { + sequences: window.settings.keys.toggleFocusMainPane + onActivated: toggleFocus() + } + } + } +} diff --git a/src/gui/MainPane/FilterRoomsField.qml b/src/gui/MainPane/FilterRoomsField.qml deleted file mode 100644 index 8793e8da..00000000 --- a/src/gui/MainPane/FilterRoomsField.qml +++ /dev/null @@ -1,58 +0,0 @@ -// SPDX-License-Identifier: LGPL-3.0-or-later - -import QtQuick 2.12 -import QtQuick.Layouts 1.12 -import ".." -import "../Base" - -HTextField { - id: filterField - saveName: "roomFilterField" - implicitHeight: theme.baseElementsHeight - - placeholderText: qsTr("Filter rooms") - backgroundColor: theme.accountView.bottomBar.filterFieldBackground - bordered: false - opacity: width >= 16 * theme.uiScale ? 1 : 0 - - Keys.onUpPressed: roomList.decrementCurrentIndex() - Keys.onDownPressed: roomList.incrementCurrentIndex() - - Keys.onEnterPressed: Keys.onReturnPressed(event) - Keys.onReturnPressed: { - roomList.showItemAtIndex() - if (window.settings.clearRoomFilterOnEnter) text = "" - } - - Keys.onEscapePressed: { - mainUI.pageLoader.forceActiveFocus() - if (window.settings.clearRoomFilterOnEscape) text = "" - } - - - property RoomList roomList - - - function toggleFocus() { - if (filterField.activeFocus) { - pageLoader.takeFocus() - return - } - - mainPane.open() - filterField.forceActiveFocus() - } - - - Behavior on opacity { HNumberAnimation {} } - - HShortcut { - sequences: window.settings.keys.clearRoomFilter - onActivated: filterField.text = "" - } - - HShortcut { - sequences: window.settings.keys.toggleFocusMainPane - onActivated: toggleFocus() - } -} diff --git a/src/gui/MainPane/MainPane.qml b/src/gui/MainPane/MainPane.qml index cc27a0fc..22778421 100644 --- a/src/gui/MainPane/MainPane.qml +++ b/src/gui/MainPane/MainPane.qml @@ -7,12 +7,12 @@ import "../Base" HDrawer { id: mainPane saveName: "mainPane" - background: null + background: theme.mainPane.background minimumSize: theme.controls.avatar.size + theme.spacing * 2 readonly property alias accountsBar: accountsBar readonly property alias roomList: roomList - readonly property alias filterRoomsField: filterRoomsField + readonly property alias bottomBar: bottomBar Behavior on opacity { HNumberAnimation {} } @@ -27,7 +27,6 @@ HDrawer { TopBar { Layout.fillWidth: true - Layout.preferredHeight: theme.baseElementsHeight } AccountsBar { @@ -41,14 +40,14 @@ HDrawer { RoomList { id: roomList clip: true - filter: filterRoomsField.text + filter: bottomBar.filterField.text Layout.fillWidth: true Layout.fillHeight: true } - FilterRoomsField { - id: filterRoomsField + BottomBar { + id: bottomBar roomList: roomList Layout.fillWidth: true diff --git a/src/gui/MainPane/TopBar.qml b/src/gui/MainPane/TopBar.qml index dc8b201e..969cc76a 100644 --- a/src/gui/MainPane/TopBar.qml +++ b/src/gui/MainPane/TopBar.qml @@ -6,6 +6,7 @@ import "../Base" Rectangle { clip: true + implicitHeight: theme.baseElementsHeight color: theme.mainPaneTopBar.background HRowLayout {