Skip to content

Commit e8799fd

Browse files
committed
Merge #224: Initial support and wiring for developer settings
3bc5c97 qml: add and wire par (script threads) settings to OptionsModel backend (jarolrod) 217a5cf qml: add and wire dbcache settings to OptionsModel backend (jarolrod) Pull request description: This introduces initial support and wiring for the currently implemented settings that are part of the `DeveloperSettings.qml`. [![Windows](https://img.shields.io/badge/OS-Windows-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/win64/insecure_win_gui.zip?branch=pull/224) [![Intel macOS](https://img.shields.io/badge/OS-Intel%20macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos/insecure_mac_gui.zip?branch=pull/224) [![Apple Silicon macOS](https://img.shields.io/badge/OS-Apple%20Silicon%20macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos_arm64/insecure_mac_arm64_gui.zip?branch=pull/224) [![ARM64 Android](https://img.shields.io/badge/OS-Android-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/android/insecure_android_apk.zip?branch=pull/224) ACKs for top commit: johnny9: ACK 3bc5c97 Tree-SHA512: 78b006d8898aa6c3a9b9ef2fae4b0d32426dbb80822bf5f6d7fcc9083f5b5f35fbaf5628850ec1a5d185c9fcb3f0075de40f475ba6a2d8becc37353f41d9f186
2 parents d1c51ac + 3bc5c97 commit e8799fd

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

src/qml/components/DeveloperOptions.qml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ ColumnLayout {
2525
Setting {
2626
id: dbcacheSetting
2727
Layout.fillWidth: true
28-
header: qsTr("Database cache size")
28+
header: qsTr("Database cache size (MiB)")
2929
actionItem: ValueInput {
3030
parentState: dbcacheSetting.state
31-
description: ("450 MiB")
31+
description: optionsModel.dbcacheSizeMiB
32+
onEditingFinished: optionsModel.dbcacheSizeMiB = parseInt(text)
3233
}
3334
onClicked: loadedItem.forceActiveFocus()
3435
}
@@ -38,7 +39,8 @@ ColumnLayout {
3839
header: qsTr("Script verification threads")
3940
actionItem: ValueInput {
4041
parentState: parSetting.state
41-
description: ("0")
42+
description: optionsModel.scriptThreads
43+
onEditingFinished: optionsModel.scriptThreads = parseInt(text)
4244
}
4345
onClicked: loadedItem.forceActiveFocus()
4446
}

src/qml/options_model.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,33 @@
77
#include <interfaces/node.h>
88
#include <qt/guiconstants.h>
99
#include <qt/optionsmodel.h>
10+
#include <txdb.h>
1011
#include <univalue.h>
1112
#include <util/settings.h>
1213
#include <util/system.h>
14+
#include <validation.h>
1315

1416
#include <cassert>
1517

1618
OptionsQmlModel::OptionsQmlModel(interfaces::Node& node)
1719
: m_node{node}
1820
{
21+
m_dbcache_size_mib = SettingToInt(m_node.getPersistentSetting("dbcache"), nDefaultDbCache);
22+
1923
int64_t prune_value{SettingToInt(m_node.getPersistentSetting("prune"), 0)};
2024
m_prune = (prune_value > 1);
2125
m_prune_size_gb = m_prune ? PruneMiBtoGB(prune_value) : DEFAULT_PRUNE_TARGET_GB;
26+
27+
m_script_threads = SettingToInt(m_node.getPersistentSetting("par"), DEFAULT_SCRIPTCHECK_THREADS);
28+
}
29+
30+
void OptionsQmlModel::setDbcacheSizeMiB(int new_dbcache_size_mib)
31+
{
32+
if (new_dbcache_size_mib != m_dbcache_size_mib) {
33+
m_dbcache_size_mib = new_dbcache_size_mib;
34+
m_node.updateRwSetting("dbcache", new_dbcache_size_mib);
35+
Q_EMIT dbcacheSizeMiBChanged(new_dbcache_size_mib);
36+
}
2237
}
2338

2439
void OptionsQmlModel::setListen(bool new_listen)
@@ -57,6 +72,15 @@ void OptionsQmlModel::setPruneSizeGB(int new_prune_size_gb)
5772
}
5873
}
5974

75+
void OptionsQmlModel::setScriptThreads(int new_script_threads)
76+
{
77+
if (new_script_threads != m_script_threads) {
78+
m_script_threads = new_script_threads;
79+
m_node.updateRwSetting("par", new_script_threads);
80+
Q_EMIT scriptThreadsChanged(new_script_threads);
81+
}
82+
}
83+
6084
void OptionsQmlModel::setServer(bool new_server)
6185
{
6286
if (new_server != m_server) {

src/qml/options_model.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,20 @@ class Node;
1717
class OptionsQmlModel : public QObject
1818
{
1919
Q_OBJECT
20+
Q_PROPERTY(int dbcacheSizeMiB READ dbcacheSizeMiB WRITE setDbcacheSizeMiB NOTIFY dbcacheSizeMiBChanged)
2021
Q_PROPERTY(bool listen READ listen WRITE setListen NOTIFY listenChanged)
2122
Q_PROPERTY(bool natpmp READ natpmp WRITE setNatpmp NOTIFY natpmpChanged)
2223
Q_PROPERTY(bool prune READ prune WRITE setPrune NOTIFY pruneChanged)
2324
Q_PROPERTY(int pruneSizeGB READ pruneSizeGB WRITE setPruneSizeGB NOTIFY pruneSizeGBChanged)
25+
Q_PROPERTY(int scriptThreads READ scriptThreads WRITE setScriptThreads NOTIFY scriptThreadsChanged)
2426
Q_PROPERTY(bool server READ server WRITE setServer NOTIFY serverChanged)
2527
Q_PROPERTY(bool upnp READ upnp WRITE setUpnp NOTIFY upnpChanged)
2628

2729
public:
2830
explicit OptionsQmlModel(interfaces::Node& node);
2931

32+
int dbcacheSizeMiB() const { return m_dbcache_size_mib; }
33+
void setDbcacheSizeMiB(int new_dbcache_size_mib);
3034
bool listen() const { return m_listen; }
3135
void setListen(bool new_listen);
3236
bool natpmp() const { return m_natpmp; }
@@ -35,27 +39,33 @@ class OptionsQmlModel : public QObject
3539
void setPrune(bool new_prune);
3640
int pruneSizeGB() const { return m_prune_size_gb; }
3741
void setPruneSizeGB(int new_prune_size);
42+
int scriptThreads() const { return m_script_threads; }
43+
void setScriptThreads(int new_script_threads);
3844
bool server() const { return m_server; }
3945
void setServer(bool new_server);
4046
bool upnp() const { return m_upnp; }
4147
void setUpnp(bool new_upnp);
4248

4349
Q_SIGNALS:
50+
void dbcacheSizeMiBChanged(int new_dbcache_size_mib);
4451
void listenChanged(bool new_listen);
4552
void natpmpChanged(bool new_natpmp);
4653
void pruneChanged(bool new_prune);
4754
void pruneSizeGBChanged(int new_prune_size_gb);
55+
void scriptThreadsChanged(int new_script_threads);
4856
void serverChanged(bool new_server);
4957
void upnpChanged(bool new_upnp);
5058

5159
private:
5260
interfaces::Node& m_node;
5361

5462
// Properties that are exposed to QML.
63+
int m_dbcache_size_mib;
5564
bool m_listen;
5665
bool m_natpmp;
5766
bool m_prune;
5867
int m_prune_size_gb;
68+
int m_script_threads;
5969
bool m_server;
6070
bool m_upnp;
6171

0 commit comments

Comments
 (0)