mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-12-22 19:49:34 +00:00
RemoteNodeList, RemoteNodeDialog: different remote node for each network type; implement labels
This commit is contained in:
parent
710e3f6948
commit
bc08952c76
3 changed files with 124 additions and 10 deletions
|
@ -34,13 +34,14 @@ import "." as MoneroComponents
|
||||||
|
|
||||||
MoneroComponents.Dialog {
|
MoneroComponents.Dialog {
|
||||||
id: root
|
id: root
|
||||||
title: (editMode ? qsTr("Edit remote node") : qsTr("Add remote node")) + translationManager.emptyString
|
title: (editMode ? qsTr("Edit remote node") + (persistentSettings.nettype != 0 ? " (%1)".arg(networkTypeAsString()) : "")
|
||||||
|
: qsTr("Add remote node") + (persistentSettings.nettype != 0 ? " (%1)".arg(networkTypeAsString()) : "")
|
||||||
|
) + translationManager.emptyString
|
||||||
property var callbackOnSuccess: null
|
property var callbackOnSuccess: null
|
||||||
property bool editMode: false
|
property bool editMode: false
|
||||||
property bool success: false
|
property bool success: false
|
||||||
|
|
||||||
onActiveFocusChanged: activeFocus && remoteNodeAddress.forceActiveFocus()
|
onActiveFocusChanged: activeFocus && remoteNodeLabel.forceActiveFocus()
|
||||||
|
|
||||||
function onOk() {
|
function onOk() {
|
||||||
root.success = true;
|
root.success = true;
|
||||||
|
@ -62,6 +63,9 @@ MoneroComponents.Dialog {
|
||||||
remoteNodeAddress.daemonAddrText = hostPort[1];
|
remoteNodeAddress.daemonAddrText = hostPort[1];
|
||||||
remoteNodeAddress.daemonPortText = hostPort[2];
|
remoteNodeAddress.daemonPortText = hostPort[2];
|
||||||
}
|
}
|
||||||
|
if (remoteNode.label) {
|
||||||
|
remoteNodeLabel.text = remoteNode.label;
|
||||||
|
}
|
||||||
daemonUsername.text = remoteNode.username;
|
daemonUsername.text = remoteNode.username;
|
||||||
daemonPassword.text = remoteNode.password;
|
daemonPassword.text = remoteNode.password;
|
||||||
setTrustedDaemonCheckBox.checked = remoteNode.trusted;
|
setTrustedDaemonCheckBox.checked = remoteNode.trusted;
|
||||||
|
@ -74,6 +78,8 @@ MoneroComponents.Dialog {
|
||||||
onClosed: {
|
onClosed: {
|
||||||
if (root.success && callbackOnSuccess) {
|
if (root.success && callbackOnSuccess) {
|
||||||
callbackOnSuccess({
|
callbackOnSuccess({
|
||||||
|
label: remoteNodeLabel.text,
|
||||||
|
networkType: persistentSettings.nettype.toString(),
|
||||||
address: remoteNodeAddress.getAddress(),
|
address: remoteNodeAddress.getAddress(),
|
||||||
username: daemonUsername.text,
|
username: daemonUsername.text,
|
||||||
password: daemonPassword.text,
|
password: daemonPassword.text,
|
||||||
|
@ -81,6 +87,7 @@ MoneroComponents.Dialog {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remoteNodeLabel.text = "";
|
||||||
remoteNodeAddress.daemonAddrText = "";
|
remoteNodeAddress.daemonAddrText = "";
|
||||||
remoteNodeAddress.daemonPortText = "";
|
remoteNodeAddress.daemonPortText = "";
|
||||||
daemonUsername.text = "";
|
daemonUsername.text = "";
|
||||||
|
@ -89,6 +96,18 @@ MoneroComponents.Dialog {
|
||||||
root.success = false;
|
root.success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MoneroComponents.LineEdit {
|
||||||
|
id: remoteNodeLabel
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.minimumWidth: 220
|
||||||
|
labelText: qsTr("Label") + translationManager.emptyString
|
||||||
|
placeholderText: qsTr("(optional)") + translationManager.emptyString
|
||||||
|
placeholderFontSize: 15
|
||||||
|
text: ""
|
||||||
|
labelFontSize: 14
|
||||||
|
fontSize: 15
|
||||||
|
}
|
||||||
|
|
||||||
MoneroComponents.RemoteNodeEdit {
|
MoneroComponents.RemoteNodeEdit {
|
||||||
id: remoteNodeAddress
|
id: remoteNodeAddress
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
|
@ -60,6 +60,10 @@ ColumnLayout {
|
||||||
height: 30
|
height: 30
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
color: itemMouseArea.containsMouse || trustedDaemonCheckMark.labelMouseArea.containsMouse || index === remoteNodesModel.selected ? MoneroComponents.Style.titleBarButtonHoverColor : "transparent"
|
color: itemMouseArea.containsMouse || trustedDaemonCheckMark.labelMouseArea.containsMouse || index === remoteNodesModel.selected ? MoneroComponents.Style.titleBarButtonHoverColor : "transparent"
|
||||||
|
property var networkType: remoteNodesModel.get(index) ? remoteNodesModel.get(index).networkType : ""
|
||||||
|
visible: (networkType ? networkType == persistentSettings.nettype.toString()
|
||||||
|
: persistentSettings.nettype.toString() == 0 ? true
|
||||||
|
: false)
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
visible: index === remoteNodesModel.selected
|
visible: index === remoteNodesModel.selected
|
||||||
|
@ -76,7 +80,7 @@ ColumnLayout {
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
height: 1
|
height: 1
|
||||||
visible: index > 0
|
visible: index != remoteNodesModel.findFirstRemoteNodeAvailable(persistentSettings.nettype)
|
||||||
|
|
||||||
MoneroEffects.ColorTransition {
|
MoneroEffects.ColorTransition {
|
||||||
targetObj: parent
|
targetObj: parent
|
||||||
|
@ -90,6 +94,7 @@ ColumnLayout {
|
||||||
anchors.rightMargin: 80
|
anchors.rightMargin: 80
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
property var trusted: remoteNodesModel.get(index) ? remoteNodesModel.get(index).trusted : false
|
property var trusted: remoteNodesModel.get(index) ? remoteNodesModel.get(index).trusted : false
|
||||||
|
property var label: remoteNodesModel.get(index) ? remoteNodesModel.get(index).label : ""
|
||||||
|
|
||||||
MoneroComponents.TextPlain {
|
MoneroComponents.TextPlain {
|
||||||
id: addressText
|
id: addressText
|
||||||
|
@ -99,7 +104,7 @@ ColumnLayout {
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: 6
|
anchors.leftMargin: 6
|
||||||
font.pixelSize: 16
|
font.pixelSize: 16
|
||||||
text: address
|
text: (label ? label + " (" + address + ")" : address)
|
||||||
themeTransition: false
|
themeTransition: false
|
||||||
elide: Text.ElideMiddle
|
elide: Text.ElideMiddle
|
||||||
}
|
}
|
||||||
|
|
100
main.qml
100
main.qml
|
@ -137,7 +137,7 @@ ApplicationWindow {
|
||||||
passwordDialog.onAcceptedCallback = function() {
|
passwordDialog.onAcceptedCallback = function() {
|
||||||
if(walletPassword === passwordDialog.password)
|
if(walletPassword === passwordDialog.password)
|
||||||
passwordDialog.close();
|
passwordDialog.close();
|
||||||
else
|
else
|
||||||
passwordDialog.showError(qsTr("Wrong password") + translationManager.emptyString);
|
passwordDialog.showError(qsTr("Wrong password") + translationManager.emptyString);
|
||||||
}
|
}
|
||||||
passwordDialog.open(usefulName(persistentSettings.wallet_path));
|
passwordDialog.open(usefulName(persistentSettings.wallet_path));
|
||||||
|
@ -358,6 +358,46 @@ ApplicationWindow {
|
||||||
|
|
||||||
if (persistentSettings.useRemoteNode) {
|
if (persistentSettings.useRemoteNode) {
|
||||||
const remoteNode = remoteNodesModel.currentRemoteNode();
|
const remoteNode = remoteNodesModel.currentRemoteNode();
|
||||||
|
var firstRemoteNodeAvailable = remoteNodesModel.findFirstRemoteNodeAvailable(persistentSettings.nettype)
|
||||||
|
if (!remoteNodesModel.currentRemoteNode()) {
|
||||||
|
remoteNodesModel.applyRemoteNode(firstRemoteNodeAvailable)
|
||||||
|
} else {
|
||||||
|
if (!remoteNodesModel.currentRemoteNode().networkType) {
|
||||||
|
//backward compatibility with previous remote nodes that don't have networkType set
|
||||||
|
if (persistentSettings.nettype != 0) {
|
||||||
|
if (persistentSettings.nettype == 1) {
|
||||||
|
if (remoteNodesModel.lastTestnetNodeSelected == -1) {
|
||||||
|
remoteNodesModel.lastTestnetNodeSelected = firstRemoteNodeAvailable
|
||||||
|
}
|
||||||
|
remoteNodesModel.applyRemoteNode(remoteNodesModel.lastTestnetNodeSelected)
|
||||||
|
} else if (persistentSettings.nettype == 2) {
|
||||||
|
if (remoteNodesModel.lastStagenetNodeSelected == -1) {
|
||||||
|
remoteNodesModel.lastStagenetNodeSelected = firstRemoteNodeAvailable
|
||||||
|
}
|
||||||
|
remoteNodesModel.applyRemoteNode(remoteNodesModel.lastStagenetNodeSelected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (remoteNodesModel.currentRemoteNode().networkType != persistentSettings.nettype) {
|
||||||
|
if (persistentSettings.nettype == 0) {
|
||||||
|
if (remoteNodesModel.lastMainnetNodeSelected == -1) {
|
||||||
|
remoteNodesModel.lastMainnetNodeSelected = firstRemoteNodeAvailable
|
||||||
|
}
|
||||||
|
remoteNodesModel.applyRemoteNode(remoteNodesModel.lastMainnetNodeSelected)
|
||||||
|
} else if (persistentSettings.nettype == 1) {
|
||||||
|
if (remoteNodesModel.lastTestnetNodeSelected == -1) {
|
||||||
|
remoteNodesModel.lastTestnetNodeSelected = firstRemoteNodeAvailable
|
||||||
|
}
|
||||||
|
remoteNodesModel.applyRemoteNode(remoteNodesModel.lastTestnetNodeSelected)
|
||||||
|
} else if (persistentSettings.nettype == 2) {
|
||||||
|
if (remoteNodesModel.lastStagenetNodeSelected == -1) {
|
||||||
|
remoteNodesModel.lastStagenetNodeSelected = firstRemoteNodeAvailable
|
||||||
|
}
|
||||||
|
remoteNodesModel.applyRemoteNode(remoteNodesModel.lastStagenetNodeSelected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
currentDaemonAddress = remoteNode.address;
|
currentDaemonAddress = remoteNode.address;
|
||||||
currentWallet.setDaemonLogin(remoteNode.username, remoteNode.password);
|
currentWallet.setDaemonLogin(remoteNode.username, remoteNode.password);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1042,10 +1082,10 @@ ApplicationWindow {
|
||||||
var isReserveProof = signature.indexOf("ReserveProofV") === 0;
|
var isReserveProof = signature.indexOf("ReserveProofV") === 0;
|
||||||
if (address.length > 0 && !isReserveProof) {
|
if (address.length > 0 && !isReserveProof) {
|
||||||
result = currentWallet.checkTxProof(txid, address, message, signature);
|
result = currentWallet.checkTxProof(txid, address, message, signature);
|
||||||
}
|
}
|
||||||
else if (isReserveProof) {
|
else if (isReserveProof) {
|
||||||
result = currentWallet.checkReserveProof(address, message, signature);
|
result = currentWallet.checkReserveProof(address, message, signature);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result = currentWallet.checkSpendProof(txid, message, signature);
|
result = currentWallet.checkSpendProof(txid, message, signature);
|
||||||
}
|
}
|
||||||
|
@ -1078,7 +1118,7 @@ ApplicationWindow {
|
||||||
informationPopup.title = qsTr("Payment proof check") + translationManager.emptyString;
|
informationPopup.title = qsTr("Payment proof check") + translationManager.emptyString;
|
||||||
informationPopup.icon = good ? StandardIcon.Information : StandardIcon.Critical;
|
informationPopup.icon = good ? StandardIcon.Information : StandardIcon.Critical;
|
||||||
informationPopup.text = good ? qsTr("Good signature") : qsTr("Bad signature");
|
informationPopup.text = good ? qsTr("Good signature") : qsTr("Bad signature");
|
||||||
}
|
}
|
||||||
else if (isReserveProof && results[0] === "true") {
|
else if (isReserveProof && results[0] === "true") {
|
||||||
var good = results[1] === "true";
|
var good = results[1] === "true";
|
||||||
informationPopup.title = qsTr("Reserve proof check") + translationManager.emptyString;
|
informationPopup.title = qsTr("Reserve proof check") + translationManager.emptyString;
|
||||||
|
@ -1480,6 +1520,9 @@ ApplicationWindow {
|
||||||
id: remoteNodesModel
|
id: remoteNodesModel
|
||||||
|
|
||||||
property int selected: 0
|
property int selected: 0
|
||||||
|
property int lastMainnetNodeSelected: -1
|
||||||
|
property int lastTestnetNodeSelected: -1
|
||||||
|
property int lastStagenetNodeSelected: -1
|
||||||
|
|
||||||
signal store()
|
signal store()
|
||||||
|
|
||||||
|
@ -1491,6 +1534,9 @@ ApplicationWindow {
|
||||||
remoteNodesModel.append(remoteNode);
|
remoteNodesModel.append(remoteNode);
|
||||||
}
|
}
|
||||||
selected = remoteNodes.selected % remoteNodesModel.count || 0;
|
selected = remoteNodes.selected % remoteNodesModel.count || 0;
|
||||||
|
lastMainnetNodeSelected = remoteNodes.lastMainnetNodeSelected;
|
||||||
|
lastTestnetNodeSelected = remoteNodes.lastTestnetNodeSelected;
|
||||||
|
lastStagenetNodeSelected = remoteNodes.lastStagenetNodeSelected;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('failed to parse remoteNodesSerialized', e);
|
console.error('failed to parse remoteNodesSerialized', e);
|
||||||
}
|
}
|
||||||
|
@ -1502,6 +1548,9 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
persistentSettings.remoteNodesSerialized = JSON.stringify({
|
persistentSettings.remoteNodesSerialized = JSON.stringify({
|
||||||
selected: selected,
|
selected: selected,
|
||||||
|
lastMainnetNodeSelected: lastMainnetNodeSelected,
|
||||||
|
lastTestnetNodeSelected: lastTestnetNodeSelected,
|
||||||
|
lastStagenetNodeSelected: lastStagenetNodeSelected,
|
||||||
nodes: remoteNodes
|
nodes: remoteNodes
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1510,7 +1559,9 @@ ApplicationWindow {
|
||||||
function appendIfNotExists(newRemoteNode) {
|
function appendIfNotExists(newRemoteNode) {
|
||||||
for (var index = 0; index < remoteNodesModel.count; ++index) {
|
for (var index = 0; index < remoteNodesModel.count; ++index) {
|
||||||
const remoteNode = remoteNodesModel.get(index);
|
const remoteNode = remoteNodesModel.get(index);
|
||||||
if (remoteNode.address == newRemoteNode.address &&
|
if (remoteNode.label == newRemoteNode.label &&
|
||||||
|
remoteNode.networkType == newRemoteNode.networkType &&
|
||||||
|
remoteNode.address == newRemoteNode.address &&
|
||||||
remoteNode.username == newRemoteNode.username &&
|
remoteNode.username == newRemoteNode.username &&
|
||||||
remoteNode.password == newRemoteNode.password &&
|
remoteNode.password == newRemoteNode.password &&
|
||||||
remoteNode.trusted == newRemoteNode.trusted) {
|
remoteNode.trusted == newRemoteNode.trusted) {
|
||||||
|
@ -1530,6 +1581,13 @@ ApplicationWindow {
|
||||||
currentWallet.setTrustedDaemon(remoteNode.trusted);
|
currentWallet.setTrustedDaemon(remoteNode.trusted);
|
||||||
appWindow.connectRemoteNode();
|
appWindow.connectRemoteNode();
|
||||||
}
|
}
|
||||||
|
if (persistentSettings.nettype == 0) {
|
||||||
|
remoteNodesModel.lastMainnetNodeSelected = selected;
|
||||||
|
} else if (persistentSettings.nettype == 1) {
|
||||||
|
remoteNodesModel.lastTestnetNodeSelected = selected;
|
||||||
|
} else if (persistentSettings.nettype == 2) {
|
||||||
|
remoteNodesModel.lastStagenetNodeSelected = selected;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function currentRemoteNode() {
|
function currentRemoteNode() {
|
||||||
|
@ -1537,6 +1595,8 @@ ApplicationWindow {
|
||||||
return remoteNodesModel.get(selected);
|
return remoteNodesModel.get(selected);
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
label: "",
|
||||||
|
networkType: "",
|
||||||
address: "",
|
address: "",
|
||||||
username: "",
|
username: "",
|
||||||
password: "",
|
password: "",
|
||||||
|
@ -1546,6 +1606,15 @@ ApplicationWindow {
|
||||||
|
|
||||||
function removeSelectNextIfNeeded(index) {
|
function removeSelectNextIfNeeded(index) {
|
||||||
remoteNodesModel.remove(index);
|
remoteNodesModel.remove(index);
|
||||||
|
if (index < remoteNodesModel.lastMainnetNodeSelected) {
|
||||||
|
remoteNodesModel.lastMainnetNodeSelected = remoteNodesModel.lastMainnetNodeSelected - 1
|
||||||
|
}
|
||||||
|
if (index < remoteNodesModel.lastTestnetNodeSelected) {
|
||||||
|
remoteNodesModel.lastTestnetNodeSelected = remoteNodesModel.lastTestnetNodeSelected - 1
|
||||||
|
}
|
||||||
|
if (index < remoteNodesModel.lastStagenetNodeSelected) {
|
||||||
|
remoteNodesModel.lastStagenetNodeSelected = remoteNodesModel.lastStagenetNodeSelected - 1
|
||||||
|
}
|
||||||
if (selected == index) {
|
if (selected == index) {
|
||||||
applyRemoteNode(selected % remoteNodesModel.count || 0);
|
applyRemoteNode(selected % remoteNodesModel.count || 0);
|
||||||
} else if (selected > index) {
|
} else if (selected > index) {
|
||||||
|
@ -1553,6 +1622,16 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function findFirstRemoteNodeAvailable(nettype) {
|
||||||
|
for (var index = 0; index < remoteNodesModel.count; ++index) {
|
||||||
|
const remoteNode = remoteNodesModel.get(index);
|
||||||
|
if (remoteNode.networkType == nettype || persistentSettings.nettype == 0 && !remoteNode.networkType) {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
onCountChanged: store()
|
onCountChanged: store()
|
||||||
onDataChanged: store()
|
onDataChanged: store()
|
||||||
onSelectedChanged: store()
|
onSelectedChanged: store()
|
||||||
|
@ -2305,6 +2384,17 @@ ApplicationWindow {
|
||||||
console.log("walletMode: " + (mode === 0 ? "simple": mode === 1 ? "simple (bootstrap)" : "Advanced"));
|
console.log("walletMode: " + (mode === 0 ? "simple": mode === 1 ? "simple (bootstrap)" : "Advanced"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function networkTypeAsString() {
|
||||||
|
if (persistentSettings.nettype == 0){
|
||||||
|
return "mainnet";
|
||||||
|
}
|
||||||
|
else if (persistentSettings.nettype == 1) {
|
||||||
|
return "testnet";
|
||||||
|
} else {
|
||||||
|
return "stagenet"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: inactiveOverlay
|
id: inactiveOverlay
|
||||||
visible: blur.visible
|
visible: blur.visible
|
||||||
|
|
Loading…
Reference in a new issue