Ref T41, download dialog available for all swift UI applications

This commit is contained in:
Klaus Basan
2017-04-25 14:39:18 +02:00
committed by Mathew Sutcliffe
parent 5aa9cb1dca
commit b2d95f471e
2 changed files with 42 additions and 1 deletions

View File

@@ -11,6 +11,7 @@
#include "blackcore/context/contextnetwork.h"
#include "blackcore/data/globalsetup.h"
#include "blackgui/components/applicationclosedialog.h"
#include "blackgui/components/downloadandinstalldialog.h"
#include "blackgui/guiapplication.h"
#include "blackgui/guiutility.h"
#include "blackgui/registermetadata.h"
@@ -386,6 +387,10 @@ namespace BlackGui
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
}
});
a = menu.addAction(CIcons::swift24(), "Check for updates");
c = connect(a, &QAction::triggered, this, &CGuiApplication::checkNewVersion);
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
Q_UNUSED(c);
}
@@ -622,6 +627,28 @@ namespace BlackGui
return true;
}
void CGuiApplication::checkNewVersion()
{
if (!m_installDialog)
{
// without parent stylesheet is not inherited
m_installDialog = new CDownloadAndInstallDialog(this->mainApplicationWindow());
}
if (!m_installDialog->isNewVersionAvailable()) return;
const int result = m_installDialog->exec();
if (result != QDialog::Accepted) { return; }
}
void CGuiApplication::triggerNewVersionCheck(int delayedMs)
{
QTimer::singleShot(delayedMs, this, [ = ]
{
if (this->m_installDialog) { return; }
this->checkNewVersion();
});
}
void CGuiApplication::settingsChanged()
{
// changing widget style is slow, so I try to prevent setting it when nothing changed