Skip to content

Commit 13243fc

Browse files
jarolrodhebasto
authored andcommitted
qml: add and wire upnp setting to OptionsModel backend
Github-Pull: #222 Rebased-From: 04cb898
1 parent 02cd1a0 commit 13243fc

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
@@ -21,7 +21,10 @@ ColumnLayout {
2121
Setting {
2222
Layout.fillWidth: true
2323
header: qsTr("Map port using UPnP")
24-
actionItem: OptionSwitch {}
24+
actionItem: OptionSwitch {
25+
checked: optionsModel.upnp
26+
onToggled: optionsModel.upnp = checked
27+
}
2528
}
2629
Setting {
2730
Layout.fillWidth: true

src/qml/BitcoinApp/options_model.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ void OptionsQmlModel::setPruneSizeGB(int new_prune_size_gb)
4848
}
4949
}
5050

51+
void OptionsQmlModel::setUpnp(bool new_upnp)
52+
{
53+
if (new_upnp != m_upnp) {
54+
m_upnp = new_upnp;
55+
m_node.updateRwSetting("upnp", new_upnp);
56+
Q_EMIT upnpChanged(new_upnp);
57+
}
58+
}
59+
5160
common::SettingsValue OptionsQmlModel::pruneSetting() const
5261
{
5362
assert(!m_prune || m_prune_size_gb >= 1);

src/qml/BitcoinApp/options_model.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class OptionsQmlModel : public QObject
2020
Q_PROPERTY(bool listen READ listen WRITE setListen NOTIFY listenChanged)
2121
Q_PROPERTY(bool prune READ prune WRITE setPrune NOTIFY pruneChanged)
2222
Q_PROPERTY(int pruneSizeGB READ pruneSizeGB WRITE setPruneSizeGB NOTIFY pruneSizeGBChanged)
23+
Q_PROPERTY(bool upnp READ upnp WRITE setUpnp NOTIFY upnpChanged)
2324

2425
public:
2526
explicit OptionsQmlModel(interfaces::Node& node);
@@ -30,11 +31,14 @@ class OptionsQmlModel : public QObject
3031
void setPrune(bool new_prune);
3132
int pruneSizeGB() const { return m_prune_size_gb; }
3233
void setPruneSizeGB(int new_prune_size);
34+
bool upnp() const { return m_upnp; }
35+
void setUpnp(bool new_upnp);
3336

3437
Q_SIGNALS:
3538
void listenChanged(bool new_listen);
3639
void pruneChanged(bool new_prune);
3740
void pruneSizeGBChanged(int new_prune_size_gb);
41+
void upnpChanged(bool new_upnp);
3842

3943
private:
4044
interfaces::Node& m_node;
@@ -43,6 +47,7 @@ class OptionsQmlModel : public QObject
4347
bool m_listen;
4448
bool m_prune;
4549
int m_prune_size_gb;
50+
bool m_upnp;
4651

4752
common::SettingsValue pruneSetting() const;
4853
};

0 commit comments

Comments
 (0)