Skip to content

Commit 02cd1a0

Browse files
jarolrodhebasto
authored andcommitted
qml: add and wire listen setting to OptionsModel backend
Github-Pull: #222 Rebased-From: faeb551
1 parent 380378d commit 02cd1a0

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
@@ -13,7 +13,10 @@ 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

src/qml/BitcoinApp/options_model.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ 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+
2433
void OptionsQmlModel::setPrune(bool new_prune)
2534
{
2635
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
@@ -17,25 +17,30 @@ class Node;
1717
class OptionsQmlModel : public QObject
1818
{
1919
Q_OBJECT
20+
Q_PROPERTY(bool listen READ listen WRITE setListen NOTIFY listenChanged)
2021
Q_PROPERTY(bool prune READ prune WRITE setPrune NOTIFY pruneChanged)
2122
Q_PROPERTY(int pruneSizeGB READ pruneSizeGB WRITE setPruneSizeGB NOTIFY pruneSizeGBChanged)
2223

2324
public:
2425
explicit OptionsQmlModel(interfaces::Node& node);
2526

27+
bool listen() const { return m_listen; }
28+
void setListen(bool new_listen);
2629
bool prune() const { return m_prune; }
2730
void setPrune(bool new_prune);
2831
int pruneSizeGB() const { return m_prune_size_gb; }
2932
void setPruneSizeGB(int new_prune_size);
3033

3134
Q_SIGNALS:
35+
void listenChanged(bool new_listen);
3236
void pruneChanged(bool new_prune);
3337
void pruneSizeGBChanged(int new_prune_size_gb);
3438

3539
private:
3640
interfaces::Node& m_node;
3741

3842
// Properties that are exposed to QML.
43+
bool m_listen;
3944
bool m_prune;
4045
int m_prune_size_gb;
4146

0 commit comments

Comments
 (0)