1717
1818#include  < cassert> 
1919
20- OptionsQmlModel::OptionsQmlModel (interfaces::Node& node)
20+ OptionsQmlModel::OptionsQmlModel (interfaces::Node& node,  bool  is_onboarded )
2121    : m_node{node}
22+     , m_onboarded{is_onboarded}
2223{
2324    m_dbcache_size_mib = SettingToInt (m_node.getPersistentSetting (" dbcache" 
2425
@@ -41,7 +42,9 @@ void OptionsQmlModel::setDbcacheSizeMiB(int new_dbcache_size_mib)
4142{
4243    if  (new_dbcache_size_mib != m_dbcache_size_mib) {
4344        m_dbcache_size_mib = new_dbcache_size_mib;
44-         m_node.updateRwSetting (" dbcache" 
45+         if  (m_onboarded) {
46+             m_node.updateRwSetting (" dbcache" 
47+         }
4548        Q_EMIT dbcacheSizeMiBChanged (new_dbcache_size_mib);
4649    }
4750}
@@ -50,7 +53,9 @@ void OptionsQmlModel::setListen(bool new_listen)
5053{
5154    if  (new_listen != m_listen) {
5255        m_listen = new_listen;
53-         m_node.updateRwSetting (" listen" 
56+         if  (m_onboarded) {
57+             m_node.updateRwSetting (" listen" 
58+         }
5459        Q_EMIT listenChanged (new_listen);
5560    }
5661}
@@ -59,7 +64,9 @@ void OptionsQmlModel::setNatpmp(bool new_natpmp)
5964{
6065    if  (new_natpmp != m_natpmp) {
6166        m_natpmp = new_natpmp;
62-         m_node.updateRwSetting (" natpmp" 
67+         if  (m_onboarded) {
68+             m_node.updateRwSetting (" natpmp" 
69+         }
6370        Q_EMIT natpmpChanged (new_natpmp);
6471    }
6572}
@@ -68,7 +75,9 @@ void OptionsQmlModel::setPrune(bool new_prune)
6875{
6976    if  (new_prune != m_prune) {
7077        m_prune = new_prune;
71-         m_node.updateRwSetting (" prune" pruneSetting ());
78+         if  (m_onboarded) {
79+             m_node.updateRwSetting (" prune" pruneSetting ());
80+         }
7281        Q_EMIT pruneChanged (new_prune);
7382    }
7483}
@@ -77,7 +86,9 @@ void OptionsQmlModel::setPruneSizeGB(int new_prune_size_gb)
7786{
7887    if  (new_prune_size_gb != m_prune_size_gb) {
7988        m_prune_size_gb = new_prune_size_gb;
80-         m_node.updateRwSetting (" prune" pruneSetting ());
89+         if  (m_onboarded) {
90+             m_node.updateRwSetting (" prune" pruneSetting ());
91+         }
8192        Q_EMIT pruneSizeGBChanged (new_prune_size_gb);
8293    }
8394}
@@ -86,7 +97,9 @@ void OptionsQmlModel::setScriptThreads(int new_script_threads)
8697{
8798    if  (new_script_threads != m_script_threads) {
8899        m_script_threads = new_script_threads;
89-         m_node.updateRwSetting (" par" 
100+         if  (m_onboarded) {
101+             m_node.updateRwSetting (" par" 
102+         }
90103        Q_EMIT scriptThreadsChanged (new_script_threads);
91104    }
92105}
@@ -95,7 +108,9 @@ void OptionsQmlModel::setServer(bool new_server)
95108{
96109    if  (new_server != m_server) {
97110        m_server = new_server;
98-         m_node.updateRwSetting (" server" 
111+         if  (m_onboarded) {
112+             m_node.updateRwSetting (" server" 
113+         }
99114        Q_EMIT serverChanged (new_server);
100115    }
101116}
@@ -104,7 +119,9 @@ void OptionsQmlModel::setUpnp(bool new_upnp)
104119{
105120    if  (new_upnp != m_upnp) {
106121        m_upnp = new_upnp;
107-         m_node.updateRwSetting (" upnp" 
122+         if  (m_onboarded) {
123+             m_node.updateRwSetting (" upnp" 
124+         }
108125        Q_EMIT upnpChanged (new_upnp);
109126    }
110127}
@@ -114,3 +131,30 @@ common::SettingsValue OptionsQmlModel::pruneSetting() const
114131    assert (!m_prune || m_prune_size_gb >= 1 );
115132    return  m_prune ? PruneGBtoMiB (m_prune_size_gb) : 0 ;
116133}
134+ 
135+ void  OptionsQmlModel::onboard ()
136+ {
137+     m_node.resetSettings ();
138+     if  (m_dbcache_size_mib != nDefaultDbCache) {
139+         m_node.updateRwSetting (" dbcache" 
140+     }
141+     if  (m_listen) {
142+         m_node.updateRwSetting (" listen" 
143+     }
144+     if  (m_natpmp) {
145+         m_node.updateRwSetting (" natpmp" 
146+     }
147+     if  (m_prune) {
148+         m_node.updateRwSetting (" prune" pruneSetting ());
149+     }
150+     if  (m_script_threads != DEFAULT_SCRIPTCHECK_THREADS) {
151+         m_node.updateRwSetting (" par" 
152+     }
153+     if  (m_server) {
154+         m_node.updateRwSetting (" server" 
155+     }
156+     if  (m_upnp) {
157+         m_node.updateRwSetting (" upnp" 
158+     }
159+     m_onboarded = true ;
160+ }
0 commit comments