moment/src/qml/MainPane/AccountDelegate.qml

124 lines
3.4 KiB
QML
Raw Normal View History

import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../Base"
import "../utils.js" as Utils
HTileDelegate {
id: accountDelegate
spacing: 0
topPadding: model.index > 0 ? theme.spacing / 2 : 0
bottomPadding: topPadding
2019-12-11 06:17:41 +11:00
backgroundColor: theme.mainPane.account.background
opacity: collapsed && ! forceExpand ?
2019-12-11 06:17:41 +11:00
theme.mainPane.account.collapsedOpacity : 1
shouldBeCurrent:
2019-12-10 02:35:50 +11:00
window.uiState.page === "Pages/AccountSettings/AccountSettings.qml" &&
window.uiState.pageProperties.userId === model.data.user_id
setCurrentTimer.running:
2019-12-11 06:17:41 +11:00
! mainPaneList.activateLimiter.running && ! mainPane.hasFocus
2019-12-16 19:42:41 +11:00
Behavior on opacity { HNumberAnimation {} }
2019-12-11 06:17:41 +11:00
readonly property bool forceExpand: Boolean(mainPaneList.filter)
// Hide harmless error when a filter matches nothing
readonly property bool collapsed: try {
2019-12-11 06:17:41 +11:00
return mainPaneList.collapseAccounts[model.data.user_id] || false
} catch (err) {}
2019-12-16 19:10:23 +11:00
onActivated: pageLoader.showPage(
"AccountSettings/AccountSettings", { "userId": model.data.user_id }
)
function toggleCollapse() {
window.uiState.collapseAccounts[model.data.user_id] = ! collapsed
window.uiStateChanged()
}
image: HUserAvatar {
userId: model.data.user_id
displayName: model.data.display_name
mxc: model.data.avatar_url
}
2019-12-11 06:17:41 +11:00
title.color: theme.mainPane.account.name
title.text: model.data.display_name || model.data.user_id
title.font.pixelSize: theme.fontSize.big
title.leftPadding: theme.spacing
2019-11-07 21:44:53 +11:00
HButton {
id: addChat
2019-12-05 00:08:38 +11:00
iconItem.small: true
2019-11-10 02:10:00 +11:00
icon.name: "add-chat"
2019-11-07 21:44:53 +11:00
backgroundColor: "transparent"
toolTip.text: qsTr("Add new chat")
onClicked: pageLoader.showPage(
"AddChat/AddChat", {userId: model.data.user_id},
)
2019-11-07 21:44:53 +11:00
leftPadding: theme.spacing / 2
rightPadding: leftPadding
visible: opacity > 0
opacity: expand.loading ? 0 : 1
Layout.fillHeight: true
2019-12-16 19:42:41 +11:00
Behavior on opacity { HNumberAnimation {} }
2019-11-07 21:44:53 +11:00
}
HButton {
id: expand
2019-08-28 05:00:50 +10:00
loading: ! model.data.first_sync_done || ! model.data.profile_updated
2019-12-05 00:08:38 +11:00
iconItem.small: true
icon.name: "expand"
backgroundColor: "transparent"
toolTip.text: collapsed ? qsTr("Expand") : qsTr("Collapse")
onClicked: accountDelegate.toggleCollapse()
2019-11-07 21:44:53 +11:00
leftPadding: theme.spacing / 2
rightPadding: leftPadding
visible: opacity > 0
2019-08-28 05:00:50 +10:00
opacity: ! loading && accountDelegate.forceExpand ? 0 : 1
2019-11-07 21:44:53 +11:00
Layout.fillHeight: true
iconItem.transform: Rotation {
2019-11-07 21:44:53 +11:00
origin.x: expand.iconItem.width / 2
origin.y: expand.iconItem.height / 2
2019-08-28 05:00:50 +10:00
angle: expand.loading ? 0 : collapsed ? 180 : 90
Behavior on angle { HNumberAnimation {} }
}
2019-12-16 19:42:41 +11:00
Behavior on opacity { HNumberAnimation {} }
}
contextMenu: HMenu {
2019-12-12 23:32:50 +11:00
HMenuItem {
icon.name: "copy-user-id"
text: qsTr("Copy user ID")
onTriggered: Clipboard.text = model.data.user_id
}
HMenuItem {
icon.name: "sign-out"
2019-08-29 08:21:13 +10:00
icon.color: theme.colors.negativeBackground
text: qsTr("Sign out")
onTriggered: Utils.makePopup(
"Popups/SignOutPopup.qml",
window,
{ "userId": model.data.user_id },
)
}
}
}