From 11c8af7c1963be0576c7c5d7c1c59c6b9a14b543 Mon Sep 17 00:00:00 2001 From: miruka Date: Thu, 7 Nov 2019 11:08:47 -0400 Subject: [PATCH] Show the creator or future room's avatar --- src/qml/Pages/AddChat/AddChat.qml | 7 ++++++- src/qml/Pages/AddChat/CreateRoom.qml | 28 ++++++++++++++++++++++++++++ src/qml/SidePane/AccountDelegate.qml | 4 +++- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/qml/Pages/AddChat/AddChat.qml b/src/qml/Pages/AddChat/AddChat.qml index 451c6807..925ee38d 100644 --- a/src/qml/Pages/AddChat/AddChat.qml +++ b/src/qml/Pages/AddChat/AddChat.qml @@ -4,13 +4,18 @@ import QtQuick.Layouts 1.12 import "../../Base" HPage { + id: addChatPage onFocusChanged: createRoom.forceActiveFocus() + + property string userId + + HColumnLayout { Layout.alignment: Qt.AlignCenter Layout.minimumWidth: Layout.maximumWidth Layout.maximumWidth: - Math.max(tabBar.implicitWidth, swipeView.contentWidth) + Math.max(tabBar.contentWidth, swipeView.contentWidth) TabBar { id: tabBar diff --git a/src/qml/Pages/AddChat/CreateRoom.qml b/src/qml/Pages/AddChat/CreateRoom.qml index c79b3763..86e3eef3 100644 --- a/src/qml/Pages/AddChat/CreateRoom.qml +++ b/src/qml/Pages/AddChat/CreateRoom.qml @@ -1,6 +1,7 @@ import QtQuick 2.12 import QtQuick.Layouts 1.12 import "../../Base" +import "../../utils.js" as Utils HBox { id: addChatBox @@ -16,6 +17,33 @@ HBox { buttonCallbacks: ({ }) + HRoomAvatar { + // TODO: click to change the avatar + id: avatar + clientUserId: addChatPage.userId + displayName: nameField.text + + Layout.alignment: Qt.AlignCenter + Layout.preferredWidth: 128 + Layout.preferredHeight: Layout.preferredWidth + + HUserAvatar { + anchors.fill: parent + z: 10 + opacity: nameField.text ? 0 : 1 + visible: opacity > 0 + clientUserId: parent.clientUserId + userId: clientUserId + displayName: account ? account.display_name : "" + mxc: account ? account.avatar_url : "" + + readonly property var account: + Utils.getItem(modelSources["Account"] || [], "user_id", userId) + + Behavior on opacity { HNumberAnimation {} } + } + } + HTextField { id: nameField placeholderText: qsTr("Name") diff --git a/src/qml/SidePane/AccountDelegate.qml b/src/qml/SidePane/AccountDelegate.qml index 744ea0d6..a8504161 100644 --- a/src/qml/SidePane/AccountDelegate.qml +++ b/src/qml/SidePane/AccountDelegate.qml @@ -63,7 +63,9 @@ HTileDelegate { icon.name: "add-account" // TODO backgroundColor: "transparent" toolTip.text: qsTr("Add new chat") - onClicked: pageLoader.showPage("AddChat/AddChat") + onClicked: pageLoader.showPage( + "AddChat/AddChat", {userId: model.data.user_id}, + ) leftPadding: theme.spacing / 2 rightPadding: leftPadding