2023-04-24 18:35:34 +00:00
|
|
|
import QtQuick 2.15
|
2022-03-18 14:47:51 +00:00
|
|
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2022-06-27 13:41:47 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as StatusQUtils
|
2022-03-18 14:47:51 +00:00
|
|
|
|
|
|
|
import "../controls"
|
|
|
|
|
2023-04-24 18:35:34 +00:00
|
|
|
StatusComboBox {
|
2022-11-11 09:24:26 +00:00
|
|
|
id: root
|
2022-03-18 14:47:51 +00:00
|
|
|
|
2022-06-27 13:41:47 +00:00
|
|
|
property var selectedAccount
|
2023-04-24 18:35:34 +00:00
|
|
|
property string chainShortNames
|
|
|
|
property int selectedIndex: -1
|
2022-03-18 14:47:51 +00:00
|
|
|
|
2023-04-24 18:35:34 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
function getTextColorForWhite(color) {
|
|
|
|
// The grey is kept for backwards compatibility for accounts already created with grey background
|
|
|
|
return color === StatusColors.colors['grey'] || color === StatusColors.colors['white'] ? Theme.palette.black : Theme.palette.white
|
|
|
|
}
|
|
|
|
}
|
2022-11-11 09:24:26 +00:00
|
|
|
|
2023-04-24 18:35:34 +00:00
|
|
|
control.padding: 0
|
|
|
|
control.spacing: 0
|
|
|
|
control.leftPadding: 8
|
|
|
|
control.rightPadding: 8
|
|
|
|
control.topPadding: 10
|
2022-05-19 08:53:57 +00:00
|
|
|
|
2023-04-24 18:35:34 +00:00
|
|
|
control.popup.width: 430
|
|
|
|
control.indicator: null
|
|
|
|
|
|
|
|
control.background: Rectangle {
|
|
|
|
width: contentItem.childrenRect.width + control.leftPadding + control.rightPadding
|
|
|
|
height: 32
|
2022-06-27 13:41:47 +00:00
|
|
|
radius: 8
|
2023-04-24 18:35:34 +00:00
|
|
|
color: !!selectedAccount ? hoverHandler.containsMouse ?
|
|
|
|
Theme.palette.walletAccountColors.getHoveredColor(selectedAccount.color) :
|
|
|
|
selectedAccount.color ?? "transparent" : "transparent"
|
|
|
|
HoverHandler {
|
|
|
|
id: hoverHandler
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: Row {
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
width: childrenRect.width
|
|
|
|
spacing: 8
|
|
|
|
StatusEmoji {
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
width: 16
|
|
|
|
height: 16
|
|
|
|
emojiId: StatusQUtils.Emoji.iconId(selectedAccount.emoji ?? "", StatusQUtils.Emoji.size.verySmall) || ""
|
|
|
|
}
|
|
|
|
StatusBaseText {
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
text: selectedAccount.name ?? ""
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: d.getTextColorForWhite(selectedAccount.color ?? "")
|
|
|
|
}
|
|
|
|
StatusIcon {
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
width: 16
|
|
|
|
height: width
|
|
|
|
icon: "chevron-down"
|
|
|
|
color: d.getTextColorForWhite(selectedAccount.color ?? "")
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
2022-06-27 13:41:47 +00:00
|
|
|
}
|
2023-04-24 18:35:34 +00:00
|
|
|
|
|
|
|
delegate: WalletAccountListItem {
|
|
|
|
width: ListView.view.width
|
|
|
|
modelData: model
|
|
|
|
chainShortNames: root.chainShortNames
|
|
|
|
color: sensor.containsMouse || highlighted ?
|
|
|
|
Theme.palette.baseColor2 :
|
|
|
|
selectedAccount.name === model.name ? Theme.palette.statusListItem.highlightColor : "transparent"
|
2022-06-27 13:41:47 +00:00
|
|
|
onClicked: {
|
2023-04-24 18:35:34 +00:00
|
|
|
selectedIndex = index
|
|
|
|
control.popup.close()
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
2023-05-04 12:55:39 +00:00
|
|
|
Component.onCompleted:{
|
|
|
|
if(selectedAccount.address === model.address)
|
|
|
|
selectedIndex = index
|
|
|
|
}
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|