mirror of
https://github.com/monero-project/monero-gui
synced 2024-11-24 11:17:15 +01:00
check updates async
This commit is contained in:
parent
c68c317776
commit
3f7e3ba3c4
8
main.qml
8
main.qml
@ -821,6 +821,7 @@ ApplicationWindow {
|
||||
//
|
||||
walletManager.walletOpened.connect(onWalletOpened);
|
||||
walletManager.walletClosed.connect(onWalletClosed);
|
||||
walletManager.checkUpdatesComplete.connect(onWalletCheckUpdatesComplete);
|
||||
|
||||
if(typeof daemonManager != "undefined") {
|
||||
daemonManager.daemonStarted.connect(onDaemonStarted);
|
||||
@ -1341,8 +1342,7 @@ ApplicationWindow {
|
||||
Qt.quit();
|
||||
}
|
||||
|
||||
function checkUpdates() {
|
||||
var update = walletManager.checkUpdates("monero-gui", "gui")
|
||||
function onWalletCheckUpdatesComplete(update) {
|
||||
if (update === "")
|
||||
return
|
||||
print("Update found: " + update)
|
||||
@ -1360,6 +1360,10 @@ ApplicationWindow {
|
||||
}
|
||||
}
|
||||
|
||||
function checkUpdates() {
|
||||
walletManager.checkUpdatesAsync("monero-gui", "gui")
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: updatesTimer
|
||||
interval: 3600*1000; running: true; repeat: true
|
||||
|
@ -331,8 +331,26 @@ bool WalletManager::saveQrCode(const QString &code, const QString &path) const
|
||||
return QRCodeImageProvider::genQrImage(code, &size).scaled(size.expandedTo(QSize(240, 240)), Qt::KeepAspectRatio).save(path, "PNG", 100);
|
||||
}
|
||||
|
||||
void WalletManager::checkUpdatesAsync(const QString &software, const QString &subdir) const
|
||||
{
|
||||
QFuture<QString> future = QtConcurrent::run(this, &WalletManager::checkUpdates,
|
||||
software, subdir);
|
||||
QFutureWatcher<QString> * watcher = new QFutureWatcher<QString>();
|
||||
connect(watcher, &QFutureWatcher<Wallet*>::finished,
|
||||
this, [this, watcher]() {
|
||||
QFuture<QString> future = watcher->future();
|
||||
watcher->deleteLater();
|
||||
qDebug() << "Checking for updates - done";
|
||||
emit checkUpdatesComplete(future.result());
|
||||
});
|
||||
watcher->setFuture(future);
|
||||
}
|
||||
|
||||
|
||||
|
||||
QString WalletManager::checkUpdates(const QString &software, const QString &subdir) const
|
||||
{
|
||||
qDebug() << "Checking for updates";
|
||||
const std::tuple<bool, std::string, std::string, std::string, std::string> result = Monero::WalletManager::checkUpdates(software.toStdString(), subdir.toStdString());
|
||||
if (!std::get<0>(result))
|
||||
return QString("");
|
||||
|
@ -134,6 +134,7 @@ public:
|
||||
Q_INVOKABLE QString resolveOpenAlias(const QString &address) const;
|
||||
Q_INVOKABLE bool parse_uri(const QString &uri, QString &address, QString &payment_id, uint64_t &amount, QString &tx_description, QString &recipient_name, QVector<QString> &unknown_parameters, QString &error);
|
||||
Q_INVOKABLE bool saveQrCode(const QString &, const QString &) const;
|
||||
Q_INVOKABLE void checkUpdatesAsync(const QString &software, const QString &subdir) const;
|
||||
Q_INVOKABLE QString checkUpdates(const QString &software, const QString &subdir) const;
|
||||
|
||||
// clear/rename wallet cache
|
||||
@ -143,6 +144,7 @@ signals:
|
||||
|
||||
void walletOpened(Wallet * wallet);
|
||||
void walletClosed(const QString &walletAddress);
|
||||
void checkUpdatesComplete(const QString &result) const;
|
||||
|
||||
public slots:
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user