2022-03-09 10:27:32 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
|
2022-06-22 12:16:21 +00:00
|
|
|
enum ImageSize {
|
|
|
|
Compact,
|
|
|
|
Middle,
|
|
|
|
Big
|
|
|
|
}
|
|
|
|
|
2022-06-28 18:11:18 +00:00
|
|
|
property var store
|
2022-03-09 10:27:32 +00:00
|
|
|
property string displayName
|
|
|
|
property string pubkey
|
|
|
|
property string icon
|
2022-06-28 18:11:18 +00:00
|
|
|
property int trustStatus
|
|
|
|
property bool isContact: false
|
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
|
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
|
2022-06-28 18:11:18 +00:00
|
|
|
property bool pubkeyVisibleWithCopy: false
|
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
|
2022-07-06 19:07:33 +00:00
|
|
|
readonly property bool compact: root.imageSize === ProfileHeader.ImageSize.Compact
|
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
|
|
|
|
|
|
|
height: visible ? contentContainer.height : 0
|
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-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
|
|
|
|
leftMargin: Style.current.smallPadding
|
|
|
|
rightMargin: Style.current.smallPadding
|
|
|
|
}
|
|
|
|
|
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
|
2022-08-29 18:03:50 +00:00
|
|
|
objectName: "ProfileHeader_userImage"
|
2022-06-22 12:16:21 +00:00
|
|
|
name: root.displayName
|
|
|
|
pubkey: root.pubkey
|
|
|
|
image: root.icon
|
|
|
|
interactive: false
|
2022-09-28 14:24:12 +00:00
|
|
|
imageWidth: d.getSize(36, 64, 160)
|
2022-06-22 12:16:21 +00:00
|
|
|
imageHeight: imageWidth
|
2022-09-22 22:18:15 +00:00
|
|
|
showRing: !root.userIsEnsVerified
|
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
|
|
|
|
anchors.bottom: userImage.bottom
|
|
|
|
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"
|
|
|
|
icon.width: d.getSize(8, 12, 20)
|
|
|
|
icon.height: d.getSize(8, 12, 20)
|
|
|
|
|
2022-08-07 21:05:25 +00:00
|
|
|
onClicked: {
|
|
|
|
if (!!root.store.profileLargeImage)
|
|
|
|
imageEditMenu.popup(this, mouse.x, mouse.y);
|
|
|
|
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-08-07 21:05:25 +00:00
|
|
|
}
|
2022-03-09 10:27:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
visible: root.displayNameVisible
|
|
|
|
text: root.displayName
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
elide: Text.ElideRight
|
|
|
|
maximumLineCount: 3
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
font {
|
2022-09-28 14:24:12 +00:00
|
|
|
bold: true
|
|
|
|
pixelSize: 17
|
2022-03-09 10:27:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-11 09:38:39 +00:00
|
|
|
RowLayout {
|
2022-07-21 11:02:31 +00:00
|
|
|
spacing: compact ? 4 : Style.current.halfPadding
|
|
|
|
Layout.fillWidth: true
|
2022-06-28 18:11:18 +00:00
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
visible: root.displayNamePlusIconsVisible
|
|
|
|
StyledText {
|
2022-08-29 18:03:50 +00:00
|
|
|
objectName: "ProfileHeader_displayName"
|
2022-07-21 11:02:31 +00:00
|
|
|
Layout.maximumWidth: root.width - Style.current.xlPadding
|
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
|
|
|
|
pixelSize: Style.current.primaryTextFontSize
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-27 21:26:26 +00:00
|
|
|
StatusContactVerificationIcons {
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
visible: !root.isCurrentUser
|
|
|
|
isContact: root.isContact
|
|
|
|
trustIndicator: root.trustStatus
|
2022-06-28 18:11:18 +00:00
|
|
|
}
|
|
|
|
|
2022-07-21 11:02:31 +00:00
|
|
|
Loader {
|
|
|
|
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
|
|
|
|
source: Style.svg("edit-message")
|
|
|
|
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
|
2022-03-30 07:09:39 +00:00
|
|
|
text: Utils.getElidedCompressedPk(pubkey)
|
2022-03-09 10:27:32 +00:00
|
|
|
horizontalAlignment: Text.AlignHCenter
|
2022-09-28 14:24:12 +00:00
|
|
|
font.pixelSize: 13
|
2022-03-09 10:27:32 +00:00
|
|
|
color: Style.current.secondaryText
|
|
|
|
}
|
|
|
|
|
2022-07-11 09:38:39 +00:00
|
|
|
RowLayout {
|
2022-06-28 18:11:18 +00:00
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
visible: root.pubkeyVisibleWithCopy
|
|
|
|
StyledText {
|
|
|
|
id: txtChatKey
|
|
|
|
text: qsTr("Chatkey:%1...").arg(pubkey.substring(0, 32))
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
font.pixelSize: Style.current.primaryTextFontSize
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
}
|
|
|
|
|
|
|
|
CopyToClipBoardButton {
|
|
|
|
id: copyBtn
|
2022-07-11 09:38:39 +00:00
|
|
|
Layout.preferredWidth: 20
|
|
|
|
Layout.preferredHeight: 20
|
2022-06-28 18:11:18 +00:00
|
|
|
color: Style.current.transparent
|
|
|
|
textToCopy: pubkey
|
|
|
|
store: root.store
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-07 22:59:38 +00:00
|
|
|
EmojiHash {
|
2022-04-14 08:26:46 +00:00
|
|
|
id: emojiHash
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
2022-06-22 12:16:21 +00:00
|
|
|
visible: root.emojiHashVisible
|
2022-07-04 20:09:08 +00:00
|
|
|
compact: root.compact
|
2022-03-07 22:59:38 +00:00
|
|
|
publicKey: root.pubkey
|
2022-03-09 10:27:32 +00:00
|
|
|
}
|
|
|
|
}
|
2022-08-07 21:05:25 +00:00
|
|
|
|
|
|
|
StatusPopupMenu {
|
|
|
|
id: imageEditMenu
|
|
|
|
|
|
|
|
StatusMenuItem {
|
|
|
|
text: qsTr("Upload a file")
|
|
|
|
icon.name: "download"
|
|
|
|
iconRotation: 180
|
2022-11-08 18:30:50 +00:00
|
|
|
onTriggered: Global.openChangeProfilePicPopup(editButton.tempIcon)
|
2022-08-07 21:05:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusMenuItem {
|
|
|
|
text: qsTr("Remove image")
|
|
|
|
type: StatusMenuItem.Danger
|
|
|
|
icon.name: "delete"
|
2022-11-08 18:30:50 +00:00
|
|
|
onTriggered: root.icon = ""
|
2022-08-07 21:05:25 +00:00
|
|
|
}
|
|
|
|
}
|
2022-03-09 10:27:32 +00:00
|
|
|
}
|