2024-10-15 19:26:12 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQml.Models 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
2022-08-31 17:09:07 +00:00
|
|
|
|
2023-08-09 10:41:55 +00:00
|
|
|
import StatusQ.Core 0.1
|
2022-08-31 17:09:07 +00:00
|
|
|
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 ButtonGroup buttonGroup
|
|
|
|
property bool usedAsSelectOption: false
|
2022-12-16 09:37:08 +00:00
|
|
|
property bool tagClickable: false
|
|
|
|
property bool tagDisplayRemoveAccountButton: false
|
2023-01-31 12:23:35 +00:00
|
|
|
property bool canBeSelected: true
|
2023-08-09 10:41:55 +00:00
|
|
|
property bool displayRadioButtonForSelection: true
|
2023-08-21 10:58:21 +00:00
|
|
|
property bool useTransparentItemBackgroundColor: false
|
2022-08-31 17:09:07 +00:00
|
|
|
|
2022-09-02 11:04:59 +00:00
|
|
|
property int keyPairType: Constants.keycard.keyPairType.unknown
|
2023-05-18 18:28:46 +00:00
|
|
|
property string keyPairKeyUid: ""
|
2022-08-31 17:09:07 +00:00
|
|
|
property string keyPairName: ""
|
|
|
|
property string keyPairIcon: ""
|
|
|
|
property string keyPairImage: ""
|
|
|
|
property string keyPairDerivedFrom: ""
|
2022-09-13 10:03:25 +00:00
|
|
|
property bool keyPairCardLocked: false
|
2022-12-16 09:37:08 +00:00
|
|
|
property var keyPairAccounts
|
2022-08-31 17:09:07 +00:00
|
|
|
|
2023-09-01 13:32:21 +00:00
|
|
|
property bool displayAdditionalInfoForProfileKeypair: true
|
|
|
|
property string additionalInfoForProfileKeypair: qsTr("Moving this key pair will require you to use your Keycard to login")
|
|
|
|
|
2022-09-02 11:04:59 +00:00
|
|
|
signal keyPairSelected()
|
2022-12-16 09:37:08 +00:00
|
|
|
signal removeAccount(int index, string name)
|
|
|
|
signal accountClicked(int index)
|
2022-09-02 11:04:59 +00:00
|
|
|
|
2023-08-21 10:58:21 +00:00
|
|
|
color: {
|
|
|
|
if (!root.useTransparentItemBackgroundColor) {
|
|
|
|
return root.keyPairCardLocked? Theme.palette.dangerColor3 : Theme.palette.baseColor2
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sensor.containsMouse) {
|
|
|
|
return Theme.palette.baseColor2
|
|
|
|
}
|
|
|
|
|
|
|
|
return Theme.palette.transparent
|
|
|
|
}
|
2022-08-31 17:09:07 +00:00
|
|
|
title: root.keyPairName
|
2022-10-12 17:08:59 +00:00
|
|
|
statusListItemTitleAside.textFormat: Text.RichText
|
|
|
|
statusListItemTitleAside.visible: !!statusListItemTitleAside.text
|
|
|
|
statusListItemTitleAside.text: {
|
|
|
|
let t = ""
|
|
|
|
if (root.keyPairType === Constants.keycard.keyPairType.profile) {
|
|
|
|
t = Utils.getElidedCompressedPk(d.myPublicKey)
|
|
|
|
}
|
|
|
|
if (root.keyPairCardLocked) {
|
|
|
|
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-12 17:08:59 +00:00
|
|
|
}
|
|
|
|
return t
|
|
|
|
}
|
2023-05-25 18:59:20 +00:00
|
|
|
|
2023-09-01 13:32:21 +00:00
|
|
|
beneathTagsTitle: root.keyPairType === Constants.keycard.keyPairType.profile && root.displayAdditionalInfoForProfileKeypair?
|
|
|
|
root.additionalInfoForProfileKeypair :
|
2023-05-25 18:59:20 +00:00
|
|
|
!root.canBeSelected?
|
|
|
|
qsTranslate("", "Contains account(s) with Keycard incompatible derivation paths", root.keyPairAccounts.count.toString()) :
|
|
|
|
""
|
|
|
|
beneathTagsIcon: !!beneathTagsTitle? "info" : ""
|
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
|
2022-10-11 12:15:33 +00:00
|
|
|
isImage: !!root.keyPairImage
|
2022-09-02 11:04:59 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-12-16 09:37:08 +00:00
|
|
|
tagsModel: root.keyPairAccounts
|
2022-08-31 17:09:07 +00:00
|
|
|
|
|
|
|
tagsDelegate: StatusListItemTag {
|
2023-05-22 15:55:47 +00:00
|
|
|
bgColor: Utils.getColorForId(model.account.colorId)
|
2024-10-15 19:26:12 +00:00
|
|
|
height: Theme.bigPadding
|
2022-12-16 09:37:08 +00:00
|
|
|
bgRadius: 6
|
|
|
|
tagClickable: root.tagClickable
|
|
|
|
closeButtonVisible: root.tagDisplayRemoveAccountButton?
|
|
|
|
index > 0 : false
|
2022-09-02 11:04:59 +00:00
|
|
|
asset {
|
2022-12-16 09:37:08 +00:00
|
|
|
emoji: model.account.emoji
|
2022-08-31 17:09:07 +00:00
|
|
|
emojiSize: Emoji.size.verySmall
|
2022-12-16 09:37:08 +00:00
|
|
|
isLetterIdenticon: !!model.account.emoji
|
|
|
|
name: model.account.icon
|
2022-08-31 17:09:07 +00:00
|
|
|
color: Theme.palette.indirectColor1
|
|
|
|
width: 16
|
|
|
|
height: 16
|
|
|
|
}
|
2023-05-07 09:18:40 +00:00
|
|
|
title: Utils.appTranslation(model.account.name)
|
2022-08-31 17:09:07 +00:00
|
|
|
titleText.font.pixelSize: 12
|
|
|
|
titleText.color: Theme.palette.indirectColor1
|
2022-12-16 09:37:08 +00:00
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
root.removeAccount(index, model.account.name)
|
|
|
|
}
|
|
|
|
|
|
|
|
onTagClicked: {
|
|
|
|
root.accountClicked(index)
|
|
|
|
}
|
2022-08-31 17:09:07 +00:00
|
|
|
}
|
|
|
|
|
2023-01-31 12:23:35 +00:00
|
|
|
components: root.canBeSelected? d.components : []
|
2022-08-31 17:09:07 +00:00
|
|
|
|
2022-09-02 11:04:59 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
property string myPublicKey: userProfile.pubKey
|
2023-01-31 12:23:35 +00:00
|
|
|
|
|
|
|
property list<Item> components: [
|
|
|
|
StatusRadioButton {
|
|
|
|
id: radioButton
|
2023-08-09 10:41:55 +00:00
|
|
|
visible: root.usedAsSelectOption && root.displayRadioButtonForSelection
|
2023-01-31 12:23:35 +00:00
|
|
|
ButtonGroup.group: root.buttonGroup
|
|
|
|
onCheckedChanged: {
|
2023-08-09 10:41:55 +00:00
|
|
|
d.doAction(checked)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
StatusIcon {
|
|
|
|
visible: root.usedAsSelectOption && !root.displayRadioButtonForSelection
|
|
|
|
icon: "next"
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
onClicked: {
|
|
|
|
d.doAction(true)
|
2023-01-31 12:23:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2023-08-09 10:41:55 +00:00
|
|
|
|
|
|
|
function doAction(checked){
|
|
|
|
if (!root.usedAsSelectOption || !root.canBeSelected)
|
|
|
|
return
|
|
|
|
if (checked) {
|
|
|
|
root.keyPairSelected()
|
|
|
|
}
|
|
|
|
}
|
2022-09-02 11:04:59 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 17:09:07 +00:00
|
|
|
onClicked: {
|
2023-01-31 12:23:35 +00:00
|
|
|
if (!root.usedAsSelectOption || !root.canBeSelected)
|
2022-08-31 17:09:07 +00:00
|
|
|
return
|
2023-08-09 10:41:55 +00:00
|
|
|
d.doAction(!root.displayRadioButtonForSelection || radioButton.checked)
|
2022-08-31 17:09:07 +00:00
|
|
|
}
|
|
|
|
}
|