From bd5dd1dd54267ff493403161e7196f5a18356f9b Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Mon, 15 Jul 2024 22:16:51 +0200 Subject: [PATCH] Revamped user info --- src/CMakeLists.txt | 1 + src/qml/AccountDialog.qml | 84 +++++++++++++++++++++++++++++++++++++++ src/qml/RoomListPage.qml | 5 --- src/qml/SpaceDrawer.qml | 16 ++++++++ 4 files changed, 101 insertions(+), 5 deletions(-) create mode 100644 src/qml/AccountDialog.qml diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 77ba048c6..97b771eb0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -282,6 +282,7 @@ ecm_add_qml_module(neochat URI org.kde.neochat GENERATE_PLUGIN_SOURCE qml/ConsentDialog.qml qml/AskDirectChatConfirmation.qml qml/HoverLinkIndicator.qml + qml/AccountDialog.qml DEPENDENCIES QtCore QtQuick diff --git a/src/qml/AccountDialog.qml b/src/qml/AccountDialog.qml new file mode 100644 index 000000000..bef9e21ad --- /dev/null +++ b/src/qml/AccountDialog.qml @@ -0,0 +1,84 @@ +// SPDX-FileCopyrightText: 2019 Black Hat +// SPDX-FileCopyrightText: 2020 Carl Schwan +// SPDX-License-Identifier: GPL-3.0-only + +import QtQuick +import QtQuick.Controls as QQC2 +import QtQuick.Layouts + +import org.kde.kirigami as Kirigami +import org.kde.kirigamiaddons.components as KirigamiComponents +import org.kde.kirigamiaddons.formcard as FormCard +import org.kde.prison + +import org.kde.neochat + +Kirigami.Dialog { + id: root + + property NeoChatConnection connection + + leftPadding: 0 + rightPadding: 0 + topPadding: 0 + bottomPadding: 0 + + standardButtons: Kirigami.Dialog.NoButton + + width: Math.min(QQC2.ApplicationWindow.window.width, Kirigami.Units.gridUnit * 24) + + contentItem: ColumnLayout { + spacing: 0 + + KirigamiComponents.Avatar { + id: avatar + + readonly property string mediaId: root.connection.localUser.avatarMediaId + + Layout.preferredWidth: Kirigami.Units.iconSizes.huge * 2 + Layout.preferredHeight: Kirigami.Units.iconSizes.huge * 2 + Layout.alignment: Qt.AlignHCenter + + name: root.room ? root.room.member(root.user.id).displayName : root.user.displayName + source: mediaId ? root.connection.makeMediaUrl("mxc://" + mediaId) : "" + color: root.room ? root.room.member(root.user.id).color : QmlUtils.getUserColor(root.user.hueF) + } + + QQC2.Label { + Layout.fillWidth: true + font.bold: false + font.weight: Font.DemiBold + font.pixelSize: 32 + + elide: Text.ElideRight + wrapMode: Text.NoWrap + text: root.connection.localUser.displayName + textFormat: Text.PlainText + horizontalAlignment: Text.AlignHCenter + } + + Kirigami.SelectableLabel { + Layout.fillWidth: true + Layout.bottomMargin: Kirigami.Units.largeSpacing + font.pixelSize: 16 + textFormat: TextEdit.PlainText + text: root.connection.localUser.id + horizontalAlignment: Text.AlignHCenter + } + FormCard.FormDelegateSeparator {} + FormCard.FormButtonDelegate { + text: i18n("Edit Account") + } + FormCard.FormButtonDelegate { + text: i18n("Switch Account") + } + FormCard.FormButtonDelegate { + text: i18n("Logout") + } + + } + Component { + id: qrMaximizeComponent + QrCodeMaximizeComponent {} + } +} diff --git a/src/qml/RoomListPage.qml b/src/qml/RoomListPage.qml index 0fbe291af..04a5e73f0 100644 --- a/src/qml/RoomListPage.qml +++ b/src/qml/RoomListPage.qml @@ -227,11 +227,6 @@ Kirigami.Page { } } - footer: Loader { - width: parent.width - sourceComponent: Kirigami.Settings.isMobile ? exploreComponentMobile : userInfoDesktop - } - MouseArea { anchors.top: parent.top anchors.bottom: parent.bottom diff --git a/src/qml/SpaceDrawer.qml b/src/qml/SpaceDrawer.qml index 82b73f601..da869dc17 100644 --- a/src/qml/SpaceDrawer.qml +++ b/src/qml/SpaceDrawer.qml @@ -47,6 +47,22 @@ QQC2.Control { width: scrollView.width spacing: 0 + AvatarTabButton { + readonly property string mediaId: root.connection.localUser.avatarMediaId + + Layout.fillWidth: true + Layout.preferredHeight: width - Kirigami.Units.smallSpacing + Layout.maximumHeight: width - Kirigami.Units.smallSpacing + Layout.topMargin: Kirigami.Units.smallSpacing / 2 + Layout.bottomMargin: Kirigami.Units.smallSpacing / 2 + + text: root.connection.localUser.displayName + source: mediaId ? root.connection.makeMediaUrl("mxc://" + mediaId) : "" + onClicked: Qt.createComponent("org.kde.neochat", "AccountDialog").createObject(root, { + connection: root.connection + }).open() + } + AvatarTabButton { id: notificationsButton