diff --git a/src/qml/Base/HTile.qml b/src/qml/Base/HTile.qml index d245a514..763af8d0 100644 --- a/src/qml/Base/HTile.qml +++ b/src/qml/Base/HTile.qml @@ -1,5 +1,6 @@ import QtQuick 2.12 import QtQuick.Layouts 1.12 +import "../utils.js" as Utils HButton { id: tile @@ -7,7 +8,7 @@ HButton { signal leftClicked() signal rightClicked() - default property var additionalItems: [] + default property alias additionalData: contentItem.data readonly property alias title: title readonly property alias additionalInfo: additionalInfo @@ -16,62 +17,71 @@ HButton { property HMenu contextMenu: HMenu {} - property Item image - - property Item details: HColumnLayout { - Layout.fillWidth: true - - HRowLayout { - spacing: tile.spacing - - HLabel { - id: title - text: "Missing title" - elide: Text.ElideRight - verticalAlignment: Qt.AlignVCenter - - Layout.fillWidth: true - } - - HRowLayout { - id: additionalInfo - visible: visibleChildren.length > 0 - } - - HLabel { - id: rightInfo - font.pixelSize: theme.fontSize.small - color: theme.colors.halfDimText - - visible: Layout.maximumWidth > 0 - Layout.maximumWidth: - text && tile.width >= 160 ? implicitWidth : 0 - - Behavior on Layout.maximumWidth { HNumberAnimation {} } - } - } - - HRichLabel { - id: subtitle - textFormat: Text.StyledText - font.pixelSize: theme.fontSize.small - elide: Text.ElideRight - color: theme.colors.dimText - - visible: Layout.maximumHeight > 0 - Layout.maximumHeight: text ? implicitWidth : 0 - Layout.fillWidth: true - - Behavior on Layout.maximumHeight { HNumberAnimation {} } - } - } + property Component image contentItem: HRowLayout { + id: contentItem spacing: tile.spacing - children: [image, details].concat(additionalItems) + + HLoader { + sourceComponent: image + } + + HColumnLayout { + Layout.fillWidth: true + + HRowLayout { + spacing: tile.spacing + + HLabel { + id: title + text: "Missing title" + elide: Text.ElideRight + verticalAlignment: Qt.AlignVCenter + + Layout.fillWidth: true + } + + HRowLayout { + id: additionalInfo + visible: visibleChildren.length > 0 + } + + HLabel { + id: rightInfo + font.pixelSize: theme.fontSize.small + color: theme.colors.halfDimText + + visible: Layout.maximumWidth > 0 + Layout.maximumWidth: + text && tile.width >= 160 ? implicitWidth : 0 + + Behavior on Layout.maximumWidth { HNumberAnimation {} } + } + } + + HRichLabel { + id: subtitle + textFormat: Text.StyledText + font.pixelSize: theme.fontSize.small + elide: Text.ElideRight + color: theme.colors.dimText + + visible: Layout.maximumHeight > 0 + Layout.maximumHeight: text ? implicitWidth : 0 + Layout.fillWidth: true + + Behavior on Layout.maximumHeight { HNumberAnimation {} } + } + } } + + // Binding { target: details; property: "parent"; value: contentItem } + // Binding { target: image; property: "parent"; value: contentItem } + + TapHandler { acceptedButtons: Qt.LeftButton onTapped: leftClicked() diff --git a/src/qml/Chat/RoomSidePane/MemberDelegate.qml b/src/qml/Chat/RoomSidePane/MemberDelegate.qml index 7d33ac85..a548deb0 100644 --- a/src/qml/Chat/RoomSidePane/MemberDelegate.qml +++ b/src/qml/Chat/RoomSidePane/MemberDelegate.qml @@ -11,8 +11,6 @@ HTileDelegate { userId: model.user_id displayName: model.display_name mxc: model.avatar_url - width: height - height: memberDelegate.height } title.text: model.display_name || model.user_id diff --git a/src/qml/SidePane/AccountDelegate.qml b/src/qml/SidePane/AccountDelegate.qml index 7aa7f617..27f7e6a7 100644 --- a/src/qml/SidePane/AccountDelegate.qml +++ b/src/qml/SidePane/AccountDelegate.qml @@ -57,22 +57,45 @@ HTileDelegate { title.font.pixelSize: theme.fontSize.big title.leftPadding: sidePane.currentSpacing + HButton { + id: addChat + iconItem.dimension: 16 + icon.name: "add-account" // TODO + backgroundColor: "transparent" + toolTip.text: qsTr("Add new chat") + // onClicked: accountDelegate.toggleCollapse() + + leftPadding: theme.spacing / 2 + rightPadding: leftPadding + + visible: opacity > 0 + opacity: expand.loading ? 0 : 1 + + Layout.fillHeight: true + + Behavior on opacity { HNumberAnimation {} } + } + HButton { id: expand loading: ! model.data.first_sync_done || ! model.data.profile_updated + iconItem.dimension: 16 icon.name: "expand" backgroundColor: "transparent" - padding: sidePane.currentSpacing / 1.5 - rightPadding: leftPadding toolTip.text: collapsed ? qsTr("Expand") : qsTr("Collapse") onClicked: accountDelegate.toggleCollapse() + leftPadding: theme.spacing / 2 + rightPadding: leftPadding + visible: opacity > 0 opacity: ! loading && accountDelegate.forceExpand ? 0 : 1 + Layout.fillHeight: true + iconItem.transform: Rotation { - origin.x: expand.iconItem.dimension / 2 - origin.y: expand.iconItem.dimension / 2 + origin.x: expand.iconItem.width / 2 + origin.y: expand.iconItem.height / 2 angle: expand.loading ? 0 : collapsed ? 180 : 90 Behavior on angle { HNumberAnimation {} }