2020-05-24 13:20:03 +02:00
|
|
|
/*
|
|
|
|
|
* This file is part of the Flowee project
|
2024-01-04 20:37:46 +01:00
|
|
|
* Copyright (C) 2020-2024 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
|
2024-01-26 14:26:40 +01:00
|
|
|
import QtQuick.Controls as QQC2;
|
2022-11-26 10:46:57 +01:00
|
|
|
import QtQuick.Layouts
|
2022-11-14 21:19:31 +01:00
|
|
|
import "../Flowee" as Flowee
|
2024-01-04 20:37:46 +01:00
|
|
|
import Flowee.org.pay;
|
2020-05-24 13:20:03 +02:00
|
|
|
|
2024-01-26 14:26:40 +01:00
|
|
|
QQC2.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
|
2024-01-04 20:37:46 +01:00
|
|
|
title: qsTr("Peers (%1)", "", listView.count).arg(listView.count)
|
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
|
2024-01-04 20:37:46 +01:00
|
|
|
model: net
|
2021-04-30 18:35:26 +02:00
|
|
|
clip: true
|
2024-01-26 14:26:40 +01:00
|
|
|
QQC2.ScrollBar.vertical: QQC2.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
|
2024-01-26 14:26:40 +01:00
|
|
|
border.width: net.selectedId === model.connectionId ? 2 : 0
|
|
|
|
|
border.color: palette.highlight
|
2023-02-21 16:40:46 +01:00
|
|
|
color: index % 2 === 0 ? palette.button : palette.base
|
2024-01-04 20:37:46 +01:00
|
|
|
opacity: {
|
|
|
|
|
let validity = model.validity;
|
|
|
|
|
if (validity === Wallet.Checking)
|
|
|
|
|
return 0.7;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2024-01-26 14:26:40 +01:00
|
|
|
QQC2.Label {
|
2024-01-04 20:37:46 +01:00
|
|
|
text: "(" + model.connectionId + ")"
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.rightMargin: 10
|
|
|
|
|
y: 20
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-30 18:35:26 +02:00
|
|
|
ColumnLayout {
|
|
|
|
|
id: peerPane
|
2024-01-04 20:37:46 +01:00
|
|
|
width: listView.width - 40
|
2021-04-30 18:35:26 +02:00
|
|
|
x: 10
|
|
|
|
|
y: 6
|
2020-05-24 13:20:03 +02:00
|
|
|
|
2024-01-26 14:26:40 +01:00
|
|
|
QQC2.Label {
|
2024-01-04 20:37:46 +01:00
|
|
|
text: model.userAgent
|
2021-04-30 18:35:26 +02:00
|
|
|
}
|
2024-01-26 14:26:40 +01:00
|
|
|
QQC2.Label {
|
2024-01-04 20:37:46 +01:00
|
|
|
text: qsTr("Address", "network address (IP)") + ": " + model.address
|
2021-04-30 18:35:26 +02:00
|
|
|
}
|
|
|
|
|
RowLayout {
|
|
|
|
|
height: secondRow.height
|
2024-01-04 20:37:46 +01:00
|
|
|
spacing: 0
|
2024-01-26 14:26:40 +01:00
|
|
|
QQC2.Label {
|
2021-04-30 18:35:26 +02:00
|
|
|
id: secondRow
|
2024-01-04 20:37:46 +01:00
|
|
|
text: qsTr("Start-height: %1").arg(model.startHeight)
|
2020-05-24 13:20:03 +02:00
|
|
|
}
|
2024-01-26 14:26:40 +01:00
|
|
|
QQC2.Label {
|
2024-01-04 20:37:46 +01:00
|
|
|
text: ", " + qsTr("ban-score: %1").arg(model.banScore)
|
2020-05-24 13:20:03 +02:00
|
|
|
}
|
2021-04-30 18:35:26 +02:00
|
|
|
}
|
2024-01-26 14:26:40 +01:00
|
|
|
QQC2.Label {
|
2021-07-30 10:52:09 +02:00
|
|
|
id : accountStatus
|
2021-04-30 18:35:26 +02:00
|
|
|
font.bold: true
|
|
|
|
|
text: {
|
2024-01-04 20:37:46 +01:00
|
|
|
var id = model.segment;
|
2021-07-30 10:52:09 +02:00
|
|
|
if (id === 0) {
|
2024-01-04 20:37:46 +01:00
|
|
|
let validity = model.validity;
|
2024-01-26 12:12:45 +01:00
|
|
|
if (validity === Wallet.OpeningConnection)
|
|
|
|
|
return "Opening Connection";
|
2024-01-04 20:37:46 +01:00
|
|
|
if (validity === Wallet.Checking)
|
|
|
|
|
return "Validating peer";
|
|
|
|
|
if (validity === Wallet.CheckedOk)
|
|
|
|
|
return "Validated";
|
|
|
|
|
if (validity === Wallet.KnownGood)
|
|
|
|
|
return "Good Peer";
|
|
|
|
|
return ""; // unknown
|
2021-07-30 10:52:09 +02:00
|
|
|
}
|
2024-01-04 20:37:46 +01:00
|
|
|
var accounts = portfolio.rawAccounts;
|
2021-04-30 18:35:26 +02:00
|
|
|
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);
|
2020-10-18 16:57:06 +02:00
|
|
|
}
|
2024-01-04 20:37:46 +01:00
|
|
|
return "Internal Error";
|
2020-10-18 16:57:06 +02:00
|
|
|
}
|
|
|
|
|
}
|
2024-01-26 14:26:40 +01:00
|
|
|
QQC2.Label {
|
2024-01-04 20:37:46 +01:00
|
|
|
text: "Downloading!"
|
|
|
|
|
visible: model.isDownloading
|
2021-07-30 10:52:09 +02:00
|
|
|
}
|
2020-05-24 13:20:03 +02:00
|
|
|
}
|
2024-01-26 14:26:40 +01:00
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
|
onClicked: (event)=> {
|
|
|
|
|
// for mouse
|
|
|
|
|
net.selectedId = model.connectionId;
|
|
|
|
|
if (event.button === Qt.RightButton)
|
|
|
|
|
peerContextMenu.popup(parent, event.x, event.y)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
QQC2.Menu {
|
|
|
|
|
id: peerContextMenu
|
|
|
|
|
QQC2.MenuItem {
|
|
|
|
|
text: qsTr("Disconnect Peer")
|
|
|
|
|
onClicked: net.disconnectPeer(model.connectionId);
|
|
|
|
|
}
|
|
|
|
|
QQC2.MenuItem {
|
|
|
|
|
text: qsTr("Ban Peer")
|
|
|
|
|
onClicked: net.banPeer(model.connectionId);
|
|
|
|
|
}
|
|
|
|
|
}
|
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
|
|
|
|
|
|
2024-01-26 14:26:40 +01:00
|
|
|
QQC2.Button {
|
2021-04-30 18:35:26 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
}
|