mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-17 02:52:12 +01:00
OP-232 GCS Configuration: Reset Settings. Proper functioning is blocked by OP-310.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2734 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
037ff44436
commit
5eab9bf7e6
@ -204,4 +204,8 @@ void CoreImpl::saveSettings(IConfigurablePlugin* plugin, QSettings* qs)
|
||||
{
|
||||
m_mainwindow->saveSettings(plugin, qs);
|
||||
}
|
||||
void CoreImpl::deleteSettings()
|
||||
{
|
||||
m_mainwindow->deleteSettings();
|
||||
}
|
||||
|
||||
|
@ -68,6 +68,7 @@ public:
|
||||
void saveMainSettings(QSettings* qs);
|
||||
void readSettings(IConfigurablePlugin* plugin, QSettings* qs = 0 );
|
||||
void saveSettings(IConfigurablePlugin* plugin, QSettings* qs = 0 );
|
||||
void deleteSettings();
|
||||
|
||||
QString resourcePath() const;
|
||||
|
||||
|
@ -92,6 +92,7 @@ public:
|
||||
virtual void saveMainSettings(QSettings* qs) = 0;
|
||||
virtual void readSettings(IConfigurablePlugin* plugin, QSettings* qs = 0) = 0;
|
||||
virtual void saveSettings(IConfigurablePlugin* plugin, QSettings* qs = 0) = 0;
|
||||
virtual void deleteSettings() = 0;
|
||||
|
||||
virtual QString resourcePath() const = 0;
|
||||
|
||||
|
@ -119,6 +119,7 @@ MainWindow::MainWindow() :
|
||||
m_settingsDatabase(new SettingsDatabase(QFileInfo(m_settings->fileName()).path(),
|
||||
QLatin1String("OpenPilotGCS"),
|
||||
this)),
|
||||
m_dontSaveSettings(false),
|
||||
m_actionManager(new ActionManagerPrivate(this)),
|
||||
m_variableManager(new VariableManager(this)),
|
||||
m_threadManager(new ThreadManager(this)),
|
||||
@ -279,10 +280,16 @@ void MainWindow::extensionsInitialized()
|
||||
QSettings defaultSettings(":/core/OpenPilotGCS.ini", QSettings::IniFormat);
|
||||
|
||||
if ( ! qs->allKeys().count() ){
|
||||
qDebug() << "There is no config, load default config from resource /core/OpenPilotGCS.ini";
|
||||
qs = &defaultSettings;
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(tr("No configuration file could be found."));
|
||||
msgBox.setInformativeText(tr("Do you want to load an example configuration?"));
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
msgBox.setDefaultButton(QMessageBox::Yes);
|
||||
if ( msgBox.exec() == QMessageBox::Yes ){
|
||||
qDebug() << "Load default config from resource /core/OpenPilotGCS.ini";
|
||||
qs = &defaultSettings;
|
||||
}
|
||||
}
|
||||
// qDebug() << "Number of keys in config: " << qs->allKeys().count();
|
||||
|
||||
m_uavGadgetInstanceManager = new UAVGadgetInstanceManager(this);
|
||||
m_uavGadgetInstanceManager->readSettings(qs);
|
||||
@ -299,7 +306,9 @@ void MainWindow::extensionsInitialized()
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
emit m_coreImpl->saveSettingsRequested();
|
||||
if ( !m_dontSaveSettings ){
|
||||
emit m_coreImpl->saveSettingsRequested();
|
||||
}
|
||||
|
||||
const QList<ICoreListener *> listeners =
|
||||
ExtensionSystem::PluginManager::instance()->getObjects<ICoreListener>();
|
||||
@ -311,10 +320,11 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||
}
|
||||
|
||||
emit m_coreImpl->coreAboutToClose();
|
||||
saveSettings(m_settings);
|
||||
|
||||
m_uavGadgetInstanceManager->saveSettings(m_settings);
|
||||
|
||||
if ( !m_dontSaveSettings ){
|
||||
saveSettings(m_settings);
|
||||
m_uavGadgetInstanceManager->saveSettings(m_settings);
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
|
||||
@ -767,6 +777,8 @@ bool MainWindow::showOptionsDialog(const QString &category,
|
||||
|
||||
void MainWindow::saveAll()
|
||||
{
|
||||
if ( m_dontSaveSettings) return;
|
||||
|
||||
emit m_coreImpl->saveSettingsRequested();
|
||||
saveSettings(); // OpenPilot-specific.
|
||||
}
|
||||
@ -1043,6 +1055,8 @@ void MainWindow::readSettings(QSettings* qs)
|
||||
|
||||
void MainWindow::saveSettings(QSettings* qs)
|
||||
{
|
||||
if ( m_dontSaveSettings ) return;
|
||||
|
||||
if ( !qs ){
|
||||
qs = m_settings;
|
||||
}
|
||||
@ -1099,6 +1113,7 @@ void MainWindow::readSettings(IConfigurablePlugin* plugin, QSettings* qs)
|
||||
|
||||
void MainWindow::saveSettings(IConfigurablePlugin* plugin, QSettings* qs)
|
||||
{
|
||||
if ( m_dontSaveSettings ) return;
|
||||
if ( !qs ){
|
||||
qs = m_settings;
|
||||
}
|
||||
@ -1117,6 +1132,13 @@ void MainWindow::saveSettings(IConfigurablePlugin* plugin, QSettings* qs)
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::deleteSettings()
|
||||
{
|
||||
m_settings->clear();
|
||||
m_settings->sync();
|
||||
m_dontSaveSettings = true;
|
||||
}
|
||||
|
||||
void MainWindow::addAdditionalContext(int context)
|
||||
{
|
||||
if (context == 0)
|
||||
|
@ -98,6 +98,7 @@ public:
|
||||
void saveSettings(QSettings* qs = 0);
|
||||
void readSettings(IConfigurablePlugin* plugin, QSettings* qs = 0);
|
||||
void saveSettings(IConfigurablePlugin* plugin, QSettings* qs = 0);
|
||||
void deleteSettings();
|
||||
void openFiles(const QStringList &fileNames);
|
||||
|
||||
Core::ActionManager *actionManager() const;
|
||||
@ -176,6 +177,7 @@ private:
|
||||
QList<int> m_additionalContexts;
|
||||
QSettings *m_settings;
|
||||
QSettings *m_globalSettings;
|
||||
bool m_dontSaveSettings; // In case of an Error or if we reset the settings, never save them.
|
||||
SettingsDatabase *m_settingsDatabase;
|
||||
ActionManagerPrivate *m_actionManager;
|
||||
MessageManager *m_messageManager;
|
||||
|
@ -115,7 +115,7 @@ by your version of the plugin. You might want to upgrade the plugin.")
|
||||
|
||||
#define TEXT_MISSING_CONFIGURATION tr( \
|
||||
" Some configuration is missing in the imported config and will be replaced \
|
||||
by default settings. It's probably an old config.")
|
||||
by default settings.")
|
||||
|
||||
#define TEXT_MAJOR_LOSS_OF_CONFIGURATION tr( \
|
||||
" Major features can't be imported \
|
||||
|
@ -227,7 +227,28 @@ void ImportExportGadgetWidget::on_helpButton_clicked()
|
||||
qDebug() << "Show Help";
|
||||
QDesktopServices::openUrl(QUrl("http://wiki.openpilot.org/Import_Export_plugin"));
|
||||
}
|
||||
|
||||
|
||||
void ImportExportGadgetWidget::on_resetButton_clicked()
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(tr("All your settings will be deleted!"));
|
||||
msgBox.setInformativeText(tr("You must restart the GCS in order to activate the changes."));
|
||||
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
if ( msgBox.exec() == QMessageBox::Ok ){
|
||||
qDebug() << "Reset requested!";
|
||||
Core::ICore::instance()->deleteSettings();
|
||||
}
|
||||
else{
|
||||
qDebug() << "Reset canceled!";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
@ -44,6 +44,7 @@ private:
|
||||
QList<Core::IConfigurablePlugin*> getConfigurables();
|
||||
|
||||
private slots:
|
||||
void on_resetButton_clicked();
|
||||
void on_helpButton_clicked();
|
||||
void on_importButton_clicked();
|
||||
void on_exportButton_clicked();
|
||||
|
@ -96,6 +96,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="resetButton">
|
||||
<property name="text">
|
||||
<string>Reset Config</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="helpButton">
|
||||
<property name="text">
|
||||
|
Loading…
x
Reference in New Issue
Block a user