2020-04-27 04:20:45 +10:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
import ".."
|
|
|
|
import "../Base"
|
|
|
|
import "../Base/HTile"
|
|
|
|
|
|
|
|
HColumnLayout {
|
2020-04-30 04:00:02 +10:00
|
|
|
property RoomList roomList
|
2020-04-27 04:20:45 +10:00
|
|
|
|
|
|
|
|
|
|
|
HButton {
|
2020-04-30 04:00:02 +10:00
|
|
|
id: addAccountButton
|
|
|
|
icon.name: "add-account"
|
|
|
|
toolTip.text: qsTr("Add another account")
|
|
|
|
backgroundColor: theme.accountsBar.addAccountButtonBackground
|
|
|
|
onClicked: pageLoader.showPage("AddAccount/AddAccount")
|
2020-04-27 04:20:45 +10:00
|
|
|
|
|
|
|
Layout.preferredHeight: theme.baseElementsHeight
|
2020-04-29 06:18:18 +10:00
|
|
|
|
|
|
|
HShortcut {
|
2020-04-30 04:00:02 +10:00
|
|
|
sequences: window.settings.keys.addNewAccount
|
|
|
|
onActivated: addAccountButton.clicked()
|
2020-04-29 06:18:18 +10:00
|
|
|
}
|
2020-04-27 04:20:45 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
HListView {
|
|
|
|
id: accountList
|
2020-04-29 04:21:15 +10:00
|
|
|
clip: true
|
2020-04-27 04:20:45 +10:00
|
|
|
model: ModelStore.get("accounts")
|
2020-04-30 04:00:02 +10:00
|
|
|
currentIndex:
|
|
|
|
roomList.currentIndex === -1 ?
|
|
|
|
-1 :
|
|
|
|
model.findIndex(
|
2020-05-01 06:37:03 +10:00
|
|
|
roomList.model.filtered.get(
|
|
|
|
roomList.currentIndex,
|
|
|
|
).model.for_account,
|
|
|
|
-1,
|
2020-04-30 04:00:02 +10:00
|
|
|
)
|
2020-04-27 04:20:45 +10:00
|
|
|
|
2020-04-29 04:21:15 +10:00
|
|
|
highlight: Item {
|
|
|
|
Rectangle {
|
|
|
|
anchors.fill: parent
|
|
|
|
color: theme.accountsBar.accountList.account.selectedBackground
|
|
|
|
opacity: theme.accountsBar.accountList.account
|
|
|
|
.selectedBackgroundOpacity
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
z: 100
|
|
|
|
width: theme.accountsBar.accountList.account.selectedBorderSize
|
|
|
|
height: parent.height
|
|
|
|
color: theme.accountsBar.accountList.account.selectedBorder
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-27 04:20:45 +10:00
|
|
|
delegate: HTileDelegate {
|
|
|
|
id: tile
|
|
|
|
width: accountList.width
|
2020-04-28 13:49:36 +10:00
|
|
|
backgroundColor: theme.accountsBar.accountList.account.background
|
2020-04-29 04:21:15 +10:00
|
|
|
|
|
|
|
topPadding: (accountList.width - avatar.width) / 4
|
|
|
|
bottomPadding: topPadding
|
2020-04-27 04:20:45 +10:00
|
|
|
leftPadding: 0
|
|
|
|
rightPadding: leftPadding
|
|
|
|
|
|
|
|
contentItem: Item {
|
|
|
|
implicitHeight: avatar.height
|
|
|
|
|
|
|
|
HUserAvatar {
|
|
|
|
id: avatar
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
userId: model.id
|
|
|
|
displayName: model.display_name
|
|
|
|
mxc: model.avatar_url
|
2020-05-01 15:22:08 +10:00
|
|
|
// compact: tile.compact
|
2020-04-27 04:20:45 +10:00
|
|
|
|
2020-04-28 13:49:36 +10:00
|
|
|
radius: theme.accountsBar.accountList.account.avatarRadius
|
2020-04-27 04:20:45 +10:00
|
|
|
}
|
2020-05-01 18:46:08 +10:00
|
|
|
|
|
|
|
MessageIndicator {
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
2020-05-01 18:50:00 +10:00
|
|
|
indicatorTheme: theme.accountView.account.unreadIndicator
|
2020-05-01 18:46:08 +10:00
|
|
|
unreads: model.total_unread
|
|
|
|
mentions: model.total_mentions
|
|
|
|
}
|
2020-04-27 04:20:45 +10:00
|
|
|
}
|
|
|
|
|
2020-05-01 19:21:50 +10:00
|
|
|
contextMenu: AccountContextMenu { userId: model.id }
|
|
|
|
|
2020-05-02 08:34:23 +10:00
|
|
|
onLeftClicked: {
|
|
|
|
model.id in roomList.sectionIndice ?
|
|
|
|
roomList.goToAccount(model.id) :
|
|
|
|
pageLoader.showPage("AddChat/AddChat", {userId: model.id})
|
|
|
|
}
|
2020-04-27 04:20:45 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2020-04-28 12:10:10 +10:00
|
|
|
|
|
|
|
HShortcut {
|
|
|
|
sequences: window.settings.keys.goToPreviousAccount
|
2020-04-30 04:00:02 +10:00
|
|
|
onActivated: {
|
|
|
|
accountList.decrementCurrentIndex()
|
|
|
|
accountList.currentItem.leftClicked()
|
|
|
|
}
|
2020-04-28 12:10:10 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
HShortcut {
|
|
|
|
sequences: window.settings.keys.goToNextAccount
|
2020-04-30 04:00:02 +10:00
|
|
|
onActivated: {
|
|
|
|
accountList.incrementCurrentIndex()
|
|
|
|
accountList.currentItem.leftClicked()
|
|
|
|
}
|
2020-04-28 12:10:10 +10:00
|
|
|
}
|
2020-04-28 13:49:36 +10:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
anchors.fill: parent
|
|
|
|
z: -100
|
|
|
|
color: theme.accountsBar.accountList.background
|
|
|
|
}
|
2020-04-27 04:20:45 +10:00
|
|
|
}
|
|
|
|
|
2020-04-29 06:18:18 +10:00
|
|
|
HButton {
|
|
|
|
id: settingsButton
|
|
|
|
backgroundColor: theme.accountsBar.settingsButtonBackground
|
|
|
|
icon.name: "settings"
|
|
|
|
toolTip.text: qsTr("Open config folder")
|
|
|
|
|
|
|
|
onClicked: py.callCoro("get_config_dir", [], Qt.openUrlExternally)
|
|
|
|
|
|
|
|
Layout.preferredHeight: theme.baseElementsHeight
|
|
|
|
}
|
2020-04-27 04:20:45 +10:00
|
|
|
}
|