fix(@desktop/keycard): additional updates
- `Setup a new Keycard with an existing account` flow improved - code review comments applied - Qml part updated due to the latest `StatusListItem` changes in `StatusQ`
This commit is contained in:
parent
79aece0aeb
commit
07a0cdc680
|
@ -52,6 +52,16 @@ proc newController*(delegate: io_interface.AccessInterface,
|
|||
result.tmpSeedPhraseLength = 0
|
||||
result.tmpSelectedKeyPairIsProfile = false
|
||||
|
||||
proc serviceApplicable[T](service: T): bool =
|
||||
if not service.isNil:
|
||||
return true
|
||||
var serviceName = ""
|
||||
when (service is wallet_account_service.Service):
|
||||
serviceName = "WalletAccountService"
|
||||
when (service is privacy_service.Service):
|
||||
serviceName = "PrivacyService"
|
||||
debug "service doesn't meant to be used from the context it's used, check the context shared popup module is used", service=serviceName
|
||||
|
||||
proc disconnect*(self: Controller) =
|
||||
for id in self.connectionIds:
|
||||
self.events.disconnect(id)
|
||||
|
@ -154,7 +164,7 @@ proc getLastReceivedKeycardData*(self: Controller): tuple[flowType: string, flow
|
|||
proc setMetadataFromKeycard*(self: Controller, cardMetadata: CardMetadata) =
|
||||
self.delegate.setKeyPairStoredOnKeycard(cardMetadata)
|
||||
|
||||
proc cancelCurrentFlow(self: Controller) =
|
||||
proc cancelCurrentFlow*(self: Controller) =
|
||||
self.keycardService.cancelCurrentFlow()
|
||||
# in most cases we're running another flow after canceling the current one,
|
||||
# this way we're giving to the keycard some time to cancel the current flow
|
||||
|
@ -187,14 +197,12 @@ proc terminateCurrentFlow*(self: Controller, lastStepInTheCurrentFlow: bool) =
|
|||
self.events.emit(SignalSharedKeycarModuleFlowTerminated, data)
|
||||
|
||||
proc getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAccountDto] =
|
||||
if self.walletAccountService.isNil:
|
||||
debug "walletAccountService doesn't meant to be used from the context it's used, check the context shared popup module is used"
|
||||
if not serviceApplicable(self.walletAccountService):
|
||||
return
|
||||
return self.walletAccountService.fetchAccounts()
|
||||
|
||||
proc getBalanceForAddress*(self: Controller, address: string): float64 =
|
||||
if self.walletAccountService.isNil:
|
||||
debug "walletAccountService doesn't meant to be used from the context it's used, check the context shared popup module is used"
|
||||
if not serviceApplicable(self.walletAccountService):
|
||||
return
|
||||
return self.walletAccountService.fetchBalanceForAddress(address)
|
||||
|
||||
|
@ -211,26 +219,22 @@ proc generateRandomPUK*(self: Controller): string =
|
|||
return self.keycardService.generateRandomPUK()
|
||||
|
||||
proc isMnemonicBackedUp*(self: Controller): bool =
|
||||
if self.privacyService.isNil:
|
||||
debug "privacyService doesn't meant to be used from the context it's used, check the context shared popup module is used"
|
||||
if not serviceApplicable(self.privacyService):
|
||||
return
|
||||
return self.privacyService.isMnemonicBackedUp()
|
||||
|
||||
proc getMnemonic*(self: Controller): string =
|
||||
if self.privacyService.isNil:
|
||||
debug "privacyService doesn't meant to be used from the context it's used, check the context shared popup module is used"
|
||||
if not serviceApplicable(self.privacyService):
|
||||
return
|
||||
return self.privacyService.getMnemonic()
|
||||
|
||||
proc removeMnemonic*(self: Controller) =
|
||||
if self.privacyService.isNil:
|
||||
debug "privacyService doesn't meant to be used from the context it's used, check the context shared popup module is used"
|
||||
if not serviceApplicable(self.privacyService):
|
||||
return
|
||||
self.privacyService.removeMnemonic()
|
||||
|
||||
proc getMnemonicWordAtIndex*(self: Controller, index: int): string =
|
||||
if self.privacyService.isNil:
|
||||
debug "privacyService doesn't meant to be used from the context it's used, check the context shared popup module is used"
|
||||
if not serviceApplicable(self.privacyService):
|
||||
return
|
||||
return self.privacyService.getMnemonicWordAtIndex(index)
|
||||
|
||||
|
|
|
@ -11,6 +11,9 @@ proc delete*(self: CreatePinState) =
|
|||
method executeBackCommand*(self: CreatePinState, controller: Controller) =
|
||||
controller.setPin("")
|
||||
controller.setPinMatch(false)
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
if not self.getBackState.isNil and self.getBackState.stateType == StateType.SelectExistingKeyPair:
|
||||
controller.cancelCurrentFlow()
|
||||
|
||||
method executeSecondaryCommand*(self: CreatePinState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
|
|
|
@ -8,6 +8,11 @@ proc newInsertKeycardState*(flowType: FlowType, backState: State): InsertKeycard
|
|||
proc delete*(self: InsertKeycardState) =
|
||||
self.State.delete
|
||||
|
||||
method executeBackCommand*(self: InsertKeycardState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
if not self.getBackState.isNil and self.getBackState.stateType == StateType.SelectExistingKeyPair:
|
||||
controller.cancelCurrentFlow()
|
||||
|
||||
method executePrimaryCommand*(self: InsertKeycardState, controller: Controller) =
|
||||
if self.flowType == FlowType.FactoryReset or
|
||||
self.flowType == FlowType.SetupNewKeycard:
|
||||
|
|
|
@ -8,12 +8,19 @@ proc newKeycardInsertedState*(flowType: FlowType, backState: State): KeycardInse
|
|||
proc delete*(self: KeycardInsertedState) =
|
||||
self.State.delete
|
||||
|
||||
method executeBackCommand*(self: KeycardInsertedState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
if not self.getBackState.isNil and self.getBackState.stateType == StateType.SelectExistingKeyPair:
|
||||
controller.cancelCurrentFlow()
|
||||
|
||||
method getNextSecondaryState*(self: KeycardInsertedState, controller: Controller): State =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
if self.stateType == StateType.SelectExistingKeyPair:
|
||||
return createState(StateType.RecognizedKeycard, self.flowType, self)
|
||||
return createState(StateType.ReadingKeycard, self.flowType, self.getBackState)
|
||||
return createState(StateType.ReadingKeycard, self.flowType, nil)
|
||||
|
||||
method executePrimaryCommand*(self: KeycardInsertedState, controller: Controller) =
|
||||
if self.flowType == FlowType.FactoryReset or
|
||||
self.flowType == FlowType.SetupNewKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
|
@ -8,6 +8,11 @@ proc newPluginReaderState*(flowType: FlowType, backState: State): PluginReaderSt
|
|||
proc delete*(self: PluginReaderState) =
|
||||
self.State.delete
|
||||
|
||||
method executeBackCommand*(self: PluginReaderState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
if not self.getBackState.isNil and self.getBackState.stateType == StateType.SelectExistingKeyPair:
|
||||
controller.cancelCurrentFlow()
|
||||
|
||||
method executePrimaryCommand*(self: PluginReaderState, controller: Controller) =
|
||||
if self.flowType == FlowType.FactoryReset or
|
||||
self.flowType == FlowType.SetupNewKeycard:
|
||||
|
|
|
@ -8,6 +8,11 @@ proc newReadingKeycardState*(flowType: FlowType, backState: State): ReadingKeyca
|
|||
proc delete*(self: ReadingKeycardState) =
|
||||
self.State.delete
|
||||
|
||||
method executeBackCommand*(self: ReadingKeycardState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
if not self.getBackState.isNil and self.getBackState.stateType == StateType.SelectExistingKeyPair:
|
||||
controller.cancelCurrentFlow()
|
||||
|
||||
method executePrimaryCommand*(self: ReadingKeycardState, controller: Controller) =
|
||||
if self.flowType == FlowType.FactoryReset or
|
||||
self.flowType == FlowType.SetupNewKeycard:
|
||||
|
|
|
@ -8,6 +8,11 @@ proc newRecognizedKeycardState*(flowType: FlowType, backState: State): Recognize
|
|||
proc delete*(self: RecognizedKeycardState) =
|
||||
self.State.delete
|
||||
|
||||
method executeBackCommand*(self: RecognizedKeycardState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
if not self.getBackState.isNil and self.getBackState.stateType == StateType.SelectExistingKeyPair:
|
||||
controller.cancelCurrentFlow()
|
||||
|
||||
method executePrimaryCommand*(self: RecognizedKeycardState, controller: Controller) =
|
||||
if self.flowType == FlowType.FactoryReset or
|
||||
self.flowType == FlowType.SetupNewKeycard:
|
||||
|
|
|
@ -160,9 +160,13 @@ proc ensureReaderAndCardPresence*(state: State, keycardFlowType: string, keycard
|
|||
keycardEvent.error == ErrorConnection:
|
||||
if state.stateType == StateType.InsertKeycard:
|
||||
return nil
|
||||
return createState(StateType.InsertKeycard, state.flowType, state)
|
||||
if state.stateType == StateType.SelectExistingKeyPair:
|
||||
return createState(StateType.InsertKeycard, state.flowType, state)
|
||||
return createState(StateType.InsertKeycard, state.flowType, state.getBackState)
|
||||
if keycardFlowType == ResponseTypeValueCardInserted:
|
||||
controller.setKeycardData(getPredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.WronglyInsertedCard, add = false))
|
||||
if state.stateType == StateType.SelectExistingKeyPair:
|
||||
return createState(StateType.InsertKeycard, state.flowType, state)
|
||||
return createState(StateType.KeycardInserted, state.flowType, state.getBackState)
|
||||
|
||||
proc ensureReaderAndCardPresenceAndResolveNextState*(state: State, keycardFlowType: string, keycardEvent: KeycardEvent, controller: Controller): State =
|
||||
|
@ -222,4 +226,6 @@ proc ensureReaderAndCardPresenceAndResolveNextState*(state: State, keycardFlowTy
|
|||
if keycardFlowType == ResponseTypeValueEnterNewPIN and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorRequireInit:
|
||||
if state.stateType == StateType.SelectExistingKeyPair:
|
||||
return createState(StateType.RecognizedKeycard, state.flowType, state)
|
||||
return createState(StateType.RecognizedKeycard, state.flowType, state.getBackState)
|
|
@ -83,8 +83,8 @@ QtObject:
|
|||
of ModelRole.DerivedFrom:
|
||||
result = newQVariant(item.derivedFrom)
|
||||
|
||||
proc findItemByDerivedFromAddress*(self: KeyPairModel, address: string): KeyPairItem =
|
||||
proc findItemByPublicKey*(self: KeyPairModel, publicKey: string): KeyPairItem =
|
||||
for i in 0 ..< self.items.len:
|
||||
if(self.items[i].derivedFrom == address):
|
||||
if(self.items[i].pubKey == publicKey):
|
||||
return self.items[i]
|
||||
return nil
|
|
@ -193,7 +193,7 @@ proc prepareKeyPairsModel[T](self: Module[T]) =
|
|||
if self.isProfileKeyPairMigrated():
|
||||
continue
|
||||
if item.isNil:
|
||||
item = initKeyPairItem(pubKey = singletonInstance.userProfile.getPubKey(),
|
||||
item = initKeyPairItem(pubKey = a.publicKey,
|
||||
name = singletonInstance.userProfile.getName(),
|
||||
image = singletonInstance.userProfile.getIcon(),
|
||||
icon = "",
|
||||
|
@ -208,7 +208,7 @@ proc prepareKeyPairsModel[T](self: Module[T]) =
|
|||
if a.walletType == WalletTypeSeed:
|
||||
let diffImports = countOfKeyPairsForType(items, KeyPairType.SeedImport)
|
||||
if item.isNil:
|
||||
item = initKeyPairItem(pubKey = "",
|
||||
item = initKeyPairItem(pubKey = a.publicKey,
|
||||
name = "Seed Phrase " & $(diffImports + 1), # string created here should be transalted, but so far it's like it is
|
||||
image = "",
|
||||
icon = "key_pair_seed_phrase",
|
||||
|
@ -220,7 +220,7 @@ proc prepareKeyPairsModel[T](self: Module[T]) =
|
|||
if a.walletType == WalletTypeKey:
|
||||
let diffImports = countOfKeyPairsForType(items, KeyPairType.PrivateKeyImport)
|
||||
if item.isNil:
|
||||
item = initKeyPairItem(pubKey = "",
|
||||
item = initKeyPairItem(pubKey = a.publicKey,
|
||||
name = "Key " & $(diffImports + 1), # string created here should be transalted, but so far it's like it is
|
||||
image = "",
|
||||
icon = "key_pair_private_key",
|
||||
|
@ -229,11 +229,9 @@ proc prepareKeyPairsModel[T](self: Module[T]) =
|
|||
items.add(item)
|
||||
item.addAccount(a.name, a.path, a.address, a.emoji, a.color, icon = "", balance = 0.0)
|
||||
continue
|
||||
self.view.createKeyPairModel(items)
|
||||
if items.len == 0:
|
||||
debug "sm_there is no any key pair for the logged in user that is not already migrated to a keycard"
|
||||
return
|
||||
self.view.setSelectedKeyPairByTheAddressItIsDerivedFrom(items[0].derivedFrom())
|
||||
self.view.createKeyPairModel(items)
|
||||
|
||||
method runFlow*[T](self: Module[T], flowToRun: FlowType) =
|
||||
if flowToRun == FlowType.General:
|
||||
|
|
|
@ -111,8 +111,8 @@ QtObject:
|
|||
return self.selectedKeyPairItemVariant
|
||||
QtProperty[QVariant] selectedKeyPairItem:
|
||||
read = getSelectedKeyPairItem
|
||||
proc setSelectedKeyPairByTheAddressItIsDerivedFrom*(self: View, address: string) {.slot.} =
|
||||
let item = self.keyPairModel.findItemByDerivedFromAddress(address)
|
||||
proc setSelectedKeyPair*(self: View, publicKey: string) {.slot.} =
|
||||
let item = self.keyPairModel.findItemByPublicKey(publicKey)
|
||||
self.delegate.setSelectedKeyPair(item)
|
||||
self.selectedKeyPairItem.setItem(item)
|
||||
|
||||
|
|
|
@ -12,12 +12,4 @@ method getNextPrimaryState*(self: UserProfileImportSeedPhraseState, controller:
|
|||
return createState(StateType.UserProfileEnterSeedPhrase, FlowType.FirstRunNewUserImportSeedPhrase, self)
|
||||
|
||||
method getNextSecondaryState*(self: UserProfileImportSeedPhraseState, controller: Controller): State =
|
||||
return createState(StateType.UserProfileEnterSeedPhrase, FlowType.FirstRunNewUserImportSeedPhraseIntoKeycard, self.getBackState)
|
||||
|
||||
# method executeSecondaryCommand*(self: UserProfileImportSeedPhraseState, controller: Controller) =
|
||||
# if self.flowType == FlowType.FirstRunNewUserImportSeedPhraseIntoKeycard:
|
||||
# controller.runLoadAccountFlow()
|
||||
|
||||
# method resolveKeycardNextState*(self: UserProfileImportSeedPhraseState, keycardFlowType: string, keycardEvent: KeycardEvent,
|
||||
# controller: Controller): State =
|
||||
# return ensureReaderAndCardPresenceAndResolveNextOnboardingState(self, keycardFlowType, keycardEvent, controller)
|
||||
return createState(StateType.UserProfileEnterSeedPhrase, FlowType.FirstRunNewUserImportSeedPhraseIntoKeycard, self.getBackState)
|
|
@ -86,7 +86,7 @@ Item {
|
|||
else if(root.state === Constants.startupState.keycardRepeatPin) {
|
||||
let pinsMatch = root.startupStore.checkRepeatedKeycardPinWhileTyping(pinInput)
|
||||
if (pinsMatch) {
|
||||
info.text = qsTr("It is very important that you do not loose this PIN")
|
||||
info.text = qsTr("It is very important that you do not lose this PIN")
|
||||
root.startupStore.doPrimaryAction()
|
||||
} else {
|
||||
info.text = qsTr("PINs don't match")
|
||||
|
@ -120,7 +120,7 @@ Item {
|
|||
}
|
||||
PropertyChanges {
|
||||
target: info
|
||||
text: qsTr("It is very important that you do not loose this PIN")
|
||||
text: qsTr("It is very important that you do not lose this PIN")
|
||||
}
|
||||
PropertyChanges {
|
||||
target: message
|
||||
|
@ -136,7 +136,7 @@ Item {
|
|||
}
|
||||
PropertyChanges {
|
||||
target: info
|
||||
text: qsTr("It is very important that you do not loose this PIN")
|
||||
text: qsTr("It is very important that you do not lose this PIN")
|
||||
color: Theme.palette.dangerColor1
|
||||
}
|
||||
PropertyChanges {
|
||||
|
|
|
@ -96,7 +96,7 @@ Item {
|
|||
Repeater {
|
||||
model: root.tabs
|
||||
StatusSwitchTabButton {
|
||||
text: qsTr("%1 words").arg(modelData)
|
||||
text: qsTr("%n word(s)", "", modelData)
|
||||
id: seedPhraseWords
|
||||
objectName: `${modelData}SeedButton`
|
||||
}
|
||||
|
|
|
@ -251,7 +251,7 @@ StatusGridView {
|
|||
Repeater {
|
||||
model: _internal.seedPhraseWordsOptions
|
||||
StatusSwitchTabButton {
|
||||
text: qsTr("%1 words").arg(modelData)
|
||||
text: qsTr("%n word(s)", "", modelData)
|
||||
}
|
||||
}
|
||||
onCurrentIndexChanged: {
|
||||
|
|
|
@ -51,10 +51,10 @@ StatusModal {
|
|||
id: d
|
||||
property bool primaryButtonEnabled: false
|
||||
property bool seedPhraseRevealed: false
|
||||
property bool disablePopupClose: root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard ||
|
||||
root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.migratingKeyPair ||
|
||||
(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keyPairMigrateSuccess &&
|
||||
root.sharedKeycardModule.migratingProfileKeyPair())
|
||||
readonly property bool disablePopupClose: root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard ||
|
||||
root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.migratingKeyPair ||
|
||||
(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keyPairMigrateSuccess &&
|
||||
root.sharedKeycardModule.migratingProfileKeyPair())
|
||||
|
||||
onDisablePopupCloseChanged: {
|
||||
hasCloseButton = !disablePopupClose
|
||||
|
@ -189,6 +189,14 @@ StatusModal {
|
|||
id: selectKeyPairComponent
|
||||
SelectKeyPair {
|
||||
sharedKeycardModule: root.sharedKeycardModule
|
||||
|
||||
Component.onCompleted: {
|
||||
d.primaryButtonEnabled = false
|
||||
}
|
||||
|
||||
onKeyPairSelected: {
|
||||
d.primaryButtonEnabled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -414,16 +422,15 @@ StatusModal {
|
|||
}
|
||||
}
|
||||
else if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.setupNewKeycard) {
|
||||
if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.factoryResetConfirmation ||
|
||||
if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.selectExistingKeyPair ||
|
||||
root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.factoryResetConfirmation ||
|
||||
root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.factoryResetConfirmationDisplayMetadata ||
|
||||
root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.seedPhraseDisplay ||
|
||||
root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.seedPhraseEnterWords ||
|
||||
root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.enterSeedPhrase) {
|
||||
return d.primaryButtonEnabled
|
||||
}
|
||||
if ((root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.selectExistingKeyPair &&
|
||||
root.sharedKeycardModule.keyPairModel.count === 0) ||
|
||||
root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.pluginReader ||
|
||||
if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.pluginReader ||
|
||||
root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard ||
|
||||
root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted ||
|
||||
root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard ||
|
||||
|
|
|
@ -16,6 +16,7 @@ StatusListItem {
|
|||
property ButtonGroup buttonGroup
|
||||
property bool usedAsSelectOption: false
|
||||
|
||||
property int keyPairType: Constants.keycard.keyPairType.unknown
|
||||
property string keyPairPubKey: ""
|
||||
property string keyPairName: ""
|
||||
property string keyPairIcon: ""
|
||||
|
@ -23,29 +24,28 @@ StatusListItem {
|
|||
property string keyPairDerivedFrom: ""
|
||||
property string keyPairAccounts: ""
|
||||
|
||||
signal keyPairSelected()
|
||||
|
||||
color: Style.current.grey
|
||||
title: root.keyPairName
|
||||
titleAsideText: Utils.getElidedCompressedPk(root.keyPairPubKey)
|
||||
titleAsideText: root.keyPairType === Constants.keycard.keyPairType.profile?
|
||||
Utils.getElidedCompressedPk(d.myPublicKey) : ""
|
||||
|
||||
image {
|
||||
width: 40
|
||||
height: 40
|
||||
source: root.keyPairImage
|
||||
}
|
||||
|
||||
icon {
|
||||
asset {
|
||||
width: root.keyPairIcon? 24 : 40
|
||||
height: root.keyPairIcon? 24 : 40
|
||||
name: root.keyPairIcon
|
||||
color: Utils.colorForPubkey(root.keyPairPubKey)
|
||||
letterSize: Math.max(4, this.image.width / 2.4)
|
||||
name: root.keyPairImage? root.keyPairImage : root.keyPairIcon
|
||||
color: root.keyPairType === Constants.keycard.keyPairType.profile?
|
||||
Utils.colorForPubkey(d.myPublicKey) : Theme.palette.primaryColor1
|
||||
letterSize: Math.max(4, this.width / 2.4)
|
||||
charactersLen: 2
|
||||
isLetterIdenticon: !root.keyPairIcon && !this.image.source.toString()
|
||||
background.color: Theme.palette.primaryColor3
|
||||
isLetterIdenticon: !root.keyPairIcon && !this.name.toString()
|
||||
bgColor: Theme.palette.primaryColor3
|
||||
}
|
||||
|
||||
ringSettings {
|
||||
ringSpecModel: Utils.getColorHashAsJson(root.keyPairPubKey)
|
||||
ringSpecModel: root.keyPairType === Constants.keycard.keyPairType.profile?
|
||||
Utils.getColorHashAsJson(d.myPublicKey) : []
|
||||
ringPxSize: Math.max(this.icon.width / 24.0)
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ StatusListItem {
|
|||
height: Style.current.bigPadding
|
||||
radius: 6
|
||||
closeButtonVisible: false
|
||||
icon {
|
||||
asset {
|
||||
emoji: model.emoji
|
||||
emojiSize: Emoji.size.verySmall
|
||||
isLetterIdenticon: !!model.emoji
|
||||
|
@ -72,23 +72,17 @@ StatusListItem {
|
|||
|
||||
components: [
|
||||
StatusRadioButton {
|
||||
id: radioButton
|
||||
visible: root.usedAsSelectOption
|
||||
ButtonGroup.group: root.buttonGroup
|
||||
onCheckedChanged: {
|
||||
if (!root.usedAsSelectOption)
|
||||
return
|
||||
let checkCondition = root.sharedKeycardModule.selectedKeyPairItem.derivedFrom === root.keyPairDerivedFrom
|
||||
if (checked && checked != checkCondition) {
|
||||
root.sharedKeycardModule.setSelectedKeyPairByTheAddressItIsDerivedFrom(root.keyPairDerivedFrom)
|
||||
if (checked) {
|
||||
root.sharedKeycardModule.setSelectedKeyPair(root.keyPairPubKey)
|
||||
root.keyPairSelected()
|
||||
}
|
||||
}
|
||||
Component.onCompleted: {
|
||||
if (!root.usedAsSelectOption)
|
||||
return
|
||||
checked = Qt.binding(function() {
|
||||
return root.sharedKeycardModule.selectedKeyPairItem.derivedFrom === root.keyPairDerivedFrom
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
|
@ -109,9 +103,14 @@ StatusListItem {
|
|||
}
|
||||
}
|
||||
|
||||
QtObject {
|
||||
id: d
|
||||
property string myPublicKey: userProfile.pubKey
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
if (!root.usedAsSelectOption)
|
||||
return
|
||||
root.sharedKeycardModule.setSelectedKeyPairByTheAddressItIsDerivedFrom(root.keyPairDerivedFrom)
|
||||
radioButton.checked = true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
import QtQuick 2.14
|
||||
import QtQml.Models 2.14
|
||||
import QtQuick.Controls 2.14
|
||||
|
||||
import StatusQ.Core.Theme 0.1
|
||||
import StatusQ.Core.Utils 0.1
|
||||
import StatusQ.Components 0.1
|
||||
import StatusQ.Controls 0.1
|
||||
|
||||
import utils 1.0
|
||||
|
||||
import SortFilterProxyModel 0.2
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
|
@ -17,54 +13,15 @@ Item {
|
|||
property var keyPairModel
|
||||
property ButtonGroup buttonGroup
|
||||
|
||||
DelegateModel {
|
||||
id: delegateModel
|
||||
signal keyPairSelected()
|
||||
|
||||
function update() {
|
||||
var visible = [];
|
||||
for (var i = 0; i < items.count; ++i) {
|
||||
var item = items.get(i);
|
||||
if(root.filterProfilePair) {
|
||||
if (item.model.pairType === Constants.keycard.keyPairType.profile)
|
||||
visible.push(item);
|
||||
}
|
||||
else if (item.model.pairType !== Constants.keycard.keyPairType.profile) {
|
||||
visible.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < visible.length; ++i) {
|
||||
item = visible[i];
|
||||
item.inPairType = true;
|
||||
if (item.pairTypeIndex !== i) {
|
||||
visibleItems.move(item.pairTypeIndex, i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
model: root.keyPairModel
|
||||
|
||||
groups: [DelegateModelGroup {
|
||||
id: visibleItems
|
||||
name: "pairType"
|
||||
includeByDefault: false
|
||||
}]
|
||||
|
||||
filterOnGroup: "pairType"
|
||||
items.onChanged: update()
|
||||
delegate: KeyPairItem {
|
||||
width: parent.width
|
||||
|
||||
sharedKeycardModule: root.sharedKeycardModule
|
||||
buttonGroup: root.buttonGroup
|
||||
usedAsSelectOption: true
|
||||
|
||||
keyPairPubKey: model.pubKey
|
||||
keyPairName: model.name
|
||||
keyPairIcon: model.icon
|
||||
keyPairImage: model.image
|
||||
keyPairDerivedFrom: model.derivedFrom
|
||||
keyPairAccounts: model.accounts
|
||||
SortFilterProxyModel {
|
||||
id: proxyModel
|
||||
sourceModel: root.keyPairModel
|
||||
filters: ValueFilter {
|
||||
roleName: "pairType"
|
||||
value: Constants.keycard.keyPairType.profile
|
||||
inverted: !root.filterProfilePair
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,6 +29,25 @@ Item {
|
|||
anchors.fill: parent
|
||||
spacing: Style.current.padding
|
||||
clip: true
|
||||
model: delegateModel
|
||||
model: proxyModel
|
||||
delegate: KeyPairItem {
|
||||
width: ListView.view.width
|
||||
|
||||
sharedKeycardModule: root.sharedKeycardModule
|
||||
buttonGroup: root.buttonGroup
|
||||
usedAsSelectOption: true
|
||||
|
||||
keyPairType: model.pairType
|
||||
keyPairPubKey: model.pubKey
|
||||
keyPairName: model.name
|
||||
keyPairIcon: model.icon
|
||||
keyPairImage: model.image
|
||||
keyPairDerivedFrom: model.derivedFrom
|
||||
keyPairAccounts: model.accounts
|
||||
|
||||
onKeyPairSelected: {
|
||||
root.keyPairSelected()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ Rectangle {
|
|||
|
||||
color: Style.current.grey
|
||||
radius: Style.current.halfPadding
|
||||
clip: true
|
||||
implicitWidth: 448
|
||||
implicitHeight: 198
|
||||
|
||||
|
@ -61,7 +60,7 @@ Rectangle {
|
|||
color: "transparent"
|
||||
title: root.keyPairName
|
||||
|
||||
icon {
|
||||
asset {
|
||||
width: 24
|
||||
height: 24
|
||||
name: root.keyPairIcon
|
||||
|
@ -69,7 +68,7 @@ Rectangle {
|
|||
letterSize: Math.max(4, this.image.width / 2.4)
|
||||
charactersLen: 2
|
||||
isLetterIdenticon: false
|
||||
background.color: Theme.palette.primaryColor3
|
||||
bgColor: Theme.palette.primaryColor3
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ Item {
|
|||
Repeater {
|
||||
model: d.tabs
|
||||
StatusSwitchTabButton {
|
||||
text: qsTr("%1 words").arg(modelData)
|
||||
text: qsTr("%n word(s)", "", modelData)
|
||||
id: seedPhraseWords
|
||||
objectName: `${modelData}SeedButton`
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ Item {
|
|||
Component {
|
||||
id: knownKeyPairComponent
|
||||
KeyPairItem {
|
||||
keyPairType: root.sharedKeycardModule.keyPairStoredOnKeycard.pairType
|
||||
keyPairPubKey: root.sharedKeycardModule.keyPairStoredOnKeycard.pubKey
|
||||
keyPairName: root.sharedKeycardModule.keyPairStoredOnKeycard.name
|
||||
keyPairIcon: root.sharedKeycardModule.keyPairStoredOnKeycard.icon
|
||||
|
@ -129,7 +130,7 @@ Item {
|
|||
Item {
|
||||
visible: !loader.active
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: visible? true : false
|
||||
Layout.fillHeight: visible
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ Item {
|
|||
QtObject {
|
||||
id: d
|
||||
|
||||
property bool hideKeyPair: root.sharedKeycardModule.keycardData & Constants.predefinedKeycardData.hideKeyPair
|
||||
readonly property bool hideKeyPair: root.sharedKeycardModule.keycardData & Constants.predefinedKeycardData.hideKeyPair
|
||||
}
|
||||
|
||||
Timer {
|
||||
|
@ -75,6 +75,7 @@ Item {
|
|||
Component {
|
||||
id: keyPairComponent
|
||||
KeyPairItem {
|
||||
keyPairType: root.sharedKeycardModule.selectedKeyPairItem.pairType
|
||||
keyPairPubKey: root.sharedKeycardModule.selectedKeyPairItem.pubKey
|
||||
keyPairName: root.sharedKeycardModule.selectedKeyPairItem.name
|
||||
keyPairIcon: root.sharedKeycardModule.selectedKeyPairItem.icon
|
||||
|
@ -87,6 +88,7 @@ Item {
|
|||
Component {
|
||||
id: knownKeyPairComponent
|
||||
KeyPairItem {
|
||||
keyPairType: root.sharedKeycardModule.keyPairStoredOnKeycard.pairType
|
||||
keyPairPubKey: root.sharedKeycardModule.keyPairStoredOnKeycard.pubKey
|
||||
keyPairName: root.sharedKeycardModule.keyPairStoredOnKeycard.name
|
||||
keyPairIcon: root.sharedKeycardModule.keyPairStoredOnKeycard.icon
|
||||
|
@ -220,7 +222,7 @@ Item {
|
|||
Item {
|
||||
visible: !loader.active
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: this.visible? true : false
|
||||
Layout.fillHeight: visible
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ Item {
|
|||
else if(root.state === Constants.keycardSharedState.repeatPin) {
|
||||
let pinsMatch = root.sharedKeycardModule.checkRepeatedKeycardPinWhileTyping(pinInput)
|
||||
if (pinsMatch) {
|
||||
info.text = qsTr("It is very important that you do not loose this PIN")
|
||||
info.text = qsTr("It is very important that you do not lose this PIN")
|
||||
root.sharedKeycardModule.currentState.doTertiaryAction()
|
||||
} else {
|
||||
info.text = qsTr("PINs don't match")
|
||||
|
@ -119,6 +119,7 @@ Item {
|
|||
root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.pinSet)
|
||||
|
||||
sourceComponent: KeyPairItem {
|
||||
keyPairType: root.sharedKeycardModule.selectedKeyPairItem.pairType
|
||||
keyPairPubKey: root.sharedKeycardModule.selectedKeyPairItem.pubKey
|
||||
keyPairName: root.sharedKeycardModule.selectedKeyPairItem.name
|
||||
keyPairIcon: root.sharedKeycardModule.selectedKeyPairItem.icon
|
||||
|
@ -198,7 +199,7 @@ Item {
|
|||
}
|
||||
PropertyChanges {
|
||||
target: info
|
||||
text: qsTr("It is very important that you do not loose this PIN")
|
||||
text: qsTr("It is very important that you do not lose this PIN")
|
||||
color: Theme.palette.dangerColor1
|
||||
font.pixelSize: Constants.keycard.general.fontSize3
|
||||
}
|
||||
|
@ -223,7 +224,7 @@ Item {
|
|||
}
|
||||
PropertyChanges {
|
||||
target: info
|
||||
text: qsTr("It is very important that you do not loose this PIN")
|
||||
text: qsTr("It is very important that you do not lose this PIN")
|
||||
color: Theme.palette.dangerColor1
|
||||
font.pixelSize: Constants.keycard.general.fontSize3
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ Item {
|
|||
anchors.leftMargin: Style.current.xlPadding
|
||||
anchors.rightMargin: Style.current.xlPadding
|
||||
spacing: Style.current.padding
|
||||
clip: true
|
||||
|
||||
StatusBaseText {
|
||||
id: title
|
||||
|
|
|
@ -18,6 +18,8 @@ Item {
|
|||
|
||||
property var sharedKeycardModule
|
||||
|
||||
signal keyPairSelected()
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: Style.current.xlPadding
|
||||
|
@ -79,6 +81,10 @@ Item {
|
|||
filterProfilePair: true
|
||||
keyPairModel: root.sharedKeycardModule.keyPairModel
|
||||
buttonGroup: keyPairsButtonGroup
|
||||
|
||||
onKeyPairSelected: {
|
||||
root.keyPairSelected()
|
||||
}
|
||||
}
|
||||
|
||||
StatusBaseText {
|
||||
|
@ -104,6 +110,10 @@ Item {
|
|||
sharedKeycardModule: root.sharedKeycardModule
|
||||
keyPairModel: root.sharedKeycardModule.keyPairModel
|
||||
buttonGroup: keyPairsButtonGroup
|
||||
|
||||
onKeyPairSelected: {
|
||||
root.keyPairSelected()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -373,6 +373,7 @@ QtObject {
|
|||
}
|
||||
|
||||
readonly property QtObject keyPairType: QtObject {
|
||||
readonly property int unknown: -1
|
||||
readonly property int profile: 0
|
||||
readonly property int seedImport: 1
|
||||
readonly property int privateKeyImport: 2
|
||||
|
|
Loading…
Reference in New Issue