mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +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
|
||||
|
||||
@@ -39,12 +39,14 @@ namespace BlackGui
|
||||
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)
|
||||
{
|
||||
registerMetadata();
|
||||
setWindowIcon(icon);
|
||||
CGuiApplication::registerMetadata();
|
||||
CApplication::init(false); // base class without metadata
|
||||
this->setWindowIcon(icon);
|
||||
sGui = this;
|
||||
connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CGuiApplication::styleSheetsChanged);
|
||||
}
|
||||
@@ -55,6 +57,12 @@ namespace BlackGui
|
||||
sGui = nullptr;
|
||||
}
|
||||
|
||||
void CGuiApplication::registerMetadata()
|
||||
{
|
||||
CApplication::registerMetadata();
|
||||
BlackGui::registerMetadata();
|
||||
}
|
||||
|
||||
void CGuiApplication::addWindowModeOption()
|
||||
{
|
||||
this->m_cmdWindowMode = QCommandLineOption(QStringList() << "w" << "window",
|
||||
|
||||
@@ -158,6 +158,9 @@ namespace BlackGui
|
||||
//! Handle paring of special GUI cmd arguments
|
||||
virtual bool parsingHookIn() override;
|
||||
|
||||
//! Register metadata
|
||||
static void registerMetadata();
|
||||
|
||||
private:
|
||||
QPixmap m_windowIcon;
|
||||
QCommandLineOption m_cmdWindowStateMinimized { "empty" }; //!< window state (minimized)
|
||||
|
||||
Reference in New Issue
Block a user