2024-10-15 19:26:12 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
2023-03-22 15:48:44 +00:00
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Core.Utils 0.1 as StatusQUtils
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
|
|
|
|
import "../stores"
|
|
|
|
|
|
|
|
StatusMenu {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property AddAccountStore store
|
|
|
|
|
|
|
|
property int itemsPerPage: 5
|
|
|
|
|
|
|
|
signal selected(string address)
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
property int currentPage: 0
|
2024-11-01 13:27:34 +00:00
|
|
|
readonly property int lowerBound: root.itemsPerPage * d.currentPage
|
2023-03-22 15:48:44 +00:00
|
|
|
readonly property int totalPages: Math.ceil(root.store.derivedAddressModel.count / root.itemsPerPage)
|
|
|
|
}
|
|
|
|
|
|
|
|
SortFilterProxyModel {
|
|
|
|
id: proxyModel
|
|
|
|
sourceModel: root.store.derivedAddressModel
|
2024-11-01 13:27:34 +00:00
|
|
|
filters: IndexFilter {
|
|
|
|
minimumIndex: d.lowerBound
|
|
|
|
maximumIndex: d.lowerBound + root.itemsPerPage
|
2023-03-22 15:48:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: Column {
|
|
|
|
width: root.width
|
|
|
|
|
|
|
|
Item {
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
height: Constants.addAccountPopup.itemHeight - root.topPadding
|
|
|
|
|
|
|
|
Row{
|
|
|
|
anchors.centerIn: parent
|
2024-10-15 19:26:12 +00:00
|
|
|
spacing: Theme.halfPadding
|
2023-03-22 15:48:44 +00:00
|
|
|
|
|
|
|
StatusIcon {
|
|
|
|
visible: !root.store.addAccountModule.scanningForActivityIsOngoing ||
|
|
|
|
root.store.derivedAddressModel.loadedCount > 0
|
|
|
|
width: 20
|
|
|
|
height: 20
|
|
|
|
icon: "flash"
|
|
|
|
color: root.store.derivedAddressModel.loadedCount === 0?
|
|
|
|
Theme.palette.primaryColor1 : Theme.palette.successColor1
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusLinkText {
|
|
|
|
visible: !root.store.addAccountModule.scanningForActivityIsOngoing
|
|
|
|
font.pixelSize: Constants.addAccountPopup.labelFontSize1
|
|
|
|
text: qsTr("Scan addresses for activity")
|
|
|
|
color: Theme.palette.primaryColor1
|
|
|
|
onClicked: {
|
|
|
|
root.store.startScanningForActivity()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusLoadingIndicator {
|
|
|
|
visible: root.store.addAccountModule.scanningForActivityIsOngoing &&
|
|
|
|
root.store.derivedAddressModel.loadedCount === 0
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
visible: root.store.addAccountModule.scanningForActivityIsOngoing
|
|
|
|
color: root.store.derivedAddressModel.loadedCount === 0?
|
|
|
|
Theme.palette.baseColor1 : Theme.palette.successColor1
|
|
|
|
font.pixelSize: Constants.addAccountPopup.labelFontSize1
|
|
|
|
text: root.store.derivedAddressModel.loadedCount === 0?
|
|
|
|
qsTr("Scanning for activity...")
|
|
|
|
: qsTr("Activity fetched for %1 / %2 addresses").arg(root.store.derivedAddressModel.loadedCount).arg(root.store.derivedAddressModel.count)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
height: 1
|
|
|
|
color: Theme.palette.baseColor2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-11-01 13:27:34 +00:00
|
|
|
StatusListView {
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
implicitHeight: contentHeight
|
2023-03-22 15:48:44 +00:00
|
|
|
model: proxyModel
|
|
|
|
|
2024-11-01 13:27:34 +00:00
|
|
|
delegate: Rectangle {
|
2023-04-13 10:27:56 +00:00
|
|
|
objectName: "AddAccountPopup-GeneratedAddress-%1".arg(model.addressDetails.order)
|
2024-11-01 13:27:34 +00:00
|
|
|
width: ListView.view.width
|
2023-03-22 15:48:44 +00:00
|
|
|
height: Constants.addAccountPopup.itemHeight
|
|
|
|
enabled: !model.addressDetails.alreadyCreated
|
2024-10-15 19:26:12 +00:00
|
|
|
radius: Theme.halfPadding
|
2023-03-22 15:48:44 +00:00
|
|
|
color: {
|
|
|
|
if (sensor.containsMouse) {
|
|
|
|
return Theme.palette.baseColor2
|
|
|
|
}
|
|
|
|
return "transparent"
|
|
|
|
}
|
|
|
|
|
2024-11-01 13:27:34 +00:00
|
|
|
MouseArea {
|
|
|
|
id: sensor
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
onClicked: {
|
|
|
|
root.selected(model.addressDetails.address)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-22 15:48:44 +00:00
|
|
|
GridLayout {
|
|
|
|
anchors.fill: parent
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.leftMargin: Theme.padding
|
|
|
|
anchors.rightMargin: Theme.padding
|
|
|
|
columnSpacing: Theme.padding
|
2023-03-22 15:48:44 +00:00
|
|
|
rowSpacing: 0
|
|
|
|
|
|
|
|
StatusBaseText {
|
2024-11-01 13:27:34 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
elide: Text.ElideMiddle
|
2023-03-22 15:48:44 +00:00
|
|
|
color: model.addressDetails.alreadyCreated? Theme.palette.baseColor1 : Theme.palette.directColor1
|
|
|
|
font.pixelSize: Constants.addAccountPopup.labelFontSize1
|
2024-11-01 13:27:34 +00:00
|
|
|
text: model.addressDetails.address
|
2023-03-22 15:48:44 +00:00
|
|
|
}
|
|
|
|
|
2024-11-01 13:27:34 +00:00
|
|
|
RowLayout {
|
2024-10-15 19:26:12 +00:00
|
|
|
spacing: Theme.halfPadding * 0.5
|
2023-03-22 15:48:44 +00:00
|
|
|
|
|
|
|
StatusIcon {
|
|
|
|
visible: model.addressDetails.loaded && model.addressDetails.hasActivity
|
2024-11-01 13:27:34 +00:00
|
|
|
Layout.preferredWidth: 20
|
|
|
|
Layout.preferredHeight: 20
|
2023-03-22 15:48:44 +00:00
|
|
|
icon: "flash"
|
|
|
|
color: Theme.palette.successColor1
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusTextWithLoadingState {
|
2024-11-01 13:27:34 +00:00
|
|
|
Layout.fillWidth: true
|
2023-03-22 15:48:44 +00:00
|
|
|
font.pixelSize: Constants.addAccountPopup.labelFontSize1
|
|
|
|
text: {
|
|
|
|
if (!root.store.addAccountModule.scanningForActivityIsOngoing) {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
if (!model.addressDetails.loaded) {
|
|
|
|
return qsTr("loading...")
|
|
|
|
}
|
|
|
|
if (model.addressDetails.hasActivity) {
|
|
|
|
return qsTr("Has activity")
|
|
|
|
}
|
|
|
|
return qsTr("No activity")
|
|
|
|
}
|
|
|
|
color: {
|
|
|
|
if (!root.store.addAccountModule.scanningForActivityIsOngoing || !model.addressDetails.loaded) {
|
|
|
|
return "transparent"
|
|
|
|
}
|
|
|
|
if (model.addressDetails.hasActivity) {
|
|
|
|
return Theme.palette.successColor1
|
|
|
|
}
|
|
|
|
return Theme.palette.warningColor1
|
|
|
|
}
|
|
|
|
loading: root.store.addAccountModule.scanningForActivityIsOngoing && !model.addressDetails.loaded
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
font.pixelSize: Constants.addAccountPopup.labelFontSize1
|
|
|
|
text: model.addressDetails.order
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusFlatRoundButton {
|
|
|
|
Layout.preferredWidth: 20
|
|
|
|
Layout.preferredHeight: 20
|
|
|
|
type: StatusFlatRoundButton.Type.Tertiary
|
|
|
|
icon.name: "external"
|
|
|
|
icon.width: 16
|
|
|
|
icon.height: 16
|
|
|
|
onClicked: {
|
2024-11-01 13:27:34 +00:00
|
|
|
Global.openLink("https://etherscan.io/address/%1".arg(model.addressDetails.address))
|
2023-03-22 15:48:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
height: Constants.addAccountPopup.itemHeight - root.bottomPadding
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: parent.top
|
|
|
|
height: 1
|
|
|
|
color: Theme.palette.baseColor2
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusPageIndicator {
|
2023-04-13 10:27:56 +00:00
|
|
|
objectName: "AddAccountPopup-GeneratedAddressesListPageIndicatior"
|
2023-03-22 15:48:44 +00:00
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: (Constants.addAccountPopup.itemHeight - height) * 0.5
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
totalPages: d.totalPages
|
|
|
|
|
|
|
|
onCurrentIndexChanged: {
|
|
|
|
d.currentPage = currentIndex
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|