mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-03 16:25:54 +08:00
refs #635, init metadata in CApplication / CGuiApplication
This commit is contained in:
@@ -41,19 +41,29 @@ BlackCore::CApplication *sApp = nullptr; // set by constructor
|
|||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
{
|
{
|
||||||
CApplication::CApplication(const QString &applicationName) :
|
CApplication::CApplication(const QString &applicationName, bool init) :
|
||||||
m_cookieManager( {}, this),
|
m_cookieManager( {}, this),
|
||||||
m_applicationName(applicationName),
|
m_applicationName(applicationName),
|
||||||
m_coreFacadeConfig(CCoreFacadeConfig::allEmpty())
|
m_coreFacadeConfig(CCoreFacadeConfig::allEmpty())
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(!sApp, Q_FUNC_INFO, "already initialized");
|
Q_ASSERT_X(!sApp, Q_FUNC_INFO, "already initialized");
|
||||||
Q_ASSERT_X(QCoreApplication::instance(), Q_FUNC_INFO, "no application object");
|
Q_ASSERT_X(QCoreApplication::instance(), Q_FUNC_INFO, "no application object");
|
||||||
|
|
||||||
|
// init skiped when called from CGuiApplication
|
||||||
|
if (init)
|
||||||
|
{
|
||||||
|
this->init(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CApplication::init(bool withMetadata)
|
||||||
|
{
|
||||||
if (!sApp)
|
if (!sApp)
|
||||||
{
|
{
|
||||||
CApplication::initEnvironment();
|
if (withMetadata) { CApplication::registerMetadata(); }
|
||||||
QCoreApplication::setApplicationName(applicationName);
|
QCoreApplication::setApplicationName(this->m_applicationName);
|
||||||
QCoreApplication::setApplicationVersion(CVersion::version());
|
QCoreApplication::setApplicationVersion(CProject::version());
|
||||||
this->setObjectName(applicationName);
|
this->setObjectName(this->m_applicationName);
|
||||||
this->initParser();
|
this->initParser();
|
||||||
this->initLogging();
|
this->initLogging();
|
||||||
|
|
||||||
@@ -96,6 +106,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CApplication::~CApplication()
|
CApplication::~CApplication()
|
||||||
{
|
{
|
||||||
this->gracefulShutdown();
|
this->gracefulShutdown();
|
||||||
@@ -485,7 +496,7 @@ namespace BlackCore
|
|||||||
this->addParserOption(this->m_cmdSharedDir);
|
this->addParserOption(this->m_cmdSharedDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CApplication::initEnvironment()
|
void CApplication::registerMetadata()
|
||||||
{
|
{
|
||||||
BlackMisc::registerMetadata();
|
BlackMisc::registerMetadata();
|
||||||
BlackCore::registerMetadata();
|
BlackCore::registerMetadata();
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ namespace BlackCore
|
|||||||
static const BlackMisc::CLogCategoryList &getLogCategories();
|
static const BlackMisc::CLogCategoryList &getLogCategories();
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
CApplication(const QString &applicationName = executable());
|
CApplication(const QString &applicationName = executable(), bool init = true);
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
virtual ~CApplication();
|
virtual ~CApplication();
|
||||||
@@ -282,6 +282,9 @@ namespace BlackCore
|
|||||||
virtual void ps_startupCompleted();
|
virtual void ps_startupCompleted();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
//! Init class, allows to init from BlackGui::CGuiApplication as well (pseudo virtual)
|
||||||
|
void init(bool withMetadata);
|
||||||
|
|
||||||
//! Display help message
|
//! Display help message
|
||||||
virtual void cmdLineHelpMessage();
|
virtual void cmdLineHelpMessage();
|
||||||
|
|
||||||
@@ -310,6 +313,9 @@ namespace BlackCore
|
|||||||
//! executable name
|
//! executable name
|
||||||
static const QString &executable();
|
static const QString &executable();
|
||||||
|
|
||||||
|
//! Register metadata
|
||||||
|
static void registerMetadata();
|
||||||
|
|
||||||
// cmd parsing
|
// cmd parsing
|
||||||
QCommandLineParser m_parser; //!< cmd parser
|
QCommandLineParser m_parser; //!< cmd parser
|
||||||
QCommandLineOption m_cmdHelp {"help"}; //!< help option
|
QCommandLineOption m_cmdHelp {"help"}; //!< help option
|
||||||
@@ -333,9 +339,6 @@ namespace BlackCore
|
|||||||
//! Async. start when setup is loaded
|
//! Async. start when setup is loaded
|
||||||
bool asyncWebAndContextStart();
|
bool asyncWebAndContextStart();
|
||||||
|
|
||||||
//! static init part
|
|
||||||
static void initEnvironment();
|
|
||||||
|
|
||||||
QScopedPointer<CCoreFacade> m_coreFacade; //!< core facade if any
|
QScopedPointer<CCoreFacade> m_coreFacade; //!< core facade if any
|
||||||
QScopedPointer<CSetupReader> m_setupReader; //!< setup reader
|
QScopedPointer<CSetupReader> m_setupReader; //!< setup reader
|
||||||
QScopedPointer<CWebDataServices> m_webDataServices; //!< web data services
|
QScopedPointer<CWebDataServices> m_webDataServices; //!< web data services
|
||||||
|
|||||||
@@ -39,12 +39,14 @@ namespace BlackGui
|
|||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGuiApplication::CGuiApplication(const QString &applicationName, const QPixmap &icon) : CApplication(applicationName)
|
CGuiApplication::CGuiApplication(const QString &applicationName, const QPixmap &icon) :
|
||||||
|
CApplication(applicationName, false)
|
||||||
{
|
{
|
||||||
if (!sGui)
|
if (!sGui)
|
||||||
{
|
{
|
||||||
registerMetadata();
|
CGuiApplication::registerMetadata();
|
||||||
setWindowIcon(icon);
|
CApplication::init(false); // base class without metadata
|
||||||
|
this->setWindowIcon(icon);
|
||||||
sGui = this;
|
sGui = this;
|
||||||
connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CGuiApplication::styleSheetsChanged);
|
connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CGuiApplication::styleSheetsChanged);
|
||||||
}
|
}
|
||||||
@@ -55,6 +57,12 @@ namespace BlackGui
|
|||||||
sGui = nullptr;
|
sGui = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGuiApplication::registerMetadata()
|
||||||
|
{
|
||||||
|
CApplication::registerMetadata();
|
||||||
|
BlackGui::registerMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
void CGuiApplication::addWindowModeOption()
|
void CGuiApplication::addWindowModeOption()
|
||||||
{
|
{
|
||||||
this->m_cmdWindowMode = QCommandLineOption(QStringList() << "w" << "window",
|
this->m_cmdWindowMode = QCommandLineOption(QStringList() << "w" << "window",
|
||||||
|
|||||||
@@ -158,6 +158,9 @@ namespace BlackGui
|
|||||||
//! Handle paring of special GUI cmd arguments
|
//! Handle paring of special GUI cmd arguments
|
||||||
virtual bool parsingHookIn() override;
|
virtual bool parsingHookIn() override;
|
||||||
|
|
||||||
|
//! Register metadata
|
||||||
|
static void registerMetadata();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPixmap m_windowIcon;
|
QPixmap m_windowIcon;
|
||||||
QCommandLineOption m_cmdWindowStateMinimized { "empty" }; //!< window state (minimized)
|
QCommandLineOption m_cmdWindowStateMinimized { "empty" }; //!< window state (minimized)
|
||||||
|
|||||||
Reference in New Issue
Block a user