-
Notifications
You must be signed in to change notification settings - Fork 39
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
Only write options after onboarding #284
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -8,6 +8,7 @@ | |||||||
#include <common/settings.h> | ||||||||
#include <common/system.h> | ||||||||
#include <interfaces/node.h> | ||||||||
#include <mapport.h> | ||||||||
#include <qt/guiconstants.h> | ||||||||
#include <qt/guiutil.h> | ||||||||
#include <qt/optionsmodel.h> | ||||||||
|
@@ -23,23 +24,34 @@ | |||||||
#include <QDir> | ||||||||
#include <QSettings> | ||||||||
|
||||||||
OptionsQmlModel::OptionsQmlModel(interfaces::Node& node) | ||||||||
OptionsQmlModel::OptionsQmlModel(interfaces::Node& node, bool is_onboarded) | ||||||||
: m_node{node} | ||||||||
, m_onboarded{is_onboarded} | ||||||||
{ | ||||||||
m_dbcache_size_mib = SettingToInt(m_node.getPersistentSetting("dbcache"), nDefaultDbCache); | ||||||||
|
||||||||
m_listen = SettingToBool(m_node.getPersistentSetting("listen"), DEFAULT_LISTEN); | ||||||||
|
||||||||
m_natpmp = SettingToBool(m_node.getPersistentSetting("natpmp"), DEFAULT_NATPMP); | ||||||||
|
||||||||
int64_t prune_value{SettingToInt(m_node.getPersistentSetting("prune"), 0)}; | ||||||||
m_prune = (prune_value > 1); | ||||||||
m_prune_size_gb = m_prune ? PruneMiBtoGB(prune_value) : DEFAULT_PRUNE_TARGET_GB; | ||||||||
|
||||||||
m_script_threads = SettingToInt(m_node.getPersistentSetting("par"), DEFAULT_SCRIPTCHECK_THREADS); | ||||||||
|
||||||||
m_server = SettingToBool(m_node.getPersistentSetting("server"), false); | ||||||||
|
||||||||
m_upnp = SettingToBool(m_node.getPersistentSetting("upnp"), DEFAULT_UPNP); | ||||||||
} | ||||||||
|
||||||||
void OptionsQmlModel::setDbcacheSizeMiB(int new_dbcache_size_mib) | ||||||||
{ | ||||||||
if (new_dbcache_size_mib != m_dbcache_size_mib) { | ||||||||
m_dbcache_size_mib = new_dbcache_size_mib; | ||||||||
m_node.updateRwSetting("dbcache", new_dbcache_size_mib); | ||||||||
if (m_onboarded) { | ||||||||
m_node.updateRwSetting("dbcache", new_dbcache_size_mib); | ||||||||
} | ||||||||
Q_EMIT dbcacheSizeMiBChanged(new_dbcache_size_mib); | ||||||||
} | ||||||||
} | ||||||||
|
@@ -48,7 +60,9 @@ void OptionsQmlModel::setListen(bool new_listen) | |||||||
{ | ||||||||
if (new_listen != m_listen) { | ||||||||
m_listen = new_listen; | ||||||||
m_node.updateRwSetting("listen", new_listen); | ||||||||
if (m_onboarded) { | ||||||||
m_node.updateRwSetting("listen", new_listen); | ||||||||
} | ||||||||
Q_EMIT listenChanged(new_listen); | ||||||||
} | ||||||||
} | ||||||||
|
@@ -57,7 +71,9 @@ void OptionsQmlModel::setNatpmp(bool new_natpmp) | |||||||
{ | ||||||||
if (new_natpmp != m_natpmp) { | ||||||||
m_natpmp = new_natpmp; | ||||||||
m_node.updateRwSetting("natpmp", new_natpmp); | ||||||||
if (m_onboarded) { | ||||||||
m_node.updateRwSetting("natpmp", new_natpmp); | ||||||||
} | ||||||||
Q_EMIT natpmpChanged(new_natpmp); | ||||||||
} | ||||||||
} | ||||||||
|
@@ -66,7 +82,9 @@ void OptionsQmlModel::setPrune(bool new_prune) | |||||||
{ | ||||||||
if (new_prune != m_prune) { | ||||||||
m_prune = new_prune; | ||||||||
m_node.updateRwSetting("prune", pruneSetting()); | ||||||||
if (m_onboarded) { | ||||||||
m_node.updateRwSetting("prune", pruneSetting()); | ||||||||
} | ||||||||
Q_EMIT pruneChanged(new_prune); | ||||||||
} | ||||||||
} | ||||||||
|
@@ -75,7 +93,9 @@ void OptionsQmlModel::setPruneSizeGB(int new_prune_size_gb) | |||||||
{ | ||||||||
if (new_prune_size_gb != m_prune_size_gb) { | ||||||||
m_prune_size_gb = new_prune_size_gb; | ||||||||
m_node.updateRwSetting("prune", pruneSetting()); | ||||||||
if (m_onboarded) { | ||||||||
m_node.updateRwSetting("prune", pruneSetting()); | ||||||||
} | ||||||||
Q_EMIT pruneSizeGBChanged(new_prune_size_gb); | ||||||||
} | ||||||||
} | ||||||||
|
@@ -84,7 +104,9 @@ void OptionsQmlModel::setScriptThreads(int new_script_threads) | |||||||
{ | ||||||||
if (new_script_threads != m_script_threads) { | ||||||||
m_script_threads = new_script_threads; | ||||||||
m_node.updateRwSetting("par", new_script_threads); | ||||||||
if (m_onboarded) { | ||||||||
m_node.updateRwSetting("par", new_script_threads); | ||||||||
} | ||||||||
Q_EMIT scriptThreadsChanged(new_script_threads); | ||||||||
} | ||||||||
} | ||||||||
|
@@ -93,7 +115,9 @@ void OptionsQmlModel::setServer(bool new_server) | |||||||
{ | ||||||||
if (new_server != m_server) { | ||||||||
m_server = new_server; | ||||||||
m_node.updateRwSetting("server", new_server); | ||||||||
if (m_onboarded) { | ||||||||
m_node.updateRwSetting("server", new_server); | ||||||||
} | ||||||||
Q_EMIT serverChanged(new_server); | ||||||||
} | ||||||||
} | ||||||||
|
@@ -102,7 +126,9 @@ void OptionsQmlModel::setUpnp(bool new_upnp) | |||||||
{ | ||||||||
if (new_upnp != m_upnp) { | ||||||||
m_upnp = new_upnp; | ||||||||
m_node.updateRwSetting("upnp", new_upnp); | ||||||||
if (m_onboarded) { | ||||||||
m_node.updateRwSetting("upnp", new_upnp); | ||||||||
} | ||||||||
Q_EMIT upnpChanged(new_upnp); | ||||||||
} | ||||||||
} | ||||||||
|
@@ -136,4 +162,31 @@ void OptionsQmlModel::setCustomDataDirArgs(QString path) | |||||||
// TODO: add actual custom data wiring | ||||||||
qDebug() << "PlaceHolder: Created data directory: " << path; | ||||||||
} | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
void OptionsQmlModel::onboard() | ||||||||
{ | ||||||||
m_node.resetSettings(); | ||||||||
if (m_dbcache_size_mib != nDefaultDbCache) { | ||||||||
m_node.updateRwSetting("dbcache", m_dbcache_size_mib); | ||||||||
} | ||||||||
if (m_listen) { | ||||||||
m_node.updateRwSetting("listen", m_listen); | ||||||||
} | ||||||||
if (m_natpmp) { | ||||||||
m_node.updateRwSetting("natpmp", m_natpmp); | ||||||||
} | ||||||||
if (m_prune) { | ||||||||
m_node.updateRwSetting("prune", pruneSetting()); | ||||||||
} | ||||||||
if (m_script_threads != DEFAULT_SCRIPTCHECK_THREADS) { | ||||||||
m_node.updateRwSetting("par", m_script_threads); | ||||||||
} | ||||||||
if (m_server) { | ||||||||
m_node.updateRwSetting("server", m_server); | ||||||||
} | ||||||||
if (m_upnp) { | ||||||||
m_node.updateRwSetting("upnp", m_upnp); | ||||||||
} | ||||||||
m_onboarded = true; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: accidentally removed the last line break?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. already has a newline character at the end of the file. don't need an additional blank line. |
||||||||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is needed for PruneMiBtoGB i believe