mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 18:25:37 +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
|
||||
{
|
||||
CApplication::CApplication(const QString &applicationName) :
|
||||
CApplication::CApplication(const QString &applicationName, bool init) :
|
||||
m_cookieManager( {}, this),
|
||||
m_applicationName(applicationName),
|
||||
m_coreFacadeConfig(CCoreFacadeConfig::allEmpty())
|
||||
m_applicationName(applicationName),
|
||||
m_coreFacadeConfig(CCoreFacadeConfig::allEmpty())
|
||||
{
|
||||
Q_ASSERT_X(!sApp, Q_FUNC_INFO, "already initialized");
|
||||
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)
|
||||
{
|
||||
CApplication::initEnvironment();
|
||||
QCoreApplication::setApplicationName(applicationName);
|
||||
QCoreApplication::setApplicationVersion(CVersion::version());
|
||||
this->setObjectName(applicationName);
|
||||
if (withMetadata) { CApplication::registerMetadata(); }
|
||||
QCoreApplication::setApplicationName(this->m_applicationName);
|
||||
QCoreApplication::setApplicationVersion(CProject::version());
|
||||
this->setObjectName(this->m_applicationName);
|
||||
this->initParser();
|
||||
this->initLogging();
|
||||
|
||||
@@ -96,6 +106,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CApplication::~CApplication()
|
||||
{
|
||||
this->gracefulShutdown();
|
||||
@@ -485,7 +496,7 @@ namespace BlackCore
|
||||
this->addParserOption(this->m_cmdSharedDir);
|
||||
}
|
||||
|
||||
void CApplication::initEnvironment()
|
||||
void CApplication::registerMetadata()
|
||||
{
|
||||
BlackMisc::registerMetadata();
|
||||
BlackCore::registerMetadata();
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace BlackCore
|
||||
static const BlackMisc::CLogCategoryList &getLogCategories();
|
||||
|
||||
//! Constructor
|
||||
CApplication(const QString &applicationName = executable());
|
||||
CApplication(const QString &applicationName = executable(), bool init = true);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CApplication();
|
||||
@@ -282,6 +282,9 @@ namespace BlackCore
|
||||
virtual void ps_startupCompleted();
|
||||
|
||||
protected:
|
||||
//! Init class, allows to init from BlackGui::CGuiApplication as well (pseudo virtual)
|
||||
void init(bool withMetadata);
|
||||
|
||||
//! Display help message
|
||||
virtual void cmdLineHelpMessage();
|
||||
|
||||
@@ -310,6 +313,9 @@ namespace BlackCore
|
||||
//! executable name
|
||||
static const QString &executable();
|
||||
|
||||
//! Register metadata
|
||||
static void registerMetadata();
|
||||
|
||||
// cmd parsing
|
||||
QCommandLineParser m_parser; //!< cmd parser
|
||||
QCommandLineOption m_cmdHelp {"help"}; //!< help option
|
||||
@@ -333,9 +339,6 @@ namespace BlackCore
|
||||
//! Async. start when setup is loaded
|
||||
bool asyncWebAndContextStart();
|
||||
|
||||
//! static init part
|
||||
static void initEnvironment();
|
||||
|
||||
QScopedPointer<CCoreFacade> m_coreFacade; //!< core facade if any
|
||||
QScopedPointer<CSetupReader> m_setupReader; //!< setup reader
|
||||
QScopedPointer<CWebDataServices> m_webDataServices; //!< web data services
|
||||
|
||||
Reference in New Issue
Block a user