2023-06-22 10:32:43 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2023-07-13 13:58:48 +00:00
|
|
|
import StatusQ.Popups 0.1
|
2023-06-22 10:32:43 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
2023-07-28 07:57:58 +00:00
|
|
|
import AppLayouts.Profile.popups 1.0
|
|
|
|
|
2023-06-22 10:32:43 +00:00
|
|
|
Rectangle {
|
|
|
|
id: root
|
|
|
|
|
2023-07-18 09:10:48 +00:00
|
|
|
property var keyPair
|
2023-07-21 08:41:24 +00:00
|
|
|
property var getNetworkShortNames: function(chainIds){}
|
2023-06-22 10:32:43 +00:00
|
|
|
property string userProfilePublicKey
|
2023-06-26 15:57:16 +00:00
|
|
|
property bool includeWatchOnlyAccount
|
2023-06-22 10:32:43 +00:00
|
|
|
|
|
|
|
signal goToAccountView(var account)
|
2023-06-26 15:57:16 +00:00
|
|
|
signal toggleIncludeWatchOnlyAccount()
|
2023-07-13 13:58:48 +00:00
|
|
|
signal runRenameKeypairFlow()
|
2023-07-28 13:12:46 +00:00
|
|
|
signal runRemoveKeypairFlow()
|
2023-06-22 10:32:43 +00:00
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
2023-07-18 09:10:48 +00:00
|
|
|
readonly property var relatedAccounts: keyPair.accounts
|
|
|
|
readonly property bool isWatchOnly: keyPair.pairType === Constants.keycard.keyPairType.watchOnly
|
|
|
|
readonly property bool isPrivateKeyImport: keyPair.pairType === Constants.keycard.keyPairType.privateKeyImport
|
|
|
|
readonly property bool isProfileKeypair: keyPair.pairType === Constants.keycard.keyPairType.profile
|
|
|
|
readonly property string locationInfo: keyPair.migratedToKeycard ? qsTr("On Keycard"): qsTr("On device")
|
2023-06-22 10:32:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
implicitHeight: layout.height
|
|
|
|
color: Theme.palette.baseColor4
|
|
|
|
radius: 8
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: layout
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
width: parent.width
|
|
|
|
StatusListItem {
|
|
|
|
Layout.fillWidth: true
|
2023-07-18 09:10:48 +00:00
|
|
|
title: d.isWatchOnly ? qsTr("Watched addresses") : keyPair.name
|
2023-06-22 10:32:43 +00:00
|
|
|
statusListItemSubTitle.textFormat: Qt.RichText
|
2023-07-18 09:10:48 +00:00
|
|
|
titleTextIcon: keyPair.migratedToKeycard ? "keycard": ""
|
2023-06-22 10:32:43 +00:00
|
|
|
subTitle: d.isWatchOnly ? "" : d.isProfileKeypair ?
|
2023-07-18 09:10:48 +00:00
|
|
|
Utils.getElidedCompressedPk(keyPair.pubKey) + Constants.settingsSection.dotSepString + d.locationInfo : d.locationInfo
|
2023-06-22 10:32:43 +00:00
|
|
|
color: Theme.palette.transparent
|
|
|
|
ringSettings {
|
|
|
|
ringSpecModel: d.isProfileKeypair ? Utils.getColorHashAsJson(root.userProfilePublicKey) : []
|
|
|
|
ringPxSize: Math.max(asset.width / 24.0)
|
|
|
|
}
|
|
|
|
asset {
|
2023-07-18 09:10:48 +00:00
|
|
|
width: keyPair.icon ? Style.current.bigPadding : 40
|
|
|
|
height: keyPair.icon ? Style.current.bigPadding : 40
|
|
|
|
name: keyPair.image ? keyPair.image : keyPair.icon
|
|
|
|
isImage: !!keyPair.image
|
2023-06-22 10:32:43 +00:00
|
|
|
color: d.isProfileKeypair ? Utils.colorForPubkey(root.userProfilePublicKey) : Theme.palette.primaryColor1
|
|
|
|
letterSize: Math.max(4, asset.width / 2.4)
|
|
|
|
charactersLen: 2
|
2023-07-18 09:10:48 +00:00
|
|
|
isLetterIdenticon: !keyPair.icon && !asset.name.toString()
|
2023-06-22 10:32:43 +00:00
|
|
|
}
|
|
|
|
components: [
|
|
|
|
StatusFlatRoundButton {
|
|
|
|
icon.name: "more"
|
|
|
|
icon.color: Theme.palette.directColor1
|
|
|
|
visible: !d.isWatchOnly
|
2023-07-13 13:58:48 +00:00
|
|
|
highlighted: menuLoader.item && menuLoader.item.opened
|
|
|
|
onClicked: {
|
|
|
|
menuLoader.active = true
|
|
|
|
menuLoader.item.popup(0, height)
|
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: menuLoader
|
|
|
|
active: false
|
2023-07-28 07:57:58 +00:00
|
|
|
sourceComponent: WalletAccountKeycardMenu {
|
2023-07-13 13:58:48 +00:00
|
|
|
onClosed: {
|
|
|
|
menuLoader.active = false
|
|
|
|
}
|
2023-07-28 07:57:58 +00:00
|
|
|
keyPair: root.keyPair
|
|
|
|
onRunRenameKeypairFlow: root.runRenameKeypairFlow()
|
|
|
|
onRunRemoveKeypairFlow: root.runRemoveKeypairFlow()
|
2023-07-13 13:58:48 +00:00
|
|
|
}
|
|
|
|
}
|
2023-06-22 10:32:43 +00:00
|
|
|
},
|
|
|
|
StatusBaseText {
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
text: qsTr("Include in total balance")
|
|
|
|
visible: d.isWatchOnly
|
|
|
|
},
|
|
|
|
StatusSwitch {
|
|
|
|
visible: d.isWatchOnly
|
2023-06-26 15:57:16 +00:00
|
|
|
checked: root.includeWatchOnlyAccount
|
|
|
|
onClicked: root.toggleIncludeWatchOnlyAccount()
|
2023-06-22 10:32:43 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
StatusListView {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: childrenRect.height
|
|
|
|
Layout.leftMargin: 16
|
|
|
|
Layout.rightMargin: 16
|
|
|
|
spacing: 1
|
|
|
|
model: d.relatedAccounts
|
|
|
|
delegate: WalletAccountDelegate {
|
|
|
|
width: ListView.view.width
|
|
|
|
account: model.account
|
|
|
|
totalCount: ListView.view.count
|
2023-07-21 08:41:24 +00:00
|
|
|
getNetworkShortNames: root.getNetworkShortNames
|
2023-06-22 10:32:43 +00:00
|
|
|
onGoToAccountView: root.goToAccountView(model.account)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|