mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-13 07:35:41 +08:00
refs #693, integrated GUI close dialog
* utility function in CGuiApplication containing the logic (dialog needed, ..) * closeEvent function
This commit is contained in:
@@ -217,6 +217,8 @@ namespace BlackCore
|
||||
CLogMessage::preformatted(m);
|
||||
}
|
||||
|
||||
// Settings are distributed via DBus. So only one application is responsible for saving. `enableLocalSave()` means
|
||||
// "this is the application responsible for saving". If swiftgui requests a setting to be saved, it is sent to swiftcore and saved by swiftcore.
|
||||
CSettingsCache::instance()->enableLocalSave();
|
||||
}
|
||||
|
||||
@@ -344,6 +346,34 @@ namespace BlackCore
|
||||
return env;
|
||||
}
|
||||
|
||||
bool CApplication::hasUnsavedSettings() const
|
||||
{
|
||||
return !this->getAllUnsavedSettings().isEmpty();
|
||||
}
|
||||
|
||||
void CApplication::setSettingsAutoSave(bool autoSave)
|
||||
{
|
||||
this->m_autoSaveSettings = autoSave;
|
||||
}
|
||||
|
||||
QStringList CApplication::getAllUnsavedSettings() const
|
||||
{
|
||||
return CSettingsCache::instance()->getAllUnsavedKeys();
|
||||
}
|
||||
|
||||
CStatusMessage CApplication::saveSettingsByKey(const QStringList &keys)
|
||||
{
|
||||
if (keys.isEmpty()) { return CStatusMessage(); }
|
||||
if (this->supportsContexts())
|
||||
{
|
||||
return this->getIContextApplication()->saveSettingsByKey(keys);
|
||||
}
|
||||
else
|
||||
{
|
||||
return CSettingsCache::instance()->saveToStore(keys);
|
||||
}
|
||||
}
|
||||
|
||||
QString CApplication::getInfoString(const QString &separator) const
|
||||
{
|
||||
QString str(CVersion::version());
|
||||
@@ -604,7 +634,7 @@ namespace BlackCore
|
||||
CStatusMessage m;
|
||||
if (this->m_parsed)
|
||||
{
|
||||
if (this->supportsContexts())
|
||||
if (this->supportsContexts() && this->m_autoSaveSettings)
|
||||
{
|
||||
// this will eventually also call saveToStore
|
||||
m = this->getIContextApplication()->saveSettings();
|
||||
@@ -698,9 +728,9 @@ namespace BlackCore
|
||||
return l;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// Parsing
|
||||
// ---------------------------------------------------------------------------------
|
||||
// ---------------------------------------------------------------------------------
|
||||
// Parsing
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
bool CApplication::addParserOption(const QCommandLineOption &option)
|
||||
{
|
||||
@@ -824,9 +854,9 @@ namespace BlackCore
|
||||
printf("%s %s\n", qPrintable(QCoreApplication::applicationName()), qPrintable(QCoreApplication::applicationVersion()));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// Contexts
|
||||
// ---------------------------------------------------------------------------------
|
||||
// ---------------------------------------------------------------------------------
|
||||
// Contexts
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
bool CApplication::supportsContexts() const
|
||||
{
|
||||
@@ -896,9 +926,9 @@ namespace BlackCore
|
||||
return this->m_coreFacade->getIContextSimulator();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// Setup
|
||||
// ---------------------------------------------------------------------------------
|
||||
// ---------------------------------------------------------------------------------
|
||||
// Setup
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
CUrlList CApplication::getVatsimMetarUrls() const
|
||||
{
|
||||
|
||||
@@ -161,6 +161,18 @@ namespace BlackCore
|
||||
//! To string
|
||||
QString getInfoString(const QString &separator) const;
|
||||
|
||||
//! Unsaved settings
|
||||
bool hasUnsavedSettings() const;
|
||||
|
||||
//! Automatically and always save settings
|
||||
void setSettingsAutoSave(bool autoSave);
|
||||
|
||||
//! All unsave settings
|
||||
QStringList getAllUnsavedSettings() const;
|
||||
|
||||
//! Save all settings
|
||||
BlackMisc::CStatusMessage saveSettingsByKey(const QStringList &keys);
|
||||
|
||||
//! Run event loop
|
||||
static int exec();
|
||||
|
||||
@@ -226,6 +238,8 @@ namespace BlackCore
|
||||
//! @{
|
||||
|
||||
//! Supports contexts
|
||||
//! \remark checks the real availability of the contexts, so it can happen that we want to use contexts, and they are not yet initialized (false here)
|
||||
//! \sa m_useContexts we use or we will use contexts
|
||||
bool supportsContexts() const;
|
||||
|
||||
//! Init the contexts part and start core facade
|
||||
@@ -402,6 +416,8 @@ namespace BlackCore
|
||||
bool m_signalStartup = true; //!< signal startup automatically
|
||||
bool m_devEnv = false; //!< dev. environment
|
||||
bool m_unitTest = false; //!< is UNIT test
|
||||
bool m_autoSaveSettings = true;//!< automatically saving all settings
|
||||
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
||||
Reference in New Issue
Block a user