2019-08-18 17:27:00 +10:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
import "../Base"
|
|
|
|
|
|
|
|
HInteractiveRectangle {
|
|
|
|
id: accountDelegate
|
|
|
|
color: theme.sidePane.account.background
|
2019-08-20 03:09:05 +10:00
|
|
|
// checked: isCurrent
|
2019-08-20 00:28:49 +10:00
|
|
|
height: row.height
|
|
|
|
|
2019-08-18 17:27:00 +10:00
|
|
|
|
2019-08-20 04:28:12 +10:00
|
|
|
readonly property var delegateModel: model
|
|
|
|
|
2019-08-18 17:27:00 +10:00
|
|
|
readonly property bool isCurrent:
|
|
|
|
window.uiState.page == "Pages/EditAccount/EditAccount.qml" &&
|
|
|
|
window.uiState.pageProperties.userId == model.data.user_id
|
|
|
|
|
2019-08-20 00:28:49 +10:00
|
|
|
readonly property bool forceExpand:
|
|
|
|
Boolean(accountRoomList.filter)
|
|
|
|
|
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-20 03:09:05 +10:00
|
|
|
onIsCurrentChanged: if (isCurrent) beHighlighted()
|
|
|
|
|
|
|
|
|
|
|
|
function beHighlighted() {
|
|
|
|
accountRoomList.currentIndex = model.index
|
|
|
|
}
|
|
|
|
|
2019-08-18 17:27:00 +10:00
|
|
|
function toggleCollapse() {
|
|
|
|
window.uiState.collapseAccounts[model.data.user_id] = ! collapsed
|
|
|
|
window.uiStateChanged()
|
|
|
|
}
|
|
|
|
|
|
|
|
function activate() {
|
2019-08-20 05:37:48 +10:00
|
|
|
pageLoader.showPage(
|
2019-08-18 17:27:00 +10:00
|
|
|
"EditAccount/EditAccount", { "userId": model.data.user_id }
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2019-08-20 00:28:49 +10:00
|
|
|
|
2019-08-20 03:09:05 +10:00
|
|
|
// Component.onCompleted won't work for this
|
|
|
|
Timer {
|
|
|
|
interval: 100
|
|
|
|
repeat: true
|
|
|
|
running: accountRoomList.currentIndex == -1
|
|
|
|
onTriggered: if (isCurrent) beHighlighted()
|
|
|
|
}
|
|
|
|
|
2019-08-21 04:29:03 +10:00
|
|
|
Connections {
|
|
|
|
target: accountRoomList
|
|
|
|
onHideHoverHighlight: accountDelegate.hovered = false
|
|
|
|
}
|
|
|
|
|
2019-08-20 08:32:43 +10:00
|
|
|
TapHandler {
|
|
|
|
onTapped: {
|
|
|
|
accountRoomList.highlightRangeMode = ListView.NoHighlightRange
|
|
|
|
accountRoomList.highlightMoveDuration = 0
|
|
|
|
activate()
|
|
|
|
accountRoomList.highlightRangeMode = ListView.ApplyRange
|
|
|
|
accountRoomList.highlightMoveDuration = theme.animationDuration
|
|
|
|
}
|
|
|
|
}
|
2019-08-18 17:27:00 +10:00
|
|
|
|
|
|
|
HRowLayout {
|
|
|
|
id: row
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
HUserAvatar {
|
|
|
|
id: avatar
|
|
|
|
userId: model.data.user_id
|
|
|
|
displayName: model.data.display_name
|
|
|
|
avatarUrl: model.data.avatar_url
|
|
|
|
|
2019-08-20 01:42:24 +10:00
|
|
|
opacity: collapsed && ! forceExpand ?
|
|
|
|
theme.sidePane.account.collapsedOpacity : 1
|
2019-08-18 17:27:00 +10:00
|
|
|
Behavior on opacity { HNumberAnimation {} }
|
|
|
|
|
|
|
|
Layout.topMargin: model.index > 0 ? sidePane.currentSpacing / 2 : 0
|
|
|
|
Layout.bottomMargin: Layout.topMargin
|
|
|
|
}
|
|
|
|
|
|
|
|
HLabel {
|
|
|
|
id: accountLabel
|
|
|
|
color: theme.sidePane.account.name
|
|
|
|
text: model.data.display_name || model.data.user_id
|
|
|
|
font.pixelSize: theme.fontSize.big
|
|
|
|
elide: HLabel.ElideRight
|
|
|
|
|
|
|
|
leftPadding: sidePane.currentSpacing
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
|
2019-08-20 01:42:24 +10:00
|
|
|
opacity: collapsed && ! forceExpand ?
|
|
|
|
theme.sidePane.account.collapsedOpacity : 1
|
2019-08-18 17:27:00 +10:00
|
|
|
Behavior on opacity { HNumberAnimation {} }
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
|
|
|
|
|
|
|
HUIButton {
|
|
|
|
id: expandButton
|
|
|
|
iconName: "expand"
|
|
|
|
iconDimension: 16
|
|
|
|
backgroundColor: "transparent"
|
|
|
|
leftPadding: sidePane.currentSpacing
|
|
|
|
rightPadding: leftPadding
|
|
|
|
onClicked: accountDelegate.toggleCollapse()
|
|
|
|
|
|
|
|
visible: opacity > 0
|
|
|
|
opacity:
|
2019-08-20 00:28:49 +10:00
|
|
|
accountDelegate.forceExpand ? 0 :
|
2019-08-18 17:27:00 +10:00
|
|
|
collapsed ? theme.sidePane.account.collapsedOpacity + 0.2 :
|
|
|
|
1
|
|
|
|
Behavior on opacity { HNumberAnimation {} }
|
|
|
|
|
|
|
|
iconTransform: Rotation {
|
|
|
|
origin.x: expandButton.iconDimension / 2
|
|
|
|
origin.y: expandButton.iconDimension / 2
|
|
|
|
|
|
|
|
angle: collapsed ? 180 : 90
|
|
|
|
Behavior on angle { HNumberAnimation {} }
|
|
|
|
}
|
|
|
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|