mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 15:25:35 +08:00
Ref T41, download dialog available for all swift UI applications
This commit is contained in:
committed by
Mathew Sutcliffe
parent
5aa9cb1dca
commit
b2d95f471e
@@ -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
|
||||
|
||||
@@ -35,7 +35,14 @@ class QWidget;
|
||||
class QMainWindow;
|
||||
|
||||
namespace BlackMisc { class CLogCategoryList; }
|
||||
namespace BlackGui { namespace Components { class CApplicationCloseDialog; }}
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
class CApplicationCloseDialog;
|
||||
class CDownloadAndInstallDialog;
|
||||
}
|
||||
}
|
||||
namespace BlackGui
|
||||
{
|
||||
/*!
|
||||
@@ -154,6 +161,9 @@ namespace BlackGui
|
||||
//! Show close dialog
|
||||
QDialog::DialogCode showCloseDialog(QMainWindow *mainWindow, QCloseEvent *closeEvent);
|
||||
|
||||
//! Trigger new version check
|
||||
void triggerNewVersionCheck(int delayedMs);
|
||||
|
||||
//! Set icon
|
||||
//! \note Pixmap requires a valid QApplication, so it cannot be passed as constructor parameter
|
||||
static void setWindowIcon(const QPixmap &icon);
|
||||
@@ -192,11 +202,15 @@ namespace BlackGui
|
||||
//! Handle paring of special GUI cmd arguments
|
||||
virtual bool parsingHookIn() override;
|
||||
|
||||
//! Check for a new version (update)
|
||||
void checkNewVersion();
|
||||
|
||||
//! Register metadata
|
||||
static void registerMetadata();
|
||||
|
||||
private:
|
||||
QPixmap m_windowIcon;
|
||||
BlackGui::Components::CDownloadAndInstallDialog *m_installDialog = nullptr; //!< software installation dialog
|
||||
QCommandLineOption m_cmdWindowStateMinimized { "empty" }; //!< window state (minimized)
|
||||
QCommandLineOption m_cmdWindowMode { "empty" }; //!< window mode (flags: frameless ...)
|
||||
CStyleSheetUtility m_styleSheetUtility{{}, this}; //!< style sheet utility
|
||||
|
||||
Reference in New Issue
Block a user