moment/src/gui/MainPane/MainPaneToolBar.qml
miruka 9990fecc74 Begin yet another model refactor
Use native ListModel which require a lot of changes, but should be
much faster than the old way which exponentially slowed down to a crawl.
Also fix some popup bugs (leave/forget).

Not working yet: side pane keyboard controls, proper highlight,
room & member filtering, local echo replacement
2020-01-06 03:41:14 -04:00

61 lines
1.7 KiB
QML

// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../Base"
HRowLayout {
id: toolBar
// Hide filter field overflowing for a sec on size changes
clip: true
property AccountRoomsList mainPaneList
readonly property alias addAccountButton: addAccountButton
readonly property alias filterField: filterField
property alias roomFilter: filterField.text
HButton {
id: addAccountButton
icon.name: "add-account"
toolTip.text: qsTr("Add another account")
backgroundColor: theme.mainPane.settingsButton.background
onClicked: pageLoader.showPage("AddAccount/AddAccount")
Layout.fillHeight: true
}
HTextField {
id: filterField
saveName: "roomFilterField"
placeholderText: qsTr("Filter rooms")
backgroundColor: theme.mainPane.filterRooms.background
bordered: false
opacity: width >= 16 * theme.uiScale ? 1 : 0
Layout.fillWidth: true
Layout.fillHeight: true
Keys.onUpPressed: mainPaneList.previous(false) // do not activate
Keys.onDownPressed: mainPaneList.next(false)
Keys.onEnterPressed: Keys.onReturnPressed(event)
Keys.onReturnPressed: {
if (event.modifiers & Qt.ShiftModifier) {
mainPaneList.toggleCollapseAccount()
return
}
if (window.settings.clearRoomFilterOnEnter) text = ""
mainPaneList.activate()
}
Keys.onEscapePressed: {
if (window.settings.clearRoomFilterOnEscape) text = ""
mainUI.pageLoader.forceActiveFocus()
}
Behavior on opacity { HNumberAnimation {} }
}
}