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-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
2021-10-01 15:58:36 +00:00
import "../../../../../shared/controls"
2020-12-18 20:55:33 +00:00
2021-10-19 08:51:11 +00:00
StatusModal {
2020-12-18 20:55:33 +00:00
id: popup
2021-02-12 18:19:31 +00:00
width: 400
height: 400
2021-10-19 08:51:11 +00:00
anchors.centerIn: parent
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 ( ) === "" ) {
2021-07-16 20:22:50 +00:00
//% "You need to enter a key"
keyValidationError = qsTrId ( "you-need-to-enter-a-key" )
2021-03-10 14:25:06 +00:00
}
return ! keyValidationError
}
2021-07-16 20:22:50 +00:00
//% "Access existing community"
2021-10-19 08:51:11 +00:00
header.title: qsTrId ( "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-10-19 08:51:11 +00:00
contentItem: Item {
width: popup . 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
2021-02-12 18:19:31 +00:00
StyledTextArea {
2021-03-10 14:25:06 +00:00
id: keyInput
2021-07-16 20:22:50 +00:00
//% "Community private key"
label: qsTrId ( "community-key" )
2021-02-12 18:19:31 +00:00
placeholderText: "0x0..."
customHeight: 110
}
2020-12-18 20:55:33 +00:00
2021-10-19 08:51:11 +00:00
StatusBaseText {
2021-02-12 18:19:31 +00:00
id: infoText1
2021-07-16 20:22:50 +00:00
//% "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."
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-" )
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
2021-10-19 08:51:11 +00:00
color: Theme . palette . baseColor1
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 {
//% "Import"
text: qsTrId ( "import" )
onClicked: {
if ( ! validate ( ) ) {
return
}
2020-12-18 20:55:33 +00:00
2021-10-19 08:51:11 +00:00
let communityKey = keyInput . text . trim ( )
if ( ! communityKey . startsWith ( "0x" ) ) {
communityKey = "0x" + communityKey
}
2020-12-18 20:55:33 +00:00
2021-10-19 08:51:11 +00:00
const error = chatsModel . communities . importCommunity ( communityKey , Utils . uuid ( ) )
2020-12-18 20:55:33 +00:00
2021-10-19 08:51:11 +00:00
if ( error ) {
creatingError . text = error
return creatingError . open ( )
}
2020-12-18 20:55:33 +00:00
2021-10-19 08:51:11 +00:00
popup . close ( )
}
2020-12-18 20:55:33 +00:00
2021-10-19 08:51:11 +00:00
MessageDialog {
id: creatingError
//% "Error importing the community"
title: qsTrId ( "error-importing-the-community" )
icon: StandardIcon . Critical
standardButtons: StandardButton . Ok
}
2020-12-18 20:55:33 +00:00
}
2021-10-19 08:51:11 +00:00
]
2020-12-18 20:55:33 +00:00
}