Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SettingsNode: redesign stop/keep local node running #2898

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 42 additions & 13 deletions main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -1420,6 +1420,7 @@ ApplicationWindow {
property bool autosave: true
property int autosaveMinutes: 10
property bool pruneBlockchain: false
property int keepLocalNodeRunning: 2 //0 = stop local node, 1 = keep it running, 2 = always ask

property bool fiatPriceEnabled: false
property bool fiatPriceToggle: false
Expand Down Expand Up @@ -1603,7 +1604,25 @@ ApplicationWindow {
onRejectedCallback();
}
}


StandardDialog {
z: parent.z + 1
id: localNodeRunningConfirmationDialog
closeVisible: false
property var onAcceptedCallback
property var onRejectedCallback
onRejected: {
//Stop local node
if (onRejectedCallback)
onRejectedCallback();
}
onAccepted: {
//Keep local node running
if (onAcceptedCallback)
onAcceptedCallback()
}
}

MoneroComponents.UpdateDialog {
id: updateDialog

Expand Down Expand Up @@ -1845,7 +1864,7 @@ ApplicationWindow {
radius: 64
visible: passwordDialog.visible || inputDialog.visible || splash.visible || updateDialog.visible ||
devicePassphraseDialog.visible || txConfirmationPopup.visible || successfulTxPopup.visible ||
remoteNodeDialog.visible
remoteNodeDialog.visible || localNodeRunningConfirmationDialog.visible
}


Expand Down Expand Up @@ -2080,19 +2099,29 @@ ApplicationWindow {
}

function showDaemonIsRunningDialog(onClose) {
// Show confirmation dialog
confirmationDialog.title = qsTr("Local node is running") + translationManager.emptyString;
confirmationDialog.text = qsTr("Do you want to stop local node or keep it running in the background?") + translationManager.emptyString;
confirmationDialog.icon = StandardIcon.Question;
confirmationDialog.cancelText = qsTr("Force stop") + translationManager.emptyString;
confirmationDialog.okText = qsTr("Keep it running") + translationManager.emptyString;
confirmationDialog.onAcceptedCallback = function() {
if (persistentSettings.keepLocalNodeRunning == 2) {
// 2 = always ask
// Show confirmation dialog
localNodeRunningConfirmationDialog.title = qsTr("Local node is running") + translationManager.emptyString;
localNodeRunningConfirmationDialog.closeVisible = false;
localNodeRunningConfirmationDialog.text = qsTr("Your local node is now running in the background. It is recommended to keep it running in order to help the network and to maintain your blockchain synchronized.") + translationManager.emptyString;
localNodeRunningConfirmationDialog.icon = StandardIcon.Question;
localNodeRunningConfirmationDialog.cancelText = qsTr("Stop local node") + translationManager.emptyString;
localNodeRunningConfirmationDialog.okText = qsTr("Keep it running") + translationManager.emptyString;
localNodeRunningConfirmationDialog.onAcceptedCallback = function() {
onClose();
}
localNodeRunningConfirmationDialog.onRejectedCallback = function() {
stopDaemon(onClose);
};
localNodeRunningConfirmationDialog.open();
} else if (persistentSettings.keepLocalNodeRunning == 1) {
//1 = keep local node running
onClose();
}
confirmationDialog.onRejectedCallback = function() {
} else if (persistentSettings.keepLocalNodeRunning == 0) {
//0 = stop local node
stopDaemon(onClose);
};
confirmationDialog.open();
}
}

onClosing: {
Expand Down
36 changes: 36 additions & 0 deletions pages/settings/SettingsNode.qml
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,42 @@ Rectangle{
}
}

ColumnLayout {
spacing: 10
Layout.fillWidth: true
id: keepLocalNodeRunningColumn
z: parent.z + 1

MoneroComponents.Label {
id: keepLocalNodeRunningLabel
Layout.topMargin: 0
text: qsTr("When closing GUI wallet or connecting to a remote node") + translationManager.emptyString
fontBold: false
fontSize: 14
}

ListModel {
id: keepLocalNodeRunningListModel
ListElement { column1: "Stop local node"; }
ListElement { column1: "Keep local node running (recommended)"; }
ListElement { column1: "Always ask whether the node should be stopped"; }
}

MoneroComponents.StandardDropdown {
id: keepLocalNodeRunningDropDown
dataModel: keepLocalNodeRunningListModel
itemTopMargin: 2
currentIndex: appWindow.persistentSettings.keepLocalNodeRunning;
onChanged: {
console.log("keepLocalNodeRunning changed: ",currentIndex);
appWindow.persistentSettings.keepLocalNodeRunning = currentIndex;
}
Layout.fillWidth: true
Layout.preferredWidth: keepLocalNodeRunningColumn.width
z: parent.z + 1
}
}

MoneroComponents.LineEditMulti {
id: daemonFlags
Layout.fillWidth: true
Expand Down