2023-03-30 12:55:07 +00:00
import QtQuick 2.15
import QtQuick . Controls 2.15
2023-12-11 12:58:15 +00:00
import QtQml . Models 2.15
2023-03-30 12:55:07 +00:00
import QtQuick . Layouts 1.15
import StatusQ . Core 0.1
2023-12-11 12:58:15 +00:00
import StatusQ . Components 0.1
2023-03-30 12:55:07 +00:00
import StatusQ . Core . Theme 0.1
2023-12-11 12:58:15 +00:00
import StatusQ . Core . Utils 0.1 as StatusQUtils
2023-03-30 12:55:07 +00:00
import StatusQ . Controls 0.1
2023-12-11 12:58:15 +00:00
import StatusQ . Popups . Dialog 0.1
import AppLayouts . Wallet 1.0
2023-03-30 12:55:07 +00:00
import utils 1.0
import shared . controls 1.0
2023-12-11 12:58:15 +00:00
StatusDialog {
2023-03-30 12:55:07 +00:00
id: root
2023-12-11 12:58:15 +00:00
required property string accountType
2023-03-30 12:55:07 +00:00
required property string accountName
required property string accountAddress
required property string accountDerivationPath
2023-12-11 12:58:15 +00:00
required property string preferredSharingNetworkShortNames
required property string emoji
required property string color
2023-03-30 12:55:07 +00:00
2023-05-04 14:34:00 +00:00
signal removeAccount ( string address )
2023-03-30 12:55:07 +00:00
2023-12-11 12:58:15 +00:00
width: 521
2023-03-30 12:55:07 +00:00
focus: visible
padding: Style . current . padding
QtObject {
id: d
readonly property int checkboxHeight: 24
readonly property real lineHeight: 1.2
function confirm ( ) {
2023-12-11 12:58:15 +00:00
if ( root . accountType !== Constants . watchWalletType && ! derivationPathWritten . checked ) {
2023-03-30 12:55:07 +00:00
return
}
2023-05-04 14:34:00 +00:00
root . removeAccount ( root . accountAddress )
2023-03-30 12:55:07 +00:00
}
}
2023-12-11 12:58:15 +00:00
header: StatusDialogHeader {
headline.title: qsTr ( "Remove %1" ) . arg ( root . accountName )
headline.subtitle: WalletUtils . colorizedChainPrefix ( root . preferredSharingNetworkShortNames ) + StatusQUtils . Utils . elideText ( root . accountAddress , 6 , 4 )
actions.closeButton.onClicked: root . close ( )
leftComponent: StatusSmartIdenticon {
asset.emoji: root . emoji
asset.color: root . color
}
}
2023-03-30 12:55:07 +00:00
contentItem: ColumnLayout {
spacing: Style . current . halfPadding
StatusBaseText {
2023-04-13 10:27:56 +00:00
objectName: "RemoveAccountPopup-Notification"
2023-03-30 12:55:07 +00:00
Layout.preferredWidth: parent . width
wrapMode: Text . WordWrap
textFormat: Text . RichText
font.pixelSize: Style . current . primaryTextFontSize
lineHeight: d . lineHeight
2023-12-11 12:58:15 +00:00
text: {
switch ( root . accountType ) {
case Constants.generatedWalletType: return qsTr ( "Are you sure you want to remove %1? The account will be removed from all of your synced devices. Make sure you have a backup of your keys or recovery phrase before proceeding. %2 Copying the derivation path to this account now will enable you to import it again at a later date should you wish to do so:" ) . arg ( "<b>%1</b>" . arg ( root . accountName ) ) . arg ( "<br/><br/>" )
case Constants.watchWalletType: return qsTr ( "Are you sure you want to remove %1? The address will be removed from all of your synced devices." ) . arg ( "<b>%1</b>" . arg ( root . accountName ) )
case Constants.keyWalletType: return qsTr ( "Are you sure you want to remove %1 and it's associated private key? The account and private key will be removed from all of your synced devices." ) . arg ( "<b>%1</b>" . arg ( root . accountName ) )
case Constants.seedWalletType: return qsTr ( "Are you sure you want to remove %1? The account will be removed from all of your synced devices. Copying the derivation path to this account now will enable you to import it again at a later date should you with to do so:" ) . arg ( "<b>%1</b>" . arg ( root . accountName ) )
}
}
2023-03-30 12:55:07 +00:00
}
StatusBaseText {
Layout.preferredWidth: parent . width
Layout.topMargin: Style . current . padding
2023-12-11 12:58:15 +00:00
visible: root . accountType === Constants . generatedWalletType || root . accountType === Constants . seedWalletType
2023-03-30 12:55:07 +00:00
text: qsTr ( "Derivation path for %1" ) . arg ( root . accountName )
font.pixelSize: Style . current . primaryTextFontSize
lineHeight: d . lineHeight
}
StatusInput {
2023-04-13 10:27:56 +00:00
objectName: "RemoveAccountPopup-DerivationPath"
2023-03-30 12:55:07 +00:00
Layout.preferredWidth: parent . width
2023-12-11 12:58:15 +00:00
visible: root . accountType === Constants . generatedWalletType || root . accountType === Constants . seedWalletType
2023-03-30 12:55:07 +00:00
input.edit.enabled: false
text: root . accountDerivationPath
input.background.color: "transparent"
input.background.border.color: Theme . palette . baseColor2
input.rightComponent: CopyButton {
textToCopy: root . accountDerivationPath
}
}
StatusCheckBox {
id: derivationPathWritten
2023-04-13 10:27:56 +00:00
objectName: "RemoveAccountPopup-HavePenPaper"
2023-03-30 12:55:07 +00:00
Layout.preferredWidth: parent . width
Layout.preferredHeight: d . checkboxHeight
Layout.topMargin: Style . current . padding
2023-12-11 12:58:15 +00:00
visible: root . accountType !== Constants . watchWalletType
2023-03-30 12:55:07 +00:00
spacing: Style . current . padding
font.pixelSize: Style . current . primaryTextFontSize
2023-12-11 12:58:15 +00:00
text: {
if ( root . accountType === Constants . keyWalletType ) {
return qsTr ( "I have a copy of the private key" )
}
return qsTr ( "I have taken note of the derivation path" )
}
2023-03-30 12:55:07 +00:00
}
}
2023-12-11 12:58:15 +00:00
footer: StatusDialogFooter {
spacing: Style . current . padding
rightButtons: ObjectModel {
StatusFlatButton {
objectName: "RemoveAccountPopup-CancelButton"
text: qsTr ( "Cancel" )
type: StatusBaseButton . Type . Normal
onClicked: {
root . close ( )
}
2023-03-30 12:55:07 +00:00
}
2023-12-11 12:58:15 +00:00
StatusButton {
objectName: "RemoveAccountPopup-ConfirmButton"
text: qsTr ( "Remove %1" ) . arg ( root . accountName )
type: StatusBaseButton . Type . Danger
enabled: root . accountType === Constants . watchWalletType || derivationPathWritten . checked
focus: true
Keys.onReturnPressed: function ( event ) {
d . confirm ( )
}
onClicked: {
d . confirm ( )
}
2023-03-30 12:55:07 +00:00
}
}
2023-12-11 12:58:15 +00:00
}
2023-03-30 12:55:07 +00:00
}