mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-06 02:16:04 +08:00
refs #485, support splash screen
This commit is contained in:
committed by
Mathew Sutcliffe
parent
90a8368002
commit
45496ce08e
@@ -87,6 +87,9 @@ namespace BlackCore
|
|||||||
|
|
||||||
this->m_parser.addOptions(this->m_setupReader->getCmdLineOptions());
|
this->m_parser.addOptions(this->m_setupReader->getCmdLineOptions());
|
||||||
|
|
||||||
|
// startup done
|
||||||
|
connect(this, &CApplication::startUpCompleted, this, &CApplication::ps_startupCompleted);
|
||||||
|
|
||||||
// notify when app goes down
|
// notify when app goes down
|
||||||
connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &CApplication::gracefulShutdown);
|
connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &CApplication::gracefulShutdown);
|
||||||
}
|
}
|
||||||
@@ -253,6 +256,11 @@ namespace BlackCore
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CApplication::signalStartupAutomatically(bool signal)
|
||||||
|
{
|
||||||
|
this->m_signalStartup = signal;
|
||||||
|
}
|
||||||
|
|
||||||
QString CApplication::getEnvironmentInfoString(const QString &separator) const
|
QString CApplication::getEnvironmentInfoString(const QString &separator) const
|
||||||
{
|
{
|
||||||
QString env("Beta: ");
|
QString env("Beta: ");
|
||||||
@@ -536,7 +544,15 @@ namespace BlackCore
|
|||||||
this->m_started = this->asyncWebAndContextStart();
|
this->m_started = this->asyncWebAndContextStart();
|
||||||
}
|
}
|
||||||
this->m_startUpCompleted = true;
|
this->m_startUpCompleted = true;
|
||||||
emit this->startUpCompleted(this->m_started);
|
if (this->m_signalStartup)
|
||||||
|
{
|
||||||
|
emit this->startUpCompleted(this->m_started);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CApplication::ps_startupCompleted()
|
||||||
|
{
|
||||||
|
// void
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CApplication::asyncWebAndContextStart()
|
bool CApplication::asyncWebAndContextStart()
|
||||||
@@ -575,9 +591,9 @@ namespace BlackCore
|
|||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
// Parsing
|
// Parsing
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
|
|
||||||
bool CApplication::addParserOption(const QCommandLineOption &option)
|
bool CApplication::addParserOption(const QCommandLineOption &option)
|
||||||
{
|
{
|
||||||
@@ -698,9 +714,9 @@ namespace BlackCore
|
|||||||
printf("%s %s\n", qPrintable(QCoreApplication::applicationName()), qPrintable(QCoreApplication::applicationVersion()));
|
printf("%s %s\n", qPrintable(QCoreApplication::applicationName()), qPrintable(QCoreApplication::applicationVersion()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
// Contexts
|
// Contexts
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
|
|
||||||
bool CApplication::supportsContexts() const
|
bool CApplication::supportsContexts() const
|
||||||
{
|
{
|
||||||
@@ -770,9 +786,9 @@ namespace BlackCore
|
|||||||
return this->m_coreFacade->getIContextSimulator();
|
return this->m_coreFacade->getIContextSimulator();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
// Setup
|
// Setup
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
|
|
||||||
CUrlList CApplication::getVatsimMetarUrls() const
|
CUrlList CApplication::getVatsimMetarUrls() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -116,6 +116,9 @@ namespace BlackCore
|
|||||||
//! Running in dev.environment?
|
//! Running in dev.environment?
|
||||||
bool isRunningInDeveloperEnvironment() const;
|
bool isRunningInDeveloperEnvironment() const;
|
||||||
|
|
||||||
|
//! Signal startup automatically or individually
|
||||||
|
void signalStartupAutomatically(bool signal = false);
|
||||||
|
|
||||||
//! Info string
|
//! Info string
|
||||||
QString getEnvironmentInfoString(const QString &separator) const;
|
QString getEnvironmentInfoString(const QString &separator) const;
|
||||||
|
|
||||||
@@ -275,6 +278,9 @@ namespace BlackCore
|
|||||||
//! Setup read/syncronized
|
//! Setup read/syncronized
|
||||||
void ps_setupSyncronized(bool success);
|
void ps_setupSyncronized(bool success);
|
||||||
|
|
||||||
|
//! Startup completed
|
||||||
|
virtual void ps_startupCompleted();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Display help message
|
//! Display help message
|
||||||
virtual void cmdLineHelpMessage();
|
virtual void cmdLineHelpMessage();
|
||||||
@@ -344,6 +350,7 @@ namespace BlackCore
|
|||||||
std::atomic<bool> m_shutdown { false }; //!< is being shutdown?
|
std::atomic<bool> m_shutdown { false }; //!< is being shutdown?
|
||||||
bool m_useContexts = false; //!< use contexts
|
bool m_useContexts = false; //!< use contexts
|
||||||
bool m_useWebData = false; //!< use web data
|
bool m_useWebData = false; //!< use web data
|
||||||
|
bool m_signalStartup = true; //!< signal startup automatically
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
CInfoArea::initInfoArea(); // init base class
|
CInfoArea::initInfoArea(); // init base class
|
||||||
this->setWindowIcon(CIcons::swift48());
|
this->setWindowIcon(CIcons::swift64());
|
||||||
connect(this->getLogComponent(), &CLogComponent::requestAttention, this, &CMainInfoAreaComponent::selectLog);
|
connect(this->getLogComponent(), &CLogComponent::requestAttention, this, &CMainInfoAreaComponent::selectLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,32 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGuiApplication::splashScreen(const QString &resource)
|
||||||
|
{
|
||||||
|
if (this->m_splashScreen)
|
||||||
|
{
|
||||||
|
// delete old one
|
||||||
|
this->m_splashScreen.reset();
|
||||||
|
}
|
||||||
|
if (!resource.isEmpty())
|
||||||
|
{
|
||||||
|
const QPixmap pm(resource);
|
||||||
|
this->splashScreen(pm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGuiApplication::splashScreen(const QPixmap &pixmap)
|
||||||
|
{
|
||||||
|
if (this->m_splashScreen)
|
||||||
|
{
|
||||||
|
// delete old one
|
||||||
|
this->m_splashScreen.reset();
|
||||||
|
}
|
||||||
|
this->m_splashScreen.reset(new QSplashScreen(pixmap.scaled(256, 256)));
|
||||||
|
this->m_splashScreen->show();
|
||||||
|
this->processEventsToRefreshGui();
|
||||||
|
}
|
||||||
|
|
||||||
void CGuiApplication::processEventsToRefreshGui() const
|
void CGuiApplication::processEventsToRefreshGui() const
|
||||||
{
|
{
|
||||||
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
|
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
|
||||||
@@ -181,7 +207,7 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
if (CProject::isRunningOnWindowsNtPlatform())
|
if (CProject::isRunningOnWindowsNtPlatform())
|
||||||
{
|
{
|
||||||
const QString helpText(beautifyHelpMessageImpl(this->m_parser.helpText()));
|
const QString helpText(beautifyHelpMessage(this->m_parser.helpText()));
|
||||||
QMessageBox::warning(nullptr,
|
QMessageBox::warning(nullptr,
|
||||||
QGuiApplication::applicationDisplayName(),
|
QGuiApplication::applicationDisplayName(),
|
||||||
"<html><head/><body><h2>" + errorMessage + "</h2>" + helpText + "</body></html>");
|
"<html><head/><body><h2>" + errorMessage + "</h2>" + helpText + "</body></html>");
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
#include "blackgui/enableforframelesswindow.h"
|
#include "blackgui/enableforframelesswindow.h"
|
||||||
#include "blackgui/blackguiexport.h"
|
#include "blackgui/blackguiexport.h"
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
#include <QSplashScreen>
|
||||||
|
#include <QScopedPointer>
|
||||||
|
|
||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
{
|
{
|
||||||
@@ -54,7 +56,7 @@ namespace BlackGui
|
|||||||
static const BlackMisc::CLogCategoryList &getLogCategories();
|
static const BlackMisc::CLogCategoryList &getLogCategories();
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
CGuiApplication(const QString &applicationName = executable(), const QPixmap &icon = BlackMisc::CIcons::swift48());
|
CGuiApplication(const QString &applicationName = executable(), const QPixmap &icon = BlackMisc::CIcons::swift64());
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
virtual ~CGuiApplication();
|
virtual ~CGuiApplication();
|
||||||
@@ -71,7 +73,13 @@ namespace BlackGui
|
|||||||
//! Window mode (window flags)
|
//! Window mode (window flags)
|
||||||
CEnableForFramelessWindow::WindowMode getWindowMode() const;
|
CEnableForFramelessWindow::WindowMode getWindowMode() const;
|
||||||
|
|
||||||
//! Allow the GUI to refresh by processing events
|
//! Add a splash screen based on resource, empty means remove splash screen
|
||||||
|
void splashScreen(const QString &resource);
|
||||||
|
|
||||||
|
//! Add a splash screen based on resource, empty means remove splash screen
|
||||||
|
void splashScreen(const QPixmap &pixmap);
|
||||||
|
|
||||||
|
//! Allow the GUI to refresh by processing events, call the event loop
|
||||||
void processEventsToRefreshGui() const;
|
void processEventsToRefreshGui() const;
|
||||||
|
|
||||||
//! Reload style sheets
|
//! Reload style sheets
|
||||||
@@ -124,6 +132,10 @@ namespace BlackGui
|
|||||||
//! Style sheet changed
|
//! Style sheet changed
|
||||||
void styleSheetsChanged();
|
void styleSheetsChanged();
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
//! Startup competed
|
||||||
|
virtual void ps_startupCompleted() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! \name print messages generated during parsing / cmd handling
|
//! \name print messages generated during parsing / cmd handling
|
||||||
//! @{
|
//! @{
|
||||||
@@ -137,7 +149,8 @@ namespace BlackGui
|
|||||||
private:
|
private:
|
||||||
QPixmap m_windowIcon;
|
QPixmap m_windowIcon;
|
||||||
QCommandLineOption m_cmdWindowStateMinimized { "empty" }; //!< window state (minimized)
|
QCommandLineOption m_cmdWindowStateMinimized { "empty" }; //!< window state (minimized)
|
||||||
QCommandLineOption m_cmdWindowMode { "empty" }; //!< window mode (flags: frameless ...)
|
QCommandLineOption m_cmdWindowMode { "empty" }; //!< window mode (flags: frameless ...)
|
||||||
|
QScopedPointer<QSplashScreen> m_splashScreen; //!< splash screen
|
||||||
|
|
||||||
//! Qt help message to formatted HTML
|
//! Qt help message to formatted HTML
|
||||||
static QString beautifyHelpMessage(const QString &helpText);
|
static QString beautifyHelpMessage(const QString &helpText);
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ int main(int argc, char *argv[])
|
|||||||
//! [CSwiftGuiStdApplication]
|
//! [CSwiftGuiStdApplication]
|
||||||
QApplication qa(argc, argv);
|
QApplication qa(argc, argv);
|
||||||
CSwiftGuiStdApplication a;
|
CSwiftGuiStdApplication a;
|
||||||
|
a.signalStartupAutomatically(); // application will signal startup on its own
|
||||||
|
a.splashScreen(":/own/icons/own/swift/swiftCirclePilotClient1024.png");
|
||||||
if (!a.start()) { return EXIT_FAILURE; }
|
if (!a.start()) { return EXIT_FAILURE; }
|
||||||
//! [CSwiftGuiStdApplication]
|
//! [CSwiftGuiStdApplication]
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,8 @@
|
|||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackCore;
|
using namespace BlackCore;
|
||||||
|
|
||||||
CSwiftGuiStdApplication::CSwiftGuiStdApplication() : CGuiApplication("swift pilot client GUI", CIcons::swift24())
|
CSwiftGuiStdApplication::CSwiftGuiStdApplication() :
|
||||||
|
CGuiApplication("swift pilot client GUI", CIcons::swift1024())
|
||||||
{
|
{
|
||||||
this->addParserOption(this->m_cmdFacadeMode);
|
this->addParserOption(this->m_cmdFacadeMode);
|
||||||
this->addWindowModeOption();
|
this->addWindowModeOption();
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ void SwiftGuiStd::init()
|
|||||||
// whether init has been completed
|
// whether init has been completed
|
||||||
this->setVisible(true);
|
this->setVisible(true);
|
||||||
|
|
||||||
|
sGui->startUpCompleted(true);
|
||||||
this->m_init = true;
|
this->m_init = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
//! [CSwiftGuiStdApplication]
|
//! [CSwiftGuiStdApplication]
|
||||||
QApplication qa(argc, argv);
|
QApplication qa(argc, argv);
|
||||||
CGuiApplication a("swift launcher", CIcons::swift24());
|
CGuiApplication a("swift launcher", CIcons::swift1024());
|
||||||
a.addParserOption({{"i", "installer"}, QCoreApplication::translate("main", "Installer setup."), "installer"});
|
a.addParserOption({{"i", "installer"}, QCoreApplication::translate("main", "Installer setup."), "installer"});
|
||||||
a.parse();
|
a.parse();
|
||||||
//! [CSwiftGuiStdApplication]
|
//! [CSwiftGuiStdApplication]
|
||||||
|
|||||||
@@ -116,8 +116,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>355</width>
|
<width>199</width>
|
||||||
<height>301</height>
|
<height>63</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
@@ -181,8 +181,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>341</width>
|
<width>277</width>
|
||||||
<height>309</height>
|
<height>222</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
@@ -406,8 +406,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>355</width>
|
<width>283</width>
|
||||||
<height>301</height>
|
<height>198</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
@@ -502,8 +502,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>355</width>
|
<width>98</width>
|
||||||
<height>301</height>
|
<height>88</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
@@ -602,7 +602,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../blackmisc/blackmisc.qrc">
|
<iconset resource="../blackmisc/blackmisc.qrc">
|
||||||
<normaloff>:/own/icons/own/swift/swift64.png</normaloff>:/own/icons/own/swift/swift64.png</iconset>
|
<normaloff>:/own/icons/own/swift/swiftCircle64.png</normaloff>:/own/icons/own/swift/swiftCircle64.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="iconSize">
|
<property name="iconSize">
|
||||||
<size>
|
<size>
|
||||||
|
|||||||
Reference in New Issue
Block a user