moment/src/qml/SidePane/RoomCategoryDelegate.qml

72 lines
1.8 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.
import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../Base"
Column {
id: roomCategoryDelegate
width: roomCategoriesList.width
property int normalHeight: childrenRect.height // avoid binding loop
opacity: roomList.model.count > 0 ? 1 : 0
height: normalHeight * opacity
visible: opacity > 0
Behavior on opacity { HNumberAnimation {} }
property string roomListUserId: userId
property bool expanded: true
Component.onCompleted: {
if (! window.uiState.collapseCategories[model.userId]) {
window.uiState.collapseCategories[model.userId] = {}
window.uiStateChanged()
}
expanded = !window.uiState.collapseCategories[model.userId][model.name]
}
onExpandedChanged: {
window.uiState.collapseCategories[model.userId][model.name] = !expanded
window.uiStateChanged()
}
HRowLayout {
width: parent.width
HLabel {
id: roomCategoryLabel
text: model.name
font.weight: Font.DemiBold
elide: Text.ElideRight
2019-07-13 07:06:37 +10:00
Layout.leftMargin: sidePane.currentSpacing
Layout.fillWidth: true
}
ExpandButton {
expandableItem: roomCategoryDelegate
iconDimension: 12
}
}
RoomList {
id: roomList
visible: height > 0
width: roomCategoriesList.width - accountList.Layout.leftMargin
opacity: roomCategoryDelegate.expanded ? 1 : 0
height: childrenRect.height * opacity
clip: listHeightAnimation.running
userId: roomListUserId
category: name
Behavior on opacity {
HNumberAnimation { id: listHeightAnimation }
}
}
}