2022-10-11 12:15:33 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQml.Models 2.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
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 bool displayChevronComponent: true
|
|
|
|
property string keycardName: ""
|
2022-12-09 19:43:36 +00:00
|
|
|
property string keycardUid: ""
|
2022-10-11 12:15:33 +00:00
|
|
|
property bool keycardLocked: false
|
|
|
|
property int keyPairType: Constants.keycard.keyPairType.unknown
|
|
|
|
property string keyPairIcon: ""
|
|
|
|
property string keyPairImage: ""
|
|
|
|
property string keyPairAccounts: ""
|
|
|
|
|
|
|
|
signal keycardSelected()
|
|
|
|
|
2022-10-14 08:30:23 +00:00
|
|
|
color: root.keycardLocked? Theme.palette.dangerColor3 : Theme.palette.baseColor2
|
2022-10-11 12:15:33 +00:00
|
|
|
title: root.keycardName
|
|
|
|
statusListItemTitleAside.textFormat: Text.RichText
|
2022-10-12 17:08:59 +00:00
|
|
|
statusListItemTitleAside.visible: !!statusListItemTitleAside.text
|
2022-10-11 12:15:33 +00:00
|
|
|
statusListItemTitleAside.text: {
|
|
|
|
let t = ""
|
|
|
|
if (root.keyPairType === Constants.keycard.keyPairType.profile) {
|
|
|
|
t = Utils.getElidedCompressedPk(d.myPublicKey)
|
|
|
|
}
|
|
|
|
if (root.keycardLocked) {
|
|
|
|
let label = qsTr("Keycard Locked")
|
2022-10-14 08:30:23 +00:00
|
|
|
t += ` <font color="${Theme.palette.dangerColor1}" size="5">${label}</font>`
|
2022-10-11 12:15:33 +00:00
|
|
|
}
|
|
|
|
return t
|
|
|
|
}
|
2022-12-09 19:43:36 +00:00
|
|
|
statusListItemSubTitle.text: !!root.keycardUid? "(%1)".arg(root.keycardUid) : ""
|
|
|
|
statusListItemSubTitle.font.pixelSize: 10
|
|
|
|
statusListItemSubTitle.visible: !!statusListItemSubTitle.text
|
2022-10-11 12:15:33 +00:00
|
|
|
|
|
|
|
asset {
|
|
|
|
width: root.keyPairIcon? 24 : 40
|
|
|
|
height: root.keyPairIcon? 24 : 40
|
|
|
|
name: root.keyPairImage? root.keyPairImage : root.keyPairIcon
|
|
|
|
isImage: !!root.keyPairImage
|
|
|
|
color: root.keyPairType === Constants.keycard.keyPairType.profile?
|
2022-10-12 17:08:59 +00:00
|
|
|
Utils.colorForPubkey(d.myPublicKey) :
|
|
|
|
root.keycardLocked? Theme.palette.dangerColor1 : Theme.palette.primaryColor1
|
2022-10-11 12:15:33 +00:00
|
|
|
letterSize: Math.max(4, asset.width / 2.4)
|
|
|
|
charactersLen: 2
|
|
|
|
isLetterIdenticon: !root.keyPairIcon && !asset.name.toString()
|
2022-10-12 17:08:59 +00:00
|
|
|
bgColor: root.keycardLocked? Theme.palette.dangerColor3 : Theme.palette.primaryColor3
|
2022-10-11 12:15:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ringSettings {
|
|
|
|
ringSpecModel: root.keyPairType === Constants.keycard.keyPairType.profile?
|
|
|
|
Utils.getColorHashAsJson(d.myPublicKey) : []
|
|
|
|
ringPxSize: Math.max(asset.width / 24.0)
|
|
|
|
}
|
|
|
|
|
|
|
|
tagsModel: ListModel{}
|
|
|
|
|
|
|
|
tagsDelegate: StatusListItemTag {
|
2022-12-21 13:57:41 +00:00
|
|
|
bgColor: model.color
|
|
|
|
bgRadius: 6
|
2022-10-11 12:15:33 +00:00
|
|
|
height: Style.current.bigPadding
|
|
|
|
closeButtonVisible: false
|
|
|
|
asset {
|
|
|
|
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: [
|
|
|
|
StatusIcon {
|
|
|
|
visible: root.displayChevronComponent
|
|
|
|
icon: "tiny/chevron-right"
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
root.keycardSelected()
|
|
|
|
}
|
|
|
|
|
|
|
|
onKeyPairAccountsChanged: {
|
|
|
|
tagsModel.clear()
|
|
|
|
if (root.keyPairAccounts === "") {
|
|
|
|
// should never be here, as it's not possible to have keypair item without at least a single account
|
2022-10-28 17:17:16 +00:00
|
|
|
console.warn("accounts list is empty for selecting keycard pair")
|
2022-10-11 12:15:33 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
let obj = JSON.parse(root.keyPairAccounts)
|
|
|
|
if (obj.error) {
|
2022-10-28 17:17:16 +00:00
|
|
|
console.warn("error parsing accounts for selecting keycard pair, error: ", obj.error)
|
2022-10-11 12:15:33 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var i=0; i<obj.length; i++) {
|
|
|
|
tagsModel.append({"name": obj[i].Field0, "color": obj[i].Field4, "emoji": obj[i].Field3, "icon": obj[i].Field5})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
property string myPublicKey: userProfile.pubKey
|
|
|
|
}
|
|
|
|
}
|