Skip to content

Commit 5c6ed49

Browse files
johnny9shaavan
authored andcommitted
qml: add ability to pause NodeModel
Github-Pull: #220 Rebased-From: 094a2c4 Co-authored-by: shaavan <shaavan.github@gmail.com>
1 parent 6726694 commit 5c6ed49

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/qml/BitcoinApp/nodemodel.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ void NodeModel::setVerificationProgress(double new_progress)
3535
}
3636
}
3737

38+
void NodeModel::setPause(bool new_pause)
39+
{
40+
if(m_pause != new_pause) {
41+
m_pause = new_pause;
42+
m_node.setNetworkActive(!new_pause);
43+
Q_EMIT pauseChanged(new_pause);
44+
}
45+
}
46+
3847
void NodeModel::startNodeInitializionThread()
3948
{
4049
Q_EMIT requestedInitialize();

src/qml/BitcoinApp/nodemodel.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class NodeModel : public QObject
2626
Q_OBJECT
2727
Q_PROPERTY(int blockTipHeight READ blockTipHeight NOTIFY blockTipHeightChanged)
2828
Q_PROPERTY(double verificationProgress READ verificationProgress NOTIFY verificationProgressChanged)
29+
Q_PROPERTY(bool pause READ pause WRITE setPause NOTIFY pauseChanged)
2930

3031
public:
3132
explicit NodeModel(interfaces::Node& node);
@@ -34,6 +35,8 @@ class NodeModel : public QObject
3435
void setBlockTipHeight(int new_height);
3536
double verificationProgress() const { return m_verification_progress; }
3637
void setVerificationProgress(double new_progress);
38+
bool pause() const { return m_pause; }
39+
void setPause(bool new_pause);
3740

3841
Q_INVOKABLE void startNodeInitializionThread();
3942

@@ -48,6 +51,7 @@ public Q_SLOTS:
4851
void requestedInitialize();
4952
void requestedShutdown();
5053
void verificationProgressChanged();
54+
void pauseChanged(bool new_pause);
5155

5256
protected:
5357
void timerEvent(QTimerEvent* event) override;
@@ -56,6 +60,7 @@ public Q_SLOTS:
5660
// Properties that are exposed to QML.
5761
int m_block_tip_height{0};
5862
double m_verification_progress{0.0};
63+
bool m_pause{false};
5964

6065
int m_shutdown_polling_timer_id{0};
6166

0 commit comments

Comments
 (0)