mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-12-23 12:09:57 +00:00
WalletManager: non-blocking mining status updates
This commit is contained in:
parent
c286c7e5a8
commit
73a3549e09
3 changed files with 22 additions and 3 deletions
|
@ -258,14 +258,18 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function update() {
|
function onMiningStatus(isMining) {
|
||||||
var daemonReady = walletManager.isDaemonLocal(appWindow.currentDaemonAddress) && appWindow.daemonSynced
|
var daemonReady = walletManager.isDaemonLocal(appWindow.currentDaemonAddress) && appWindow.daemonSynced
|
||||||
appWindow.isMining = walletManager.isMining()
|
appWindow.isMining = isMining;
|
||||||
updateStatusText()
|
updateStatusText()
|
||||||
startSoloMinerButton.enabled = !appWindow.isMining && daemonReady
|
startSoloMinerButton.enabled = !appWindow.isMining && daemonReady
|
||||||
stopSoloMinerButton.enabled = !startSoloMinerButton.enabled && daemonReady
|
stopSoloMinerButton.enabled = !startSoloMinerButton.enabled && daemonReady
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function update() {
|
||||||
|
walletManager.miningStatusAsync();
|
||||||
|
}
|
||||||
|
|
||||||
MoneroComponents.StandardDialog {
|
MoneroComponents.StandardDialog {
|
||||||
id: errorPopup
|
id: errorPopup
|
||||||
cancelVisible: false
|
cancelVisible: false
|
||||||
|
@ -286,4 +290,8 @@ Rectangle {
|
||||||
function onPageClosed() {
|
function onPageClosed() {
|
||||||
timer.running = false
|
timer.running = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
walletManager.miningStatus.connect(onMiningStatus);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -381,6 +381,13 @@ bool WalletManager::isMining() const
|
||||||
return m_pimpl->isMining();
|
return m_pimpl->isMining();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WalletManager::miningStatusAsync() const
|
||||||
|
{
|
||||||
|
QtConcurrent::run([this] {
|
||||||
|
emit miningStatus(isMining());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
bool WalletManager::startMining(const QString &address, quint32 threads, bool backgroundMining, bool ignoreBattery)
|
bool WalletManager::startMining(const QString &address, quint32 threads, bool backgroundMining, bool ignoreBattery)
|
||||||
{
|
{
|
||||||
if(threads == 0)
|
if(threads == 0)
|
||||||
|
|
|
@ -159,7 +159,7 @@ public:
|
||||||
Q_INVOKABLE bool localDaemonSynced() const;
|
Q_INVOKABLE bool localDaemonSynced() const;
|
||||||
Q_INVOKABLE bool isDaemonLocal(const QString &daemon_address) const;
|
Q_INVOKABLE bool isDaemonLocal(const QString &daemon_address) const;
|
||||||
|
|
||||||
Q_INVOKABLE bool isMining() const;
|
Q_INVOKABLE void miningStatusAsync() const;
|
||||||
Q_INVOKABLE bool startMining(const QString &address, quint32 threads, bool backgroundMining, bool ignoreBattery);
|
Q_INVOKABLE bool startMining(const QString &address, quint32 threads, bool backgroundMining, bool ignoreBattery);
|
||||||
Q_INVOKABLE bool stopMining();
|
Q_INVOKABLE bool stopMining();
|
||||||
|
|
||||||
|
@ -201,12 +201,16 @@ signals:
|
||||||
void deviceButtonPressed();
|
void deviceButtonPressed();
|
||||||
void walletClosed(const QString &walletAddress);
|
void walletClosed(const QString &walletAddress);
|
||||||
void checkUpdatesComplete(const QString &result) const;
|
void checkUpdatesComplete(const QString &result) const;
|
||||||
|
void miningStatus(bool isMining) const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
private:
|
private:
|
||||||
friend class WalletPassphraseListenerImpl;
|
friend class WalletPassphraseListenerImpl;
|
||||||
|
|
||||||
explicit WalletManager(QObject *parent = 0);
|
explicit WalletManager(QObject *parent = 0);
|
||||||
|
|
||||||
|
bool isMining() const;
|
||||||
|
|
||||||
static WalletManager * m_instance;
|
static WalletManager * m_instance;
|
||||||
Monero::WalletManager * m_pimpl;
|
Monero::WalletManager * m_pimpl;
|
||||||
QMutex m_mutex;
|
QMutex m_mutex;
|
||||||
|
|
Loading…
Reference in a new issue