2022-08-31 17:09:07 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
StatusListItem {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property var sharedKeycardModule
|
|
|
|
property ButtonGroup buttonGroup
|
|
|
|
property bool usedAsSelectOption: false
|
|
|
|
|
2022-09-02 11:04:59 +00:00
|
|
|
property int keyPairType: Constants.keycard.keyPairType.unknown
|
2022-08-31 17:09:07 +00:00
|
|
|
property string keyPairPubKey: ""
|
|
|
|
property string keyPairName: ""
|
|
|
|
property string keyPairIcon: ""
|
|
|
|
property string keyPairImage: ""
|
|
|
|
property string keyPairDerivedFrom: ""
|
|
|
|
property string keyPairAccounts: ""
|
2022-09-13 10:03:25 +00:00
|
|
|
property bool keyPairCardLocked: false
|
2022-08-31 17:09:07 +00:00
|
|
|
|
2022-09-02 11:04:59 +00:00
|
|
|
signal keyPairSelected()
|
|
|
|
|
2022-08-31 17:09:07 +00:00
|
|
|
color: Style.current.grey
|
|
|
|
title: root.keyPairName
|
2022-09-02 11:04:59 +00:00
|
|
|
titleAsideText: root.keyPairType === Constants.keycard.keyPairType.profile?
|
|
|
|
Utils.getElidedCompressedPk(d.myPublicKey) : ""
|
2022-08-31 17:09:07 +00:00
|
|
|
|
2022-09-02 11:04:59 +00:00
|
|
|
asset {
|
2022-08-31 17:09:07 +00:00
|
|
|
width: root.keyPairIcon? 24 : 40
|
|
|
|
height: root.keyPairIcon? 24 : 40
|
2022-09-02 11:04:59 +00:00
|
|
|
name: root.keyPairImage? root.keyPairImage : root.keyPairIcon
|
|
|
|
color: root.keyPairType === Constants.keycard.keyPairType.profile?
|
2022-09-13 10:03:25 +00:00
|
|
|
Utils.colorForPubkey(d.myPublicKey) :
|
|
|
|
root.keyPairCardLocked? Theme.palette.dangerColor1 : Theme.palette.primaryColor1
|
|
|
|
letterSize: Math.max(4, asset.width / 2.4)
|
2022-08-31 17:09:07 +00:00
|
|
|
charactersLen: 2
|
2022-09-13 10:03:25 +00:00
|
|
|
isLetterIdenticon: !root.keyPairIcon && !asset.name.toString()
|
|
|
|
bgColor: root.keyPairCardLocked? Theme.palette.dangerColor3 : Theme.palette.primaryColor3
|
2022-08-31 17:09:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ringSettings {
|
2022-09-02 11:04:59 +00:00
|
|
|
ringSpecModel: root.keyPairType === Constants.keycard.keyPairType.profile?
|
|
|
|
Utils.getColorHashAsJson(d.myPublicKey) : []
|
2022-09-13 10:03:25 +00:00
|
|
|
ringPxSize: Math.max(asset.width / 24.0)
|
2022-08-31 17:09:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tagsModel: ListModel{}
|
|
|
|
|
|
|
|
tagsDelegate: StatusListItemTag {
|
|
|
|
color: model.color
|
|
|
|
height: Style.current.bigPadding
|
|
|
|
radius: 6
|
|
|
|
closeButtonVisible: false
|
2022-09-02 11:04:59 +00:00
|
|
|
asset {
|
2022-08-31 17:09:07 +00:00
|
|
|
emoji: model.emoji
|
|
|
|
emojiSize: Emoji.size.verySmall
|
|
|
|
isLetterIdenticon: !!model.emoji
|
|
|
|
name: model.icon
|
|
|
|
color: Theme.palette.indirectColor1
|
|
|
|
width: 16
|
|
|
|
height: 16
|
|
|
|
}
|
|
|
|
title: model.name
|
|
|
|
titleText.font.pixelSize: 12
|
|
|
|
titleText.color: Theme.palette.indirectColor1
|
|
|
|
}
|
|
|
|
|
|
|
|
components: [
|
|
|
|
StatusRadioButton {
|
2022-09-02 11:04:59 +00:00
|
|
|
id: radioButton
|
2022-08-31 17:09:07 +00:00
|
|
|
visible: root.usedAsSelectOption
|
|
|
|
ButtonGroup.group: root.buttonGroup
|
|
|
|
onCheckedChanged: {
|
|
|
|
if (!root.usedAsSelectOption)
|
|
|
|
return
|
2022-09-02 11:04:59 +00:00
|
|
|
if (checked) {
|
|
|
|
root.sharedKeycardModule.setSelectedKeyPair(root.keyPairPubKey)
|
|
|
|
root.keyPairSelected()
|
2022-08-31 17:09:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
if (root.keyPairAccounts === "") {
|
|
|
|
// should never be here, as it's not possible to have keypair item without at least a single account
|
|
|
|
console.debug("accounts list is empty for selecting keycard pair")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
let obj = JSON.parse(root.keyPairAccounts)
|
|
|
|
if (obj.error) {
|
|
|
|
console.debug("error parsing accounts for selecting keycard pair, error: ", obj.error)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var i=0; i<obj.length; i++) {
|
|
|
|
this.tagsModel.append({"name": obj[i].Field0, "color": obj[i].Field4, "emoji": obj[i].Field3, "icon": obj[i].Field5})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-02 11:04:59 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
property string myPublicKey: userProfile.pubKey
|
|
|
|
}
|
|
|
|
|
2022-08-31 17:09:07 +00:00
|
|
|
onClicked: {
|
|
|
|
if (!root.usedAsSelectOption)
|
|
|
|
return
|
2022-09-02 11:04:59 +00:00
|
|
|
radioButton.checked = true
|
2022-08-31 17:09:07 +00:00
|
|
|
}
|
|
|
|
}
|