Files
pay/guis/desktop/NetView.qml
T

125 lines
4.0 KiB
QML
Raw Permalink Normal View History

2020-05-24 13:20:03 +02:00
/*
* This file is part of the Flowee project
2022-09-07 20:32:05 +02:00
* Copyright (C) 2020-2022 Tom Zander <tom@flowee.org>
2020-05-24 13:20:03 +02:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2022-11-26 10:46:57 +01:00
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
2022-11-14 21:19:31 +01:00
import "../Flowee" as Flowee
2020-05-24 13:20:03 +02:00
2020-10-14 18:29:10 +02:00
ApplicationWindow {
2021-04-22 16:13:40 +02:00
id: root
2020-10-14 18:29:10 +02:00
visible: false
2022-09-08 17:34:36 +02:00
minimumWidth: 200
minimumHeight: 200
width: 400
height: 500
2021-01-29 10:27:24 +01:00
title: qsTr("Peers (%1)", "", net.peers.length).arg(net.peers.length)
2020-10-14 18:29:10 +02:00
modality: Qt.NonModal
flags: Qt.Dialog
2020-05-24 13:20:03 +02:00
2021-04-30 18:35:26 +02:00
ListView {
id: listView
model: net.peers
clip: true
2021-10-30 16:37:33 +02:00
ScrollBar.vertical: ScrollBar { }
2021-04-30 18:35:26 +02:00
anchors.fill: parent
2021-04-22 16:13:40 +02:00
focus: true
2022-09-07 20:32:05 +02:00
Keys.onPressed: (event)=> {
2021-04-22 16:13:40 +02:00
if (event.key === Qt.Key_Escape) {
root.visible = false;
event.accepted = true
}
}
2021-04-30 18:35:26 +02:00
delegate: Rectangle {
width: listView.width
height: peerPane.height + 12
2023-02-21 16:40:46 +01:00
color: index % 2 === 0 ? palette.button : palette.base
2021-04-30 18:35:26 +02:00
ColumnLayout {
id: peerPane
width: listView.width - 20
x: 10
y: 6
2020-05-24 13:20:03 +02:00
2021-04-30 18:35:26 +02:00
Label {
text: modelData.userAgent
}
Label {
2021-11-09 21:34:40 +01:00
text: qsTr("Address", "network address (IP)") + ": " + modelData.address
2021-04-30 18:35:26 +02:00
}
RowLayout {
height: secondRow.height
2020-10-14 18:29:10 +02:00
Label {
2021-04-30 18:35:26 +02:00
id: secondRow
text: qsTr("Start-height: %1").arg(modelData.startHeight)
2020-05-24 13:20:03 +02:00
}
2020-10-14 18:29:10 +02:00
Label {
2021-04-30 18:35:26 +02:00
text: qsTr("ban-score: %1").arg(modelData.banScore)
2020-05-24 13:20:03 +02:00
}
2021-04-30 18:35:26 +02:00
}
Label {
2021-07-30 10:52:09 +02:00
id : accountStatus
2021-04-30 18:35:26 +02:00
font.bold: true
text: {
var id = modelData.segmentId;
2021-07-30 10:52:09 +02:00
if (id === 0) {
// not peered yet.
if (modelData.services.Length === 0)
return qsTr("initializing connection")
if (!modelData.headersReceived)
return qsTr("Verifying peer")
2021-11-09 21:34:40 +01:00
return qsTr("Assigning...")
2021-07-30 10:52:09 +02:00
}
2021-04-30 18:35:26 +02:00
var accounts = portfolio.accounts;
for (var i = 0; i < accounts.length; ++i) {
if (accounts[i].id === id)
2021-11-09 21:34:40 +01:00
return qsTr("Peer for wallet: %1").arg(accounts[i].name);
}
2021-11-09 21:34:40 +01:00
return qsTr("Peer for initial wallet");
}
2021-04-30 18:35:26 +02:00
visible: text !== ""
}
2021-07-30 10:52:09 +02:00
Flow {
Repeater {
model: modelData.services
delegate: Label { text: modelData }
}
}
2020-05-24 13:20:03 +02:00
}
}
2021-12-01 10:30:01 +01:00
Keys.forwardTo: Flowee.ListViewKeyHandler {
target: listView
}
2021-04-30 18:35:26 +02:00
}
2021-04-22 16:13:40 +02:00
2021-04-30 18:35:26 +02:00
footer: Item {
width: parent.width
height: closeButton.height + 20
Button {
id: closeButton
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.margins: 10
text: qsTr("Close")
onClicked: root.visible = false
2021-04-22 16:13:40 +02:00
}
2020-05-24 13:20:03 +02:00
}
}