1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

LP-419 cleanup QSettings usage throughout GCS

This commit is contained in:
Philippe Renon 2016-10-02 21:08:30 +02:00
parent 7113c1a624
commit 068988741d
120 changed files with 1547 additions and 1752 deletions

View File

@ -86,13 +86,9 @@ public:
}
#ifdef Q_OS_UNIX
void setSettings(QSettings *settings)
{
m_settings = settings;
}
static QString defaultTerminalEmulator();
static QString terminalEmulator(const QSettings *settings);
static void setTerminalEmulator(QSettings *settings, const QString &term);
static QString terminalEmulator(const QSettings &settings);
static void setTerminalEmulator(QSettings &settings, const QString &term);
#endif
signals:
@ -146,7 +142,6 @@ private:
#else
QProcess m_process;
QByteArray m_stubServerDir;
QSettings *m_settings;
#endif
};
} // namespace Utils

View File

@ -254,17 +254,17 @@ QString ConsoleProcess::defaultTerminalEmulator()
#endif
}
QString ConsoleProcess::terminalEmulator(const QSettings *settings)
QString ConsoleProcess::terminalEmulator(const QSettings &settings)
{
const QString dflt = defaultTerminalEmulator() + QLatin1String(" -e");
if (!settings) {
return dflt;
}
return settings->value(QLatin1String("General/TerminalEmulator"), dflt).toString();
return settings.value(QLatin1String("General/TerminalEmulator"), dflt).toString();
}
void ConsoleProcess::setTerminalEmulator(QSettings *settings, const QString &term)
void ConsoleProcess::setTerminalEmulator(QSettings &settings, const QString &term)
{
return settings->setValue(QLatin1String("General/TerminalEmulator"), term);
return settings.setValue(QLatin1String("General/TerminalEmulator"), term);
}

View File

@ -26,83 +26,59 @@
*/
#include "antennatrackgadgetconfiguration.h"
#include <QtSerialPort/QSerialPort>
/**
* Loads a saved configuration or defaults if non exist.
*
*/
AntennaTrackGadgetConfiguration::AntennaTrackGadgetConfiguration(QString classId, QSettings *qSettings, QObject *parent) :
IUAVGadgetConfiguration(classId, parent),
m_connectionMode("Serial"),
m_defaultPort("Unknown"),
m_defaultSpeed(QSerialPort::UnknownBaud),
m_defaultDataBits(QSerialPort::UnknownDataBits),
m_defaultFlow(QSerialPort::UnknownFlowControl),
m_defaultParity(QSerialPort::UnknownParity),
m_defaultStopBits(QSerialPort::UnknownStopBits),
m_defaultTimeOut(5000)
AntennaTrackGadgetConfiguration::AntennaTrackGadgetConfiguration(QString classId, QSettings &settings, QObject *parent) :
IUAVGadgetConfiguration(classId, parent)
{
// if a saved configuration exists load it
if (qSettings != 0) {
QSerialPort::BaudRate speed;
QSerialPort::DataBits databits;
QSerialPort::FlowControl flow;
QSerialPort::Parity parity;
QSerialPort::StopBits stopbits;
m_defaultPort = settings.value("defaultPort", "Unknown").toString();
m_defaultSpeed = (QSerialPort::BaudRate)settings.value("defaultSpeed", QSerialPort::UnknownBaud).toInt();
m_defaultDataBits = (QSerialPort::DataBits)settings.value("defaultDataBits", QSerialPort::UnknownDataBits).toInt();
m_defaultFlow = (QSerialPort::FlowControl)settings.value("defaultFlow", QSerialPort::UnknownFlowControl).toInt();
m_defaultParity = (QSerialPort::Parity)settings.value("defaultParity", QSerialPort::UnknownParity).toInt();
m_defaultStopBits = (QSerialPort::StopBits)settings.value("defaultStopBits", QSerialPort::UnknownStopBits).toInt();
m_connectionMode = (QSerialPort::BaudRate)settings.value("connectionMode", "Serial").toString();
m_defaultTimeOut = 5000;
}
int ispeed = qSettings->value("defaultSpeed").toInt();
int idatabits = qSettings->value("defaultDataBits").toInt();
int iflow = qSettings->value("defaultFlow").toInt();
int iparity = qSettings->value("defaultParity").toInt();
int istopbits = qSettings->value("defaultStopBits").toInt();
QString port = qSettings->value("defaultPort").toString();
QString conMode = qSettings->value("connectionMode").toString();
databits = (QSerialPort::DataBits)idatabits;
flow = (QSerialPort::FlowControl)iflow;
parity = (QSerialPort::Parity)iparity;
stopbits = (QSerialPort::StopBits)istopbits;
speed = (QSerialPort::BaudRate)ispeed;
m_defaultPort = port;
m_defaultSpeed = speed;
m_defaultDataBits = databits;
m_defaultFlow = flow;
m_defaultParity = parity;
m_defaultStopBits = stopbits;
m_connectionMode = conMode;
}
AntennaTrackGadgetConfiguration::AntennaTrackGadgetConfiguration(const AntennaTrackGadgetConfiguration &obj) :
IUAVGadgetConfiguration(obj.classId(), obj.parent())
{
m_defaultSpeed = obj.m_defaultSpeed;
m_defaultDataBits = obj.m_defaultDataBits;
m_defaultFlow = obj.m_defaultFlow;
m_defaultParity = obj.m_defaultParity;
m_defaultStopBits = obj.m_defaultStopBits;
m_defaultPort = obj.m_defaultPort;
m_connectionMode = obj.m_connectionMode;
m_defaultTimeOut = obj.m_defaultTimeOut;
}
/**
* Clones a configuration.
*
*/
IUAVGadgetConfiguration *AntennaTrackGadgetConfiguration::clone()
IUAVGadgetConfiguration *AntennaTrackGadgetConfiguration::clone() const
{
AntennaTrackGadgetConfiguration *m = new AntennaTrackGadgetConfiguration(this->classId());
m->m_defaultSpeed = m_defaultSpeed;
m->m_defaultDataBits = m_defaultDataBits;
m->m_defaultFlow = m_defaultFlow;
m->m_defaultParity = m_defaultParity;
m->m_defaultStopBits = m_defaultStopBits;
m->m_defaultPort = m_defaultPort;
m->m_connectionMode = m_connectionMode;
return m;
return new AntennaTrackGadgetConfiguration(*this);
}
/**
* Saves a configuration.
*
*/
void AntennaTrackGadgetConfiguration::saveConfig(QSettings *settings) const
void AntennaTrackGadgetConfiguration::saveConfig(QSettings &settings) const
{
settings->setValue("defaultSpeed", m_defaultSpeed);
settings->setValue("defaultDataBits", m_defaultDataBits);
settings->setValue("defaultFlow", m_defaultFlow);
settings->setValue("defaultParity", m_defaultParity);
settings->setValue("defaultStopBits", m_defaultStopBits);
settings->setValue("defaultPort", m_defaultPort);
settings->setValue("connectionMode", m_connectionMode);
settings.setValue("defaultSpeed", m_defaultSpeed);
settings.setValue("defaultDataBits", m_defaultDataBits);
settings.setValue("defaultFlow", m_defaultFlow);
settings.setValue("defaultParity", m_defaultParity);
settings.setValue("defaultStopBits", m_defaultStopBits);
settings.setValue("defaultPort", m_defaultPort);
settings.setValue("connectionMode", m_connectionMode);
}

View File

@ -29,6 +29,7 @@
#define ANTENNATRACKGADGETCONFIGURATION_H
#include <coreplugin/iuavgadgetconfiguration.h>
#include <QtSerialPort/QSerialPort>
using namespace Core;
@ -45,11 +46,14 @@ struct PortSettings {
long Timeout_Millisec;
};
class AntennaTrackGadgetConfiguration : public IUAVGadgetConfiguration {
Q_OBJECT
public:
explicit AntennaTrackGadgetConfiguration(QString classId, QSettings *qSettings = 0, QObject *parent = 0);
explicit AntennaTrackGadgetConfiguration(QString classId, QSettings &settings, QObject *parent = 0);
explicit AntennaTrackGadgetConfiguration(const AntennaTrackGadgetConfiguration &obj);
IUAVGadgetConfiguration *clone() const;
void saveConfig(QSettings &settings) const;
void setConnectionMode(QString mode)
{
@ -59,7 +63,6 @@ public:
{
return m_connectionMode;
}
// set port configuration functions
void setSpeed(QSerialPort::BaudRate speed)
{
@ -120,9 +123,6 @@ public:
return m_defaultTimeOut;
}
void saveConfig(QSettings *settings) const;
IUAVGadgetConfiguration *clone();
private:
QString m_connectionMode;
QString m_defaultPort;

View File

@ -47,9 +47,9 @@ Core::IUAVGadget *AntennaTrackGadgetFactory::createGadget(QWidget *parent)
return new AntennaTrackGadget(QString("AntennaTrackGadget"), gadgetWidget, parent);
}
IUAVGadgetConfiguration *AntennaTrackGadgetFactory::createConfiguration(QSettings *qSettings)
IUAVGadgetConfiguration *AntennaTrackGadgetFactory::createConfiguration(QSettings &settings)
{
return new AntennaTrackGadgetConfiguration(QString("AntennaTrackGadget"), qSettings);
return new AntennaTrackGadgetConfiguration(QString("AntennaTrackGadget"), settings);
}
IOptionsPage *AntennaTrackGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)

View File

@ -44,7 +44,7 @@ public:
~AntennaTrackGadgetFactory();
Core::IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(QSettings *qSettings);
IUAVGadgetConfiguration *createConfiguration(QSettings &settings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
};

View File

@ -45,12 +45,12 @@ void ConfigGadget::loadConfiguration(IUAVGadgetConfiguration *config)
Q_UNUSED(config);
}
void ConfigGadget::saveState(QSettings *settings)
void ConfigGadget::saveState(QSettings &settings)
{
m_widget->saveState(settings);
}
void ConfigGadget::restoreState(QSettings *settings)
void ConfigGadget::restoreState(QSettings &settings)
{
m_widget->restoreState(settings);
}

View File

@ -49,8 +49,8 @@ public:
void loadConfiguration(IUAVGadgetConfiguration *config);
void saveState(QSettings *settings);
void restoreState(QSettings *settings);
void saveState(QSettings &settings);
void restoreState(QSettings &settings);
private:
ConfigGadgetWidget *m_widget;

View File

@ -173,14 +173,14 @@ void ConfigGadgetWidget::startInputWizard()
inputWidget->startInputWizard();
}
void ConfigGadgetWidget::saveState(QSettings *settings)
void ConfigGadgetWidget::saveState(QSettings &settings)
{
settings->setValue("currentIndex", stackWidget->currentIndex());
settings.setValue("currentIndex", stackWidget->currentIndex());
}
void ConfigGadgetWidget::restoreState(QSettings *settings)
void ConfigGadgetWidget::restoreState(QSettings &settings)
{
int index = settings->value("currentIndex", 0).toInt();
int index = settings.value("currentIndex", 0).toInt();
stackWidget->setCurrentIndex(index);
}

View File

@ -45,8 +45,8 @@ public:
void startInputWizard();
void saveState(QSettings *settings);
void restoreState(QSettings *settings);
void saveState(QSettings &settings);
void restoreState(QSettings &settings);
protected:
void resizeEvent(QResizeEvent *event);

View File

@ -481,14 +481,14 @@ static const char *settingsGroup = "KeyBindings";
static const char *idKey = "ID";
static const char *sequenceKey = "Keysequence";
void ActionManagerPrivate::readSettings(QSettings *settings)
void ActionManagerPrivate::readSettings(QSettings &settings)
{
const int shortcuts = settings->beginReadArray(QLatin1String(settingsGroup));
const int shortcuts = settings.beginReadArray(QLatin1String(settingsGroup));
for (int i = 0; i < shortcuts; ++i) {
settings->setArrayIndex(i);
const QString sid = settings->value(QLatin1String(idKey)).toString();
const QKeySequence key(settings->value(QLatin1String(sequenceKey)).toString());
settings.setArrayIndex(i);
const QString sid = settings.value(QLatin1String(idKey)).toString();
const QKeySequence key(settings.value(QLatin1String(sequenceKey)).toString());
const int id = UniqueIDManager::instance()->uniqueIdentifier(sid);
Command *cmd = command(id);
@ -496,12 +496,12 @@ void ActionManagerPrivate::readSettings(QSettings *settings)
cmd->setKeySequence(key);
}
}
settings->endArray();
settings.endArray();
}
void ActionManagerPrivate::saveSettings(QSettings *settings)
void ActionManagerPrivate::saveSettings(QSettings &settings) const
{
settings->beginWriteArray(QLatin1String(settingsGroup));
settings.beginWriteArray(QLatin1String(settingsGroup));
int count = 0;
const IdCmdMap::const_iterator cmdcend = m_idCmdMap.constEnd();
@ -511,12 +511,12 @@ void ActionManagerPrivate::saveSettings(QSettings *settings)
QKeySequence key = cmd->keySequence();
if (key != cmd->defaultKeySequence()) {
const QString sid = UniqueIDManager::instance()->stringForUniqueIdentifier(id);
settings->setArrayIndex(count);
settings->setValue(QLatin1String(idKey), sid);
settings->setValue(QLatin1String(sequenceKey), key.toString());
settings.setArrayIndex(count);
settings.setValue(QLatin1String(idKey), sid);
settings.setValue(QLatin1String(sequenceKey), key.toString());
count++;
}
}
settings->endArray();
settings.endArray();
}

View File

@ -31,9 +31,9 @@
#include <coreplugin/actionmanager/actionmanager.h>
#include <QtCore/QMap>
#include <QtCore/QHash>
#include <QtCore/QMultiHash>
#include <QMap>
#include <QHash>
#include <QMultiHash>
QT_BEGIN_NAMESPACE
class QSettings;
@ -62,7 +62,9 @@ public:
void setContext(const QList<int> &context);
static ActionManagerPrivate *instance();
void saveSettings(QSettings *settings);
void saveSettings(QSettings &settings) const;
void readSettings(QSettings &settings);
QList<int> defaultGroups() const;
QList<CommandPrivate *> commands() const;
@ -73,8 +75,6 @@ public:
Command *command(int uid) const;
ActionContainer *actionContainer(int uid) const;
void readSettings(QSettings *settings);
// ActionManager Interface
ActionContainer *createMenu(const QString &id);
ActionContainer *createMenuBar(const QString &id);

View File

@ -28,11 +28,11 @@
#include "coreimpl.h"
#include <QtCore/QDir>
#include <QtCore/QCoreApplication>
#include "utils/pathutils.h"
#include <QDir>
#include <QSettings>
namespace Core {
namespace Internal {
// The Core Singleton
@ -117,11 +117,6 @@ MimeDatabase *CoreImpl::mimeDatabase() const
return m_mainwindow->mimeDatabase();
}
QSettings *CoreImpl::settings(QSettings::Scope scope) const
{
return m_mainwindow->settings(scope);
}
SettingsDatabase *CoreImpl::settingsDatabase() const
{
return m_mainwindow->settingsDatabase();
@ -137,7 +132,6 @@ IContext *CoreImpl::currentContextObject() const
return m_mainwindow->currentContextObject();
}
QMainWindow *CoreImpl::mainWindow() const
{
return m_mainwindow;
@ -181,24 +175,40 @@ void CoreImpl::openFiles(const QStringList &arguments)
// m_mainwindow->openFiles(arguments);
}
void CoreImpl::readMainSettings(QSettings *qs, bool workspaceDiffOnly)
void CoreImpl::readSettings(IConfigurablePlugin *plugin)
{
m_mainwindow->readSettings(qs, workspaceDiffOnly);
QSettings settings;
readSettings(plugin, settings);
}
void CoreImpl::saveMainSettings(QSettings *qs)
void CoreImpl::saveSettings(IConfigurablePlugin *plugin) const
{
m_mainwindow->saveSettings(qs);
QSettings settings;
saveSettings(plugin, settings);
}
void CoreImpl::readSettings(IConfigurablePlugin *plugin, QSettings *qs)
void CoreImpl::readMainSettings(QSettings &settings, bool workspaceDiffOnly)
{
m_mainwindow->readSettings(plugin, qs);
m_mainwindow->readSettings(settings, workspaceDiffOnly);
}
void CoreImpl::saveSettings(IConfigurablePlugin *plugin, QSettings *qs)
void CoreImpl::saveMainSettings(QSettings &settings) const
{
m_mainwindow->saveSettings(plugin, qs);
m_mainwindow->saveSettings(settings);
}
void CoreImpl::readSettings(IConfigurablePlugin *plugin, QSettings &settings)
{
m_mainwindow->readSettings(plugin, settings);
}
void CoreImpl::saveSettings(IConfigurablePlugin *plugin, QSettings &settings) const
{
m_mainwindow->saveSettings(plugin, settings);
}
void CoreImpl::deleteSettings()
{
m_mainwindow->deleteSettings();

View File

@ -60,12 +60,14 @@ public:
ModeManager *modeManager() const;
MimeDatabase *mimeDatabase() const;
QSettings *settings(QSettings::Scope scope = QSettings::UserScope) const;
SettingsDatabase *settingsDatabase() const;
void readMainSettings(QSettings *qs, bool workspaceDiffOnly);
void saveMainSettings(QSettings *qs);
void readSettings(IConfigurablePlugin *plugin, QSettings *qs = 0);
void saveSettings(IConfigurablePlugin *plugin, QSettings *qs = 0);
void readMainSettings(QSettings &settings, bool workspaceDiffOnly);
void saveMainSettings(QSettings &settings) const;
void readSettings(IConfigurablePlugin *plugin);
void saveSettings(IConfigurablePlugin *plugin) const;
void readSettings(IConfigurablePlugin *plugin, QSettings &settings);
void saveSettings(IConfigurablePlugin *plugin, QSettings &settings) const;
void deleteSettings();
QString resourcePath() const;

View File

@ -33,8 +33,8 @@
#include "coreplugin/uavgadgetinstancemanager.h"
#include "coreplugin/uavgadgetoptionspagedecorator.h"
#include <QtCore/QDebug>
#include <QtCore/QSettings>
#include <QDebug>
#include <QSettings>
#include <QHeaderView>
#include <QLabel>
#include <QPushButton>
@ -96,10 +96,10 @@ Q_DECLARE_METATYPE(::PageData) SettingsDialog::SettingsDialog(QWidget *parent, c
setWindowTitle(tr("Options"));
#endif
QSettings *settings = ICore::instance()->settings();
QSettings settings;
settings->beginGroup("General");
settings->beginGroup("Settings");
settings.beginGroup("General");
settings.beginGroup("Settings");
// restore last displayed category and page
// this is done only if no category or page was provided through the constructor
@ -107,28 +107,28 @@ Q_DECLARE_METATYPE(::PageData) SettingsDialog::SettingsDialog(QWidget *parent, c
QString initialPage = pageId;
qDebug() << "SettingsDialog constructor initial category:" << initialCategory << ", initial page:" << initialPage;
if (initialCategory.isEmpty() && initialPage.isEmpty()) {
initialCategory = settings->value("LastPreferenceCategory", QVariant(QString())).toString();
initialPage = settings->value("LastPreferencePage", QVariant(QString())).toString();
initialCategory = settings.value("LastPreferenceCategory", QVariant(QString())).toString();
initialPage = settings.value("LastPreferencePage", QVariant(QString())).toString();
qDebug() << "SettingsDialog settings initial category:" << initialCategory << ", initial page: " << initialPage;
}
// restore window size
int windowWidth = settings->value("WindowWidth", 0).toInt();
int windowHeight = settings->value("WindowHeight", 0).toInt();
int windowWidth = settings.value("WindowWidth", 0).toInt();
int windowHeight = settings.value("WindowHeight", 0).toInt();
qDebug() << "SettingsDialog window width :" << windowWidth << ", height:" << windowHeight;
if (windowWidth > 0 && windowHeight > 0) {
resize(windowWidth, windowHeight);
}
// restore splitter size
int splitterPosition = settings->value("SplitterPosition", 350).toInt();
int splitterPosition = settings.value("SplitterPosition", 350).toInt();
qDebug() << "SettingsDialog splitter position:" << splitterPosition;
QList<int> sizes;
sizes << splitterPosition << 400;
splitter->setSizes(sizes);
settings->endGroup();
settings->endGroup();
settings.endGroup();
settings.endGroup();
// all extra space must go to the option page and none to the tree
splitter->setStretchFactor(0, 0);
@ -464,22 +464,22 @@ bool SettingsDialog::execDialog()
void SettingsDialog::done(int val)
{
QSettings *settings = ICore::instance()->settings();
QSettings settings;
settings->beginGroup("General");
settings->beginGroup("Settings");
settings.beginGroup("General");
settings.beginGroup("Settings");
settings->setValue("LastPreferenceCategory", m_currentCategory);
settings->setValue("LastPreferencePage", m_currentPage);
settings.setValue("LastPreferenceCategory", m_currentCategory);
settings.setValue("LastPreferencePage", m_currentPage);
settings->setValue("WindowWidth", this->width());
settings->setValue("WindowHeight", this->height());
settings.setValue("WindowWidth", this->width());
settings.setValue("WindowHeight", this->height());
QList<int> sizes = splitter->sizes();
settings->setValue("SplitterPosition", sizes[0]);
settings.setValue("SplitterPosition", sizes[0]);
settings->endGroup();
settings->endGroup();
settings.endGroup();
settings.endGroup();
QDialog::done(val);
}

View File

@ -31,7 +31,7 @@
#include "ui_settingsdialog.h"
#include <QtCore/QList>
#include <QList>
#include "coreplugin/dialogs/ioptionspage.h"

View File

@ -157,40 +157,40 @@ void GeneralSettings::finish()
delete m_page;
}
void GeneralSettings::readSettings(QSettings *qs)
void GeneralSettings::readSettings(QSettings &settings)
{
qs->beginGroup(QLatin1String("General"));
m_language = qs->value(QLatin1String("OverrideLanguage"), QLocale::system().name()).toString();
m_saveSettingsOnExit = qs->value(QLatin1String("SaveSettingsOnExit"), m_saveSettingsOnExit).toBool();
m_autoConnect = qs->value(QLatin1String("AutoConnect"), m_autoConnect).toBool();
m_autoSelect = qs->value(QLatin1String("AutoSelect"), m_autoSelect).toBool();
m_useUDPMirror = qs->value(QLatin1String("UDPMirror"), m_useUDPMirror).toBool();
m_useExpertMode = qs->value(QLatin1String("ExpertMode"), m_useExpertMode).toBool();
m_collectUsageData = qs->value(QLatin1String("CollectUsageData"), m_collectUsageData).toBool();
m_showUsageDataDisclaimer = qs->value(QLatin1String("ShowUsageDataDisclaimer"), m_showUsageDataDisclaimer).toBool();
m_lastUsageHash = qs->value(QLatin1String("LastUsageHash"), m_lastUsageHash).toString();
qs->endGroup();
settings.beginGroup(QLatin1String("General"));
m_language = settings.value(QLatin1String("OverrideLanguage"), QLocale::system().name()).toString();
m_saveSettingsOnExit = settings.value(QLatin1String("SaveSettingsOnExit"), m_saveSettingsOnExit).toBool();
m_autoConnect = settings.value(QLatin1String("AutoConnect"), m_autoConnect).toBool();
m_autoSelect = settings.value(QLatin1String("AutoSelect"), m_autoSelect).toBool();
m_useUDPMirror = settings.value(QLatin1String("UDPMirror"), m_useUDPMirror).toBool();
m_useExpertMode = settings.value(QLatin1String("ExpertMode"), m_useExpertMode).toBool();
m_collectUsageData = settings.value(QLatin1String("CollectUsageData"), m_collectUsageData).toBool();
m_showUsageDataDisclaimer = settings.value(QLatin1String("ShowUsageDataDisclaimer"), m_showUsageDataDisclaimer).toBool();
m_lastUsageHash = settings.value(QLatin1String("LastUsageHash"), m_lastUsageHash).toString();
settings.endGroup();
}
void GeneralSettings::saveSettings(QSettings *qs)
void GeneralSettings::saveSettings(QSettings &settings) const
{
qs->beginGroup(QLatin1String("General"));
settings.beginGroup(QLatin1String("General"));
if (m_language.isEmpty()) {
qs->remove(QLatin1String("OverrideLanguage"));
settings.remove(QLatin1String("OverrideLanguage"));
} else {
qs->setValue(QLatin1String("OverrideLanguage"), m_language);
settings.setValue(QLatin1String("OverrideLanguage"), m_language);
}
qs->setValue(QLatin1String("SaveSettingsOnExit"), m_saveSettingsOnExit);
qs->setValue(QLatin1String("AutoConnect"), m_autoConnect);
qs->setValue(QLatin1String("AutoSelect"), m_autoSelect);
qs->setValue(QLatin1String("UDPMirror"), m_useUDPMirror);
qs->setValue(QLatin1String("ExpertMode"), m_useExpertMode);
qs->setValue(QLatin1String("CollectUsageData"), m_collectUsageData);
qs->setValue(QLatin1String("ShowUsageDataDisclaimer"), m_showUsageDataDisclaimer);
qs->setValue(QLatin1String("LastUsageHash"), m_lastUsageHash);
qs->endGroup();
settings.setValue(QLatin1String("SaveSettingsOnExit"), m_saveSettingsOnExit);
settings.setValue(QLatin1String("AutoConnect"), m_autoConnect);
settings.setValue(QLatin1String("AutoSelect"), m_autoSelect);
settings.setValue(QLatin1String("UDPMirror"), m_useUDPMirror);
settings.setValue(QLatin1String("ExpertMode"), m_useExpertMode);
settings.setValue(QLatin1String("CollectUsageData"), m_collectUsageData);
settings.setValue(QLatin1String("ShowUsageDataDisclaimer"), m_showUsageDataDisclaimer);
settings.setValue(QLatin1String("LastUsageHash"), m_lastUsageHash);
settings.endGroup();
}
void GeneralSettings::resetInterfaceColor()

View File

@ -33,7 +33,8 @@
#include <QPointer>
#include <QWidget>
#include <QSettings>
class QSettings;
namespace Core {
namespace Internal {
@ -61,8 +62,8 @@ public:
bool collectUsageData() const;
bool showUsageDataDisclaimer() const;
QString lastUsageHash() const;
void readSettings(QSettings *qs);
void saveSettings(QSettings *qs);
void readSettings(QSettings &settings);
void saveSettings(QSettings &settings) const;
bool useExpertMode() const;
void setCollectUsageData(bool collect);
void setShowUsageDataDisclaimer(bool show);

View File

@ -14,8 +14,8 @@ class CORE_EXPORT IConfigurablePlugin : public ExtensionSystem::IPlugin {
public:
// IConfigurablePlugin(QObject *parent = 0){}
virtual ~IConfigurablePlugin() {}
virtual void readConfig(QSettings *qSettings, UAVConfigInfo *configInfo) = 0;
virtual void saveConfig(QSettings *qSettings, Core::UAVConfigInfo *configInfo) = 0;
virtual void readConfig(QSettings &settings, UAVConfigInfo *configInfo) = 0;
virtual void saveConfig(QSettings &settings, Core::UAVConfigInfo *configInfo) const = 0;
};
} // namespace Core

View File

@ -172,24 +172,6 @@
Use the mime database to manage mime types.
*/
/*!
\fn QSettings *ICore::settings(QSettings::UserScope scope) const
\brief Returns the application's main settings object.
You can use it to retrieve or set application wide settings
(in contrast to session or project specific settings).
If \a scope is QSettings::UserScope (the default), the
users settings will be read from the users settings, with
a fallback to global settings provided with Qt Creator.
If \a scope is QSettings::SystemScope, only the system settings
shipped with the current version of Qt Creator will be read. This
functionality exists for internal purposes only.
\see settingsDatabase()
*/
/*!
\fn SettingsDatabase *ICore::settingsDatabase() const
\brief Returns the application's settings database.

View File

@ -30,13 +30,12 @@
#define ICORE_H
#include "core_global.h"
#include <QtCore/QObject>
#include <QSettings>
#include <QObject>
QT_BEGIN_NAMESPACE
class QMainWindow;
class QSettings;
template <class T> class QList;
QT_END_NAMESPACE
namespace Core {
@ -84,12 +83,14 @@ public:
virtual UAVGadgetInstanceManager *uavGadgetInstanceManager() const = 0;
virtual MimeDatabase *mimeDatabase() const = 0;
virtual QSettings *settings(QSettings::Scope scope = QSettings::UserScope) const = 0;
virtual SettingsDatabase *settingsDatabase() const = 0;
virtual void readMainSettings(QSettings *qs, bool workspaceDiffOnly = false) = 0;
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 readMainSettings(QSettings &settings, bool workspaceDiffOnly = false) = 0;
virtual void saveMainSettings(QSettings &settings) const = 0;
virtual void readSettings(IConfigurablePlugin *plugin) = 0;
virtual void saveSettings(IConfigurablePlugin *plugin) const = 0;
virtual void readSettings(IConfigurablePlugin *plugin, QSettings &settings) = 0;
virtual void saveSettings(IConfigurablePlugin *plugin, QSettings &settings) const = 0;
virtual void deleteSettings() = 0;
virtual QString resourcePath() const = 0;

View File

@ -77,9 +77,9 @@ public:
return 0;
}
virtual void loadConfiguration(IUAVGadgetConfiguration *) {}
virtual void saveState(QSettings * /*qSettings*/) {}
virtual void saveState(QSettings &) const {}
virtual void restoreState(QByteArray) {}
virtual void restoreState(QSettings * /*qSettings*/) {}
virtual void restoreState(QSettings &) {}
public slots:
virtual void configurationChanged(IUAVGadgetConfiguration *) {}
virtual void configurationAdded(IUAVGadgetConfiguration *) {}

View File

@ -31,8 +31,8 @@ using namespace Core;
IUAVGadgetConfiguration::IUAVGadgetConfiguration(QString classId, QObject *parent) :
QObject(parent),
m_locked(false),
m_classId(classId),
m_name(tr("default")),
m_provisionalName(tr("default"))
m_provisionalName(tr("default")),
m_locked(false)
{}

View File

@ -40,52 +40,60 @@ class CORE_EXPORT IUAVGadgetConfiguration : public QObject {
Q_OBJECT
public:
explicit IUAVGadgetConfiguration(QString classId, QObject *parent = 0);
QString classId()
QString classId() const
{
return m_classId;
}
QString name()
QString name() const
{
return m_name;
}
void setName(QString name)
{
m_name = name;
}
QString provisionalName()
QString provisionalName() const
{
return m_provisionalName;
}
void setProvisionalName(QString name)
{
m_provisionalName = name;
}
bool locked() const
{
return m_locked;
}
void setLocked(bool locked)
{
m_locked = locked;
}
virtual void saveConfig(QSettings * /*settings*/) const {}
virtual void saveConfig(QSettings *settings, UAVConfigInfo * /*configInfo*/) const
virtual void saveConfig(QSettings &) const {}
virtual void saveConfig(QSettings &settings, UAVConfigInfo *) const
{
saveConfig(settings);
}
virtual IUAVGadgetConfiguration *clone() = 0;
virtual IUAVGadgetConfiguration *clone() const = 0;
signals:
public slots:
private:
bool m_locked;
QString m_classId;
QString m_name;
QString m_provisionalName;
bool m_locked;
};
} // namespace Core

View File

@ -28,15 +28,17 @@
#ifndef IUAVGADGETFACTORY_H
#define IUAVGADGETFACTORY_H
#include "core_global.h"
#include <QtCore/QObject>
#include <QIcon>
#include <QSettings>
#include "uavconfiginfo.h"
#include <QObject>
#include <QIcon>
QT_BEGIN_NAMESPACE
class QStringList;
class QSettings;
QT_END_NAMESPACE
namespace Core {
@ -56,15 +58,15 @@ public:
virtual ~IUAVGadgetFactory() {}
virtual IUAVGadget *createGadget(QWidget *parent) = 0;
virtual IUAVGadgetConfiguration *createConfiguration(QSettings * /*qSettings*/)
virtual IUAVGadgetConfiguration *createConfiguration(QSettings &)
{
return 0;
}
virtual IUAVGadgetConfiguration *createConfiguration(QSettings *qs, UAVConfigInfo * /*configInfo*/)
virtual IUAVGadgetConfiguration *createConfiguration(QSettings &settings, UAVConfigInfo *)
{
return createConfiguration(qs);
return createConfiguration(settings);
}
virtual IOptionsPage *createOptionsPage(IUAVGadgetConfiguration * /*config*/)
virtual IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *)
{
return 0;
}

View File

@ -65,7 +65,6 @@
#include <utils/pathchooser.h>
#include <utils/pathutils.h>
#include <utils/stylehelper.h>
#include <utils/xmlconfig.h>
#include "version_info/version_info.h"
#include <QtCore/QDebug>
@ -102,13 +101,6 @@ MainWindow::MainWindow() :
m_uniqueIDManager(new UniqueIDManager()),
m_globalContext(QList<int>() << Constants::C_GLOBAL_ID),
m_additionalContexts(m_globalContext),
// keep this in sync with main() in app/main.cpp
m_settings(new QSettings(this)),
m_globalSettings(new QSettings(XmlConfig::XmlFormat, QSettings::SystemScope,
m_settings->organizationName(), m_settings->applicationName(), this)),
m_settingsDatabase(new SettingsDatabase(QFileInfo(m_settings->fileName()).path(),
QFileInfo(m_settings->fileName()).baseName(),
this)),
m_dontSaveSettings(false),
m_actionManager(new ActionManagerPrivate(this)),
m_variableManager(new VariableManager(this)),
@ -140,6 +132,11 @@ MainWindow::MainWindow() :
#endif
qApp->setStyle(QStyleFactory::create("Fusion"));
QSettings settings;
m_settingsDatabase = new SettingsDatabase(QFileInfo(settings.fileName()).path(),
QFileInfo(settings.fileName()).baseName(),
this);
setDockNestingEnabled(true);
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
@ -200,10 +197,8 @@ MainWindow::~MainWindow()
m_generalSettings = 0;
delete m_workspaceSettings;
m_workspaceSettings = 0;
delete m_settings;
m_settings = 0;
delete m_uniqueIDManager;
m_uniqueIDManager = 0;
m_uniqueIDManager = 0;
pm->removeObject(m_coreImpl);
delete m_coreImpl;
@ -236,13 +231,13 @@ void MainWindow::modeChanged(Core::IMode * /*mode*/)
void MainWindow::extensionsInitialized()
{
QSettings *qs = m_settings;
QSettings settings;
qs->beginGroup("General");
settings.beginGroup("General");
m_config_description = qs->value("Description", "none").toString();
m_config_details = qs->value("Details", "none").toString();
m_config_stylesheet = qs->value("StyleSheet", "none").toString();
m_config_description = settings.value("Description", "none").toString();
m_config_details = settings.value("Details", "none").toString();
m_config_stylesheet = settings.value("StyleSheet", "none").toString();
qDebug() << "Configured style sheet:" << m_config_stylesheet;
if (m_config_stylesheet == "wide") {
@ -269,13 +264,14 @@ void MainWindow::extensionsInitialized()
// qDebug() << "Setting application style sheet to:" << style;
qApp->setStyleSheet(style);
qs->endGroup();
settings.endGroup();
m_uavGadgetInstanceManager = new UAVGadgetInstanceManager(this);
m_uavGadgetInstanceManager->readSettings(qs);
m_uavGadgetInstanceManager->readSettings(settings);
m_messageManager->init();
readSettings(qs);
readSettings(settings);
updateContext();
@ -323,8 +319,9 @@ void MainWindow::closeEvent(QCloseEvent *event)
emit m_coreImpl->coreAboutToClose();
if (!m_dontSaveSettings) {
saveSettings(m_settings);
m_uavGadgetInstanceManager->saveSettings(m_settings);
QSettings settings;
saveSettings(settings);
m_uavGadgetInstanceManager->saveSettings(settings);
}
qApp->closeAllWindows();
@ -477,31 +474,31 @@ void MainWindow::registerDefaultActions()
ActionContainer *mhelp = am->actionContainer(Constants::M_HELP);
// File menu separators
Command *cmd = createSeparator(am, this, QLatin1String("QtCreator.File.Sep.Save"), m_globalContext);
Command *cmd = createSeparator(am, this, "QtCreator.File.Sep.Save", m_globalContext);
mfile->addAction(cmd, Constants::G_FILE_SAVE);
cmd = createSeparator(am, this, QLatin1String("QtCreator.File.Sep.Close"), m_globalContext);
cmd = createSeparator(am, this, "QtCreator.File.Sep.Close", m_globalContext);
mfile->addAction(cmd, Constants::G_FILE_CLOSE);
cmd = createSeparator(am, this, QLatin1String("QtCreator.File.Sep.Other"), m_globalContext);
cmd = createSeparator(am, this, "QtCreator.File.Sep.Other", m_globalContext);
mfile->addAction(cmd, Constants::G_FILE_OTHER);
// Edit menu separators
cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.CopyPaste"), m_globalContext);
cmd = createSeparator(am, this, "QtCreator.Edit.Sep.CopyPaste", m_globalContext);
medit->addAction(cmd, Constants::G_EDIT_COPYPASTE);
cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.SelectAll"), m_globalContext);
cmd = createSeparator(am, this, "QtCreator.Edit.Sep.SelectAll", m_globalContext);
medit->addAction(cmd, Constants::G_EDIT_SELECTALL);
cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.Find"), m_globalContext);
cmd = createSeparator(am, this, "QtCreator.Edit.Sep.Find", m_globalContext);
medit->addAction(cmd, Constants::G_EDIT_FIND);
cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.Advanced"), m_globalContext);
cmd = createSeparator(am, this, "QtCreator.Edit.Sep.Advanced", m_globalContext);
medit->addAction(cmd, Constants::G_EDIT_ADVANCED);
// Tools menu separators
cmd = createSeparator(am, this, QLatin1String("QtCreator.Tools.Sep.Options"), m_globalContext);
cmd = createSeparator(am, this, "QtCreator.Tools.Sep.Options", m_globalContext);
mtools->addAction(cmd, Constants::G_DEFAULT_THREE);
// Help menu separators
@ -653,7 +650,7 @@ void MainWindow::registerDefaultActions()
connect(m_zoomAction, SIGNAL(triggered()), this, SLOT(showMaximized()));
// Window separator
cmd = createSeparator(am, this, QLatin1String("QtCreator.Window.Sep.Size"), m_globalContext);
cmd = createSeparator(am, this, "QtCreator.Window.Sep.Size"), m_globalContext);
mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
#endif
@ -675,7 +672,7 @@ void MainWindow::registerDefaultActions()
// Window menu separators
QAction *tmpaction1 = new QAction(this);
tmpaction1->setSeparator(true);
cmd = am->registerAction(tmpaction1, QLatin1String("OpenPilot.Window.Sep.Split"), uavGadgetManagerContext);
cmd = am->registerAction(tmpaction1, "OpenPilot.Window.Sep.Split", uavGadgetManagerContext);
mwindow->addAction(cmd, Constants::G_WINDOW_HIDE_TOOLBAR);
m_showToolbarsAction = new QAction(tr("Edit Gadgets Mode"), this);
@ -687,7 +684,7 @@ void MainWindow::registerDefaultActions()
// Window menu separators
QAction *tmpaction2 = new QAction(this);
tmpaction2->setSeparator(true);
cmd = am->registerAction(tmpaction2, QLatin1String("OpenPilot.Window.Sep.Split2"), uavGadgetManagerContext);
cmd = am->registerAction(tmpaction2, "OpenPilot.Window.Sep.Split2", uavGadgetManagerContext);
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
#ifdef Q_WS_MAC
@ -733,7 +730,7 @@ void MainWindow::registerDefaultActions()
#ifndef Q_WS_MAC
tmpaction = new QAction(this);
tmpaction->setSeparator(true);
cmd = am->registerAction(tmpaction, QLatin1String("QtCreator.Help.Sep.About"), m_globalContext);
cmd = am->registerAction(tmpaction, "QtCreator.Help.Sep.About", m_globalContext);
mhelp->addAction(cmd, Constants::G_HELP_ABOUT);
#endif
@ -785,7 +782,8 @@ void MainWindow::saveAll()
}
emit m_coreImpl->saveSettingsRequested();
saveSettings(); // OpenPilot-specific.
QSettings settings;
saveSettings(settings);
}
void MainWindow::exit()
@ -829,15 +827,6 @@ MessageManager *MainWindow::messageManager() const
return m_messageManager;
}
QSettings *MainWindow::settings(QSettings::Scope scope) const
{
if (scope == QSettings::UserScope) {
return m_settings;
} else {
return m_globalSettings;
}
}
VariableManager *MainWindow::variableManager() const
{
return m_variableManager;
@ -1025,7 +1014,7 @@ inline int takeLeastPriorityUavGadgetManager(const QList<Core::UAVGadgetManager
return index;
}
void MainWindow::createWorkspaces(QSettings *qs, bool diffOnly)
void MainWindow::createWorkspaces(QSettings &settings, bool diffOnly)
{
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
@ -1084,175 +1073,161 @@ void MainWindow::createWorkspaces(QSettings *qs, bool diffOnly)
pm->addObject(uavGadgetManager);
m_uavGadgetManagers.append(uavGadgetManager);
uavGadgetManager->readSettings(qs);
uavGadgetManager->readSettings(settings);
qDebug() << "MainWindow::createWorkspaces - creating workspace" << name << "took" << timer.elapsed() << "ms";
}
qDebug() << "MainWindow::createWorkspaces - creating workspaces took" << totalTimer.elapsed() << "ms";
}
static const char *settingsGroup = "MainWindow";
static const char *geometryKey = "Geometry";
static const char *colorKey = "Color";
static const char *maxKey = "Maximized";
static const char *fullScreenKey = "FullScreen";
static const char *modePriorities = "ModePriorities";
static const QString settingsGroup = "MainWindow";
static const QString geometryKey = "Geometry";
static const QString colorKey = "Color";
static const QString maxKey = "Maximized";
static const QString fullScreenKey = "FullScreen";
static const QString modePriorities = "ModePriorities";
void MainWindow::readSettings(QSettings *qs, bool workspaceDiffOnly)
void MainWindow::readSettings(QSettings &settings, bool workspaceDiffOnly)
{
if (!qs) {
qs = m_settings;
}
if (workspaceDiffOnly) {
createWorkspaces(qs, workspaceDiffOnly);
createWorkspaces(settings, workspaceDiffOnly);
return;
}
m_generalSettings->readSettings(qs);
m_actionManager->readSettings(qs);
m_generalSettings->readSettings(settings);
m_actionManager->readSettings(settings);
qs->beginGroup(QLatin1String(settingsGroup));
settings.beginGroup(settingsGroup);
Utils::StyleHelper::setBaseColor(qs->value(QLatin1String(colorKey)).value<QColor>());
Utils::StyleHelper::setBaseColor(settings.value(colorKey).value<QColor>());
const QVariant geom = qs->value(QLatin1String(geometryKey));
const QVariant geom = settings.value(geometryKey);
if (geom.isValid()) {
setGeometry(geom.toRect());
} else {
resize(750, 400);
}
if (qs->value(QLatin1String(maxKey), false).toBool()) {
if (settings.value(maxKey, false).toBool()) {
setWindowState(Qt::WindowMaximized);
}
setFullScreen(qs->value(QLatin1String(fullScreenKey), false).toBool());
setFullScreen(settings.value(fullScreenKey, false).toBool());
qs->endGroup();
settings.endGroup();
m_workspaceSettings->readSettings(qs);
m_workspaceSettings->readSettings(settings);
createWorkspaces(qs);
createWorkspaces(settings);
// Restore tab ordering
qs->beginGroup(QLatin1String(modePriorities));
settings.beginGroup(modePriorities);
QStringList modeNames = qs->childKeys();
QStringList modeNames = settings.childKeys();
QMap<QString, int> map;
foreach(QString modeName, modeNames) {
map.insert(modeName, qs->value(modeName).toInt());
map.insert(modeName, settings.value(modeName).toInt());
}
m_modeManager->reorderModes(map);
qs->endGroup();
settings.endGroup();
// Restore selected tab
if (m_workspaceSettings->restoreSelectedOnStartup()) {
int index = qs->value(QLatin1String("SelectedWorkspace")).toInt();
int index = settings.value("SelectedWorkspace").toInt();
m_modeStack->setCurrentIndex(index);
}
}
void MainWindow::saveSettings(QSettings *qs)
void MainWindow::saveSettings(QSettings &settings) const
{
if (m_dontSaveSettings) {
return;
}
if (!qs) {
qs = m_settings;
}
m_workspaceSettings->saveSettings(settings);
m_workspaceSettings->saveSettings(qs);
settings.beginGroup(settingsGroup);
qs->beginGroup(QLatin1String(settingsGroup));
qs->setValue(QLatin1String(colorKey), Utils::StyleHelper::baseColor());
settings.setValue(colorKey, Utils::StyleHelper::baseColor());
if (windowState() & (Qt::WindowMaximized | Qt::WindowFullScreen)) {
qs->setValue(QLatin1String(maxKey), (bool)(windowState() & Qt::WindowMaximized));
qs->setValue(QLatin1String(fullScreenKey), (bool)(windowState() & Qt::WindowFullScreen));
settings.setValue(maxKey, (bool)(windowState() & Qt::WindowMaximized));
settings.setValue(fullScreenKey, (bool)(windowState() & Qt::WindowFullScreen));
} else {
qs->setValue(QLatin1String(maxKey), false);
qs->setValue(QLatin1String(fullScreenKey), false);
qs->setValue(QLatin1String(geometryKey), geometry());
settings.setValue(maxKey, false);
settings.setValue(fullScreenKey, false);
settings.setValue(geometryKey, geometry());
}
qs->endGroup();
settings.endGroup();
// Write tab ordering
qs->beginGroup(QLatin1String(modePriorities));
settings.beginGroup(modePriorities);
QVector<IMode *> modes = m_modeManager->modes();
foreach(IMode * mode, modes) {
qs->setValue(QLatin1String(mode->uniqueModeName()), mode->priority());
settings.setValue(mode->uniqueModeName(), mode->priority());
}
qs->endGroup();
settings.endGroup();
// Write selected tab
qs->setValue(QLatin1String("SelectedWorkspace"), m_modeStack->currentIndex());
settings.setValue("SelectedWorkspace", m_modeStack->currentIndex());
foreach(UAVGadgetManager * manager, m_uavGadgetManagers) {
manager->saveSettings(qs);
manager->saveSettings(settings);
}
m_actionManager->saveSettings(qs);
m_generalSettings->saveSettings(qs);
m_actionManager->saveSettings(settings);
m_generalSettings->saveSettings(settings);
qs->beginGroup("General");
qs->setValue("Description", m_config_description);
qs->setValue("Details", m_config_details);
qs->setValue("StyleSheet", m_config_stylesheet);
qs->endGroup();
settings.beginGroup("General");
settings.setValue("Description", m_config_description);
settings.setValue("Details", m_config_details);
settings.setValue("StyleSheet", m_config_stylesheet);
settings.endGroup();
}
void MainWindow::readSettings(IConfigurablePlugin *plugin, QSettings *qs)
void MainWindow::readSettings(IConfigurablePlugin *plugin, QSettings &settings)
{
if (!qs) {
qs = m_settings;
}
UAVConfigInfo configInfo;
QObject *qo = reinterpret_cast<QObject *>(plugin);
QString configName = qo->metaObject()->className();
qs->beginGroup("Plugins");
qs->beginGroup(configName);
configInfo.read(qs);
settings.beginGroup("Plugins");
settings.beginGroup(configName);
configInfo.read(settings);
configInfo.setNameOfConfigurable("Plugin-" + configName);
qs->beginGroup("data");
plugin->readConfig(qs, &configInfo);
settings.beginGroup("data");
plugin->readConfig(settings, &configInfo);
qs->endGroup();
qs->endGroup();
qs->endGroup();
settings.endGroup();
settings.endGroup();
settings.endGroup();
}
void MainWindow::saveSettings(IConfigurablePlugin *plugin, QSettings *qs)
void MainWindow::saveSettings(IConfigurablePlugin *plugin, QSettings &settings) const
{
if (m_dontSaveSettings) {
return;
}
if (!qs) {
qs = m_settings;
}
UAVConfigInfo configInfo;
QString configName = plugin->metaObject()->className();
qs->beginGroup("Plugins");
qs->beginGroup(configName);
qs->beginGroup("data");
plugin->saveConfig(qs, &configInfo);
qs->endGroup();
configInfo.save(qs);
qs->endGroup();
qs->endGroup();
settings.beginGroup("Plugins");
settings.beginGroup(configName);
settings.beginGroup("data");
plugin->saveConfig(settings, &configInfo);
settings.endGroup();
configInfo.save(settings);
settings.endGroup();
settings.endGroup();
}
void MainWindow::deleteSettings()
{
m_settings->clear();
m_settings->sync();
QSettings settings;
settings.clear();
settings.sync();
m_dontSaveSettings = true;
}

View File

@ -33,8 +33,7 @@
#include "eventfilteringmainwindow.h"
#include <QtCore/QMap>
#include <QSettings>
#include <QMap>
QT_BEGIN_NAMESPACE
class QSettings;
@ -88,10 +87,10 @@ public:
void addContextObject(IContext *contex);
void removeContextObject(IContext *contex);
void resetContext();
void readSettings(QSettings *qs = 0, bool workspaceDiffOnly = false);
void saveSettings(QSettings *qs = 0);
void readSettings(IConfigurablePlugin *plugin, QSettings *qs = 0);
void saveSettings(IConfigurablePlugin *plugin, QSettings *qs = 0);
void readSettings(QSettings &settings, bool workspaceDiffOnly = false);
void saveSettings(QSettings &settings) const;
void readSettings(IConfigurablePlugin *plugin, QSettings &settings);
void saveSettings(IConfigurablePlugin *plugin, QSettings &settings) const;
void deleteSettings();
void openFiles(const QStringList &fileNames);
@ -106,7 +105,6 @@ public:
Core::ModeManager *modeManager() const;
Core::MimeDatabase *mimeDatabase() const;
Internal::GeneralSettings *generalSettings() const;
QSettings *settings(QSettings::Scope scope) const;
inline SettingsDatabase *settingsDatabase() const
{
return m_settingsDatabase;
@ -165,15 +163,13 @@ private:
void updateContextObject(IContext *context);
void registerDefaultContainers();
void registerDefaultActions();
void createWorkspaces(QSettings *qs, bool diffOnly = false);
void createWorkspaces(QSettings &settings, bool diffOnly = false);
QString loadStyleSheet(QString name);
CoreImpl *m_coreImpl;
UniqueIDManager *m_uniqueIDManager;
QList<int> m_globalContext;
QList<int> m_additionalContexts;
QSettings *m_settings;
QSettings *m_globalSettings;
SettingsDatabase *m_settingsDatabase;
bool m_dontSaveSettings; // In case of an Error or if we reset the settings, never save them.
ActionManagerPrivate *m_actionManager;

View File

@ -48,12 +48,9 @@
Typically a plugin can handle version-changes like this:
\code
MyGadgetConfiguration::MyGadgetConfiguration(QString classId, QSettings* qSettings, UAVConfigInfo *configInfo, QObject *parent) :
MyGadgetConfiguration::MyGadgetConfiguration(QString classId, QSettings &settings, UAVConfigInfo *configInfo, QObject *parent) :
IUAVGadgetConfiguration(classId, parent)
{
if ( ! qSettings )
return;
if ( configInfo->version() == UAVConfigVersion() )
configInfo->setVersion("1.0.0");
@ -63,7 +60,7 @@
... read the config ...
}
void MyGadgetConfiguration::saveConfig(QSettings* qSettings, Core::UAVConfigInfo *configInfo) const {
void MyGadgetConfiguration::saveConfig(QSettings &settings, Core::UAVConfigInfo *configInfo) const {
configInfo->setVersion(CURRENT_VERSION);
@ -118,11 +115,11 @@ UAVConfigInfo::UAVConfigInfo(QObject *parent) :
m_nameOfConfigurable("")
{}
UAVConfigInfo::UAVConfigInfo(QSettings *qs, QObject *parent) :
UAVConfigInfo::UAVConfigInfo(QSettings &settings, QObject *parent) :
QObject(parent),
m_version(VERSION_DEFAULT)
{
read(qs);
read(settings);
}
UAVConfigInfo::UAVConfigInfo(UAVConfigVersion version, QString nameOfConfigurable, QObject *parent) :
@ -139,20 +136,20 @@ UAVConfigInfo::UAVConfigInfo(IUAVGadgetConfiguration *config, QObject *parent) :
m_nameOfConfigurable = config->classId() + "-" + config->name();
}
void UAVConfigInfo::save(QSettings *qs)
void UAVConfigInfo::save(QSettings &settings) const
{
qs->beginGroup("configInfo");
qs->setValue("version", m_version.toString());
qs->setValue("locked", m_locked);
qs->endGroup();
settings.beginGroup("configInfo");
settings.setValue("version", m_version.toString());
settings.setValue("locked", m_locked);
settings.endGroup();
}
void UAVConfigInfo::read(QSettings *qs)
void UAVConfigInfo::read(QSettings &settings)
{
qs->beginGroup("configInfo");
m_version = UAVConfigVersion(qs->value("version", VERSION_DEFAULT).toString());
m_locked = qs->value("locked", false).toBool();
qs->endGroup();
settings.beginGroup("configInfo");
m_version = UAVConfigVersion(settings.value("version", VERSION_DEFAULT).toString());
m_locked = settings.value("locked", false).toBool();
settings.endGroup();
}
bool UAVConfigInfo::askToAbort(int compat, QString message)

View File

@ -27,11 +27,12 @@
#ifndef UAVCONFIGINFO_H
#define UAVCONFIGINFO_H
#include "core_global.h"
#include "iuavgadgetconfiguration.h"
#include <QObject>
#include <QString>
#include <QSettings>
#include "iuavgadgetconfiguration.h"
#include "core_global.h"
namespace Core {
class IUAVGadgetConfiguration;
@ -54,18 +55,19 @@ class CORE_EXPORT UAVConfigInfo : public QObject {
public:
explicit UAVConfigInfo(QObject *parent = 0);
explicit UAVConfigInfo(QSettings *qs, QObject *parent = 0);
explicit UAVConfigInfo(QSettings &, QObject *parent = 0);
explicit UAVConfigInfo(IUAVGadgetConfiguration *config, QObject *parent = 0);
UAVConfigInfo(UAVConfigVersion version, QString nameOfConfigurable, QObject *parent = 0);
enum Compatibility { FullyCompatible, MinorLossOfConfiguration, MissingConfiguration, MajorLossOfConfiguration, NotCompatible };
void setNameOfConfigurable(const QString nameOfConfigurable)
{
m_nameOfConfigurable = nameOfConfigurable;
}
void save(QSettings *qs);
void read(QSettings *qs);
void save(QSettings &) const;
void read(QSettings &);
void setVersion(int major, int minor, int patch)
{

View File

@ -26,10 +26,11 @@
*/
#include "uavgadgetdecorator.h"
#include "iuavgadgetconfiguration.h"
#include <QComboBox>
#include <QtCore/QByteArray>
#include <QtCore/QDebug>
#include <QDebug>
using namespace Core;
@ -123,20 +124,20 @@ void UAVGadgetDecorator::updateToolbar()
m_toolbar->setEnabled(m_toolbar->count() > 1);
}
void UAVGadgetDecorator::saveState(QSettings *qSettings)
void UAVGadgetDecorator::saveState(QSettings &settings) const
{
if (m_activeConfiguration) {
qSettings->setValue("activeConfiguration", m_activeConfiguration->name());
settings.setValue("activeConfiguration", m_activeConfiguration->name());
}
// save gadget individual state
qSettings->beginGroup("state");
m_gadget->saveState(qSettings);
qSettings->endGroup();
settings.beginGroup("state");
m_gadget->saveState(settings);
settings.endGroup();
}
void UAVGadgetDecorator::restoreState(QSettings *qSettings)
void UAVGadgetDecorator::restoreState(QSettings &settings)
{
QString configName = qSettings->value("activeConfiguration").toString();
QString configName = settings.value("activeConfiguration").toString();
foreach(IUAVGadgetConfiguration * config, *m_configurations) {
if (config->name() == configName) {
@ -145,7 +146,7 @@ void UAVGadgetDecorator::restoreState(QSettings *qSettings)
}
}
// restore gadget individual state
qSettings->beginGroup("state");
m_gadget->restoreState(qSettings);
qSettings->endGroup();
settings.beginGroup("state");
m_gadget->restoreState(settings);
settings.endGroup();
}

View File

@ -27,8 +27,11 @@
#ifndef UAVGADGETDECORATOR_H
#define UAVGADGETDECORATOR_H
#include <coreplugin/iuavgadget.h>
class QSettings;
namespace Core {
class IUAVGadgetConfiguration;
@ -51,8 +54,8 @@ public:
return m_activeConfiguration;
}
void loadConfiguration(IUAVGadgetConfiguration *config);
void saveState(QSettings *qSettings);
void restoreState(QSettings *qSettings);
void saveState(QSettings &settings) const;
void restoreState(QSettings &settings);
public slots:
void configurationChanged(IUAVGadgetConfiguration *config);
void configurationAdded(IUAVGadgetConfiguration *config);

View File

@ -26,6 +26,7 @@
*/
#include "uavgadgetinstancemanager.h"
#include "iuavgadget.h"
#include "uavgadgetdecorator.h"
#include "iuavgadgetfactory.h"
@ -36,17 +37,16 @@
#include "icore.h"
#include <extensionsystem/pluginmanager.h>
#include <QtCore/QStringList>
#include <QtCore/QSettings>
#include <QtCore/QDebug>
#include <QStringList>
#include <QSettings>
#include <QDebug>
#include <QMessageBox>
using namespace Core;
static const UAVConfigVersion m_versionUAVGadgetConfigurations = UAVConfigVersion("1.2.0");
UAVGadgetInstanceManager::UAVGadgetInstanceManager(QObject *parent) :
QObject(parent)
UAVGadgetInstanceManager::UAVGadgetInstanceManager(QObject *parent) : QObject(parent), m_settingsDialog(NULL)
{
m_pm = ExtensionSystem::PluginManager::instance();
QList<IUAVGadgetFactory *> factories = m_pm->getObjects<IUAVGadgetFactory>();
@ -70,14 +70,17 @@ UAVGadgetInstanceManager::~UAVGadgetInstanceManager()
}
}
void UAVGadgetInstanceManager::readSettings(QSettings *qs)
void UAVGadgetInstanceManager::readSettings(QSettings &settings)
{
while (!m_configurations.isEmpty()) {
emit configurationToBeDeleted(m_configurations.takeLast());
}
qs->beginGroup("UAVGadgetConfigurations");
UAVConfigInfo configInfo(qs);
settings.beginGroup("UAVGadgetConfigurations");
UAVConfigInfo configInfo(settings);
configInfo.setNameOfConfigurable("UAVGadgetConfigurations");
if (configInfo.version() == UAVConfigVersion()) {
// If version is not set, assume its a old version before readable config (1.0.0).
// however compatibility to 1.0.0 is broken.
@ -87,7 +90,7 @@ void UAVGadgetInstanceManager::readSettings(QSettings *qs)
if (configInfo.version() == UAVConfigVersion("1.1.0")) {
configInfo.notify(tr("Migrating UAVGadgetConfigurations from version 1.1.0 to ")
+ m_versionUAVGadgetConfigurations.toString());
readConfigs_1_1_0(qs); // this is fully compatible with 1.2.0
readConfigs_1_1_0(settings); // this is fully compatible with 1.2.0
} else if (!configInfo.standardVersionHandlingOK(m_versionUAVGadgetConfigurations)) {
// We are in trouble now. User wants us to quit the import, but when he saves
// the GCS, his old config will be lost.
@ -95,32 +98,32 @@ void UAVGadgetInstanceManager::readSettings(QSettings *qs)
tr("You might want to save your old config NOW since it might be replaced by broken one when you exit the GCS!")
);
} else {
readConfigs_1_2_0(qs);
readConfigs_1_2_0(settings);
}
qs->endGroup();
settings.endGroup();
createOptionsPages();
}
void UAVGadgetInstanceManager::readConfigs_1_2_0(QSettings *qs)
void UAVGadgetInstanceManager::readConfigs_1_2_0(QSettings &settings)
{
UAVConfigInfo configInfo;
foreach(QString classId, m_classIdNameMap.keys()) {
IUAVGadgetFactory *f = factory(classId);
qs->beginGroup(classId);
settings.beginGroup(classId);
QStringList configs = QStringList();
configs = qs->childGroups();
configs = settings.childGroups();
foreach(QString configName, configs) {
// qDebug() << "Loading config: " << classId << "," << configName;
qs->beginGroup(configName);
configInfo.read(qs);
settings.beginGroup(configName);
configInfo.read(settings);
configInfo.setNameOfConfigurable(classId + "-" + configName);
qs->beginGroup("data");
IUAVGadgetConfiguration *config = f->createConfiguration(qs, &configInfo);
settings.beginGroup("data");
IUAVGadgetConfiguration *config = f->createConfiguration(settings, &configInfo);
if (config) {
config->setName(configName);
config->setProvisionalName(configName);
@ -134,42 +137,42 @@ void UAVGadgetInstanceManager::readConfigs_1_2_0(QSettings *qs)
m_configurations.append(config);
}
}
qs->endGroup();
qs->endGroup();
settings.endGroup();
settings.endGroup();
}
if (configs.count() == 0) {
IUAVGadgetConfiguration *config = f->createConfiguration(0, 0);
// it is not mandatory for uavgadgets to have any configurations (settings)
// and therefore we have to check for that
if (config) {
config->setName(tr("default"));
config->setProvisionalName(tr("default"));
m_configurations.append(config);
}
}
qs->endGroup();
// if (configs.count() == 0) {
// IUAVGadgetConfiguration *config = f->createConfiguration(0, 0);
//// it is not mandatory for uavgadgets to have any configurations (settings)
//// and therefore we have to check for that
// if (config) {
// config->setName(tr("default"));
// config->setProvisionalName(tr("default"));
// m_configurations.append(config);
// }
// }
settings.endGroup();
}
}
void UAVGadgetInstanceManager::readConfigs_1_1_0(QSettings *qs)
void UAVGadgetInstanceManager::readConfigs_1_1_0(QSettings &settings)
{
UAVConfigInfo configInfo;
foreach(QString classId, m_classIdNameMap.keys()) {
IUAVGadgetFactory *f = factory(classId);
qs->beginGroup(classId);
settings.beginGroup(classId);
QStringList configs = QStringList();
configs = qs->childGroups();
configs = settings.childGroups();
foreach(QString configName, configs) {
// qDebug().nospace() << "Loading config: " << classId << ", " << configName;
qs->beginGroup(configName);
bool locked = qs->value("config.locked").toBool();
settings.beginGroup(configName);
bool locked = settings.value("config.locked").toBool();
configInfo.setNameOfConfigurable(classId + "-" + configName);
IUAVGadgetConfiguration *config = f->createConfiguration(qs, &configInfo);
IUAVGadgetConfiguration *config = f->createConfiguration(settings, &configInfo);
if (config) {
config->setName(configName);
config->setProvisionalName(configName);
@ -183,45 +186,45 @@ void UAVGadgetInstanceManager::readConfigs_1_1_0(QSettings *qs)
m_configurations.append(config);
}
}
qs->endGroup();
settings.endGroup();
}
if (configs.count() == 0) {
IUAVGadgetConfiguration *config = f->createConfiguration(0, 0);
// it is not mandatory for uavgadgets to have any configurations (settings)
// and therefore we have to check for that
if (config) {
config->setName(tr("default"));
config->setProvisionalName(tr("default"));
m_configurations.append(config);
}
}
qs->endGroup();
// if (configs.count() == 0) {
// IUAVGadgetConfiguration *config = f->createConfiguration(0, 0);
//// it is not mandatory for uavgadgets to have any configurations (settings)
//// and therefore we have to check for that
// if (config) {
// config->setName(tr("default"));
// config->setProvisionalName(tr("default"));
// m_configurations.append(config);
// }
// }
settings.endGroup();
}
}
void UAVGadgetInstanceManager::saveSettings(QSettings *qs)
void UAVGadgetInstanceManager::saveSettings(QSettings &settings) const
{
UAVConfigInfo *configInfo;
qs->beginGroup("UAVGadgetConfigurations");
qs->remove(""); // Remove existing configurations
settings.beginGroup("UAVGadgetConfigurations");
settings.remove(""); // Remove existing configurations
configInfo = new UAVConfigInfo(m_versionUAVGadgetConfigurations, "UAVGadgetConfigurations");
configInfo->save(qs);
configInfo->save(settings);
delete configInfo;
foreach(IUAVGadgetConfiguration * config, m_configurations) {
configInfo = new UAVConfigInfo(config);
qs->beginGroup(config->classId());
qs->beginGroup(config->name());
qs->beginGroup("data");
config->saveConfig(qs, configInfo);
qs->endGroup();
configInfo->save(qs);
qs->endGroup();
qs->endGroup();
settings.beginGroup(config->classId());
settings.beginGroup(config->name());
settings.beginGroup("data");
config->saveConfig(settings, configInfo);
settings.endGroup();
configInfo->save(settings);
settings.endGroup();
settings.endGroup();
delete configInfo;
}
qs->endGroup();
settings.endGroup();
}
void UAVGadgetInstanceManager::createOptionsPages()

View File

@ -28,14 +28,15 @@
#ifndef UAVGADGETINSTANCEMANAGER_H
#define UAVGADGETINSTANCEMANAGER_H
#include <QObject>
#include <QSettings>
#include <QtCore/QMap>
#include <QtCore/QStringList>
#include <QIcon>
#include "core_global.h"
#include "uavconfiginfo.h"
#include <QObject>
#include <QSettings>
#include <QMap>
#include <QStringList>
#include <QIcon>
namespace ExtensionSystem {
class PluginManager;
}
@ -58,8 +59,8 @@ public:
explicit UAVGadgetInstanceManager(QObject *parent = 0);
~UAVGadgetInstanceManager();
void readSettings(QSettings *qs);
void saveSettings(QSettings *qs);
void readSettings(QSettings &settings);
void saveSettings(QSettings &settings) const;
IUAVGadget *createGadget(QString classId, QWidget *parent, bool loadDefaultConfiguration = true);
void removeGadget(IUAVGadget *gadget);
@ -116,8 +117,8 @@ private:
int indexForConfig(QList<IUAVGadgetConfiguration *> configurations, QString classId, QString configName);
void readConfigs_1_1_0(QSettings *qs);
void readConfigs_1_2_0(QSettings *qs);
void readConfigs_1_1_0(QSettings &settings);
void readConfigs_1_2_0(QSettings &settings);
};
} // namespace Core

View File

@ -32,7 +32,9 @@
#include "iuavgadget.h"
#include "minisplitter.h"
#include <QtCore/QDebug>
#include <QStackedLayout>
#include <QSettings>
#include <QDebug>
#ifdef Q_WS_MAC
#include <qmacstyle_mac.h>
@ -382,47 +384,47 @@ void SplitterOrView::unsplitAll_helper(UAVGadgetManager *uavGadgetManager, QSpli
}
}
void SplitterOrView::saveState(QSettings *qSettings) const
void SplitterOrView::saveState(QSettings &settings) const
{
if (m_splitter) {
qSettings->setValue("type", "splitter");
qSettings->setValue("splitterOrientation", (qint32)m_splitter->orientation());
settings.setValue("type", "splitter");
settings.setValue("splitterOrientation", (qint32)m_splitter->orientation());
QList<QVariant> sizesQVariant;
foreach(int value, m_sizes) {
sizesQVariant.append(value);
}
qSettings->setValue("splitterSizes", sizesQVariant);
qSettings->beginGroup("side0");
static_cast<SplitterOrView *>(m_splitter->widget(0))->saveState(qSettings);
qSettings->endGroup();
qSettings->beginGroup("side1");
static_cast<SplitterOrView *>(m_splitter->widget(1))->saveState(qSettings);
qSettings->endGroup();
settings.setValue("splitterSizes", sizesQVariant);
settings.beginGroup("side0");
static_cast<SplitterOrView *>(m_splitter->widget(0))->saveState(settings);
settings.endGroup();
settings.beginGroup("side1");
static_cast<SplitterOrView *>(m_splitter->widget(1))->saveState(settings);
settings.endGroup();
} else if (gadget()) {
m_view->saveState(qSettings);
m_view->saveState(settings);
}
}
void SplitterOrView::restoreState(QSettings *qSettings)
void SplitterOrView::restoreState(QSettings &settings)
{
QString mode = qSettings->value("type").toString();
QString mode = settings.value("type").toString();
if (mode == "splitter") {
qint32 orientation = qSettings->value("splitterOrientation").toInt();
QList<QVariant> sizesQVariant = qSettings->value("splitterSizes").toList();
qint32 orientation = settings.value("splitterOrientation").toInt();
QList<QVariant> sizesQVariant = settings.value("splitterSizes").toList();
m_sizes.clear();
foreach(QVariant value, sizesQVariant) {
m_sizes.append(value.toInt());
}
split((Qt::Orientation)orientation);
m_splitter->setSizes(m_sizes);
qSettings->beginGroup("side0");
static_cast<SplitterOrView *>(m_splitter->widget(0))->restoreState(qSettings);
qSettings->endGroup();
qSettings->beginGroup("side1");
static_cast<SplitterOrView *>(m_splitter->widget(1))->restoreState(qSettings);
qSettings->endGroup();
settings.beginGroup("side0");
static_cast<SplitterOrView *>(m_splitter->widget(0))->restoreState(settings);
settings.endGroup();
settings.beginGroup("side1");
static_cast<SplitterOrView *>(m_splitter->widget(1))->restoreState(settings);
settings.endGroup();
} else if (mode == "uavGadget") {
m_view->restoreState(qSettings);
m_view->restoreState(settings);
}
}

View File

@ -29,11 +29,15 @@
#ifndef SPLITTERORVIEW_H
#define SPLITTERORVIEW_H
#include <QWidget>
#include <QMouseEvent>
#include "uavgadgetmanager.h"
#include "uavgadgetview.h"
#include <QWidget>
#include <QMouseEvent>
#include <QSplitter>
class QSettings;
namespace Core {
namespace Internal {
class SplitterOrView : public QWidget {
@ -82,8 +86,8 @@ public:
QSplitter *takeSplitter();
UAVGadgetView *takeView();
void saveState(QSettings *) const;
void restoreState(QSettings *);
void saveState(QSettings &) const;
void restoreState(QSettings &);
SplitterOrView *findView(Core::IUAVGadget *uavGadget);
SplitterOrView *findView(UAVGadgetView *view);

View File

@ -27,6 +27,7 @@
*/
#include "uavgadgetmanager.h"
#include "uavgadgetview.h"
#include "splitterorview.h"
#include "uavgadgetinstancemanager.h"
@ -37,31 +38,17 @@
#include <coreplugin/coreconstants.h>
#include <coreplugin/modemanager.h>
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/baseview.h>
#include <coreplugin/imode.h>
#include <coreplugin/settingsdatabase.h>
#include <coreplugin/variablemanager.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/consoleprocess.h>
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtCore/QMap>
#include <QtCore/QProcess>
#include <QtCore/QSet>
#include <QAction>
#include <QtWidgets/QApplication>
#include <QLayout>
#include <QMainWindow>
#include <QMenu>
#include <QMessageBox>
#include <QPushButton>
#include <QSplitter>
#include <QStackedLayout>
#include <QDebug>
#include <QApplication>
#include <QHBoxLayout>
Q_DECLARE_METATYPE(Core::IUAVGadget *)
@ -291,16 +278,16 @@ void UAVGadgetManager::updateUavGadgetMenus()
emit showUavGadgetMenus(m_showToolbars, hasSplitter);
}
void UAVGadgetManager::saveState(QSettings *qSettings) const
void UAVGadgetManager::saveState(QSettings &settings) const
{
qSettings->setValue("version", "UAVGadgetManagerV1");
qSettings->setValue("showToolbars", m_showToolbars);
qSettings->beginGroup("splitter");
m_splitterOrView->saveState(qSettings);
qSettings->endGroup();
settings.setValue("version", "UAVGadgetManagerV1");
settings.setValue("showToolbars", m_showToolbars);
settings.beginGroup("splitter");
m_splitterOrView->saveState(settings);
settings.endGroup();
}
bool UAVGadgetManager::restoreState(QSettings *qSettings)
bool UAVGadgetManager::restoreState(QSettings &settings)
{
removeAllSplits();
@ -309,59 +296,59 @@ bool UAVGadgetManager::restoreState(QSettings *qSettings)
emptyView(m_splitterOrView->view());
im->removeGadget(gadget);
QString version = qSettings->value("version").toString();
QString version = settings.value("version").toString();
if (version != "UAVGadgetManagerV1") {
return false;
}
m_showToolbars = qSettings->value("showToolbars").toBool();
m_showToolbars = settings.value("showToolbars").toBool();
QApplication::setOverrideCursor(Qt::WaitCursor);
qSettings->beginGroup("splitter");
m_splitterOrView->restoreState(qSettings);
qSettings->endGroup();
settings.beginGroup("splitter");
m_splitterOrView->restoreState(settings);
settings.endGroup();
QApplication::restoreOverrideCursor();
return true;
}
void UAVGadgetManager::saveSettings(QSettings *qs)
void UAVGadgetManager::saveSettings(QSettings &settings) const
{
qs->beginGroup("UAVGadgetManager");
qs->beginGroup(this->uniqueModeName());
settings.beginGroup("UAVGadgetManager");
settings.beginGroup(this->uniqueModeName());
// Make sure the old tree is wiped.
qs->remove("");
settings.remove("");
// Do actual saving
saveState(qs);
saveState(settings);
qs->endGroup();
qs->endGroup();
settings.endGroup();
settings.endGroup();
}
void UAVGadgetManager::readSettings(QSettings *qs)
void UAVGadgetManager::readSettings(QSettings &settings)
{
QString uavGadgetManagerRootKey = "UAVGadgetManager";
if (!qs->childGroups().contains(uavGadgetManagerRootKey)) {
if (!settings.childGroups().contains(uavGadgetManagerRootKey)) {
return;
}
qs->beginGroup(uavGadgetManagerRootKey);
settings.beginGroup(uavGadgetManagerRootKey);
if (!qs->childGroups().contains(uniqueModeName())) {
qs->endGroup();
if (!settings.childGroups().contains(uniqueModeName())) {
settings.endGroup();
return;
}
qs->beginGroup(uniqueModeName());
settings.beginGroup(uniqueModeName());
restoreState(qs);
restoreState(settings);
showToolbars(m_showToolbars);
qs->endGroup();
qs->endGroup();
settings.endGroup();
settings.endGroup();
}
void UAVGadgetManager::split(Qt::Orientation orientation)

View File

@ -35,13 +35,12 @@
#include <coreplugin/imode.h>
#include <QWidget>
#include <QtCore/QList>
#include <QtCore/QPointer>
#include <QtCore/QSettings>
#include <QList>
#include <QIcon>
QT_BEGIN_NAMESPACE
class QModelIndex;
class QSettings;
QT_END_NAMESPACE
namespace Core {
@ -95,11 +94,12 @@ public:
IUAVGadget *currentGadget() const;
void saveState(QSettings *) const;
bool restoreState(QSettings *qSettings);
void saveState(QSettings &) const;
bool restoreState(QSettings &);
void readSettings(QSettings &settings);
void saveSettings(QSettings &settings) const;
void saveSettings(QSettings *qs);
void readSettings(QSettings *qs);
bool toolbarsShown()
{
return m_showToolbars;

View File

@ -261,18 +261,18 @@ void UAVGadgetView::currentGadgetChanged(IUAVGadget *gadget)
m_activeLabel->setVisible(m_uavGadget == gadget);
}
void UAVGadgetView::saveState(QSettings *qSettings)
void UAVGadgetView::saveState(QSettings &settings)
{
qSettings->setValue("type", "uavGadget");
qSettings->setValue("classId", gadget()->classId());
qSettings->beginGroup("gadget");
gadget()->saveState(qSettings);
qSettings->endGroup();
settings.setValue("type", "uavGadget");
settings.setValue("classId", gadget()->classId());
settings.beginGroup("gadget");
gadget()->saveState(settings);
settings.endGroup();
}
void UAVGadgetView::restoreState(QSettings *qSettings)
void UAVGadgetView::restoreState(QSettings &settings)
{
QString classId = qSettings->value("classId").toString();
QString classId = settings.value("classId").toString();
int index = indexOfClassId(classId);
if (index < 0) {
@ -282,11 +282,11 @@ void UAVGadgetView::restoreState(QSettings *qSettings)
IUAVGadget *newGadget;
UAVGadgetInstanceManager *im = ICore::instance()->uavGadgetInstanceManager();
if (qSettings->childGroups().contains("gadget")) {
if (settings.childGroups().contains("gadget")) {
newGadget = im->createGadget(classId, this, false);
qSettings->beginGroup("gadget");
newGadget->restoreState(qSettings);
qSettings->endGroup();
settings.beginGroup("gadget");
newGadget->restoreState(settings);
settings.endGroup();
} else {
newGadget = im->createGadget(classId, this);
}

View File

@ -29,22 +29,17 @@
#ifndef UAVGADGETVIEW_H
#define UAVGADGETVIEW_H
#include <QtCore/QList>
#include <QtCore/QString>
#include <QtCore/QSettings>
#include <QList>
#include <QString>
#include <QWidget>
#include <QAction>
#include <QSplitter>
#include <QVBoxLayout>
#include <QStackedLayout>
#include <QtCore/QPointer>
#include <QPointer>
QT_BEGIN_NAMESPACE
class QComboBox;
class QToolButton;
class QLabel;
class QVBoxLayout;
class QSettings;
QT_END_NAMESPACE
namespace Utils {
@ -70,8 +65,8 @@ public:
void showToolbar(bool show);
void saveState(QSettings *qSettings);
void restoreState(QSettings *qSettings);
void saveState(QSettings &settings);
void restoreState(QSettings &settings);
public slots:
void closeView();

View File

@ -26,13 +26,15 @@
*/
#include "workspacesettings.h"
#include <coreplugin/icore.h>
#include <coreplugin/modemanager.h>
#include <coreplugin/uavgadgetmanager/uavgadgetmanager.h>
#include <QtCore/QSettings>
#include "ui_workspacesettings.h"
#include <QSettings>
using namespace Core;
using namespace Core::Internal;
@ -100,62 +102,63 @@ QWidget *WorkspaceSettings::createPage(QWidget *parent)
return w;
}
void WorkspaceSettings::readSettings(QSettings *qs)
void WorkspaceSettings::readSettings(QSettings &settings)
{
m_names.clear();
m_iconNames.clear();
m_modeNames.clear();
qs->beginGroup(QLatin1String("Workspace"));
m_numberOfWorkspaces = qs->value(QLatin1String("NumberOfWorkspaces"), 2).toInt();
settings.beginGroup(QLatin1String("Workspace"));
m_numberOfWorkspaces = settings.value(QLatin1String("NumberOfWorkspaces"), 2).toInt();
m_previousNumberOfWorkspaces = m_numberOfWorkspaces;
for (int i = 1; i <= MAX_WORKSPACES; ++i) {
QString numberString = QString::number(i);
QString defaultName = "Workspace" + numberString;
QString defaultIconName = "Icon" + numberString;
QString name = qs->value(defaultName, defaultName).toString();
QString iconName = qs->value(defaultIconName, ":/core/images/librepilot_logo_64.png").toString();
QString name = settings.value(defaultName, defaultName).toString();
QString iconName = settings.value(defaultIconName, ":/core/images/librepilot_logo_64.png").toString();
m_names.append(name);
m_iconNames.append(iconName);
m_modeNames.append(QString("Mode") + QString::number(i));
}
m_tabBarPlacementIndex = qs->value(QLatin1String("TabBarPlacementIndex"), 1).toInt(); // 1 == "Bottom"
m_allowTabBarMovement = qs->value(QLatin1String("AllowTabBarMovement"), false).toBool();
m_restoreSelectedOnStartup = qs->value(QLatin1String("RestoreSelectedOnStartup"), false).toBool();
m_tabBarPlacementIndex = settings.value(QLatin1String("TabBarPlacementIndex"), 1).toInt(); // 1 == "Bottom"
m_allowTabBarMovement = settings.value(QLatin1String("AllowTabBarMovement"), false).toBool();
m_restoreSelectedOnStartup = settings.value(QLatin1String("RestoreSelectedOnStartup"), false).toBool();
qs->endGroup();
settings.endGroup();
QTabWidget::TabPosition pos = m_tabBarPlacementIndex == 0 ? QTabWidget::North : QTabWidget::South;
emit tabBarSettingsApplied(pos, m_allowTabBarMovement);
}
void WorkspaceSettings::saveSettings(QSettings *qs)
void WorkspaceSettings::saveSettings(QSettings &settings) const
{
qs->beginGroup(QLatin1String("Workspace"));
qs->setValue(QLatin1String("NumberOfWorkspaces"), m_numberOfWorkspaces);
settings.beginGroup(QLatin1String("Workspace"));
settings.setValue(QLatin1String("NumberOfWorkspaces"), m_numberOfWorkspaces);
for (int i = 0; i < MAX_WORKSPACES; ++i) {
QString mode = QString("Mode") + QString::number(i + 1);
int j = m_modeNames.indexOf(mode);
QString numberString = QString::number(i + 1);
QString defaultName = "Workspace" + numberString;
QString defaultIconName = "Icon" + numberString;
qs->setValue(defaultName, m_names.at(j));
qs->setValue(defaultIconName, m_iconNames.at(j));
settings.setValue(defaultName, m_names.at(j));
settings.setValue(defaultIconName, m_iconNames.at(j));
}
qs->setValue(QLatin1String("TabBarPlacementIndex"), m_tabBarPlacementIndex);
qs->setValue(QLatin1String("AllowTabBarMovement"), m_allowTabBarMovement);
qs->setValue(QLatin1String("RestoreSelectedOnStartup"), m_restoreSelectedOnStartup);
qs->endGroup();
settings.setValue(QLatin1String("TabBarPlacementIndex"), m_tabBarPlacementIndex);
settings.setValue(QLatin1String("AllowTabBarMovement"), m_allowTabBarMovement);
settings.setValue(QLatin1String("RestoreSelectedOnStartup"), m_restoreSelectedOnStartup);
settings.endGroup();
}
void WorkspaceSettings::apply()
{
selectWorkspace(m_currentIndex, true);
saveSettings(Core::ICore::instance()->settings());
QSettings settings;
saveSettings(settings);
if (m_numberOfWorkspaces != m_previousNumberOfWorkspaces) {
Core::ICore::instance()->readMainSettings(Core::ICore::instance()->settings(), true);
Core::ICore::instance()->readMainSettings(settings, true);
m_previousNumberOfWorkspaces = m_numberOfWorkspaces;
}

View File

@ -29,8 +29,9 @@
#define WORKSPACESETTINGS_H
#include <coreplugin/dialogs/ioptionspage.h>
#include <QtCore/QObject>
#include <QtCore/QStringList>
#include <QObject>
#include <QStringList>
#include <QTabWidget>
class QSettings;
@ -59,8 +60,8 @@ public:
QWidget *createPage(QWidget *parent);
void apply();
void finish();
void readSettings(QSettings *qs);
void saveSettings(QSettings *qs);
void readSettings(QSettings &settings);
void saveSettings(QSettings &settings) const;
int numberOfWorkspaces() const
{
return m_numberOfWorkspaces;

View File

@ -30,146 +30,125 @@
#include "utils/pathutils.h"
/**
* Loads a saved configuration or defaults if non exist.
* Loads a saved configuration.
*
*/
DialGadgetConfiguration::DialGadgetConfiguration(QString classId, QSettings *qSettings, QObject *parent) :
IUAVGadgetConfiguration(classId, parent),
m_defaultDial("Unknown"),
dialBackgroundID("background"),
dialForegroundID("foreground"),
dialNeedleID1("needle"),
dialNeedleID2("needle2"),
dialNeedleID3("needle3"),
needle1MinValue(0),
needle1MaxValue(100),
needle2MinValue(0),
needle2MaxValue(100),
needle3MinValue(0),
needle3MaxValue(100),
needle1Factor(1),
needle2Factor(1),
needle3Factor(1),
needle1Move("Rotate"),
needle2Move("Rotate"),
needle3Move("Rotate"),
useOpenGLFlag(false),
beSmooth(true)
DialGadgetConfiguration::DialGadgetConfiguration(QString classId, QSettings &settings, QObject *parent) :
IUAVGadgetConfiguration(classId, parent)
{
// if a saved configuration exists load it
if (qSettings != 0) {
QString dialFile = qSettings->value("dialFile").toString();
QString dialFile = settings.value("dialFile", "Unknown").toString();
m_defaultDial = Utils::InsertDataPath(dialFile);
dialBackgroundID = qSettings->value("dialBackgroundID").toString();
dialForegroundID = qSettings->value("dialForegroundID").toString();
dialNeedleID1 = qSettings->value("dialNeedleID1").toString();
dialNeedleID2 = qSettings->value("dialNeedleID2").toString();
dialNeedleID3 = qSettings->value("dialNeedleID3").toString();
needle1MinValue = qSettings->value("needle1MinValue").toDouble();
needle1MaxValue = qSettings->value("needle1MaxValue").toDouble();
needle2MinValue = qSettings->value("needle2MinValue").toDouble();
needle2MaxValue = qSettings->value("needle2MaxValue").toDouble();
needle3MinValue = qSettings->value("needle3MinValue").toDouble();
needle3MaxValue = qSettings->value("needle3MaxValue").toDouble();
needle1DataObject = qSettings->value("needle1DataObject").toString();
needle1ObjectField = qSettings->value("needle1ObjectField").toString();
needle2DataObject = qSettings->value("needle2DataObject").toString();
needle2ObjectField = qSettings->value("needle2ObjectField").toString();
needle3DataObject = qSettings->value("needle3DataObject").toString();
needle3ObjectField = qSettings->value("needle3ObjectField").toString();
needle1Factor = qSettings->value("needle1Factor").toDouble();
needle2Factor = qSettings->value("needle2Factor").toDouble();
needle3Factor = qSettings->value("needle3Factor").toDouble();
needle1Move = qSettings->value("needle1Move").toString();
needle2Move = qSettings->value("needle2Move").toString();
needle3Move = qSettings->value("needle3Move").toString();
font = qSettings->value("font").toString();
useOpenGLFlag = qSettings->value("useOpenGLFlag").toBool();
beSmooth = qSettings->value("beSmooth").toBool();
}
m_defaultDial = Utils::InsertDataPath(dialFile);
dialBackgroundID = settings.value("dialBackgroundID", "background").toString();
dialForegroundID = settings.value("dialForegroundID", "foreground").toString();
dialNeedleID1 = settings.value("dialNeedleID1", "needle").toString();
dialNeedleID2 = settings.value("dialNeedleID2", "needle2").toString();
dialNeedleID3 = settings.value("dialNeedleID3", "needle3").toString();
needle1MinValue = settings.value("needle1MinValue", 0).toDouble();
needle1MaxValue = settings.value("needle1MaxValue", 100).toDouble();
needle2MinValue = settings.value("needle2MinValue", 0).toDouble();
needle2MaxValue = settings.value("needle2MaxValue", 100).toDouble();
needle3MinValue = settings.value("needle3MinValue", 0).toDouble();
needle3MaxValue = settings.value("needle3MaxValue", 100).toDouble();
needle1DataObject = settings.value("needle1DataObject").toString();
needle1ObjectField = settings.value("needle1ObjectField").toString();
needle2DataObject = settings.value("needle2DataObject").toString();
needle2ObjectField = settings.value("needle2ObjectField").toString();
needle3DataObject = settings.value("needle3DataObject").toString();
needle3ObjectField = settings.value("needle3ObjectField").toString();
needle1Factor = settings.value("needle1Factor", 1).toDouble();
needle2Factor = settings.value("needle2Factor", 1).toDouble();
needle3Factor = settings.value("needle3Factor", 1).toDouble();
needle1Move = settings.value("needle1Move", "Rotate").toString();
needle2Move = settings.value("needle2Move", "Rotate").toString();
needle3Move = settings.value("needle3Move", "Rotate").toString();
font = settings.value("font").toString();
useOpenGLFlag = settings.value("useOpenGLFlag", false).toBool();
beSmooth = settings.value("beSmooth", true).toBool();
}
DialGadgetConfiguration::DialGadgetConfiguration(const DialGadgetConfiguration &obj) :
IUAVGadgetConfiguration(obj.classId(), obj.parent())
{
m_defaultDial = obj.m_defaultDial;
dialBackgroundID = obj.dialBackgroundID;
dialForegroundID = obj.dialForegroundID;
dialNeedleID1 = obj.dialNeedleID1;
dialNeedleID2 = obj.dialNeedleID2;
dialNeedleID3 = obj.dialNeedleID3;
needle1MinValue = obj.needle1MinValue;
needle1MaxValue = obj.needle1MaxValue;
needle2MinValue = obj.needle2MinValue;
needle2MaxValue = obj.needle2MaxValue;
needle3MinValue = obj.needle3MinValue;
needle3MaxValue = obj.needle3MaxValue;
needle1DataObject = obj.needle1DataObject;
needle1ObjectField = obj.needle1ObjectField;
needle2DataObject = obj.needle2DataObject;
needle2ObjectField = obj.needle2ObjectField;
needle3DataObject = obj.needle3DataObject;
needle3ObjectField = obj.needle3ObjectField;
needle1Factor = obj.needle1Factor;
needle2Factor = obj.needle2Factor;
needle3Factor = obj.needle3Factor;
needle1Move = obj.needle1Move;
needle2Move = obj.needle2Move;
needle3Move = obj.needle3Move;
font = obj.font;
useOpenGLFlag = obj.useOpenGLFlag;
beSmooth = obj.beSmooth;
}
/**
* Clones a configuration.
*
*/
IUAVGadgetConfiguration *DialGadgetConfiguration::clone()
IUAVGadgetConfiguration *DialGadgetConfiguration::clone() const
{
DialGadgetConfiguration *m = new DialGadgetConfiguration(this->classId());
m->m_defaultDial = m_defaultDial;
m->setDialBackgroundID(dialBackgroundID);
m->setDialForegroundID(dialForegroundID);
m->setDialNeedleID1(dialNeedleID1);
m->setDialNeedleID2(dialNeedleID2);
m->setDialNeedleID3(dialNeedleID3);
m->setN1Min(needle1MinValue);
m->setN1Max(needle1MaxValue);
m->setN2Min(needle2MinValue);
m->setN2Max(needle2MaxValue);
m->setN3Min(needle3MinValue);
m->setN3Max(needle3MaxValue);
m->setN1DataObject(needle1DataObject);
m->setN1ObjField(needle1ObjectField);
m->setN2DataObject(needle2DataObject);
m->setN2ObjField(needle2ObjectField);
m->setN3DataObject(needle3DataObject);
m->setN3ObjField(needle3ObjectField);
m->setN1Factor(needle1Factor);
m->setN2Factor(needle2Factor);
m->setN3Factor(needle3Factor);
m->setN1Move(needle1Move);
m->setN2Move(needle2Move);
m->setN3Move(needle3Move);
m->setFont(font);
m->useOpenGLFlag = useOpenGLFlag;
m->beSmooth = beSmooth;
return m;
return new DialGadgetConfiguration(*this);
}
/**
* Saves a configuration.
*
*/
void DialGadgetConfiguration::saveConfig(QSettings *settings) const
void DialGadgetConfiguration::saveConfig(QSettings &settings) const
{
QString dialFile = Utils::RemoveDataPath(m_defaultDial);
settings->setValue("dialFile", dialFile);
settings.setValue("dialFile", dialFile);
settings->setValue("dialBackgroundID", dialBackgroundID);
settings->setValue("dialForegroundID", dialForegroundID);
settings.setValue("dialBackgroundID", dialBackgroundID);
settings.setValue("dialForegroundID", dialForegroundID);
settings->setValue("dialNeedleID1", dialNeedleID1);
settings->setValue("dialNeedleID2", dialNeedleID2);
settings->setValue("dialNeedleID3", dialNeedleID3);
settings.setValue("dialNeedleID1", dialNeedleID1);
settings.setValue("dialNeedleID2", dialNeedleID2);
settings.setValue("dialNeedleID3", dialNeedleID3);
settings->setValue("needle1MinValue", needle1MinValue);
settings->setValue("needle1MaxValue", needle1MaxValue);
settings->setValue("needle2MinValue", needle2MinValue);
settings->setValue("needle2MaxValue", needle2MaxValue);
settings->setValue("needle3MinValue", needle3MinValue);
settings->setValue("needle3MaxValue", needle3MaxValue);
settings.setValue("needle1MinValue", needle1MinValue);
settings.setValue("needle1MaxValue", needle1MaxValue);
settings.setValue("needle2MinValue", needle2MinValue);
settings.setValue("needle2MaxValue", needle2MaxValue);
settings.setValue("needle3MinValue", needle3MinValue);
settings.setValue("needle3MaxValue", needle3MaxValue);
settings->setValue("needle1DataObject", needle1DataObject);
settings->setValue("needle1ObjectField", needle1ObjectField);
settings->setValue("needle2DataObject", needle2DataObject);
settings->setValue("needle2ObjectField", needle2ObjectField);
settings->setValue("needle3DataObject", needle3DataObject);
settings->setValue("needle3ObjectField", needle3ObjectField);
settings.setValue("needle1DataObject", needle1DataObject);
settings.setValue("needle1ObjectField", needle1ObjectField);
settings.setValue("needle2DataObject", needle2DataObject);
settings.setValue("needle2ObjectField", needle2ObjectField);
settings.setValue("needle3DataObject", needle3DataObject);
settings.setValue("needle3ObjectField", needle3ObjectField);
settings->setValue("needle1Factor", needle1Factor);
settings->setValue("needle2Factor", needle2Factor);
settings->setValue("needle3Factor", needle3Factor);
settings.setValue("needle1Factor", needle1Factor);
settings.setValue("needle2Factor", needle2Factor);
settings.setValue("needle3Factor", needle3Factor);
settings->setValue("needle1Move", needle1Move);
settings->setValue("needle2Move", needle2Move);
settings->setValue("needle3Move", needle3Move);
settings.setValue("needle1Move", needle1Move);
settings.setValue("needle2Move", needle2Move);
settings.setValue("needle3Move", needle3Move);
settings->setValue("font", font);
settings.setValue("font", font);
settings->setValue("useOpenGLFlag", useOpenGLFlag);
settings->setValue("beSmooth", beSmooth);
settings.setValue("useOpenGLFlag", useOpenGLFlag);
settings.setValue("beSmooth", beSmooth);
}

View File

@ -39,8 +39,11 @@ using namespace Core;
class DialGadgetConfiguration : public IUAVGadgetConfiguration {
Q_OBJECT
public:
explicit DialGadgetConfiguration(QString classId, QSettings *qSettings = 0, QObject *parent = 0);
explicit DialGadgetConfiguration(QString classId, QSettings &settings, QObject *parent = 0);
explicit DialGadgetConfiguration(const DialGadgetConfiguration &obj);
IUAVGadgetConfiguration *clone() const;
void saveConfig(QSettings &settings) const;
// set dial configuration functions
void setDialFile(QString dialFile)
@ -152,7 +155,6 @@ public:
beSmooth = flag;
}
// get dial configuration functions
QString dialFile()
{
@ -263,9 +265,6 @@ public:
return beSmooth;
}
void saveConfig(QSettings *settings) const;
IUAVGadgetConfiguration *clone();
private:
QString m_defaultDial; // The name of the dial's SVG source file
QString dialBackgroundID; // SVG elementID of the background

View File

@ -48,9 +48,9 @@ Core::IUAVGadget *DialGadgetFactory::createGadget(QWidget *parent)
return new DialGadget(QString("DialGadget"), gadgetWidget, parent);
}
IUAVGadgetConfiguration *DialGadgetFactory::createConfiguration(QSettings *qSettings)
IUAVGadgetConfiguration *DialGadgetFactory::createConfiguration(QSettings &settings)
{
return new DialGadgetConfiguration(QString("DialGadget"), qSettings);
return new DialGadgetConfiguration(QString("DialGadget"), settings);
}
IOptionsPage *DialGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)

View File

@ -45,7 +45,7 @@ public:
~DialGadgetFactory();
Core::IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(QSettings *qSettings);
IUAVGadgetConfiguration *createConfiguration(QSettings &settings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
};

View File

@ -31,39 +31,43 @@
* Loads a saved configuration or defaults if non exist.
*
*/
GCSControlGadgetConfiguration::GCSControlGadgetConfiguration(QString classId, QSettings *qSettings, QObject *parent) :
IUAVGadgetConfiguration(classId, parent),
rollChannel(-1),
pitchChannel(-1),
yawChannel(-1),
throttleChannel(-1)
GCSControlGadgetConfiguration::GCSControlGadgetConfiguration(QString classId, QSettings &settings, QObject *parent) :
IUAVGadgetConfiguration(classId, parent)
{
int i;
controlsMode = settings.value("controlsMode").toInt();
rollChannel = settings.value("rollChannel", -1).toInt();
pitchChannel = settings.value("pitchChannel", -1).toInt();
yawChannel = settings.value("yawChannel", -1).toInt();
throttleChannel = settings.value("throttleChannel", -1).toInt();
for (i = 0; i < 8; i++) {
buttonSettings[i].ActionID = 0;
buttonSettings[i].FunctionID = 0;
buttonSettings[i].Amount = 0;
channelReverse[i] = 0;
udp_port = settings.value("controlPortUDP").toUInt();
udp_host = QHostAddress(settings.value("controlHostUDP").toString());
for (int i = 0; i < 8; i++) {
buttonSettings[i].ActionID = settings.value(QString().sprintf("button%dAction", i)).toInt();
buttonSettings[i].FunctionID = settings.value(QString().sprintf("button%dFunction", i)).toInt();
buttonSettings[i].Amount = settings.value(QString().sprintf("button%dAmount", i)).toDouble();
channelReverse[i] = settings.value(QString().sprintf("channel%dReverse", i)).toBool();
}
// if a saved configuration exists load it
if (qSettings != 0) {
controlsMode = qSettings->value("controlsMode").toInt();
rollChannel = qSettings->value("rollChannel").toInt();
pitchChannel = qSettings->value("pitchChannel").toInt();
yawChannel = qSettings->value("yawChannel").toInt();
throttleChannel = qSettings->value("throttleChannel").toInt();
}
udp_port = qSettings->value("controlPortUDP").toUInt();
udp_host = QHostAddress(qSettings->value("controlHostUDP").toString());
GCSControlGadgetConfiguration::GCSControlGadgetConfiguration(const GCSControlGadgetConfiguration &obj) :
IUAVGadgetConfiguration(obj.classId(), obj.parent())
{
controlsMode = obj.controlsMode;
rollChannel = obj.rollChannel;
pitchChannel = obj.pitchChannel;
yawChannel = obj.yawChannel;
throttleChannel = obj.throttleChannel;
int i;
for (i = 0; i < 8; i++) {
buttonSettings[i].ActionID = qSettings->value(QString().sprintf("button%dAction", i)).toInt();
buttonSettings[i].FunctionID = qSettings->value(QString().sprintf("button%dFunction", i)).toInt();
buttonSettings[i].Amount = qSettings->value(QString().sprintf("button%dAmount", i)).toDouble();
channelReverse[i] = qSettings->value(QString().sprintf("channel%dReverse", i)).toBool();
}
udp_host = obj.udp_host;
udp_port = obj.udp_port;
for (int i = 0; i < 8; i++) {
buttonSettings[i].ActionID = obj.buttonSettings[i].ActionID;
buttonSettings[i].FunctionID = obj.buttonSettings[i].FunctionID;
buttonSettings[i].Amount = obj.buttonSettings[i].Amount;
channelReverse[i] = obj.channelReverse[i];
}
}
@ -77,6 +81,7 @@ int GCSControlGadgetConfiguration::getUDPControlPort()
{
return udp_port;
}
QHostAddress GCSControlGadgetConfiguration::getUDPControlHost()
{
return udp_host;
@ -96,14 +101,13 @@ QList<int> GCSControlGadgetConfiguration::getChannelsMapping()
ql << rollChannel << pitchChannel << yawChannel << throttleChannel;
return ql;
}
QList<bool> GCSControlGadgetConfiguration::getChannelsReverse()
{
QList<bool> ql;
int i;
for (i = 0; i < 8; i++) {
for (int i = 0; i < 8; i++) {
ql << channelReverse[i];
}
return ql;
}
@ -111,51 +115,30 @@ QList<bool> GCSControlGadgetConfiguration::getChannelsReverse()
* Clones a configuration.
*
*/
IUAVGadgetConfiguration *GCSControlGadgetConfiguration::clone()
IUAVGadgetConfiguration *GCSControlGadgetConfiguration::clone() const
{
GCSControlGadgetConfiguration *m = new GCSControlGadgetConfiguration(this->classId());
m->controlsMode = controlsMode;
m->rollChannel = rollChannel;
m->pitchChannel = pitchChannel;
m->yawChannel = yawChannel;
m->throttleChannel = throttleChannel;
m->udp_host = udp_host;
m->udp_port = udp_port;
int i;
for (i = 0; i < 8; i++) {
m->buttonSettings[i].ActionID = buttonSettings[i].ActionID;
m->buttonSettings[i].FunctionID = buttonSettings[i].FunctionID;
m->buttonSettings[i].Amount = buttonSettings[i].Amount;
m->channelReverse[i] = channelReverse[i];
}
return m;
return new GCSControlGadgetConfiguration(*this);
}
/**
* Saves a configuration.
*
*/
void GCSControlGadgetConfiguration::saveConfig(QSettings *settings) const
void GCSControlGadgetConfiguration::saveConfig(QSettings &settings) const
{
settings->setValue("controlsMode", controlsMode);
settings->setValue("rollChannel", rollChannel);
settings->setValue("pitchChannel", pitchChannel);
settings->setValue("yawChannel", yawChannel);
settings->setValue("throttleChannel", throttleChannel);
settings.setValue("controlsMode", controlsMode);
settings.setValue("rollChannel", rollChannel);
settings.setValue("pitchChannel", pitchChannel);
settings.setValue("yawChannel", yawChannel);
settings.setValue("throttleChannel", throttleChannel);
settings->setValue("controlPortUDP", QString::number(udp_port));
settings->setValue("controlHostUDP", udp_host.toString());
settings.setValue("controlPortUDP", QString::number(udp_port));
settings.setValue("controlHostUDP", udp_host.toString());
int i;
for (i = 0; i < 8; i++) {
settings->setValue(QString().sprintf("button%dAction", i), buttonSettings[i].ActionID);
settings->setValue(QString().sprintf("button%dFunction", i), buttonSettings[i].FunctionID);
settings->setValue(QString().sprintf("button%dAmount", i), buttonSettings[i].Amount);
settings->setValue(QString().sprintf("channel%dReverse", i), channelReverse[i]);
for (int i = 0; i < 8; i++) {
settings.setValue(QString().sprintf("button%dAction", i), buttonSettings[i].ActionID);
settings.setValue(QString().sprintf("button%dFunction", i), buttonSettings[i].FunctionID);
settings.setValue(QString().sprintf("button%dAmount", i), buttonSettings[i].Amount);
settings.setValue(QString().sprintf("channel%dReverse", i), channelReverse[i]);
}
}

View File

@ -29,7 +29,8 @@
#define GCSCONTROLGADGETCONFIGURATION_H
#include <coreplugin/iuavgadgetconfiguration.h>
#include <QtNetwork/QHostAddress>
#include <QHostAddress>
typedef struct {
int ActionID;
@ -42,14 +43,16 @@ typedef struct {
QHostAddress address;
} portSettingsStruct;
using namespace Core;
class GCSControlGadgetConfiguration : public IUAVGadgetConfiguration {
Q_OBJECT
public:
explicit GCSControlGadgetConfiguration(QString classId, QSettings *qSettings = 0, QObject *parent = 0);
explicit GCSControlGadgetConfiguration(QString classId, QSettings &settings, QObject *parent = 0);
explicit GCSControlGadgetConfiguration(const GCSControlGadgetConfiguration &obj);
IUAVGadgetConfiguration *clone() const;
void saveConfig(QSettings &settings) const;
void setControlsMode(int mode)
{
@ -63,8 +66,8 @@ public:
{
return controlsMode;
}
QList<int> getChannelsMapping();
QList<bool> getChannelsReverse();
QList<int> getChannelsMapping();
QList<bool> getChannelsReverse();
buttonSettingsStruct getbuttonSettings(int i)
{
@ -87,10 +90,6 @@ public:
channelReverse[i] = Reverse;
}
void saveConfig(QSettings *settings) const;
IUAVGadgetConfiguration *clone();
private:
int controlsMode; // Mode1 to Mode4
// Joystick mappings for roll/pitch/yaw/throttle:

View File

@ -45,9 +45,9 @@ IUAVGadget *GCSControlGadgetFactory::createGadget(QWidget *parent)
return new GCSControlGadget(QString("GCSControlGadget"), gadgetWidget, parent, this->parent());
}
IUAVGadgetConfiguration *GCSControlGadgetFactory::createConfiguration(QSettings *qSettings)
IUAVGadgetConfiguration *GCSControlGadgetFactory::createConfiguration(QSettings &settings)
{
return new GCSControlGadgetConfiguration(QString("GCSControlGadget"), qSettings);
return new GCSControlGadgetConfiguration(QString("GCSControlGadget"), settings);
}
IOptionsPage *GCSControlGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)

View File

@ -46,7 +46,7 @@ public:
~GCSControlGadgetFactory();
IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(QSettings *qSettings);
IUAVGadgetConfiguration *createConfiguration(QSettings &settings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
};

View File

@ -33,77 +33,52 @@
* Loads a saved configuration or defaults if non exist.
*
*/
GpsDisplayGadgetConfiguration::GpsDisplayGadgetConfiguration(QString classId, QSettings *qSettings, QObject *parent) :
IUAVGadgetConfiguration(classId, parent),
m_connectionMode("Serial"),
m_defaultPort("Unknown"),
m_defaultSpeed(QSerialPort::UnknownBaud),
m_defaultDataBits(QSerialPort::UnknownDataBits),
m_defaultFlow(QSerialPort::UnknownFlowControl),
m_defaultParity(QSerialPort::UnknownParity),
m_defaultStopBits(QSerialPort::UnknownStopBits),
m_defaultTimeOut(5000)
GpsDisplayGadgetConfiguration::GpsDisplayGadgetConfiguration(QString classId, QSettings &settings, QObject *parent) :
IUAVGadgetConfiguration(classId, parent)
{
// if a saved configuration exists load it
if (qSettings != 0) {
QSerialPort::BaudRate speed;
QSerialPort::DataBits databits;
QSerialPort::FlowControl flow;
QSerialPort::Parity parity;
QSerialPort::StopBits stopbits;
m_defaultPort = settings.value("defaultPort", "Unknown").toString();
m_defaultSpeed = (QSerialPort::BaudRate)settings.value("defaultSpeed", QSerialPort::UnknownBaud).toInt();
m_defaultDataBits = (QSerialPort::DataBits)settings.value("defaultDataBits", QSerialPort::UnknownDataBits).toInt();
m_defaultFlow = (QSerialPort::FlowControl)settings.value("defaultFlow", QSerialPort::UnknownFlowControl).toInt();
m_defaultParity = (QSerialPort::Parity)settings.value("defaultParity", QSerialPort::UnknownParity).toInt();
m_defaultStopBits = (QSerialPort::StopBits)settings.value("defaultStopBits", QSerialPort::UnknownStopBits).toInt();
m_connectionMode = settings.value("connectionMode", "Serial").toString();
m_defaultTimeOut = 5000;
}
int ispeed = qSettings->value("defaultSpeed").toInt();
int idatabits = qSettings->value("defaultDataBits").toInt();
int iflow = qSettings->value("defaultFlow").toInt();
int iparity = qSettings->value("defaultParity").toInt();
int istopbits = qSettings->value("defaultStopBits").toInt();
QString port = qSettings->value("defaultPort").toString();
QString conMode = qSettings->value("connectionMode").toString();
databits = (QSerialPort::DataBits)idatabits;
flow = (QSerialPort::FlowControl)iflow;
parity = (QSerialPort::Parity)iparity;
stopbits = (QSerialPort::StopBits)istopbits;
speed = (QSerialPort::BaudRate)ispeed;
m_defaultPort = port;
m_defaultSpeed = speed;
m_defaultDataBits = databits;
m_defaultFlow = flow;
m_defaultParity = parity;
m_defaultStopBits = stopbits;
m_connectionMode = conMode;
}
GpsDisplayGadgetConfiguration::GpsDisplayGadgetConfiguration(const GpsDisplayGadgetConfiguration &obj) :
IUAVGadgetConfiguration(obj.classId(), obj.parent())
{
m_defaultSpeed = obj.m_defaultSpeed;
m_defaultDataBits = obj.m_defaultDataBits;
m_defaultFlow = obj.m_defaultFlow;
m_defaultParity = obj.m_defaultParity;
m_defaultStopBits = obj.m_defaultStopBits;
m_defaultPort = obj.m_defaultPort;
m_connectionMode = obj.m_connectionMode;
m_defaultTimeOut = obj.m_defaultTimeOut;
}
/**
* Clones a configuration.
*
*/
IUAVGadgetConfiguration *GpsDisplayGadgetConfiguration::clone()
IUAVGadgetConfiguration *GpsDisplayGadgetConfiguration::clone() const
{
GpsDisplayGadgetConfiguration *m = new GpsDisplayGadgetConfiguration(this->classId());
m->m_defaultSpeed = m_defaultSpeed;
m->m_defaultDataBits = m_defaultDataBits;
m->m_defaultFlow = m_defaultFlow;
m->m_defaultParity = m_defaultParity;
m->m_defaultStopBits = m_defaultStopBits;
m->m_defaultPort = m_defaultPort;
m->m_connectionMode = m_connectionMode;
return m;
return new GpsDisplayGadgetConfiguration(*this);
}
/**
* Saves a configuration.
*
*/
void GpsDisplayGadgetConfiguration::saveConfig(QSettings *settings) const
void GpsDisplayGadgetConfiguration::saveConfig(QSettings &settings) const
{
settings->setValue("defaultSpeed", m_defaultSpeed);
settings->setValue("defaultDataBits", m_defaultDataBits);
settings->setValue("defaultFlow", m_defaultFlow);
settings->setValue("defaultParity", m_defaultParity);
settings->setValue("defaultStopBits", m_defaultStopBits);
settings->setValue("defaultPort", m_defaultPort);
settings->setValue("connectionMode", m_connectionMode);
settings.setValue("defaultSpeed", m_defaultSpeed);
settings.setValue("defaultDataBits", m_defaultDataBits);
settings.setValue("defaultFlow", m_defaultFlow);
settings.setValue("defaultParity", m_defaultParity);
settings.setValue("defaultStopBits", m_defaultStopBits);
settings.setValue("defaultPort", m_defaultPort);
settings.setValue("connectionMode", m_connectionMode);
}

View File

@ -49,7 +49,11 @@ struct PortSettings {
class GpsDisplayGadgetConfiguration : public IUAVGadgetConfiguration {
Q_OBJECT
public:
explicit GpsDisplayGadgetConfiguration(QString classId, QSettings *qSettings = 0, QObject *parent = 0);
explicit GpsDisplayGadgetConfiguration(QString classId, QSettings &settings, QObject *parent = 0);
explicit GpsDisplayGadgetConfiguration(const GpsDisplayGadgetConfiguration &obj);
IUAVGadgetConfiguration *clone() const;
void saveConfig(QSettings &settings) const;
void setConnectionMode(QString mode)
{
@ -59,7 +63,6 @@ public:
{
return m_connectionMode;
}
// set port configuration functions
void setSpeed(QSerialPort::BaudRate speed)
{
@ -120,9 +123,6 @@ public:
return m_defaultTimeOut;
}
void saveConfig(QSettings *settings) const;
IUAVGadgetConfiguration *clone();
private:
QString m_connectionMode;
QString m_defaultPort;

View File

@ -47,9 +47,9 @@ Core::IUAVGadget *GpsDisplayGadgetFactory::createGadget(QWidget *parent)
return new GpsDisplayGadget(QString("GpsDisplayGadget"), gadgetWidget, parent);
}
IUAVGadgetConfiguration *GpsDisplayGadgetFactory::createConfiguration(QSettings *qSettings)
IUAVGadgetConfiguration *GpsDisplayGadgetFactory::createConfiguration(QSettings &settings)
{
return new GpsDisplayGadgetConfiguration(QString("GpsDisplayGadget"), qSettings);
return new GpsDisplayGadgetConfiguration(QString("GpsDisplayGadget"), settings);
}
IOptionsPage *GpsDisplayGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)

View File

@ -44,7 +44,7 @@ public:
~GpsDisplayGadgetFactory();
Core::IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(QSettings *qSettings);
IUAVGadgetConfiguration *createConfiguration(QSettings &settings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
};

View File

@ -28,9 +28,8 @@
#include "settings.h"
Settings::Settings(QString settingsPath, QObject *parent) :
QObject(parent)
QObject(parent), settings(settingsPath + "/cc_plugin.ini", QSettings::IniFormat)
{
settings = new QSettings(settingsPath + "/cc_plugin.ini", QSettings::IniFormat);
// default settings
sendToHost = "127.0.0.1";
sendToPort = 40100;
@ -51,12 +50,12 @@ Settings::Settings(QString settingsPath, QObject *parent) :
void Settings::read()
{
// network
listenOnHost = settings->value("listen_on_host", listenOnHost).toString();
listenOnPort = settings->value("listen_on_port", listenOnPort).toInt();
sendToHost = settings->value("send_to_host", sendToHost).toString();
sendToPort = settings->value("send_to_port", sendToPort).toInt();
listenOnHost = settings.value("listen_on_host", listenOnHost).toString();
listenOnPort = settings.value("listen_on_port", listenOnPort).toInt();
sendToHost = settings.value("send_to_host", sendToHost).toString();
sendToPort = settings.value("send_to_port", sendToPort).toInt();
QString allChannels = settings->value("all_channels").toString();
QString allChannels = settings.value("all_channels").toString();
QString chan;
int i = 0;
foreach(chan, allChannels.split(" "))
@ -67,31 +66,31 @@ void Settings::read()
QString map = "";
for (quint8 i = 0; i < 10; ++i) {
num = QString::number(i + 1);
map = settings->value("Input/cc_channel_" + num).toString();
map = settings.value("Input/cc_channel_" + num).toString();
inputMap[i] = channels.value(map, inputMap.at(i));
}
QString sendTo = settings->value("Input/send_to", "RX").toString();
QString sendTo = settings.value("Input/send_to", "RX").toString();
sendToRX = (sendTo == "RX") ? true : false;
// outputs
for (quint8 i = 0; i < 8; ++i) {
num = QString::number(i + 1);
map = settings->value("Output/sim_channel_" + num).toString();
map = settings.value("Output/sim_channel_" + num).toString();
outputMap[i] = channels.value(map, outputMap.at(i));
}
QString takeFrom = settings->value("Output/take_from", "TX").toString();
QString takeFrom = settings.value("Output/take_from", "TX").toString();
takeFromTX = (takeFrom == "TX") ? true : false;
// video
quint8 resolutionNum = settings->value("Video/number_of_resolutions", 0).toInt();
quint8 resolutionNum = settings.value("Video/number_of_resolutions", 0).toInt();
if (resolutionNum > 0) {
videoModes.clear();
videoModes << resolutionNum;
for (quint8 i = 0; i < resolutionNum; ++i) {
num = QString::number(i + 1);
QString modes = settings->value("Video/resolution_" + num, "0, 0, 640, 480").toString();
QString modes = settings.value("Video/resolution_" + num, "0, 0, 640, 480").toString();
QString mode;
foreach(mode, modes.split(" "))
videoModes << mode.toInt();

View File

@ -77,8 +77,9 @@ public:
}
private:
QSettings settings;
QHash<QString, quint8> channels;
QSettings *settings;
QString sendToHost;
quint16 sendToPort;
QString listenOnHost;

View File

@ -27,136 +27,138 @@
#include "hitlconfiguration.h"
HITLConfiguration::HITLConfiguration(QString classId, QSettings *qSettings, QObject *parent) :
// Default settings values
#define DFLT_SIMULATOR_ID ""
#define DFLT_BIN_PATH ""
#define DFLT_DATA_PATH ""
#define DFLT_START_SIM false
#define DFLT_addNoise false
#define DFLT_ADD_NOISE false
#define DFLT_HOST_ADDRESS "127.0.0.1"
#define DFLT_REMOTE_ADDRESS "127.0.0.1"
#define DFLT_OUT_PORT 0
#define DFLT_IN_PORT 0
#define DFLT_LATITUDE ""
#define DFLT_LONGITUDE ""
#define DFLT_ATT_RAW_ENABLED false
#define DFLT_ATT_RAW_RATE 20
#define DFLT_ATT_STATE_ENABLED true
#define DFLT_ATT_ACT_HW false
#define DFLT_ATT_ACT_SIM true
#define DFLT_ATT_ACT_CALC false
#define DFLT_BARO_SENSOR_ENABLED false
#define DFLT_BARO_ALT_RATE 0
#define DFLT_GPS_POSITION_ENABLED false
#define DFLT_GPS_POS_RATE 100
#define DFLT_GROUND_TRUTH_ENABLED false
#define DFLT_GROUND_TRUTH_RATE 100
#define DFLT_INPUT_COMMAND false
#define DFLT_GCS_RECEIVER_ENABLED false
#define DFLT_MANUAL_CONTROL_ENABLED false
#define DFLT_MIN_INPUT_PERIOD 100
#define DFLT_AIRSPEED_STATE_ENABLED false
#define DFLT_AIRSPEED_STATE_RATE 100
HITLConfiguration::HITLConfiguration(QString classId, QSettings &settings, QObject *parent) :
IUAVGadgetConfiguration(classId, parent)
{
// Default settings values
settings.simulatorId = "";
settings.binPath = "";
settings.dataPath = "";
settings.manualControlEnabled = true;
settings.startSim = false;
settings.addNoise = false;
settings.hostAddress = "127.0.0.1";
settings.remoteAddress = "127.0.0.1";
settings.outPort = 0;
settings.inPort = 0;
settings.latitude = "";
settings.longitude = "";
simSettings.simulatorId = settings.value("simulatorId", DFLT_SIMULATOR_ID).toString();
simSettings.binPath = settings.value("binPath", DFLT_BIN_PATH).toString();
simSettings.dataPath = settings.value("dataPath", DFLT_DATA_PATH).toString();
settings.attRawEnabled = false;
settings.attRawRate = 20;
simSettings.hostAddress = settings.value("hostAddress", DFLT_HOST_ADDRESS).toString();
simSettings.remoteAddress = settings.value("remoteAddress", DFLT_REMOTE_ADDRESS).toString();
simSettings.outPort = settings.value("outPort", DFLT_OUT_PORT).toInt();
simSettings.inPort = settings.value("inPort", DFLT_IN_PORT).toInt();
settings.attStateEnabled = true;
settings.attActHW = false;
settings.attActSim = true;
settings.attActCalc = false;
simSettings.latitude = settings.value("latitude", DFLT_LATITUDE).toString();
simSettings.longitude = settings.value("longitude", DFLT_LONGITUDE).toString();
simSettings.startSim = settings.value("startSim", DFLT_START_SIM).toBool();
simSettings.addNoise = settings.value("noiseCheckBox", DFLT_ADD_NOISE).toBool();
settings.gpsPositionEnabled = false;
settings.gpsPosRate = 100;
simSettings.gcsReceiverEnabled = settings.value("gcsReceiverEnabled", DFLT_GCS_RECEIVER_ENABLED).toBool();
simSettings.manualControlEnabled = settings.value("manualControlEnabled", DFLT_MANUAL_CONTROL_ENABLED).toBool();
settings.groundTruthEnabled = false;
settings.groundTruthRate = 100;
simSettings.attRawEnabled = settings.value("attRawEnabled", DFLT_ATT_RAW_ENABLED).toBool();
simSettings.attRawRate = settings.value("attRawRate", DFLT_ATT_RAW_RATE).toInt();
settings.inputCommand = false;
settings.gcsReceiverEnabled = false;
settings.manualControlEnabled = false;
settings.minOutputPeriod = 100;
simSettings.attStateEnabled = settings.value("attStateEnabled", DFLT_ATT_STATE_ENABLED).toBool();
simSettings.attActHW = settings.value("attActHW", DFLT_ATT_ACT_HW).toBool();
simSettings.attActSim = settings.value("attActSim", DFLT_ATT_ACT_SIM).toBool();
simSettings.attActCalc = settings.value("attActCalc", DFLT_ATT_ACT_CALC).toBool();
settings.airspeedStateEnabled = false;
settings.airspeedStateRate = 100;
simSettings.baroSensorEnabled = settings.value("baroSensorEnabled", DFLT_BARO_SENSOR_ENABLED).toBool();
simSettings.baroAltRate = settings.value("baroAltRate", DFLT_BARO_ALT_RATE).toInt();
simSettings.gpsPositionEnabled = settings.value("gpsPositionEnabled", DFLT_GPS_POSITION_ENABLED).toBool();
simSettings.gpsPosRate = settings.value("gpsPosRate", DFLT_GPS_POS_RATE).toInt();
// if a saved configuration exists load it, and overwrite defaults
if (qSettings != 0) {
settings.simulatorId = qSettings->value("simulatorId").toString();
settings.binPath = qSettings->value("binPath").toString();
settings.dataPath = qSettings->value("dataPath").toString();
simSettings.groundTruthEnabled = settings.value("groundTruthEnabled", DFLT_GROUND_TRUTH_ENABLED).toBool();
simSettings.groundTruthRate = settings.value("groundTruthRate", DFLT_GROUND_TRUTH_RATE).toInt();
settings.hostAddress = qSettings->value("hostAddress").toString();
settings.remoteAddress = qSettings->value("remoteAddress").toString();
settings.outPort = qSettings->value("outPort").toInt();
settings.inPort = qSettings->value("inPort").toInt();
simSettings.inputCommand = settings.value("inputCommand", DFLT_INPUT_COMMAND).toBool();
simSettings.minOutputPeriod = settings.value("minOutputPeriod", DFLT_MIN_INPUT_PERIOD).toInt();
settings.latitude = qSettings->value("latitude").toString();
settings.longitude = qSettings->value("longitude").toString();
settings.startSim = qSettings->value("startSim").toBool();
settings.addNoise = qSettings->value("noiseCheckBox").toBool();
settings.gcsReceiverEnabled = qSettings->value("gcsReceiverEnabled").toBool();
settings.manualControlEnabled = qSettings->value("manualControlEnabled").toBool();
settings.attRawEnabled = qSettings->value("attRawEnabled").toBool();
settings.attRawRate = qSettings->value("attRawRate").toInt();
settings.attStateEnabled = qSettings->value("attStateEnabled").toBool();
settings.attActHW = qSettings->value("attActHW").toBool();
settings.attActSim = qSettings->value("attActSim").toBool();
settings.attActCalc = qSettings->value("attActCalc").toBool();
settings.baroSensorEnabled = qSettings->value("baroSensorEnabled").toBool();
settings.baroAltRate = qSettings->value("baroAltRate").toInt();
settings.gpsPositionEnabled = qSettings->value("gpsPositionEnabled").toBool();
settings.gpsPosRate = qSettings->value("gpsPosRate").toInt();
settings.groundTruthEnabled = qSettings->value("groundTruthEnabled").toBool();
settings.groundTruthRate = qSettings->value("groundTruthRate").toInt();
settings.inputCommand = qSettings->value("inputCommand").toBool();
settings.minOutputPeriod = qSettings->value("minOutputPeriod").toInt();
settings.airspeedStateEnabled = qSettings->value("airspeedStateEnabled").toBool();
settings.airspeedStateRate = qSettings->value("airspeedStateRate").toInt();
}
simSettings.airspeedStateEnabled = settings.value("airspeedStateEnabled", DFLT_AIRSPEED_STATE_ENABLED).toBool();
simSettings.airspeedStateRate = settings.value("airspeedStateRate", DFLT_AIRSPEED_STATE_RATE).toInt();
}
IUAVGadgetConfiguration *HITLConfiguration::clone()
HITLConfiguration::HITLConfiguration(const HITLConfiguration &obj) :
IUAVGadgetConfiguration(obj.classId(), obj.parent())
{
HITLConfiguration *m = new HITLConfiguration(this->classId());
simSettings = obj.simSettings;
}
m->settings = settings;
return m;
IUAVGadgetConfiguration *HITLConfiguration::clone() const
{
return new HITLConfiguration(*this);
}
/**
* Saves a configuration.
*
*/
void HITLConfiguration::saveConfig(QSettings *qSettings) const
void HITLConfiguration::saveConfig(QSettings &settings) const
{
qSettings->setValue("simulatorId", settings.simulatorId);
qSettings->setValue("binPath", settings.binPath);
qSettings->setValue("dataPath", settings.dataPath);
settings.setValue("simulatorId", simSettings.simulatorId);
settings.setValue("binPath", simSettings.binPath);
settings.setValue("dataPath", simSettings.dataPath);
qSettings->setValue("hostAddress", settings.hostAddress);
qSettings->setValue("remoteAddress", settings.remoteAddress);
qSettings->setValue("outPort", settings.outPort);
qSettings->setValue("inPort", settings.inPort);
settings.setValue("hostAddress", simSettings.hostAddress);
settings.setValue("remoteAddress", simSettings.remoteAddress);
settings.setValue("outPort", simSettings.outPort);
settings.setValue("inPort", simSettings.inPort);
qSettings->setValue("latitude", settings.latitude);
qSettings->setValue("longitude", settings.longitude);
qSettings->setValue("addNoise", settings.addNoise);
qSettings->setValue("startSim", settings.startSim);
settings.setValue("latitude", simSettings.latitude);
settings.setValue("longitude", simSettings.longitude);
settings.setValue("addNoise", simSettings.addNoise);
settings.setValue("startSim", simSettings.startSim);
qSettings->setValue("gcsReceiverEnabled", settings.gcsReceiverEnabled);
qSettings->setValue("manualControlEnabled", settings.manualControlEnabled);
settings.setValue("gcsReceiverEnabled", simSettings.gcsReceiverEnabled);
settings.setValue("manualControlEnabled", simSettings.manualControlEnabled);
qSettings->setValue("attRawEnabled", settings.attRawEnabled);
qSettings->setValue("attRawRate", settings.attRawRate);
qSettings->setValue("attStateEnabled", settings.attStateEnabled);
qSettings->setValue("attActHW", settings.attActHW);
qSettings->setValue("attActSim", settings.attActSim);
qSettings->setValue("attActCalc", settings.attActCalc);
qSettings->setValue("baroSensorEnabled", settings.baroSensorEnabled);
qSettings->setValue("baroAltRate", settings.baroAltRate);
qSettings->setValue("gpsPositionEnabled", settings.gpsPositionEnabled);
qSettings->setValue("gpsPosRate", settings.gpsPosRate);
qSettings->setValue("groundTruthEnabled", settings.groundTruthEnabled);
qSettings->setValue("groundTruthRate", settings.groundTruthRate);
qSettings->setValue("inputCommand", settings.inputCommand);
qSettings->setValue("minOutputPeriod", settings.minOutputPeriod);
settings.setValue("attRawEnabled", simSettings.attRawEnabled);
settings.setValue("attRawRate", simSettings.attRawRate);
settings.setValue("attStateEnabled", simSettings.attStateEnabled);
settings.setValue("attActHW", simSettings.attActHW);
settings.setValue("attActSim", simSettings.attActSim);
settings.setValue("attActCalc", simSettings.attActCalc);
settings.setValue("baroSensorEnabled", simSettings.baroSensorEnabled);
settings.setValue("baroAltRate", simSettings.baroAltRate);
settings.setValue("gpsPositionEnabled", simSettings.gpsPositionEnabled);
settings.setValue("gpsPosRate", simSettings.gpsPosRate);
settings.setValue("groundTruthEnabled", simSettings.groundTruthEnabled);
settings.setValue("groundTruthRate", simSettings.groundTruthRate);
settings.setValue("inputCommand", simSettings.inputCommand);
settings.setValue("minOutputPeriod", simSettings.minOutputPeriod);
qSettings->setValue("airspeedStateEnabled", settings.airspeedStateEnabled);
qSettings->setValue("airspeedStateRate", settings.airspeedStateRate);
settings.setValue("airspeedStateEnabled", simSettings.airspeedStateEnabled);
settings.setValue("airspeedStateRate", simSettings.airspeedStateRate);
}

View File

@ -29,7 +29,6 @@
#define HITLCONFIGURATION_H
#include <coreplugin/iuavgadgetconfiguration.h>
#include <QColor>
#include <QString>
#include <simulator.h>
@ -40,25 +39,26 @@ class HITLConfiguration : public IUAVGadgetConfiguration {
Q_OBJECT Q_PROPERTY(SimulatorSettings settings READ Settings WRITE setSimulatorSettings)
public:
explicit HITLConfiguration(QString classId, QSettings *qSettings = 0, QObject *parent = 0);
explicit HITLConfiguration(QString classId, QSettings &settings, QObject *parent = 0);
explicit HITLConfiguration(const HITLConfiguration &obj);
void saveConfig(QSettings *settings) const;
IUAVGadgetConfiguration *clone();
IUAVGadgetConfiguration *clone() const;
void saveConfig(QSettings &settings) const;
SimulatorSettings Settings() const
{
return settings;
return simSettings;
}
public slots:
void setSimulatorSettings(const SimulatorSettings & params)
{
settings = params;
simSettings = params;
}
private:
SimulatorSettings settings;
SimulatorSettings simSettings;
};
#endif // HITLCONFIGURATION_H

View File

@ -45,9 +45,9 @@ Core::IUAVGadget *HITLFactory::createGadget(QWidget *parent)
return new HITLGadget(QString("HITL"), gadgetWidget, parent);
}
IUAVGadgetConfiguration *HITLFactory::createConfiguration(QSettings *qSettings)
IUAVGadgetConfiguration *HITLFactory::createConfiguration(QSettings &settings)
{
return new HITLConfiguration(QString("HITL"), qSettings);
return new HITLConfiguration(QString("HITL"), settings);
}
IOptionsPage *HITLFactory::createOptionsPage(IUAVGadgetConfiguration *config)

View File

@ -44,7 +44,7 @@ public:
~HITLFactory();
IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(QSettings *qSettings);
IUAVGadgetConfiguration *createConfiguration(QSettings &settings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
};

View File

@ -28,13 +28,15 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "importexportgadgetwidget.h"
#include "ui_importexportgadgetwidget.h"
#include "utils/xmlconfig.h"
#include "coreplugin/uavgadgetinstancemanager.h"
#include "coreplugin/icore.h"
#include <extensionsystem/pluginmanager.h>
#include <extensionsystem/pluginspec.h>
#include <QtDebug>
#include <QDebug>
#include <QSettings>
#include <QMessageBox>
#include <QFileInfo>
@ -125,17 +127,17 @@ void ImportExportGadgetWidget::exportConfiguration(const QString & fileName)
bool doAllGadgets = ui->checkBoxAllGadgets->isChecked();
bool doPlugins = ui->checkBoxPlugins->isChecked();
QSettings qs(fileName, XmlConfig::XmlFormat);
QSettings settings(fileName, XmlConfig::XmlFormat);
if (doGeneral) {
Core::ICore::instance()->saveMainSettings(&qs);
Core::ICore::instance()->saveMainSettings(settings);
}
if (doAllGadgets) {
Core::ICore::instance()->uavGadgetInstanceManager()->saveSettings(&qs);
Core::ICore::instance()->uavGadgetInstanceManager()->saveSettings(settings);
}
if (doPlugins) {
foreach(Core::IConfigurablePlugin * plugin, getConfigurables()) {
Core::ICore::instance()->saveSettings(plugin, &qs);
Core::ICore::instance()->saveSettings(plugin, settings);
}
}
@ -183,17 +185,17 @@ void ImportExportGadgetWidget::importConfiguration(const QString & fileName)
bool doAllGadgets = ui->checkBoxAllGadgets->isChecked();
bool doPlugins = ui->checkBoxPlugins->isChecked();
QSettings qs(fileName, XmlConfig::XmlFormat);
QSettings settings(fileName, XmlConfig::XmlFormat);
if (doAllGadgets) {
Core::ICore::instance()->uavGadgetInstanceManager()->readSettings(&qs);
Core::ICore::instance()->uavGadgetInstanceManager()->readSettings(settings);
}
if (doGeneral) {
Core::ICore::instance()->readMainSettings(&qs);
Core::ICore::instance()->readMainSettings(settings);
}
if (doPlugins) {
foreach(Core::IConfigurablePlugin * plugin, getConfigurables()) {
Core::ICore::instance()->readSettings(plugin, &qs);
Core::ICore::instance()->readSettings(plugin, settings);
}
}

View File

@ -26,66 +26,73 @@
*/
#include "ipconnectionconfiguration.h"
#include <coreplugin/icore.h>
IPconnectionConfiguration::IPconnectionConfiguration(QString classId, QSettings *qSettings, QObject *parent) :
IPconnectionConfiguration::IPconnectionConfiguration(QString classId, QObject *parent) :
IUAVGadgetConfiguration(classId, parent),
m_HostName("127.0.0.1"),
m_Port(1000),
m_UseTCP(1)
{
Q_UNUSED(qSettings);
}
settings = Core::ICore::instance()->settings();
IPconnectionConfiguration::IPconnectionConfiguration(const IPconnectionConfiguration &obj) :
IUAVGadgetConfiguration(obj.classId(), obj.parent())
{
m_HostName = obj.m_HostName;
m_Port = obj.m_Port;
m_UseTCP = obj.m_UseTCP;
}
IPconnectionConfiguration::~IPconnectionConfiguration()
{}
IUAVGadgetConfiguration *IPconnectionConfiguration::clone()
IUAVGadgetConfiguration *IPconnectionConfiguration::clone() const
{
IPconnectionConfiguration *m = new IPconnectionConfiguration(this->classId());
m->m_Port = m_Port;
m->m_HostName = m_HostName;
m->m_UseTCP = m_UseTCP;
return m;
return new IPconnectionConfiguration(*this);
}
/**
* Saves a configuration.
*
*/
void IPconnectionConfiguration::saveConfig(QSettings *qSettings) const
void IPconnectionConfiguration::saveConfig(QSettings &settings) const
{
qSettings->setValue("port", m_Port);
qSettings->setValue("hostName", m_HostName);
qSettings->setValue("useTCP", m_UseTCP);
settings.setValue("port", m_Port);
settings.setValue("hostName", m_HostName);
settings.setValue("useTCP", m_UseTCP);
}
void IPconnectionConfiguration::savesettings() const
void IPconnectionConfiguration::saveSettings() const
{
settings->beginGroup(QLatin1String("IPconnection"));
QSettings settings;
settings->beginWriteArray("Current");
settings->setArrayIndex(0);
settings->setValue(QLatin1String("HostName"), m_HostName);
settings->setValue(QLatin1String("Port"), m_Port);
settings->setValue(QLatin1String("UseTCP"), m_UseTCP);
settings->endArray();
settings->endGroup();
settings.beginGroup("IPconnection");
settings.beginWriteArray("Current");
settings.setArrayIndex(0);
settings.setValue("HostName", m_HostName);
settings.setValue("Port", m_Port);
settings.setValue("UseTCP", m_UseTCP);
settings.endArray();
settings.endGroup();
}
void IPconnectionConfiguration::restoresettings()
void IPconnectionConfiguration::restoreSettings()
{
settings->beginGroup(QLatin1String("IPconnection"));
QSettings settings;
settings->beginReadArray("Current");
settings->setArrayIndex(0);
m_HostName = (settings->value(QLatin1String("HostName"), tr("")).toString());
m_Port = (settings->value(QLatin1String("Port"), tr("")).toInt());
m_UseTCP = (settings->value(QLatin1String("UseTCP"), tr("")).toInt());
settings->endArray();
settings->endGroup();
settings.beginGroup("IPconnection");
settings.beginReadArray("Current");
settings.setArrayIndex(0);
m_HostName = settings.value("HostName", "").toString();
m_Port = settings.value("Port", 0).toInt();
m_UseTCP = settings.value("UseTCP", 0).toInt();
settings.endArray();
settings.endGroup();
}

View File

@ -29,8 +29,8 @@
#define IPconnectionCONFIGURATION_H
#include <coreplugin/iuavgadgetconfiguration.h>
#include <QtCore/QString>
#include <QtCore/QSettings>
#include <QString>
using namespace Core;
@ -40,15 +40,16 @@ class IPconnectionConfiguration : public IUAVGadgetConfiguration {
Q_PROPERTY(int UseTCP READ UseTCP WRITE setUseTCP)
public:
explicit IPconnectionConfiguration(QString classId, QSettings *qSettings = 0, QObject *parent = 0);
explicit IPconnectionConfiguration(QString classId, QObject *parent = 0);
explicit IPconnectionConfiguration(const IPconnectionConfiguration &obj);
virtual ~IPconnectionConfiguration();
void saveConfig(QSettings *settings) const;
// void savesettings(QSettings* settings) const;
// void restoresettings(QSettings* settings);
void savesettings() const;
void restoresettings();
IUAVGadgetConfiguration *clone();
IUAVGadgetConfiguration *clone() const;
void saveConfig(QSettings &settings) const;
void saveSettings() const;
void restoreSettings();
QString HostName() const
{
@ -63,7 +64,6 @@ public:
return m_UseTCP;
}
public slots:
void setHostName(QString HostName)
{
@ -82,7 +82,6 @@ private:
QString m_HostName;
int m_Port;
int m_UseTCP;
QSettings *settings;
};
#endif // IPconnectionCONFIGURATION_H

View File

@ -42,8 +42,10 @@ IPconnectionOptionsPage::IPconnectionOptionsPage(IPconnectionConfiguration *conf
IOptionsPage(parent),
m_config(config)
{}
IPconnectionOptionsPage::~IPconnectionOptionsPage()
{}
QWidget *IPconnectionOptionsPage::createPage(QWidget *parent)
{
m_page = new Ui::IPconnectionOptionsPage();
@ -63,7 +65,7 @@ void IPconnectionOptionsPage::apply()
m_config->setPort(m_page->Port->value());
m_config->setHostName(m_page->HostName->text());
m_config->setUseTCP(m_page->UseTCP->isChecked() ? 1 : 0);
m_config->savesettings();
m_config->saveSettings();
emit availableDevChanged();
}

View File

@ -121,8 +121,8 @@ IPconnectionConnection::IPconnectionConnection()
{
ipSocket = NULL;
// create all our objects
m_config = new IPconnectionConfiguration("IP Network Telemetry", NULL, this);
m_config->restoresettings();
m_config = new IPconnectionConfiguration("IP Network Telemetry", this);
m_config->restoreSettings();
m_optionspage = new IPconnectionOptionsPage(m_config, this);

View File

@ -80,7 +80,6 @@ private:
QAbstractSocket *ipSocket;
IPconnectionConfiguration *m_config;
IPconnectionOptionsPage *m_optionspage;
// QSettings* settings;
};
class IPconnection_EXPORT IPconnectionPlugin : public ExtensionSystem::IPlugin {

View File

@ -32,92 +32,78 @@
* Loads a saved configuration or defaults if non exist.
*
*/
LineardialGadgetConfiguration::LineardialGadgetConfiguration(QString classId, QSettings *qSettings, QObject *parent) :
IUAVGadgetConfiguration(classId, parent),
dialFile("Unknown"),
sourceDataObject("Unknown"),
sourceObjectField("Unknown"),
minValue(0),
maxValue(100),
redMin(0),
redMax(33),
yellowMin(33),
yellowMax(66),
greenMin(66),
greenMax(100),
factor(1.00),
decimalPlaces(0),
useOpenGLFlag(false)
LineardialGadgetConfiguration::LineardialGadgetConfiguration(QString classId, QSettings &settings, QObject *parent) :
IUAVGadgetConfiguration(classId, parent)
{
// if a saved configuration exists load it
if (qSettings != 0) {
QString dFile = qSettings->value("dFile").toString();
dialFile = Utils::InsertDataPath(dFile);
sourceDataObject = qSettings->value("sourceDataObject").toString();
sourceObjectField = qSettings->value("sourceObjectField").toString();
minValue = qSettings->value("minValue").toDouble();
maxValue = qSettings->value("maxValue").toDouble();
redMin = qSettings->value("redMin").toDouble();
redMax = qSettings->value("redMax").toDouble();
yellowMin = qSettings->value("yellowMin").toDouble();
yellowMax = qSettings->value("yellowMax").toDouble();
greenMin = qSettings->value("greenMin").toDouble();
greenMax = qSettings->value("greenMax").toDouble();
font = qSettings->value("font").toString();
decimalPlaces = qSettings->value("decimalPlaces").toInt();
factor = qSettings->value("factor").toDouble();
useOpenGLFlag = qSettings->value("useOpenGLFlag").toBool();
}
QString dFile = settings.value("dFile").toString();
dialFile = Utils::InsertDataPath(dFile);
sourceDataObject = settings.value("sourceDataObject", "Unknown").toString();
sourceObjectField = settings.value("sourceObjectField", "Unknown").toString();
minValue = settings.value("minValue", 0).toDouble();
maxValue = settings.value("maxValue", 100).toDouble();
redMin = settings.value("redMin", 0).toDouble();
redMax = settings.value("redMax", 33).toDouble();
yellowMin = settings.value("yellowMin", 33).toDouble();
yellowMax = settings.value("yellowMax", 66).toDouble();
greenMin = settings.value("greenMin", 66).toDouble();
greenMax = settings.value("greenMax", 100).toDouble();
font = settings.value("font").toString();
decimalPlaces = settings.value("decimalPlaces", 0).toInt();
factor = settings.value("factor", 1.0).toDouble();
useOpenGLFlag = settings.value("useOpenGLFlag").toBool();
}
LineardialGadgetConfiguration::LineardialGadgetConfiguration(const LineardialGadgetConfiguration &obj) :
IUAVGadgetConfiguration(obj.classId(), obj.parent())
{
dialFile = obj.dialFile;
sourceDataObject = obj.sourceDataObject;
sourceObjectField = obj.sourceObjectField;
minValue = obj.minValue;
maxValue = obj.maxValue;
redMin = obj.redMin;
redMax = obj.redMax;
yellowMin = obj.yellowMin;
yellowMax = obj.yellowMax;
greenMin = obj.greenMin;
greenMax = obj.greenMax;
font = obj.font;
decimalPlaces = obj.decimalPlaces;
factor = obj.factor;
useOpenGLFlag = obj.useOpenGLFlag;
}
/**
* Clones a configuration.
*
*/
IUAVGadgetConfiguration *LineardialGadgetConfiguration::clone()
IUAVGadgetConfiguration *LineardialGadgetConfiguration::clone() const
{
LineardialGadgetConfiguration *m = new LineardialGadgetConfiguration(this->classId());
m->dialFile = dialFile;
m->sourceDataObject = sourceDataObject;
m->sourceObjectField = sourceObjectField;
m->minValue = minValue;
m->maxValue = maxValue;
m->redMin = redMin;
m->redMax = redMax;
m->yellowMin = yellowMin;
m->yellowMax = yellowMax;
m->greenMin = greenMin;
m->greenMax = greenMax;
m->font = font;
m->decimalPlaces = decimalPlaces;
m->factor = factor;
m->useOpenGLFlag = useOpenGLFlag;
return m;
return new LineardialGadgetConfiguration(*this);
}
/**
* Saves a configuration.
*
*/
void LineardialGadgetConfiguration::saveConfig(QSettings *qSettings) const
void LineardialGadgetConfiguration::saveConfig(QSettings &settings) const
{
QString dFile = Utils::RemoveDataPath(dialFile);
qSettings->setValue("dFile", dFile);
qSettings->setValue("sourceDataObject", sourceDataObject);
qSettings->setValue("sourceObjectField", sourceObjectField);
qSettings->setValue("minValue", minValue);
qSettings->setValue("maxValue", maxValue);
qSettings->setValue("redMin", redMin);
qSettings->setValue("redMax", redMax);
qSettings->setValue("yellowMin", yellowMin);
qSettings->setValue("yellowMax", yellowMax);
qSettings->setValue("greenMin", greenMin);
qSettings->setValue("greenMax", greenMax);
qSettings->setValue("font", font);
qSettings->setValue("decimalPlaces", decimalPlaces);
qSettings->setValue("factor", factor);
qSettings->setValue("useOpenGLFlag", useOpenGLFlag);
settings.setValue("dFile", dFile);
settings.setValue("sourceDataObject", sourceDataObject);
settings.setValue("sourceObjectField", sourceObjectField);
settings.setValue("minValue", minValue);
settings.setValue("maxValue", maxValue);
settings.setValue("redMin", redMin);
settings.setValue("redMax", redMax);
settings.setValue("yellowMin", yellowMin);
settings.setValue("yellowMax", yellowMax);
settings.setValue("greenMin", greenMin);
settings.setValue("greenMax", greenMax);
settings.setValue("font", font);
settings.setValue("decimalPlaces", decimalPlaces);
settings.setValue("factor", factor);
settings.setValue("useOpenGLFlag", useOpenGLFlag);
}

View File

@ -38,7 +38,11 @@ using namespace Core;
class LineardialGadgetConfiguration : public IUAVGadgetConfiguration {
Q_OBJECT
public:
explicit LineardialGadgetConfiguration(QString classId, QSettings *qSettings = 0, QObject *parent = 0);
explicit LineardialGadgetConfiguration(QString classId, QSettings &settings, QObject *parent = 0);
explicit LineardialGadgetConfiguration(const LineardialGadgetConfiguration &obj);
IUAVGadgetConfiguration *clone() const;
void saveConfig(QSettings &settings) const;
// set dial configuration functions
void setDialFile(QString filename)
@ -61,12 +65,10 @@ public:
{
redMin = min; redMax = max;
}
void setFont(QString text)
{
font = text;
}
void setFactor(double val)
{
factor = val;
@ -75,7 +77,6 @@ public:
{
decimalPlaces = val;
}
void setSourceDataObject(QString text)
{
sourceDataObject = text;
@ -84,7 +85,6 @@ public:
{
sourceObjectField = text;
}
void setUseOpenGL(bool flag)
{
useOpenGLFlag = flag;
@ -152,9 +152,6 @@ public:
return useOpenGLFlag;
}
void saveConfig(QSettings *settings) const;
IUAVGadgetConfiguration *clone();
private:
// A linear or "bargraph" dial contains:
// * A SVG background file

View File

@ -47,9 +47,9 @@ Core::IUAVGadget *LineardialGadgetFactory::createGadget(QWidget *parent)
return new LineardialGadget(QString("LineardialGadget"), gadgetWidget, parent);
}
IUAVGadgetConfiguration *LineardialGadgetFactory::createConfiguration(QSettings *qSettings)
IUAVGadgetConfiguration *LineardialGadgetFactory::createConfiguration(QSettings &settings)
{
return new LineardialGadgetConfiguration(QString("LineardialGadget"), qSettings);
return new LineardialGadgetConfiguration(QString("LineardialGadget"), settings);
}
IOptionsPage *LineardialGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)

View File

@ -44,7 +44,7 @@ public:
~LineardialGadgetFactory();
Core::IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(QSettings *qSettings);
IUAVGadgetConfiguration *createConfiguration(QSettings &settings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
};

View File

@ -104,42 +104,42 @@ void NotificationItem::copyTo(NotificationItem *that) const
}
void NotificationItem::saveState(QSettings *settings) const
void NotificationItem::saveState(QSettings &settings) const
{
settings->setValue("SoundCollectionPath", Utils::RemoveDataPath(getSoundCollectionPath()));
settings->setValue(QLatin1String("CurrentLanguage"), getCurrentLanguage());
settings->setValue(QLatin1String("ObjectField"), getObjectField());
settings->setValue(QLatin1String("DataObject"), getDataObject());
settings->setValue(QLatin1String("RangeLimit"), getCondition());
settings->setValue(QLatin1String("Value1"), singleValue());
settings->setValue(QLatin1String("Value2"), valueRange2());
settings->setValue(QLatin1String("Sound1"), getSound1());
settings->setValue(QLatin1String("Sound2"), getSound2());
settings->setValue(QLatin1String("Sound3"), getSound3());
settings->setValue(QLatin1String("SayOrder"), getSayOrder());
settings->setValue(QLatin1String("Repeat"), retryValue());
settings->setValue(QLatin1String("ExpireTimeout"), lifetime());
settings->setValue(QLatin1String("Mute"), mute());
settings.setValue("SoundCollectionPath", Utils::RemoveDataPath(getSoundCollectionPath()));
settings.setValue(QLatin1String("CurrentLanguage"), getCurrentLanguage());
settings.setValue(QLatin1String("ObjectField"), getObjectField());
settings.setValue(QLatin1String("DataObject"), getDataObject());
settings.setValue(QLatin1String("RangeLimit"), getCondition());
settings.setValue(QLatin1String("Value1"), singleValue());
settings.setValue(QLatin1String("Value2"), valueRange2());
settings.setValue(QLatin1String("Sound1"), getSound1());
settings.setValue(QLatin1String("Sound2"), getSound2());
settings.setValue(QLatin1String("Sound3"), getSound3());
settings.setValue(QLatin1String("SayOrder"), getSayOrder());
settings.setValue(QLatin1String("Repeat"), retryValue());
settings.setValue(QLatin1String("ExpireTimeout"), lifetime());
settings.setValue(QLatin1String("Mute"), mute());
}
void NotificationItem::restoreState(QSettings *settings)
void NotificationItem::restoreState(QSettings &settings)
{
// settings = Core::ICore::instance()->settings();
setSoundCollectionPath(Utils::InsertDataPath(settings->value(QLatin1String("SoundCollectionPath"), tr("")).toString()));
setCurrentLanguage(settings->value(QLatin1String("CurrentLanguage"), tr("")).toString());
setDataObject(settings->value(QLatin1String("DataObject"), tr("")).toString());
setObjectField(settings->value(QLatin1String("ObjectField"), tr("")).toString());
setCondition(settings->value(QLatin1String("RangeLimit"), tr("")).toInt());
setSound1(settings->value(QLatin1String("Sound1"), tr("")).toString());
setSound2(settings->value(QLatin1String("Sound2"), tr("")).toString());
setSound3(settings->value(QLatin1String("Sound3"), tr("")).toString());
setSayOrder(settings->value(QLatin1String("SayOrder"), tr("")).toInt());
QVariant value = settings->value(QLatin1String("Value1"), tr(""));
setSoundCollectionPath(Utils::InsertDataPath(settings.value(QLatin1String("SoundCollectionPath"), tr("")).toString()));
setCurrentLanguage(settings.value(QLatin1String("CurrentLanguage"), tr("")).toString());
setDataObject(settings.value(QLatin1String("DataObject"), tr("")).toString());
setObjectField(settings.value(QLatin1String("ObjectField"), tr("")).toString());
setCondition(settings.value(QLatin1String("RangeLimit"), tr("")).toInt());
setSound1(settings.value(QLatin1String("Sound1"), tr("")).toString());
setSound2(settings.value(QLatin1String("Sound2"), tr("")).toString());
setSound3(settings.value(QLatin1String("Sound3"), tr("")).toString());
setSayOrder(settings.value(QLatin1String("SayOrder"), tr("")).toInt());
QVariant value = settings.value(QLatin1String("Value1"), tr(""));
setSingleValue(value);
setValueRange2(settings->value(QLatin1String("Value2"), tr("")).toDouble());
setRetryValue(settings->value(QLatin1String("Repeat"), tr("")).toInt());
setLifetime(settings->value(QLatin1String("ExpireTimeout"), tr("")).toInt());
setMute(settings->value(QLatin1String("Mute"), tr("")).toInt());
setValueRange2(settings.value(QLatin1String("Value2"), tr("")).toDouble());
setRetryValue(settings.value(QLatin1String("Repeat"), tr("")).toInt());
setLifetime(settings.value(QLatin1String("ExpireTimeout"), tr("")).toInt());
setMute(settings.value(QLatin1String("Mute"), tr("")).toInt());
}
void NotificationItem::serialize(QDataStream & stream)
@ -149,7 +149,7 @@ void NotificationItem::serialize(QDataStream & stream)
stream << this->_dataObject;
stream << this->_objectField;
stream << this->_condition;
qNotifyDebug() << "getOptionsPageValues seriaize" << _condition;
qNotifyDebug() << "getOptionsPageValues serialize" << _condition;
stream << this->_sound1;
stream << this->_sound2;
stream << this->_sound3;

View File

@ -177,9 +177,8 @@ public:
_mute = value;
}
void saveState(QSettings *settings) const;
void restoreState(QSettings *settings);
void saveState(QSettings &settings) const;
void restoreState(QSettings &settings);
UAVDataObject *getUAVObject(void);
UAVObjectField *getUAVObjectField(void);
@ -208,7 +207,7 @@ public:
* Returns sound caption name, needed to create string representation of notification.
*
* @return success - string == <sound filename>, if sound file exists
* error - string == [missind]<sound filename>, if sound file doesn't exist
* error - string == [missing]<sound filename>, if sound file doesn't exist
*/
QString getSoundCaption(QString fileName);

View File

@ -81,48 +81,48 @@ void SoundNotifyPlugin::extensionsInitialized()
connectNotifications();
}
void SoundNotifyPlugin::saveConfig(QSettings *settings, UAVConfigInfo *configInfo)
void SoundNotifyPlugin::saveConfig(QSettings &settings, UAVConfigInfo *configInfo) const
{
configInfo->setVersion(VERSION);
settings->beginWriteArray("Current");
settings->setArrayIndex(0);
settings.beginWriteArray("Current");
settings.setArrayIndex(0);
currentNotification.saveState(settings);
settings->endArray();
settings.endArray();
settings->beginGroup("listNotifies");
settings->remove("");
settings->endGroup();
settings.beginGroup("listNotifies");
settings.remove("");
settings.endGroup();
settings->beginWriteArray("listNotifies");
settings.beginWriteArray("listNotifies");
for (int i = 0; i < _notificationList.size(); i++) {
settings->setArrayIndex(i);
settings.setArrayIndex(i);
_notificationList.at(i)->saveState(settings);
}
settings->endArray();
settings->setValue(QLatin1String("EnableSound"), enableSound);
settings.endArray();
settings.setValue(QLatin1String("EnableSound"), enableSound);
}
void SoundNotifyPlugin::readConfig(QSettings *settings, UAVConfigInfo * /* configInfo */)
void SoundNotifyPlugin::readConfig(QSettings &settings, UAVConfigInfo * /* configInfo */)
{
// Just for migration to the new format.
// Q_ASSERT(configInfo->version() == UAVConfigVersion());
settings->beginReadArray("Current");
settings->setArrayIndex(0);
settings.beginReadArray("Current");
settings.setArrayIndex(0);
currentNotification.restoreState(settings);
settings->endArray();
settings.endArray();
// read list of notifications from settings
int size = settings->beginReadArray("listNotifies");
int size = settings.beginReadArray("listNotifies");
for (int i = 0; i < size; ++i) {
settings->setArrayIndex(i);
settings.setArrayIndex(i);
NotificationItem *notification = new NotificationItem;
notification->restoreState(settings);
_notificationList.append(notification);
}
settings->endArray();
setEnableSound(settings->value(QLatin1String("EnableSound"), 0).toBool());
settings.endArray();
setEnableSound(settings.value(QLatin1String("EnableSound"), 0).toBool());
}
void SoundNotifyPlugin::onTelemetryManagerAdded(QObject *obj)

View File

@ -56,8 +56,8 @@ public:
void extensionsInitialized();
bool initialize(const QStringList & arguments, QString *errorString);
void readConfig(QSettings *qSettings, Core::UAVConfigInfo *configInfo);
void saveConfig(QSettings *qSettings, Core::UAVConfigInfo *configInfo);
void readConfig(QSettings &settings, Core::UAVConfigInfo *configInfo);
void saveConfig(QSettings &settings, Core::UAVConfigInfo *configInfo) const;
void shutdown();

View File

@ -35,7 +35,6 @@
#include <QFileDialog>
#include <QtAlgorithms>
#include <QStringList>
#include <QtCore/QSettings>
#include <QTableWidget>
#include <QPalette>
#include <QBuffer>

View File

@ -29,112 +29,80 @@
#include "utils/pathutils.h"
#include <QDir>
OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, QSettings *qSettings, QObject *parent) :
IUAVGadgetConfiguration(classId, parent),
m_mapProvider("GoogleHybrid"),
m_defaultZoom(2),
m_defaultLatitude(0),
m_defaultLongitude(0),
m_useOpenGL(false),
m_showTileGridLines(false),
m_accessMode("ServerAndCache"),
m_useMemoryCache(true),
m_cacheLocation(Utils::GetStoragePath() + "mapscache" + QDir::separator()),
m_uavSymbol(QString::fromUtf8(":/uavs/images/mapquad.png")),
m_maxUpdateRate(2000), // ms
m_settings(qSettings),
m_opacity(1),
m_defaultWaypointAltitude(15),
m_defaultWaypointVelocity(2)
OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, QSettings &settings, QObject *parent) :
IUAVGadgetConfiguration(classId, parent)
{
// if a saved configuration exists load it
if (qSettings != 0) {
QString mapProvider = qSettings->value("mapProvider").toString();
int zoom = qSettings->value("defaultZoom").toInt();
double latitude = qSettings->value("defaultLatitude").toDouble();
double longitude = qSettings->value("defaultLongitude").toDouble();
bool useOpenGL = qSettings->value("useOpenGL").toBool();
bool showTileGridLines = qSettings->value("showTileGridLines").toBool();
QString accessMode = qSettings->value("accessMode").toString();
bool useMemoryCache = qSettings->value("useMemoryCache").toBool();
QString cacheLocation = qSettings->value("cacheLocation").toString();
QString uavSymbol = qSettings->value("uavSymbol").toString();
int max_update_rate = qSettings->value("maxUpdateRate").toInt();
m_defaultWaypointAltitude = qSettings->value("defaultWaypointAltitude", 15).toReal();
m_defaultWaypointVelocity = qSettings->value("defaultWaypointVelocity", 2).toReal();
m_opacity = qSettings->value("overlayOpacity", 1).toReal();
m_defaultWaypointAltitude = settings.value("defaultWaypointAltitude", 15).toReal();
m_defaultWaypointVelocity = settings.value("defaultWaypointVelocity", 2).toReal();
m_opacity = settings.value("overlayOpacity", 1).toReal();
if (!mapProvider.isEmpty()) {
m_mapProvider = mapProvider;
}
m_defaultZoom = zoom;
m_defaultLatitude = latitude;
m_defaultLongitude = longitude;
m_useOpenGL = useOpenGL;
m_showTileGridLines = showTileGridLines;
m_uavSymbol = uavSymbol;
m_mapProvider = settings.value("mapProvider", "GoogleHybrid").toString();
m_defaultZoom = settings.value("defaultZoom", 2).toInt();
m_defaultLatitude = settings.value("defaultLatitude").toDouble();
m_defaultLongitude = settings.value("defaultLongitude").toDouble();
m_useOpenGL = settings.value("useOpenGL").toBool();
m_showTileGridLines = settings.value("showTileGridLines").toBool();
m_uavSymbol = settings.value("uavSymbol", QString::fromUtf8(":/uavs/images/mapquad.png")).toString();
m_maxUpdateRate = max_update_rate;
if (m_maxUpdateRate < 100 || m_maxUpdateRate > 5000) {
m_maxUpdateRate = 2000;
}
if (!accessMode.isEmpty()) {
m_accessMode = accessMode;
}
m_useMemoryCache = useMemoryCache;
if (!cacheLocation.isEmpty()) {
m_cacheLocation = Utils::InsertStoragePath(cacheLocation);
}
m_maxUpdateRate = settings.value("maxUpdateRate", 2000).toInt();
if (m_maxUpdateRate < 100 || m_maxUpdateRate > 5000) {
m_maxUpdateRate = 2000;
}
m_accessMode = settings.value("accessMode", "ServerAndCache").toString();
m_useMemoryCache = settings.value("useMemoryCache").toBool();
m_cacheLocation = settings.value("cacheLocation", Utils::GetStoragePath() + "mapscache" + QDir::separator()).toString();
m_cacheLocation = Utils::InsertStoragePath(m_cacheLocation);
}
IUAVGadgetConfiguration *OPMapGadgetConfiguration::clone()
OPMapGadgetConfiguration::OPMapGadgetConfiguration(const OPMapGadgetConfiguration &obj) :
IUAVGadgetConfiguration(obj.classId(), obj.parent())
{
OPMapGadgetConfiguration *m = new OPMapGadgetConfiguration(this->classId());
m->m_mapProvider = m_mapProvider;
m->m_defaultZoom = m_defaultZoom;
m->m_defaultLatitude = m_defaultLatitude;
m->m_defaultLongitude = m_defaultLongitude;
m->m_useOpenGL = m_useOpenGL;
m->m_showTileGridLines = m_showTileGridLines;
m->m_accessMode = m_accessMode;
m->m_useMemoryCache = m_useMemoryCache;
m->m_cacheLocation = m_cacheLocation;
m->m_uavSymbol = m_uavSymbol;
m->m_maxUpdateRate = m_maxUpdateRate;
m->m_opacity = m_opacity;
m->m_defaultWaypointAltitude = m_defaultWaypointAltitude;
m->m_defaultWaypointVelocity = m_defaultWaypointVelocity;
return m;
m_mapProvider = obj.m_mapProvider;
m_defaultZoom = obj.m_defaultZoom;
m_defaultLatitude = obj.m_defaultLatitude;
m_defaultLongitude = obj.m_defaultLongitude;
m_useOpenGL = obj.m_useOpenGL;
m_showTileGridLines = obj.m_showTileGridLines;
m_accessMode = obj.m_accessMode;
m_useMemoryCache = obj.m_useMemoryCache;
m_cacheLocation = obj.m_cacheLocation;
m_uavSymbol = obj.m_uavSymbol;
m_maxUpdateRate = obj.m_maxUpdateRate;
m_opacity = obj.m_opacity;
m_defaultWaypointAltitude = obj.m_defaultWaypointAltitude;
m_defaultWaypointVelocity = obj.m_defaultWaypointVelocity;
}
IUAVGadgetConfiguration *OPMapGadgetConfiguration::clone() const
{
return new OPMapGadgetConfiguration(*this);
}
void OPMapGadgetConfiguration::save() const
{
if (!m_settings) {
return;
}
QSettings settings;
saveConfig(m_settings);
saveConfig(settings);
}
void OPMapGadgetConfiguration::saveConfig(QSettings *qSettings) const
{
qSettings->setValue("mapProvider", m_mapProvider);
qSettings->setValue("defaultZoom", m_defaultZoom);
qSettings->setValue("defaultLatitude", m_defaultLatitude);
qSettings->setValue("defaultLongitude", m_defaultLongitude);
qSettings->setValue("useOpenGL", m_useOpenGL);
qSettings->setValue("showTileGridLines", m_showTileGridLines);
qSettings->setValue("accessMode", m_accessMode);
qSettings->setValue("useMemoryCache", m_useMemoryCache);
qSettings->setValue("uavSymbol", m_uavSymbol);
qSettings->setValue("cacheLocation", Utils::RemoveStoragePath(m_cacheLocation));
qSettings->setValue("maxUpdateRate", m_maxUpdateRate);
qSettings->setValue("overlayOpacity", m_opacity);
qSettings->setValue("defaultWaypointAltitude", m_defaultWaypointAltitude);
qSettings->setValue("defaultWaypointVelocity", m_defaultWaypointVelocity);
void OPMapGadgetConfiguration::saveConfig(QSettings &settings) const
{
settings.setValue("mapProvider", m_mapProvider);
settings.setValue("defaultZoom", m_defaultZoom);
settings.setValue("defaultLatitude", m_defaultLatitude);
settings.setValue("defaultLongitude", m_defaultLongitude);
settings.setValue("useOpenGL", m_useOpenGL);
settings.setValue("showTileGridLines", m_showTileGridLines);
settings.setValue("accessMode", m_accessMode);
settings.setValue("useMemoryCache", m_useMemoryCache);
settings.setValue("uavSymbol", m_uavSymbol);
settings.setValue("cacheLocation", Utils::RemoveStoragePath(m_cacheLocation));
settings.setValue("maxUpdateRate", m_maxUpdateRate);
settings.setValue("overlayOpacity", m_opacity);
settings.setValue("defaultWaypointAltitude", m_defaultWaypointAltitude);
settings.setValue("defaultWaypointVelocity", m_defaultWaypointVelocity);
}
void OPMapGadgetConfiguration::setCacheLocation(QString cacheLocation)
{

View File

@ -29,7 +29,8 @@
#define OPMAP_GADGETCONFIGURATION_H
#include <coreplugin/iuavgadgetconfiguration.h>
#include <QtCore/QString>
#include <QString>
using namespace Core;
@ -50,10 +51,13 @@ class OPMapGadgetConfiguration : public IUAVGadgetConfiguration {
Q_PROPERTY(qreal defaultWaypointVelocity READ defaultWaypointVelocity WRITE setDefaultWaypointVelocity)
public:
explicit OPMapGadgetConfiguration(QString classId, QSettings *qSettings = 0, QObject *parent = 0);
explicit OPMapGadgetConfiguration(QString classId, QSettings &settings, QObject *parent = 0);
explicit OPMapGadgetConfiguration(const OPMapGadgetConfiguration &obj);
void saveConfig(QSettings *settings) const;
IUAVGadgetConfiguration *clone();
IUAVGadgetConfiguration *clone() const;
void saveConfig(QSettings &settings) const;
void save() const;
QString mapProvider() const
{
@ -114,7 +118,6 @@ public:
return m_defaultWaypointVelocity;
}
void save() const;
public slots:
void setMapProvider(QString provider)
{
@ -184,7 +187,6 @@ private:
QString m_cacheLocation;
QString m_uavSymbol;
int m_maxUpdateRate;
QSettings *m_settings;
qreal m_opacity;
qreal m_defaultWaypointAltitude;
qreal m_defaultWaypointVelocity;

View File

@ -45,9 +45,9 @@ Core::IUAVGadget *OPMapGadgetFactory::createGadget(QWidget *parent)
return new OPMapGadget(QString("OPMapGadget"), gadgetWidget, parent);
}
IUAVGadgetConfiguration *OPMapGadgetFactory::createConfiguration(QSettings *qSettings)
IUAVGadgetConfiguration *OPMapGadgetFactory::createConfiguration(QSettings &settings)
{
return new OPMapGadgetConfiguration(QString("OPMapGadget"), qSettings);
return new OPMapGadgetConfiguration(QString("OPMapGadget"), settings);
}
IOptionsPage *OPMapGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)

View File

@ -45,7 +45,7 @@ public:
~OPMapGadgetFactory();
Core::IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(QSettings *qSettings);
IUAVGadgetConfiguration *createConfiguration(QSettings &settings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
};

View File

@ -310,14 +310,14 @@ void PfdQmlContext::loadConfiguration(PfdQmlGadgetConfiguration *config)
}
void PfdQmlContext::saveState(QSettings *settings)
void PfdQmlContext::saveState(QSettings &settings)
{
settings->setValue("modelFile", modelFile());
settings.setValue("modelFile", modelFile());
}
void PfdQmlContext::restoreState(QSettings *settings)
void PfdQmlContext::restoreState(QSettings &settings)
{
QString file = settings->value("modelFile").toString();
QString file = settings.value("modelFile").toString();
if (!file.isEmpty()) {
setModelFile(file);

View File

@ -105,8 +105,8 @@ public:
Q_INVOKABLE void resetConsumedEnergy();
void loadConfiguration(PfdQmlGadgetConfiguration *config);
void saveState(QSettings *);
void restoreState(QSettings *);
void saveState(QSettings &);
void restoreState(QSettings &);
void apply(QQmlContext *context);

View File

@ -52,12 +52,12 @@ void PfdQmlGadget::loadConfiguration(IUAVGadgetConfiguration *config)
m_qmlGadgetWidget->loadConfiguration(m);
}
void PfdQmlGadget::saveState(QSettings *settings)
void PfdQmlGadget::saveState(QSettings &settings)
{
m_qmlGadgetWidget->saveState(settings);
}
void PfdQmlGadget::restoreState(QSettings *settings)
void PfdQmlGadget::restoreState(QSettings &settings)
{
m_qmlGadgetWidget->restoreState(settings);
}

View File

@ -46,8 +46,8 @@ public:
QWidget *widget();
void loadConfiguration(IUAVGadgetConfiguration *config);
void saveState(QSettings *);
void restoreState(QSettings *);
void saveState(QSettings &);
void restoreState(QSettings &);
private:
PfdQmlGadgetWidget *m_qmlGadgetWidget;

View File

@ -32,24 +32,8 @@
* Loads a saved configuration or defaults if non exist.
*
*/
PfdQmlGadgetConfiguration::PfdQmlGadgetConfiguration(QString classId, QSettings *qSettings, QObject *parent) :
IUAVGadgetConfiguration(classId, parent),
m_qmlFile("Unknown"),
m_speedFactor(1.0),
m_altitudeFactor(1.0),
m_terrainEnabled(false),
m_terrainFile("Unknown"),
m_cacheOnly(false),
m_latitude(0),
m_longitude(0),
m_altitude(0),
m_timeMode(TimeMode::Local),
m_dateTime(QDateTime()),
m_minAmbientLight(0),
m_modelEnabled(false),
m_modelFile("Unknown"),
m_modelSelectionMode(ModelSelectionMode::Auto),
m_backgroundImageFile("Unknown")
PfdQmlGadgetConfiguration::PfdQmlGadgetConfiguration(QString classId, QSettings &settings, QObject *parent) :
IUAVGadgetConfiguration(classId, parent)
{
m_speedMap[1.0] = "m/s";
m_speedMap[3.6] = "km/h";
@ -59,114 +43,113 @@ PfdQmlGadgetConfiguration::PfdQmlGadgetConfiguration(QString classId, QSettings
m_altitudeMap[1.0] = "m";
m_altitudeMap[3.2808] = "ft";
// if a saved configuration exists load it
if (qSettings != 0) {
m_qmlFile = qSettings->value("qmlFile").toString();
m_qmlFile = Utils::InsertDataPath(m_qmlFile);
m_qmlFile = settings.value("qmlFile", "Unknown").toString();
m_qmlFile = Utils::InsertDataPath(m_qmlFile);
m_speedFactor = qSettings->value("speedFactor").toDouble();
m_altitudeFactor = qSettings->value("altitudeFactor").toDouble();
m_speedFactor = settings.value("speedFactor", 1.0).toDouble();
m_altitudeFactor = settings.value("altitudeFactor", 1.0).toDouble();
// terrain
m_terrainEnabled = qSettings->value("terrainEnabled").toBool();
m_terrainFile = qSettings->value("earthFile").toString();
m_terrainFile = Utils::InsertDataPath(m_terrainFile);
m_cacheOnly = qSettings->value("cacheOnly").toBool();
// terrain
m_terrainEnabled = settings.value("terrainEnabled", false).toBool();
m_terrainFile = settings.value("earthFile", "Unknown").toString();
m_terrainFile = Utils::InsertDataPath(m_terrainFile);
m_cacheOnly = settings.value("cacheOnly", false).toBool();
m_latitude = qSettings->value("latitude").toDouble();
m_longitude = qSettings->value("longitude").toDouble();
m_altitude = qSettings->value("altitude").toDouble();
m_latitude = settings.value("latitude").toDouble();
m_longitude = settings.value("longitude").toDouble();
m_altitude = settings.value("altitude").toDouble();
// sky
m_timeMode = static_cast<TimeMode::Enum>(qSettings->value("timeMode").toUInt());
m_dateTime = qSettings->value("dateTime").toDateTime();
m_minAmbientLight = qSettings->value("minAmbientLight").toDouble();
// sky
m_timeMode = static_cast<TimeMode::Enum>(settings.value("timeMode", TimeMode::Local).toUInt());
m_dateTime = settings.value("dateTime", QDateTime()).toDateTime();
m_minAmbientLight = settings.value("minAmbientLight").toDouble();
// model
m_modelEnabled = qSettings->value("modelEnabled").toBool();
m_modelSelectionMode = static_cast<ModelSelectionMode::Enum>(qSettings->value("modelSelectionMode").toUInt());
m_modelFile = qSettings->value("modelFile").toString();
m_modelFile = Utils::InsertDataPath(m_modelFile);
// model
m_modelEnabled = settings.value("modelEnabled").toBool();
m_modelSelectionMode = static_cast<ModelSelectionMode::Enum>(settings.value("modelSelectionMode", ModelSelectionMode::Auto).toUInt());
m_modelFile = settings.value("modelFile", "Unknown").toString();
m_modelFile = Utils::InsertDataPath(m_modelFile);
// background image
m_backgroundImageFile = qSettings->value("backgroundImageFile").toString();
m_backgroundImageFile = Utils::InsertDataPath(m_backgroundImageFile);
}
// background image
m_backgroundImageFile = settings.value("backgroundImageFile", "Unknown").toString();
m_backgroundImageFile = Utils::InsertDataPath(m_backgroundImageFile);
}
PfdQmlGadgetConfiguration::PfdQmlGadgetConfiguration(const PfdQmlGadgetConfiguration &obj) :
IUAVGadgetConfiguration(obj.classId(), obj.parent())
{
m_qmlFile = obj.m_qmlFile;
m_speedFactor = obj.m_speedFactor;
m_altitudeFactor = obj.m_altitudeFactor;
// terrain
m_terrainEnabled = obj.m_terrainEnabled;
m_terrainFile = obj.m_terrainFile;
m_cacheOnly = obj.m_cacheOnly;
m_latitude = obj.m_latitude;
m_longitude = obj.m_longitude;
m_altitude = obj.m_altitude;
// sky
m_timeMode = obj.m_timeMode;
m_dateTime = obj.m_dateTime;
m_minAmbientLight = obj.m_minAmbientLight;
// model
m_modelEnabled = obj.m_modelEnabled;
m_modelSelectionMode = obj.m_modelSelectionMode;
m_modelFile = obj.m_modelFile;
// background image
m_backgroundImageFile = obj.m_backgroundImageFile;
}
/**
* Clones a configuration.
*
*/
IUAVGadgetConfiguration *PfdQmlGadgetConfiguration::clone()
IUAVGadgetConfiguration *PfdQmlGadgetConfiguration::clone() const
{
PfdQmlGadgetConfiguration *m = new PfdQmlGadgetConfiguration(this->classId());
m->m_qmlFile = m_qmlFile;
m->m_speedFactor = m_speedFactor;
m->m_altitudeFactor = m_altitudeFactor;
// terrain
m->m_terrainEnabled = m_terrainEnabled;
m->m_terrainFile = m_terrainFile;
m->m_cacheOnly = m_cacheOnly;
m->m_latitude = m_latitude;
m->m_longitude = m_longitude;
m->m_altitude = m_altitude;
// sky
m->m_timeMode = m_timeMode;
m->m_dateTime = m_dateTime;
m->m_minAmbientLight = m_minAmbientLight;
// model
m->m_modelEnabled = m_modelEnabled;
m->m_modelSelectionMode = m_modelSelectionMode;
m->m_modelFile = m_modelFile;
// background image
m->m_backgroundImageFile = m_backgroundImageFile;
return m;
return new PfdQmlGadgetConfiguration(*this);
}
/**
* Saves a configuration.
*
*/
void PfdQmlGadgetConfiguration::saveConfig(QSettings *qSettings) const
void PfdQmlGadgetConfiguration::saveConfig(QSettings &settings) const
{
QString qmlFile = Utils::RemoveDataPath(m_qmlFile);
qSettings->setValue("qmlFile", qmlFile);
settings.setValue("qmlFile", qmlFile);
qSettings->setValue("speedFactor", m_speedFactor);
qSettings->setValue("altitudeFactor", m_altitudeFactor);
settings.setValue("speedFactor", m_speedFactor);
settings.setValue("altitudeFactor", m_altitudeFactor);
// terrain
qSettings->setValue("terrainEnabled", m_terrainEnabled);
settings.setValue("terrainEnabled", m_terrainEnabled);
QString terrainFile = Utils::RemoveDataPath(m_terrainFile);
qSettings->setValue("earthFile", terrainFile);
qSettings->setValue("cacheOnly", m_cacheOnly);
settings.setValue("earthFile", terrainFile);
settings.setValue("cacheOnly", m_cacheOnly);
qSettings->setValue("latitude", m_latitude);
qSettings->setValue("longitude", m_longitude);
qSettings->setValue("altitude", m_altitude);
settings.setValue("latitude", m_latitude);
settings.setValue("longitude", m_longitude);
settings.setValue("altitude", m_altitude);
// sky
qSettings->setValue("timeMode", static_cast<uint>(m_timeMode));
qSettings->setValue("dateTime", m_dateTime);
qSettings->setValue("minAmbientLight", m_minAmbientLight);
settings.setValue("timeMode", static_cast<uint>(m_timeMode));
settings.setValue("dateTime", m_dateTime);
settings.setValue("minAmbientLight", m_minAmbientLight);
// model
qSettings->setValue("modelEnabled", m_modelEnabled);
qSettings->setValue("modelSelectionMode", static_cast<uint>(m_modelSelectionMode));
settings.setValue("modelEnabled", m_modelEnabled);
settings.setValue("modelSelectionMode", static_cast<uint>(m_modelSelectionMode));
QString modelFile = Utils::RemoveDataPath(m_modelFile);
qSettings->setValue("modelFile", modelFile);
settings.setValue("modelFile", modelFile);
// background image
QString backgroundImageFile = Utils::RemoveDataPath(m_backgroundImageFile);
qSettings->setValue("backgroundImageFile", backgroundImageFile);
settings.setValue("backgroundImageFile", backgroundImageFile);
}

View File

@ -39,7 +39,11 @@ using namespace Core;
class PfdQmlGadgetConfiguration : public IUAVGadgetConfiguration {
Q_OBJECT
public:
explicit PfdQmlGadgetConfiguration(QString classId, QSettings *qSettings = 0, QObject *parent = 0);
explicit PfdQmlGadgetConfiguration(QString classId, QSettings &settings, QObject *parent = 0);
explicit PfdQmlGadgetConfiguration(const PfdQmlGadgetConfiguration &obj);
IUAVGadgetConfiguration *clone() const;
void saveConfig(QSettings &settings) const;
QString qmlFile() const
{
@ -206,9 +210,6 @@ public:
return QMapIterator<double, QString>(m_altitudeMap);
}
void saveConfig(QSettings *settings) const;
IUAVGadgetConfiguration *clone();
private:
QString m_qmlFile; // The name of the dial's SVG source file

View File

@ -45,9 +45,9 @@ Core::IUAVGadget *PfdQmlGadgetFactory::createGadget(QWidget *parent)
return new PfdQmlGadget(QString("PfdQmlGadget"), parent);
}
IUAVGadgetConfiguration *PfdQmlGadgetFactory::createConfiguration(QSettings *qSettings)
IUAVGadgetConfiguration *PfdQmlGadgetFactory::createConfiguration(QSettings &settings)
{
return new PfdQmlGadgetConfiguration(QString("PfdQmlGadget"), qSettings);
return new PfdQmlGadgetConfiguration(QString("PfdQmlGadget"), settings);
}
IOptionsPage *PfdQmlGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)

View File

@ -44,7 +44,7 @@ public:
~PfdQmlGadgetFactory();
Core::IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(QSettings *qSettings);
IUAVGadgetConfiguration *createConfiguration(QSettings &settings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
};

View File

@ -93,12 +93,12 @@ void PfdQmlGadgetWidget::loadConfiguration(PfdQmlGadgetConfiguration *config)
setQmlFile(config->qmlFile());
}
void PfdQmlGadgetWidget::saveState(QSettings *settings)
void PfdQmlGadgetWidget::saveState(QSettings &settings)
{
m_pfdQmlContext->saveState(settings);
}
void PfdQmlGadgetWidget::restoreState(QSettings *settings)
void PfdQmlGadgetWidget::restoreState(QSettings &settings)
{
m_pfdQmlContext->restoreState(settings);
}

View File

@ -46,8 +46,8 @@ public:
virtual ~PfdQmlGadgetWidget();
void loadConfiguration(PfdQmlGadgetConfiguration *config);
void saveState(QSettings *);
void restoreState(QSettings *);
void saveState(QSettings &);
void restoreState(QSettings &);
private:
QuickWidgetProxy *m_quickWidgetProxy;

View File

@ -32,39 +32,38 @@
* Loads a saved configuration or defaults if non exist.
*
*/
QmlViewGadgetConfiguration::QmlViewGadgetConfiguration(QString classId, QSettings *qSettings, QObject *parent) :
IUAVGadgetConfiguration(classId, parent),
m_defaultDial("Unknown")
QmlViewGadgetConfiguration::QmlViewGadgetConfiguration(QString classId, QSettings &settings, QObject *parent) :
IUAVGadgetConfiguration(classId, parent)
{
// if a saved configuration exists load it
if (qSettings != 0) {
QString dialFile = qSettings->value("dialFile").toString();
useOpenGLFlag = qSettings->value("useOpenGLFlag").toBool();
m_defaultDial = Utils::InsertDataPath(dialFile);
}
m_defaultDial = settings.value("dialFile", "Unknown").toString();
m_defaultDial = Utils::InsertDataPath(m_defaultDial);
useOpenGLFlag = settings.value("useOpenGLFlag").toBool();
}
QmlViewGadgetConfiguration::QmlViewGadgetConfiguration(const QmlViewGadgetConfiguration &obj) :
IUAVGadgetConfiguration(obj.classId(), obj.parent())
{
m_defaultDial = obj.m_defaultDial;
useOpenGLFlag = obj.useOpenGLFlag;
}
/**
* Clones a configuration.
*
*/
IUAVGadgetConfiguration *QmlViewGadgetConfiguration::clone()
IUAVGadgetConfiguration *QmlViewGadgetConfiguration::clone() const
{
QmlViewGadgetConfiguration *m = new QmlViewGadgetConfiguration(this->classId());
m->m_defaultDial = m_defaultDial;
m->useOpenGLFlag = useOpenGLFlag;
return m;
return new QmlViewGadgetConfiguration(*this);
}
/**
* Saves a configuration.
*
*/
void QmlViewGadgetConfiguration::saveConfig(QSettings *qSettings) const
void QmlViewGadgetConfiguration::saveConfig(QSettings &settings) const
{
QString dialFile = Utils::RemoveDataPath(m_defaultDial);
qSettings->setValue("dialFile", dialFile);
qSettings->setValue("useOpenGLFlag", useOpenGLFlag);
settings.setValue("dialFile", dialFile);
settings.setValue("useOpenGLFlag", useOpenGLFlag);
}

View File

@ -35,7 +35,11 @@ using namespace Core;
class QmlViewGadgetConfiguration : public IUAVGadgetConfiguration {
Q_OBJECT
public:
explicit QmlViewGadgetConfiguration(QString classId, QSettings *qSettings = 0, QObject *parent = 0);
explicit QmlViewGadgetConfiguration(QString classId, QSettings &settings, QObject *parent = 0);
explicit QmlViewGadgetConfiguration(const QmlViewGadgetConfiguration &obj);
IUAVGadgetConfiguration *clone() const;
void saveConfig(QSettings &settings) const;
// set dial configuration functions
void setDialFile(QString dialFile)
@ -57,9 +61,6 @@ public:
return useOpenGLFlag;
}
void saveConfig(QSettings *settings) const;
IUAVGadgetConfiguration *clone();
private:
QString m_defaultDial; // The name of the dial's SVG source file
bool useOpenGLFlag;

View File

@ -47,9 +47,9 @@ Core::IUAVGadget *QmlViewGadgetFactory::createGadget(QWidget *parent)
return new QmlViewGadget(QString("QmlViewGadget"), gadgetWidget, parent);
}
IUAVGadgetConfiguration *QmlViewGadgetFactory::createConfiguration(QSettings *qSettings)
IUAVGadgetConfiguration *QmlViewGadgetFactory::createConfiguration(QSettings &settings)
{
return new QmlViewGadgetConfiguration(QString("QmlViewGadget"), qSettings);
return new QmlViewGadgetConfiguration(QString("QmlViewGadget"), settings);
}
IOptionsPage *QmlViewGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)

View File

@ -44,7 +44,7 @@ public:
~QmlViewGadgetFactory();
Core::IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(QSettings *qSettings);
IUAVGadgetConfiguration *createConfiguration(QSettings &settings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
};

View File

@ -30,7 +30,8 @@
#include "scopegadgetwidget.h"
#include <QVBoxLayout>
#include <qcolor.h>
#include <QSettings>
#include <QColor>
ScopeGadget::ScopeGadget(QString classId, ScopeGadgetWidget *widget, QWidget *parent) :
IUAVGadget(classId, parent), m_widget(widget)
@ -98,12 +99,12 @@ ScopeGadget::~ScopeGadget()
delete m_widget;
}
void ScopeGadget::saveState(QSettings *qSettings)
void ScopeGadget::saveState(QSettings &settings)
{
m_widget->saveState(qSettings);
m_widget->saveState(settings);
}
void ScopeGadget::restoreState(QSettings *qSettings)
void ScopeGadget::restoreState(QSettings &settings)
{
m_widget->restoreState(qSettings);
m_widget->restoreState(settings);
}

View File

@ -63,8 +63,8 @@ public:
return QString();
}
void saveState(QSettings *qSettings);
void restoreState(QSettings *qSettings);
void saveState(QSettings &settings);
void restoreState(QSettings &settings);
private:
ScopeGadgetWidget *m_widget;

View File

@ -2,7 +2,8 @@
******************************************************************************
*
* @file scopegadgetconfiguration.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @author The LibrePilot Team http://www.librepilot.org Copyright (C) 2017.
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ScopePlugin Scope Gadget Plugin
@ -27,53 +28,79 @@
#include "scopegadgetconfiguration.h"
ScopeGadgetConfiguration::ScopeGadgetConfiguration(QString classId, QSettings *qSettings, QObject *parent) :
IUAVGadgetConfiguration(classId, parent),
m_plotType((int)ChronoPlot),
m_dataSize(60),
m_refreshInterval(1000),
m_mathFunctionType(0)
ScopeGadgetConfiguration::ScopeGadgetConfiguration(QString classId, QSettings &settings, QObject *parent) :
IUAVGadgetConfiguration(classId, parent)
{
uint currentStreamVersion = 0;
int plotCurveCount = 0;
uint currentStreamVersion = settings.value("configurationStreamVersion").toUInt();
// If a saved configuration exists load it
if (qSettings != 0) {
currentStreamVersion = qSettings->value("configurationStreamVersion").toUInt();
if (currentStreamVersion != m_configurationStreamVersion) {
return;
}
m_plotType = qSettings->value("plotType").toInt();
m_dataSize = qSettings->value("dataSize").toInt();
m_refreshInterval = qSettings->value("refreshInterval").toInt();
plotCurveCount = qSettings->value("plotCurveCount").toInt();
for (int plotDatasLoadIndex = 0; plotDatasLoadIndex < plotCurveCount; plotDatasLoadIndex++) {
qSettings->beginGroup(QString("plotCurve") + QString().number(plotDatasLoadIndex));
PlotCurveConfiguration *plotCurveConf = new PlotCurveConfiguration();
plotCurveConf->uavObject = qSettings->value("uavObject").toString();
plotCurveConf->uavField = qSettings->value("uavField").toString();
plotCurveConf->color = qSettings->value("color").value<QRgb>();
plotCurveConf->yScalePower = qSettings->value("yScalePower").toInt();
plotCurveConf->mathFunction = qSettings->value("mathFunction").toString();
plotCurveConf->yMeanSamples = qSettings->value("yMeanSamples", 1).toInt();
plotCurveConf->yMeanSamples = qSettings->value("yMeanSamples", 1).toInt();
plotCurveConf->drawAntialiased = qSettings->value("drawAntialiased", true).toBool();
plotCurveConf->yMinimum = qSettings->value("yMinimum").toDouble();
plotCurveConf->yMaximum = qSettings->value("yMaximum").toDouble();
m_plotCurveConfigs.append(plotCurveConf);
qSettings->endGroup();
}
m_loggingEnabled = qSettings->value("LoggingEnabled").toBool();
m_loggingNewFileOnConnect = qSettings->value("LoggingNewFileOnConnect").toBool();
m_loggingPath = qSettings->value("LoggingPath").toString();
if (currentStreamVersion != m_configurationStreamVersion) {
return;
}
m_plotType = settings.value("plotType", ChronoPlot).toInt();
m_dataSize = settings.value("dataSize", 60).toInt();
m_refreshInterval = settings.value("refreshInterval", 1000).toInt();
m_mathFunctionType = 0;
int plotCurveCount = settings.value("plotCurveCount").toInt();
for (int i = 0; i < plotCurveCount; i++) {
settings.beginGroup(QString("plotCurve") + QString().number(i));
PlotCurveConfiguration *plotCurveConf = new PlotCurveConfiguration();
plotCurveConf->uavObject = settings.value("uavObject").toString();
plotCurveConf->uavField = settings.value("uavField").toString();
plotCurveConf->color = settings.value("color").value<QRgb>();
plotCurveConf->yScalePower = settings.value("yScalePower").toInt();
plotCurveConf->mathFunction = settings.value("mathFunction").toString();
plotCurveConf->yMeanSamples = settings.value("yMeanSamples", 1).toInt();
plotCurveConf->yMeanSamples = settings.value("yMeanSamples", 1).toInt();
plotCurveConf->drawAntialiased = settings.value("drawAntialiased", true).toBool();
plotCurveConf->yMinimum = settings.value("yMinimum").toDouble();
plotCurveConf->yMaximum = settings.value("yMaximum").toDouble();
m_plotCurveConfigs.append(plotCurveConf);
settings.endGroup();
}
m_loggingEnabled = settings.value("LoggingEnabled").toBool();
m_loggingNewFileOnConnect = settings.value("LoggingNewFileOnConnect").toBool();
m_loggingPath = settings.value("LoggingPath").toString();
}
ScopeGadgetConfiguration::ScopeGadgetConfiguration(const ScopeGadgetConfiguration & obj) :
IUAVGadgetConfiguration(obj.classId(), obj.parent())
{
m_plotType = obj.m_plotType;
m_dataSize = obj.m_dataSize;
m_mathFunctionType = obj.m_mathFunctionType;
m_refreshInterval = obj.m_refreshInterval;
int plotCurveCount = m_plotCurveConfigs.size();
for (int i = 0; i < plotCurveCount; i++) {
PlotCurveConfiguration *currentPlotCurveConf = obj.m_plotCurveConfigs.at(i);
PlotCurveConfiguration *newPlotCurveConf = new PlotCurveConfiguration();
newPlotCurveConf->uavObject = currentPlotCurveConf->uavObject;
newPlotCurveConf->uavField = currentPlotCurveConf->uavField;
newPlotCurveConf->color = currentPlotCurveConf->color;
newPlotCurveConf->yScalePower = currentPlotCurveConf->yScalePower;
newPlotCurveConf->yMeanSamples = currentPlotCurveConf->yMeanSamples;
newPlotCurveConf->mathFunction = currentPlotCurveConf->mathFunction;
newPlotCurveConf->drawAntialiased = currentPlotCurveConf->drawAntialiased;
newPlotCurveConf->yMinimum = currentPlotCurveConf->yMinimum;
newPlotCurveConf->yMaximum = currentPlotCurveConf->yMaximum;
addPlotCurveConfig(newPlotCurveConf);
}
m_loggingEnabled = obj.m_loggingEnabled;
m_loggingNewFileOnConnect = obj.m_loggingNewFileOnConnect;
m_loggingPath = obj.m_loggingPath;
}
ScopeGadgetConfiguration::~ScopeGadgetConfiguration()
{
clearPlotData();
}
void ScopeGadgetConfiguration::clearPlotData()
@ -91,42 +118,9 @@ void ScopeGadgetConfiguration::clearPlotData()
* Clones a configuration.
*
*/
IUAVGadgetConfiguration *ScopeGadgetConfiguration::clone()
IUAVGadgetConfiguration *ScopeGadgetConfiguration::clone() const
{
int plotCurveCount = 0;
int plotDatasLoadIndex = 0;
ScopeGadgetConfiguration *m = new ScopeGadgetConfiguration(this->classId());
m->setPlotType(m_plotType);
m->setDataSize(m_dataSize);
m->setMathFunctionType(m_mathFunctionType);
m->setRefreashInterval(m_refreshInterval);
plotCurveCount = m_plotCurveConfigs.size();
for (plotDatasLoadIndex = 0; plotDatasLoadIndex < plotCurveCount; plotDatasLoadIndex++) {
PlotCurveConfiguration *currentPlotCurveConf = m_plotCurveConfigs.at(plotDatasLoadIndex);
PlotCurveConfiguration *newPlotCurveConf = new PlotCurveConfiguration();
newPlotCurveConf->uavObject = currentPlotCurveConf->uavObject;
newPlotCurveConf->uavField = currentPlotCurveConf->uavField;
newPlotCurveConf->color = currentPlotCurveConf->color;
newPlotCurveConf->yScalePower = currentPlotCurveConf->yScalePower;
newPlotCurveConf->yMeanSamples = currentPlotCurveConf->yMeanSamples;
newPlotCurveConf->mathFunction = currentPlotCurveConf->mathFunction;
newPlotCurveConf->drawAntialiased = currentPlotCurveConf->drawAntialiased;
newPlotCurveConf->yMinimum = currentPlotCurveConf->yMinimum;
newPlotCurveConf->yMaximum = currentPlotCurveConf->yMaximum;
m->addPlotCurveConfig(newPlotCurveConf);
}
m->setLoggingEnabled(m_loggingEnabled);
m->setLoggingNewFileOnConnect(m_loggingNewFileOnConnect);
m->setLoggingPath(m_loggingPath);
return m;
return new ScopeGadgetConfiguration(*this);
}
@ -134,37 +128,36 @@ IUAVGadgetConfiguration *ScopeGadgetConfiguration::clone()
* Saves a configuration. //REDEFINES saveConfig CHILD BEHAVIOR?
*
*/
void ScopeGadgetConfiguration::saveConfig(QSettings *qSettings) const
void ScopeGadgetConfiguration::saveConfig(QSettings &settings) const
{
int plotCurveCount = m_plotCurveConfigs.size();
int plotDatasLoadIndex = 0;
int plotCurveCount = m_plotCurveConfigs.size();
qSettings->setValue("configurationStreamVersion", m_configurationStreamVersion);
qSettings->setValue("plotType", m_plotType);
qSettings->setValue("dataSize", m_dataSize);
qSettings->setValue("refreshInterval", m_refreshInterval);
qSettings->setValue("plotCurveCount", plotCurveCount);
settings.setValue("configurationStreamVersion", m_configurationStreamVersion);
settings.setValue("plotType", m_plotType);
settings.setValue("dataSize", m_dataSize);
settings.setValue("refreshInterval", m_refreshInterval);
settings.setValue("plotCurveCount", plotCurveCount);
for (plotDatasLoadIndex = 0; plotDatasLoadIndex < plotCurveCount; plotDatasLoadIndex++) {
qSettings->beginGroup(QString("plotCurve") + QString().number(plotDatasLoadIndex));
for (int i = 0; i < plotCurveCount; i++) {
settings.beginGroup(QString("plotCurve") + QString().number(i));
PlotCurveConfiguration *plotCurveConf = m_plotCurveConfigs.at(plotDatasLoadIndex);
qSettings->setValue("uavObject", plotCurveConf->uavObject);
qSettings->setValue("uavField", plotCurveConf->uavField);
qSettings->setValue("color", plotCurveConf->color);
qSettings->setValue("mathFunction", plotCurveConf->mathFunction);
qSettings->setValue("yScalePower", plotCurveConf->yScalePower);
qSettings->setValue("yMeanSamples", plotCurveConf->yMeanSamples);
qSettings->setValue("yMinimum", plotCurveConf->yMinimum);
qSettings->setValue("yMaximum", plotCurveConf->yMaximum);
qSettings->setValue("drawAntialiased", plotCurveConf->drawAntialiased);
PlotCurveConfiguration *plotCurveConf = m_plotCurveConfigs.at(i);
settings.setValue("uavObject", plotCurveConf->uavObject);
settings.setValue("uavField", plotCurveConf->uavField);
settings.setValue("color", plotCurveConf->color);
settings.setValue("mathFunction", plotCurveConf->mathFunction);
settings.setValue("yScalePower", plotCurveConf->yScalePower);
settings.setValue("yMeanSamples", plotCurveConf->yMeanSamples);
settings.setValue("yMinimum", plotCurveConf->yMinimum);
settings.setValue("yMaximum", plotCurveConf->yMaximum);
settings.setValue("drawAntialiased", plotCurveConf->drawAntialiased);
qSettings->endGroup();
settings.endGroup();
}
qSettings->setValue("LoggingEnabled", m_loggingEnabled);
qSettings->setValue("LoggingNewFileOnConnect", m_loggingNewFileOnConnect);
qSettings->setValue("LoggingPath", m_loggingPath);
settings.setValue("LoggingEnabled", m_loggingEnabled);
settings.setValue("LoggingNewFileOnConnect", m_loggingNewFileOnConnect);
settings.setValue("LoggingPath", m_loggingPath);
}
void ScopeGadgetConfiguration::replacePlotCurveConfig(QList<PlotCurveConfiguration *> newPlotCurveConfigs)
@ -173,8 +166,3 @@ void ScopeGadgetConfiguration::replacePlotCurveConfig(QList<PlotCurveConfigurati
m_plotCurveConfigs.append(newPlotCurveConfigs);
}
ScopeGadgetConfiguration::~ScopeGadgetConfiguration()
{
clearPlotData();
}

View File

@ -28,10 +28,8 @@
#ifndef SCOPEGADGETCONFIGURATION_H
#define SCOPEGADGETCONFIGURATION_H
#include "plotdata.h"
#include <coreplugin/iuavgadgetconfiguration.h>
#include <QVector>
#include "plotdata.h"
using namespace Core;
@ -50,9 +48,13 @@ struct PlotCurveConfiguration {
class ScopeGadgetConfiguration : public IUAVGadgetConfiguration {
Q_OBJECT
public:
explicit ScopeGadgetConfiguration(QString classId, QSettings *qSettings = 0, QObject *parent = 0);
explicit ScopeGadgetConfiguration(QString classId, QSettings &settings, QObject *parent = 0);
explicit ScopeGadgetConfiguration(const ScopeGadgetConfiguration &obj);
~ScopeGadgetConfiguration();
virtual ~ScopeGadgetConfiguration();
IUAVGadgetConfiguration *clone() const;
void saveConfig(QSettings &settings) const;
// configuration setter functions
void setPlotType(int value)
@ -99,9 +101,6 @@ public:
return m_plotCurveConfigs;
}
void saveConfig(QSettings *settings) const; // THIS SEEMS TO BE UNUSED
IUAVGadgetConfiguration *clone();
bool getLoggingEnabled()
{
return m_loggingEnabled;
@ -128,7 +127,6 @@ public:
}
private:
// Increment this if the stream format is not compatible with previous versions. This would cause existing configs to be discarded.
static const uint m_configurationStreamVersion = 1000;
// The type of the plot

View File

@ -59,9 +59,9 @@ Core::IUAVGadget *ScopeGadgetFactory::createGadget(QWidget *parent)
return new ScopeGadget(QString("ScopeGadget"), gadgetWidget, parent);
}
IUAVGadgetConfiguration *ScopeGadgetFactory::createConfiguration(QSettings *qSettings)
IUAVGadgetConfiguration *ScopeGadgetFactory::createConfiguration(QSettings &settings)
{
return new ScopeGadgetConfiguration(QString("ScopeGadget"), qSettings);
return new ScopeGadgetConfiguration(QString("ScopeGadget"), settings);
}
IOptionsPage *ScopeGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)

View File

@ -45,7 +45,7 @@ public:
~ScopeGadgetFactory();
Core::IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(QSettings *qSettings);
IUAVGadgetConfiguration *createConfiguration(QSettings &settings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
public slots:

View File

@ -52,6 +52,7 @@
#include <QMenu>
#include <QAction>
#include <QClipboard>
#include <QSettings>
#include <QApplication>
#include <qwt/src/qwt_legend_label.h>
@ -456,7 +457,7 @@ void ScopeGadgetWidget::clearCurvePlots()
m_curvesData.clear();
}
void ScopeGadgetWidget::saveState(QSettings *qSettings)
void ScopeGadgetWidget::saveState(QSettings &settings)
{
// plot state
int i = 1;
@ -465,25 +466,25 @@ void ScopeGadgetWidget::saveState(QSettings *qSettings)
bool plotVisible = plotData->isVisible();
if (!plotVisible) {
qSettings->setValue(QString("plot%1").arg(i), plotVisible);
settings.setValue(QString("plot%1").arg(i), plotVisible);
}
i++;
}
// legend state
qSettings->setValue("legendVisible", legend() != NULL);
settings.setValue("legendVisible", legend() != NULL);
}
void ScopeGadgetWidget::restoreState(QSettings *qSettings)
void ScopeGadgetWidget::restoreState(QSettings &settings)
{
// plot state
int i = 1;
foreach(PlotData * plotData, m_curvesData.values()) {
plotData->setVisible(qSettings->value(QString("plot%1").arg(i), true).toBool());
plotData->setVisible(settings.value(QString("plot%1").arg(i), true).toBool());
i++;
}
// legend state
bool legendVisible = qSettings->value("legendVisible", true).toBool();
bool legendVisible = settings.value("legendVisible", true).toBool();
if (legendVisible) {
addLegend();
} else {

View File

@ -100,8 +100,8 @@ public:
QString mathFunction = "None", QPen pen = QPen(Qt::black), bool antialiased = true);
void clearCurvePlots();
void saveState(QSettings *qSettings);
void restoreState(QSettings *qSettings);
void saveState(QSettings &settings);
void restoreState(QSettings &settings);
int csvLoggingStart();
int csvLoggingStop();

Some files were not shown because too many files have changed in this diff Show More