refs #608, generic menus are now available via CGuiApplication and don`t have to be redefined over and over again

This commit is contained in:
Klaus Basan
2016-03-02 23:25:12 +01:00
committed by Mathew Sutcliffe
parent bf9ea12a2b
commit bcb00b1b91
18 changed files with 352 additions and 393 deletions

View File

@@ -54,25 +54,6 @@ void CSwiftData::initStyleSheet()
CSwiftData::~CSwiftData()
{ }
bool CSwiftData::displayInStatusBar(const CStatusMessage &message)
{
this->m_statusBar.displayStatusMessage(message);
return true;
}
bool CSwiftData::displayInOverlayWindow(const CStatusMessage &message)
{
this->ui->comp_MainInfoArea->getMappingComponent()->showOverlayMessage(message);
return true;
}
void CSwiftData::closeEvent(QCloseEvent *event)
{
Q_UNUSED(event);
this->performGracefulShutdown();
sGui->exit();
}
void CSwiftData::ps_appendLogMessage(const CStatusMessage &message)
{
CLogComponent *logComponent = ui->comp_MainInfoArea->getLogComponent();
@@ -91,8 +72,13 @@ void CSwiftData::ps_onStyleSheetsChanged()
void CSwiftData::init()
{
sGui->initMainApplicationWindow(this);
this->initStyleSheet();
this->initLogDisplay();
this->m_mwaLogComponent = this->ui->comp_MainInfoArea->getLogComponent();
this->m_mwaStatusBar = &this->m_statusBar;
this->m_mwaOverlayFrame = this->ui->comp_MainInfoArea->getMappingComponent();
this->initStyleSheet();
connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CSwiftData::ps_onStyleSheetsChanged);
this->initMenu();
}
@@ -112,32 +98,17 @@ void CSwiftData::initLogDisplay()
void CSwiftData::initMenu()
{
// menu
this->initDynamicMenus();
this->ui->menu_WindowMinimize->setIcon(this->style()->standardIcon(QStyle::SP_TitleBarMinButton));
connect(this->ui->menu_FileExit, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_FileReloadStyleSheets, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_FileResetSettings, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_SettingsDirectory, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_SettingsFiles, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_SettingsReset, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_CacheDirectory, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_CacheFiles, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_CacheReset, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_WindowFont, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_WindowMinimize, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_WindowToggleOnTop, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_MappingMaxData, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_MappingMaxMapping, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_InternalsCompileInfo, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_InternalsEnvVars, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_InternalsMetatypes, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_InternalsSetup, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_JsonBootstrapTemplate, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_JsonDownloadTemplate, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
sGui->addMenuFile(*this->ui->menu_File);
sGui->addMenuInternals(*this->ui->menu_Internals);
sGui->addMenuWindow(*this->ui->menu_Window);
}
void CSwiftData::performGracefulShutdown()

View File

@@ -43,16 +43,6 @@ public:
//! Destructor
~CSwiftData();
//! \name direct access to main application window
//! @{
virtual bool displayInStatusBar(const BlackMisc::CStatusMessage &message) override;
virtual bool displayInOverlayWindow(const BlackMisc::CStatusMessage &message) override;
//! }@
protected:
//! \copydoc QMainWindow::closeEvent
virtual void closeEvent(QCloseEvent *event) override;
private slots:
//! Append log message
void ps_appendLogMessage(const BlackMisc::CStatusMessage &message);
@@ -76,7 +66,7 @@ private:
QScopedPointer<Ui::CSwiftData> ui;
BlackGui::CManagedStatusBar m_statusBar;
BlackMisc::CData<BlackCore::Data::UpdateInfo> m_updateInfo { this }; //!< download / version data
BlackMisc::CData<BlackCore::Data::UpdateInfo> m_updateInfo { this }; //!< download / version data
};
#endif // guard

View File

@@ -79,34 +79,13 @@
<property name="title">
<string>File</string>
</property>
<widget class="QMenu" name="menu_Settings">
<property name="title">
<string>Settings</string>
</property>
<addaction name="menu_SettingsDirectory"/>
<addaction name="menu_SettingsFiles"/>
<addaction name="menu_SettingsReset"/>
</widget>
<widget class="QMenu" name="menuCache">
<property name="title">
<string>Cache</string>
</property>
<addaction name="menu_CacheDirectory"/>
<addaction name="menu_CacheFiles"/>
<addaction name="menu_CacheReset"/>
</widget>
<addaction name="menu_Settings"/>
<addaction name="menuCache"/>
<addaction name="menu_FileReloadStyleSheets"/>
<addaction name="separator"/>
<addaction name="menu_FileExit"/>
</widget>
<widget class="QMenu" name="menu_Window">
<property name="title">
<string>Window</string>
</property>
<addaction name="menu_WindowFont"/>
<addaction name="menu_WindowMinimize"/>
</widget>
<widget class="QMenu" name="menu_InfoAreas">
<property name="title">
@@ -120,27 +99,10 @@
<addaction name="menu_MappingMaxData"/>
<addaction name="menu_MappingMaxMapping"/>
</widget>
<widget class="QMenu" name="menu_Test">
<widget class="QMenu" name="menu_Internals">
<property name="title">
<string>Test</string>
<string>Internals</string>
</property>
<widget class="QMenu" name="menu_Internals">
<property name="title">
<string>Internals</string>
</property>
<widget class="QMenu" name="menuTemplates">
<property name="title">
<string>Templates</string>
</property>
<addaction name="menu_JsonBootstrapTemplate"/>
<addaction name="menu_JsonDownloadTemplate"/>
</widget>
<addaction name="menuTemplates"/>
<addaction name="menu_InternalsMetatypes"/>
<addaction name="menu_InternalsSetup"/>
<addaction name="menu_InternalsCompileInfo"/>
</widget>
<addaction name="menu_Internals"/>
<addaction name="separator"/>
</widget>
<widget class="QMenu" name="menu_Help">
@@ -153,7 +115,7 @@
<addaction name="menu_InfoAreas"/>
<addaction name="menu_Help"/>
<addaction name="menu_Mapping"/>
<addaction name="menu_Test"/>
<addaction name="menu_Internals"/>
</widget>
<widget class="QStatusBar" name="sb_SwiftData"/>
<action name="menu_FileExit">

View File

@@ -35,64 +35,11 @@ using namespace BlackMisc;
void CSwiftData::ps_onMenuClicked()
{
QObject *sender = QObject::sender();
if (sender == this->ui->menu_FileReloadStyleSheets)
{
sGui->reloadStyleSheets();
}
else if (sender == this->ui->menu_WindowFont)
if (sender == this->ui->menu_WindowFont)
{
// this->ps_setMainPageToInfoArea();
// this->ui->comp_MainInfoArea->selectSettingsTab(BlackGui::Components::CSettingsComponent::SettingTabGui);
}
else if (sender == this->ui->menu_WindowMinimize)
{
this->showMinimized();
}
else if (sender == this->ui->menu_FileExit)
{
CLogMessage(this).info("Closing");
this->close(); // graceful shutdown in close event
}
else if (sender == this->ui->menu_SettingsDirectory)
{
QString path(QDir::toNativeSeparators(CSettingsCache::persistentStore()));
if (QDir(path).exists())
{
QDesktopServices::openUrl(QUrl("file:///" + path));
}
}
else if (sender == this->ui->menu_SettingsReset)
{
CSettingsCache::instance()->clearAllValues();
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole("Cleared all settings!");
this->displayConsole();
}
else if (sender == this->ui->menu_SettingsFiles)
{
QStringList cachedFiles(CSettingsCache::instance()->enumerateStore());
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(cachedFiles.join("\n"));
this->displayConsole();
}
else if (sender == this->ui->menu_CacheDirectory)
{
QString path(QDir::toNativeSeparators(CDataCache::persistentStore()));
if (QDir(path).exists())
{
QDesktopServices::openUrl(QUrl("file:///" + path));
}
}
else if (sender == this->ui->menu_CacheFiles)
{
QStringList cachedFiles(CDataCache::instance()->enumerateStore());
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(cachedFiles.join("\n"));
this->displayConsole();
}
else if (sender == this->ui->menu_CacheReset)
{
CDataCache::instance()->clearAllValues();
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole("Cleared all cached values!");
this->displayConsole();
}
else if (sender == this->ui->menu_MappingMaxData)
{
CDbMappingComponent *mappingComponent = this->ui->comp_MainInfoArea->getMappingComponent();
@@ -103,36 +50,6 @@ void CSwiftData::ps_onMenuClicked()
CDbMappingComponent *mappingComponent = this->ui->comp_MainInfoArea->getMappingComponent();
mappingComponent->resizeForMapping();
}
else if (sender == this->ui->menu_JsonBootstrapTemplate)
{
QString json(sApp->getGlobalSetup().toJsonString());
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(json);
this->displayConsole();
}
else if (sender == this->ui->menu_JsonDownloadTemplate)
{
QString json(m_updateInfo.get().toJsonString());
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(json);
this->displayConsole();
}
else if (sender == this->ui->menu_InternalsMetatypes)
{
QString metadata(getAllUserMetatypesTypes());
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(metadata);
this->displayConsole();
}
else if (sender == this->ui->menu_InternalsSetup)
{
QString setup(sApp->getGlobalSetup().convertToQString("\n", true));
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(setup);
this->displayConsole();
}
else if (sender == this->ui->menu_InternalsCompileInfo)
{
QString project(sGui->convertToQString("\n"));
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(project);
this->displayConsole();
}
}
void CSwiftData::initDynamicMenus()