UserStatusContextMenu refactored to be not dependent on stores

This commit is contained in:
Michał Cieślak 2024-10-15 10:13:36 +02:00 committed by Michał
parent affaf6099f
commit 3bf415add0
4 changed files with 46 additions and 44 deletions

View File

@ -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

View File

@ -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)
}
}

View File

@ -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);

View File

@ -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()
}
}
}