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 "../../../../imports"
import "../../../../shared"
import "../../../../shared/status"
ModalPopup {
id: popup
2021-02-12 18:19:31 +00:00
width: 400
height: 400
2020-12-18 20:55:33 +00:00
2021-03-10 14:25:06 +00:00
property string keyValidationError: ""
function validate ( ) {
keyValidationError = ""
if ( keyInput . text . trim ( ) === "" ) {
keyValidationError = qsTr ( "You need to enter a key" )
}
return ! keyValidationError
}
2021-02-12 18:19:31 +00:00
title: qsTr ( "Access existing community" )
2020-12-18 20:55:33 +00:00
2021-02-12 18:19:31 +00:00
onClosed: {
popup . destroy ( ) ;
2020-12-18 20:55:33 +00:00
}
2021-02-12 18:19:31 +00:00
Item {
anchors.fill: parent
2020-12-18 20:55:33 +00:00
2021-02-12 18:19:31 +00:00
StyledTextArea {
2021-03-10 14:25:06 +00:00
id: keyInput
2021-02-12 18:19:31 +00:00
label: qsTr ( "Community private key" )
placeholderText: "0x0..."
customHeight: 110
}
2020-12-18 20:55:33 +00:00
2021-02-12 18:19:31 +00:00
StyledText {
id: infoText1
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." )
2021-03-10 14:25:06 +00:00
anchors.top: keyInput . bottom
2021-02-12 18:19:31 +00:00
wrapMode: Text . WordWrap
anchors.topMargin: Style . current . bigPadding
width: parent . width
font.pixelSize: 13
color: Style . current . secondaryText
}
2020-12-18 20:55:33 +00:00
}
footer: StatusButton {
2021-02-12 18:19:31 +00:00
id: btnBack
text: qsTr ( "Import" )
2020-12-18 20:55:33 +00:00
anchors.right: parent . right
onClicked: {
if ( ! validate ( ) ) {
return
}
2021-03-10 14:25:06 +00:00
let communityKey = keyInput . text . trim ( )
2020-12-18 20:55:33 +00:00
if ( ! communityKey . startsWith ( "0x" ) ) {
communityKey = "0x" + communityKey
}
2021-02-11 20:37:31 +00:00
const error = chatsModel . communities . importCommunity ( communityKey )
2020-12-18 20:55:33 +00:00
if ( error ) {
creatingError . text = error
return creatingError . open ( )
}
2020-12-22 20:23:21 +00:00
popup . close ( )
2020-12-18 20:55:33 +00:00
}
MessageDialog {
id: creatingError
2021-02-12 18:19:31 +00:00
title: qsTr ( "Error importing the community" )
2020-12-18 20:55:33 +00:00
icon: StandardIcon . Critical
standardButtons: StandardButton . Ok
}
}
}