2020-04-27 04:20:45 +10:00
|
|
|
// 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)
|
|
|
|
}
|
|
|
|
|
2020-04-28 12:10:10 +10:00
|
|
|
onIsCurrentChanged: if (isCurrent) showRoom()
|
|
|
|
|
2020-04-27 04:20:45 +10:00
|
|
|
|
|
|
|
property var accountModel
|
|
|
|
property var roomPane
|
|
|
|
property bool isCurrent: false
|
|
|
|
|
|
|
|
|
|
|
|
function showRoom(index=currentIndex) {
|
2020-04-28 12:10:10 +10:00
|
|
|
if (index === -1) index = 0
|
|
|
|
if (index >= model.count) return
|
2020-04-27 04:20:45 +10:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
2020-04-28 13:49:36 +10:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
anchors.fill: parent
|
|
|
|
z: -100
|
|
|
|
color: theme.accountView.roomList.background
|
|
|
|
}
|
2020-04-27 04:20:45 +10:00
|
|
|
}
|