mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-08-13 04:55:44 +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());
|
||||
|
||||
// startup done
|
||||
connect(this, &CApplication::startUpCompleted, this, &CApplication::ps_startupCompleted);
|
||||
|
||||
// notify when app goes down
|
||||
connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &CApplication::gracefulShutdown);
|
||||
}
|
||||
@@ -253,6 +256,11 @@ namespace BlackCore
|
||||
return false;
|
||||
}
|
||||
|
||||
void CApplication::signalStartupAutomatically(bool signal)
|
||||
{
|
||||
this->m_signalStartup = signal;
|
||||
}
|
||||
|
||||
QString CApplication::getEnvironmentInfoString(const QString &separator) const
|
||||
{
|
||||
QString env("Beta: ");
|
||||
@@ -536,7 +544,15 @@ namespace BlackCore
|
||||
this->m_started = this->asyncWebAndContextStart();
|
||||
}
|
||||
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()
|
||||
@@ -575,9 +591,9 @@ namespace BlackCore
|
||||
return l;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// Parsing
|
||||
// ---------------------------------------------------------------------------------
|
||||
// ---------------------------------------------------------------------------------
|
||||
// Parsing
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
bool CApplication::addParserOption(const QCommandLineOption &option)
|
||||
{
|
||||
@@ -698,9 +714,9 @@ namespace BlackCore
|
||||
printf("%s %s\n", qPrintable(QCoreApplication::applicationName()), qPrintable(QCoreApplication::applicationVersion()));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// Contexts
|
||||
// ---------------------------------------------------------------------------------
|
||||
// ---------------------------------------------------------------------------------
|
||||
// Contexts
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
bool CApplication::supportsContexts() const
|
||||
{
|
||||
@@ -770,9 +786,9 @@ namespace BlackCore
|
||||
return this->m_coreFacade->getIContextSimulator();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// Setup
|
||||
// ---------------------------------------------------------------------------------
|
||||
// ---------------------------------------------------------------------------------
|
||||
// Setup
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
CUrlList CApplication::getVatsimMetarUrls() const
|
||||
{
|
||||
|
||||
@@ -116,6 +116,9 @@ namespace BlackCore
|
||||
//! Running in dev.environment?
|
||||
bool isRunningInDeveloperEnvironment() const;
|
||||
|
||||
//! Signal startup automatically or individually
|
||||
void signalStartupAutomatically(bool signal = false);
|
||||
|
||||
//! Info string
|
||||
QString getEnvironmentInfoString(const QString &separator) const;
|
||||
|
||||
@@ -275,6 +278,9 @@ namespace BlackCore
|
||||
//! Setup read/syncronized
|
||||
void ps_setupSyncronized(bool success);
|
||||
|
||||
//! Startup completed
|
||||
virtual void ps_startupCompleted();
|
||||
|
||||
protected:
|
||||
//! Display help message
|
||||
virtual void cmdLineHelpMessage();
|
||||
@@ -344,6 +350,7 @@ namespace BlackCore
|
||||
std::atomic<bool> m_shutdown { false }; //!< is being shutdown?
|
||||
bool m_useContexts = false; //!< use contexts
|
||||
bool m_useWebData = false; //!< use web data
|
||||
bool m_signalStartup = true; //!< signal startup automatically
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace BlackGui
|
||||
{
|
||||
ui->setupUi(this);
|
||||
CInfoArea::initInfoArea(); // init base class
|
||||
this->setWindowIcon(CIcons::swift48());
|
||||
this->setWindowIcon(CIcons::swift64());
|
||||
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
|
||||
{
|
||||
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
|
||||
@@ -181,7 +207,7 @@ namespace BlackGui
|
||||
{
|
||||
if (CProject::isRunningOnWindowsNtPlatform())
|
||||
{
|
||||
const QString helpText(beautifyHelpMessageImpl(this->m_parser.helpText()));
|
||||
const QString helpText(beautifyHelpMessage(this->m_parser.helpText()));
|
||||
QMessageBox::warning(nullptr,
|
||||
QGuiApplication::applicationDisplayName(),
|
||||
"<html><head/><body><h2>" + errorMessage + "</h2>" + helpText + "</body></html>");
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#include "blackgui/enableforframelesswindow.h"
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include <QMenu>
|
||||
#include <QSplashScreen>
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
@@ -54,7 +56,7 @@ namespace BlackGui
|
||||
static const BlackMisc::CLogCategoryList &getLogCategories();
|
||||
|
||||
//! Constructor
|
||||
CGuiApplication(const QString &applicationName = executable(), const QPixmap &icon = BlackMisc::CIcons::swift48());
|
||||
CGuiApplication(const QString &applicationName = executable(), const QPixmap &icon = BlackMisc::CIcons::swift64());
|
||||
|
||||
//! Destructor
|
||||
virtual ~CGuiApplication();
|
||||
@@ -71,7 +73,13 @@ namespace BlackGui
|
||||
//! Window mode (window flags)
|
||||
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;
|
||||
|
||||
//! Reload style sheets
|
||||
@@ -124,6 +132,10 @@ namespace BlackGui
|
||||
//! Style sheet changed
|
||||
void styleSheetsChanged();
|
||||
|
||||
protected slots:
|
||||
//! Startup competed
|
||||
virtual void ps_startupCompleted() override;
|
||||
|
||||
protected:
|
||||
//! \name print messages generated during parsing / cmd handling
|
||||
//! @{
|
||||
@@ -137,7 +149,8 @@ namespace BlackGui
|
||||
private:
|
||||
QPixmap m_windowIcon;
|
||||
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
|
||||
static QString beautifyHelpMessage(const QString &helpText);
|
||||
|
||||
@@ -25,6 +25,8 @@ int main(int argc, char *argv[])
|
||||
//! [CSwiftGuiStdApplication]
|
||||
QApplication qa(argc, argv);
|
||||
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; }
|
||||
//! [CSwiftGuiStdApplication]
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
using namespace BlackMisc;
|
||||
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->addWindowModeOption();
|
||||
|
||||
@@ -121,6 +121,7 @@ void SwiftGuiStd::init()
|
||||
// whether init has been completed
|
||||
this->setVisible(true);
|
||||
|
||||
sGui->startUpCompleted(true);
|
||||
this->m_init = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
//! [CSwiftGuiStdApplication]
|
||||
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.parse();
|
||||
//! [CSwiftGuiStdApplication]
|
||||
|
||||
@@ -116,8 +116,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>355</width>
|
||||
<height>301</height>
|
||||
<width>199</width>
|
||||
<height>63</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@@ -181,8 +181,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>341</width>
|
||||
<height>309</height>
|
||||
<width>277</width>
|
||||
<height>222</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@@ -406,8 +406,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>355</width>
|
||||
<height>301</height>
|
||||
<width>283</width>
|
||||
<height>198</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@@ -502,8 +502,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>355</width>
|
||||
<height>301</height>
|
||||
<width>98</width>
|
||||
<height>88</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@@ -602,7 +602,7 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
<property name="icon">
|
||||
<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 name="iconSize">
|
||||
<size>
|
||||
|
||||
Reference in New Issue
Block a user