2024-02-08 16:59:53 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
2023-08-04 12:41:57 +00:00
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import "./stores"
|
2023-08-09 10:41:55 +00:00
|
|
|
import "./states"
|
2023-08-04 12:41:57 +00:00
|
|
|
import "../common"
|
|
|
|
|
|
|
|
StatusModal {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property KeypairImportStore store: KeypairImportStore { }
|
|
|
|
|
|
|
|
width: Constants.keypairImportPopup.popupWidth
|
|
|
|
|
|
|
|
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
|
|
|
|
|
|
|
headerSettings.title: {
|
2023-08-09 10:41:55 +00:00
|
|
|
switch (root.store.currentState.stateType) {
|
|
|
|
case Constants.keypairImportPopup.state.selectKeypair:
|
2024-06-07 13:29:09 +00:00
|
|
|
return qsTr("Import missing key pairs")
|
2023-08-21 10:58:21 +00:00
|
|
|
case Constants.keypairImportPopup.state.exportKeypair:
|
2023-08-22 11:22:27 +00:00
|
|
|
if (!!root.store.selectedKeypair.name) {
|
2024-06-07 13:29:09 +00:00
|
|
|
return qsTr("Encrypted QR for %1 key pair").arg(root.store.selectedKeypair.name)
|
2023-08-22 11:22:27 +00:00
|
|
|
}
|
2024-06-07 13:29:09 +00:00
|
|
|
return qsTr("Encrypted QR for key pairs on this device")
|
2023-08-21 10:58:21 +00:00
|
|
|
case Constants.keypairImportPopup.state.importQr:
|
2024-06-07 13:29:09 +00:00
|
|
|
return qsTr("Scan encrypted key pair QR code")
|
2023-08-21 10:58:21 +00:00
|
|
|
case Constants.keypairImportPopup.state.displayInstructions:
|
2023-08-23 07:09:16 +00:00
|
|
|
if (root.store.syncViaQr) {
|
|
|
|
return Constants.keypairImportPopup.instructionsLabelForQr
|
|
|
|
}
|
|
|
|
return Constants.keypairImportPopup.instructionsLabelForEncryptedKey
|
2023-08-09 10:41:55 +00:00
|
|
|
}
|
|
|
|
|
2024-06-07 13:29:09 +00:00
|
|
|
return qsTr("Import %1 key pair").arg(root.store.selectedKeypair.name)
|
2023-08-04 12:41:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onClosed: {
|
|
|
|
root.store.currentState.doCancelAction()
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusScrollView {
|
|
|
|
id: scrollView
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
padding: 0
|
|
|
|
contentWidth: availableWidth
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: content
|
|
|
|
|
|
|
|
implicitWidth: loader.implicitWidth
|
|
|
|
implicitHeight: loader.implicitHeight
|
|
|
|
width: scrollView.availableWidth
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: loader
|
|
|
|
width: parent.width
|
|
|
|
sourceComponent: {
|
|
|
|
switch (root.store.currentState.stateType) {
|
2023-08-09 10:41:55 +00:00
|
|
|
case Constants.keypairImportPopup.state.selectKeypair:
|
|
|
|
return selectKeypairComponent
|
|
|
|
case Constants.keypairImportPopup.state.selectImportMethod:
|
|
|
|
return selectImportMethodComponent
|
2023-08-21 10:58:21 +00:00
|
|
|
case Constants.keypairImportPopup.state.exportKeypair:
|
|
|
|
return exportKeypairComponent
|
|
|
|
case Constants.keypairImportPopup.state.importQr:
|
|
|
|
return keypairImportQrComponent
|
2023-08-04 12:41:57 +00:00
|
|
|
case Constants.keypairImportPopup.state.importPrivateKey:
|
|
|
|
return keypairImportPrivateKeyComponent
|
|
|
|
case Constants.keypairImportPopup.state.importSeedPhrase:
|
|
|
|
return keypairImportSeedPhraseComponent
|
2023-08-21 10:58:21 +00:00
|
|
|
case Constants.keypairImportPopup.state.displayInstructions:
|
|
|
|
return displayInstructionsComponent
|
2023-08-04 12:41:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return undefined
|
|
|
|
}
|
|
|
|
|
|
|
|
onLoaded: {
|
|
|
|
content.height = Qt.binding(function(){return item.height})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-09 10:41:55 +00:00
|
|
|
Component {
|
|
|
|
id: selectKeypairComponent
|
|
|
|
SelectKeypair {
|
|
|
|
height: Constants.keypairImportPopup.contentHeight
|
|
|
|
store: root.store
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: selectImportMethodComponent
|
|
|
|
SelectImportMethod {
|
|
|
|
height: Constants.keypairImportPopup.contentHeight
|
|
|
|
store: root.store
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
2023-08-21 10:58:21 +00:00
|
|
|
id: exportKeypairComponent
|
|
|
|
ExportKeypair {
|
|
|
|
height: Constants.keypairImportPopup.contentHeight
|
|
|
|
store: root.store
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: keypairImportQrComponent
|
|
|
|
ScanOrEnterQrCode {
|
|
|
|
height: Constants.keypairImportPopup.contentHeight
|
|
|
|
store: root.store
|
2023-08-09 10:41:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-04 12:41:57 +00:00
|
|
|
Component {
|
|
|
|
id: keypairImportPrivateKeyComponent
|
|
|
|
EnterPrivateKey {
|
|
|
|
height: Constants.keypairImportPopup.contentHeight
|
|
|
|
store: root.store
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: keypairImportSeedPhraseComponent
|
|
|
|
EnterSeedPhrase {
|
|
|
|
height: Constants.keypairImportPopup.contentHeight
|
|
|
|
store: root.store
|
|
|
|
}
|
|
|
|
}
|
2023-08-21 10:58:21 +00:00
|
|
|
|
|
|
|
Component {
|
|
|
|
id: displayInstructionsComponent
|
|
|
|
DisplayInstructions {
|
|
|
|
height: Constants.keypairImportPopup.contentHeight
|
2023-08-23 07:09:16 +00:00
|
|
|
store: root.store
|
2023-08-21 10:58:21 +00:00
|
|
|
}
|
|
|
|
}
|
2023-08-04 12:41:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
leftButtons: [
|
|
|
|
StatusBackButton {
|
|
|
|
id: backButton
|
|
|
|
visible: root.store.currentState.displayBackButton
|
2024-02-08 16:59:53 +00:00
|
|
|
|
|
|
|
Layout.minimumWidth: implicitWidth
|
|
|
|
|
2023-08-04 12:41:57 +00:00
|
|
|
onClicked: {
|
|
|
|
root.store.currentState.doBackAction()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
rightButtons: [
|
|
|
|
StatusButton {
|
|
|
|
id: primaryButton
|
|
|
|
height: Constants.keypairImportPopup.footerButtonsHeight
|
|
|
|
text: {
|
|
|
|
switch (root.store.currentState.stateType) {
|
|
|
|
|
2023-08-21 10:58:21 +00:00
|
|
|
case Constants.keypairImportPopup.state.exportKeypair:
|
2023-08-09 10:41:55 +00:00
|
|
|
return qsTr("Done")
|
2023-08-21 10:58:21 +00:00
|
|
|
case Constants.keypairImportPopup.state.importQr:
|
2023-08-22 11:22:27 +00:00
|
|
|
if (root.store.syncViaQr) {
|
|
|
|
return qsTr("Done")
|
|
|
|
}
|
2024-06-07 13:29:09 +00:00
|
|
|
return qsTr("Import key pair")
|
2023-08-04 12:41:57 +00:00
|
|
|
case Constants.keypairImportPopup.state.importPrivateKey:
|
|
|
|
case Constants.keypairImportPopup.state.importSeedPhrase:
|
2024-06-07 13:29:09 +00:00
|
|
|
return qsTr("Import key pair")
|
2023-08-04 12:41:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
visible: text !== ""
|
|
|
|
enabled: root.store.primaryPopupButtonEnabled
|
|
|
|
|
|
|
|
icon.name: {
|
2023-08-22 11:22:27 +00:00
|
|
|
if (root.store.currentState.stateType === Constants.keypairImportPopup.state.exportKeypair ||
|
|
|
|
root.store.currentState.stateType === Constants.keypairImportPopup.state.importQr && root.store.syncViaQr) {
|
2023-08-21 10:58:21 +00:00
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2023-08-04 12:41:57 +00:00
|
|
|
if (root.store.userProfileUsingBiometricLogin) {
|
|
|
|
return "touch-id"
|
|
|
|
}
|
|
|
|
|
|
|
|
if (root.store.userProfileIsKeycardUser) {
|
|
|
|
return "keycard"
|
|
|
|
}
|
|
|
|
|
|
|
|
return "password"
|
|
|
|
}
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
root.store.submitPopup(null)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|