2019-08-18 17:27:00 +10:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
import "../Base"
|
|
|
|
|
2019-08-21 18:39:07 +10:00
|
|
|
HTileDelegate {
|
2019-08-18 17:27:00 +10:00
|
|
|
id: accountDelegate
|
2019-08-21 18:39:07 +10:00
|
|
|
spacing: 0
|
|
|
|
topPadding: model.index > 0 ? sidePane.currentSpacing / 2 : 0
|
|
|
|
bottomPadding: topPadding
|
|
|
|
backgroundColor: theme.sidePane.account.background
|
|
|
|
opacity: collapsed && ! forceExpand ?
|
|
|
|
theme.sidePane.account.collapsedOpacity : 1
|
2019-08-18 17:27:00 +10:00
|
|
|
|
2019-08-21 20:02:00 +10:00
|
|
|
shouldBeCurrent:
|
|
|
|
window.uiState.page == "Pages/EditAccount/EditAccount.qml" &&
|
|
|
|
window.uiState.pageProperties.userId == model.data.user_id
|
2019-08-20 04:28:12 +10:00
|
|
|
|
2019-08-24 00:53:54 +10:00
|
|
|
setCurrentTimer.running: ! accountRoomList.activateLimiter.running
|
|
|
|
|
2019-08-18 17:27:00 +10:00
|
|
|
|
2019-08-21 18:39:07 +10:00
|
|
|
Behavior on opacity { HNumberAnimation {} }
|
|
|
|
|
|
|
|
|
2019-08-22 07:45:05 +10:00
|
|
|
property bool disconnecting: false
|
2019-08-21 18:39:07 +10:00
|
|
|
readonly property bool forceExpand: Boolean(accountRoomList.filter)
|
2019-08-20 00:28:49 +10:00
|
|
|
|
2019-08-20 04:06:11 +10:00
|
|
|
// Hide harmless error when a filter matches nothing
|
|
|
|
readonly property bool collapsed: try {
|
|
|
|
return accountRoomList.collapseAccounts[model.data.user_id] || false
|
|
|
|
} catch (err) {}
|
2019-08-20 00:28:49 +10:00
|
|
|
|
2019-08-18 17:27:00 +10:00
|
|
|
|
2019-08-22 07:45:05 +10:00
|
|
|
onActivated: if (! disconnecting) {
|
|
|
|
pageLoader.showPage(
|
|
|
|
"EditAccount/EditAccount", { "userId": model.data.user_id }
|
|
|
|
)
|
|
|
|
}
|
2019-08-20 03:09:05 +10:00
|
|
|
|
|
|
|
|
2019-08-18 17:27:00 +10:00
|
|
|
function toggleCollapse() {
|
|
|
|
window.uiState.collapseAccounts[model.data.user_id] = ! collapsed
|
|
|
|
window.uiStateChanged()
|
|
|
|
}
|
|
|
|
|
2019-08-20 03:09:05 +10:00
|
|
|
|
2019-08-21 18:39:07 +10:00
|
|
|
image: HUserAvatar {
|
|
|
|
userId: model.data.user_id
|
|
|
|
displayName: model.data.display_name
|
|
|
|
avatarUrl: model.data.avatar_url
|
2019-08-21 04:29:03 +10:00
|
|
|
}
|
|
|
|
|
2019-08-21 18:39:07 +10:00
|
|
|
title.color: theme.sidePane.account.name
|
|
|
|
title.text: model.data.display_name || model.data.user_id
|
|
|
|
title.font.pixelSize: theme.fontSize.big
|
|
|
|
title.leftPadding: sidePane.currentSpacing
|
|
|
|
|
|
|
|
HButton {
|
|
|
|
id: expand
|
2019-08-28 05:00:50 +10:00
|
|
|
loading: ! model.data.first_sync_done || ! model.data.profile_updated
|
2019-08-22 05:45:13 +10:00
|
|
|
icon.name: "expand"
|
2019-08-21 18:39:07 +10:00
|
|
|
backgroundColor: "transparent"
|
2019-08-21 20:02:00 +10:00
|
|
|
padding: sidePane.currentSpacing / 1.5
|
2019-08-21 18:39:07 +10:00
|
|
|
rightPadding: leftPadding
|
2019-08-22 23:27:26 +10:00
|
|
|
toolTip.text: collapsed ? qsTr("Expand") : qsTr("Collapse")
|
2019-08-21 18:39:07 +10:00
|
|
|
onClicked: accountDelegate.toggleCollapse()
|
|
|
|
|
|
|
|
visible: opacity > 0
|
2019-08-28 05:00:50 +10:00
|
|
|
opacity: ! loading && accountDelegate.forceExpand ? 0 : 1
|
2019-08-21 18:39:07 +10:00
|
|
|
|
2019-08-22 05:45:13 +10:00
|
|
|
iconItem.transform: Rotation {
|
|
|
|
origin.x: expand.iconItem.dimension / 2
|
|
|
|
origin.y: expand.iconItem.dimension / 2
|
2019-08-28 05:00:50 +10:00
|
|
|
angle: expand.loading ? 0 : collapsed ? 180 : 90
|
2019-08-21 18:39:07 +10:00
|
|
|
|
|
|
|
Behavior on angle { HNumberAnimation {} }
|
2019-08-20 08:32:43 +10:00
|
|
|
}
|
2019-08-18 17:27:00 +10:00
|
|
|
|
2019-08-21 18:39:07 +10:00
|
|
|
Behavior on opacity { HNumberAnimation {} }
|
2019-08-18 17:27:00 +10:00
|
|
|
}
|
2019-08-22 07:45:05 +10:00
|
|
|
|
|
|
|
contextMenu: HMenu {
|
|
|
|
HMenuItem {
|
|
|
|
icon.name: "logout"
|
|
|
|
text: qsTr("Logout")
|
|
|
|
onTriggered: {
|
|
|
|
disconnecting = true
|
|
|
|
|
|
|
|
let page = window.uiState.page
|
|
|
|
let userId = model.data.user_id
|
|
|
|
|
|
|
|
if ((modelSources["Account"] || []).length < 2) {
|
|
|
|
pageLoader.showPage("SignIn")
|
|
|
|
}
|
|
|
|
else if ((page == "Pages/EditAccount/EditAccount.qml" ||
|
|
|
|
page == "Chat/Chat.qml") &&
|
|
|
|
window.uiState.pageProperties.userId == userId)
|
|
|
|
{
|
|
|
|
pageLoader.showPage("Default")
|
|
|
|
}
|
|
|
|
|
|
|
|
py.callCoro("logout_client", [userId])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-08-18 17:27:00 +10:00
|
|
|
}
|