diff --git a/src/app/global/app_translatable_constants.nim b/src/app/global/app_translatable_constants.nim index 66927636b4..f3d299ef16 100644 --- a/src/app/global/app_translatable_constants.nim +++ b/src/app/global/app_translatable_constants.nim @@ -2,4 +2,5 @@ ## should be stated here and translated via translations map in `Constants.qml` to be displayed well in user's language const LOGIN_ACCOUNTS_LIST_ADD_NEW_USER* = "LOGIN-ACCOUNTS-LIST-ADD-NEW-USER" const LOGIN_ACCOUNTS_LIST_ADD_EXISTING_USER* = "LOGIN-ACCOUNTS-LIST-ADD-EXISTING-USER" -const LOGIN_ACCOUNTS_LIST_LOST_KEYCARD* = "LOGIN-ACCOUNTS-LIST-LOST-KEYCARD" \ No newline at end of file +const LOGIN_ACCOUNTS_LIST_LOST_KEYCARD* = "LOGIN-ACCOUNTS-LIST-LOST-KEYCARD" +const KEYCARD_ACCOUNT_NAME_OF_UNKNOWN_WALLET_ACCOUNT* = "KEYCARD-ACCOUNT-NAME-OF-UNKNOWN-WALLET-ACCOUNT" \ No newline at end of file diff --git a/src/app/modules/main/profile_section/keycard/module.nim b/src/app/modules/main/profile_section/keycard/module.nim index c3eb0059fd..4b6499417b 100644 --- a/src/app/modules/main/profile_section/keycard/module.nim +++ b/src/app/modules/main/profile_section/keycard/module.nim @@ -3,6 +3,7 @@ import NimQml, chronicles, json, marshal, sequtils, sugar, strutils import ./io_interface, ./view, ./controller import ../io_interface as delegate_interface +import ../../../../global/app_translatable_constants as atc import ../../../../global/global_singleton import ../../../../core/eventemitter @@ -252,7 +253,7 @@ proc buildKeycardItem(self: Module, walletAccounts: seq[WalletAccountDto], keyPa var i = 0 for ua in unknownAccountsAddresses: i.inc - let name = "acc" & $i + let name = atc.KEYCARD_ACCOUNT_NAME_OF_UNKNOWN_WALLET_ACCOUNT & $i item.addAccount(newKeyPairAccountItem(name, path = "", ua, pubKey = "", emoji = "", color = "#939BA1", icon = "wallet", balance = 0.0)) return item diff --git a/src/app/modules/shared_modules/keycard_popup/module.nim b/src/app/modules/shared_modules/keycard_popup/module.nim index 1f20506e53..0a2b4e5729 100644 --- a/src/app/modules/shared_modules/keycard_popup/module.nim +++ b/src/app/modules/shared_modules/keycard_popup/module.nim @@ -5,6 +5,7 @@ import view, controller import internal/[state, state_factory] import ../../shared/keypairs import ../../shared_models/[keypair_model, keypair_item] +import ../../../global/app_translatable_constants as atc import ../../../global/global_singleton import ../../../core/eventemitter @@ -534,12 +535,6 @@ method setSelectedKeyPair*[T](self: Module[T], item: KeyPairItem) = paths, keyPairDto) self.setKeyPairForProcessing(item) -proc generateRandomColor[T](self: Module[T]): string = - let r = rand(0 .. 255) - let g = rand(0 .. 255) - let b = rand(0 .. 255) - return "#" & r.toHex(2) & g.toHex(2) & b.toHex(2) - proc updateKeyPairItemIfDataAreKnown[T](self: Module[T], address: string, item: var KeyPairItem): bool = let accounts = self.controller.getWalletAccounts() for a in accounts: @@ -575,13 +570,16 @@ proc buildKeyPairItemBasedOnCardMetadata[T](self: Module[T], cardMetadata: CardM result.item.setKeyUid(currKp.getKeyUid()) result.item.setPubKey(currKp.getPubKey()) result.knownKeyPair = true + var unknonwAccountNumber = 0 for wa in cardMetadata.walletAccounts: if self.updateKeyPairItemIfDataAreKnown(wa.address, result.item): continue let (balance, balanceFetched) = self.controller.getOrFetchBalanceForAddressInPreferredCurrency(wa.address) result.knownKeyPair = false - result.item.addAccount(newKeyPairAccountItem(name = "", wa.path, wa.address, pubKey = wa.publicKey, emoji = "", - color = self.generateRandomColor(), icon = "wallet", balance, balanceFetched)) + unknonwAccountNumber.inc + let name = atc.KEYCARD_ACCOUNT_NAME_OF_UNKNOWN_WALLET_ACCOUNT & $unknonwAccountNumber + result.item.addAccount(newKeyPairAccountItem(name, wa.path, wa.address, pubKey = wa.publicKey, emoji = "", + color = "#939BA1", icon = "wallet", balance, balanceFetched)) method updateKeyPairForProcessing*[T](self: Module[T], cardMetadata: CardMetadata) = let(item, knownKeyPair) = self.buildKeyPairItemBasedOnCardMetadata(cardMetadata) diff --git a/ui/imports/shared/popups/keycard/helpers/KeyPairItem.qml b/ui/imports/shared/popups/keycard/helpers/KeyPairItem.qml index 934ab85cd5..bde688370b 100644 --- a/ui/imports/shared/popups/keycard/helpers/KeyPairItem.qml +++ b/ui/imports/shared/popups/keycard/helpers/KeyPairItem.qml @@ -90,7 +90,7 @@ StatusListItem { width: 16 height: 16 } - title: model.account.name + title: Utils.appTranslation(model.account.name) titleText.font.pixelSize: 12 titleText.color: Theme.palette.indirectColor1 diff --git a/ui/imports/shared/popups/keycard/helpers/KeycardItem.qml b/ui/imports/shared/popups/keycard/helpers/KeycardItem.qml index 16319d60bc..5d0da3cdf3 100644 --- a/ui/imports/shared/popups/keycard/helpers/KeycardItem.qml +++ b/ui/imports/shared/popups/keycard/helpers/KeycardItem.qml @@ -79,7 +79,7 @@ StatusListItem { width: 16 height: 16 } - title: model.account.name + title: Utils.appTranslation(model.account.name) titleText.font.pixelSize: 12 titleText.color: Theme.palette.indirectColor1 } diff --git a/ui/imports/utils/Constants.qml b/ui/imports/utils/Constants.qml index bff90ac7ef..fa250852b5 100644 --- a/ui/imports/utils/Constants.qml +++ b/ui/imports/utils/Constants.qml @@ -974,6 +974,7 @@ QtObject { readonly property string addAccountLabelImportNew: "LABEL-IMPORT-NEW" readonly property string addAccountLabelOptionAddNewMasterKey: "LABEL-OPTION-ADD-NEW-MASTER-KEY" readonly property string addAccountLabelOptionAddWatchOnlyAcc: "LABEL-OPTION-ADD-WATCH-ONLY-ACC" + readonly property string keycardAccountNameOfUnknownWalletAccount: "KEYCARD-ACCOUNT-NAME-OF-UNKNOWN-WALLET-ACCOUNT" } enum CommunitySettingsSections { diff --git a/ui/imports/utils/Utils.qml b/ui/imports/utils/Utils.qml index 4ac7b16591..f859a9fa69 100644 --- a/ui/imports/utils/Utils.qml +++ b/ui/imports/utils/Utils.qml @@ -653,6 +653,12 @@ QtObject { return qsTr("Add watch-only account") } + // special handling because on an index attached to the constant + if (key.startsWith(Constants.appTranslatableConstants.keycardAccountNameOfUnknownWalletAccount)) { + let num = key.substring(Constants.appTranslatableConstants.keycardAccountNameOfUnknownWalletAccount.length) + return "%1%2".arg(qsTr("acc")).arg(num) //short name of an unknown (removed) wallet account + } + return key }