Split pane components more

This commit is contained in:
miruka 2020-04-28 16:40:33 -04:00
parent 393a56a50a
commit 56c09e6b48
5 changed files with 109 additions and 91 deletions

View File

@ -0,0 +1,16 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import ".."
import "../Base"
HSwipeView {
id: swipeView
orientation: Qt.Vertical
Repeater {
model: ModelStore.get("accounts")
AccountView {}
}
}

View File

@ -5,97 +5,42 @@ import QtQuick.Layouts 1.12
import ".." import ".."
import "../Base" import "../Base"
HSwipeView { HLoader {
id: swipeView id: loader
orientation: Qt.Vertical active:
HSwipeView.isCurrentItem ||
HSwipeView.isNextItem ||
HSwipeView.isPreviousItem
readonly property bool isCurrent: HSwipeView.isCurrentItem
Repeater { sourceComponent: HColumnLayout {
model: ModelStore.get("accounts") id: column
HLoader { readonly property QtObject accountModel: model
id: loader readonly property alias roomList: roomList
active:
HSwipeView.isCurrentItem ||
HSwipeView.isNextItem ||
HSwipeView.isPreviousItem
readonly property bool isCurrent: HSwipeView.isCurrentItem Account {
id: account
isCurrent: loader.isCurrent
sourceComponent: HColumnLayout { Layout.fillWidth: true
id: column }
readonly property QtObject accountModel: model RoomList {
readonly property alias roomList: roomList id: roomList
clip: true
accountModel: column.accountModel
roomPane: swipeView
isCurrent: loader.isCurrent
Account { Layout.fillWidth: true
id: account Layout.fillHeight: true
isCurrent: loader.isCurrent }
Layout.fillWidth: true FilterRoomsField {
} roomList: roomList
Layout.fillWidth: true
RoomList {
id: roomList
clip: true
accountModel: column.accountModel
roomPane: swipeView
isCurrent: loader.isCurrent
Layout.fillWidth: true
Layout.fillHeight: true
}
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.preferredHeight: theme.baseElementsHeight
Keys.onUpPressed: roomList.decrementCurrentIndex()
Keys.onDownPressed: roomList.incrementCurrentIndex()
Keys.onEnterPressed: Keys.onReturnPressed(event)
Keys.onReturnPressed: {
if (window.settings.clearRoomFilterOnEnter) text = ""
roomList.showRoom()
}
Keys.onEscapePressed: {
if (window.settings.clearRoomFilterOnEscape) text = ""
mainUI.pageLoader.forceActiveFocus()
}
Behavior on opacity { HNumberAnimation {} }
HShortcut {
enabled: loader.isCurrent
sequences: window.settings.keys.clearRoomFilter
onActivated: filterField.text = ""
}
HShortcut {
enabled: loader.isCurrent
sequences: window.settings.keys.toggleFocusMainPane
onActivated: {
if (filterField.activeFocus) {
pageLoader.takeFocus()
return
}
mainPane.open()
filterField.forceActiveFocus()
}
}
}
}
} }
} }
} }

View File

@ -8,7 +8,7 @@ import "../Base"
import "../Base/HTile" import "../Base/HTile"
HColumnLayout { HColumnLayout {
property AccountView accountView property AccountSwipeView accountSwipeView
HButton { HButton {
@ -30,7 +30,7 @@ HColumnLayout {
id: accountList id: accountList
clip: true clip: true
model: ModelStore.get("accounts") model: ModelStore.get("accounts")
currentIndex: accountView.currentIndex currentIndex: accountSwipeView.currentIndex
highlight: Item { highlight: Item {
@ -74,7 +74,7 @@ HColumnLayout {
} }
} }
onLeftClicked: accountView.currentIndex = model.index onLeftClicked: accountSwipeView.currentIndex = model.index
} }
Layout.fillWidth: true Layout.fillWidth: true
@ -82,12 +82,12 @@ HColumnLayout {
HShortcut { HShortcut {
sequences: window.settings.keys.goToPreviousAccount sequences: window.settings.keys.goToPreviousAccount
onActivated: accountView.decrementWrapIndex() onActivated: accountSwipeView.decrementWrapIndex()
} }
HShortcut { HShortcut {
sequences: window.settings.keys.goToNextAccount sequences: window.settings.keys.goToNextAccount
onActivated: accountView.incrementWrapIndex() onActivated: accountSwipeView.incrementWrapIndex()
} }
Rectangle { Rectangle {

View File

@ -0,0 +1,57 @@
// 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: {
if (window.settings.clearRoomFilterOnEnter) text = ""
roomList.showRoom()
}
Keys.onEscapePressed: {
if (window.settings.clearRoomFilterOnEscape) text = ""
mainUI.pageLoader.forceActiveFocus()
}
property RoomList roomList
Behavior on opacity { HNumberAnimation {} }
HShortcut {
enabled: loader.isCurrent
sequences: window.settings.keys.clearRoomFilter
onActivated: filterField.text = ""
}
HShortcut {
enabled: loader.isCurrent
sequences: window.settings.keys.toggleFocusMainPane
onActivated: {
if (filterField.activeFocus) {
pageLoader.takeFocus()
return
}
mainPane.open()
filterField.forceActiveFocus()
}
}
}

View File

@ -28,13 +28,13 @@ HDrawer {
AccountsBar { AccountsBar {
id: accountBar id: accountBar
accountView: accView accountSwipeView: accountSwipeView
Layout.fillWidth: false Layout.fillWidth: false
} }
AccountView { AccountSwipeView {
id: accView id: accountSwipeView
currentIndex: 0 currentIndex: 0
Layout.fillWidth: true Layout.fillWidth: true