onDaemonStarted/stopped signals/slots

This commit is contained in:
Jaquee 2016-11-25 21:09:32 +01:00
parent de635cb24f
commit 48471f3407
No known key found for this signature in database
GPG key ID: 384E52B09F45DC39
3 changed files with 30 additions and 15 deletions

View file

@ -59,6 +59,7 @@ ApplicationWindow {
property int restoreHeight:0
property bool daemonSynced: false
property int maxWindowHeight: (Screen.height < 900)? 720 : 800;
property bool daemonRunning: false
// true if wallet ever synchronized
property bool walletInitialized : false
@ -292,6 +293,10 @@ ApplicationWindow {
// TODO: implement onDaemonSynced or similar in wallet API and don't start refresh thread before daemon is synced
daemonSynced = (currentWallet.connected != Wallet.ConnectionStatus_Disconnected && dCurrentBlock >= dTargetBlock)
// If wallet isnt connected and no daemon is running - Ask
if(!currentWallet.connected && !daemonManager.running() && !walletInitialized){
daemonManagerDialog.open();
}
// Refresh is succesfull if blockchain height > 1
if (currentWallet.blockChainHeight() > 1){
@ -317,22 +322,19 @@ ApplicationWindow {
walletInitialized = true
}
// daemonManager.daemonConsole();
// console.log("Daemon runnnig: ",daemonManager.running());
if(!daemonManager.running()){
daemonManagerDialog.open();
}
onWalletUpdate();
}
function onDaemonStarted(){
console.log("daemon started");
daemonRunning = true;
}
function onDaemonStopped(){
console.log("daemon stopped");
daemonRunning = false;
}
function onWalletNewBlock(blockHeight) {
if (splash.visible) {
var currHeight = blockHeight
@ -645,6 +647,9 @@ ApplicationWindow {
walletManager.walletOpened.connect(onWalletOpened);
walletManager.walletClosed.connect(onWalletClosed);
daemonManager.daemonStarted.connect(onDaemonStarted);
daemonManager.daemonStopped.connect(onDaemonStopped);
if(!walletsFound()) {
rootItem.state = "wizard"
} else {

View file

@ -36,6 +36,8 @@ bool DaemonManager::start()
if(!started){
qDebug() << "Daemon start error: " + m_daemon->errorString();
} else {
emit daemonStarted();
}
return started;
@ -43,6 +45,15 @@ bool DaemonManager::start()
bool DaemonManager::stop()
{
if(m_daemon){
qDebug() << "stopping daemon";
m_daemon->terminate();
// Wait until stopped. Max 30 seconds
bool stopped = m_daemon->waitForFinished(30000);
if(stopped) emit daemonStopped();
return stopped;
}
return true;
}

View file

@ -21,8 +21,7 @@ public:
Q_INVOKABLE bool running() const;
signals:
void daemonStarted(const QProcess &d);
void daemonStarted();
void daemonStopped();
public slots: