2020-08-04 22:22:51 +00:00
|
|
|
|
import QtQuick 2.14
|
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
|
import QtQuick.Controls 2.14
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2021-10-25 19:37:44 +00:00
|
|
|
|
import StatusQ.Controls 0.1
|
2022-12-05 19:24:55 +00:00
|
|
|
|
import StatusQ.Components 0.1
|
2021-10-06 09:16:39 +00:00
|
|
|
|
|
2021-10-27 21:27:49 +00:00
|
|
|
|
import shared 1.0
|
|
|
|
|
import shared.panels 1.0
|
2021-10-28 20:23:30 +00:00
|
|
|
|
import shared.views.chat 1.0
|
|
|
|
|
import shared.panels.chat 1.0
|
|
|
|
|
import shared.controls.chat 1.0
|
2022-07-14 11:03:36 +00:00
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
|
|
import "../popups"
|
2020-08-04 22:22:51 +00:00
|
|
|
|
|
|
|
|
|
Item {
|
2021-10-06 09:16:39 +00:00
|
|
|
|
id: root
|
2020-08-04 22:22:51 +00:00
|
|
|
|
|
2022-01-17 08:56:44 +00:00
|
|
|
|
property var ensUsernamesStore
|
|
|
|
|
|
2021-12-09 13:28:02 +00:00
|
|
|
|
property int profileContentWidth
|
2021-10-06 09:16:39 +00:00
|
|
|
|
|
2022-12-05 19:24:55 +00:00
|
|
|
|
signal addBtnClicked()
|
|
|
|
|
signal selectEns(string username)
|
|
|
|
|
|
2022-12-06 20:42:18 +00:00
|
|
|
|
Component.onCompleted: {
|
|
|
|
|
d.updateNumberOfPendingEnsUsernames()
|
|
|
|
|
}
|
2022-12-05 19:24:55 +00:00
|
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
|
id: d
|
|
|
|
|
|
2022-12-06 20:42:18 +00:00
|
|
|
|
property int numOfPendingEnsUsernames: 0
|
|
|
|
|
readonly property bool hasConfirmedEnsUsernames: root.ensUsernamesStore.ensUsernamesModel.count > 0
|
|
|
|
|
&& numOfPendingEnsUsernames !== root.ensUsernamesStore.ensUsernamesModel.count
|
|
|
|
|
|
|
|
|
|
function updateNumberOfPendingEnsUsernames() {
|
|
|
|
|
numOfPendingEnsUsernames = root.ensUsernamesStore.numOfPendingEnsUsernames()
|
2022-12-05 19:24:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
|
target: root.ensUsernamesStore.ensUsernamesModule
|
|
|
|
|
onUsernameConfirmed: {
|
2022-12-06 20:42:18 +00:00
|
|
|
|
d.updateNumberOfPendingEnsUsernames()
|
2022-12-05 19:24:55 +00:00
|
|
|
|
chatSettingsLabel.visible = true
|
|
|
|
|
}
|
2020-09-11 17:23:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
Item {
|
|
|
|
|
anchors.top: parent.top
|
2021-12-09 13:28:02 +00:00
|
|
|
|
width: profileContentWidth
|
2021-04-08 15:44:58 +00:00
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
|
|
|
|
|
Component {
|
|
|
|
|
id: statusENS
|
|
|
|
|
Item {
|
|
|
|
|
Text {
|
|
|
|
|
id: usernameTxt
|
2022-04-04 11:26:30 +00:00
|
|
|
|
text: username.substr(0, username.indexOf(".")) + " " + (isPending ? qsTr("(pending)") : "")
|
2021-04-08 15:44:58 +00:00
|
|
|
|
color: Style.current.textColor
|
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
Text {
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
anchors.top: usernameTxt.bottom
|
|
|
|
|
anchors.topMargin: 2
|
|
|
|
|
text: username.substr(username.indexOf("."))
|
2021-11-01 09:42:00 +00:00
|
|
|
|
color: Theme.palette.baseColor1
|
2021-04-08 15:44:58 +00:00
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
Component {
|
|
|
|
|
id: normalENS
|
|
|
|
|
Item {
|
|
|
|
|
Text {
|
|
|
|
|
id: usernameTxt
|
2022-04-04 11:26:30 +00:00
|
|
|
|
text: username + " " + (isPending ? qsTr("(pending)") : "")
|
2021-04-08 15:44:58 +00:00
|
|
|
|
font.pixelSize: 16
|
2021-11-01 09:42:00 +00:00
|
|
|
|
color: Theme.palette.directColor1
|
2021-04-08 15:44:58 +00:00
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: 5
|
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
Component {
|
|
|
|
|
id: ensDelegate
|
|
|
|
|
Item {
|
|
|
|
|
height: 45
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
2020-08-06 19:45:57 +00:00
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
MouseArea {
|
2022-02-09 16:39:10 +00:00
|
|
|
|
enabled: !model.isPending
|
2021-04-08 15:44:58 +00:00
|
|
|
|
anchors.fill: parent
|
2022-02-09 16:39:10 +00:00
|
|
|
|
cursorShape:enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
|
2022-01-17 08:56:44 +00:00
|
|
|
|
onClicked: selectEns(model.ensUsername)
|
2021-04-08 15:44:58 +00:00
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
Rectangle {
|
|
|
|
|
id: circle
|
|
|
|
|
width: 35
|
|
|
|
|
height: 35
|
|
|
|
|
radius: 35
|
2021-10-06 09:16:39 +00:00
|
|
|
|
color: Theme.palette.primaryColor1
|
2021-04-08 15:44:58 +00:00
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
|
StatusBaseText {
|
2021-04-08 15:44:58 +00:00
|
|
|
|
text: "@"
|
|
|
|
|
opacity: 0.7
|
|
|
|
|
font.weight: Font.Bold
|
|
|
|
|
font.pixelSize: 16
|
2021-10-06 09:16:39 +00:00
|
|
|
|
color: Theme.palette.indirectColor1
|
2021-04-08 15:44:58 +00:00
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
Loader {
|
2022-01-17 08:56:44 +00:00
|
|
|
|
sourceComponent: model.ensUsername.endsWith(".stateofus.eth") ? statusENS : normalENS
|
|
|
|
|
property string username: model.ensUsername
|
2021-04-08 15:44:58 +00:00
|
|
|
|
property bool isPending: model.isPending
|
|
|
|
|
active: true
|
|
|
|
|
anchors.left: circle.right
|
|
|
|
|
anchors.leftMargin: Style.current.smallPadding
|
2020-08-05 19:50:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-04 22:22:51 +00:00
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
|
StatusBaseText {
|
2021-04-08 15:44:58 +00:00
|
|
|
|
id: sectionTitle
|
2022-04-04 11:26:30 +00:00
|
|
|
|
text: qsTr("ENS usernames")
|
2021-04-08 15:44:58 +00:00
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: 24
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: 24
|
|
|
|
|
font.weight: Font.Bold
|
|
|
|
|
font.pixelSize: 20
|
2021-11-01 09:42:00 +00:00
|
|
|
|
color: Theme.palette.directColor1
|
2020-08-04 22:22:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
Item {
|
|
|
|
|
id: addUsername
|
|
|
|
|
anchors.top: sectionTitle.bottom
|
|
|
|
|
anchors.topMargin: Style.current.bigPadding
|
|
|
|
|
width: addButton.width + usernameText.width + Style.current.padding
|
|
|
|
|
height: addButton.height
|
|
|
|
|
|
|
|
|
|
StatusRoundButton {
|
|
|
|
|
id: addButton
|
2021-10-25 19:37:44 +00:00
|
|
|
|
width: 40
|
|
|
|
|
height: 40
|
2021-04-08 15:44:58 +00:00
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2021-10-25 19:37:44 +00:00
|
|
|
|
icon.name: "add"
|
|
|
|
|
type: StatusRoundButton.Type.Secondary
|
2021-04-08 15:44:58 +00:00
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
|
StatusBaseText {
|
2021-04-08 15:44:58 +00:00
|
|
|
|
id: usernameText
|
2022-04-04 11:26:30 +00:00
|
|
|
|
text: qsTr("Add username")
|
2021-10-06 09:16:39 +00:00
|
|
|
|
color: Theme.palette.primaryColor1
|
2021-04-08 15:44:58 +00:00
|
|
|
|
anchors.left: addButton.right
|
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
|
anchors.verticalCenter: addButton.verticalCenter
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
MouseArea {
|
2020-08-05 19:50:55 +00:00
|
|
|
|
anchors.fill: parent
|
2021-04-08 15:44:58 +00:00
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
|
onClicked: addBtnClicked()
|
2020-08-05 19:50:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
|
StatusBaseText {
|
2021-04-08 15:44:58 +00:00
|
|
|
|
id: usernamesLabel
|
2022-04-04 11:26:30 +00:00
|
|
|
|
text: qsTr("Your usernames")
|
2021-04-08 15:44:58 +00:00
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.top: addUsername.bottom
|
|
|
|
|
anchors.topMargin: 24
|
|
|
|
|
font.pixelSize: 16
|
2021-11-01 09:42:00 +00:00
|
|
|
|
color: Theme.palette.directColor1
|
2021-04-08 15:44:58 +00:00
|
|
|
|
}
|
2020-08-06 18:19:26 +00:00
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
Item {
|
2022-07-14 11:03:36 +00:00
|
|
|
|
id: ensList
|
2021-04-08 15:44:58 +00:00
|
|
|
|
anchors.top: usernamesLabel.bottom
|
|
|
|
|
anchors.topMargin: 10
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
height: 200
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
|
StatusListView {
|
|
|
|
|
id: lvEns
|
2021-04-08 15:44:58 +00:00
|
|
|
|
anchors.fill: parent
|
2022-07-14 11:03:36 +00:00
|
|
|
|
model: root.ensUsernamesStore.ensUsernamesModel
|
|
|
|
|
spacing: 10
|
|
|
|
|
delegate: ensDelegate
|
2021-04-08 15:44:58 +00:00
|
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
|
ScrollBar.vertical: ScrollBar { policy: ScrollBar.AsNeeded }
|
2021-04-08 15:44:58 +00:00
|
|
|
|
}
|
2020-08-06 18:19:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
Separator {
|
|
|
|
|
id: separator
|
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
|
anchors.top: ensList.bottom
|
2020-08-06 18:19:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
|
StatusBaseText {
|
2021-04-08 15:44:58 +00:00
|
|
|
|
id: chatSettingsLabel
|
2022-12-06 20:42:18 +00:00
|
|
|
|
visible: d.hasConfirmedEnsUsernames
|
2022-04-04 11:26:30 +00:00
|
|
|
|
text: qsTr("Chat settings")
|
2021-04-08 15:44:58 +00:00
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.top: ensList.bottom
|
|
|
|
|
anchors.topMargin: 24
|
|
|
|
|
font.pixelSize: 16
|
2021-11-01 09:42:00 +00:00
|
|
|
|
color: Theme.palette.directColor1
|
2020-08-06 18:19:26 +00:00
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
Item {
|
|
|
|
|
width: childrenRect.width
|
|
|
|
|
height: childrenRect.height
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
2022-12-05 19:24:55 +00:00
|
|
|
|
id: primaryUsernameItem
|
2020-08-05 19:50:55 +00:00
|
|
|
|
anchors.left: parent.left
|
2021-04-08 15:44:58 +00:00
|
|
|
|
anchors.top: chatSettingsLabel.bottom
|
|
|
|
|
anchors.topMargin: 24
|
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
|
StatusBaseText {
|
2021-04-08 15:44:58 +00:00
|
|
|
|
id: usernameLabel
|
|
|
|
|
visible: chatSettingsLabel.visible
|
2022-04-04 11:26:30 +00:00
|
|
|
|
text: qsTr("Primary Username")
|
2021-04-08 15:44:58 +00:00
|
|
|
|
font.pixelSize: 14
|
|
|
|
|
font.weight: Font.Bold
|
2021-11-01 09:42:00 +00:00
|
|
|
|
color: Theme.palette.directColor1
|
2021-04-08 15:44:58 +00:00
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
|
StatusBaseText {
|
2021-04-08 15:44:58 +00:00
|
|
|
|
id: usernameLabel2
|
|
|
|
|
visible: chatSettingsLabel.visible
|
2022-04-04 11:26:30 +00:00
|
|
|
|
text: root.ensUsernamesStore.preferredUsername || qsTr("None selected")
|
2021-04-08 15:44:58 +00:00
|
|
|
|
anchors.left: usernameLabel.right
|
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
|
font.pixelSize: 14
|
2021-11-01 09:42:00 +00:00
|
|
|
|
color: Theme.palette.directColor1
|
2021-04-08 15:44:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
2022-12-05 19:24:55 +00:00
|
|
|
|
onClicked: {
|
|
|
|
|
Global.openPopup(ensPopupComponent)
|
|
|
|
|
}
|
2021-04-08 15:44:58 +00:00
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-12-05 19:24:55 +00:00
|
|
|
|
StatusMessage {
|
2021-04-08 15:44:58 +00:00
|
|
|
|
id: messagesShownAs
|
|
|
|
|
|
2022-12-05 19:24:55 +00:00
|
|
|
|
anchors.top: !visible ? separator.bottom : primaryUsernameItem.bottom
|
|
|
|
|
anchors.topMargin: Style.current.padding * 2
|
2020-09-11 17:23:57 +00:00
|
|
|
|
|
2022-12-06 20:42:18 +00:00
|
|
|
|
visible: d.hasConfirmedEnsUsernames
|
|
|
|
|
&& root.ensUsernamesStore.preferredUsername !== ""
|
|
|
|
|
|
2022-12-05 19:24:55 +00:00
|
|
|
|
timestamp: new Date().getTime()
|
|
|
|
|
disableHover: true
|
|
|
|
|
hideQuickActions: true
|
|
|
|
|
profileClickable: false
|
|
|
|
|
|
|
|
|
|
messageDetails: StatusMessageDetails {
|
|
|
|
|
contentType: StatusMessage.ContentType.Text
|
|
|
|
|
messageText: qsTr("Hey!")
|
|
|
|
|
amISender: false
|
|
|
|
|
sender.displayName: root.ensUsernamesStore.preferredUsername
|
|
|
|
|
sender.profileImage.assetSettings.isImage: true
|
|
|
|
|
sender.profileImage.name: root.ensUsernamesStore.icon
|
2021-04-08 15:44:58 +00:00
|
|
|
|
}
|
2022-12-05 19:24:55 +00:00
|
|
|
|
}
|
2021-04-08 15:44:58 +00:00
|
|
|
|
|
2022-12-05 19:24:55 +00:00
|
|
|
|
StatusBaseText {
|
|
|
|
|
anchors.top: messagesShownAs.bottom
|
|
|
|
|
anchors.left: messagesShownAs.left
|
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
|
text: qsTr("You’re displaying your ENS username in chats")
|
|
|
|
|
font.pixelSize: 14
|
|
|
|
|
color: Theme.palette.baseColor1
|
2020-09-11 17:23:57 +00:00
|
|
|
|
}
|
2022-12-05 19:24:55 +00:00
|
|
|
|
}
|
2021-04-08 15:44:58 +00:00
|
|
|
|
|
2022-12-05 19:24:55 +00:00
|
|
|
|
Component {
|
|
|
|
|
id: ensPopupComponent
|
2021-04-08 15:44:58 +00:00
|
|
|
|
|
2022-12-05 19:24:55 +00:00
|
|
|
|
ENSPopup {
|
|
|
|
|
ensUsernamesStore: root.ensUsernamesStore
|
|
|
|
|
onClosed: {
|
|
|
|
|
destroy()
|
2021-04-08 15:44:58 +00:00
|
|
|
|
}
|
2020-09-11 17:23:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-14 12:12:47 +00:00
|
|
|
|
}
|
2021-10-06 09:16:39 +00:00
|
|
|
|
|