2022-02-15 13:19:45 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import QtGraphicalEffects 1.0
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
// TODO: replace with StatusModal
|
|
|
|
Popup {
|
2022-11-12 09:18:18 +00:00
|
|
|
id: root
|
2022-02-15 13:19:45 +00:00
|
|
|
modal: false
|
|
|
|
width: 360
|
|
|
|
height: 432
|
2022-08-05 12:07:03 +00:00
|
|
|
|
|
|
|
horizontalPadding: 5
|
|
|
|
verticalPadding: 5
|
|
|
|
|
2022-02-17 09:15:37 +00:00
|
|
|
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
|
|
|
|
property var layer1Networks
|
|
|
|
property var layer2Networks
|
|
|
|
property var testNetworks
|
|
|
|
|
2022-11-12 09:18:18 +00:00
|
|
|
// If true NetworksExtraStoreProxy expected for layer1Networks and layer2Networks properties
|
|
|
|
property bool useNetworksExtraStoreProxy: false
|
|
|
|
|
2022-02-15 13:19:45 +00:00
|
|
|
signal toggleNetwork(int chainId)
|
|
|
|
|
|
|
|
background: Rectangle {
|
|
|
|
radius: Style.current.radius
|
|
|
|
color: Style.current.background
|
|
|
|
border.color: Style.current.border
|
|
|
|
layer.enabled: true
|
|
|
|
layer.effect: DropShadow{
|
|
|
|
verticalOffset: 3
|
|
|
|
radius: 8
|
|
|
|
samples: 15
|
|
|
|
fast: true
|
|
|
|
cached: true
|
|
|
|
color: "#22000000"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-13 12:29:38 +00:00
|
|
|
contentItem: StatusScrollView {
|
2022-02-15 13:19:45 +00:00
|
|
|
id: scrollView
|
2022-11-12 09:18:18 +00:00
|
|
|
width: root.width
|
|
|
|
height: root.height
|
2022-12-20 15:23:49 +00:00
|
|
|
contentHeight: content.height
|
2022-08-05 12:07:03 +00:00
|
|
|
padding: 0
|
2022-02-15 13:19:45 +00:00
|
|
|
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
|
|
|
|
Column {
|
|
|
|
id: content
|
2022-12-20 15:23:49 +00:00
|
|
|
width: childrenRect.width
|
2022-08-05 12:07:03 +00:00
|
|
|
spacing: 4
|
2022-02-15 13:19:45 +00:00
|
|
|
|
2022-02-17 09:15:37 +00:00
|
|
|
Repeater {
|
|
|
|
id: chainRepeater1
|
2022-08-18 17:51:18 +00:00
|
|
|
width: parent.width
|
|
|
|
height: parent.height
|
2022-08-09 13:52:17 +00:00
|
|
|
objectName: "networkSelectPopupChainRepeaterLayer1"
|
2022-11-12 09:18:18 +00:00
|
|
|
model: root.layer1Networks
|
2022-02-17 09:15:37 +00:00
|
|
|
|
|
|
|
delegate: chainItem
|
|
|
|
}
|
|
|
|
|
2022-05-18 21:58:07 +00:00
|
|
|
StatusBaseText {
|
|
|
|
font.pixelSize: Style.current.primaryTextFontSize
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
text: qsTr("Layer 2")
|
2022-08-05 12:07:03 +00:00
|
|
|
height: 40
|
|
|
|
leftPadding: 16
|
|
|
|
topPadding: 10
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
|
2022-05-18 21:58:07 +00:00
|
|
|
visible: chainRepeater2.count > 0
|
|
|
|
}
|
|
|
|
|
2022-02-17 09:15:37 +00:00
|
|
|
Repeater {
|
|
|
|
id: chainRepeater2
|
2022-11-12 09:18:18 +00:00
|
|
|
model: root.layer2Networks
|
2022-02-17 09:15:37 +00:00
|
|
|
|
|
|
|
delegate: chainItem
|
|
|
|
}
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
id: chainRepeater3
|
2022-11-12 09:18:18 +00:00
|
|
|
model: root.testNetworks
|
2022-02-17 09:15:37 +00:00
|
|
|
|
|
|
|
delegate: chainItem
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: chainItem
|
2022-05-18 21:58:07 +00:00
|
|
|
StatusListItem {
|
2022-08-11 11:55:08 +00:00
|
|
|
objectName: model.chainName
|
2022-08-05 12:07:03 +00:00
|
|
|
implicitHeight: 48
|
2022-05-18 21:58:07 +00:00
|
|
|
implicitWidth: scrollView.width
|
|
|
|
title: model.chainName
|
2022-08-11 11:55:08 +00:00
|
|
|
asset.height: 24
|
|
|
|
asset.width: 24
|
|
|
|
asset.isImage: true
|
|
|
|
asset.name: Style.svg(model.iconUrl)
|
2022-05-18 21:58:07 +00:00
|
|
|
onClicked: {
|
|
|
|
checkBox.checked = !checkBox.checked
|
2022-02-17 09:15:37 +00:00
|
|
|
}
|
2022-05-18 21:58:07 +00:00
|
|
|
components: [
|
|
|
|
StatusCheckBox {
|
|
|
|
id: checkBox
|
2022-11-12 09:18:18 +00:00
|
|
|
checked: root.useNetworksExtraStoreProxy ? model.isActive : model.isEnabled
|
2022-05-18 21:58:07 +00:00
|
|
|
onCheckedChanged: {
|
2022-11-12 09:18:18 +00:00
|
|
|
if(root.useNetworksExtraStoreProxy && model.isActive !== checked) {
|
|
|
|
model.isActive = checked
|
|
|
|
} else if (model.isEnabled !== checked) {
|
|
|
|
root.toggleNetwork(model.chainId)
|
2022-05-18 21:58:07 +00:00
|
|
|
}
|
2022-02-15 13:19:45 +00:00
|
|
|
}
|
|
|
|
}
|
2022-05-18 21:58:07 +00:00
|
|
|
]
|
2022-02-15 13:19:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|