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 ".."
|
|
|
|
import "../Base"
|
|
|
|
import "../Base/HTile"
|
|
|
|
|
|
|
|
|
2020-05-13 21:37:39 +10:00
|
|
|
Rectangle {
|
|
|
|
implicitHeight: accountList.count >= 2 ? accountList.contentHeight : 0
|
|
|
|
color: theme.accountsBar.accountList.background
|
2020-04-27 04:20:45 +10:00
|
|
|
|
|
|
|
|
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-04-27 04:20:45 +10:00
|
|
|
|
2020-05-13 21:37:39 +10:00
|
|
|
Behavior on implicitHeight { HNumberAnimation {} }
|
|
|
|
|
|
|
|
HGridView {
|
2020-04-27 04:20:45 +10:00
|
|
|
id: accountList
|
2020-05-13 21:37:39 +10:00
|
|
|
anchors.centerIn: parent
|
|
|
|
width: Math.min(cellWidth * count, parent.width)
|
|
|
|
height: parent.height
|
|
|
|
// anchors.topMargin: theme.spacing / 2
|
|
|
|
// anchors.bottomMargin: anchors.topMargin
|
|
|
|
// anchors.leftMargin: -theme.spacing / 2
|
|
|
|
// anchors.rightMargin: anchors.leftMargin
|
|
|
|
|
|
|
|
|
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
|
2020-04-30 04:00:02 +10:00
|
|
|
currentIndex:
|
2020-05-11 07:41:12 +10:00
|
|
|
roomList.count === 0 || roomList.currentIndex === -1 ?
|
2020-04-30 04:00:02 +10:00
|
|
|
-1 :
|
2020-05-11 07:41:12 +10:00
|
|
|
model.findIndex(
|
2020-05-12 20:09:07 +10:00
|
|
|
roomList.model.get(roomList.currentIndex).for_account ||
|
|
|
|
roomList.model.get(roomList.currentIndex).id,
|
|
|
|
-1,
|
2020-04-30 04:00:02 +10:00
|
|
|
)
|
2020-04-27 04:20:45 +10:00
|
|
|
|
2020-05-11 04:26:26 +10:00
|
|
|
model: ModelStore.get("matching_accounts")
|
|
|
|
|
|
|
|
delegate: HTileDelegate {
|
|
|
|
id: tile
|
2020-05-13 21:37:39 +10:00
|
|
|
width: accountList.cellWidth
|
|
|
|
height: accountList.cellHeight
|
|
|
|
padded: false
|
|
|
|
backgroundColor: theme.accountsBar.accountList.account.background
|
2020-05-11 04:26:26 +10:00
|
|
|
|
|
|
|
contentItem: Item {
|
2020-05-11 05:29:18 +10:00
|
|
|
id: tileContent
|
2020-05-11 04:26:26 +10:00
|
|
|
|
|
|
|
HUserAvatar {
|
|
|
|
id: avatar
|
2020-05-13 21:37:39 +10:00
|
|
|
anchors.centerIn: parent
|
2020-05-11 04:26:26 +10:00
|
|
|
userId: model.id
|
|
|
|
displayName: model.display_name
|
|
|
|
mxc: model.avatar_url
|
|
|
|
// compact: tile.compact
|
|
|
|
|
2020-05-13 21:37:39 +10:00
|
|
|
radius: theme.accountsBar.accountList.account.avatarRadius
|
2020-05-02 09:00:49 +10:00
|
|
|
}
|
|
|
|
|
2020-05-11 04:26:26 +10:00
|
|
|
MessageIndicator {
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: parent.bottom
|
2020-05-02 09:00:49 +10:00
|
|
|
|
2020-05-11 04:26:26 +10:00
|
|
|
indicatorTheme:
|
|
|
|
theme.accountView.account.unreadIndicator
|
|
|
|
unreads: model.total_unread
|
|
|
|
mentions: model.total_mentions
|
2020-05-02 09:00:49 +10:00
|
|
|
}
|
2020-05-11 05:29:18 +10:00
|
|
|
|
|
|
|
HLoader {
|
2020-05-13 21:37:39 +10:00
|
|
|
visible: false // XXX
|
|
|
|
anchors.centerIn: parent
|
|
|
|
width: avatar.width
|
|
|
|
height: avatar.height
|
2020-05-11 05:29:18 +10:00
|
|
|
opacity: model.first_sync_done ? 0 : 1
|
|
|
|
|
|
|
|
active: opacity > 0
|
|
|
|
sourceComponent: Rectangle {
|
2020-05-13 21:37:39 +10:00
|
|
|
radius: avatar.radius
|
2020-05-11 05:29:18 +10:00
|
|
|
color: utils.hsluv(0, 0, 0, 0.5)
|
|
|
|
|
|
|
|
HBusyIndicator {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
width: tileContent.width / 2
|
|
|
|
height: width
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Behavior on opacity { HNumberAnimation {} }
|
|
|
|
}
|
2020-05-02 09:00:49 +10:00
|
|
|
}
|
|
|
|
|
2020-05-11 04:26:26 +10:00
|
|
|
contextMenu: AccountContextMenu { userId: model.id }
|
2020-05-02 09:00:49 +10:00
|
|
|
|
2020-05-12 20:09:07 +10:00
|
|
|
onLeftClicked: roomList.goToAccount(model.id)
|
2020-05-02 09:00:49 +10:00
|
|
|
}
|
|
|
|
|
2020-04-29 04:21:15 +10:00
|
|
|
highlight: Item {
|
2020-05-12 20:09:07 +10:00
|
|
|
readonly property alias border: border
|
|
|
|
|
2020-04-29 04:21:15 +10:00
|
|
|
Rectangle {
|
|
|
|
anchors.fill: parent
|
|
|
|
color: theme.accountsBar.accountList.account.selectedBackground
|
|
|
|
opacity: theme.accountsBar.accountList.account
|
|
|
|
.selectedBackgroundOpacity
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
2020-05-12 20:09:07 +10:00
|
|
|
id: border
|
2020-05-13 21:37:39 +10:00
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
width: parent.width
|
|
|
|
height:
|
|
|
|
theme.accountsBar.accountList.account.selectedBorderSize
|
2020-04-29 04:21:15 +10:00
|
|
|
color: theme.accountsBar.accountList.account.selectedBorder
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-29 06:18:18 +10:00
|
|
|
}
|
2020-04-27 04:20:45 +10:00
|
|
|
}
|
2020-05-13 21:37:39 +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
|
|
|
|
// }
|
|
|
|
// HButton {
|
|
|
|
// id: addAccountButton
|
|
|
|
// icon.name: "add-account"
|
|
|
|
// toolTip.text: qsTr("Add another account")
|
|
|
|
// backgroundColor: theme.accountsBar.addAccountButtonBackground
|
|
|
|
// onClicked: pageLoader.showPage("AddAccount/AddAccount")
|
|
|
|
|
|
|
|
// Layout.preferredHeight: theme.baseElementsHeight
|
|
|
|
|
|
|
|
// HShortcut {
|
|
|
|
// sequences: window.settings.keys.addNewAccount
|
|
|
|
// onActivated: addAccountButton.clicked()
|
|
|
|
// }
|
|
|
|
// }
|