Skip to content

Commit 1a18f92

Browse files
jarolrodhebasto
authored andcommitted
qml: add and wire natpmp setting to OptionsModel backend
Github-Pull: #222 Rebased-From: 30dec24
1 parent 13243fc commit 1a18f92

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/qml/BitcoinApp/Components/ConnectionSettings.qml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ ColumnLayout {
2929
Setting {
3030
Layout.fillWidth: true
3131
header: qsTr("Map port using NAT-PMP")
32-
actionItem: OptionSwitch {}
32+
actionItem: OptionSwitch {
33+
checked: optionsModel.natpmp
34+
onToggled: optionsModel.natpmp = checked
35+
}
3336
}
3437
Setting {
3538
Layout.fillWidth: true

src/qml/BitcoinApp/options_model.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ void OptionsQmlModel::setListen(bool new_listen)
3030
}
3131
}
3232

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+
3342
void OptionsQmlModel::setPrune(bool new_prune)
3443
{
3544
if (new_prune != m_prune) {

src/qml/BitcoinApp/options_model.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class OptionsQmlModel : public QObject
1818
{
1919
Q_OBJECT
2020
Q_PROPERTY(bool listen READ listen WRITE setListen NOTIFY listenChanged)
21+
Q_PROPERTY(bool natpmp READ natpmp WRITE setNatpmp NOTIFY natpmpChanged)
2122
Q_PROPERTY(bool prune READ prune WRITE setPrune NOTIFY pruneChanged)
2223
Q_PROPERTY(int pruneSizeGB READ pruneSizeGB WRITE setPruneSizeGB NOTIFY pruneSizeGBChanged)
2324
Q_PROPERTY(bool upnp READ upnp WRITE setUpnp NOTIFY upnpChanged)
@@ -27,6 +28,8 @@ class OptionsQmlModel : public QObject
2728

2829
bool listen() const { return m_listen; }
2930
void setListen(bool new_listen);
31+
bool natpmp() const { return m_natpmp; }
32+
void setNatpmp(bool new_natpmp);
3033
bool prune() const { return m_prune; }
3134
void setPrune(bool new_prune);
3235
int pruneSizeGB() const { return m_prune_size_gb; }
@@ -36,6 +39,7 @@ class OptionsQmlModel : public QObject
3639

3740
Q_SIGNALS:
3841
void listenChanged(bool new_listen);
42+
void natpmpChanged(bool new_natpmp);
3943
void pruneChanged(bool new_prune);
4044
void pruneSizeGBChanged(int new_prune_size_gb);
4145
void upnpChanged(bool new_upnp);
@@ -45,6 +49,7 @@ class OptionsQmlModel : public QObject
4549

4650
// Properties that are exposed to QML.
4751
bool m_listen;
52+
bool m_natpmp;
4853
bool m_prune;
4954
int m_prune_size_gb;
5055
bool m_upnp;

0 commit comments

Comments
 (0)