moment/src/gui/MainPane/AccountBar.qml

93 lines
2.5 KiB
QML
Raw Normal View History

// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import QtQuick.Controls 2.12
import ".."
import "../Base"
import "../Base/HTile"
2020-05-13 21:37:39 +10:00
Rectangle {
implicitHeight: accountList.count >= 2 ? accountList.contentHeight : 0
color: theme.mainPane.accountBar.background
2020-05-13 21:37:39 +10:00
property RoomList roomList
readonly property alias accountList: accountList
2020-04-29 06:18:18 +10:00
2020-05-13 21:37:39 +10:00
Behavior on implicitHeight { HNumberAnimation {} }
HGridView {
id: accountList
2020-05-13 21:37:39 +10:00
anchors.centerIn: parent
width: Math.min(cellWidth * count, parent.width)
height: parent.height
2020-04-29 04:21:15 +10:00
clip: true
2020-05-13 21:37:39 +10:00
cellWidth: theme.controls.avatar.size + theme.spacing
cellHeight: cellWidth
currentIndex:
2020-05-11 07:41:12 +10:00
roomList.count === 0 || roomList.currentIndex === -1 ?
-1 :
2020-05-11 07:41:12 +10:00
model.findIndex(
roomList.model.get(roomList.currentIndex).for_account ||
roomList.model.get(roomList.currentIndex).id,
-1,
)
2020-05-11 04:26:26 +10:00
model: ModelStore.get("matching_accounts")
delegate: Account {
2020-05-13 21:37:39 +10:00
width: accountList.cellWidth
height: accountList.cellHeight
padded: false
compact: false
filterActive: Boolean(roomList.filter)
2020-05-11 04:26:26 +10:00
title.visible: false
addChat.visible: false
expand.visible: false
2020-05-11 04:26:26 +10:00
onLeftClicked: roomList.goToAccount(model.id)
}
2020-04-29 04:21:15 +10:00
highlight: Item {
readonly property alias border: border
2020-04-29 04:21:15 +10:00
Rectangle {
anchors.fill: parent
color: theme.mainPane.accountBar.account.selectedBackground
opacity: theme.mainPane.accountBar.account
2020-04-29 04:21:15 +10:00
.selectedBackgroundOpacity
}
Rectangle {
id: border
2020-05-13 21:37:39 +10:00
anchors.bottom: parent.bottom
width: parent.width
height:
theme.mainPane.accountBar.account.selectedBorderSize
color: theme.mainPane.accountBar.account.selectedBorder
2020-04-29 04:21:15 +10:00
}
}
2020-04-28 12:10:10 +10:00
HShortcut {
sequences: window.settings.keys.goToPreviousAccount
onActivated: {
2020-05-14 17:49:52 +10:00
accountList.moveCurrentIndexLeft()
accountList.currentItem.leftClicked()
}
2020-04-28 12:10:10 +10:00
}
HShortcut {
sequences: window.settings.keys.goToNextAccount
onActivated: {
2020-05-14 17:49:52 +10:00
accountList.moveCurrentIndexRight()
accountList.currentItem.leftClicked()
}
2020-04-28 12:10:10 +10:00
}
2020-04-29 06:18:18 +10:00
}
}