// 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 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 } } } }