2019-12-19 22:46:16 +11:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
2019-08-18 17:27:00 +10:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
import "../Base"
|
2020-03-31 06:03:35 +11:00
|
|
|
import "../Base/HTile"
|
2019-08-18 17:27:00 +10:00
|
|
|
|
2020-05-15 08:42:50 +10:00
|
|
|
HTile {
|
2019-12-03 07:29:29 +11:00
|
|
|
id: account
|
2020-05-13 22:24:53 +10:00
|
|
|
backgroundColor: theme.mainPane.listView.account.background
|
2019-08-18 17:27:00 +10:00
|
|
|
|
2020-03-31 06:03:35 +11:00
|
|
|
contentItem: ContentRow {
|
|
|
|
tile: account
|
2020-05-14 04:16:37 +10:00
|
|
|
spacing: 0
|
2020-05-15 08:42:50 +10:00
|
|
|
opacity:
|
|
|
|
collapsed ? theme.mainPane.listView.account.collapsedOpacity : 1
|
2020-05-14 04:16:37 +10:00
|
|
|
|
|
|
|
Behavior on opacity { HNumberAnimation {} }
|
2019-08-24 00:53:54 +10:00
|
|
|
|
2020-03-31 06:03:35 +11:00
|
|
|
HUserAvatar {
|
|
|
|
id: avatar
|
2020-05-12 20:09:07 +10:00
|
|
|
userId: model.id
|
|
|
|
displayName: model.display_name
|
|
|
|
mxc: model.avatar_url
|
2020-05-13 22:24:53 +10:00
|
|
|
radius: theme.mainPane.listView.account.avatarRadius
|
2020-05-01 15:22:08 +10:00
|
|
|
compact: account.compact
|
2020-05-15 08:42:50 +10:00
|
|
|
|
|
|
|
Layout.alignment: Qt.AlignCenter
|
|
|
|
|
|
|
|
HLoader {
|
|
|
|
anchors.fill: parent
|
|
|
|
z: 9998
|
|
|
|
opacity: model.first_sync_done ? 0 : 1
|
|
|
|
active: opacity > 0
|
|
|
|
|
|
|
|
sourceComponent: Rectangle {
|
|
|
|
radius: avatar.radius
|
|
|
|
color: utils.hsluv(0, 0, 0, 0.6)
|
|
|
|
|
|
|
|
HBusyIndicator {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
width: parent.width / 2
|
|
|
|
height: width
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Behavior on opacity { HNumberAnimation {} }
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageIndicator {
|
|
|
|
id: totalMessageIndicator
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
z: 9999
|
|
|
|
|
|
|
|
indicatorTheme:
|
|
|
|
theme.mainPane.accountBar.account.unreadIndicator
|
|
|
|
unreads: model.total_unread
|
|
|
|
mentions: model.total_mentions
|
|
|
|
}
|
|
|
|
|
2019-12-03 07:29:29 +11:00
|
|
|
}
|
2019-08-20 00:28:49 +10:00
|
|
|
|
2020-03-31 06:03:35 +11:00
|
|
|
TitleLabel {
|
2020-05-15 08:42:50 +10:00
|
|
|
id: title
|
2020-05-12 20:09:07 +10:00
|
|
|
text: model.display_name || model.id
|
2020-03-31 06:03:35 +11:00
|
|
|
color:
|
|
|
|
hovered ?
|
2020-04-30 04:00:02 +10:00
|
|
|
utils.nameColor(
|
2020-05-12 20:09:07 +10:00
|
|
|
model.display_name || model.id.substring(1),
|
2020-04-30 04:00:02 +10:00
|
|
|
) :
|
2020-05-13 22:24:53 +10:00
|
|
|
theme.mainPane.listView.account.name
|
2019-08-20 00:28:49 +10:00
|
|
|
|
2020-03-31 06:03:35 +11:00
|
|
|
Behavior on color { HColorAnimation {} }
|
2020-05-14 04:16:37 +10:00
|
|
|
|
|
|
|
Layout.leftMargin: theme.spacing
|
2020-03-31 06:03:35 +11:00
|
|
|
}
|
2020-02-13 21:58:13 +11:00
|
|
|
|
2020-03-13 13:16:33 +11:00
|
|
|
HButton {
|
|
|
|
id: addChat
|
|
|
|
iconItem.small: true
|
|
|
|
icon.name: "add-chat"
|
|
|
|
backgroundColor: "transparent"
|
|
|
|
toolTip.text: qsTr("Add new chat")
|
|
|
|
onClicked: pageLoader.showPage(
|
2020-05-12 20:09:07 +10:00
|
|
|
"AddChat/AddChat", {userId: model.id},
|
2020-03-13 13:16:33 +11:00
|
|
|
)
|
2019-11-07 21:44:53 +11:00
|
|
|
|
2020-05-14 04:16:37 +10:00
|
|
|
leftPadding: theme.spacing
|
|
|
|
rightPadding: theme.spacing / 1.75
|
|
|
|
|
2020-03-13 13:16:33 +11:00
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.maximumWidth:
|
|
|
|
account.width >= 100 * theme.uiScale ? implicitWidth : 0
|
2019-11-07 21:44:53 +11:00
|
|
|
|
2020-04-27 04:20:45 +10:00
|
|
|
HShortcut {
|
2020-05-15 08:42:50 +10:00
|
|
|
enabled: enableKeybinds
|
2020-04-27 04:20:45 +10:00
|
|
|
sequences: window.settings.keys.addNewChat
|
|
|
|
onActivated: addChat.clicked()
|
2020-03-13 13:16:33 +11:00
|
|
|
}
|
|
|
|
}
|
2020-05-14 04:16:37 +10:00
|
|
|
|
|
|
|
HButton {
|
|
|
|
id: expand
|
|
|
|
iconItem.small: true
|
|
|
|
icon.name: "expand"
|
|
|
|
backgroundColor: "transparent"
|
|
|
|
toolTip.text: collapsed ? qsTr("Expand") : qsTr("Collapse")
|
|
|
|
onClicked: account.toggleCollapse()
|
|
|
|
|
|
|
|
leftPadding: theme.spacing / 1.75
|
|
|
|
rightPadding: theme.spacing
|
|
|
|
|
|
|
|
visible: Layout.maximumWidth > 0
|
|
|
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.maximumWidth:
|
|
|
|
! filterActive && account.width >= 120 * theme.uiScale ?
|
|
|
|
implicitWidth :
|
|
|
|
0
|
|
|
|
|
|
|
|
iconItem.transform: Rotation {
|
|
|
|
origin.x: expand.iconItem.width / 2
|
|
|
|
origin.y: expand.iconItem.height / 2
|
|
|
|
angle: expand.loading ? 0 : collapsed ? 180 : 90
|
|
|
|
|
|
|
|
Behavior on angle { HNumberAnimation {} }
|
|
|
|
}
|
|
|
|
|
|
|
|
Behavior on Layout.maximumWidth { HNumberAnimation {} }
|
|
|
|
}
|
2019-08-18 17:27:00 +10:00
|
|
|
}
|
2020-03-31 06:03:35 +11:00
|
|
|
|
2020-05-12 20:09:07 +10:00
|
|
|
contextMenu: AccountContextMenu { userId: model.id }
|
2020-03-31 06:03:35 +11:00
|
|
|
|
|
|
|
|
2020-05-15 08:42:50 +10:00
|
|
|
property bool enableKeybinds: false
|
2020-05-14 04:16:37 +10:00
|
|
|
property bool filterActive: false
|
|
|
|
|
|
|
|
readonly property bool collapsed:
|
|
|
|
(window.uiState.collapseAccounts[model.id] || false) &&
|
|
|
|
! filterActive
|
|
|
|
|
2020-05-15 08:42:50 +10:00
|
|
|
readonly property alias avatar: title
|
|
|
|
readonly property alias totalMessageIndicator: totalMessageIndicator
|
|
|
|
readonly property alias title: title
|
|
|
|
readonly property alias addChat: addChat
|
|
|
|
readonly property alias expand: expand
|
|
|
|
|
2020-05-14 04:16:37 +10:00
|
|
|
|
|
|
|
function setCollapse(collapse) {
|
|
|
|
window.uiState.collapseAccounts[model.id] = collapse
|
|
|
|
window.uiStateChanged()
|
2020-05-14 10:22:48 +10:00
|
|
|
|
|
|
|
py.callCoro("set_account_collapse", [model.id, collapse])
|
2020-05-14 04:16:37 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
function toggleCollapse() {
|
|
|
|
setCollapse(! collapsed)
|
|
|
|
}
|
2020-03-31 06:03:35 +11:00
|
|
|
|
|
|
|
|
2020-04-27 04:20:45 +10:00
|
|
|
HShortcut {
|
2020-05-15 08:42:50 +10:00
|
|
|
enabled: enableKeybinds
|
2020-04-27 04:20:45 +10:00
|
|
|
sequences: window.settings.keys.accountSettings
|
|
|
|
onActivated: leftClicked()
|
|
|
|
}
|
2020-05-14 10:34:20 +10:00
|
|
|
|
|
|
|
HShortcut {
|
2020-05-15 08:42:50 +10:00
|
|
|
enabled: enableKeybinds
|
2020-05-14 10:34:20 +10:00
|
|
|
sequences: window.settings.keys.toggleCollapseAccount
|
|
|
|
onActivated: toggleCollapse()
|
|
|
|
}
|
2019-08-18 17:27:00 +10:00
|
|
|
}
|