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
|
2019-12-28 00:06:42 +11:00
|
|
|
import Clipboard 0.1
|
2019-08-18 17:27:00 +10:00
|
|
|
import "../Base"
|
|
|
|
|
2019-08-21 18:39:07 +10:00
|
|
|
HTileDelegate {
|
2019-12-03 07:29:29 +11:00
|
|
|
id: account
|
2020-03-13 13:16:33 +11:00
|
|
|
rightPadding: 0
|
2019-12-11 06:17:41 +11:00
|
|
|
backgroundColor: theme.mainPane.account.background
|
2020-02-04 07:19:42 +11:00
|
|
|
opacity: collapsed && ! mainPane.filter ?
|
2019-12-11 06:17:41 +11:00
|
|
|
theme.mainPane.account.collapsedOpacity : 1
|
2019-08-18 17:27:00 +10:00
|
|
|
|
2019-12-03 07:29:29 +11:00
|
|
|
title.text: model.display_name || model.id
|
|
|
|
title.font.pixelSize: theme.fontSize.big
|
2020-03-13 13:16:33 +11:00
|
|
|
title.color:
|
|
|
|
hovered ?
|
|
|
|
utils.nameColor(model.display_name || model.id.substring(1)) :
|
|
|
|
theme.mainPane.account.name
|
2019-08-20 04:28:12 +10:00
|
|
|
|
2019-12-03 07:29:29 +11:00
|
|
|
image: HUserAvatar {
|
|
|
|
userId: model.id
|
|
|
|
displayName: model.display_name
|
|
|
|
mxc: model.avatar_url
|
2020-03-13 14:17:23 +11:00
|
|
|
rotation: mainPane.small ? -45 : 0
|
|
|
|
|
|
|
|
Behavior on rotation { HNumberAnimation {} }
|
2019-12-03 07:29:29 +11:00
|
|
|
}
|
2019-08-24 00:53:54 +10:00
|
|
|
|
2019-12-03 07:29:29 +11:00
|
|
|
contextMenu: HMenu {
|
|
|
|
HMenuItem {
|
|
|
|
icon.name: "copy-user-id"
|
|
|
|
text: qsTr("Copy user ID")
|
|
|
|
onTriggered: Clipboard.text = model.id
|
|
|
|
}
|
2019-08-18 17:27:00 +10:00
|
|
|
|
2019-12-03 07:29:29 +11:00
|
|
|
HMenuItemPopupSpawner {
|
|
|
|
icon.name: "sign-out"
|
|
|
|
icon.color: theme.colors.negativeBackground
|
|
|
|
text: qsTr("Sign out")
|
2019-08-21 18:39:07 +10:00
|
|
|
|
2019-12-03 07:29:29 +11:00
|
|
|
popup: "Popups/SignOutPopup.qml"
|
|
|
|
properties: { "userId": model.id }
|
|
|
|
}
|
|
|
|
}
|
2019-08-21 18:39:07 +10:00
|
|
|
|
2020-03-10 20:38:28 +11:00
|
|
|
onActivated: {
|
|
|
|
pageLoader.showPage(
|
|
|
|
"AccountSettings/AccountSettings", { "userId": model.id }
|
|
|
|
)
|
|
|
|
mainPaneList.detachedCurrentIndex = false
|
|
|
|
}
|
2019-08-20 00:28:49 +10:00
|
|
|
|
|
|
|
|
2020-02-13 20:56:10 +11:00
|
|
|
readonly property alias addChat: addChat
|
|
|
|
|
2019-12-03 07:29:29 +11:00
|
|
|
readonly property bool collapsed:
|
2020-03-08 01:15:54 +11:00
|
|
|
(window.uiState.collapseAccounts[model.id] || false) &&
|
|
|
|
! mainPane.filter
|
2019-08-18 17:27:00 +10:00
|
|
|
|
2019-08-20 03:09:05 +10:00
|
|
|
|
2020-03-08 02:28:51 +11:00
|
|
|
function setCollapse(collapse) {
|
|
|
|
window.uiState.collapseAccounts[model.id] = collapse
|
2019-08-18 17:27:00 +10:00
|
|
|
window.uiStateChanged()
|
|
|
|
}
|
|
|
|
|
2020-03-08 02:28:51 +11:00
|
|
|
function toggleCollapse() {
|
|
|
|
setCollapse(! collapsed)
|
|
|
|
}
|
|
|
|
|
2019-08-20 03:09:05 +10:00
|
|
|
|
2020-03-13 13:16:33 +11:00
|
|
|
Behavior on title.color { HColorAnimation {} }
|
2019-12-03 07:29:29 +11:00
|
|
|
Behavior on opacity { HNumberAnimation {} }
|
2020-03-13 14:17:23 +11:00
|
|
|
Behavior on leftPadding { HNumberAnimation {} }
|
|
|
|
Behavior on topPadding { HNumberAnimation {} }
|
|
|
|
|
|
|
|
Binding on leftPadding {
|
|
|
|
value: (mainPane.minimumSize - loadedImage.width) / 2
|
|
|
|
when: mainPane.small
|
|
|
|
}
|
2019-08-21 18:39:07 +10:00
|
|
|
|
2020-03-13 14:17:23 +11:00
|
|
|
Binding on topPadding {
|
|
|
|
value: theme.spacing
|
|
|
|
when: mainPane.small
|
|
|
|
}
|
|
|
|
|
|
|
|
Binding on bottomPadding {
|
|
|
|
value: theme.spacing
|
|
|
|
when: mainPane.small
|
|
|
|
}
|
2020-02-13 21:58:13 +11:00
|
|
|
|
2020-03-13 13:16:33 +11:00
|
|
|
HRowLayout {
|
|
|
|
HButton {
|
|
|
|
id: addChat
|
|
|
|
iconItem.small: true
|
|
|
|
icon.name: "add-chat"
|
|
|
|
backgroundColor: "transparent"
|
|
|
|
toolTip.text: qsTr("Add new chat")
|
|
|
|
onClicked: pageLoader.showPage(
|
|
|
|
"AddChat/AddChat", {userId: model.id},
|
|
|
|
)
|
2019-11-07 21:44:53 +11:00
|
|
|
|
2020-03-13 13:16:33 +11:00
|
|
|
leftPadding: theme.spacing / 2
|
|
|
|
rightPadding: leftPadding
|
2019-11-07 21:44:53 +11:00
|
|
|
|
2020-03-13 13:16:33 +11:00
|
|
|
opacity: expand.loading ? 0 : 1
|
|
|
|
visible: opacity > 0 && Layout.maximumWidth > 0
|
2019-11-07 21:44:53 +11:00
|
|
|
|
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-03-13 13:16:33 +11:00
|
|
|
Behavior on Layout.maximumWidth { HNumberAnimation {} }
|
|
|
|
Behavior on opacity { HNumberAnimation {} }
|
|
|
|
}
|
2019-11-07 21:44:53 +11:00
|
|
|
|
2020-03-13 13:16:33 +11:00
|
|
|
HButton {
|
|
|
|
id: expand
|
|
|
|
loading:
|
|
|
|
! model.first_sync_done || model.profile_updated < new Date(1)
|
|
|
|
iconItem.small: true
|
|
|
|
icon.name: "expand"
|
|
|
|
backgroundColor: "transparent"
|
|
|
|
toolTip.text: collapsed ? qsTr("Expand") : qsTr("Collapse")
|
|
|
|
onClicked: account.toggleCollapse()
|
2019-08-21 18:39:07 +10:00
|
|
|
|
2020-03-13 13:16:33 +11:00
|
|
|
leftPadding: theme.spacing / 2
|
|
|
|
rightPadding: theme.spacing
|
2019-11-07 21:44:53 +11:00
|
|
|
|
2020-03-13 13:16:33 +11:00
|
|
|
opacity: ! loading && mainPane.filter ? 0 : 1
|
|
|
|
visible: opacity > 0 && Layout.maximumWidth > 0
|
2019-08-21 18:39:07 +10:00
|
|
|
|
2020-03-13 13:16:33 +11:00
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.maximumWidth:
|
|
|
|
account.width >= 120 * theme.uiScale ? implicitWidth : 0
|
2019-12-22 05:25:17 +11:00
|
|
|
|
2019-11-07 21:44:53 +11:00
|
|
|
|
2020-03-13 13:16:33 +11:00
|
|
|
iconItem.transform: Rotation {
|
|
|
|
origin.x: expand.iconItem.width / 2
|
|
|
|
origin.y: expand.iconItem.height / 2
|
|
|
|
angle: expand.loading ? 0 : collapsed ? 180 : 90
|
2019-08-21 18:39:07 +10:00
|
|
|
|
2020-03-13 13:16:33 +11:00
|
|
|
Behavior on angle { HNumberAnimation {} }
|
|
|
|
}
|
2019-08-18 17:27:00 +10:00
|
|
|
|
2020-03-13 13:16:33 +11:00
|
|
|
Behavior on Layout.maximumWidth { HNumberAnimation {} }
|
|
|
|
Behavior on opacity { HNumberAnimation {} }
|
|
|
|
}
|
2019-08-18 17:27:00 +10:00
|
|
|
}
|
|
|
|
}
|