Start restructuring how the account/room pane work

This commit is contained in:
miruka
2020-04-26 14:20:45 -04:00
parent da6a54f0bf
commit 72c96b3ba5
13 changed files with 290 additions and 692 deletions

View File

@@ -0,0 +1,74 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import QtQuick.Layouts 1.12
import ".."
import "../Base"
HListView {
id: roomList
model: ModelStore.get(accountModel.id, "rooms")
delegate: Room {
width: roomList.width
userId: accountModel.id
onActivated: showRoom(model.index)
}
property var accountModel
property var roomPane
property bool isCurrent: false
function showRoom(index=currentIndex) {
pageLoader.showRoom(accountModel.id, model.get(index).id)
currentIndex = index
}
Timer {
id: showRoomLimiter
interval: 200
onTriggered: showRoom()
}
HShortcut {
enabled: isCurrent
sequences: window.settings.keys.goToPreviousRoom
onActivated: { decrementCurrentIndex(); showRoomLimiter.restart() }
}
HShortcut {
enabled: isCurrent
sequences: window.settings.keys.goToNextRoom
onActivated: { incrementCurrentIndex(); showRoomLimiter.restart() }
}
Repeater {
model: Object.keys(window.settings.keys.focusRoomAtIndex)
Item {
HShortcut {
enabled: isCurrent
sequence: window.settings.keys.focusRoomAtIndex[modelData]
onActivated: showRoom(parseInt(modelData - 1, 10))
}
}
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton
onWheel: {
const goingDown = wheel.angleDelta.y < 0
if (! goingDown && roomList.atYBeginning)
roomPane.decrementCurrentIndex()
else if (goingDown && roomList.atYEnd)
roomPane.incrementCurrentIndex()
else
wheel.accepted = false
}
}
}