From 3bf415add058e6ffc17fed09455705f9b9c89bfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Cie=C5=9Blak?= Date: Tue, 15 Oct 2024 10:13:36 +0200 Subject: [PATCH] UserStatusContextMenu refactored to be not dependent on stores --- .../Profile/views/MyProfileView.qml | 2 - ui/app/mainui/AppMain.qml | 13 +++- .../shared/controls/chat/ProfileHeader.qml | 5 +- .../shared/popups/UserStatusContextMenu.qml | 70 +++++++++---------- 4 files changed, 46 insertions(+), 44 deletions(-) diff --git a/ui/app/AppLayouts/Profile/views/MyProfileView.qml b/ui/app/AppLayouts/Profile/views/MyProfileView.qml index eb3d6c4bd5..a2b5eff795 100644 --- a/ui/app/AppLayouts/Profile/views/MyProfileView.qml +++ b/ui/app/AppLayouts/Profile/views/MyProfileView.qml @@ -272,8 +272,6 @@ SettingsContentBase { Layout.leftMargin: Style.current.padding Layout.rightMargin: Style.current.padding - store: root.profileStore - displayName: profileStore.name pubkey: profileStore.pubkey icon: profileStore.profileLargeImage diff --git a/ui/app/mainui/AppMain.qml b/ui/app/mainui/AppMain.qml index 801bceed2f..7a631a49f4 100644 --- a/ui/app/mainui/AppMain.qml +++ b/ui/app/mainui/AppMain.qml @@ -863,9 +863,20 @@ Item { UserStatusContextMenu { id: userStatusContextMenu + y: profileButton.y - userStatusContextMenu.height + profileButton.height x: profileButton.x + profileButton.width + 5 - store: appMain.rootStore + + pubKey: appMain.rootStore.userProfileInst.pubKey + name: appMain.rootStore.userProfileInst.name + icon: appMain.rootStore.userProfileInst.icon + isEnsVerified: !!appMain.rootStore.userProfileInst.preferredName + + currentUserStatus: appMain.rootStore.userProfileInst.currentUserStatus + + onViewProfileRequested: Global.openProfilePopup(pubKey) + onCopyLinkRequested: ClipboardUtils.setText(appMain.rootStore.contactStore.getLinkToProfile(pubKey)) + onSetCurrentUserStatusRequested: appMain.rootStore.setCurrentUserStatus(status) } } diff --git a/ui/imports/shared/controls/chat/ProfileHeader.qml b/ui/imports/shared/controls/chat/ProfileHeader.qml index d0b24cad1f..f0f24d81b8 100644 --- a/ui/imports/shared/controls/chat/ProfileHeader.qml +++ b/ui/imports/shared/controls/chat/ProfileHeader.qml @@ -11,8 +11,6 @@ import StatusQ.Components 0.1 import StatusQ.Popups 0.1 import StatusQ.Core.Utils 0.1 as StatusQUtils -import AppLayouts.Profile.stores 1.0 as ProfileStores - Item { id: root @@ -22,7 +20,6 @@ Item { Big } - property ProfileStores.ProfileStore store property string displayName property string pubkey property string icon @@ -145,7 +142,7 @@ Item { icon.height: d.getSize(8, 12, 24) onClicked: { - if (!!root.store.profileLargeImage) + if (!!root.icon) Global.openMenu(editImageMenuComponent, this) else Global.openChangeProfilePicPopup(tempIcon); diff --git a/ui/imports/shared/popups/UserStatusContextMenu.qml b/ui/imports/shared/popups/UserStatusContextMenu.qml index ffc66de52c..23edd7590f 100644 --- a/ui/imports/shared/popups/UserStatusContextMenu.qml +++ b/ui/imports/shared/popups/UserStatusContextMenu.qml @@ -1,41 +1,41 @@ -import QtQuick 2.12 -import QtQuick.Controls 2.14 -import QtQuick.Layouts 1.3 -import QtQml.Models 2.3 - -import utils 1.0 -import shared.controls.chat 1.0 -import shared.panels 1.0 -import shared.controls.chat.menuItems 1.0 - -import StatusQ 0.1 -import StatusQ.Components 0.1 import StatusQ.Popups 0.1 -import AppLayouts.stores 1.0 +import shared.controls.chat 1.0 +import shared.controls.chat.menuItems 1.0 +import shared.panels 1.0 +import utils 1.0 StatusMenu { id: root - property RootStore store + property string pubKey + property alias name: header.displayName + property alias icon: header.icon + + property alias isEnsVerified: header.userIsEnsVerified + + // Constants.currentUserStatus + property int currentUserStatus + + signal viewProfileRequested + signal copyLinkRequested + signal setCurrentUserStatusRequested(int status) ProfileHeader { - width: parent.width + id: header - displayName: root.store.userProfileInst.name - pubkey: root.store.userProfileInst.pubKey - icon: root.store.userProfileInst.icon - userIsEnsVerified: !!root.store.userProfileInst.preferredName objectName: 'onlineIdentifierProfileHeader' + + width: parent.width + pubkey: root.pubKey } - StatusMenuSeparator { - } + StatusMenuSeparator {} ViewProfileMenuItem { objectName: "userStatusViewMyProfileAction" onTriggered: { - Global.openProfilePopup(root.store.userProfileInst.pubKey) + root.viewProfileRequested() root.close() } } @@ -45,54 +45,50 @@ StatusMenu { text: qsTr("Copy link to profile") icon.name: "copy" onTriggered: { - ClipboardUtils.setText(root.store.contactStore.getLinkToProfile(root.store.userProfileInst.pubKey)) + root.copyLinkRequested() root.close() } } - StatusMenuSeparator { - } + StatusMenuSeparator {} StatusAction { - id: alwaysOnlineAction objectName: "userStatusMenuAlwaysOnlineAction" text: qsTr("Always online") assetSettings.name: "statuses/online" assetSettings.width: 12 assetSettings.height: 12 assetSettings.color: "transparent" - fontSettings.bold: root.store.userProfileInst.currentUserStatus === Constants.currentUserStatus.alwaysOnline + fontSettings.bold: root.currentUserStatus === Constants.currentUserStatus.alwaysOnline onTriggered: { - store.setCurrentUserStatus(Constants.currentUserStatus.alwaysOnline) - root.close(); + root.setCurrentUserStatusRequested(Constants.currentUserStatus.alwaysOnline) + root.close() } } StatusAction { - id: inactiveAction objectName: "userStatusMenuInactiveAction" text: qsTr("Inactive") assetSettings.name: "statuses/inactive" assetSettings.width: 12 assetSettings.height: 12 assetSettings.color: "transparent" - fontSettings.bold: root.store.userProfileInst.currentUserStatus === Constants.currentUserStatus.inactive + fontSettings.bold: root.currentUserStatus === Constants.currentUserStatus.inactive onTriggered: { - store.setCurrentUserStatus(Constants.currentUserStatus.inactive) - root.close(); + root.setCurrentUserStatusRequested(Constants.currentUserStatus.inactive) + root.close() } } StatusAction { - id: automaticAction objectName: "userStatusMenuAutomaticAction" text: qsTr("Set status automatically") assetSettings.name: "statuses/automatic" assetSettings.color: "transparent" - fontSettings.bold: root.store.userProfileInst.currentUserStatus === Constants.currentUserStatus.automatic + fontSettings.bold: root.currentUserStatus === Constants.currentUserStatus.automatic onTriggered: { - store.setCurrentUserStatus(Constants.currentUserStatus.automatic) - root.close(); + root.setCurrentUserStatusRequested(Constants.currentUserStatus.automatic) + root.close() } } }