diff --git a/src/app/profile/views/ens_manager.nim b/src/app/profile/views/ens_manager.nim index deae7cc829..e085d4d477 100644 --- a/src/app/profile/views/ens_manager.nim +++ b/src/app/profile/views/ens_manager.nim @@ -93,6 +93,17 @@ QtObject: result.pendingUsernames = initHashSet[string]() result.setup + proc getFirstEnsUsername(self: EnsManager): string {.slot.} = + if self.usernames.len > 0: + return self.usernames[0] + return "" + + proc firstEnsUsernameChanged(self: EnsManager) {.signal.} + + QtProperty[string] firstEnsUsername: + read = getFirstEnsUsername + notify = firstEnsUsernameChanged + proc init*(self: EnsManager) = self.usernames = getSetting[seq[string]](self.status.settings, Setting.Usernames, @[]) @@ -106,6 +117,8 @@ QtObject: self.usernames.add trx["additionalData"].getStr self.pendingUsernames.incl trx["additionalData"].getStr + self.firstEnsUsernameChanged() + proc ensWasResolved*(self: EnsManager, ensResult: string) {.signal.} diff --git a/ui/app/AppLayouts/Profile/Sections/MyProfileContainer.qml b/ui/app/AppLayouts/Profile/Sections/MyProfileContainer.qml index 6441609409..a2dbc14a50 100644 --- a/ui/app/AppLayouts/Profile/Sections/MyProfileContainer.qml +++ b/ui/app/AppLayouts/Profile/Sections/MyProfileContainer.qml @@ -5,8 +5,12 @@ import "../../../../imports" import "../../../../shared" import "../../../../shared/status" +import StatusQ.Core.Theme 0.1 +import StatusQ.Components 0.1 + Item { - property string ensName: profileModel.ens.preferredUsername || "" + property string ensName: profileModel.ens.preferredUsername || + profileModel.ens.firstEnsUsername || "" property string username: profileModel.profile.username property string pubkey: profileModel.profile.pubKey @@ -132,22 +136,47 @@ Item { Column { anchors.right: profileImgNameContainer.right anchors.left: profileImgNameContainer.left - spacing: Style.current.bigPadding anchors.top: profileImgNameContainer.bottom - anchors.topMargin: Style.current.smallPadding + anchors.topMargin: 16 - TextWithLabel { - //% "Chat key" - label: qsTrId("chat-key") - text: pubkey.substring(0, 13) + "..." + pubkey.substring(pubkey.length - 13) - textToCopy: pubkey + StatusDescriptionListItem { + title: qsTr("ENS username") + subTitle: ensName + tooltip.text: qsTr("Copy to clipboard") + icon.name: "copy" + visible: !!ensName + iconButton.onClicked: { + chatsModel.copyToClipboard(ensName) + tooltip.visible = !tooltip.visible + } + width: parent.width } - TextWithLabel { - //% "Share Profile URL" - label: qsTrId("share-profile-url") - text: `${Constants.userLinkPrefix}${ensName !== "" ? ensName : (pubkey.substring(0, 5) + "..." + pubkey.substring(pubkey.length - 5))}` - textToCopy: Constants.userLinkPrefix + (ensName !== "" ? ensName : pubkey) + StatusDescriptionListItem { + title: qsTr("Chat key") + subTitle: pubkey + subTitleComponent.elide: Text.ElideMiddle + subTitleComponent.width: 320 + subTitleComponent.font.family: Theme.palette.monoFont.name + tooltip.text: qsTr("Copy to clipboard") + icon.name: "copy" + iconButton.onClicked: { + chatsModel.copyToClipboard(pubkey) + tooltip.visible = !tooltip.visible + } + width: parent.width + } + + StatusDescriptionListItem { + title: qsTr("Share Profile URL") + subTitle: `${Constants.userLinkPrefix}${ensName !== "" ? ensName : (pubkey.substring(0, 5) + "..." + pubkey.substring(pubkey.length - 5))}` + tooltip.text: qsTr("Copy to clipboard") + icon.name: "copy" + iconButton.onClicked: { + chatsModel.copyToClipboard(Constants.userLinkPrefix + (ensName !== "" ? ensName : pubkey)) + tooltip.visible = !tooltip.visible + } + width: parent.width } } }