2019-12-19 07:46:16 -04:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
2019-08-18 03:27:00 -04:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
import "../Base"
|
2020-03-30 15:03:35 -04:00
|
|
|
import "../Base/HTile"
|
2019-08-18 03:27:00 -04:00
|
|
|
|
2020-05-14 18:42:50 -04:00
|
|
|
HTile {
|
2019-12-02 16:29:29 -04:00
|
|
|
id: account
|
2020-05-13 08:24:53 -04:00
|
|
|
backgroundColor: theme.mainPane.listView.account.background
|
2019-08-18 03:27:00 -04:00
|
|
|
|
2020-03-30 15:03:35 -04:00
|
|
|
contentItem: ContentRow {
|
|
|
|
tile: account
|
2020-05-13 14:16:37 -04:00
|
|
|
spacing: 0
|
2020-05-14 18:42:50 -04:00
|
|
|
opacity:
|
|
|
|
collapsed ? theme.mainPane.listView.account.collapsedOpacity : 1
|
2020-05-13 14:16:37 -04:00
|
|
|
|
|
|
|
Behavior on opacity { HNumberAnimation {} }
|
2019-08-23 10:53:54 -04:00
|
|
|
|
2020-03-30 15:03:35 -04:00
|
|
|
HUserAvatar {
|
|
|
|
id: avatar
|
2020-05-12 06:09:07 -04:00
|
|
|
userId: model.id
|
|
|
|
displayName: model.display_name
|
|
|
|
mxc: model.avatar_url
|
2020-05-13 08:24:53 -04:00
|
|
|
radius: theme.mainPane.listView.account.avatarRadius
|
2020-05-01 01:22:08 -04:00
|
|
|
compact: account.compact
|
2020-05-14 18:42:50 -04:00
|
|
|
|
2020-07-02 00:27:50 -03:00
|
|
|
presence: model.presence
|
2020-06-29 13:26:28 -03:00
|
|
|
|
2020-05-14 18:42:50 -04: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
|
2020-05-31 19:13:19 -04:00
|
|
|
highlights: model.total_highlights
|
2020-06-26 05:43:49 -04:00
|
|
|
localUnreads: model.local_unreads
|
2020-06-26 05:58:43 -04:00
|
|
|
localHighlights: model.local_highlights
|
2020-05-14 18:42:50 -04:00
|
|
|
}
|
|
|
|
|
2019-12-02 16:29:29 -04:00
|
|
|
}
|
2019-08-19 10:28:49 -04:00
|
|
|
|
2020-07-03 02:28:27 -03:00
|
|
|
HColumnLayout {
|
2020-07-07 11:42:16 -03:00
|
|
|
id: title
|
|
|
|
|
2020-07-03 02:28:27 -03:00
|
|
|
TitleLabel {
|
|
|
|
text: model.display_name || model.id
|
|
|
|
color:
|
|
|
|
hovered ?
|
|
|
|
utils.nameColor(
|
|
|
|
model.display_name || model.id.substring(1),
|
|
|
|
) :
|
|
|
|
theme.mainPane.listView.account.name
|
|
|
|
|
|
|
|
Behavior on color { HColorAnimation {} }
|
|
|
|
|
|
|
|
Layout.leftMargin: theme.spacing
|
|
|
|
}
|
|
|
|
|
|
|
|
SubtitleLabel {
|
2020-07-07 11:42:16 -03:00
|
|
|
id: statusMsg
|
2020-07-03 02:28:27 -03:00
|
|
|
tile: account
|
2020-07-07 11:42:16 -03:00
|
|
|
text: utils.escapeHtml(model.status_msg.trim())
|
|
|
|
visible: model.status_msg.trim()
|
2020-07-03 02:28:27 -03:00
|
|
|
|
|
|
|
Layout.leftMargin: theme.spacing
|
|
|
|
}
|
2020-07-07 11:42:16 -03:00
|
|
|
|
|
|
|
HoverHandler { id: nameHover }
|
|
|
|
|
|
|
|
HToolTip {
|
|
|
|
visible: nameHover.hovered
|
|
|
|
text:
|
|
|
|
model.id +
|
|
|
|
(statusMsg.text ? " - " + model.status_msg.trim() : "")
|
|
|
|
}
|
2020-03-30 15:03:35 -04:00
|
|
|
}
|
2020-02-13 06:58:13 -04:00
|
|
|
|
2020-03-12 22:16:33 -04: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 06:09:07 -04:00
|
|
|
"AddChat/AddChat", {userId: model.id},
|
2020-03-12 22:16:33 -04:00
|
|
|
)
|
2019-11-07 06:44:53 -04:00
|
|
|
|
2020-05-13 14:16:37 -04:00
|
|
|
leftPadding: theme.spacing
|
|
|
|
rightPadding: theme.spacing / 1.75
|
|
|
|
|
2020-03-12 22:16:33 -04:00
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.maximumWidth:
|
|
|
|
account.width >= 100 * theme.uiScale ? implicitWidth : 0
|
2019-11-07 06:44:53 -04:00
|
|
|
|
2020-04-26 14:20:45 -04:00
|
|
|
HShortcut {
|
2020-05-14 18:42:50 -04:00
|
|
|
enabled: enableKeybinds
|
2020-04-26 14:20:45 -04:00
|
|
|
sequences: window.settings.keys.addNewChat
|
|
|
|
onActivated: addChat.clicked()
|
2020-03-12 22:16:33 -04:00
|
|
|
}
|
|
|
|
}
|
2020-05-13 14:16:37 -04: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 03:27:00 -04:00
|
|
|
}
|
2020-03-30 15:03:35 -04:00
|
|
|
|
2020-07-02 00:27:50 -03:00
|
|
|
contextMenu: AccountContextMenu {
|
|
|
|
userId: model.id
|
2020-07-02 21:25:24 -03:00
|
|
|
presence: model.presence_support ? model.presence : null
|
2020-07-03 02:28:27 -03:00
|
|
|
statusMsg: model.status_msg
|
2020-07-02 21:25:24 -03:00
|
|
|
|
|
|
|
// Gray out buttons before first sync
|
2020-07-02 00:27:50 -03:00
|
|
|
firstSyncDone: model.first_sync_done
|
|
|
|
}
|
2020-03-30 15:03:35 -04:00
|
|
|
|
|
|
|
|
2020-05-14 18:42:50 -04:00
|
|
|
property bool enableKeybinds: false
|
2020-05-13 14:16:37 -04:00
|
|
|
property bool filterActive: false
|
|
|
|
|
|
|
|
readonly property bool collapsed:
|
|
|
|
(window.uiState.collapseAccounts[model.id] || false) &&
|
|
|
|
! filterActive
|
|
|
|
|
2020-05-14 18:42:50 -04: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-13 14:16:37 -04:00
|
|
|
|
|
|
|
function setCollapse(collapse) {
|
|
|
|
window.uiState.collapseAccounts[model.id] = collapse
|
|
|
|
window.uiStateChanged()
|
2020-05-13 20:22:48 -04:00
|
|
|
|
|
|
|
py.callCoro("set_account_collapse", [model.id, collapse])
|
2020-05-13 14:16:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function toggleCollapse() {
|
|
|
|
setCollapse(! collapsed)
|
|
|
|
}
|
2020-03-30 15:03:35 -04:00
|
|
|
|
|
|
|
|
2020-04-26 14:20:45 -04:00
|
|
|
HShortcut {
|
2020-05-14 18:42:50 -04:00
|
|
|
enabled: enableKeybinds
|
2020-04-26 14:20:45 -04:00
|
|
|
sequences: window.settings.keys.accountSettings
|
|
|
|
onActivated: leftClicked()
|
|
|
|
}
|
2020-05-13 20:34:20 -04:00
|
|
|
|
|
|
|
HShortcut {
|
2020-05-14 18:42:50 -04:00
|
|
|
enabled: enableKeybinds
|
2020-05-13 20:34:20 -04:00
|
|
|
sequences: window.settings.keys.toggleCollapseAccount
|
|
|
|
onActivated: toggleCollapse()
|
|
|
|
}
|
2019-08-18 03:27:00 -04:00
|
|
|
}
|