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
2021-09-28 15:04:06 +00:00
import utils 1.0
2021-10-27 21:27:49 +00:00
import shared . controls 1.0
2021-10-19 08:51:11 +00:00
import StatusQ . Core 0.1
import StatusQ . Core . Theme 0.1
import StatusQ . Popups 0.1
import StatusQ . Controls 0.1 as StatusQControls
StatusModal {
2021-10-22 20:49:47 +00:00
id: root
2022-03-23 10:56:25 +00:00
width: 640
2021-02-12 18:19:31 +00:00
height: 400
2020-12-18 20:55:33 +00:00
2021-11-30 14:49:36 +00:00
property var store
2021-10-22 20:49:47 +00:00
2022-02-02 17:54:28 +00:00
function validate ( communityKey ) {
2022-05-18 13:16:59 +00:00
return Utils . isPrivateKey ( communityKey ) && Utils . startsWith0x ( communityKey )
2021-03-10 14:25:06 +00:00
}
2022-04-04 11:26:30 +00:00
header.title: qsTr ( "Import Community" )
2020-12-18 20:55:33 +00:00
2021-02-12 18:19:31 +00:00
onClosed: {
2021-10-22 20:49:47 +00:00
root . destroy ( ) ;
2020-12-18 20:55:33 +00:00
}
2021-10-19 08:51:11 +00:00
contentItem: Item {
2021-10-22 20:49:47 +00:00
width: root . width - 32
2021-10-19 08:51:11 +00:00
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
2022-03-23 10:56:25 +00:00
StatusBaseText {
id: infoText1
anchors.top: parent . top
anchors.topMargin: Style . current . padding
2022-04-04 11:26:30 +00:00
text: qsTr ( "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." )
2022-03-23 10:56:25 +00:00
wrapMode: Text . WordWrap
width: parent . width
font.pixelSize: 13
color: Theme . palette . baseColor1
}
2021-02-12 18:19:31 +00:00
StyledTextArea {
2021-03-10 14:25:06 +00:00
id: keyInput
2022-04-04 11:26:30 +00:00
label: qsTr ( "Community private key" )
2021-02-12 18:19:31 +00:00
placeholderText: "0x0..."
customHeight: 110
2022-03-23 10:56:25 +00:00
anchors.top: infoText1 . bottom
anchors.topMargin: Style . current . bigPadding
2022-01-17 09:59:52 +00:00
anchors.left: parent . left
anchors.right: parent . right
2022-02-02 17:54:28 +00:00
onTextChanged: {
importButton . enabled = root . validate ( keyInput . text )
}
2021-02-12 18:19:31 +00:00
}
2020-12-18 20:55:33 +00:00
}
2021-10-19 08:51:11 +00:00
rightButtons: [
StatusQControls . StatusButton {
2022-02-02 17:54:28 +00:00
id: importButton
enabled: false
2022-04-04 11:26:30 +00:00
text: qsTr ( "Import" )
2021-10-19 08:51:11 +00:00
onClicked: {
2022-02-02 17:54:28 +00:00
let communityKey = keyInput . text . trim ( ) ;
2021-10-19 08:51:11 +00:00
if ( ! communityKey . startsWith ( "0x" ) ) {
2021-10-22 20:49:47 +00:00
communityKey = "0x" + communityKey ;
2021-10-19 08:51:11 +00:00
}
2020-12-18 20:55:33 +00:00
2022-02-02 17:54:28 +00:00
root . store . importCommunity ( communityKey ) ;
2021-10-22 20:49:47 +00:00
root . close ( ) ;
2021-10-19 08:51:11 +00:00
}
2020-12-18 20:55:33 +00:00
}
2021-10-19 08:51:11 +00:00
]
2020-12-18 20:55:33 +00:00
}