moment/src/qml/SidePane/AccountDelegate.qml

105 lines
2.9 KiB
QML
Raw Normal View History

2019-07-08 13:52:41 +10:00
// Copyright 2019 miruka
// This file is part of harmonyqml, licensed under LGPLv3.
2019-07-13 19:34:58 +10:00
import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../Base"
2019-03-22 14:28:14 +11:00
Column {
id: accountDelegate
width: parent.width
spacing: theme.spacing / 2
2019-03-22 14:28:14 +11:00
2019-07-08 12:41:32 +10:00
property var userInfo: users.find(model.userId)
property bool expanded: true
Component.onCompleted:
2019-07-21 23:26:47 +10:00
expanded = ! window.uiState.collapseAccounts[model.userId]
onExpandedChanged: {
window.uiState.collapseAccounts[model.userId] = ! expanded
window.uiStateChanged()
}
HInteractiveRectangle {
width: parent.width
height: childrenRect.height
color: theme.sidePane.account.background
2019-03-26 09:29:46 +11:00
TapHandler {
onTapped: pageStack.showPage(
"EditAccount/EditAccount", { "userId": model.userId }
)
}
2019-07-13 07:06:37 +10:00
HRowLayout {
id: row
width: parent.width
2019-03-26 09:29:46 +11:00
2019-07-13 07:06:37 +10:00
HUserAvatar {
id: avatar
// Need to do this because conflict with the model property
Component.onCompleted: userId = model.userId
2019-03-26 09:29:46 +11:00
}
2019-07-13 07:06:37 +10:00
HColumnLayout {
Layout.fillWidth: true
2019-07-13 07:06:37 +10:00
Layout.fillHeight: true
2019-07-13 07:06:37 +10:00
HLabel {
id: accountLabel
color: theme.sidePane.account.name
2019-07-13 07:06:37 +10:00
text: userInfo.displayName || model.userId
font.pixelSize: theme.fontSize.big
elide: HLabel.ElideRight
2019-07-13 07:06:37 +10:00
leftPadding: sidePane.currentSpacing
rightPadding: leftPadding
Layout.fillWidth: true
2019-07-13 07:06:37 +10:00
}
HTextField {
visible: false // TODO
2019-07-13 07:06:37 +10:00
id: statusEdit
// text: userInfo.statusMessage
2019-07-13 07:06:37 +10:00
placeholderText: qsTr("Set status message")
font.pixelSize: theme.fontSize.small
background: null
bordered: false
2019-07-13 07:06:37 +10:00
padding: 0
leftPadding: accountLabel.leftPadding
rightPadding: leftPadding
Layout.fillWidth: true
onEditingFinished: {
//Backend.setStatusMessage(model.userId, text) TODO
pageStack.forceActiveFocus()
}
}
}
2019-03-26 09:29:46 +11:00
2019-07-13 07:06:37 +10:00
ExpandButton {
id: expandButton
expandableItem: accountDelegate
Layout.preferredHeight: row.height
}
2019-03-22 14:28:14 +11:00
}
}
RoomCategoriesList {
id: roomCategoriesList
visible: height > 0
width: parent.width
height: childrenRect.height * (accountDelegate.expanded ? 1 : 0)
clip: heightAnimation.running
userId: userInfo.userId
Behavior on height {
HNumberAnimation { id: heightAnimation }
}
}
2019-03-22 14:28:14 +11:00
}