2020-08-06 18:19:26 +00:00
|
|
|
|
import QtQuick 2.12
|
|
|
|
|
import QtQuick.Controls 2.3
|
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
|
import QtQml.Models 2.3
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
|
import shared 1.0
|
|
|
|
|
import shared.panels 1.0
|
|
|
|
|
import shared.popups 1.0
|
2020-08-06 18:19:26 +00:00
|
|
|
|
|
2021-10-14 11:33:34 +00:00
|
|
|
|
// TODO: replace with StatusModal
|
2020-08-06 18:19:26 +00:00
|
|
|
|
ModalPopup {
|
|
|
|
|
id: popup
|
|
|
|
|
|
2020-08-26 15:52:26 +00:00
|
|
|
|
//% "Primary username"
|
|
|
|
|
title: qsTrId("ens-primary-username")
|
2020-08-06 18:19:26 +00:00
|
|
|
|
|
2022-01-17 08:56:44 +00:00
|
|
|
|
property var ensUsernamesStore
|
2020-08-06 18:19:26 +00:00
|
|
|
|
property string newUsername: ""
|
|
|
|
|
|
|
|
|
|
onOpened: {
|
|
|
|
|
for(var i in ensNames.contentItem.children){
|
2022-01-17 08:56:44 +00:00
|
|
|
|
ensNames.contentItem.children[i].checked = ensNames.contentItem.children[i].text === popup.ensUsernamesStore.preferredUsername
|
2020-08-06 18:19:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
|
id: lbl1
|
2022-01-17 08:56:44 +00:00
|
|
|
|
text: popup.ensUsernamesStore.preferredUsername ?
|
|
|
|
|
//% "Your messages are displayed to others with this username:"
|
|
|
|
|
qsTrId("your-messages-are-displayed-to-others-with-this-username-")
|
|
|
|
|
:
|
|
|
|
|
//% "Once you select a username, you won’t be able to disable it afterwards. You will only be able choose a different username to display."
|
|
|
|
|
qsTrId("once-you-select-a-username--you-won-t-be-able-to-disable-it-afterwards--you-will-only-be-able-choose-a-different-username-to-display-")
|
2020-08-06 18:19:26 +00:00
|
|
|
|
font.pixelSize: 15
|
2020-09-29 11:04:14 +00:00
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
|
width: parent.width
|
2020-08-06 18:19:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
|
id: lbl2
|
|
|
|
|
anchors.top: lbl1.bottom
|
|
|
|
|
anchors.topMargin: Style.current.padding
|
2022-01-17 08:56:44 +00:00
|
|
|
|
text: popup.ensUsernamesStore.preferredUsername
|
2020-08-06 18:19:26 +00:00
|
|
|
|
font.pixelSize: 17
|
|
|
|
|
font.weight: Font.Bold
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ScrollView {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
anchors.top: lbl2.bottom
|
|
|
|
|
anchors.topMargin: 70
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
|
ScrollBar.vertical.policy: ensNames.contentHeight > ensNames.height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
|
|
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
|
anchors.fill: parent
|
2022-01-17 08:56:44 +00:00
|
|
|
|
model: root.ensUsernamesStore.ensUsernamesModel
|
2020-08-06 18:19:26 +00:00
|
|
|
|
spacing: 0
|
|
|
|
|
clip: true
|
|
|
|
|
id: ensNames
|
|
|
|
|
delegate: RadioDelegate {
|
|
|
|
|
id: radioDelegate
|
2022-01-17 08:56:44 +00:00
|
|
|
|
text: ensUsername
|
|
|
|
|
checked: popup.ensUsernamesStore.preferredUsername === ensUsername
|
2020-09-29 11:04:14 +00:00
|
|
|
|
|
2020-09-29 11:36:31 +00:00
|
|
|
|
contentItem: StyledText {
|
2020-09-29 11:04:14 +00:00
|
|
|
|
color: Style.current.textColor
|
|
|
|
|
text: radioDelegate.text
|
|
|
|
|
rightPadding: radioDelegate.indicator.width + radioDelegate.spacing
|
|
|
|
|
topPadding: Style.current.halfPadding
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-06 18:19:26 +00:00
|
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
onClicked: {
|
|
|
|
|
parent.checked = true
|
2022-01-17 08:56:44 +00:00
|
|
|
|
newUsername = ensUsername;
|
2020-08-06 18:19:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onNewUsernameChanged: {
|
2022-01-17 08:56:44 +00:00
|
|
|
|
btnSelectPreferred.state = newUsername === popup.ensUsernamesStore.preferredUsername ? "inactive" : "active"
|
2020-08-06 18:19:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
footer: Item {
|
2021-01-13 19:15:52 +00:00
|
|
|
|
width: parent.width
|
|
|
|
|
height: btnSelectPreferred.height
|
2020-08-06 18:19:26 +00:00
|
|
|
|
|
|
|
|
|
Button {
|
|
|
|
|
id: btnSelectPreferred
|
|
|
|
|
width: 44
|
|
|
|
|
height: 44
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
state: "inactive"
|
|
|
|
|
states: [
|
|
|
|
|
State {
|
|
|
|
|
name: "inactive"
|
|
|
|
|
PropertyChanges {
|
|
|
|
|
target: btnContinue
|
2021-09-28 15:04:06 +00:00
|
|
|
|
source: Style.svg("arrow-right-btn-inactive")
|
2020-08-06 18:19:26 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
State {
|
|
|
|
|
name: "active"
|
|
|
|
|
PropertyChanges {
|
|
|
|
|
target: btnContinue
|
2021-09-28 15:04:06 +00:00
|
|
|
|
source: Style.svg("arrow-right-btn-active")
|
2020-08-06 18:19:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
SVGImage {
|
|
|
|
|
id: btnContinue
|
|
|
|
|
width: 50
|
|
|
|
|
height: 50
|
|
|
|
|
}
|
|
|
|
|
background: Rectangle {
|
|
|
|
|
color: "transparent"
|
|
|
|
|
}
|
|
|
|
|
MouseArea {
|
|
|
|
|
cursorShape: btnSelectPreferred.state === "active" ? Qt.PointingHandCursor : Qt.ArrowCursor
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
onClicked : {
|
|
|
|
|
if(btnSelectPreferred.state === "active"){
|
2022-01-17 08:56:44 +00:00
|
|
|
|
popup.ensUsernamesStore.setPrefferedEnsUsername(newUsername);
|
|
|
|
|
newUsername = "";
|
|
|
|
|
popup.close();
|
2020-08-06 18:19:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|