status-desktop/ui/imports/shared/popups/ImportCommunityPopup.qml

87 lines
2.4 KiB
QML
Raw Normal View History

2020-12-18 20:55:33 +00:00
import QtQuick 2.12
import QtQuick.Controls 2.3
import QtGraphicalEffects 1.13
import QtQuick.Dialogs 1.3
import utils 1.0
import shared.controls 1.0
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Popups 0.1
import StatusQ.Controls 0.1 as StatusQControls
StatusModal {
id: root
width: 640
2021-02-12 18:19:31 +00:00
height: 400
2020-12-18 20:55:33 +00:00
property var store
function validate(communityKey) {
2022-05-18 13:16:59 +00:00
return Utils.isPrivateKey(communityKey) && Utils.startsWith0x(communityKey)
}
//% "Import Community"
header.title: qsTrId("Import Community")
2020-12-18 20:55:33 +00:00
2021-02-12 18:19:31 +00:00
onClosed: {
root.destroy();
2020-12-18 20:55:33 +00:00
}
contentItem: Item {
width: root.width - 32
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 16
anchors.rightMargin: 16
height: childrenRect.height
2020-12-18 20:55:33 +00:00
StatusBaseText {
id: infoText1
anchors.top: parent.top
anchors.topMargin: Style.current.padding
//% "Entering a community key will grant you the ownership of that community. Please be responsible with it and dont share the key with people you dont trust."
text: qsTrId("entering-a-community-key-will-grant-you-the-ownership-of-that-community--please-be-responsible-with-it-and-don-t-share-the-key-with-people-you-don-t-trust-")
wrapMode: Text.WordWrap
width: parent.width
font.pixelSize: 13
color: Theme.palette.baseColor1
}
2021-02-12 18:19:31 +00:00
StyledTextArea {
id: keyInput
//% "Community private key"
label: qsTrId("Community key")
2021-02-12 18:19:31 +00:00
placeholderText: "0x0..."
customHeight: 110
anchors.top: infoText1.bottom
anchors.topMargin: Style.current.bigPadding
anchors.left: parent.left
anchors.right: parent.right
onTextChanged: {
importButton.enabled = root.validate(keyInput.text)
}
2021-02-12 18:19:31 +00:00
}
2020-12-18 20:55:33 +00:00
}
rightButtons: [
StatusQControls.StatusButton {
id: importButton
enabled: false
//% "Import"
text: qsTrId("import")
onClicked: {
let communityKey = keyInput.text.trim();
if (!communityKey.startsWith("0x")) {
communityKey = "0x" + communityKey;
}
2020-12-18 20:55:33 +00:00
root.store.importCommunity(communityKey);
root.close();
}
2020-12-18 20:55:33 +00:00
}
]
2020-12-18 20:55:33 +00:00
}