2024-08-27 14:35:52 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
2022-03-09 10:27:32 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
import shared.panels 1.0
|
2022-03-07 22:59:38 +00:00
|
|
|
import shared.controls 1.0
|
2022-03-09 10:27:32 +00:00
|
|
|
|
2024-08-27 14:35:52 +00:00
|
|
|
import StatusQ 0.1
|
2022-06-22 12:16:21 +00:00
|
|
|
import StatusQ.Controls 0.1
|
2022-03-09 10:27:32 +00:00
|
|
|
import StatusQ.Components 0.1
|
2022-08-07 21:05:25 +00:00
|
|
|
import StatusQ.Popups 0.1
|
2022-03-09 10:27:32 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as StatusQUtils
|
2024-10-15 19:26:12 +00:00
|
|
|
import StatusQ.Core.Theme 0.1
|
2022-03-09 10:27:32 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
|
2022-06-22 12:16:21 +00:00
|
|
|
enum ImageSize {
|
|
|
|
Compact,
|
|
|
|
Middle,
|
|
|
|
Big
|
|
|
|
}
|
|
|
|
|
2022-03-09 10:27:32 +00:00
|
|
|
property string displayName
|
2024-11-07 10:43:06 +00:00
|
|
|
property string compressedPubKey
|
2022-03-09 10:27:32 +00:00
|
|
|
property string icon
|
2022-12-01 08:37:46 +00:00
|
|
|
property url previewIcon: icon
|
2022-06-28 18:11:18 +00:00
|
|
|
property int trustStatus
|
2024-02-09 15:52:28 +00:00
|
|
|
property int onlineStatus: Constants.onlineStatus.unknown
|
2022-06-28 18:11:18 +00:00
|
|
|
property bool isContact: false
|
2024-02-07 14:56:45 +00:00
|
|
|
property bool isBlocked
|
2022-07-11 09:38:39 +00:00
|
|
|
property bool isCurrentUser
|
2022-09-22 22:18:15 +00:00
|
|
|
property bool userIsEnsVerified
|
2022-11-30 15:41:25 +00:00
|
|
|
property rect cropRect
|
2024-11-06 20:08:22 +00:00
|
|
|
property var colorHash: []
|
|
|
|
property int colorId
|
2022-03-09 10:27:32 +00:00
|
|
|
|
2022-06-22 12:16:21 +00:00
|
|
|
property int imageSize: ProfileHeader.ImageSize.Compact
|
2022-03-09 10:27:32 +00:00
|
|
|
property bool displayNameVisible: true
|
2022-06-28 18:11:18 +00:00
|
|
|
property bool displayNamePlusIconsVisible: false
|
2022-03-09 10:27:32 +00:00
|
|
|
property bool pubkeyVisible: true
|
2024-10-22 12:39:42 +00:00
|
|
|
property alias emojiHash: emojiHash.emojiHash
|
2022-06-22 12:16:21 +00:00
|
|
|
property bool emojiHashVisible: true
|
|
|
|
property bool editImageButtonVisible: false
|
2022-07-21 11:02:31 +00:00
|
|
|
property bool editButtonVisible: displayNamePlusIconsVisible
|
2023-04-06 07:56:50 +00:00
|
|
|
property bool loading: false
|
2022-07-06 19:07:33 +00:00
|
|
|
readonly property bool compact: root.imageSize === ProfileHeader.ImageSize.Compact
|
2024-01-05 15:34:20 +00:00
|
|
|
property bool isBridgedAccount: false
|
2022-03-09 10:27:32 +00:00
|
|
|
|
|
|
|
signal clicked()
|
2022-06-28 18:11:18 +00:00
|
|
|
signal editClicked()
|
2022-03-09 10:27:32 +00:00
|
|
|
|
2022-12-01 08:37:46 +00:00
|
|
|
Binding on previewIcon {
|
|
|
|
value: icon
|
|
|
|
}
|
|
|
|
|
2023-03-14 02:52:16 +00:00
|
|
|
implicitWidth: contentContainer.implicitWidth
|
2022-03-16 21:20:03 +00:00
|
|
|
implicitHeight: contentContainer.implicitHeight
|
2022-03-09 10:27:32 +00:00
|
|
|
|
2022-06-22 12:16:21 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
function getSize(compact, normal, big) {
|
|
|
|
switch(root.imageSize) {
|
|
|
|
case ProfileHeader.ImageSize.Compact: return compact;
|
|
|
|
case ProfileHeader.ImageSize.Middle: return normal;
|
|
|
|
case ProfileHeader.ImageSize.Big: return big;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-01 08:37:46 +00:00
|
|
|
Item {
|
|
|
|
id: tmpCroppedImageHelper
|
|
|
|
|
|
|
|
visible: false
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: tmpImage
|
|
|
|
mipmap: true
|
2023-04-26 15:33:24 +00:00
|
|
|
cache: false
|
2022-12-01 08:37:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
property var keepGrabResultAlive;
|
|
|
|
|
|
|
|
function setCroppedTmpIcon(source, x, y, width, height) {
|
|
|
|
tmpCroppedImageHelper.width = width
|
|
|
|
tmpCroppedImageHelper.height = height
|
|
|
|
|
|
|
|
tmpImage.x = -x
|
|
|
|
tmpImage.y = -y
|
|
|
|
tmpImage.source = source
|
|
|
|
|
|
|
|
tmpCroppedImageHelper.grabToImage(result => {
|
|
|
|
keepGrabResultAlive = result
|
|
|
|
root.previewIcon = result.url
|
|
|
|
tmpImage.source = ""
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-09 10:27:32 +00:00
|
|
|
ColumnLayout {
|
|
|
|
id: contentContainer
|
|
|
|
|
2022-04-14 08:26:46 +00:00
|
|
|
spacing: root.compact ? 4 : 12
|
|
|
|
|
2022-03-09 10:27:32 +00:00
|
|
|
anchors {
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
2024-10-15 19:26:12 +00:00
|
|
|
leftMargin: Theme.smallPadding
|
|
|
|
rightMargin: Theme.smallPadding
|
2022-03-09 10:27:32 +00:00
|
|
|
}
|
|
|
|
|
2022-06-22 12:16:21 +00:00
|
|
|
Item {
|
2022-03-09 10:27:32 +00:00
|
|
|
Layout.alignment: Qt.AlignHCenter
|
2022-06-22 12:16:21 +00:00
|
|
|
implicitWidth: userImage.width
|
|
|
|
implicitHeight: userImage.height
|
|
|
|
|
|
|
|
UserImage {
|
|
|
|
id: userImage
|
2024-11-06 20:08:22 +00:00
|
|
|
|
2022-08-29 18:03:50 +00:00
|
|
|
objectName: "ProfileHeader_userImage"
|
2022-06-22 12:16:21 +00:00
|
|
|
name: root.displayName
|
2024-11-06 20:08:22 +00:00
|
|
|
colorHash: root.colorHash
|
|
|
|
colorId: root.colorId
|
2022-12-01 08:37:46 +00:00
|
|
|
image: root.previewIcon
|
2022-06-22 12:16:21 +00:00
|
|
|
interactive: false
|
2023-03-06 17:04:30 +00:00
|
|
|
imageWidth: d.getSize(36, 64, 170)
|
2022-06-22 12:16:21 +00:00
|
|
|
imageHeight: imageWidth
|
2022-12-01 10:24:25 +00:00
|
|
|
ensVerified: root.userIsEnsVerified
|
2023-04-06 07:56:50 +00:00
|
|
|
loading: root.loading
|
2024-02-09 15:52:28 +00:00
|
|
|
onlineStatus: root.onlineStatus
|
2024-01-05 15:34:20 +00:00
|
|
|
isBridgedAccount: root.isBridgedAccount
|
2022-06-22 12:16:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusRoundButton {
|
2022-11-08 18:30:50 +00:00
|
|
|
id: editButton
|
2022-06-22 12:16:21 +00:00
|
|
|
visible: root.editImageButtonVisible
|
2023-03-06 17:04:30 +00:00
|
|
|
anchors.top: userImage.top
|
2022-06-22 12:16:21 +00:00
|
|
|
anchors.right: userImage.right
|
|
|
|
anchors.rightMargin: Math.round(userImage.width / 10)
|
2022-03-09 10:27:32 +00:00
|
|
|
|
2022-06-22 12:16:21 +00:00
|
|
|
width: d.getSize(10, 24, 40)
|
|
|
|
height: width
|
2022-03-09 10:27:32 +00:00
|
|
|
|
2022-06-22 12:16:21 +00:00
|
|
|
type: StatusRoundButton.Type.Secondary
|
|
|
|
icon.name: "edit_pencil"
|
2023-03-06 17:04:30 +00:00
|
|
|
icon.width: d.getSize(8, 12, 24)
|
|
|
|
icon.height: d.getSize(8, 12, 24)
|
2022-06-22 12:16:21 +00:00
|
|
|
|
2022-08-07 21:05:25 +00:00
|
|
|
onClicked: {
|
2024-10-15 08:13:36 +00:00
|
|
|
if (!!root.icon)
|
2023-05-19 16:07:50 +00:00
|
|
|
Global.openMenu(editImageMenuComponent, this)
|
2022-08-07 21:05:25 +00:00
|
|
|
else
|
2022-11-08 18:30:50 +00:00
|
|
|
Global.openChangeProfilePicPopup(tempIcon);
|
|
|
|
}
|
|
|
|
|
|
|
|
function tempIcon(image, aX, aY, bX, bY) {
|
|
|
|
root.icon = image
|
|
|
|
root.cropRect = Qt.rect(aX, aY, bX - aX, bY - aY)
|
2022-12-01 08:37:46 +00:00
|
|
|
|
|
|
|
tmpCroppedImageHelper.setCroppedTmpIcon(
|
|
|
|
image, aX, aY, bX - aX, bY - aY)
|
2022-08-07 21:05:25 +00:00
|
|
|
}
|
2022-03-09 10:27:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-06 07:56:50 +00:00
|
|
|
Item {
|
2022-03-09 10:27:32 +00:00
|
|
|
Layout.fillWidth: true
|
2023-04-06 07:56:50 +00:00
|
|
|
implicitHeight: displayNameLabel.implicitHeight
|
2023-03-20 12:29:05 +00:00
|
|
|
visible: root.displayNameVisible
|
2023-04-06 07:56:50 +00:00
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: displayNameLabel
|
|
|
|
width: parent.width
|
|
|
|
height: parent.height
|
|
|
|
text: root.displayName
|
|
|
|
visible: !root.loading
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
elide: Text.ElideRight
|
|
|
|
maximumLineCount: 3
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
font {
|
|
|
|
bold: true
|
|
|
|
pixelSize: 17
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
height: parent.height
|
|
|
|
width: 100
|
|
|
|
visible: root.loading
|
|
|
|
active: visible
|
|
|
|
|
|
|
|
sourceComponent: LoadingComponent {
|
|
|
|
radius: 4
|
|
|
|
}
|
2022-03-09 10:27:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-11 09:38:39 +00:00
|
|
|
RowLayout {
|
2024-10-15 19:26:12 +00:00
|
|
|
spacing: compact ? 4 : Theme.halfPadding
|
2022-07-21 11:02:31 +00:00
|
|
|
Layout.fillWidth: true
|
2022-06-28 18:11:18 +00:00
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
visible: root.displayNamePlusIconsVisible
|
2023-04-06 07:56:50 +00:00
|
|
|
|
2022-06-28 18:11:18 +00:00
|
|
|
StyledText {
|
2022-08-29 18:03:50 +00:00
|
|
|
objectName: "ProfileHeader_displayName"
|
2024-04-18 22:12:29 +00:00
|
|
|
Layout.maximumWidth: root.width - verificationIcons.width - contentContainer.anchors.leftMargin - contentContainer.anchors.rightMargin -
|
|
|
|
(editButtonLoader.active ? editButtonLoader.item.width : 0)
|
2022-06-28 18:11:18 +00:00
|
|
|
text: root.displayName
|
2022-07-21 11:02:31 +00:00
|
|
|
elide: Text.ElideRight
|
2022-06-28 18:11:18 +00:00
|
|
|
font {
|
|
|
|
weight: Font.Medium
|
2024-10-15 19:26:12 +00:00
|
|
|
pixelSize: Theme.primaryTextFontSize
|
2022-06-28 18:11:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-27 21:26:26 +00:00
|
|
|
StatusContactVerificationIcons {
|
2024-04-18 22:12:29 +00:00
|
|
|
id: verificationIcons
|
2024-01-05 15:34:20 +00:00
|
|
|
visible: !root.isCurrentUser && !root.isBridgedAccount
|
2022-09-27 21:26:26 +00:00
|
|
|
isContact: root.isContact
|
|
|
|
trustIndicator: root.trustStatus
|
2024-02-07 14:56:45 +00:00
|
|
|
isBlocked: root.isBlocked
|
2022-06-28 18:11:18 +00:00
|
|
|
}
|
|
|
|
|
2022-07-21 11:02:31 +00:00
|
|
|
Loader {
|
2024-04-18 22:12:29 +00:00
|
|
|
id: editButtonLoader
|
2022-07-21 11:02:31 +00:00
|
|
|
sourceComponent: SVGImage {
|
2022-08-29 18:03:50 +00:00
|
|
|
objectName: "ProfileHeader_displayNameEditIcon"
|
2022-07-21 11:02:31 +00:00
|
|
|
height: compact ? 10 : 16
|
|
|
|
width: compact ? 10 : 16
|
2024-10-15 19:26:12 +00:00
|
|
|
source: Theme.svg("edit-message")
|
2022-07-21 11:02:31 +00:00
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
acceptedButtons: Qt.LeftButton
|
|
|
|
onClicked: {
|
|
|
|
root.editClicked()
|
|
|
|
}
|
2022-06-28 18:11:18 +00:00
|
|
|
}
|
|
|
|
}
|
2022-07-21 11:02:31 +00:00
|
|
|
active: root.editButtonVisible
|
|
|
|
visible: active
|
2022-06-28 18:11:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-09 10:27:32 +00:00
|
|
|
StyledText {
|
|
|
|
Layout.fillWidth: true
|
2022-07-11 09:38:39 +00:00
|
|
|
Layout.alignment: Qt.AlignHCenter
|
2022-03-09 10:27:32 +00:00
|
|
|
visible: root.pubkeyVisible
|
2024-11-07 10:43:06 +00:00
|
|
|
text: root.isBridgedAccount ? qsTr("Bridged from Discord") : Utils.getElidedPk(compressedPubKey)
|
2022-03-09 10:27:32 +00:00
|
|
|
horizontalAlignment: Text.AlignHCenter
|
2022-09-28 14:24:12 +00:00
|
|
|
font.pixelSize: 13
|
2024-10-15 19:26:12 +00:00
|
|
|
color: Theme.palette.secondaryText
|
2022-03-09 10:27:32 +00:00
|
|
|
}
|
|
|
|
|
2022-03-07 22:59:38 +00:00
|
|
|
EmojiHash {
|
2022-04-14 08:26:46 +00:00
|
|
|
id: emojiHash
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
2024-01-05 15:34:20 +00:00
|
|
|
visible: root.emojiHashVisible && !root.isBridgedAccount
|
2022-07-04 20:09:08 +00:00
|
|
|
compact: root.compact
|
2022-03-09 10:27:32 +00:00
|
|
|
}
|
|
|
|
}
|
2022-08-07 21:05:25 +00:00
|
|
|
|
2023-05-19 16:07:50 +00:00
|
|
|
Component {
|
|
|
|
id: editImageMenuComponent
|
2022-08-07 21:05:25 +00:00
|
|
|
|
2023-05-19 16:07:50 +00:00
|
|
|
StatusMenu {
|
2024-10-24 21:39:05 +00:00
|
|
|
onClosed: destroy()
|
2023-05-19 16:07:50 +00:00
|
|
|
StatusAction {
|
2024-02-07 14:56:45 +00:00
|
|
|
text: !!root.icon ? qsTr("Select different image") : qsTr("Select image")
|
2023-05-19 16:07:50 +00:00
|
|
|
assetSettings.name: "image"
|
|
|
|
onTriggered: Global.openChangeProfilePicPopup(editButton.tempIcon)
|
|
|
|
}
|
2023-03-06 17:04:30 +00:00
|
|
|
|
2023-05-19 16:07:50 +00:00
|
|
|
StatusAction {
|
2024-02-07 14:56:45 +00:00
|
|
|
text: qsTr("Use a collectible")
|
2023-05-19 16:07:50 +00:00
|
|
|
assetSettings.name: "nft-profile"
|
|
|
|
onTriggered: Global.openChangeProfilePicPopup(editButton.tempIcon)
|
2024-02-07 14:56:45 +00:00
|
|
|
enabled: false // TODO enable this with the profile showcase (#13418)
|
2023-05-19 16:07:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusMenuSeparator {}
|
2023-03-06 17:04:30 +00:00
|
|
|
|
2023-05-19 16:07:50 +00:00
|
|
|
StatusAction {
|
|
|
|
text: qsTr("Remove image")
|
|
|
|
type: StatusAction.Danger
|
|
|
|
assetSettings.name: "delete"
|
|
|
|
onTriggered: root.icon = ""
|
|
|
|
}
|
2022-08-07 21:05:25 +00:00
|
|
|
}
|
|
|
|
}
|
2022-03-09 10:27:32 +00:00
|
|
|
}
|