Skip to content

Commit d62a49f

Browse files
committed
Merge #222: Initial support and wiring for currently implemented connection settings
15291b2 qml: add and wire server setting to OptionsModel backend (jarolrod) 30dec24 qml: add and wire natpmp setting to OptionsModel backend (jarolrod) 04cb898 qml: add and wire upnp setting to OptionsModel backend (jarolrod) faeb551 qml: add and wire listen setting to OptionsModel backend (jarolrod) Pull request description: This introduces initial support and wiring for the currently implemented settings that are part of the `ConnectionSettings.qml`. This does not set defaults for these, nor calls additionally necessary steps in the case of mapping to actually map the ports as that is left for a follow-up. [![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/222) [![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/222) [![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/222) [![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/222) ACKs for top commit: johnny9: ACK 15291b2 Tree-SHA512: 63df7bed92478c2c2e47b171499907449d497d68e4e8c3760e1772dde3123763ab0fa64929a45f343661200a52258a79319224e3080cd3743b2150a42a0b9ee2
2 parents 1a71fd4 + 15291b2 commit d62a49f

File tree

3 files changed

+72
-4
lines changed

3 files changed

+72
-4
lines changed

src/qml/components/ConnectionSettings.qml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,34 @@ ColumnLayout {
1313
Layout.fillWidth: true
1414
header: qsTr("Enable listening")
1515
description: qsTr("Allows incoming connections")
16-
actionItem: OptionSwitch {}
16+
actionItem: OptionSwitch {
17+
checked: optionsModel.listen
18+
onToggled: optionsModel.listen = checked
19+
}
1720
}
1821
Setting {
1922
Layout.fillWidth: true
2023
header: qsTr("Map port using UPnP")
21-
actionItem: OptionSwitch {}
24+
actionItem: OptionSwitch {
25+
checked: optionsModel.upnp
26+
onToggled: optionsModel.upnp = checked
27+
}
2228
}
2329
Setting {
2430
Layout.fillWidth: true
2531
header: qsTr("Map port using NAT-PMP")
26-
actionItem: OptionSwitch {}
32+
actionItem: OptionSwitch {
33+
checked: optionsModel.natpmp
34+
onToggled: optionsModel.natpmp = checked
35+
}
2736
}
2837
Setting {
2938
Layout.fillWidth: true
3039
header: qsTr("Enable RPC server")
31-
actionItem: OptionSwitch {}
40+
actionItem: OptionSwitch {
41+
checked: optionsModel.server
42+
onToggled: optionsModel.server = checked
43+
}
3244
}
3345
Setting {
3446
last: true

src/qml/options_model.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,24 @@ OptionsQmlModel::OptionsQmlModel(interfaces::Node& node)
2121
m_prune_size_gb = m_prune ? PruneMiBtoGB(prune_value) : DEFAULT_PRUNE_TARGET_GB;
2222
}
2323

24+
void OptionsQmlModel::setListen(bool new_listen)
25+
{
26+
if (new_listen != m_listen) {
27+
m_listen = new_listen;
28+
m_node.updateRwSetting("listen", new_listen);
29+
Q_EMIT listenChanged(new_listen);
30+
}
31+
}
32+
33+
void OptionsQmlModel::setNatpmp(bool new_natpmp)
34+
{
35+
if (new_natpmp != m_natpmp) {
36+
m_natpmp = new_natpmp;
37+
m_node.updateRwSetting("natpmp", new_natpmp);
38+
Q_EMIT natpmpChanged(new_natpmp);
39+
}
40+
}
41+
2442
void OptionsQmlModel::setPrune(bool new_prune)
2543
{
2644
if (new_prune != m_prune) {
@@ -39,6 +57,24 @@ void OptionsQmlModel::setPruneSizeGB(int new_prune_size_gb)
3957
}
4058
}
4159

60+
void OptionsQmlModel::setServer(bool new_server)
61+
{
62+
if (new_server != m_server) {
63+
m_server = new_server;
64+
m_node.updateRwSetting("server", new_server);
65+
Q_EMIT serverChanged(new_server);
66+
}
67+
}
68+
69+
void OptionsQmlModel::setUpnp(bool new_upnp)
70+
{
71+
if (new_upnp != m_upnp) {
72+
m_upnp = new_upnp;
73+
m_node.updateRwSetting("upnp", new_upnp);
74+
Q_EMIT upnpChanged(new_upnp);
75+
}
76+
}
77+
4278
util::SettingsValue OptionsQmlModel::pruneSetting() const
4379
{
4480
assert(!m_prune || m_prune_size_gb >= 1);

src/qml/options_model.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,47 @@ class Node;
1717
class OptionsQmlModel : public QObject
1818
{
1919
Q_OBJECT
20+
Q_PROPERTY(bool listen READ listen WRITE setListen NOTIFY listenChanged)
21+
Q_PROPERTY(bool natpmp READ natpmp WRITE setNatpmp NOTIFY natpmpChanged)
2022
Q_PROPERTY(bool prune READ prune WRITE setPrune NOTIFY pruneChanged)
2123
Q_PROPERTY(int pruneSizeGB READ pruneSizeGB WRITE setPruneSizeGB NOTIFY pruneSizeGBChanged)
24+
Q_PROPERTY(bool server READ server WRITE setServer NOTIFY serverChanged)
25+
Q_PROPERTY(bool upnp READ upnp WRITE setUpnp NOTIFY upnpChanged)
2226

2327
public:
2428
explicit OptionsQmlModel(interfaces::Node& node);
2529

30+
bool listen() const { return m_listen; }
31+
void setListen(bool new_listen);
32+
bool natpmp() const { return m_natpmp; }
33+
void setNatpmp(bool new_natpmp);
2634
bool prune() const { return m_prune; }
2735
void setPrune(bool new_prune);
2836
int pruneSizeGB() const { return m_prune_size_gb; }
2937
void setPruneSizeGB(int new_prune_size);
38+
bool server() const { return m_server; }
39+
void setServer(bool new_server);
40+
bool upnp() const { return m_upnp; }
41+
void setUpnp(bool new_upnp);
3042

3143
Q_SIGNALS:
44+
void listenChanged(bool new_listen);
45+
void natpmpChanged(bool new_natpmp);
3246
void pruneChanged(bool new_prune);
3347
void pruneSizeGBChanged(int new_prune_size_gb);
48+
void serverChanged(bool new_server);
49+
void upnpChanged(bool new_upnp);
3450

3551
private:
3652
interfaces::Node& m_node;
3753

3854
// Properties that are exposed to QML.
55+
bool m_listen;
56+
bool m_natpmp;
3957
bool m_prune;
4058
int m_prune_size_gb;
59+
bool m_server;
60+
bool m_upnp;
4161

4262
util::SettingsValue pruneSetting() const;
4363
};

0 commit comments

Comments
 (0)