mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-04-10 02:02:21 +02:00
Merged in filnet/librepilot/LP-419_avoid_gcs_config_reset (pull request #457)
LP-419 avoid gcs config reset Approved-by: Philippe Renon <philippe_renon@yahoo.fr> Approved-by: Lalanne Laurent <f5soh@free.fr> Approved-by: Jan NIJS <dr.oblivium@gmail.com> Approved-by: Brian Webb <webbbn@gmail.com>
This commit is contained in:
commit
e3a658d153
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file main.cpp
|
* @file main.cpp
|
||||||
* @author The LibrePilot Team http://www.librepilot.org Copyright (C) 2015.
|
* @author The LibrePilot Team http://www.librepilot.org Copyright (C) 2017.
|
||||||
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||||
* @brief
|
* @brief
|
||||||
@ -82,17 +82,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "qtsingleapplication.h"
|
#include "qtsingleapplication.h"
|
||||||
#include "utils/xmlconfig.h"
|
|
||||||
#include "utils/pathutils.h"
|
|
||||||
#include "utils/filelogger.h"
|
|
||||||
#include "gcssplashscreen.h"
|
#include "gcssplashscreen.h"
|
||||||
|
#include "utils/pathutils.h"
|
||||||
|
#include "utils/settingsutils.h"
|
||||||
|
#include "utils/filelogger.h"
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <extensionsystem/pluginspec.h>
|
#include <extensionsystem/pluginspec.h>
|
||||||
#include <extensionsystem/iplugin.h>
|
#include <extensionsystem/iplugin.h>
|
||||||
|
|
||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
#include <QtCore/QFile>
|
|
||||||
#include <QtCore/QElapsedTimer>
|
#include <QtCore/QElapsedTimer>
|
||||||
#include <QtCore/QTextStream>
|
#include <QtCore/QTextStream>
|
||||||
#include <QtCore/QFileInfo>
|
#include <QtCore/QFileInfo>
|
||||||
@ -101,12 +100,9 @@
|
|||||||
#include <QtCore/QLibraryInfo>
|
#include <QtCore/QLibraryInfo>
|
||||||
#include <QtCore/QTranslator>
|
#include <QtCore/QTranslator>
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
#include <QtCore/QVariant>
|
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QtWidgets/QApplication>
|
#include <QApplication>
|
||||||
#include <QMainWindow>
|
|
||||||
#include <QSplashScreen>
|
|
||||||
#include <QSurfaceFormat>
|
#include <QSurfaceFormat>
|
||||||
|
|
||||||
typedef QList<ExtensionSystem::PluginSpec *> PluginSpecSet;
|
typedef QList<ExtensionSystem::PluginSpec *> PluginSpecSet;
|
||||||
@ -350,78 +346,6 @@ AppOptionValues parseCommandLine(SharedTools::QtSingleApplication &app,
|
|||||||
return appOptionValues;
|
return appOptionValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadFactoryDefaults(QSettings &settings, AppOptionValues &appOptionValues)
|
|
||||||
{
|
|
||||||
QDir directory(Utils::GetDataPath() + QString("configurations"));
|
|
||||||
|
|
||||||
qDebug() << "Looking for factory defaults configuration files in:" << directory.absolutePath();
|
|
||||||
|
|
||||||
QString fileName;
|
|
||||||
|
|
||||||
// check if command line option -config-file contains a file name
|
|
||||||
QString commandLine = appOptionValues.value(CONFIG_FILE_OPTION);
|
|
||||||
if (!commandLine.isEmpty()) {
|
|
||||||
QFileInfo fi(commandLine);
|
|
||||||
if (fi.isRelative()) {
|
|
||||||
// file name specified on command line has a relative path
|
|
||||||
commandLine = directory.absolutePath() + QDir::separator() + commandLine;
|
|
||||||
}
|
|
||||||
if (QFile::exists(commandLine)) {
|
|
||||||
fileName = commandLine;
|
|
||||||
qDebug() << "Configuration file" << fileName << "specified on command line will be loaded.";
|
|
||||||
} else {
|
|
||||||
qWarning() << "Configuration file" << commandLine << "specified on command line does not exist.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fileName.isEmpty()) {
|
|
||||||
// check default file
|
|
||||||
if (QFile::exists(directory.absolutePath() + QDir::separator() + DEFAULT_CONFIG_FILENAME)) {
|
|
||||||
// use default file name
|
|
||||||
fileName = directory.absolutePath() + QDir::separator() + DEFAULT_CONFIG_FILENAME;
|
|
||||||
qDebug() << "Default configuration file" << fileName << "will be loaded.";
|
|
||||||
} else {
|
|
||||||
qWarning() << "No default configuration file found in" << directory.absolutePath();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fileName.isEmpty()) {
|
|
||||||
// TODO should we exit violently?
|
|
||||||
qCritical() << "No default configuration file found!";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// create settings from file
|
|
||||||
QSettings qs(fileName, XmlConfig::XmlSettingsFormat);
|
|
||||||
|
|
||||||
// transfer loaded settings to application settings
|
|
||||||
QStringList keys = qs.allKeys();
|
|
||||||
foreach(QString key, keys) {
|
|
||||||
settings.setValue(key, qs.value(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
qDebug() << "Configuration file" << fileName << "was loaded.";
|
|
||||||
}
|
|
||||||
|
|
||||||
void overrideSettings(QSettings &settings, const QStringList &arguments)
|
|
||||||
{
|
|
||||||
// Options like -D My/setting=test
|
|
||||||
QRegExp rx("([^=]+)=(.*)");
|
|
||||||
|
|
||||||
for (int i = 0; i < arguments.size(); ++i) {
|
|
||||||
if (CONFIG_OPTION == arguments[i]) {
|
|
||||||
if (rx.indexIn(arguments[++i]) > -1) {
|
|
||||||
QString key = rx.cap(1);
|
|
||||||
QString value = rx.cap(2);
|
|
||||||
qDebug() << "User setting" << key << "set to value" << value;
|
|
||||||
settings.setValue(key, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
settings.sync();
|
|
||||||
}
|
|
||||||
|
|
||||||
void loadTranslators(QString language, QTranslator &translator, QTranslator &qtTranslator)
|
void loadTranslators(QString language, QTranslator &translator, QTranslator &qtTranslator)
|
||||||
{
|
{
|
||||||
const QString &creatorTrPath = Utils::GetDataPath() + QLatin1String("translations");
|
const QString &creatorTrPath = Utils::GetDataPath() + QLatin1String("translations");
|
||||||
@ -454,7 +378,6 @@ int runApplication(int argc, char * *argv)
|
|||||||
|
|
||||||
QCoreApplication::setApplicationName(APP_NAME);
|
QCoreApplication::setApplicationName(APP_NAME);
|
||||||
QCoreApplication::setOrganizationName(ORG_NAME);
|
QCoreApplication::setOrganizationName(ORG_NAME);
|
||||||
QSettings::setDefaultFormat(XmlConfig::XmlSettingsFormat);
|
|
||||||
|
|
||||||
// initialize the plugin manager
|
// initialize the plugin manager
|
||||||
ExtensionSystem::PluginManager pluginManager;
|
ExtensionSystem::PluginManager pluginManager;
|
||||||
@ -462,7 +385,7 @@ int runApplication(int argc, char * *argv)
|
|||||||
pluginManager.setPluginPaths(Utils::GetPluginPaths());
|
pluginManager.setPluginPaths(Utils::GetPluginPaths());
|
||||||
|
|
||||||
// parse command line
|
// parse command line
|
||||||
qDebug() << "Command line" << app.arguments();
|
qDebug() << "main - command line" << app.arguments();
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
AppOptionValues appOptionValues = parseCommandLine(app, pluginManager, errorMessage);
|
AppOptionValues appOptionValues = parseCommandLine(app, pluginManager, errorMessage);
|
||||||
if (!errorMessage.isEmpty()) {
|
if (!errorMessage.isEmpty()) {
|
||||||
@ -473,39 +396,32 @@ int runApplication(int argc, char * *argv)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start logging to file if requested
|
||||||
if (appOptionValues.contains(LOG_FILE_OPTION)) {
|
if (appOptionValues.contains(LOG_FILE_OPTION)) {
|
||||||
QString logFileName = appOptionValues.value(LOG_FILE_OPTION);
|
QString logFileName = appOptionValues.value(LOG_FILE_OPTION);
|
||||||
logInit(logFileName);
|
logInit(logFileName);
|
||||||
// relog command line arguments for the benefit of the file logger...
|
// relog command line arguments for the benefit of the file logger...
|
||||||
qDebug() << "Command line" << app.arguments();
|
qDebug() << "main - command line" << app.arguments();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// init settings
|
||||||
|
Utils::initSettings(appOptionValues.value(CONFIG_FILE_OPTION));
|
||||||
|
|
||||||
// load user settings
|
// load user settings
|
||||||
// Must be done before any QSettings class is created
|
|
||||||
// keep this in sync with the MainWindow ctor in coreplugin/mainwindow.cpp
|
|
||||||
QString settingsPath = Utils::GetDataPath();
|
|
||||||
qDebug() << "Loading system settings from" << settingsPath;
|
|
||||||
QSettings::setPath(XmlConfig::XmlSettingsFormat, QSettings::SystemScope, settingsPath);
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
qDebug() << "Loading user settings from" << settings.fileName();
|
qDebug() << "main - loading user settings from" << settings.fileName();
|
||||||
|
|
||||||
// need to reset all user settings?
|
// need to reset user settings?
|
||||||
if (appOptionValues.contains(RESET_OPTION)) {
|
if (settings.allKeys().isEmpty() || appOptionValues.contains(RESET_OPTION)) {
|
||||||
qDebug() << "Resetting user settings!";
|
qDebug() << "main - resetting user settings";
|
||||||
settings.clear();
|
Utils::resetToFactoryDefaults(settings);
|
||||||
}
|
|
||||||
|
|
||||||
// check if we have user settings
|
|
||||||
if (!settings.allKeys().count()) {
|
|
||||||
// no user settings, load the factory defaults
|
|
||||||
qDebug() << "No user settings found, loading factory defaults...";
|
|
||||||
loadFactoryDefaults(settings, appOptionValues);
|
|
||||||
}
|
}
|
||||||
|
Utils::mergeFactoryDefaults(settings);
|
||||||
|
|
||||||
// override settings with command line provided values
|
// override settings with command line provided values
|
||||||
// take notice that the overridden values will be saved in the user settings and will continue to be effective
|
// take notice that the overridden values will be saved in the user settings and will continue to be effective
|
||||||
// in subsequent GCS runs
|
// in subsequent GCS runs
|
||||||
overrideSettings(settings, app.arguments());
|
Utils::overrideSettings(settings, argc, argv);
|
||||||
|
|
||||||
// initialize GCS locale
|
// initialize GCS locale
|
||||||
// use the value defined by the General/Locale setting or default to system Locale.
|
// use the value defined by the General/Locale setting or default to system Locale.
|
||||||
@ -559,8 +475,8 @@ int runApplication(int argc, char * *argv)
|
|||||||
}
|
}
|
||||||
if (!coreplugin) {
|
if (!coreplugin) {
|
||||||
QString nativePaths = QDir::toNativeSeparators(Utils::GetPluginPaths().join(QLatin1String(",")));
|
QString nativePaths = QDir::toNativeSeparators(Utils::GetPluginPaths().join(QLatin1String(",")));
|
||||||
const QString reason = QCoreApplication::translate("Application", "Could not find 'Core.pluginspec' in %1").arg(
|
const QString reason = QCoreApplication::translate("Application", "Could not find '%1.pluginspec' in %2")
|
||||||
nativePaths);
|
.arg(CORE_PLUGIN_NAME).arg(nativePaths);
|
||||||
displayError(msgCoreLoadFailure(reason));
|
displayError(msgCoreLoadFailure(reason));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -591,19 +507,17 @@ int runApplication(int argc, char * *argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
QStringList errors;
|
||||||
QStringList errors;
|
foreach(ExtensionSystem::PluginSpec * p, pluginManager.plugins()) {
|
||||||
foreach(ExtensionSystem::PluginSpec * p, pluginManager.plugins()) {
|
if (p->hasError()) {
|
||||||
if (p->hasError()) {
|
errors.append(p->errorString());
|
||||||
errors.append(p->errorString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!errors.isEmpty()) {
|
|
||||||
QMessageBox::warning(0,
|
|
||||||
QCoreApplication::translate("Application", "%1 - Plugin loader messages").arg(GCS_BIG_NAME),
|
|
||||||
errors.join(QString::fromLatin1("\n\n")));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!errors.isEmpty()) {
|
||||||
|
QMessageBox::warning(0,
|
||||||
|
QCoreApplication::translate("Application", "%1 - Plugin loader messages").arg(GCS_BIG_NAME),
|
||||||
|
errors.join(QString::fromLatin1("\n\n")));
|
||||||
|
}
|
||||||
|
|
||||||
if (isFirstInstance) {
|
if (isFirstInstance) {
|
||||||
// Set up lock and remote arguments for the first instance only.
|
// Set up lock and remote arguments for the first instance only.
|
||||||
|
@ -1,86 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
*
|
|
||||||
* @file abstractprocess.h
|
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
||||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
|
||||||
* @brief
|
|
||||||
* @see The GNU Public License (GPL) Version 3
|
|
||||||
* @defgroup
|
|
||||||
* @{
|
|
||||||
*
|
|
||||||
*****************************************************************************/
|
|
||||||
/*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ABSTRACTPROCESS_H
|
|
||||||
#define ABSTRACTPROCESS_H
|
|
||||||
|
|
||||||
#include "utils_global.h"
|
|
||||||
|
|
||||||
#include <QtCore/QStringList>
|
|
||||||
|
|
||||||
namespace Utils {
|
|
||||||
class QTCREATOR_UTILS_EXPORT AbstractProcess {
|
|
||||||
public:
|
|
||||||
AbstractProcess() {}
|
|
||||||
virtual ~AbstractProcess() {}
|
|
||||||
|
|
||||||
QString workingDirectory() const
|
|
||||||
{
|
|
||||||
return m_workingDir;
|
|
||||||
}
|
|
||||||
void setWorkingDirectory(const QString &dir)
|
|
||||||
{
|
|
||||||
m_workingDir = dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList environment() const
|
|
||||||
{
|
|
||||||
return m_environment;
|
|
||||||
}
|
|
||||||
void setEnvironment(const QStringList &env)
|
|
||||||
{
|
|
||||||
m_environment = env;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool start(const QString &program, const QStringList &args) = 0;
|
|
||||||
virtual void stop() = 0;
|
|
||||||
|
|
||||||
virtual bool isRunning() const = 0;
|
|
||||||
virtual qint64 applicationPID() const = 0;
|
|
||||||
virtual int exitCode() const = 0;
|
|
||||||
|
|
||||||
// signals:
|
|
||||||
virtual void processError(const QString &error) = 0;
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
// Add PATH and SystemRoot environment variables in case they are missing
|
|
||||||
static QStringList fixWinEnvironment(const QStringList &env);
|
|
||||||
// Quote a Windows command line correctly for the "CreateProcess" API
|
|
||||||
static QString createWinCommandline(const QString &program, const QStringList &args);
|
|
||||||
// Create a bytearray suitable to be passed on as environment
|
|
||||||
// to the "CreateProcess" API (0-terminated UTF 16 strings).
|
|
||||||
static QByteArray createWinEnvironment(const QStringList &env);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString m_workingDir;
|
|
||||||
QStringList m_environment;
|
|
||||||
};
|
|
||||||
} // namespace Utils
|
|
||||||
|
|
||||||
#endif // ABSTRACTPROCESS_H
|
|
@ -1,119 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
*
|
|
||||||
* @file abstractprocess_win.cpp
|
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
||||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
|
||||||
* @brief
|
|
||||||
* @see The GNU Public License (GPL) Version 3
|
|
||||||
* @defgroup
|
|
||||||
* @{
|
|
||||||
*
|
|
||||||
*****************************************************************************/
|
|
||||||
/*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "abstractprocess.h"
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
namespace Utils {
|
|
||||||
QStringList AbstractProcess::fixWinEnvironment(const QStringList &env)
|
|
||||||
{
|
|
||||||
QStringList envStrings = env;
|
|
||||||
|
|
||||||
// add PATH if necessary (for DLL loading)
|
|
||||||
if (envStrings.filter(QRegExp(QLatin1String("^PATH="), Qt::CaseInsensitive)).isEmpty()) {
|
|
||||||
QByteArray path = qgetenv("PATH");
|
|
||||||
if (!path.isEmpty()) {
|
|
||||||
envStrings.prepend(QString(QLatin1String("PATH=%1")).arg(QString::fromLocal8Bit(path)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// add systemroot if needed
|
|
||||||
if (envStrings.filter(QRegExp(QLatin1String("^SystemRoot="), Qt::CaseInsensitive)).isEmpty()) {
|
|
||||||
QByteArray systemRoot = qgetenv("SystemRoot");
|
|
||||||
if (!systemRoot.isEmpty()) {
|
|
||||||
envStrings.prepend(QString(QLatin1String("SystemRoot=%1")).arg(QString::fromLocal8Bit(systemRoot)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return envStrings;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AbstractProcess::createWinCommandline(const QString &program, const QStringList &args)
|
|
||||||
{
|
|
||||||
const QChar doubleQuote = QLatin1Char('"');
|
|
||||||
const QChar blank = QLatin1Char(' ');
|
|
||||||
const QChar backSlash = QLatin1Char('\\');
|
|
||||||
|
|
||||||
QString programName = program;
|
|
||||||
|
|
||||||
if (!programName.startsWith(doubleQuote) && !programName.endsWith(doubleQuote) && programName.contains(blank)) {
|
|
||||||
programName.insert(0, doubleQuote);
|
|
||||||
programName.append(doubleQuote);
|
|
||||||
}
|
|
||||||
// add the prgram as the first arrg ... it works better
|
|
||||||
programName.replace(QLatin1Char('/'), backSlash);
|
|
||||||
QString cmdLine = programName;
|
|
||||||
if (args.empty()) {
|
|
||||||
return cmdLine;
|
|
||||||
}
|
|
||||||
|
|
||||||
cmdLine += blank;
|
|
||||||
for (int i = 0; i < args.size(); ++i) {
|
|
||||||
QString tmp = args.at(i);
|
|
||||||
// in the case of \" already being in the string the \ must also be escaped
|
|
||||||
tmp.replace(QLatin1String("\\\""), QLatin1String("\\\\\""));
|
|
||||||
// escape a single " because the arguments will be parsed
|
|
||||||
tmp.replace(QString(doubleQuote), QLatin1String("\\\""));
|
|
||||||
if (tmp.isEmpty() || tmp.contains(blank) || tmp.contains('\t')) {
|
|
||||||
// The argument must not end with a \ since this would be interpreted
|
|
||||||
// as escaping the quote -- rather put the \ behind the quote: e.g.
|
|
||||||
// rather use "foo"\ than "foo\"
|
|
||||||
QString endQuote(doubleQuote);
|
|
||||||
int i = tmp.length();
|
|
||||||
while (i > 0 && tmp.at(i - 1) == backSlash) {
|
|
||||||
--i;
|
|
||||||
endQuote += backSlash;
|
|
||||||
}
|
|
||||||
cmdLine += QLatin1String(" \"");
|
|
||||||
cmdLine += tmp.left(i);
|
|
||||||
cmdLine += endQuote;
|
|
||||||
} else {
|
|
||||||
cmdLine += blank;
|
|
||||||
cmdLine += tmp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cmdLine;
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray AbstractProcess::createWinEnvironment(const QStringList &env)
|
|
||||||
{
|
|
||||||
QByteArray envlist;
|
|
||||||
int pos = 0;
|
|
||||||
|
|
||||||
foreach(const QString &tmp, env) {
|
|
||||||
const uint tmpSize = sizeof(TCHAR) * (tmp.length() + 1);
|
|
||||||
|
|
||||||
envlist.resize(envlist.size() + tmpSize);
|
|
||||||
memcpy(envlist.data() + pos, tmp.utf16(), tmpSize);
|
|
||||||
pos += tmpSize;
|
|
||||||
}
|
|
||||||
envlist.resize(envlist.size() + 2);
|
|
||||||
envlist[pos++] = 0;
|
|
||||||
envlist[pos++] = 0;
|
|
||||||
return envlist;
|
|
||||||
}
|
|
||||||
} // namespace Utils
|
|
@ -1,83 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
*
|
|
||||||
* @file consoleprocess.cpp
|
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
||||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
|
||||||
* @brief
|
|
||||||
* @see The GNU Public License (GPL) Version 3
|
|
||||||
* @defgroup
|
|
||||||
* @{
|
|
||||||
*
|
|
||||||
*****************************************************************************/
|
|
||||||
/*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "consoleprocess.h"
|
|
||||||
|
|
||||||
namespace Utils {
|
|
||||||
QString ConsoleProcess::modeOption(Mode m)
|
|
||||||
{
|
|
||||||
switch (m) {
|
|
||||||
case Debug:
|
|
||||||
return QLatin1String("debug");
|
|
||||||
|
|
||||||
case Suspend:
|
|
||||||
return QLatin1String("suspend");
|
|
||||||
|
|
||||||
case Run:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return QLatin1String("run");
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ConsoleProcess::msgCommChannelFailed(const QString &error)
|
|
||||||
{
|
|
||||||
return tr("Cannot set up communication channel: %1").arg(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ConsoleProcess::msgPromptToClose()
|
|
||||||
{
|
|
||||||
// ! Showed in a terminal which might have
|
|
||||||
// ! a different character set on Windows.
|
|
||||||
return tr("Press <RETURN> to close this window...");
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ConsoleProcess::msgCannotCreateTempFile(const QString &why)
|
|
||||||
{
|
|
||||||
return tr("Cannot create temporary file: %1").arg(why);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ConsoleProcess::msgCannotCreateTempDir(const QString & dir, const QString &why)
|
|
||||||
{
|
|
||||||
return tr("Cannot create temporary directory '%1': %2").arg(dir, why);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ConsoleProcess::msgUnexpectedOutput()
|
|
||||||
{
|
|
||||||
return tr("Unexpected output from helper program.");
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ConsoleProcess::msgCannotChangeToWorkDir(const QString & dir, const QString &why)
|
|
||||||
{
|
|
||||||
return tr("Cannot change to working directory '%1': %2").arg(dir, why);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ConsoleProcess::msgCannotExecute(const QString & p, const QString &why)
|
|
||||||
{
|
|
||||||
return tr("Cannot execute '%1': %2").arg(p, why);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,154 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
*
|
|
||||||
* @file consoleprocess.h
|
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
||||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
|
||||||
* @brief
|
|
||||||
* @see The GNU Public License (GPL) Version 3
|
|
||||||
* @defgroup
|
|
||||||
* @{
|
|
||||||
*
|
|
||||||
*****************************************************************************/
|
|
||||||
/*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef CONSOLEPROCESS_H
|
|
||||||
#define CONSOLEPROCESS_H
|
|
||||||
|
|
||||||
#include "abstractprocess.h"
|
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
|
||||||
#include <QtCore/QString>
|
|
||||||
#include <QtCore/QStringList>
|
|
||||||
#include <QtCore/QProcess>
|
|
||||||
|
|
||||||
#include <QtNetwork/QLocalServer>
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
#include <windows.h>
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QWinEventNotifier;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QSettings;
|
|
||||||
class QTemporaryFile;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
namespace Utils {
|
|
||||||
class QTCREATOR_UTILS_EXPORT ConsoleProcess : public QObject, public AbstractProcess {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
enum Mode { Run, Debug, Suspend };
|
|
||||||
ConsoleProcess(QObject *parent = 0);
|
|
||||||
~ConsoleProcess();
|
|
||||||
|
|
||||||
bool start(const QString &program, const QStringList &args);
|
|
||||||
void stop();
|
|
||||||
|
|
||||||
void setMode(Mode m)
|
|
||||||
{
|
|
||||||
m_mode = m;
|
|
||||||
}
|
|
||||||
Mode mode() const
|
|
||||||
{
|
|
||||||
return m_mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isRunning() const; // This reflects the state of the console+stub
|
|
||||||
qint64 applicationPID() const
|
|
||||||
{
|
|
||||||
return m_appPid;
|
|
||||||
}
|
|
||||||
int exitCode() const
|
|
||||||
{
|
|
||||||
return m_appCode;
|
|
||||||
} // This will be the signal number if exitStatus == CrashExit
|
|
||||||
QProcess::ExitStatus exitStatus() const
|
|
||||||
{
|
|
||||||
return m_appStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
#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);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void processError(const QString &error);
|
|
||||||
// These reflect the state of the actual client process
|
|
||||||
void processStarted();
|
|
||||||
void processStopped();
|
|
||||||
|
|
||||||
// These reflect the state of the console+stub
|
|
||||||
void wrapperStarted();
|
|
||||||
void wrapperStopped();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void stubConnectionAvailable();
|
|
||||||
void readStubOutput();
|
|
||||||
void stubExited();
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
void inferiorExited();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
|
||||||
static QString modeOption(Mode m);
|
|
||||||
static QString msgCommChannelFailed(const QString &error);
|
|
||||||
static QString msgPromptToClose();
|
|
||||||
static QString msgCannotCreateTempFile(const QString &why);
|
|
||||||
static QString msgCannotCreateTempDir(const QString & dir, const QString &why);
|
|
||||||
static QString msgUnexpectedOutput();
|
|
||||||
static QString msgCannotChangeToWorkDir(const QString & dir, const QString &why);
|
|
||||||
static QString msgCannotExecute(const QString & p, const QString &why);
|
|
||||||
|
|
||||||
QString stubServerListen();
|
|
||||||
void stubServerShutdown();
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
void cleanupStub();
|
|
||||||
void cleanupInferior();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Mode m_mode;
|
|
||||||
qint64 m_appPid;
|
|
||||||
int m_appCode;
|
|
||||||
QString m_executable;
|
|
||||||
QProcess::ExitStatus m_appStatus;
|
|
||||||
QLocalServer m_stubServer;
|
|
||||||
QLocalSocket *m_stubSocket;
|
|
||||||
QTemporaryFile *m_tempFile;
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
PROCESS_INFORMATION *m_pid;
|
|
||||||
HANDLE m_hInferior;
|
|
||||||
QWinEventNotifier *inferiorFinishedNotifier;
|
|
||||||
QWinEventNotifier *processFinishedNotifier;
|
|
||||||
#else
|
|
||||||
QProcess m_process;
|
|
||||||
QByteArray m_stubServerDir;
|
|
||||||
QSettings *m_settings;
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
} // namespace Utils
|
|
||||||
|
|
||||||
#endif // ifndef CONSOLEPROCESS_H
|
|
@ -1,270 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
*
|
|
||||||
* @file consoleprocess_unix.cpp
|
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
||||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
|
||||||
* @brief
|
|
||||||
* @see The GNU Public License (GPL) Version 3
|
|
||||||
* @defgroup
|
|
||||||
* @{
|
|
||||||
*
|
|
||||||
*****************************************************************************/
|
|
||||||
/*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "consoleprocess.h"
|
|
||||||
|
|
||||||
#include <QtCore/QCoreApplication>
|
|
||||||
#include <QtCore/QDir>
|
|
||||||
#include <QtCore/QSettings>
|
|
||||||
#include <QtCore/QTemporaryFile>
|
|
||||||
|
|
||||||
#include <QtNetwork/QLocalSocket>
|
|
||||||
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
using namespace Utils;
|
|
||||||
|
|
||||||
ConsoleProcess::ConsoleProcess(QObject *parent) :
|
|
||||||
QObject(parent),
|
|
||||||
m_mode(Run),
|
|
||||||
m_appPid(0),
|
|
||||||
m_stubSocket(0),
|
|
||||||
m_settings(0)
|
|
||||||
{
|
|
||||||
connect(&m_stubServer, SIGNAL(newConnection()), SLOT(stubConnectionAvailable()));
|
|
||||||
|
|
||||||
m_process.setProcessChannelMode(QProcess::ForwardedChannels);
|
|
||||||
connect(&m_process, SIGNAL(finished(int, QProcess::ExitStatus)),
|
|
||||||
SLOT(stubExited()));
|
|
||||||
}
|
|
||||||
|
|
||||||
ConsoleProcess::~ConsoleProcess()
|
|
||||||
{
|
|
||||||
stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ConsoleProcess::start(const QString &program, const QStringList &args)
|
|
||||||
{
|
|
||||||
if (isRunning()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString err = stubServerListen();
|
|
||||||
if (!err.isEmpty()) {
|
|
||||||
emit processError(msgCommChannelFailed(err));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!environment().isEmpty()) {
|
|
||||||
m_tempFile = new QTemporaryFile();
|
|
||||||
if (!m_tempFile->open()) {
|
|
||||||
stubServerShutdown();
|
|
||||||
emit processError(msgCannotCreateTempFile(m_tempFile->errorString()));
|
|
||||||
delete m_tempFile;
|
|
||||||
m_tempFile = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
foreach(const QString &var, environment()) {
|
|
||||||
m_tempFile->write(var.toLocal8Bit());
|
|
||||||
m_tempFile->write("", 1);
|
|
||||||
}
|
|
||||||
m_tempFile->flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList xtermArgs = terminalEmulator(m_settings).split(QLatin1Char(' ')); // FIXME: quoting
|
|
||||||
xtermArgs
|
|
||||||
#ifdef Q_OS_MAC
|
|
||||||
<< (QCoreApplication::applicationDirPath() + QLatin1String("/../Resources/qtcreator_process_stub"))
|
|
||||||
#else
|
|
||||||
<< (QCoreApplication::applicationDirPath() + QLatin1String("/qtcreator_process_stub"))
|
|
||||||
#endif
|
|
||||||
<< modeOption(m_mode)
|
|
||||||
<< m_stubServer.fullServerName()
|
|
||||||
<< msgPromptToClose()
|
|
||||||
<< workingDirectory()
|
|
||||||
<< (m_tempFile ? m_tempFile->fileName() : 0)
|
|
||||||
<< program << args;
|
|
||||||
|
|
||||||
QString xterm = xtermArgs.takeFirst();
|
|
||||||
m_process.start(xterm, xtermArgs);
|
|
||||||
if (!m_process.waitForStarted()) {
|
|
||||||
stubServerShutdown();
|
|
||||||
emit processError(tr("Cannot start the terminal emulator '%1'.").arg(xterm));
|
|
||||||
delete m_tempFile;
|
|
||||||
m_tempFile = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
m_executable = program;
|
|
||||||
emit wrapperStarted();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConsoleProcess::stop()
|
|
||||||
{
|
|
||||||
if (!isRunning()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
stubServerShutdown();
|
|
||||||
m_appPid = 0;
|
|
||||||
m_process.terminate();
|
|
||||||
if (!m_process.waitForFinished(1000)) {
|
|
||||||
m_process.kill();
|
|
||||||
}
|
|
||||||
m_process.waitForFinished();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ConsoleProcess::isRunning() const
|
|
||||||
{
|
|
||||||
return m_process.state() != QProcess::NotRunning;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ConsoleProcess::stubServerListen()
|
|
||||||
{
|
|
||||||
// We need to put the socket in a private directory, as some systems simply do not
|
|
||||||
// check the file permissions of sockets.
|
|
||||||
QString stubFifoDir;
|
|
||||||
|
|
||||||
forever {
|
|
||||||
{
|
|
||||||
QTemporaryFile tf;
|
|
||||||
if (!tf.open()) {
|
|
||||||
return msgCannotCreateTempFile(tf.errorString());
|
|
||||||
}
|
|
||||||
stubFifoDir = QFile::encodeName(tf.fileName());
|
|
||||||
}
|
|
||||||
// By now the temp file was deleted again
|
|
||||||
m_stubServerDir = QFile::encodeName(stubFifoDir);
|
|
||||||
if (!::mkdir(m_stubServerDir.constData(), 0700)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (errno != EEXIST) {
|
|
||||||
return msgCannotCreateTempDir(stubFifoDir, QString::fromLocal8Bit(strerror(errno)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const QString stubServer = stubFifoDir + "/stub-socket";
|
|
||||||
if (!m_stubServer.listen(stubServer)) {
|
|
||||||
::rmdir(m_stubServerDir.constData());
|
|
||||||
return tr("Cannot create socket '%1': %2").arg(stubServer, m_stubServer.errorString());
|
|
||||||
}
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConsoleProcess::stubServerShutdown()
|
|
||||||
{
|
|
||||||
delete m_stubSocket;
|
|
||||||
m_stubSocket = 0;
|
|
||||||
if (m_stubServer.isListening()) {
|
|
||||||
m_stubServer.close();
|
|
||||||
::rmdir(m_stubServerDir.constData());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConsoleProcess::stubConnectionAvailable()
|
|
||||||
{
|
|
||||||
m_stubSocket = m_stubServer.nextPendingConnection();
|
|
||||||
connect(m_stubSocket, SIGNAL(readyRead()), SLOT(readStubOutput()));
|
|
||||||
}
|
|
||||||
|
|
||||||
static QString errorMsg(int code)
|
|
||||||
{
|
|
||||||
return QString::fromLocal8Bit(strerror(code));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConsoleProcess::readStubOutput()
|
|
||||||
{
|
|
||||||
while (m_stubSocket->canReadLine()) {
|
|
||||||
QByteArray out = m_stubSocket->readLine();
|
|
||||||
out.chop(1); // \n
|
|
||||||
if (out.startsWith("err:chdir ")) {
|
|
||||||
emit processError(msgCannotChangeToWorkDir(workingDirectory(), errorMsg(out.mid(10).toInt())));
|
|
||||||
} else if (out.startsWith("err:exec ")) {
|
|
||||||
emit processError(msgCannotExecute(m_executable, errorMsg(out.mid(9).toInt())));
|
|
||||||
} else if (out.startsWith("pid ")) {
|
|
||||||
// Will not need it any more
|
|
||||||
delete m_tempFile;
|
|
||||||
m_tempFile = 0;
|
|
||||||
|
|
||||||
m_appPid = out.mid(4).toInt();
|
|
||||||
emit processStarted();
|
|
||||||
} else if (out.startsWith("exit ")) {
|
|
||||||
m_appStatus = QProcess::NormalExit;
|
|
||||||
m_appCode = out.mid(5).toInt();
|
|
||||||
m_appPid = 0;
|
|
||||||
emit processStopped();
|
|
||||||
} else if (out.startsWith("crash ")) {
|
|
||||||
m_appStatus = QProcess::CrashExit;
|
|
||||||
m_appCode = out.mid(6).toInt();
|
|
||||||
m_appPid = 0;
|
|
||||||
emit processStopped();
|
|
||||||
} else {
|
|
||||||
emit processError(msgUnexpectedOutput());
|
|
||||||
m_process.terminate();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConsoleProcess::stubExited()
|
|
||||||
{
|
|
||||||
// The stub exit might get noticed before we read the error status.
|
|
||||||
if (m_stubSocket && m_stubSocket->state() == QLocalSocket::ConnectedState) {
|
|
||||||
m_stubSocket->waitForDisconnected();
|
|
||||||
}
|
|
||||||
stubServerShutdown();
|
|
||||||
delete m_tempFile;
|
|
||||||
m_tempFile = 0;
|
|
||||||
if (m_appPid) {
|
|
||||||
m_appStatus = QProcess::CrashExit;
|
|
||||||
m_appCode = -1;
|
|
||||||
m_appPid = 0;
|
|
||||||
emit processStopped(); // Maybe it actually did not, but keep state consistent
|
|
||||||
}
|
|
||||||
emit wrapperStopped();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ConsoleProcess::defaultTerminalEmulator()
|
|
||||||
{
|
|
||||||
// FIXME: enable this once runInTerminal works nicely
|
|
||||||
#if 0 // def Q_OS_MAC
|
|
||||||
return QDir::cleanPath(QCoreApplication::applicationDirPath()
|
|
||||||
+ QLatin1String("/../Resources/runInTerminal.command"));
|
|
||||||
|
|
||||||
#else
|
|
||||||
return QLatin1String("xterm");
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ConsoleProcess::terminalEmulator(const QSettings *settings)
|
|
||||||
{
|
|
||||||
const QString dflt = defaultTerminalEmulator() + QLatin1String(" -e");
|
|
||||||
|
|
||||||
if (!settings) {
|
|
||||||
return dflt;
|
|
||||||
}
|
|
||||||
return settings->value(QLatin1String("General/TerminalEmulator"), dflt).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConsoleProcess::setTerminalEmulator(QSettings *settings, const QString &term)
|
|
||||||
{
|
|
||||||
return settings->setValue(QLatin1String("General/TerminalEmulator"), term);
|
|
||||||
}
|
|
@ -1,265 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
*
|
|
||||||
* @file consoleprocess_win.cpp
|
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
||||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
|
||||||
* @brief
|
|
||||||
* @see The GNU Public License (GPL) Version 3
|
|
||||||
* @defgroup
|
|
||||||
* @{
|
|
||||||
*
|
|
||||||
*****************************************************************************/
|
|
||||||
/*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "consoleprocess.h"
|
|
||||||
#include "winutils.h"
|
|
||||||
|
|
||||||
#include <QtCore/QCoreApplication>
|
|
||||||
#include <QtCore/QDir>
|
|
||||||
#include <QtCore/QTemporaryFile>
|
|
||||||
#include <QtCore/QAbstractEventDispatcher>
|
|
||||||
#include "qwineventnotifier_p.h"
|
|
||||||
|
|
||||||
#include <QtNetwork/QLocalSocket>
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
using namespace Utils;
|
|
||||||
|
|
||||||
ConsoleProcess::ConsoleProcess(QObject *parent) :
|
|
||||||
QObject(parent),
|
|
||||||
m_mode(Run),
|
|
||||||
m_appPid(0),
|
|
||||||
m_stubSocket(0),
|
|
||||||
m_tempFile(0),
|
|
||||||
m_pid(0),
|
|
||||||
m_hInferior(NULL),
|
|
||||||
inferiorFinishedNotifier(0),
|
|
||||||
processFinishedNotifier(0)
|
|
||||||
{
|
|
||||||
connect(&m_stubServer, SIGNAL(newConnection()), SLOT(stubConnectionAvailable()));
|
|
||||||
}
|
|
||||||
|
|
||||||
ConsoleProcess::~ConsoleProcess()
|
|
||||||
{
|
|
||||||
stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ConsoleProcess::start(const QString &program, const QStringList &args)
|
|
||||||
{
|
|
||||||
if (isRunning()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString err = stubServerListen();
|
|
||||||
if (!err.isEmpty()) {
|
|
||||||
emit processError(msgCommChannelFailed(err));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!environment().isEmpty()) {
|
|
||||||
m_tempFile = new QTemporaryFile();
|
|
||||||
if (!m_tempFile->open()) {
|
|
||||||
stubServerShutdown();
|
|
||||||
emit processError(msgCannotCreateTempFile(m_tempFile->errorString()));
|
|
||||||
delete m_tempFile;
|
|
||||||
m_tempFile = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
QTextStream out(m_tempFile);
|
|
||||||
out.setCodec("UTF-16LE");
|
|
||||||
out.setGenerateByteOrderMark(false);
|
|
||||||
foreach(const QString &var, fixWinEnvironment(environment()))
|
|
||||||
out << var << QChar(0);
|
|
||||||
out << QChar(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
STARTUPINFO si;
|
|
||||||
ZeroMemory(&si, sizeof(si));
|
|
||||||
si.cb = sizeof(si);
|
|
||||||
|
|
||||||
m_pid = new PROCESS_INFORMATION;
|
|
||||||
ZeroMemory(m_pid, sizeof(PROCESS_INFORMATION));
|
|
||||||
|
|
||||||
QString workDir = QDir::toNativeSeparators(workingDirectory());
|
|
||||||
if (!workDir.isEmpty() && !workDir.endsWith('\\')) {
|
|
||||||
workDir.append('\\');
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList stubArgs;
|
|
||||||
stubArgs << modeOption(m_mode)
|
|
||||||
<< m_stubServer.fullServerName()
|
|
||||||
<< workDir
|
|
||||||
<< (m_tempFile ? m_tempFile->fileName() : 0)
|
|
||||||
<< createWinCommandline(program, args)
|
|
||||||
<< msgPromptToClose();
|
|
||||||
|
|
||||||
const QString cmdLine = createWinCommandline(
|
|
||||||
QCoreApplication::applicationDirPath() + QLatin1String("/qtcreator_process_stub.exe"), stubArgs);
|
|
||||||
|
|
||||||
bool success = CreateProcessW(0, (WCHAR *)cmdLine.utf16(),
|
|
||||||
0, 0, FALSE, CREATE_NEW_CONSOLE,
|
|
||||||
0, 0,
|
|
||||||
&si, m_pid);
|
|
||||||
|
|
||||||
if (!success) {
|
|
||||||
delete m_pid;
|
|
||||||
m_pid = 0;
|
|
||||||
delete m_tempFile;
|
|
||||||
m_tempFile = 0;
|
|
||||||
stubServerShutdown();
|
|
||||||
emit processError(tr("The process '%1' could not be started: %2").arg(cmdLine, winErrorMessage(GetLastError())));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
processFinishedNotifier = new QWinEventNotifier(m_pid->hProcess, this);
|
|
||||||
connect(processFinishedNotifier, SIGNAL(activated(HANDLE)), SLOT(stubExited()));
|
|
||||||
emit wrapperStarted();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConsoleProcess::stop()
|
|
||||||
{
|
|
||||||
if (m_hInferior != NULL) {
|
|
||||||
TerminateProcess(m_hInferior, (unsigned)-1);
|
|
||||||
cleanupInferior();
|
|
||||||
}
|
|
||||||
if (m_pid) {
|
|
||||||
TerminateProcess(m_pid->hProcess, (unsigned)-1);
|
|
||||||
WaitForSingleObject(m_pid->hProcess, INFINITE);
|
|
||||||
cleanupStub();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ConsoleProcess::isRunning() const
|
|
||||||
{
|
|
||||||
return m_pid != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ConsoleProcess::stubServerListen()
|
|
||||||
{
|
|
||||||
if (m_stubServer.listen(QString::fromLatin1("creator-%1-%2")
|
|
||||||
.arg(QCoreApplication::applicationPid())
|
|
||||||
.arg(rand()))) {
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
return m_stubServer.errorString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConsoleProcess::stubServerShutdown()
|
|
||||||
{
|
|
||||||
delete m_stubSocket;
|
|
||||||
m_stubSocket = 0;
|
|
||||||
if (m_stubServer.isListening()) {
|
|
||||||
m_stubServer.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConsoleProcess::stubConnectionAvailable()
|
|
||||||
{
|
|
||||||
m_stubSocket = m_stubServer.nextPendingConnection();
|
|
||||||
connect(m_stubSocket, SIGNAL(readyRead()), SLOT(readStubOutput()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConsoleProcess::readStubOutput()
|
|
||||||
{
|
|
||||||
while (m_stubSocket->canReadLine()) {
|
|
||||||
QByteArray out = m_stubSocket->readLine();
|
|
||||||
out.chop(2); // \r\n
|
|
||||||
if (out.startsWith("err:chdir ")) {
|
|
||||||
emit processError(msgCannotChangeToWorkDir(workingDirectory(), winErrorMessage(out.mid(10).toInt())));
|
|
||||||
} else if (out.startsWith("err:exec ")) {
|
|
||||||
emit processError(msgCannotExecute(m_executable, winErrorMessage(out.mid(9).toInt())));
|
|
||||||
} else if (out.startsWith("pid ")) {
|
|
||||||
// Wil not need it any more
|
|
||||||
delete m_tempFile;
|
|
||||||
m_tempFile = 0;
|
|
||||||
|
|
||||||
m_appPid = out.mid(4).toInt();
|
|
||||||
m_hInferior = OpenProcess(
|
|
||||||
SYNCHRONIZE | PROCESS_QUERY_INFORMATION | PROCESS_TERMINATE,
|
|
||||||
FALSE, m_appPid);
|
|
||||||
if (m_hInferior == NULL) {
|
|
||||||
emit processError(tr("Cannot obtain a handle to the inferior: %1")
|
|
||||||
.arg(winErrorMessage(GetLastError())));
|
|
||||||
// Uhm, and now what?
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
inferiorFinishedNotifier = new QWinEventNotifier(m_hInferior, this);
|
|
||||||
connect(inferiorFinishedNotifier, SIGNAL(activated(HANDLE)), SLOT(inferiorExited()));
|
|
||||||
emit processStarted();
|
|
||||||
} else {
|
|
||||||
emit processError(msgUnexpectedOutput());
|
|
||||||
TerminateProcess(m_pid->hProcess, (unsigned)-1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConsoleProcess::cleanupInferior()
|
|
||||||
{
|
|
||||||
delete inferiorFinishedNotifier;
|
|
||||||
inferiorFinishedNotifier = 0;
|
|
||||||
CloseHandle(m_hInferior);
|
|
||||||
m_hInferior = NULL;
|
|
||||||
m_appPid = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConsoleProcess::inferiorExited()
|
|
||||||
{
|
|
||||||
DWORD chldStatus;
|
|
||||||
|
|
||||||
if (!GetExitCodeProcess(m_hInferior, &chldStatus)) {
|
|
||||||
emit processError(tr("Cannot obtain exit status from inferior: %1")
|
|
||||||
.arg(winErrorMessage(GetLastError())));
|
|
||||||
}
|
|
||||||
cleanupInferior();
|
|
||||||
m_appStatus = QProcess::NormalExit;
|
|
||||||
m_appCode = chldStatus;
|
|
||||||
emit processStopped();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConsoleProcess::cleanupStub()
|
|
||||||
{
|
|
||||||
stubServerShutdown();
|
|
||||||
delete processFinishedNotifier;
|
|
||||||
processFinishedNotifier = 0;
|
|
||||||
CloseHandle(m_pid->hThread);
|
|
||||||
CloseHandle(m_pid->hProcess);
|
|
||||||
delete m_pid;
|
|
||||||
m_pid = 0;
|
|
||||||
delete m_tempFile;
|
|
||||||
m_tempFile = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConsoleProcess::stubExited()
|
|
||||||
{
|
|
||||||
// The stub exit might get noticed before we read the pid for the kill.
|
|
||||||
if (m_stubSocket && m_stubSocket->state() == QLocalSocket::ConnectedState) {
|
|
||||||
m_stubSocket->waitForDisconnected();
|
|
||||||
}
|
|
||||||
cleanupStub();
|
|
||||||
if (m_hInferior != NULL) {
|
|
||||||
TerminateProcess(m_hInferior, (unsigned)-1);
|
|
||||||
cleanupInferior();
|
|
||||||
m_appStatus = QProcess::CrashExit;
|
|
||||||
m_appCode = -1;
|
|
||||||
emit processStopped();
|
|
||||||
}
|
|
||||||
emit wrapperStopped();
|
|
||||||
}
|
|
264
ground/gcs/src/libs/utils/settingsutils.cpp
Normal file
264
ground/gcs/src/libs/utils/settingsutils.cpp
Normal file
@ -0,0 +1,264 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file settingsutils.cpp
|
||||||
|
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
|
||||||
|
* @brief Settings utilities
|
||||||
|
*
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "settingsutils.h"
|
||||||
|
|
||||||
|
#include "pathutils.h"
|
||||||
|
#include "xmlconfig.h"
|
||||||
|
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
|
namespace Utils {
|
||||||
|
static const QString DEFAULT_CONFIG_DIRNAME = "configurations";
|
||||||
|
|
||||||
|
static const QString DEFAULT_CONFIG_FILENAME = "default.xml";
|
||||||
|
|
||||||
|
const QLatin1String CONFIG_OPTION("-D");
|
||||||
|
|
||||||
|
// list of read only QSettings objects containing factory defaults
|
||||||
|
QList<QSettings const *> factorySettingsList;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Helper class to manage a simple registry
|
||||||
|
* Each entry in the registry is a configuration path
|
||||||
|
* For example : UAVGadgetConfigurations/DialGadget/Attitude
|
||||||
|
* Note that entries are base64 encoded so QSettings does not mess with them
|
||||||
|
*/
|
||||||
|
class QTCREATOR_UTILS_EXPORT Registry {
|
||||||
|
public:
|
||||||
|
Registry()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
|
settings.beginGroup("Registry");
|
||||||
|
registry = settings.childKeys();
|
||||||
|
settings.endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void save() const
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
|
settings.beginGroup("Registry");
|
||||||
|
settings.remove("");
|
||||||
|
foreach(QString entry, registry) {
|
||||||
|
settings.setValue(entry, 1);
|
||||||
|
}
|
||||||
|
settings.endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool contains(QString &entry) const
|
||||||
|
{
|
||||||
|
return registry.contains(key(entry));
|
||||||
|
}
|
||||||
|
|
||||||
|
void add(QString &entry)
|
||||||
|
{
|
||||||
|
registry.append(key(entry));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QStringList registry;
|
||||||
|
|
||||||
|
QString key(QString &entry) const
|
||||||
|
{
|
||||||
|
return entry.toUtf8().toBase64();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
QString checkFile(QString fileName)
|
||||||
|
{
|
||||||
|
if (!fileName.isEmpty()) {
|
||||||
|
QFileInfo fi(fileName);
|
||||||
|
if (fi.isRelative()) {
|
||||||
|
// file name has a relative path
|
||||||
|
QDir directory(Utils::GetDataPath() + QString("configurations"));
|
||||||
|
fileName = directory.absoluteFilePath(fileName);
|
||||||
|
}
|
||||||
|
if (!QFile::exists(fileName)) {
|
||||||
|
qWarning() << "Configuration file" << fileName << "does not exist.";
|
||||||
|
fileName = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Func>
|
||||||
|
void applyToFactorySettings(Func func)
|
||||||
|
{
|
||||||
|
foreach(QSettings const *settings, factorySettingsList) {
|
||||||
|
func(*settings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void copySettings(const QSettings &from, QSettings &to)
|
||||||
|
{
|
||||||
|
foreach(QString key, from.allKeys()) {
|
||||||
|
if (!to.contains(key)) {
|
||||||
|
// qDebug() << "++" << key << from.value(key);
|
||||||
|
to.setValue(key, from.value(key));
|
||||||
|
} else if (from.value(key) != to.value(key)) {
|
||||||
|
// qDebug() << ">>" << key << from.value(key) << to.value(key);
|
||||||
|
to.setValue(key, from.value(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void mergeSettings(Registry ®istry, const QSettings &from, QSettings &to)
|
||||||
|
{
|
||||||
|
to.beginGroup(from.group());
|
||||||
|
|
||||||
|
// iterate over factory defaults groups
|
||||||
|
// note that merging could be done in smarter way
|
||||||
|
// currently we do a "all or nothing" merge but we could do something more granular
|
||||||
|
// this, would allow, new configuration options to be added to existing configurations
|
||||||
|
foreach(QString group, from.childGroups()) {
|
||||||
|
const_cast<QSettings &>(from).beginGroup(group);
|
||||||
|
to.beginGroup(group);
|
||||||
|
QString id = from.group();
|
||||||
|
if (!registry.contains(id)) {
|
||||||
|
// registry keeps growing...
|
||||||
|
registry.add(id);
|
||||||
|
// copy settings only if destination group is totally empty (see comment above)
|
||||||
|
if (to.allKeys().count() <= 0 && to.childGroups().count() <= 0) {
|
||||||
|
// found new group, copy it to the destination
|
||||||
|
qDebug() << "settings - adding new configuration" << id;
|
||||||
|
copySettings(from, to);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
to.endGroup();
|
||||||
|
const_cast<QSettings &>(from).endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
to.endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void mergeFactorySettings(Registry ®istry, const QSettings &from, QSettings &to)
|
||||||
|
{
|
||||||
|
const_cast<QSettings &>(from).beginGroup("Plugins");
|
||||||
|
mergeSettings(registry, from, to);
|
||||||
|
const_cast<QSettings &>(from).endGroup();
|
||||||
|
|
||||||
|
const_cast<QSettings &>(from).beginGroup("UAVGadgetConfigurations");
|
||||||
|
foreach(QString childGroup, from.childGroups()) {
|
||||||
|
const_cast<QSettings &>(from).beginGroup(childGroup);
|
||||||
|
mergeSettings(registry, from, to);
|
||||||
|
const_cast<QSettings &>(from).endGroup();
|
||||||
|
}
|
||||||
|
const_cast<QSettings &>(from).endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void initSettings(const QString &factoryDefaultsFileName)
|
||||||
|
{
|
||||||
|
QSettings::setDefaultFormat(XmlConfig::XmlFormat);
|
||||||
|
|
||||||
|
QDir directory(Utils::GetDataPath() + DEFAULT_CONFIG_DIRNAME);
|
||||||
|
|
||||||
|
// check if command line option -config-file contains a file name
|
||||||
|
QString fileName = checkFile(factoryDefaultsFileName);
|
||||||
|
|
||||||
|
if (fileName.isEmpty()) {
|
||||||
|
// check default file
|
||||||
|
qDebug() << "settings - looking for factory defaults configuration files in" << directory.absolutePath();
|
||||||
|
fileName = checkFile(directory.absoluteFilePath(DEFAULT_CONFIG_FILENAME));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fileName.isEmpty()) {
|
||||||
|
// TODO should we exit violently?
|
||||||
|
qCritical() << "No default configuration file found!";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList files;
|
||||||
|
|
||||||
|
// common default
|
||||||
|
files << fileName;
|
||||||
|
|
||||||
|
// OS specific default
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
files << directory.absoluteFilePath("default_macos.xml");
|
||||||
|
#elif defined(Q_OS_LINUX)
|
||||||
|
files << directory.absoluteFilePath("default_linux.xml");
|
||||||
|
#else
|
||||||
|
files << directory.absoluteFilePath("default_windows.xml");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
foreach(QString file, files) {
|
||||||
|
file = checkFile(file);
|
||||||
|
if (!file.isEmpty()) {
|
||||||
|
QSettings const *settings = new QSettings(file, XmlConfig::XmlFormat);
|
||||||
|
qDebug() << "settings - loaded factory defaults" << file;
|
||||||
|
factorySettingsList.append(settings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void overrideSettings(QSettings &settings, int argc, char * *argv)
|
||||||
|
{
|
||||||
|
// Options like -D My/setting=test
|
||||||
|
QRegExp rx("([^=]+)=(.*)");
|
||||||
|
|
||||||
|
for (int i = 0; i < argc; ++i) {
|
||||||
|
if (CONFIG_OPTION == QString(argv[i])) {
|
||||||
|
if (rx.indexIn(argv[++i]) > -1) {
|
||||||
|
QString key = rx.cap(1);
|
||||||
|
QString value = rx.cap(2);
|
||||||
|
qDebug() << "settings - user setting" << key << "set to value" << value;
|
||||||
|
settings.setValue(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void resetToFactoryDefaults(QSettings &toSettings)
|
||||||
|
{
|
||||||
|
toSettings.clear();
|
||||||
|
applyToFactorySettings(
|
||||||
|
[&](const QSettings &fromSettings) { copySettings(fromSettings, toSettings); }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merge factory defaults into user settings.
|
||||||
|
* Currently only Plugins and UAVGadgetConfigurations are merged
|
||||||
|
*/
|
||||||
|
void mergeFactoryDefaults(QSettings &toSettings)
|
||||||
|
{
|
||||||
|
// registry of all configuration groups ever seen
|
||||||
|
// used to avoid re-adding a group that was deleted by the user
|
||||||
|
Registry registry;
|
||||||
|
|
||||||
|
// merge all loaded factory defaults
|
||||||
|
applyToFactorySettings(
|
||||||
|
[&](const QSettings &fromSettings) { mergeFactorySettings(registry, fromSettings, toSettings); }
|
||||||
|
);
|
||||||
|
|
||||||
|
registry.save();
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file winutils.h
|
* @file settingsutils.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
|
||||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
@ -26,18 +26,19 @@
|
|||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef WINUTILS_H
|
#ifndef SETTINGS_UTILS_H
|
||||||
#define WINUTILS_H
|
#define SETTINGS_UTILS_H
|
||||||
|
|
||||||
#include "utils_global.h"
|
#include "utils_global.h"
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
#include <QString>
|
||||||
class QString;
|
#include <QSettings>
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
// Helper to format a Windows error message, taking the
|
QTCREATOR_UTILS_EXPORT void initSettings(const QString &factoryDefaultsFileName);
|
||||||
// code as returned by the GetLastError()-API.
|
QTCREATOR_UTILS_EXPORT void overrideSettings(QSettings &settings, int argc, char * *argv);
|
||||||
QTCREATOR_UTILS_EXPORT QString winErrorMessage(unsigned long error);
|
QTCREATOR_UTILS_EXPORT void resetToFactoryDefaults(QSettings &settings);
|
||||||
} // namespace Utils
|
QTCREATOR_UTILS_EXPORT void mergeFactoryDefaults(QSettings &settings);
|
||||||
#endif // WINUTILS_H
|
}
|
||||||
|
|
||||||
|
#endif /* SETTINGS_UTILS_H */
|
@ -18,7 +18,6 @@ SOURCES += \
|
|||||||
linecolumnlabel.cpp \
|
linecolumnlabel.cpp \
|
||||||
qtcolorbutton.cpp \
|
qtcolorbutton.cpp \
|
||||||
synchronousprocess.cpp \
|
synchronousprocess.cpp \
|
||||||
consoleprocess.cpp \
|
|
||||||
treewidgetcolumnstretcher.cpp \
|
treewidgetcolumnstretcher.cpp \
|
||||||
checkablemessagebox.cpp \
|
checkablemessagebox.cpp \
|
||||||
styledbar.cpp \
|
styledbar.cpp \
|
||||||
@ -29,6 +28,7 @@ SOURCES += \
|
|||||||
detailswidget.cpp \
|
detailswidget.cpp \
|
||||||
coordinateconversions.cpp \
|
coordinateconversions.cpp \
|
||||||
pathutils.cpp \
|
pathutils.cpp \
|
||||||
|
settingsutils.cpp \
|
||||||
worldmagmodel.cpp \
|
worldmagmodel.cpp \
|
||||||
homelocationutil.cpp \
|
homelocationutil.cpp \
|
||||||
mytabbedstackwidget.cpp \
|
mytabbedstackwidget.cpp \
|
||||||
@ -39,18 +39,8 @@ SOURCES += \
|
|||||||
logfile.cpp \
|
logfile.cpp \
|
||||||
crc.cpp \
|
crc.cpp \
|
||||||
mustache.cpp \
|
mustache.cpp \
|
||||||
textbubbleslider.cpp
|
textbubbleslider.cpp \
|
||||||
|
xmlconfig.cpp
|
||||||
SOURCES += xmlconfig.cpp
|
|
||||||
|
|
||||||
win32 {
|
|
||||||
SOURCES += \
|
|
||||||
abstractprocess_win.cpp \
|
|
||||||
consoleprocess_win.cpp \
|
|
||||||
winutils.cpp
|
|
||||||
HEADERS += winutils.h
|
|
||||||
}
|
|
||||||
else:SOURCES += consoleprocess_unix.cpp
|
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
utils_global.h \
|
utils_global.h \
|
||||||
@ -74,6 +64,7 @@ HEADERS += \
|
|||||||
detailswidget.h \
|
detailswidget.h \
|
||||||
coordinateconversions.h \
|
coordinateconversions.h \
|
||||||
pathutils.h \
|
pathutils.h \
|
||||||
|
settingsutils.h \
|
||||||
worldmagmodel.h \
|
worldmagmodel.h \
|
||||||
homelocationutil.h \
|
homelocationutil.h \
|
||||||
mytabbedstackwidget.h \
|
mytabbedstackwidget.h \
|
||||||
@ -85,9 +76,8 @@ HEADERS += \
|
|||||||
crc.h \
|
crc.h \
|
||||||
mustache.h \
|
mustache.h \
|
||||||
textbubbleslider.h \
|
textbubbleslider.h \
|
||||||
filelogger.h
|
filelogger.h \
|
||||||
|
xmlconfig.h
|
||||||
HEADERS += xmlconfig.h
|
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
checkablemessagebox.ui
|
checkablemessagebox.ui
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
*
|
|
||||||
* @file winutils.cpp
|
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
||||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
|
||||||
* @brief
|
|
||||||
* @see The GNU Public License (GPL) Version 3
|
|
||||||
* @defgroup
|
|
||||||
* @{
|
|
||||||
*
|
|
||||||
*****************************************************************************/
|
|
||||||
/*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "winutils.h"
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#include <QtCore/QString>
|
|
||||||
|
|
||||||
namespace Utils {
|
|
||||||
QTCREATOR_UTILS_EXPORT QString winErrorMessage(unsigned long error)
|
|
||||||
{
|
|
||||||
QString rc = QString::fromLatin1("#%1: ").arg(error);
|
|
||||||
ushort *lpMsgBuf;
|
|
||||||
|
|
||||||
const int len = FormatMessage(
|
|
||||||
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
|
||||||
NULL, error, 0, (LPTSTR)&lpMsgBuf, 0, NULL);
|
|
||||||
|
|
||||||
if (len) {
|
|
||||||
rc = QString::fromUtf16(lpMsgBuf, len);
|
|
||||||
LocalFree(lpMsgBuf);
|
|
||||||
} else {
|
|
||||||
rc += QString::fromLatin1("<unknown error>");
|
|
||||||
}
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
} // namespace Utils
|
|
@ -2,13 +2,14 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file xmlconfig.cpp
|
* @file xmlconfig.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
|
||||||
|
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @brief Widget for Import/Export Plugin
|
* @brief Widget for Import/Export Plugin
|
||||||
* @addtogroup GCSPlugins GCS Plugins
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
* @{
|
* @{
|
||||||
* @addtogroup importexportplugin
|
* @addtogroup utils
|
||||||
* @{
|
* @{
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
@ -30,24 +31,24 @@
|
|||||||
/* Nokia Corporation */
|
/* Nokia Corporation */
|
||||||
#include "xmlconfig.h"
|
#include "xmlconfig.h"
|
||||||
|
|
||||||
#include <QtDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
|
#include <QDataStream>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QRect>
|
#include <QRect>
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QtCore/QUrl>
|
#include <QUrl>
|
||||||
|
#include <QDomElement>
|
||||||
|
|
||||||
#define NUM_PREFIX "arr_"
|
#define NUM_PREFIX "arr_"
|
||||||
|
|
||||||
QString XmlConfig::rootName = "gcs";
|
const QString XmlConfig::RootName = "gcs";
|
||||||
|
|
||||||
const QSettings::Format XmlConfig::XmlSettingsFormat =
|
const QSettings::Format XmlConfig::XmlFormat =
|
||||||
QSettings::registerFormat("xml", XmlConfig::readXmlFile, XmlConfig::writeXmlFile);
|
QSettings::registerFormat("xml", XmlConfig::readXmlFile, XmlConfig::writeXmlFile);
|
||||||
|
|
||||||
|
|
||||||
bool XmlConfig::readXmlFile(QIODevice &device, QSettings::SettingsMap &map)
|
bool XmlConfig::readXmlFile(QIODevice &device, QSettings::SettingsMap &map)
|
||||||
{
|
{
|
||||||
QDomDocument domDoc;
|
QDomDocument domDoc;
|
||||||
@ -90,7 +91,7 @@ void XmlConfig::handleNode(QDomElement *node, QSettings::SettingsMap &map, QStri
|
|||||||
nodeName = nodeName.replace("__PCT__", "%");
|
nodeName = nodeName.replace("__PCT__", "%");
|
||||||
nodeName = QUrl::fromPercentEncoding(nodeName.toLatin1());
|
nodeName = QUrl::fromPercentEncoding(nodeName.toLatin1());
|
||||||
|
|
||||||
if (nodeName == XmlConfig::rootName) {
|
if (nodeName == XmlConfig::RootName) {
|
||||||
;
|
;
|
||||||
} else if (path == "") {
|
} else if (path == "") {
|
||||||
path = nodeName;
|
path = nodeName;
|
||||||
@ -98,31 +99,31 @@ void XmlConfig::handleNode(QDomElement *node, QSettings::SettingsMap &map, QStri
|
|||||||
path += "/" + nodeName;
|
path += "/" + nodeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
// qDebug() << "Node: " << ": " << path << " Children: " << node->childNodes().length();
|
// qDebug() << "Node: " << ": " << path << " Children: " << node->childNodes().length();
|
||||||
for (int i = 0; i < node->childNodes().length(); ++i) {
|
for (int i = 0; i < node->childNodes().length(); ++i) {
|
||||||
QDomNode child = node->childNodes().item(i);
|
QDomNode child = node->childNodes().item(i);
|
||||||
if (child.isElement()) {
|
if (child.isElement()) {
|
||||||
handleNode(static_cast<QDomElement *>(&child), map, path);
|
handleNode(static_cast<QDomElement *>(&child), map, path);
|
||||||
} else if (child.isText()) {
|
} else if (child.isText()) {
|
||||||
// qDebug() << "Key: " << path << " Value:" << node->text();
|
// qDebug() << "Key: " << path << " Value:" << node->text();
|
||||||
map.insert(path, stringToVariant(node->text()));
|
map.insert(path, stringToVariant(node->text()));
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Child not Element or text!" << child.nodeType();
|
qDebug() << "Child not Element or text!" << child.nodeType();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// qDebug() << "XmlConfig::handleNode end";
|
// qDebug() << "XmlConfig::handleNode end";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XmlConfig::writeXmlFile(QIODevice &device, const QSettings::SettingsMap &map)
|
bool XmlConfig::writeXmlFile(QIODevice &device, const QSettings::SettingsMap &map)
|
||||||
{
|
{
|
||||||
QDomDocument outDocument;
|
QDomDocument outDocument;
|
||||||
|
|
||||||
// qDebug() << "writeXmlFile start";
|
// qDebug() << "writeXmlFile start";
|
||||||
outDocument.appendChild(outDocument.createElement(XmlConfig::rootName));
|
outDocument.appendChild(outDocument.createElement(XmlConfig::RootName));
|
||||||
QMapIterator<QString, QVariant> iter(map);
|
QMapIterator<QString, QVariant> iter(map);
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
iter.next();
|
iter.next();
|
||||||
// qDebug() << "Entry: " << iter.key() << ": " << iter.value().toString() << endl;
|
// qDebug() << "Entry: " << iter.key() << ": " << iter.value().toString() << endl;
|
||||||
QDomNode node = outDocument.firstChild();
|
QDomNode node = outDocument.firstChild();
|
||||||
foreach(QString elem, iter.key().split('/')) {
|
foreach(QString elem, iter.key().split('/')) {
|
||||||
if (elem == "") {
|
if (elem == "") {
|
||||||
@ -149,27 +150,11 @@ bool XmlConfig::writeXmlFile(QIODevice &device, const QSettings::SettingsMap &ma
|
|||||||
node.appendChild(outDocument.createTextNode(variantToString(iter.value())));
|
node.appendChild(outDocument.createTextNode(variantToString(iter.value())));
|
||||||
}
|
}
|
||||||
device.write(outDocument.toByteArray(2).constData());
|
device.write(outDocument.toByteArray(2).constData());
|
||||||
// qDebug() << "Dokument:\n" << outDocument.toByteArray(2).constData();
|
// qDebug() << "Document:\n" << outDocument.toByteArray(2).constData();
|
||||||
// qDebug() << "writeXmlFile end";
|
// qDebug() << "writeXmlFile end";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QSettings::SettingsMap XmlConfig::settingsToMap(QSettings & qs)
|
|
||||||
{
|
|
||||||
qDebug() << "settingsToMap:---------------";
|
|
||||||
QSettings::SettingsMap map;
|
|
||||||
QStringList keys = qs.allKeys();
|
|
||||||
foreach(QString key, keys) {
|
|
||||||
QVariant val = qs.value(key);
|
|
||||||
|
|
||||||
qDebug() << key << val.toString();
|
|
||||||
map.insert(key, val);
|
|
||||||
}
|
|
||||||
qDebug() << "settingsToMap End --------";
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString XmlConfig::variantToString(const QVariant &v)
|
QString XmlConfig::variantToString(const QVariant &v)
|
||||||
{
|
{
|
||||||
QString result;
|
QString result;
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
* @file
|
*
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @file xmlconfig.h
|
||||||
|
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016.
|
||||||
|
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @addtogroup GCSPlugins GCS Plugins
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
* @{
|
* @{
|
||||||
* @addtogroup importexportplugin
|
* @addtogroup utils
|
||||||
* @{
|
* @{
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
/*
|
/*
|
||||||
@ -34,29 +36,29 @@
|
|||||||
|
|
||||||
#include <QtCore/qglobal.h>
|
#include <QtCore/qglobal.h>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QDomElement>
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QDataStream>
|
|
||||||
|
class QDomElement;
|
||||||
|
|
||||||
class XMLCONFIG_EXPORT XmlConfig : QObject {
|
class XMLCONFIG_EXPORT XmlConfig : QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static const QSettings::Format XmlSettingsFormat;
|
static const QSettings::Format XmlFormat;
|
||||||
|
|
||||||
static bool readXmlFile(QIODevice &device, QSettings::SettingsMap &map);
|
static bool readXmlFile(QIODevice &device, QSettings::SettingsMap &map);
|
||||||
static bool writeXmlFile(QIODevice &device, const QSettings::SettingsMap &map);
|
static bool writeXmlFile(QIODevice &device, const QSettings::SettingsMap &map);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QString rootName;
|
static const QString RootName;
|
||||||
|
|
||||||
static void handleNode(QDomElement *node, QSettings::SettingsMap &map, QString path = "");
|
static void handleNode(QDomElement *node, QSettings::SettingsMap &map, QString path = "");
|
||||||
static QSettings::SettingsMap settingsToMap(QSettings & qs);
|
|
||||||
static QString variantToString(const QVariant &v);
|
static QString variantToString(const QVariant &v);
|
||||||
static QVariant stringToVariant(const QString &s);
|
static QVariant stringToVariant(const QString &s);
|
||||||
static QStringList splitArgs(const QString &s, int idx);
|
static QStringList splitArgs(const QString &s, int idx);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // XMLCONFIG_H
|
#endif // XMLCONFIG_H
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
* @}
|
* @}
|
||||||
|
@ -26,83 +26,59 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "antennatrackgadgetconfiguration.h"
|
#include "antennatrackgadgetconfiguration.h"
|
||||||
|
|
||||||
#include <QtSerialPort/QSerialPort>
|
#include <QtSerialPort/QSerialPort>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a saved configuration or defaults if non exist.
|
* Loads a saved configuration or defaults if non exist.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
AntennaTrackGadgetConfiguration::AntennaTrackGadgetConfiguration(QString classId, QSettings *qSettings, QObject *parent) :
|
AntennaTrackGadgetConfiguration::AntennaTrackGadgetConfiguration(QString classId, QSettings &settings, QObject *parent) :
|
||||||
IUAVGadgetConfiguration(classId, 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)
|
|
||||||
{
|
{
|
||||||
// if a saved configuration exists load it
|
m_defaultPort = settings.value("defaultPort", "Unknown").toString();
|
||||||
if (qSettings != 0) {
|
m_defaultSpeed = (QSerialPort::BaudRate)settings.value("defaultSpeed", QSerialPort::UnknownBaud).toInt();
|
||||||
QSerialPort::BaudRate speed;
|
m_defaultDataBits = (QSerialPort::DataBits)settings.value("defaultDataBits", QSerialPort::UnknownDataBits).toInt();
|
||||||
QSerialPort::DataBits databits;
|
m_defaultFlow = (QSerialPort::FlowControl)settings.value("defaultFlow", QSerialPort::UnknownFlowControl).toInt();
|
||||||
QSerialPort::FlowControl flow;
|
m_defaultParity = (QSerialPort::Parity)settings.value("defaultParity", QSerialPort::UnknownParity).toInt();
|
||||||
QSerialPort::Parity parity;
|
m_defaultStopBits = (QSerialPort::StopBits)settings.value("defaultStopBits", QSerialPort::UnknownStopBits).toInt();
|
||||||
QSerialPort::StopBits stopbits;
|
m_connectionMode = (QSerialPort::BaudRate)settings.value("connectionMode", "Serial").toString();
|
||||||
|
m_defaultTimeOut = 5000;
|
||||||
|
}
|
||||||
|
|
||||||
int ispeed = qSettings->value("defaultSpeed").toInt();
|
AntennaTrackGadgetConfiguration::AntennaTrackGadgetConfiguration(const AntennaTrackGadgetConfiguration &obj) :
|
||||||
int idatabits = qSettings->value("defaultDataBits").toInt();
|
IUAVGadgetConfiguration(obj.classId(), obj.parent())
|
||||||
int iflow = qSettings->value("defaultFlow").toInt();
|
{
|
||||||
int iparity = qSettings->value("defaultParity").toInt();
|
m_defaultSpeed = obj.m_defaultSpeed;
|
||||||
int istopbits = qSettings->value("defaultStopBits").toInt();
|
m_defaultDataBits = obj.m_defaultDataBits;
|
||||||
QString port = qSettings->value("defaultPort").toString();
|
m_defaultFlow = obj.m_defaultFlow;
|
||||||
QString conMode = qSettings->value("connectionMode").toString();
|
m_defaultParity = obj.m_defaultParity;
|
||||||
|
m_defaultStopBits = obj.m_defaultStopBits;
|
||||||
databits = (QSerialPort::DataBits)idatabits;
|
m_defaultPort = obj.m_defaultPort;
|
||||||
flow = (QSerialPort::FlowControl)iflow;
|
m_connectionMode = obj.m_connectionMode;
|
||||||
parity = (QSerialPort::Parity)iparity;
|
m_defaultTimeOut = obj.m_defaultTimeOut;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clones a configuration.
|
* Clones a configuration.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
IUAVGadgetConfiguration *AntennaTrackGadgetConfiguration::clone()
|
IUAVGadgetConfiguration *AntennaTrackGadgetConfiguration::clone() const
|
||||||
{
|
{
|
||||||
AntennaTrackGadgetConfiguration *m = new AntennaTrackGadgetConfiguration(this->classId());
|
return new AntennaTrackGadgetConfiguration(*this);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves a configuration.
|
* Saves a configuration.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void AntennaTrackGadgetConfiguration::saveConfig(QSettings *settings) const
|
void AntennaTrackGadgetConfiguration::saveConfig(QSettings &settings) const
|
||||||
{
|
{
|
||||||
settings->setValue("defaultSpeed", m_defaultSpeed);
|
settings.setValue("defaultSpeed", m_defaultSpeed);
|
||||||
settings->setValue("defaultDataBits", m_defaultDataBits);
|
settings.setValue("defaultDataBits", m_defaultDataBits);
|
||||||
settings->setValue("defaultFlow", m_defaultFlow);
|
settings.setValue("defaultFlow", m_defaultFlow);
|
||||||
settings->setValue("defaultParity", m_defaultParity);
|
settings.setValue("defaultParity", m_defaultParity);
|
||||||
settings->setValue("defaultStopBits", m_defaultStopBits);
|
settings.setValue("defaultStopBits", m_defaultStopBits);
|
||||||
settings->setValue("defaultPort", m_defaultPort);
|
settings.setValue("defaultPort", m_defaultPort);
|
||||||
settings->setValue("connectionMode", m_connectionMode);
|
settings.setValue("connectionMode", m_connectionMode);
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#define ANTENNATRACKGADGETCONFIGURATION_H
|
#define ANTENNATRACKGADGETCONFIGURATION_H
|
||||||
|
|
||||||
#include <coreplugin/iuavgadgetconfiguration.h>
|
#include <coreplugin/iuavgadgetconfiguration.h>
|
||||||
|
|
||||||
#include <QtSerialPort/QSerialPort>
|
#include <QtSerialPort/QSerialPort>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
@ -45,11 +46,14 @@ struct PortSettings {
|
|||||||
long Timeout_Millisec;
|
long Timeout_Millisec;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class AntennaTrackGadgetConfiguration : public IUAVGadgetConfiguration {
|
class AntennaTrackGadgetConfiguration : public IUAVGadgetConfiguration {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
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)
|
void setConnectionMode(QString mode)
|
||||||
{
|
{
|
||||||
@ -59,7 +63,6 @@ public:
|
|||||||
{
|
{
|
||||||
return m_connectionMode;
|
return m_connectionMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set port configuration functions
|
// set port configuration functions
|
||||||
void setSpeed(QSerialPort::BaudRate speed)
|
void setSpeed(QSerialPort::BaudRate speed)
|
||||||
{
|
{
|
||||||
@ -120,9 +123,6 @@ public:
|
|||||||
return m_defaultTimeOut;
|
return m_defaultTimeOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveConfig(QSettings *settings) const;
|
|
||||||
IUAVGadgetConfiguration *clone();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_connectionMode;
|
QString m_connectionMode;
|
||||||
QString m_defaultPort;
|
QString m_defaultPort;
|
||||||
|
@ -47,9 +47,9 @@ Core::IUAVGadget *AntennaTrackGadgetFactory::createGadget(QWidget *parent)
|
|||||||
return new AntennaTrackGadget(QString("AntennaTrackGadget"), gadgetWidget, 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)
|
IOptionsPage *AntennaTrackGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||||
|
@ -44,7 +44,7 @@ public:
|
|||||||
~AntennaTrackGadgetFactory();
|
~AntennaTrackGadgetFactory();
|
||||||
|
|
||||||
Core::IUAVGadget *createGadget(QWidget *parent);
|
Core::IUAVGadget *createGadget(QWidget *parent);
|
||||||
IUAVGadgetConfiguration *createConfiguration(QSettings *qSettings);
|
IUAVGadgetConfiguration *createConfiguration(QSettings &settings);
|
||||||
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,12 +45,12 @@ void ConfigGadget::loadConfiguration(IUAVGadgetConfiguration *config)
|
|||||||
Q_UNUSED(config);
|
Q_UNUSED(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigGadget::saveState(QSettings *settings)
|
void ConfigGadget::saveState(QSettings &settings) const
|
||||||
{
|
{
|
||||||
m_widget->saveState(settings);
|
m_widget->saveState(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigGadget::restoreState(QSettings *settings)
|
void ConfigGadget::restoreState(QSettings &settings)
|
||||||
{
|
{
|
||||||
m_widget->restoreState(settings);
|
m_widget->restoreState(settings);
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,8 @@ public:
|
|||||||
|
|
||||||
void loadConfiguration(IUAVGadgetConfiguration *config);
|
void loadConfiguration(IUAVGadgetConfiguration *config);
|
||||||
|
|
||||||
void saveState(QSettings *settings);
|
void saveState(QSettings &settings) const;
|
||||||
void restoreState(QSettings *settings);
|
void restoreState(QSettings &settings);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ConfigGadgetWidget *m_widget;
|
ConfigGadgetWidget *m_widget;
|
||||||
|
@ -180,14 +180,14 @@ void ConfigGadgetWidget::startInputWizard()
|
|||||||
inputWidget->startInputWizard();
|
inputWidget->startInputWizard();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigGadgetWidget::saveState(QSettings *settings)
|
void ConfigGadgetWidget::saveState(QSettings &settings) const
|
||||||
{
|
{
|
||||||
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);
|
stackWidget->setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,8 @@ public:
|
|||||||
|
|
||||||
void startInputWizard();
|
void startInputWizard();
|
||||||
|
|
||||||
void saveState(QSettings *settings);
|
void saveState(QSettings &settings) const;
|
||||||
void restoreState(QSettings *settings);
|
void restoreState(QSettings &settings);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
|
@ -481,14 +481,14 @@ static const char *settingsGroup = "KeyBindings";
|
|||||||
static const char *idKey = "ID";
|
static const char *idKey = "ID";
|
||||||
static const char *sequenceKey = "Keysequence";
|
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) {
|
for (int i = 0; i < shortcuts; ++i) {
|
||||||
settings->setArrayIndex(i);
|
settings.setArrayIndex(i);
|
||||||
const QString sid = settings->value(QLatin1String(idKey)).toString();
|
const QString sid = settings.value(QLatin1String(idKey)).toString();
|
||||||
const QKeySequence key(settings->value(QLatin1String(sequenceKey)).toString());
|
const QKeySequence key(settings.value(QLatin1String(sequenceKey)).toString());
|
||||||
const int id = UniqueIDManager::instance()->uniqueIdentifier(sid);
|
const int id = UniqueIDManager::instance()->uniqueIdentifier(sid);
|
||||||
|
|
||||||
Command *cmd = command(id);
|
Command *cmd = command(id);
|
||||||
@ -496,12 +496,12 @@ void ActionManagerPrivate::readSettings(QSettings *settings)
|
|||||||
cmd->setKeySequence(key);
|
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;
|
int count = 0;
|
||||||
|
|
||||||
const IdCmdMap::const_iterator cmdcend = m_idCmdMap.constEnd();
|
const IdCmdMap::const_iterator cmdcend = m_idCmdMap.constEnd();
|
||||||
@ -511,12 +511,12 @@ void ActionManagerPrivate::saveSettings(QSettings *settings)
|
|||||||
QKeySequence key = cmd->keySequence();
|
QKeySequence key = cmd->keySequence();
|
||||||
if (key != cmd->defaultKeySequence()) {
|
if (key != cmd->defaultKeySequence()) {
|
||||||
const QString sid = UniqueIDManager::instance()->stringForUniqueIdentifier(id);
|
const QString sid = UniqueIDManager::instance()->stringForUniqueIdentifier(id);
|
||||||
settings->setArrayIndex(count);
|
settings.setArrayIndex(count);
|
||||||
settings->setValue(QLatin1String(idKey), sid);
|
settings.setValue(QLatin1String(idKey), sid);
|
||||||
settings->setValue(QLatin1String(sequenceKey), key.toString());
|
settings.setValue(QLatin1String(sequenceKey), key.toString());
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
settings->endArray();
|
settings.endArray();
|
||||||
}
|
}
|
||||||
|
@ -31,9 +31,9 @@
|
|||||||
|
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
|
|
||||||
#include <QtCore/QMap>
|
#include <QMap>
|
||||||
#include <QtCore/QHash>
|
#include <QHash>
|
||||||
#include <QtCore/QMultiHash>
|
#include <QMultiHash>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QSettings;
|
class QSettings;
|
||||||
@ -62,7 +62,9 @@ public:
|
|||||||
void setContext(const QList<int> &context);
|
void setContext(const QList<int> &context);
|
||||||
static ActionManagerPrivate *instance();
|
static ActionManagerPrivate *instance();
|
||||||
|
|
||||||
void saveSettings(QSettings *settings);
|
void saveSettings(QSettings &settings) const;
|
||||||
|
void readSettings(QSettings &settings);
|
||||||
|
|
||||||
QList<int> defaultGroups() const;
|
QList<int> defaultGroups() const;
|
||||||
|
|
||||||
QList<CommandPrivate *> commands() const;
|
QList<CommandPrivate *> commands() const;
|
||||||
@ -73,8 +75,6 @@ public:
|
|||||||
Command *command(int uid) const;
|
Command *command(int uid) const;
|
||||||
ActionContainer *actionContainer(int uid) const;
|
ActionContainer *actionContainer(int uid) const;
|
||||||
|
|
||||||
void readSettings(QSettings *settings);
|
|
||||||
|
|
||||||
// ActionManager Interface
|
// ActionManager Interface
|
||||||
ActionContainer *createMenu(const QString &id);
|
ActionContainer *createMenu(const QString &id);
|
||||||
ActionContainer *createMenuBar(const QString &id);
|
ActionContainer *createMenuBar(const QString &id);
|
||||||
|
@ -28,11 +28,11 @@
|
|||||||
|
|
||||||
#include "coreimpl.h"
|
#include "coreimpl.h"
|
||||||
|
|
||||||
#include <QtCore/QDir>
|
|
||||||
#include <QtCore/QCoreApplication>
|
|
||||||
|
|
||||||
#include "utils/pathutils.h"
|
#include "utils/pathutils.h"
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
// The Core Singleton
|
// The Core Singleton
|
||||||
@ -117,11 +117,6 @@ MimeDatabase *CoreImpl::mimeDatabase() const
|
|||||||
return m_mainwindow->mimeDatabase();
|
return m_mainwindow->mimeDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
QSettings *CoreImpl::settings(QSettings::Scope scope) const
|
|
||||||
{
|
|
||||||
return m_mainwindow->settings(scope);
|
|
||||||
}
|
|
||||||
|
|
||||||
SettingsDatabase *CoreImpl::settingsDatabase() const
|
SettingsDatabase *CoreImpl::settingsDatabase() const
|
||||||
{
|
{
|
||||||
return m_mainwindow->settingsDatabase();
|
return m_mainwindow->settingsDatabase();
|
||||||
@ -137,7 +132,6 @@ IContext *CoreImpl::currentContextObject() const
|
|||||||
return m_mainwindow->currentContextObject();
|
return m_mainwindow->currentContextObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QMainWindow *CoreImpl::mainWindow() const
|
QMainWindow *CoreImpl::mainWindow() const
|
||||||
{
|
{
|
||||||
return m_mainwindow;
|
return m_mainwindow;
|
||||||
@ -181,24 +175,40 @@ void CoreImpl::openFiles(const QStringList &arguments)
|
|||||||
// m_mainwindow->openFiles(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()
|
void CoreImpl::deleteSettings()
|
||||||
{
|
{
|
||||||
m_mainwindow->deleteSettings();
|
m_mainwindow->deleteSettings();
|
||||||
|
@ -60,12 +60,14 @@ public:
|
|||||||
ModeManager *modeManager() const;
|
ModeManager *modeManager() const;
|
||||||
MimeDatabase *mimeDatabase() const;
|
MimeDatabase *mimeDatabase() const;
|
||||||
|
|
||||||
QSettings *settings(QSettings::Scope scope = QSettings::UserScope) const;
|
|
||||||
SettingsDatabase *settingsDatabase() const;
|
SettingsDatabase *settingsDatabase() const;
|
||||||
void readMainSettings(QSettings *qs, bool workspaceDiffOnly);
|
|
||||||
void saveMainSettings(QSettings *qs);
|
void readMainSettings(QSettings &settings, bool workspaceDiffOnly);
|
||||||
void readSettings(IConfigurablePlugin *plugin, QSettings *qs = 0);
|
void saveMainSettings(QSettings &settings) const;
|
||||||
void saveSettings(IConfigurablePlugin *plugin, QSettings *qs = 0);
|
void readSettings(IConfigurablePlugin *plugin);
|
||||||
|
void saveSettings(IConfigurablePlugin *plugin) const;
|
||||||
|
void readSettings(IConfigurablePlugin *plugin, QSettings &settings);
|
||||||
|
void saveSettings(IConfigurablePlugin *plugin, QSettings &settings) const;
|
||||||
void deleteSettings();
|
void deleteSettings();
|
||||||
|
|
||||||
QString resourcePath() const;
|
QString resourcePath() const;
|
||||||
|
@ -33,8 +33,8 @@
|
|||||||
#include "coreplugin/uavgadgetinstancemanager.h"
|
#include "coreplugin/uavgadgetinstancemanager.h"
|
||||||
#include "coreplugin/uavgadgetoptionspagedecorator.h"
|
#include "coreplugin/uavgadgetoptionspagedecorator.h"
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QDebug>
|
||||||
#include <QtCore/QSettings>
|
#include <QSettings>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
@ -96,10 +96,10 @@ Q_DECLARE_METATYPE(::PageData) SettingsDialog::SettingsDialog(QWidget *parent, c
|
|||||||
setWindowTitle(tr("Options"));
|
setWindowTitle(tr("Options"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QSettings *settings = ICore::instance()->settings();
|
QSettings settings;
|
||||||
|
|
||||||
settings->beginGroup("General");
|
settings.beginGroup("General");
|
||||||
settings->beginGroup("Settings");
|
settings.beginGroup("Settings");
|
||||||
|
|
||||||
// restore last displayed category and page
|
// restore last displayed category and page
|
||||||
// this is done only if no category or page was provided through the constructor
|
// 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;
|
QString initialPage = pageId;
|
||||||
qDebug() << "SettingsDialog constructor initial category:" << initialCategory << ", initial page:" << initialPage;
|
qDebug() << "SettingsDialog constructor initial category:" << initialCategory << ", initial page:" << initialPage;
|
||||||
if (initialCategory.isEmpty() && initialPage.isEmpty()) {
|
if (initialCategory.isEmpty() && initialPage.isEmpty()) {
|
||||||
initialCategory = settings->value("LastPreferenceCategory", QVariant(QString())).toString();
|
initialCategory = settings.value("LastPreferenceCategory", QVariant(QString())).toString();
|
||||||
initialPage = settings->value("LastPreferencePage", QVariant(QString())).toString();
|
initialPage = settings.value("LastPreferencePage", QVariant(QString())).toString();
|
||||||
qDebug() << "SettingsDialog settings initial category:" << initialCategory << ", initial page: " << initialPage;
|
qDebug() << "SettingsDialog settings initial category:" << initialCategory << ", initial page: " << initialPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore window size
|
// restore window size
|
||||||
int windowWidth = settings->value("WindowWidth", 0).toInt();
|
int windowWidth = settings.value("WindowWidth", 0).toInt();
|
||||||
int windowHeight = settings->value("WindowHeight", 0).toInt();
|
int windowHeight = settings.value("WindowHeight", 0).toInt();
|
||||||
qDebug() << "SettingsDialog window width :" << windowWidth << ", height:" << windowHeight;
|
qDebug() << "SettingsDialog window width :" << windowWidth << ", height:" << windowHeight;
|
||||||
if (windowWidth > 0 && windowHeight > 0) {
|
if (windowWidth > 0 && windowHeight > 0) {
|
||||||
resize(windowWidth, windowHeight);
|
resize(windowWidth, windowHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore splitter size
|
// restore splitter size
|
||||||
int splitterPosition = settings->value("SplitterPosition", 350).toInt();
|
int splitterPosition = settings.value("SplitterPosition", 350).toInt();
|
||||||
qDebug() << "SettingsDialog splitter position:" << splitterPosition;
|
qDebug() << "SettingsDialog splitter position:" << splitterPosition;
|
||||||
QList<int> sizes;
|
QList<int> sizes;
|
||||||
sizes << splitterPosition << 400;
|
sizes << splitterPosition << 400;
|
||||||
splitter->setSizes(sizes);
|
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
|
// all extra space must go to the option page and none to the tree
|
||||||
splitter->setStretchFactor(0, 0);
|
splitter->setStretchFactor(0, 0);
|
||||||
@ -464,22 +464,22 @@ bool SettingsDialog::execDialog()
|
|||||||
|
|
||||||
void SettingsDialog::done(int val)
|
void SettingsDialog::done(int val)
|
||||||
{
|
{
|
||||||
QSettings *settings = ICore::instance()->settings();
|
QSettings settings;
|
||||||
|
|
||||||
settings->beginGroup("General");
|
settings.beginGroup("General");
|
||||||
settings->beginGroup("Settings");
|
settings.beginGroup("Settings");
|
||||||
|
|
||||||
settings->setValue("LastPreferenceCategory", m_currentCategory);
|
settings.setValue("LastPreferenceCategory", m_currentCategory);
|
||||||
settings->setValue("LastPreferencePage", m_currentPage);
|
settings.setValue("LastPreferencePage", m_currentPage);
|
||||||
|
|
||||||
settings->setValue("WindowWidth", this->width());
|
settings.setValue("WindowWidth", this->width());
|
||||||
settings->setValue("WindowHeight", this->height());
|
settings.setValue("WindowHeight", this->height());
|
||||||
|
|
||||||
QList<int> sizes = splitter->sizes();
|
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);
|
QDialog::done(val);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#include "ui_settingsdialog.h"
|
#include "ui_settingsdialog.h"
|
||||||
|
|
||||||
#include <QtCore/QList>
|
#include <QList>
|
||||||
|
|
||||||
#include "coreplugin/dialogs/ioptionspage.h"
|
#include "coreplugin/dialogs/ioptionspage.h"
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
|
|
||||||
#include <utils/stylehelper.h>
|
#include <utils/stylehelper.h>
|
||||||
#include <utils/qtcolorbutton.h>
|
#include <utils/qtcolorbutton.h>
|
||||||
#include <utils/consoleprocess.h>
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
@ -157,40 +156,40 @@ void GeneralSettings::finish()
|
|||||||
delete m_page;
|
delete m_page;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneralSettings::readSettings(QSettings *qs)
|
void GeneralSettings::readSettings(QSettings &settings)
|
||||||
{
|
{
|
||||||
qs->beginGroup(QLatin1String("General"));
|
settings.beginGroup(QLatin1String("General"));
|
||||||
m_language = qs->value(QLatin1String("OverrideLanguage"), QLocale::system().name()).toString();
|
m_language = settings.value(QLatin1String("OverrideLanguage"), QLocale::system().name()).toString();
|
||||||
m_saveSettingsOnExit = qs->value(QLatin1String("SaveSettingsOnExit"), m_saveSettingsOnExit).toBool();
|
m_saveSettingsOnExit = settings.value(QLatin1String("SaveSettingsOnExit"), m_saveSettingsOnExit).toBool();
|
||||||
m_autoConnect = qs->value(QLatin1String("AutoConnect"), m_autoConnect).toBool();
|
m_autoConnect = settings.value(QLatin1String("AutoConnect"), m_autoConnect).toBool();
|
||||||
m_autoSelect = qs->value(QLatin1String("AutoSelect"), m_autoSelect).toBool();
|
m_autoSelect = settings.value(QLatin1String("AutoSelect"), m_autoSelect).toBool();
|
||||||
m_useUDPMirror = qs->value(QLatin1String("UDPMirror"), m_useUDPMirror).toBool();
|
m_useUDPMirror = settings.value(QLatin1String("UDPMirror"), m_useUDPMirror).toBool();
|
||||||
m_useExpertMode = qs->value(QLatin1String("ExpertMode"), m_useExpertMode).toBool();
|
m_useExpertMode = settings.value(QLatin1String("ExpertMode"), m_useExpertMode).toBool();
|
||||||
m_collectUsageData = qs->value(QLatin1String("CollectUsageData"), m_collectUsageData).toBool();
|
m_collectUsageData = settings.value(QLatin1String("CollectUsageData"), m_collectUsageData).toBool();
|
||||||
m_showUsageDataDisclaimer = qs->value(QLatin1String("ShowUsageDataDisclaimer"), m_showUsageDataDisclaimer).toBool();
|
m_showUsageDataDisclaimer = settings.value(QLatin1String("ShowUsageDataDisclaimer"), m_showUsageDataDisclaimer).toBool();
|
||||||
m_lastUsageHash = qs->value(QLatin1String("LastUsageHash"), m_lastUsageHash).toString();
|
m_lastUsageHash = settings.value(QLatin1String("LastUsageHash"), m_lastUsageHash).toString();
|
||||||
qs->endGroup();
|
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()) {
|
if (m_language.isEmpty()) {
|
||||||
qs->remove(QLatin1String("OverrideLanguage"));
|
settings.remove(QLatin1String("OverrideLanguage"));
|
||||||
} else {
|
} else {
|
||||||
qs->setValue(QLatin1String("OverrideLanguage"), m_language);
|
settings.setValue(QLatin1String("OverrideLanguage"), m_language);
|
||||||
}
|
}
|
||||||
|
|
||||||
qs->setValue(QLatin1String("SaveSettingsOnExit"), m_saveSettingsOnExit);
|
settings.setValue(QLatin1String("SaveSettingsOnExit"), m_saveSettingsOnExit);
|
||||||
qs->setValue(QLatin1String("AutoConnect"), m_autoConnect);
|
settings.setValue(QLatin1String("AutoConnect"), m_autoConnect);
|
||||||
qs->setValue(QLatin1String("AutoSelect"), m_autoSelect);
|
settings.setValue(QLatin1String("AutoSelect"), m_autoSelect);
|
||||||
qs->setValue(QLatin1String("UDPMirror"), m_useUDPMirror);
|
settings.setValue(QLatin1String("UDPMirror"), m_useUDPMirror);
|
||||||
qs->setValue(QLatin1String("ExpertMode"), m_useExpertMode);
|
settings.setValue(QLatin1String("ExpertMode"), m_useExpertMode);
|
||||||
qs->setValue(QLatin1String("CollectUsageData"), m_collectUsageData);
|
settings.setValue(QLatin1String("CollectUsageData"), m_collectUsageData);
|
||||||
qs->setValue(QLatin1String("ShowUsageDataDisclaimer"), m_showUsageDataDisclaimer);
|
settings.setValue(QLatin1String("ShowUsageDataDisclaimer"), m_showUsageDataDisclaimer);
|
||||||
qs->setValue(QLatin1String("LastUsageHash"), m_lastUsageHash);
|
settings.setValue(QLatin1String("LastUsageHash"), m_lastUsageHash);
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneralSettings::resetInterfaceColor()
|
void GeneralSettings::resetInterfaceColor()
|
||||||
|
@ -33,7 +33,8 @@
|
|||||||
|
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QSettings>
|
|
||||||
|
class QSettings;
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@ -61,8 +62,8 @@ public:
|
|||||||
bool collectUsageData() const;
|
bool collectUsageData() const;
|
||||||
bool showUsageDataDisclaimer() const;
|
bool showUsageDataDisclaimer() const;
|
||||||
QString lastUsageHash() const;
|
QString lastUsageHash() const;
|
||||||
void readSettings(QSettings *qs);
|
void readSettings(QSettings &settings);
|
||||||
void saveSettings(QSettings *qs);
|
void saveSettings(QSettings &settings) const;
|
||||||
bool useExpertMode() const;
|
bool useExpertMode() const;
|
||||||
void setCollectUsageData(bool collect);
|
void setCollectUsageData(bool collect);
|
||||||
void setShowUsageDataDisclaimer(bool show);
|
void setShowUsageDataDisclaimer(bool show);
|
||||||
|
@ -12,10 +12,9 @@ namespace Core {
|
|||||||
class CORE_EXPORT IConfigurablePlugin : public ExtensionSystem::IPlugin {
|
class CORE_EXPORT IConfigurablePlugin : public ExtensionSystem::IPlugin {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
// IConfigurablePlugin(QObject *parent = 0){}
|
|
||||||
virtual ~IConfigurablePlugin() {}
|
virtual ~IConfigurablePlugin() {}
|
||||||
virtual void readConfig(QSettings *qSettings, UAVConfigInfo *configInfo) = 0;
|
virtual void readConfig(QSettings &settings, UAVConfigInfo *configInfo) = 0;
|
||||||
virtual void saveConfig(QSettings *qSettings, Core::UAVConfigInfo *configInfo) = 0;
|
virtual void saveConfig(QSettings &settings, UAVConfigInfo *configInfo) const = 0;
|
||||||
};
|
};
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|
||||||
|
@ -172,24 +172,6 @@
|
|||||||
Use the mime database to manage mime types.
|
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
|
\fn SettingsDatabase *ICore::settingsDatabase() const
|
||||||
\brief Returns the application's settings database.
|
\brief Returns the application's settings database.
|
||||||
|
@ -30,13 +30,12 @@
|
|||||||
#define ICORE_H
|
#define ICORE_H
|
||||||
|
|
||||||
#include "core_global.h"
|
#include "core_global.h"
|
||||||
#include <QtCore/QObject>
|
|
||||||
#include <QSettings>
|
#include <QObject>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QMainWindow;
|
class QMainWindow;
|
||||||
class QSettings;
|
class QSettings;
|
||||||
template <class T> class QList;
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
@ -84,12 +83,14 @@ public:
|
|||||||
virtual UAVGadgetInstanceManager *uavGadgetInstanceManager() const = 0;
|
virtual UAVGadgetInstanceManager *uavGadgetInstanceManager() const = 0;
|
||||||
virtual MimeDatabase *mimeDatabase() const = 0;
|
virtual MimeDatabase *mimeDatabase() const = 0;
|
||||||
|
|
||||||
virtual QSettings *settings(QSettings::Scope scope = QSettings::UserScope) const = 0;
|
|
||||||
virtual SettingsDatabase *settingsDatabase() const = 0;
|
virtual SettingsDatabase *settingsDatabase() const = 0;
|
||||||
virtual void readMainSettings(QSettings *qs, bool workspaceDiffOnly = false) = 0;
|
|
||||||
virtual void saveMainSettings(QSettings *qs) = 0;
|
virtual void readMainSettings(QSettings &settings, bool workspaceDiffOnly = false) = 0;
|
||||||
virtual void readSettings(IConfigurablePlugin *plugin, QSettings *qs = 0) = 0;
|
virtual void saveMainSettings(QSettings &settings) const = 0;
|
||||||
virtual void saveSettings(IConfigurablePlugin *plugin, QSettings *qs = 0) = 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 void deleteSettings() = 0;
|
||||||
|
|
||||||
virtual QString resourcePath() const = 0;
|
virtual QString resourcePath() const = 0;
|
||||||
|
@ -77,9 +77,9 @@ public:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
virtual void loadConfiguration(IUAVGadgetConfiguration *) {}
|
virtual void loadConfiguration(IUAVGadgetConfiguration *) {}
|
||||||
virtual void saveState(QSettings * /*qSettings*/) {}
|
virtual void saveState(QSettings &) const {}
|
||||||
virtual void restoreState(QByteArray) {}
|
virtual void restoreState(QByteArray) {}
|
||||||
virtual void restoreState(QSettings * /*qSettings*/) {}
|
virtual void restoreState(QSettings &) {}
|
||||||
public slots:
|
public slots:
|
||||||
virtual void configurationChanged(IUAVGadgetConfiguration *) {}
|
virtual void configurationChanged(IUAVGadgetConfiguration *) {}
|
||||||
virtual void configurationAdded(IUAVGadgetConfiguration *) {}
|
virtual void configurationAdded(IUAVGadgetConfiguration *) {}
|
||||||
|
@ -31,8 +31,8 @@ using namespace Core;
|
|||||||
|
|
||||||
IUAVGadgetConfiguration::IUAVGadgetConfiguration(QString classId, QObject *parent) :
|
IUAVGadgetConfiguration::IUAVGadgetConfiguration(QString classId, QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_locked(false),
|
|
||||||
m_classId(classId),
|
m_classId(classId),
|
||||||
m_name(tr("default")),
|
m_name(tr("default")),
|
||||||
m_provisionalName(tr("default"))
|
m_provisionalName(tr("default")),
|
||||||
|
m_locked(false)
|
||||||
{}
|
{}
|
||||||
|
@ -40,52 +40,60 @@ class CORE_EXPORT IUAVGadgetConfiguration : public QObject {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit IUAVGadgetConfiguration(QString classId, QObject *parent = 0);
|
explicit IUAVGadgetConfiguration(QString classId, QObject *parent = 0);
|
||||||
QString classId()
|
|
||||||
|
QString classId() const
|
||||||
{
|
{
|
||||||
return m_classId;
|
return m_classId;
|
||||||
}
|
}
|
||||||
QString name()
|
|
||||||
|
QString name() const
|
||||||
{
|
{
|
||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setName(QString name)
|
void setName(QString name)
|
||||||
{
|
{
|
||||||
m_name = name;
|
m_name = name;
|
||||||
}
|
}
|
||||||
QString provisionalName()
|
|
||||||
|
QString provisionalName() const
|
||||||
{
|
{
|
||||||
return m_provisionalName;
|
return m_provisionalName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setProvisionalName(QString name)
|
void setProvisionalName(QString name)
|
||||||
{
|
{
|
||||||
m_provisionalName = name;
|
m_provisionalName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool locked() const
|
bool locked() const
|
||||||
{
|
{
|
||||||
return m_locked;
|
return m_locked;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLocked(bool locked)
|
void setLocked(bool locked)
|
||||||
{
|
{
|
||||||
m_locked = locked;
|
m_locked = locked;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void saveConfig(QSettings * /*settings*/) const {}
|
virtual void saveConfig(QSettings &) const {}
|
||||||
virtual void saveConfig(QSettings *settings, UAVConfigInfo * /*configInfo*/) const
|
|
||||||
|
virtual void saveConfig(QSettings &settings, UAVConfigInfo *) const
|
||||||
{
|
{
|
||||||
saveConfig(settings);
|
saveConfig(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual IUAVGadgetConfiguration *clone() = 0;
|
virtual IUAVGadgetConfiguration *clone() const = 0;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_locked;
|
|
||||||
QString m_classId;
|
QString m_classId;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
QString m_provisionalName;
|
QString m_provisionalName;
|
||||||
|
bool m_locked;
|
||||||
};
|
};
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|
||||||
|
@ -28,15 +28,17 @@
|
|||||||
|
|
||||||
#ifndef IUAVGADGETFACTORY_H
|
#ifndef IUAVGADGETFACTORY_H
|
||||||
#define IUAVGADGETFACTORY_H
|
#define IUAVGADGETFACTORY_H
|
||||||
|
|
||||||
#include "core_global.h"
|
#include "core_global.h"
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
|
||||||
#include <QIcon>
|
|
||||||
#include <QSettings>
|
|
||||||
#include "uavconfiginfo.h"
|
#include "uavconfiginfo.h"
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QIcon>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QStringList;
|
class QStringList;
|
||||||
|
class QSettings;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
@ -56,15 +58,15 @@ public:
|
|||||||
virtual ~IUAVGadgetFactory() {}
|
virtual ~IUAVGadgetFactory() {}
|
||||||
|
|
||||||
virtual IUAVGadget *createGadget(QWidget *parent) = 0;
|
virtual IUAVGadget *createGadget(QWidget *parent) = 0;
|
||||||
virtual IUAVGadgetConfiguration *createConfiguration(QSettings * /*qSettings*/)
|
virtual IUAVGadgetConfiguration *createConfiguration(QSettings &)
|
||||||
{
|
{
|
||||||
return 0;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,6 @@
|
|||||||
#include <utils/pathchooser.h>
|
#include <utils/pathchooser.h>
|
||||||
#include <utils/pathutils.h>
|
#include <utils/pathutils.h>
|
||||||
#include <utils/stylehelper.h>
|
#include <utils/stylehelper.h>
|
||||||
#include <utils/xmlconfig.h>
|
|
||||||
#include "version_info/version_info.h"
|
#include "version_info/version_info.h"
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
@ -102,13 +101,6 @@ MainWindow::MainWindow() :
|
|||||||
m_uniqueIDManager(new UniqueIDManager()),
|
m_uniqueIDManager(new UniqueIDManager()),
|
||||||
m_globalContext(QList<int>() << Constants::C_GLOBAL_ID),
|
m_globalContext(QList<int>() << Constants::C_GLOBAL_ID),
|
||||||
m_additionalContexts(m_globalContext),
|
m_additionalContexts(m_globalContext),
|
||||||
// keep this in sync with main() in app/main.cpp
|
|
||||||
m_settings(new QSettings(this)),
|
|
||||||
m_globalSettings(new QSettings(XmlConfig::XmlSettingsFormat, 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_dontSaveSettings(false),
|
||||||
m_actionManager(new ActionManagerPrivate(this)),
|
m_actionManager(new ActionManagerPrivate(this)),
|
||||||
m_variableManager(new VariableManager(this)),
|
m_variableManager(new VariableManager(this)),
|
||||||
@ -140,6 +132,11 @@ MainWindow::MainWindow() :
|
|||||||
#endif
|
#endif
|
||||||
qApp->setStyle(QStyleFactory::create("Fusion"));
|
qApp->setStyle(QStyleFactory::create("Fusion"));
|
||||||
|
|
||||||
|
QSettings settings;
|
||||||
|
m_settingsDatabase = new SettingsDatabase(QFileInfo(settings.fileName()).path(),
|
||||||
|
QFileInfo(settings.fileName()).baseName(),
|
||||||
|
this);
|
||||||
|
|
||||||
setDockNestingEnabled(true);
|
setDockNestingEnabled(true);
|
||||||
|
|
||||||
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
|
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
|
||||||
@ -200,10 +197,8 @@ MainWindow::~MainWindow()
|
|||||||
m_generalSettings = 0;
|
m_generalSettings = 0;
|
||||||
delete m_workspaceSettings;
|
delete m_workspaceSettings;
|
||||||
m_workspaceSettings = 0;
|
m_workspaceSettings = 0;
|
||||||
delete m_settings;
|
|
||||||
m_settings = 0;
|
|
||||||
delete m_uniqueIDManager;
|
delete m_uniqueIDManager;
|
||||||
m_uniqueIDManager = 0;
|
m_uniqueIDManager = 0;
|
||||||
|
|
||||||
pm->removeObject(m_coreImpl);
|
pm->removeObject(m_coreImpl);
|
||||||
delete m_coreImpl;
|
delete m_coreImpl;
|
||||||
@ -236,13 +231,13 @@ void MainWindow::modeChanged(Core::IMode * /*mode*/)
|
|||||||
|
|
||||||
void MainWindow::extensionsInitialized()
|
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_description = settings.value("Description", "none").toString();
|
||||||
m_config_details = qs->value("Details", "none").toString();
|
m_config_details = settings.value("Details", "none").toString();
|
||||||
m_config_stylesheet = qs->value("StyleSheet", "none").toString();
|
m_config_stylesheet = settings.value("StyleSheet", "none").toString();
|
||||||
|
|
||||||
qDebug() << "Configured style sheet:" << m_config_stylesheet;
|
qDebug() << "Configured style sheet:" << m_config_stylesheet;
|
||||||
if (m_config_stylesheet == "wide") {
|
if (m_config_stylesheet == "wide") {
|
||||||
@ -269,13 +264,14 @@ void MainWindow::extensionsInitialized()
|
|||||||
// qDebug() << "Setting application style sheet to:" << style;
|
// qDebug() << "Setting application style sheet to:" << style;
|
||||||
qApp->setStyleSheet(style);
|
qApp->setStyleSheet(style);
|
||||||
|
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
m_uavGadgetInstanceManager = new UAVGadgetInstanceManager(this);
|
m_uavGadgetInstanceManager = new UAVGadgetInstanceManager(this);
|
||||||
m_uavGadgetInstanceManager->readSettings(qs);
|
|
||||||
|
m_uavGadgetInstanceManager->readSettings(settings);
|
||||||
|
|
||||||
m_messageManager->init();
|
m_messageManager->init();
|
||||||
readSettings(qs);
|
readSettings(settings);
|
||||||
|
|
||||||
updateContext();
|
updateContext();
|
||||||
|
|
||||||
@ -323,8 +319,9 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||||||
emit m_coreImpl->coreAboutToClose();
|
emit m_coreImpl->coreAboutToClose();
|
||||||
|
|
||||||
if (!m_dontSaveSettings) {
|
if (!m_dontSaveSettings) {
|
||||||
saveSettings(m_settings);
|
QSettings settings;
|
||||||
m_uavGadgetInstanceManager->saveSettings(m_settings);
|
saveSettings(settings);
|
||||||
|
m_uavGadgetInstanceManager->saveSettings(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
qApp->closeAllWindows();
|
qApp->closeAllWindows();
|
||||||
@ -477,31 +474,31 @@ void MainWindow::registerDefaultActions()
|
|||||||
ActionContainer *mhelp = am->actionContainer(Constants::M_HELP);
|
ActionContainer *mhelp = am->actionContainer(Constants::M_HELP);
|
||||||
|
|
||||||
// File menu separators
|
// 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);
|
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);
|
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);
|
mfile->addAction(cmd, Constants::G_FILE_OTHER);
|
||||||
|
|
||||||
// Edit menu separators
|
// 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);
|
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);
|
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);
|
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);
|
medit->addAction(cmd, Constants::G_EDIT_ADVANCED);
|
||||||
|
|
||||||
// Tools menu separators
|
// 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);
|
mtools->addAction(cmd, Constants::G_DEFAULT_THREE);
|
||||||
|
|
||||||
// Help menu separators
|
// Help menu separators
|
||||||
@ -653,7 +650,7 @@ void MainWindow::registerDefaultActions()
|
|||||||
connect(m_zoomAction, SIGNAL(triggered()), this, SLOT(showMaximized()));
|
connect(m_zoomAction, SIGNAL(triggered()), this, SLOT(showMaximized()));
|
||||||
|
|
||||||
// Window separator
|
// 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);
|
mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -675,7 +672,7 @@ void MainWindow::registerDefaultActions()
|
|||||||
// Window menu separators
|
// Window menu separators
|
||||||
QAction *tmpaction1 = new QAction(this);
|
QAction *tmpaction1 = new QAction(this);
|
||||||
tmpaction1->setSeparator(true);
|
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);
|
mwindow->addAction(cmd, Constants::G_WINDOW_HIDE_TOOLBAR);
|
||||||
|
|
||||||
m_showToolbarsAction = new QAction(tr("Edit Gadgets Mode"), this);
|
m_showToolbarsAction = new QAction(tr("Edit Gadgets Mode"), this);
|
||||||
@ -687,7 +684,7 @@ void MainWindow::registerDefaultActions()
|
|||||||
// Window menu separators
|
// Window menu separators
|
||||||
QAction *tmpaction2 = new QAction(this);
|
QAction *tmpaction2 = new QAction(this);
|
||||||
tmpaction2->setSeparator(true);
|
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);
|
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
@ -733,7 +730,7 @@ void MainWindow::registerDefaultActions()
|
|||||||
#ifndef Q_WS_MAC
|
#ifndef Q_WS_MAC
|
||||||
tmpaction = new QAction(this);
|
tmpaction = new QAction(this);
|
||||||
tmpaction->setSeparator(true);
|
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);
|
mhelp->addAction(cmd, Constants::G_HELP_ABOUT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -785,7 +782,8 @@ void MainWindow::saveAll()
|
|||||||
}
|
}
|
||||||
|
|
||||||
emit m_coreImpl->saveSettingsRequested();
|
emit m_coreImpl->saveSettingsRequested();
|
||||||
saveSettings(); // OpenPilot-specific.
|
QSettings settings;
|
||||||
|
saveSettings(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::exit()
|
void MainWindow::exit()
|
||||||
@ -829,15 +827,6 @@ MessageManager *MainWindow::messageManager() const
|
|||||||
return m_messageManager;
|
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
|
VariableManager *MainWindow::variableManager() const
|
||||||
{
|
{
|
||||||
return m_variableManager;
|
return m_variableManager;
|
||||||
@ -1025,7 +1014,7 @@ inline int takeLeastPriorityUavGadgetManager(const QList<Core::UAVGadgetManager
|
|||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::createWorkspaces(QSettings *qs, bool diffOnly)
|
void MainWindow::createWorkspaces(QSettings &settings, bool diffOnly)
|
||||||
{
|
{
|
||||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||||
|
|
||||||
@ -1084,175 +1073,161 @@ void MainWindow::createWorkspaces(QSettings *qs, bool diffOnly)
|
|||||||
|
|
||||||
pm->addObject(uavGadgetManager);
|
pm->addObject(uavGadgetManager);
|
||||||
m_uavGadgetManagers.append(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 workspace" << name << "took" << timer.elapsed() << "ms";
|
||||||
}
|
}
|
||||||
qDebug() << "MainWindow::createWorkspaces - creating workspaces took" << totalTimer.elapsed() << "ms";
|
qDebug() << "MainWindow::createWorkspaces - creating workspaces took" << totalTimer.elapsed() << "ms";
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *settingsGroup = "MainWindow";
|
static const QString settingsGroup = "MainWindow";
|
||||||
static const char *geometryKey = "Geometry";
|
static const QString geometryKey = "Geometry";
|
||||||
static const char *colorKey = "Color";
|
static const QString colorKey = "Color";
|
||||||
static const char *maxKey = "Maximized";
|
static const QString maxKey = "Maximized";
|
||||||
static const char *fullScreenKey = "FullScreen";
|
static const QString fullScreenKey = "FullScreen";
|
||||||
static const char *modePriorities = "ModePriorities";
|
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) {
|
if (workspaceDiffOnly) {
|
||||||
createWorkspaces(qs, workspaceDiffOnly);
|
createWorkspaces(settings, workspaceDiffOnly);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_generalSettings->readSettings(qs);
|
m_generalSettings->readSettings(settings);
|
||||||
m_actionManager->readSettings(qs);
|
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()) {
|
if (geom.isValid()) {
|
||||||
setGeometry(geom.toRect());
|
setGeometry(geom.toRect());
|
||||||
} else {
|
} else {
|
||||||
resize(750, 400);
|
resize(750, 400);
|
||||||
}
|
}
|
||||||
if (qs->value(QLatin1String(maxKey), false).toBool()) {
|
if (settings.value(maxKey, false).toBool()) {
|
||||||
setWindowState(Qt::WindowMaximized);
|
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
|
// Restore tab ordering
|
||||||
qs->beginGroup(QLatin1String(modePriorities));
|
settings.beginGroup(modePriorities);
|
||||||
|
|
||||||
QStringList modeNames = qs->childKeys();
|
QStringList modeNames = settings.childKeys();
|
||||||
QMap<QString, int> map;
|
QMap<QString, int> map;
|
||||||
foreach(QString modeName, modeNames) {
|
foreach(QString modeName, modeNames) {
|
||||||
map.insert(modeName, qs->value(modeName).toInt());
|
map.insert(modeName, settings.value(modeName).toInt());
|
||||||
}
|
}
|
||||||
m_modeManager->reorderModes(map);
|
m_modeManager->reorderModes(map);
|
||||||
|
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
// Restore selected tab
|
// Restore selected tab
|
||||||
if (m_workspaceSettings->restoreSelectedOnStartup()) {
|
if (m_workspaceSettings->restoreSelectedOnStartup()) {
|
||||||
int index = qs->value(QLatin1String("SelectedWorkspace")).toInt();
|
int index = settings.value("SelectedWorkspace").toInt();
|
||||||
m_modeStack->setCurrentIndex(index);
|
m_modeStack->setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::saveSettings(QSettings *qs)
|
void MainWindow::saveSettings(QSettings &settings) const
|
||||||
{
|
{
|
||||||
if (m_dontSaveSettings) {
|
if (m_dontSaveSettings) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!qs) {
|
m_workspaceSettings->saveSettings(settings);
|
||||||
qs = m_settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_workspaceSettings->saveSettings(qs);
|
settings.beginGroup(settingsGroup);
|
||||||
|
|
||||||
qs->beginGroup(QLatin1String(settingsGroup));
|
settings.setValue(colorKey, Utils::StyleHelper::baseColor());
|
||||||
|
|
||||||
qs->setValue(QLatin1String(colorKey), Utils::StyleHelper::baseColor());
|
|
||||||
|
|
||||||
if (windowState() & (Qt::WindowMaximized | Qt::WindowFullScreen)) {
|
if (windowState() & (Qt::WindowMaximized | Qt::WindowFullScreen)) {
|
||||||
qs->setValue(QLatin1String(maxKey), (bool)(windowState() & Qt::WindowMaximized));
|
settings.setValue(maxKey, (bool)(windowState() & Qt::WindowMaximized));
|
||||||
qs->setValue(QLatin1String(fullScreenKey), (bool)(windowState() & Qt::WindowFullScreen));
|
settings.setValue(fullScreenKey, (bool)(windowState() & Qt::WindowFullScreen));
|
||||||
} else {
|
} else {
|
||||||
qs->setValue(QLatin1String(maxKey), false);
|
settings.setValue(maxKey, false);
|
||||||
qs->setValue(QLatin1String(fullScreenKey), false);
|
settings.setValue(fullScreenKey, false);
|
||||||
qs->setValue(QLatin1String(geometryKey), geometry());
|
settings.setValue(geometryKey, geometry());
|
||||||
}
|
}
|
||||||
|
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
// Write tab ordering
|
// Write tab ordering
|
||||||
qs->beginGroup(QLatin1String(modePriorities));
|
settings.beginGroup(modePriorities);
|
||||||
QVector<IMode *> modes = m_modeManager->modes();
|
QVector<IMode *> modes = m_modeManager->modes();
|
||||||
foreach(IMode * mode, 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
|
// Write selected tab
|
||||||
qs->setValue(QLatin1String("SelectedWorkspace"), m_modeStack->currentIndex());
|
settings.setValue("SelectedWorkspace", m_modeStack->currentIndex());
|
||||||
|
|
||||||
foreach(UAVGadgetManager * manager, m_uavGadgetManagers) {
|
foreach(UAVGadgetManager * manager, m_uavGadgetManagers) {
|
||||||
manager->saveSettings(qs);
|
manager->saveSettings(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_actionManager->saveSettings(qs);
|
m_actionManager->saveSettings(settings);
|
||||||
m_generalSettings->saveSettings(qs);
|
m_generalSettings->saveSettings(settings);
|
||||||
|
|
||||||
qs->beginGroup("General");
|
settings.beginGroup("General");
|
||||||
qs->setValue("Description", m_config_description);
|
settings.setValue("Description", m_config_description);
|
||||||
qs->setValue("Details", m_config_details);
|
settings.setValue("Details", m_config_details);
|
||||||
qs->setValue("StyleSheet", m_config_stylesheet);
|
settings.setValue("StyleSheet", m_config_stylesheet);
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::readSettings(IConfigurablePlugin *plugin, QSettings *qs)
|
void MainWindow::readSettings(IConfigurablePlugin *plugin, QSettings &settings)
|
||||||
{
|
{
|
||||||
if (!qs) {
|
|
||||||
qs = m_settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
UAVConfigInfo configInfo;
|
UAVConfigInfo configInfo;
|
||||||
QObject *qo = reinterpret_cast<QObject *>(plugin);
|
QObject *qo = reinterpret_cast<QObject *>(plugin);
|
||||||
QString configName = qo->metaObject()->className();
|
QString configName = qo->metaObject()->className();
|
||||||
|
|
||||||
qs->beginGroup("Plugins");
|
settings.beginGroup("Plugins");
|
||||||
qs->beginGroup(configName);
|
settings.beginGroup(configName);
|
||||||
configInfo.read(qs);
|
configInfo.read(settings);
|
||||||
configInfo.setNameOfConfigurable("Plugin-" + configName);
|
configInfo.setNameOfConfigurable("Plugin-" + configName);
|
||||||
qs->beginGroup("data");
|
settings.beginGroup("data");
|
||||||
plugin->readConfig(qs, &configInfo);
|
plugin->readConfig(settings, &configInfo);
|
||||||
|
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::saveSettings(IConfigurablePlugin *plugin, QSettings *qs)
|
void MainWindow::saveSettings(IConfigurablePlugin *plugin, QSettings &settings) const
|
||||||
{
|
{
|
||||||
if (m_dontSaveSettings) {
|
if (m_dontSaveSettings) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!qs) {
|
|
||||||
qs = m_settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
UAVConfigInfo configInfo;
|
UAVConfigInfo configInfo;
|
||||||
QString configName = plugin->metaObject()->className();
|
QString configName = plugin->metaObject()->className();
|
||||||
|
|
||||||
qs->beginGroup("Plugins");
|
settings.beginGroup("Plugins");
|
||||||
qs->beginGroup(configName);
|
settings.beginGroup(configName);
|
||||||
qs->beginGroup("data");
|
settings.beginGroup("data");
|
||||||
plugin->saveConfig(qs, &configInfo);
|
plugin->saveConfig(settings, &configInfo);
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
configInfo.save(qs);
|
configInfo.save(settings);
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::deleteSettings()
|
void MainWindow::deleteSettings()
|
||||||
{
|
{
|
||||||
m_settings->clear();
|
QSettings settings;
|
||||||
m_settings->sync();
|
|
||||||
|
settings.clear();
|
||||||
|
settings.sync();
|
||||||
m_dontSaveSettings = true;
|
m_dontSaveSettings = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,8 +33,7 @@
|
|||||||
|
|
||||||
#include "eventfilteringmainwindow.h"
|
#include "eventfilteringmainwindow.h"
|
||||||
|
|
||||||
#include <QtCore/QMap>
|
#include <QMap>
|
||||||
#include <QSettings>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QSettings;
|
class QSettings;
|
||||||
@ -88,10 +87,10 @@ public:
|
|||||||
void addContextObject(IContext *contex);
|
void addContextObject(IContext *contex);
|
||||||
void removeContextObject(IContext *contex);
|
void removeContextObject(IContext *contex);
|
||||||
void resetContext();
|
void resetContext();
|
||||||
void readSettings(QSettings *qs = 0, bool workspaceDiffOnly = false);
|
void readSettings(QSettings &settings, bool workspaceDiffOnly = false);
|
||||||
void saveSettings(QSettings *qs = 0);
|
void saveSettings(QSettings &settings) const;
|
||||||
void readSettings(IConfigurablePlugin *plugin, QSettings *qs = 0);
|
void readSettings(IConfigurablePlugin *plugin, QSettings &settings);
|
||||||
void saveSettings(IConfigurablePlugin *plugin, QSettings *qs = 0);
|
void saveSettings(IConfigurablePlugin *plugin, QSettings &settings) const;
|
||||||
void deleteSettings();
|
void deleteSettings();
|
||||||
void openFiles(const QStringList &fileNames);
|
void openFiles(const QStringList &fileNames);
|
||||||
|
|
||||||
@ -106,7 +105,6 @@ public:
|
|||||||
Core::ModeManager *modeManager() const;
|
Core::ModeManager *modeManager() const;
|
||||||
Core::MimeDatabase *mimeDatabase() const;
|
Core::MimeDatabase *mimeDatabase() const;
|
||||||
Internal::GeneralSettings *generalSettings() const;
|
Internal::GeneralSettings *generalSettings() const;
|
||||||
QSettings *settings(QSettings::Scope scope) const;
|
|
||||||
inline SettingsDatabase *settingsDatabase() const
|
inline SettingsDatabase *settingsDatabase() const
|
||||||
{
|
{
|
||||||
return m_settingsDatabase;
|
return m_settingsDatabase;
|
||||||
@ -165,15 +163,13 @@ private:
|
|||||||
void updateContextObject(IContext *context);
|
void updateContextObject(IContext *context);
|
||||||
void registerDefaultContainers();
|
void registerDefaultContainers();
|
||||||
void registerDefaultActions();
|
void registerDefaultActions();
|
||||||
void createWorkspaces(QSettings *qs, bool diffOnly = false);
|
void createWorkspaces(QSettings &settings, bool diffOnly = false);
|
||||||
QString loadStyleSheet(QString name);
|
QString loadStyleSheet(QString name);
|
||||||
|
|
||||||
CoreImpl *m_coreImpl;
|
CoreImpl *m_coreImpl;
|
||||||
UniqueIDManager *m_uniqueIDManager;
|
UniqueIDManager *m_uniqueIDManager;
|
||||||
QList<int> m_globalContext;
|
QList<int> m_globalContext;
|
||||||
QList<int> m_additionalContexts;
|
QList<int> m_additionalContexts;
|
||||||
QSettings *m_settings;
|
|
||||||
QSettings *m_globalSettings;
|
|
||||||
SettingsDatabase *m_settingsDatabase;
|
SettingsDatabase *m_settingsDatabase;
|
||||||
bool m_dontSaveSettings; // In case of an Error or if we reset the settings, never save them.
|
bool m_dontSaveSettings; // In case of an Error or if we reset the settings, never save them.
|
||||||
ActionManagerPrivate *m_actionManager;
|
ActionManagerPrivate *m_actionManager;
|
||||||
|
@ -48,12 +48,9 @@
|
|||||||
|
|
||||||
Typically a plugin can handle version-changes like this:
|
Typically a plugin can handle version-changes like this:
|
||||||
\code
|
\code
|
||||||
MyGadgetConfiguration::MyGadgetConfiguration(QString classId, QSettings* qSettings, UAVConfigInfo *configInfo, QObject *parent) :
|
MyGadgetConfiguration::MyGadgetConfiguration(QString classId, QSettings &settings, UAVConfigInfo *configInfo, QObject *parent) :
|
||||||
IUAVGadgetConfiguration(classId, parent)
|
IUAVGadgetConfiguration(classId, parent)
|
||||||
{
|
{
|
||||||
if ( ! qSettings )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ( configInfo->version() == UAVConfigVersion() )
|
if ( configInfo->version() == UAVConfigVersion() )
|
||||||
configInfo->setVersion("1.0.0");
|
configInfo->setVersion("1.0.0");
|
||||||
|
|
||||||
@ -63,7 +60,7 @@
|
|||||||
... read the config ...
|
... 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);
|
configInfo->setVersion(CURRENT_VERSION);
|
||||||
|
|
||||||
@ -118,11 +115,11 @@ UAVConfigInfo::UAVConfigInfo(QObject *parent) :
|
|||||||
m_nameOfConfigurable("")
|
m_nameOfConfigurable("")
|
||||||
{}
|
{}
|
||||||
|
|
||||||
UAVConfigInfo::UAVConfigInfo(QSettings *qs, QObject *parent) :
|
UAVConfigInfo::UAVConfigInfo(QSettings &settings, QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_version(VERSION_DEFAULT)
|
m_version(VERSION_DEFAULT)
|
||||||
{
|
{
|
||||||
read(qs);
|
read(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
UAVConfigInfo::UAVConfigInfo(UAVConfigVersion version, QString nameOfConfigurable, QObject *parent) :
|
UAVConfigInfo::UAVConfigInfo(UAVConfigVersion version, QString nameOfConfigurable, QObject *parent) :
|
||||||
@ -139,20 +136,20 @@ UAVConfigInfo::UAVConfigInfo(IUAVGadgetConfiguration *config, QObject *parent) :
|
|||||||
m_nameOfConfigurable = config->classId() + "-" + config->name();
|
m_nameOfConfigurable = config->classId() + "-" + config->name();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UAVConfigInfo::save(QSettings *qs)
|
void UAVConfigInfo::save(QSettings &settings) const
|
||||||
{
|
{
|
||||||
qs->beginGroup("configInfo");
|
settings.beginGroup("configInfo");
|
||||||
qs->setValue("version", m_version.toString());
|
settings.setValue("version", m_version.toString());
|
||||||
qs->setValue("locked", m_locked);
|
settings.setValue("locked", m_locked);
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UAVConfigInfo::read(QSettings *qs)
|
void UAVConfigInfo::read(QSettings &settings)
|
||||||
{
|
{
|
||||||
qs->beginGroup("configInfo");
|
settings.beginGroup("configInfo");
|
||||||
m_version = UAVConfigVersion(qs->value("version", VERSION_DEFAULT).toString());
|
m_version = UAVConfigVersion(settings.value("version", VERSION_DEFAULT).toString());
|
||||||
m_locked = qs->value("locked", false).toBool();
|
m_locked = settings.value("locked", false).toBool();
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UAVConfigInfo::askToAbort(int compat, QString message)
|
bool UAVConfigInfo::askToAbort(int compat, QString message)
|
||||||
|
@ -27,11 +27,12 @@
|
|||||||
#ifndef UAVCONFIGINFO_H
|
#ifndef UAVCONFIGINFO_H
|
||||||
#define UAVCONFIGINFO_H
|
#define UAVCONFIGINFO_H
|
||||||
|
|
||||||
|
#include "core_global.h"
|
||||||
|
#include "iuavgadgetconfiguration.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include "iuavgadgetconfiguration.h"
|
|
||||||
#include "core_global.h"
|
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class IUAVGadgetConfiguration;
|
class IUAVGadgetConfiguration;
|
||||||
@ -54,18 +55,19 @@ class CORE_EXPORT UAVConfigInfo : public QObject {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
explicit UAVConfigInfo(QObject *parent = 0);
|
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);
|
explicit UAVConfigInfo(IUAVGadgetConfiguration *config, QObject *parent = 0);
|
||||||
UAVConfigInfo(UAVConfigVersion version, QString nameOfConfigurable, QObject *parent = 0);
|
UAVConfigInfo(UAVConfigVersion version, QString nameOfConfigurable, QObject *parent = 0);
|
||||||
|
|
||||||
enum Compatibility { FullyCompatible, MinorLossOfConfiguration, MissingConfiguration, MajorLossOfConfiguration, NotCompatible };
|
enum Compatibility { FullyCompatible, MinorLossOfConfiguration, MissingConfiguration, MajorLossOfConfiguration, NotCompatible };
|
||||||
|
|
||||||
void setNameOfConfigurable(const QString nameOfConfigurable)
|
void setNameOfConfigurable(const QString nameOfConfigurable)
|
||||||
{
|
{
|
||||||
m_nameOfConfigurable = nameOfConfigurable;
|
m_nameOfConfigurable = nameOfConfigurable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void save(QSettings *qs);
|
void save(QSettings &) const;
|
||||||
void read(QSettings *qs);
|
void read(QSettings &);
|
||||||
|
|
||||||
void setVersion(int major, int minor, int patch)
|
void setVersion(int major, int minor, int patch)
|
||||||
{
|
{
|
||||||
|
@ -26,10 +26,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "uavgadgetdecorator.h"
|
#include "uavgadgetdecorator.h"
|
||||||
|
|
||||||
#include "iuavgadgetconfiguration.h"
|
#include "iuavgadgetconfiguration.h"
|
||||||
|
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QtCore/QByteArray>
|
#include <QDebug>
|
||||||
#include <QtCore/QDebug>
|
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
|
||||||
@ -123,20 +124,20 @@ void UAVGadgetDecorator::updateToolbar()
|
|||||||
m_toolbar->setEnabled(m_toolbar->count() > 1);
|
m_toolbar->setEnabled(m_toolbar->count() > 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UAVGadgetDecorator::saveState(QSettings *qSettings)
|
void UAVGadgetDecorator::saveState(QSettings &settings) const
|
||||||
{
|
{
|
||||||
if (m_activeConfiguration) {
|
if (m_activeConfiguration) {
|
||||||
qSettings->setValue("activeConfiguration", m_activeConfiguration->name());
|
settings.setValue("activeConfiguration", m_activeConfiguration->name());
|
||||||
}
|
}
|
||||||
// save gadget individual state
|
// save gadget individual state
|
||||||
qSettings->beginGroup("state");
|
settings.beginGroup("state");
|
||||||
m_gadget->saveState(qSettings);
|
m_gadget->saveState(settings);
|
||||||
qSettings->endGroup();
|
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) {
|
foreach(IUAVGadgetConfiguration * config, *m_configurations) {
|
||||||
if (config->name() == configName) {
|
if (config->name() == configName) {
|
||||||
@ -145,7 +146,7 @@ void UAVGadgetDecorator::restoreState(QSettings *qSettings)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// restore gadget individual state
|
// restore gadget individual state
|
||||||
qSettings->beginGroup("state");
|
settings.beginGroup("state");
|
||||||
m_gadget->restoreState(qSettings);
|
m_gadget->restoreState(settings);
|
||||||
qSettings->endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,11 @@
|
|||||||
|
|
||||||
#ifndef UAVGADGETDECORATOR_H
|
#ifndef UAVGADGETDECORATOR_H
|
||||||
#define UAVGADGETDECORATOR_H
|
#define UAVGADGETDECORATOR_H
|
||||||
|
|
||||||
#include <coreplugin/iuavgadget.h>
|
#include <coreplugin/iuavgadget.h>
|
||||||
|
|
||||||
|
class QSettings;
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class IUAVGadgetConfiguration;
|
class IUAVGadgetConfiguration;
|
||||||
|
|
||||||
@ -51,8 +54,8 @@ public:
|
|||||||
return m_activeConfiguration;
|
return m_activeConfiguration;
|
||||||
}
|
}
|
||||||
void loadConfiguration(IUAVGadgetConfiguration *config);
|
void loadConfiguration(IUAVGadgetConfiguration *config);
|
||||||
void saveState(QSettings *qSettings);
|
void saveState(QSettings &settings) const;
|
||||||
void restoreState(QSettings *qSettings);
|
void restoreState(QSettings &settings);
|
||||||
public slots:
|
public slots:
|
||||||
void configurationChanged(IUAVGadgetConfiguration *config);
|
void configurationChanged(IUAVGadgetConfiguration *config);
|
||||||
void configurationAdded(IUAVGadgetConfiguration *config);
|
void configurationAdded(IUAVGadgetConfiguration *config);
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "uavgadgetinstancemanager.h"
|
#include "uavgadgetinstancemanager.h"
|
||||||
|
|
||||||
#include "iuavgadget.h"
|
#include "iuavgadget.h"
|
||||||
#include "uavgadgetdecorator.h"
|
#include "uavgadgetdecorator.h"
|
||||||
#include "iuavgadgetfactory.h"
|
#include "iuavgadgetfactory.h"
|
||||||
@ -36,17 +37,16 @@
|
|||||||
#include "icore.h"
|
#include "icore.h"
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <QtCore/QStringList>
|
#include <QStringList>
|
||||||
#include <QtCore/QSettings>
|
#include <QSettings>
|
||||||
#include <QtCore/QDebug>
|
#include <QDebug>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
|
||||||
static const UAVConfigVersion m_versionUAVGadgetConfigurations = UAVConfigVersion("1.2.0");
|
static const UAVConfigVersion m_versionUAVGadgetConfigurations = UAVConfigVersion("1.2.0");
|
||||||
|
|
||||||
UAVGadgetInstanceManager::UAVGadgetInstanceManager(QObject *parent) :
|
UAVGadgetInstanceManager::UAVGadgetInstanceManager(QObject *parent) : QObject(parent), m_settingsDialog(NULL)
|
||||||
QObject(parent)
|
|
||||||
{
|
{
|
||||||
m_pm = ExtensionSystem::PluginManager::instance();
|
m_pm = ExtensionSystem::PluginManager::instance();
|
||||||
QList<IUAVGadgetFactory *> factories = m_pm->getObjects<IUAVGadgetFactory>();
|
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()) {
|
while (!m_configurations.isEmpty()) {
|
||||||
emit configurationToBeDeleted(m_configurations.takeLast());
|
emit configurationToBeDeleted(m_configurations.takeLast());
|
||||||
}
|
}
|
||||||
qs->beginGroup("UAVGadgetConfigurations");
|
|
||||||
UAVConfigInfo configInfo(qs);
|
settings.beginGroup("UAVGadgetConfigurations");
|
||||||
|
|
||||||
|
UAVConfigInfo configInfo(settings);
|
||||||
configInfo.setNameOfConfigurable("UAVGadgetConfigurations");
|
configInfo.setNameOfConfigurable("UAVGadgetConfigurations");
|
||||||
|
|
||||||
if (configInfo.version() == UAVConfigVersion()) {
|
if (configInfo.version() == UAVConfigVersion()) {
|
||||||
// If version is not set, assume its a old version before readable config (1.0.0).
|
// If version is not set, assume its a old version before readable config (1.0.0).
|
||||||
// however compatibility to 1.0.0 is broken.
|
// however compatibility to 1.0.0 is broken.
|
||||||
@ -87,7 +90,7 @@ void UAVGadgetInstanceManager::readSettings(QSettings *qs)
|
|||||||
if (configInfo.version() == UAVConfigVersion("1.1.0")) {
|
if (configInfo.version() == UAVConfigVersion("1.1.0")) {
|
||||||
configInfo.notify(tr("Migrating UAVGadgetConfigurations from version 1.1.0 to ")
|
configInfo.notify(tr("Migrating UAVGadgetConfigurations from version 1.1.0 to ")
|
||||||
+ m_versionUAVGadgetConfigurations.toString());
|
+ 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)) {
|
} else if (!configInfo.standardVersionHandlingOK(m_versionUAVGadgetConfigurations)) {
|
||||||
// We are in trouble now. User wants us to quit the import, but when he saves
|
// We are in trouble now. User wants us to quit the import, but when he saves
|
||||||
// the GCS, his old config will be lost.
|
// 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!")
|
tr("You might want to save your old config NOW since it might be replaced by broken one when you exit the GCS!")
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
readConfigs_1_2_0(qs);
|
readConfigs_1_2_0(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
createOptionsPages();
|
createOptionsPages();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UAVGadgetInstanceManager::readConfigs_1_2_0(QSettings *qs)
|
void UAVGadgetInstanceManager::readConfigs_1_2_0(QSettings &settings)
|
||||||
{
|
{
|
||||||
UAVConfigInfo configInfo;
|
UAVConfigInfo configInfo;
|
||||||
|
|
||||||
foreach(QString classId, m_classIdNameMap.keys()) {
|
foreach(QString classId, m_classIdNameMap.keys()) {
|
||||||
IUAVGadgetFactory *f = factory(classId);
|
IUAVGadgetFactory *f = factory(classId);
|
||||||
|
|
||||||
qs->beginGroup(classId);
|
settings.beginGroup(classId);
|
||||||
|
|
||||||
QStringList configs = QStringList();
|
QStringList configs = QStringList();
|
||||||
|
|
||||||
configs = qs->childGroups();
|
configs = settings.childGroups();
|
||||||
foreach(QString configName, configs) {
|
foreach(QString configName, configs) {
|
||||||
// qDebug() << "Loading config: " << classId << "," << configName;
|
// qDebug() << "Loading config: " << classId << "," << configName;
|
||||||
qs->beginGroup(configName);
|
settings.beginGroup(configName);
|
||||||
configInfo.read(qs);
|
configInfo.read(settings);
|
||||||
configInfo.setNameOfConfigurable(classId + "-" + configName);
|
configInfo.setNameOfConfigurable(classId + "-" + configName);
|
||||||
qs->beginGroup("data");
|
settings.beginGroup("data");
|
||||||
IUAVGadgetConfiguration *config = f->createConfiguration(qs, &configInfo);
|
IUAVGadgetConfiguration *config = f->createConfiguration(settings, &configInfo);
|
||||||
if (config) {
|
if (config) {
|
||||||
config->setName(configName);
|
config->setName(configName);
|
||||||
config->setProvisionalName(configName);
|
config->setProvisionalName(configName);
|
||||||
@ -134,42 +137,42 @@ void UAVGadgetInstanceManager::readConfigs_1_2_0(QSettings *qs)
|
|||||||
m_configurations.append(config);
|
m_configurations.append(config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configs.count() == 0) {
|
// if (configs.count() == 0) {
|
||||||
IUAVGadgetConfiguration *config = f->createConfiguration(0, 0);
|
// IUAVGadgetConfiguration *config = f->createConfiguration(0, 0);
|
||||||
// it is not mandatory for uavgadgets to have any configurations (settings)
|
//// it is not mandatory for uavgadgets to have any configurations (settings)
|
||||||
// and therefore we have to check for that
|
//// and therefore we have to check for that
|
||||||
if (config) {
|
// if (config) {
|
||||||
config->setName(tr("default"));
|
// config->setName(tr("default"));
|
||||||
config->setProvisionalName(tr("default"));
|
// config->setProvisionalName(tr("default"));
|
||||||
m_configurations.append(config);
|
// m_configurations.append(config);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UAVGadgetInstanceManager::readConfigs_1_1_0(QSettings *qs)
|
void UAVGadgetInstanceManager::readConfigs_1_1_0(QSettings &settings)
|
||||||
{
|
{
|
||||||
UAVConfigInfo configInfo;
|
UAVConfigInfo configInfo;
|
||||||
|
|
||||||
foreach(QString classId, m_classIdNameMap.keys()) {
|
foreach(QString classId, m_classIdNameMap.keys()) {
|
||||||
IUAVGadgetFactory *f = factory(classId);
|
IUAVGadgetFactory *f = factory(classId);
|
||||||
|
|
||||||
qs->beginGroup(classId);
|
settings.beginGroup(classId);
|
||||||
|
|
||||||
QStringList configs = QStringList();
|
QStringList configs = QStringList();
|
||||||
|
|
||||||
configs = qs->childGroups();
|
configs = settings.childGroups();
|
||||||
foreach(QString configName, configs) {
|
foreach(QString configName, configs) {
|
||||||
// qDebug().nospace() << "Loading config: " << classId << ", " << configName;
|
// qDebug().nospace() << "Loading config: " << classId << ", " << configName;
|
||||||
qs->beginGroup(configName);
|
settings.beginGroup(configName);
|
||||||
bool locked = qs->value("config.locked").toBool();
|
bool locked = settings.value("config.locked").toBool();
|
||||||
configInfo.setNameOfConfigurable(classId + "-" + configName);
|
configInfo.setNameOfConfigurable(classId + "-" + configName);
|
||||||
IUAVGadgetConfiguration *config = f->createConfiguration(qs, &configInfo);
|
IUAVGadgetConfiguration *config = f->createConfiguration(settings, &configInfo);
|
||||||
if (config) {
|
if (config) {
|
||||||
config->setName(configName);
|
config->setName(configName);
|
||||||
config->setProvisionalName(configName);
|
config->setProvisionalName(configName);
|
||||||
@ -183,45 +186,45 @@ void UAVGadgetInstanceManager::readConfigs_1_1_0(QSettings *qs)
|
|||||||
m_configurations.append(config);
|
m_configurations.append(config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configs.count() == 0) {
|
// if (configs.count() == 0) {
|
||||||
IUAVGadgetConfiguration *config = f->createConfiguration(0, 0);
|
// IUAVGadgetConfiguration *config = f->createConfiguration(0, 0);
|
||||||
// it is not mandatory for uavgadgets to have any configurations (settings)
|
//// it is not mandatory for uavgadgets to have any configurations (settings)
|
||||||
// and therefore we have to check for that
|
//// and therefore we have to check for that
|
||||||
if (config) {
|
// if (config) {
|
||||||
config->setName(tr("default"));
|
// config->setName(tr("default"));
|
||||||
config->setProvisionalName(tr("default"));
|
// config->setProvisionalName(tr("default"));
|
||||||
m_configurations.append(config);
|
// m_configurations.append(config);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UAVGadgetInstanceManager::saveSettings(QSettings *qs)
|
void UAVGadgetInstanceManager::saveSettings(QSettings &settings) const
|
||||||
{
|
{
|
||||||
UAVConfigInfo *configInfo;
|
UAVConfigInfo *configInfo;
|
||||||
|
|
||||||
qs->beginGroup("UAVGadgetConfigurations");
|
settings.beginGroup("UAVGadgetConfigurations");
|
||||||
qs->remove(""); // Remove existing configurations
|
settings.remove(""); // Remove existing configurations
|
||||||
configInfo = new UAVConfigInfo(m_versionUAVGadgetConfigurations, "UAVGadgetConfigurations");
|
configInfo = new UAVConfigInfo(m_versionUAVGadgetConfigurations, "UAVGadgetConfigurations");
|
||||||
configInfo->save(qs);
|
configInfo->save(settings);
|
||||||
delete configInfo;
|
delete configInfo;
|
||||||
foreach(IUAVGadgetConfiguration * config, m_configurations) {
|
foreach(IUAVGadgetConfiguration * config, m_configurations) {
|
||||||
configInfo = new UAVConfigInfo(config);
|
configInfo = new UAVConfigInfo(config);
|
||||||
qs->beginGroup(config->classId());
|
settings.beginGroup(config->classId());
|
||||||
qs->beginGroup(config->name());
|
settings.beginGroup(config->name());
|
||||||
qs->beginGroup("data");
|
settings.beginGroup("data");
|
||||||
config->saveConfig(qs, configInfo);
|
config->saveConfig(settings, configInfo);
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
configInfo->save(qs);
|
configInfo->save(settings);
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
delete configInfo;
|
delete configInfo;
|
||||||
}
|
}
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UAVGadgetInstanceManager::createOptionsPages()
|
void UAVGadgetInstanceManager::createOptionsPages()
|
||||||
|
@ -28,14 +28,15 @@
|
|||||||
#ifndef UAVGADGETINSTANCEMANAGER_H
|
#ifndef UAVGADGETINSTANCEMANAGER_H
|
||||||
#define UAVGADGETINSTANCEMANAGER_H
|
#define UAVGADGETINSTANCEMANAGER_H
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QSettings>
|
|
||||||
#include <QtCore/QMap>
|
|
||||||
#include <QtCore/QStringList>
|
|
||||||
#include <QIcon>
|
|
||||||
#include "core_global.h"
|
#include "core_global.h"
|
||||||
#include "uavconfiginfo.h"
|
#include "uavconfiginfo.h"
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QMap>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QIcon>
|
||||||
|
|
||||||
namespace ExtensionSystem {
|
namespace ExtensionSystem {
|
||||||
class PluginManager;
|
class PluginManager;
|
||||||
}
|
}
|
||||||
@ -58,8 +59,8 @@ public:
|
|||||||
explicit UAVGadgetInstanceManager(QObject *parent = 0);
|
explicit UAVGadgetInstanceManager(QObject *parent = 0);
|
||||||
~UAVGadgetInstanceManager();
|
~UAVGadgetInstanceManager();
|
||||||
|
|
||||||
void readSettings(QSettings *qs);
|
void readSettings(QSettings &settings);
|
||||||
void saveSettings(QSettings *qs);
|
void saveSettings(QSettings &settings) const;
|
||||||
|
|
||||||
IUAVGadget *createGadget(QString classId, QWidget *parent, bool loadDefaultConfiguration = true);
|
IUAVGadget *createGadget(QString classId, QWidget *parent, bool loadDefaultConfiguration = true);
|
||||||
void removeGadget(IUAVGadget *gadget);
|
void removeGadget(IUAVGadget *gadget);
|
||||||
@ -116,8 +117,8 @@ private:
|
|||||||
|
|
||||||
int indexForConfig(QList<IUAVGadgetConfiguration *> configurations, QString classId, QString configName);
|
int indexForConfig(QList<IUAVGadgetConfiguration *> configurations, QString classId, QString configName);
|
||||||
|
|
||||||
void readConfigs_1_1_0(QSettings *qs);
|
void readConfigs_1_1_0(QSettings &settings);
|
||||||
void readConfigs_1_2_0(QSettings *qs);
|
void readConfigs_1_2_0(QSettings &settings);
|
||||||
};
|
};
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|
||||||
|
@ -32,7 +32,9 @@
|
|||||||
#include "iuavgadget.h"
|
#include "iuavgadget.h"
|
||||||
#include "minisplitter.h"
|
#include "minisplitter.h"
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QStackedLayout>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
#include <qmacstyle_mac.h>
|
#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) {
|
if (m_splitter) {
|
||||||
qSettings->setValue("type", "splitter");
|
settings.setValue("type", "splitter");
|
||||||
qSettings->setValue("splitterOrientation", (qint32)m_splitter->orientation());
|
settings.setValue("splitterOrientation", (qint32)m_splitter->orientation());
|
||||||
QList<QVariant> sizesQVariant;
|
QList<QVariant> sizesQVariant;
|
||||||
foreach(int value, m_sizes) {
|
foreach(int value, m_sizes) {
|
||||||
sizesQVariant.append(value);
|
sizesQVariant.append(value);
|
||||||
}
|
}
|
||||||
qSettings->setValue("splitterSizes", sizesQVariant);
|
settings.setValue("splitterSizes", sizesQVariant);
|
||||||
qSettings->beginGroup("side0");
|
settings.beginGroup("side0");
|
||||||
static_cast<SplitterOrView *>(m_splitter->widget(0))->saveState(qSettings);
|
static_cast<SplitterOrView *>(m_splitter->widget(0))->saveState(settings);
|
||||||
qSettings->endGroup();
|
settings.endGroup();
|
||||||
qSettings->beginGroup("side1");
|
settings.beginGroup("side1");
|
||||||
static_cast<SplitterOrView *>(m_splitter->widget(1))->saveState(qSettings);
|
static_cast<SplitterOrView *>(m_splitter->widget(1))->saveState(settings);
|
||||||
qSettings->endGroup();
|
settings.endGroup();
|
||||||
} else if (gadget()) {
|
} 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") {
|
if (mode == "splitter") {
|
||||||
qint32 orientation = qSettings->value("splitterOrientation").toInt();
|
qint32 orientation = settings.value("splitterOrientation").toInt();
|
||||||
QList<QVariant> sizesQVariant = qSettings->value("splitterSizes").toList();
|
QList<QVariant> sizesQVariant = settings.value("splitterSizes").toList();
|
||||||
m_sizes.clear();
|
m_sizes.clear();
|
||||||
foreach(QVariant value, sizesQVariant) {
|
foreach(QVariant value, sizesQVariant) {
|
||||||
m_sizes.append(value.toInt());
|
m_sizes.append(value.toInt());
|
||||||
}
|
}
|
||||||
split((Qt::Orientation)orientation);
|
split((Qt::Orientation)orientation);
|
||||||
m_splitter->setSizes(m_sizes);
|
m_splitter->setSizes(m_sizes);
|
||||||
qSettings->beginGroup("side0");
|
settings.beginGroup("side0");
|
||||||
static_cast<SplitterOrView *>(m_splitter->widget(0))->restoreState(qSettings);
|
static_cast<SplitterOrView *>(m_splitter->widget(0))->restoreState(settings);
|
||||||
qSettings->endGroup();
|
settings.endGroup();
|
||||||
qSettings->beginGroup("side1");
|
settings.beginGroup("side1");
|
||||||
static_cast<SplitterOrView *>(m_splitter->widget(1))->restoreState(qSettings);
|
static_cast<SplitterOrView *>(m_splitter->widget(1))->restoreState(settings);
|
||||||
qSettings->endGroup();
|
settings.endGroup();
|
||||||
} else if (mode == "uavGadget") {
|
} else if (mode == "uavGadget") {
|
||||||
m_view->restoreState(qSettings);
|
m_view->restoreState(settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,11 +29,15 @@
|
|||||||
#ifndef SPLITTERORVIEW_H
|
#ifndef SPLITTERORVIEW_H
|
||||||
#define SPLITTERORVIEW_H
|
#define SPLITTERORVIEW_H
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QMouseEvent>
|
|
||||||
#include "uavgadgetmanager.h"
|
#include "uavgadgetmanager.h"
|
||||||
#include "uavgadgetview.h"
|
#include "uavgadgetview.h"
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QSplitter>
|
||||||
|
|
||||||
|
class QSettings;
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
class SplitterOrView : public QWidget {
|
class SplitterOrView : public QWidget {
|
||||||
@ -82,8 +86,8 @@ public:
|
|||||||
QSplitter *takeSplitter();
|
QSplitter *takeSplitter();
|
||||||
UAVGadgetView *takeView();
|
UAVGadgetView *takeView();
|
||||||
|
|
||||||
void saveState(QSettings *) const;
|
void saveState(QSettings &) const;
|
||||||
void restoreState(QSettings *);
|
void restoreState(QSettings &);
|
||||||
|
|
||||||
SplitterOrView *findView(Core::IUAVGadget *uavGadget);
|
SplitterOrView *findView(Core::IUAVGadget *uavGadget);
|
||||||
SplitterOrView *findView(UAVGadgetView *view);
|
SplitterOrView *findView(UAVGadgetView *view);
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "uavgadgetmanager.h"
|
#include "uavgadgetmanager.h"
|
||||||
|
|
||||||
#include "uavgadgetview.h"
|
#include "uavgadgetview.h"
|
||||||
#include "splitterorview.h"
|
#include "splitterorview.h"
|
||||||
#include "uavgadgetinstancemanager.h"
|
#include "uavgadgetinstancemanager.h"
|
||||||
@ -37,31 +38,16 @@
|
|||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
#include <coreplugin/modemanager.h>
|
#include <coreplugin/modemanager.h>
|
||||||
#include <coreplugin/uniqueidmanager.h>
|
#include <coreplugin/uniqueidmanager.h>
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
|
||||||
#include <coreplugin/baseview.h>
|
#include <coreplugin/baseview.h>
|
||||||
#include <coreplugin/imode.h>
|
#include <coreplugin/imode.h>
|
||||||
#include <coreplugin/settingsdatabase.h>
|
|
||||||
#include <coreplugin/variablemanager.h>
|
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
#include <utils/consoleprocess.h>
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QDebug>
|
||||||
#include <QtCore/QMap>
|
#include <QApplication>
|
||||||
#include <QtCore/QProcess>
|
#include <QHBoxLayout>
|
||||||
#include <QtCore/QSet>
|
|
||||||
|
|
||||||
#include <QAction>
|
|
||||||
#include <QtWidgets/QApplication>
|
|
||||||
#include <QLayout>
|
|
||||||
#include <QMainWindow>
|
|
||||||
#include <QMenu>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QSplitter>
|
|
||||||
#include <QStackedLayout>
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(Core::IUAVGadget *)
|
Q_DECLARE_METATYPE(Core::IUAVGadget *)
|
||||||
|
|
||||||
@ -291,16 +277,16 @@ void UAVGadgetManager::updateUavGadgetMenus()
|
|||||||
emit showUavGadgetMenus(m_showToolbars, hasSplitter);
|
emit showUavGadgetMenus(m_showToolbars, hasSplitter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UAVGadgetManager::saveState(QSettings *qSettings) const
|
void UAVGadgetManager::saveState(QSettings &settings) const
|
||||||
{
|
{
|
||||||
qSettings->setValue("version", "UAVGadgetManagerV1");
|
settings.setValue("version", "UAVGadgetManagerV1");
|
||||||
qSettings->setValue("showToolbars", m_showToolbars);
|
settings.setValue("showToolbars", m_showToolbars);
|
||||||
qSettings->beginGroup("splitter");
|
settings.beginGroup("splitter");
|
||||||
m_splitterOrView->saveState(qSettings);
|
m_splitterOrView->saveState(settings);
|
||||||
qSettings->endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UAVGadgetManager::restoreState(QSettings *qSettings)
|
bool UAVGadgetManager::restoreState(QSettings &settings)
|
||||||
{
|
{
|
||||||
removeAllSplits();
|
removeAllSplits();
|
||||||
|
|
||||||
@ -309,59 +295,59 @@ bool UAVGadgetManager::restoreState(QSettings *qSettings)
|
|||||||
emptyView(m_splitterOrView->view());
|
emptyView(m_splitterOrView->view());
|
||||||
im->removeGadget(gadget);
|
im->removeGadget(gadget);
|
||||||
|
|
||||||
QString version = qSettings->value("version").toString();
|
QString version = settings.value("version").toString();
|
||||||
if (version != "UAVGadgetManagerV1") {
|
if (version != "UAVGadgetManagerV1") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_showToolbars = qSettings->value("showToolbars").toBool();
|
m_showToolbars = settings.value("showToolbars").toBool();
|
||||||
|
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
|
|
||||||
qSettings->beginGroup("splitter");
|
settings.beginGroup("splitter");
|
||||||
m_splitterOrView->restoreState(qSettings);
|
m_splitterOrView->restoreState(settings);
|
||||||
qSettings->endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UAVGadgetManager::saveSettings(QSettings *qs)
|
void UAVGadgetManager::saveSettings(QSettings &settings) const
|
||||||
{
|
{
|
||||||
qs->beginGroup("UAVGadgetManager");
|
settings.beginGroup("UAVGadgetManager");
|
||||||
qs->beginGroup(this->uniqueModeName());
|
settings.beginGroup(this->uniqueModeName());
|
||||||
|
|
||||||
// Make sure the old tree is wiped.
|
// Make sure the old tree is wiped.
|
||||||
qs->remove("");
|
settings.remove("");
|
||||||
|
|
||||||
// Do actual saving
|
// Do actual saving
|
||||||
saveState(qs);
|
saveState(settings);
|
||||||
|
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UAVGadgetManager::readSettings(QSettings *qs)
|
void UAVGadgetManager::readSettings(QSettings &settings)
|
||||||
{
|
{
|
||||||
QString uavGadgetManagerRootKey = "UAVGadgetManager";
|
QString uavGadgetManagerRootKey = "UAVGadgetManager";
|
||||||
|
|
||||||
if (!qs->childGroups().contains(uavGadgetManagerRootKey)) {
|
if (!settings.childGroups().contains(uavGadgetManagerRootKey)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qs->beginGroup(uavGadgetManagerRootKey);
|
settings.beginGroup(uavGadgetManagerRootKey);
|
||||||
|
|
||||||
if (!qs->childGroups().contains(uniqueModeName())) {
|
if (!settings.childGroups().contains(uniqueModeName())) {
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qs->beginGroup(uniqueModeName());
|
settings.beginGroup(uniqueModeName());
|
||||||
|
|
||||||
restoreState(qs);
|
restoreState(settings);
|
||||||
|
|
||||||
showToolbars(m_showToolbars);
|
showToolbars(m_showToolbars);
|
||||||
|
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UAVGadgetManager::split(Qt::Orientation orientation)
|
void UAVGadgetManager::split(Qt::Orientation orientation)
|
||||||
|
@ -35,13 +35,12 @@
|
|||||||
#include <coreplugin/imode.h>
|
#include <coreplugin/imode.h>
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QtCore/QList>
|
#include <QList>
|
||||||
#include <QtCore/QPointer>
|
|
||||||
#include <QtCore/QSettings>
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
|
class QSettings;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
@ -95,11 +94,12 @@ public:
|
|||||||
|
|
||||||
IUAVGadget *currentGadget() const;
|
IUAVGadget *currentGadget() const;
|
||||||
|
|
||||||
void saveState(QSettings *) const;
|
void saveState(QSettings &) const;
|
||||||
bool restoreState(QSettings *qSettings);
|
bool restoreState(QSettings &);
|
||||||
|
|
||||||
|
void readSettings(QSettings &settings);
|
||||||
|
void saveSettings(QSettings &settings) const;
|
||||||
|
|
||||||
void saveSettings(QSettings *qs);
|
|
||||||
void readSettings(QSettings *qs);
|
|
||||||
bool toolbarsShown()
|
bool toolbarsShown()
|
||||||
{
|
{
|
||||||
return m_showToolbars;
|
return m_showToolbars;
|
||||||
|
@ -261,18 +261,18 @@ void UAVGadgetView::currentGadgetChanged(IUAVGadget *gadget)
|
|||||||
m_activeLabel->setVisible(m_uavGadget == gadget);
|
m_activeLabel->setVisible(m_uavGadget == gadget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UAVGadgetView::saveState(QSettings *qSettings)
|
void UAVGadgetView::saveState(QSettings &settings) const
|
||||||
{
|
{
|
||||||
qSettings->setValue("type", "uavGadget");
|
settings.setValue("type", "uavGadget");
|
||||||
qSettings->setValue("classId", gadget()->classId());
|
settings.setValue("classId", gadget()->classId());
|
||||||
qSettings->beginGroup("gadget");
|
settings.beginGroup("gadget");
|
||||||
gadget()->saveState(qSettings);
|
gadget()->saveState(settings);
|
||||||
qSettings->endGroup();
|
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);
|
int index = indexOfClassId(classId);
|
||||||
|
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
@ -282,11 +282,11 @@ void UAVGadgetView::restoreState(QSettings *qSettings)
|
|||||||
|
|
||||||
IUAVGadget *newGadget;
|
IUAVGadget *newGadget;
|
||||||
UAVGadgetInstanceManager *im = ICore::instance()->uavGadgetInstanceManager();
|
UAVGadgetInstanceManager *im = ICore::instance()->uavGadgetInstanceManager();
|
||||||
if (qSettings->childGroups().contains("gadget")) {
|
if (settings.childGroups().contains("gadget")) {
|
||||||
newGadget = im->createGadget(classId, this, false);
|
newGadget = im->createGadget(classId, this, false);
|
||||||
qSettings->beginGroup("gadget");
|
settings.beginGroup("gadget");
|
||||||
newGadget->restoreState(qSettings);
|
newGadget->restoreState(settings);
|
||||||
qSettings->endGroup();
|
settings.endGroup();
|
||||||
} else {
|
} else {
|
||||||
newGadget = im->createGadget(classId, this);
|
newGadget = im->createGadget(classId, this);
|
||||||
}
|
}
|
||||||
|
@ -29,22 +29,17 @@
|
|||||||
#ifndef UAVGADGETVIEW_H
|
#ifndef UAVGADGETVIEW_H
|
||||||
#define UAVGADGETVIEW_H
|
#define UAVGADGETVIEW_H
|
||||||
|
|
||||||
#include <QtCore/QList>
|
#include <QList>
|
||||||
#include <QtCore/QString>
|
#include <QString>
|
||||||
#include <QtCore/QSettings>
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QAction>
|
#include <QPointer>
|
||||||
#include <QSplitter>
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
#include <QStackedLayout>
|
|
||||||
#include <QtCore/QPointer>
|
|
||||||
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
class QToolButton;
|
class QToolButton;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QVBoxLayout;
|
class QVBoxLayout;
|
||||||
|
class QSettings;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
@ -70,8 +65,8 @@ public:
|
|||||||
|
|
||||||
void showToolbar(bool show);
|
void showToolbar(bool show);
|
||||||
|
|
||||||
void saveState(QSettings *qSettings);
|
void saveState(QSettings &settings) const;
|
||||||
void restoreState(QSettings *qSettings);
|
void restoreState(QSettings &settings);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void closeView();
|
void closeView();
|
||||||
|
@ -26,13 +26,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "workspacesettings.h"
|
#include "workspacesettings.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/modemanager.h>
|
#include <coreplugin/modemanager.h>
|
||||||
#include <coreplugin/uavgadgetmanager/uavgadgetmanager.h>
|
#include <coreplugin/uavgadgetmanager/uavgadgetmanager.h>
|
||||||
#include <QtCore/QSettings>
|
|
||||||
|
|
||||||
#include "ui_workspacesettings.h"
|
#include "ui_workspacesettings.h"
|
||||||
|
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Core::Internal;
|
using namespace Core::Internal;
|
||||||
|
|
||||||
@ -100,62 +102,63 @@ QWidget *WorkspaceSettings::createPage(QWidget *parent)
|
|||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorkspaceSettings::readSettings(QSettings *qs)
|
void WorkspaceSettings::readSettings(QSettings &settings)
|
||||||
{
|
{
|
||||||
m_names.clear();
|
m_names.clear();
|
||||||
m_iconNames.clear();
|
m_iconNames.clear();
|
||||||
m_modeNames.clear();
|
m_modeNames.clear();
|
||||||
|
|
||||||
qs->beginGroup(QLatin1String("Workspace"));
|
settings.beginGroup(QLatin1String("Workspace"));
|
||||||
m_numberOfWorkspaces = qs->value(QLatin1String("NumberOfWorkspaces"), 2).toInt();
|
m_numberOfWorkspaces = settings.value(QLatin1String("NumberOfWorkspaces"), 2).toInt();
|
||||||
m_previousNumberOfWorkspaces = m_numberOfWorkspaces;
|
m_previousNumberOfWorkspaces = m_numberOfWorkspaces;
|
||||||
for (int i = 1; i <= MAX_WORKSPACES; ++i) {
|
for (int i = 1; i <= MAX_WORKSPACES; ++i) {
|
||||||
QString numberString = QString::number(i);
|
QString numberString = QString::number(i);
|
||||||
QString defaultName = "Workspace" + numberString;
|
QString defaultName = "Workspace" + numberString;
|
||||||
QString defaultIconName = "Icon" + numberString;
|
QString defaultIconName = "Icon" + numberString;
|
||||||
QString name = qs->value(defaultName, defaultName).toString();
|
QString name = settings.value(defaultName, defaultName).toString();
|
||||||
QString iconName = qs->value(defaultIconName, ":/core/images/librepilot_logo_64.png").toString();
|
QString iconName = settings.value(defaultIconName, ":/core/images/librepilot_logo_64.png").toString();
|
||||||
m_names.append(name);
|
m_names.append(name);
|
||||||
m_iconNames.append(iconName);
|
m_iconNames.append(iconName);
|
||||||
m_modeNames.append(QString("Mode") + QString::number(i));
|
m_modeNames.append(QString("Mode") + QString::number(i));
|
||||||
}
|
}
|
||||||
m_tabBarPlacementIndex = qs->value(QLatin1String("TabBarPlacementIndex"), 1).toInt(); // 1 == "Bottom"
|
m_tabBarPlacementIndex = settings.value(QLatin1String("TabBarPlacementIndex"), 1).toInt(); // 1 == "Bottom"
|
||||||
m_allowTabBarMovement = qs->value(QLatin1String("AllowTabBarMovement"), false).toBool();
|
m_allowTabBarMovement = settings.value(QLatin1String("AllowTabBarMovement"), false).toBool();
|
||||||
m_restoreSelectedOnStartup = qs->value(QLatin1String("RestoreSelectedOnStartup"), false).toBool();
|
m_restoreSelectedOnStartup = settings.value(QLatin1String("RestoreSelectedOnStartup"), false).toBool();
|
||||||
|
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
QTabWidget::TabPosition pos = m_tabBarPlacementIndex == 0 ? QTabWidget::North : QTabWidget::South;
|
QTabWidget::TabPosition pos = m_tabBarPlacementIndex == 0 ? QTabWidget::North : QTabWidget::South;
|
||||||
emit tabBarSettingsApplied(pos, m_allowTabBarMovement);
|
emit tabBarSettingsApplied(pos, m_allowTabBarMovement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorkspaceSettings::saveSettings(QSettings *qs)
|
void WorkspaceSettings::saveSettings(QSettings &settings) const
|
||||||
{
|
{
|
||||||
qs->beginGroup(QLatin1String("Workspace"));
|
settings.beginGroup(QLatin1String("Workspace"));
|
||||||
qs->setValue(QLatin1String("NumberOfWorkspaces"), m_numberOfWorkspaces);
|
settings.setValue(QLatin1String("NumberOfWorkspaces"), m_numberOfWorkspaces);
|
||||||
for (int i = 0; i < MAX_WORKSPACES; ++i) {
|
for (int i = 0; i < MAX_WORKSPACES; ++i) {
|
||||||
QString mode = QString("Mode") + QString::number(i + 1);
|
QString mode = QString("Mode") + QString::number(i + 1);
|
||||||
int j = m_modeNames.indexOf(mode);
|
int j = m_modeNames.indexOf(mode);
|
||||||
QString numberString = QString::number(i + 1);
|
QString numberString = QString::number(i + 1);
|
||||||
QString defaultName = "Workspace" + numberString;
|
QString defaultName = "Workspace" + numberString;
|
||||||
QString defaultIconName = "Icon" + numberString;
|
QString defaultIconName = "Icon" + numberString;
|
||||||
qs->setValue(defaultName, m_names.at(j));
|
settings.setValue(defaultName, m_names.at(j));
|
||||||
qs->setValue(defaultIconName, m_iconNames.at(j));
|
settings.setValue(defaultIconName, m_iconNames.at(j));
|
||||||
}
|
}
|
||||||
qs->setValue(QLatin1String("TabBarPlacementIndex"), m_tabBarPlacementIndex);
|
settings.setValue(QLatin1String("TabBarPlacementIndex"), m_tabBarPlacementIndex);
|
||||||
qs->setValue(QLatin1String("AllowTabBarMovement"), m_allowTabBarMovement);
|
settings.setValue(QLatin1String("AllowTabBarMovement"), m_allowTabBarMovement);
|
||||||
qs->setValue(QLatin1String("RestoreSelectedOnStartup"), m_restoreSelectedOnStartup);
|
settings.setValue(QLatin1String("RestoreSelectedOnStartup"), m_restoreSelectedOnStartup);
|
||||||
qs->endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorkspaceSettings::apply()
|
void WorkspaceSettings::apply()
|
||||||
{
|
{
|
||||||
selectWorkspace(m_currentIndex, true);
|
selectWorkspace(m_currentIndex, true);
|
||||||
|
|
||||||
saveSettings(Core::ICore::instance()->settings());
|
QSettings settings;
|
||||||
|
saveSettings(settings);
|
||||||
|
|
||||||
if (m_numberOfWorkspaces != m_previousNumberOfWorkspaces) {
|
if (m_numberOfWorkspaces != m_previousNumberOfWorkspaces) {
|
||||||
Core::ICore::instance()->readMainSettings(Core::ICore::instance()->settings(), true);
|
Core::ICore::instance()->readMainSettings(settings, true);
|
||||||
m_previousNumberOfWorkspaces = m_numberOfWorkspaces;
|
m_previousNumberOfWorkspaces = m_numberOfWorkspaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,8 +29,9 @@
|
|||||||
#define WORKSPACESETTINGS_H
|
#define WORKSPACESETTINGS_H
|
||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
#include <QtCore/QObject>
|
|
||||||
#include <QtCore/QStringList>
|
#include <QObject>
|
||||||
|
#include <QStringList>
|
||||||
#include <QTabWidget>
|
#include <QTabWidget>
|
||||||
|
|
||||||
class QSettings;
|
class QSettings;
|
||||||
@ -59,8 +60,8 @@ public:
|
|||||||
QWidget *createPage(QWidget *parent);
|
QWidget *createPage(QWidget *parent);
|
||||||
void apply();
|
void apply();
|
||||||
void finish();
|
void finish();
|
||||||
void readSettings(QSettings *qs);
|
void readSettings(QSettings &settings);
|
||||||
void saveSettings(QSettings *qs);
|
void saveSettings(QSettings &settings) const;
|
||||||
int numberOfWorkspaces() const
|
int numberOfWorkspaces() const
|
||||||
{
|
{
|
||||||
return m_numberOfWorkspaces;
|
return m_numberOfWorkspaces;
|
||||||
|
@ -30,146 +30,125 @@
|
|||||||
#include "utils/pathutils.h"
|
#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) :
|
DialGadgetConfiguration::DialGadgetConfiguration(QString classId, QSettings &settings, QObject *parent) :
|
||||||
IUAVGadgetConfiguration(classId, 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)
|
|
||||||
{
|
{
|
||||||
// if a saved configuration exists load it
|
QString dialFile = settings.value("dialFile", "Unknown").toString();
|
||||||
if (qSettings != 0) {
|
|
||||||
QString dialFile = qSettings->value("dialFile").toString();
|
|
||||||
|
|
||||||
m_defaultDial = Utils::InsertDataPath(dialFile);
|
m_defaultDial = Utils::InsertDataPath(dialFile);
|
||||||
dialBackgroundID = qSettings->value("dialBackgroundID").toString();
|
dialBackgroundID = settings.value("dialBackgroundID", "background").toString();
|
||||||
dialForegroundID = qSettings->value("dialForegroundID").toString();
|
dialForegroundID = settings.value("dialForegroundID", "foreground").toString();
|
||||||
dialNeedleID1 = qSettings->value("dialNeedleID1").toString();
|
dialNeedleID1 = settings.value("dialNeedleID1", "needle").toString();
|
||||||
dialNeedleID2 = qSettings->value("dialNeedleID2").toString();
|
dialNeedleID2 = settings.value("dialNeedleID2", "needle2").toString();
|
||||||
dialNeedleID3 = qSettings->value("dialNeedleID3").toString();
|
dialNeedleID3 = settings.value("dialNeedleID3", "needle3").toString();
|
||||||
needle1MinValue = qSettings->value("needle1MinValue").toDouble();
|
needle1MinValue = settings.value("needle1MinValue", 0).toDouble();
|
||||||
needle1MaxValue = qSettings->value("needle1MaxValue").toDouble();
|
needle1MaxValue = settings.value("needle1MaxValue", 100).toDouble();
|
||||||
needle2MinValue = qSettings->value("needle2MinValue").toDouble();
|
needle2MinValue = settings.value("needle2MinValue", 0).toDouble();
|
||||||
needle2MaxValue = qSettings->value("needle2MaxValue").toDouble();
|
needle2MaxValue = settings.value("needle2MaxValue", 100).toDouble();
|
||||||
needle3MinValue = qSettings->value("needle3MinValue").toDouble();
|
needle3MinValue = settings.value("needle3MinValue", 0).toDouble();
|
||||||
needle3MaxValue = qSettings->value("needle3MaxValue").toDouble();
|
needle3MaxValue = settings.value("needle3MaxValue", 100).toDouble();
|
||||||
needle1DataObject = qSettings->value("needle1DataObject").toString();
|
needle1DataObject = settings.value("needle1DataObject").toString();
|
||||||
needle1ObjectField = qSettings->value("needle1ObjectField").toString();
|
needle1ObjectField = settings.value("needle1ObjectField").toString();
|
||||||
needle2DataObject = qSettings->value("needle2DataObject").toString();
|
needle2DataObject = settings.value("needle2DataObject").toString();
|
||||||
needle2ObjectField = qSettings->value("needle2ObjectField").toString();
|
needle2ObjectField = settings.value("needle2ObjectField").toString();
|
||||||
needle3DataObject = qSettings->value("needle3DataObject").toString();
|
needle3DataObject = settings.value("needle3DataObject").toString();
|
||||||
needle3ObjectField = qSettings->value("needle3ObjectField").toString();
|
needle3ObjectField = settings.value("needle3ObjectField").toString();
|
||||||
needle1Factor = qSettings->value("needle1Factor").toDouble();
|
needle1Factor = settings.value("needle1Factor", 1).toDouble();
|
||||||
needle2Factor = qSettings->value("needle2Factor").toDouble();
|
needle2Factor = settings.value("needle2Factor", 1).toDouble();
|
||||||
needle3Factor = qSettings->value("needle3Factor").toDouble();
|
needle3Factor = settings.value("needle3Factor", 1).toDouble();
|
||||||
needle1Move = qSettings->value("needle1Move").toString();
|
needle1Move = settings.value("needle1Move", "Rotate").toString();
|
||||||
needle2Move = qSettings->value("needle2Move").toString();
|
needle2Move = settings.value("needle2Move", "Rotate").toString();
|
||||||
needle3Move = qSettings->value("needle3Move").toString();
|
needle3Move = settings.value("needle3Move", "Rotate").toString();
|
||||||
font = qSettings->value("font").toString();
|
font = settings.value("font").toString();
|
||||||
useOpenGLFlag = qSettings->value("useOpenGLFlag").toBool();
|
useOpenGLFlag = settings.value("useOpenGLFlag", false).toBool();
|
||||||
beSmooth = qSettings->value("beSmooth").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.
|
* Clones a configuration.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
IUAVGadgetConfiguration *DialGadgetConfiguration::clone()
|
IUAVGadgetConfiguration *DialGadgetConfiguration::clone() const
|
||||||
{
|
{
|
||||||
DialGadgetConfiguration *m = new DialGadgetConfiguration(this->classId());
|
return new DialGadgetConfiguration(*this);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves a configuration.
|
* Saves a configuration.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void DialGadgetConfiguration::saveConfig(QSettings *settings) const
|
void DialGadgetConfiguration::saveConfig(QSettings &settings) const
|
||||||
{
|
{
|
||||||
QString dialFile = Utils::RemoveDataPath(m_defaultDial);
|
QString dialFile = Utils::RemoveDataPath(m_defaultDial);
|
||||||
|
|
||||||
settings->setValue("dialFile", dialFile);
|
settings.setValue("dialFile", dialFile);
|
||||||
|
|
||||||
settings->setValue("dialBackgroundID", dialBackgroundID);
|
settings.setValue("dialBackgroundID", dialBackgroundID);
|
||||||
settings->setValue("dialForegroundID", dialForegroundID);
|
settings.setValue("dialForegroundID", dialForegroundID);
|
||||||
|
|
||||||
settings->setValue("dialNeedleID1", dialNeedleID1);
|
settings.setValue("dialNeedleID1", dialNeedleID1);
|
||||||
settings->setValue("dialNeedleID2", dialNeedleID2);
|
settings.setValue("dialNeedleID2", dialNeedleID2);
|
||||||
settings->setValue("dialNeedleID3", dialNeedleID3);
|
settings.setValue("dialNeedleID3", dialNeedleID3);
|
||||||
|
|
||||||
settings->setValue("needle1MinValue", needle1MinValue);
|
settings.setValue("needle1MinValue", QString::number(needle1MinValue));
|
||||||
settings->setValue("needle1MaxValue", needle1MaxValue);
|
settings.setValue("needle1MaxValue", QString::number(needle1MaxValue));
|
||||||
settings->setValue("needle2MinValue", needle2MinValue);
|
settings.setValue("needle2MinValue", QString::number(needle2MinValue));
|
||||||
settings->setValue("needle2MaxValue", needle2MaxValue);
|
settings.setValue("needle2MaxValue", QString::number(needle2MaxValue));
|
||||||
settings->setValue("needle3MinValue", needle3MinValue);
|
settings.setValue("needle3MinValue", QString::number(needle3MinValue));
|
||||||
settings->setValue("needle3MaxValue", needle3MaxValue);
|
settings.setValue("needle3MaxValue", QString::number(needle3MaxValue));
|
||||||
|
|
||||||
settings->setValue("needle1DataObject", needle1DataObject);
|
settings.setValue("needle1DataObject", needle1DataObject);
|
||||||
settings->setValue("needle1ObjectField", needle1ObjectField);
|
settings.setValue("needle1ObjectField", needle1ObjectField);
|
||||||
settings->setValue("needle2DataObject", needle2DataObject);
|
settings.setValue("needle2DataObject", needle2DataObject);
|
||||||
settings->setValue("needle2ObjectField", needle2ObjectField);
|
settings.setValue("needle2ObjectField", needle2ObjectField);
|
||||||
settings->setValue("needle3DataObject", needle3DataObject);
|
settings.setValue("needle3DataObject", needle3DataObject);
|
||||||
settings->setValue("needle3ObjectField", needle3ObjectField);
|
settings.setValue("needle3ObjectField", needle3ObjectField);
|
||||||
|
|
||||||
settings->setValue("needle1Factor", needle1Factor);
|
settings.setValue("needle1Factor", QString::number(needle1Factor));
|
||||||
settings->setValue("needle2Factor", needle2Factor);
|
settings.setValue("needle2Factor", QString::number(needle2Factor));
|
||||||
settings->setValue("needle3Factor", needle3Factor);
|
settings.setValue("needle3Factor", QString::number(needle3Factor));
|
||||||
|
|
||||||
settings->setValue("needle1Move", needle1Move);
|
settings.setValue("needle1Move", needle1Move);
|
||||||
settings->setValue("needle2Move", needle2Move);
|
settings.setValue("needle2Move", needle2Move);
|
||||||
settings->setValue("needle3Move", needle3Move);
|
settings.setValue("needle3Move", needle3Move);
|
||||||
|
|
||||||
settings->setValue("font", font);
|
settings.setValue("font", font);
|
||||||
|
|
||||||
settings->setValue("useOpenGLFlag", useOpenGLFlag);
|
settings.setValue("useOpenGLFlag", useOpenGLFlag);
|
||||||
settings->setValue("beSmooth", beSmooth);
|
settings.setValue("beSmooth", beSmooth);
|
||||||
}
|
}
|
||||||
|
@ -39,8 +39,11 @@ using namespace Core;
|
|||||||
class DialGadgetConfiguration : public IUAVGadgetConfiguration {
|
class DialGadgetConfiguration : public IUAVGadgetConfiguration {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
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
|
// set dial configuration functions
|
||||||
void setDialFile(QString dialFile)
|
void setDialFile(QString dialFile)
|
||||||
@ -152,7 +155,6 @@ public:
|
|||||||
beSmooth = flag;
|
beSmooth = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// get dial configuration functions
|
// get dial configuration functions
|
||||||
QString dialFile()
|
QString dialFile()
|
||||||
{
|
{
|
||||||
@ -263,9 +265,6 @@ public:
|
|||||||
return beSmooth;
|
return beSmooth;
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveConfig(QSettings *settings) const;
|
|
||||||
IUAVGadgetConfiguration *clone();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_defaultDial; // The name of the dial's SVG source file
|
QString m_defaultDial; // The name of the dial's SVG source file
|
||||||
QString dialBackgroundID; // SVG elementID of the background
|
QString dialBackgroundID; // SVG elementID of the background
|
||||||
|
@ -48,9 +48,9 @@ Core::IUAVGadget *DialGadgetFactory::createGadget(QWidget *parent)
|
|||||||
return new DialGadget(QString("DialGadget"), gadgetWidget, 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)
|
IOptionsPage *DialGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||||
|
@ -45,7 +45,7 @@ public:
|
|||||||
~DialGadgetFactory();
|
~DialGadgetFactory();
|
||||||
|
|
||||||
Core::IUAVGadget *createGadget(QWidget *parent);
|
Core::IUAVGadget *createGadget(QWidget *parent);
|
||||||
IUAVGadgetConfiguration *createConfiguration(QSettings *qSettings);
|
IUAVGadgetConfiguration *createConfiguration(QSettings &settings);
|
||||||
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -31,39 +31,43 @@
|
|||||||
* Loads a saved configuration or defaults if non exist.
|
* Loads a saved configuration or defaults if non exist.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
GCSControlGadgetConfiguration::GCSControlGadgetConfiguration(QString classId, QSettings *qSettings, QObject *parent) :
|
GCSControlGadgetConfiguration::GCSControlGadgetConfiguration(QString classId, QSettings &settings, QObject *parent) :
|
||||||
IUAVGadgetConfiguration(classId, parent),
|
IUAVGadgetConfiguration(classId, parent)
|
||||||
rollChannel(-1),
|
|
||||||
pitchChannel(-1),
|
|
||||||
yawChannel(-1),
|
|
||||||
throttleChannel(-1)
|
|
||||||
{
|
{
|
||||||
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++) {
|
udp_port = settings.value("controlPortUDP").toUInt();
|
||||||
buttonSettings[i].ActionID = 0;
|
udp_host = QHostAddress(settings.value("controlHostUDP").toString());
|
||||||
buttonSettings[i].FunctionID = 0;
|
|
||||||
buttonSettings[i].Amount = 0;
|
for (int i = 0; i < 8; i++) {
|
||||||
channelReverse[i] = 0;
|
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();
|
GCSControlGadgetConfiguration::GCSControlGadgetConfiguration(const GCSControlGadgetConfiguration &obj) :
|
||||||
udp_host = QHostAddress(qSettings->value("controlHostUDP").toString());
|
IUAVGadgetConfiguration(obj.classId(), obj.parent())
|
||||||
|
{
|
||||||
|
controlsMode = obj.controlsMode;
|
||||||
|
rollChannel = obj.rollChannel;
|
||||||
|
pitchChannel = obj.pitchChannel;
|
||||||
|
yawChannel = obj.yawChannel;
|
||||||
|
throttleChannel = obj.throttleChannel;
|
||||||
|
|
||||||
int i;
|
udp_host = obj.udp_host;
|
||||||
for (i = 0; i < 8; i++) {
|
udp_port = obj.udp_port;
|
||||||
buttonSettings[i].ActionID = qSettings->value(QString().sprintf("button%dAction", i)).toInt();
|
|
||||||
buttonSettings[i].FunctionID = qSettings->value(QString().sprintf("button%dFunction", i)).toInt();
|
for (int i = 0; i < 8; i++) {
|
||||||
buttonSettings[i].Amount = qSettings->value(QString().sprintf("button%dAmount", i)).toDouble();
|
buttonSettings[i].ActionID = obj.buttonSettings[i].ActionID;
|
||||||
channelReverse[i] = qSettings->value(QString().sprintf("channel%dReverse", i)).toBool();
|
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;
|
return udp_port;
|
||||||
}
|
}
|
||||||
|
|
||||||
QHostAddress GCSControlGadgetConfiguration::getUDPControlHost()
|
QHostAddress GCSControlGadgetConfiguration::getUDPControlHost()
|
||||||
{
|
{
|
||||||
return udp_host;
|
return udp_host;
|
||||||
@ -96,14 +101,13 @@ QList<int> GCSControlGadgetConfiguration::getChannelsMapping()
|
|||||||
ql << rollChannel << pitchChannel << yawChannel << throttleChannel;
|
ql << rollChannel << pitchChannel << yawChannel << throttleChannel;
|
||||||
return ql;
|
return ql;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<bool> GCSControlGadgetConfiguration::getChannelsReverse()
|
QList<bool> GCSControlGadgetConfiguration::getChannelsReverse()
|
||||||
{
|
{
|
||||||
QList<bool> ql;
|
QList<bool> ql;
|
||||||
int i;
|
for (int i = 0; i < 8; i++) {
|
||||||
for (i = 0; i < 8; i++) {
|
|
||||||
ql << channelReverse[i];
|
ql << channelReverse[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
return ql;
|
return ql;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,51 +115,30 @@ QList<bool> GCSControlGadgetConfiguration::getChannelsReverse()
|
|||||||
* Clones a configuration.
|
* Clones a configuration.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
IUAVGadgetConfiguration *GCSControlGadgetConfiguration::clone()
|
IUAVGadgetConfiguration *GCSControlGadgetConfiguration::clone() const
|
||||||
{
|
{
|
||||||
GCSControlGadgetConfiguration *m = new GCSControlGadgetConfiguration(this->classId());
|
return new GCSControlGadgetConfiguration(*this);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves a configuration.
|
* Saves a configuration.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void GCSControlGadgetConfiguration::saveConfig(QSettings *settings) const
|
void GCSControlGadgetConfiguration::saveConfig(QSettings &settings) const
|
||||||
{
|
{
|
||||||
settings->setValue("controlsMode", controlsMode);
|
settings.setValue("controlsMode", controlsMode);
|
||||||
settings->setValue("rollChannel", rollChannel);
|
settings.setValue("rollChannel", rollChannel);
|
||||||
settings->setValue("pitchChannel", pitchChannel);
|
settings.setValue("pitchChannel", pitchChannel);
|
||||||
settings->setValue("yawChannel", yawChannel);
|
settings.setValue("yawChannel", yawChannel);
|
||||||
settings->setValue("throttleChannel", throttleChannel);
|
settings.setValue("throttleChannel", throttleChannel);
|
||||||
|
|
||||||
settings->setValue("controlPortUDP", QString::number(udp_port));
|
settings.setValue("controlPortUDP", QString::number(udp_port));
|
||||||
settings->setValue("controlHostUDP", udp_host.toString());
|
settings.setValue("controlHostUDP", udp_host.toString());
|
||||||
|
|
||||||
int i;
|
for (int i = 0; i < 8; i++) {
|
||||||
for (i = 0; i < 8; i++) {
|
settings.setValue(QString().sprintf("button%dAction", i), buttonSettings[i].ActionID);
|
||||||
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%dFunction", i), buttonSettings[i].FunctionID);
|
settings.setValue(QString().sprintf("button%dAmount", i), buttonSettings[i].Amount);
|
||||||
settings->setValue(QString().sprintf("button%dAmount", i), buttonSettings[i].Amount);
|
settings.setValue(QString().sprintf("channel%dReverse", i), channelReverse[i]);
|
||||||
settings->setValue(QString().sprintf("channel%dReverse", i), channelReverse[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,8 @@
|
|||||||
#define GCSCONTROLGADGETCONFIGURATION_H
|
#define GCSCONTROLGADGETCONFIGURATION_H
|
||||||
|
|
||||||
#include <coreplugin/iuavgadgetconfiguration.h>
|
#include <coreplugin/iuavgadgetconfiguration.h>
|
||||||
#include <QtNetwork/QHostAddress>
|
|
||||||
|
#include <QHostAddress>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int ActionID;
|
int ActionID;
|
||||||
@ -42,14 +43,16 @@ typedef struct {
|
|||||||
QHostAddress address;
|
QHostAddress address;
|
||||||
} portSettingsStruct;
|
} portSettingsStruct;
|
||||||
|
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
|
||||||
|
|
||||||
class GCSControlGadgetConfiguration : public IUAVGadgetConfiguration {
|
class GCSControlGadgetConfiguration : public IUAVGadgetConfiguration {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
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)
|
void setControlsMode(int mode)
|
||||||
{
|
{
|
||||||
@ -63,8 +66,8 @@ public:
|
|||||||
{
|
{
|
||||||
return controlsMode;
|
return controlsMode;
|
||||||
}
|
}
|
||||||
QList<int> getChannelsMapping();
|
QList<int> getChannelsMapping();
|
||||||
QList<bool> getChannelsReverse();
|
QList<bool> getChannelsReverse();
|
||||||
|
|
||||||
buttonSettingsStruct getbuttonSettings(int i)
|
buttonSettingsStruct getbuttonSettings(int i)
|
||||||
{
|
{
|
||||||
@ -87,10 +90,6 @@ public:
|
|||||||
channelReverse[i] = Reverse;
|
channelReverse[i] = Reverse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void saveConfig(QSettings *settings) const;
|
|
||||||
IUAVGadgetConfiguration *clone();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int controlsMode; // Mode1 to Mode4
|
int controlsMode; // Mode1 to Mode4
|
||||||
// Joystick mappings for roll/pitch/yaw/throttle:
|
// Joystick mappings for roll/pitch/yaw/throttle:
|
||||||
|
@ -45,9 +45,9 @@ IUAVGadget *GCSControlGadgetFactory::createGadget(QWidget *parent)
|
|||||||
return new GCSControlGadget(QString("GCSControlGadget"), gadgetWidget, parent, this->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)
|
IOptionsPage *GCSControlGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||||
|
@ -46,7 +46,7 @@ public:
|
|||||||
~GCSControlGadgetFactory();
|
~GCSControlGadgetFactory();
|
||||||
|
|
||||||
IUAVGadget *createGadget(QWidget *parent);
|
IUAVGadget *createGadget(QWidget *parent);
|
||||||
IUAVGadgetConfiguration *createConfiguration(QSettings *qSettings);
|
IUAVGadgetConfiguration *createConfiguration(QSettings &settings);
|
||||||
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -33,77 +33,52 @@
|
|||||||
* Loads a saved configuration or defaults if non exist.
|
* Loads a saved configuration or defaults if non exist.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
GpsDisplayGadgetConfiguration::GpsDisplayGadgetConfiguration(QString classId, QSettings *qSettings, QObject *parent) :
|
GpsDisplayGadgetConfiguration::GpsDisplayGadgetConfiguration(QString classId, QSettings &settings, QObject *parent) :
|
||||||
IUAVGadgetConfiguration(classId, 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)
|
|
||||||
{
|
{
|
||||||
// if a saved configuration exists load it
|
m_defaultPort = settings.value("defaultPort", "Unknown").toString();
|
||||||
if (qSettings != 0) {
|
m_defaultSpeed = (QSerialPort::BaudRate)settings.value("defaultSpeed", QSerialPort::UnknownBaud).toInt();
|
||||||
QSerialPort::BaudRate speed;
|
m_defaultDataBits = (QSerialPort::DataBits)settings.value("defaultDataBits", QSerialPort::UnknownDataBits).toInt();
|
||||||
QSerialPort::DataBits databits;
|
m_defaultFlow = (QSerialPort::FlowControl)settings.value("defaultFlow", QSerialPort::UnknownFlowControl).toInt();
|
||||||
QSerialPort::FlowControl flow;
|
m_defaultParity = (QSerialPort::Parity)settings.value("defaultParity", QSerialPort::UnknownParity).toInt();
|
||||||
QSerialPort::Parity parity;
|
m_defaultStopBits = (QSerialPort::StopBits)settings.value("defaultStopBits", QSerialPort::UnknownStopBits).toInt();
|
||||||
QSerialPort::StopBits stopbits;
|
m_connectionMode = settings.value("connectionMode", "Serial").toString();
|
||||||
|
m_defaultTimeOut = 5000;
|
||||||
|
}
|
||||||
|
|
||||||
int ispeed = qSettings->value("defaultSpeed").toInt();
|
GpsDisplayGadgetConfiguration::GpsDisplayGadgetConfiguration(const GpsDisplayGadgetConfiguration &obj) :
|
||||||
int idatabits = qSettings->value("defaultDataBits").toInt();
|
IUAVGadgetConfiguration(obj.classId(), obj.parent())
|
||||||
int iflow = qSettings->value("defaultFlow").toInt();
|
{
|
||||||
int iparity = qSettings->value("defaultParity").toInt();
|
m_defaultSpeed = obj.m_defaultSpeed;
|
||||||
int istopbits = qSettings->value("defaultStopBits").toInt();
|
m_defaultDataBits = obj.m_defaultDataBits;
|
||||||
QString port = qSettings->value("defaultPort").toString();
|
m_defaultFlow = obj.m_defaultFlow;
|
||||||
QString conMode = qSettings->value("connectionMode").toString();
|
m_defaultParity = obj.m_defaultParity;
|
||||||
|
m_defaultStopBits = obj.m_defaultStopBits;
|
||||||
databits = (QSerialPort::DataBits)idatabits;
|
m_defaultPort = obj.m_defaultPort;
|
||||||
flow = (QSerialPort::FlowControl)iflow;
|
m_connectionMode = obj.m_connectionMode;
|
||||||
parity = (QSerialPort::Parity)iparity;
|
m_defaultTimeOut = obj.m_defaultTimeOut;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clones a configuration.
|
* Clones a configuration.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
IUAVGadgetConfiguration *GpsDisplayGadgetConfiguration::clone()
|
IUAVGadgetConfiguration *GpsDisplayGadgetConfiguration::clone() const
|
||||||
{
|
{
|
||||||
GpsDisplayGadgetConfiguration *m = new GpsDisplayGadgetConfiguration(this->classId());
|
return new GpsDisplayGadgetConfiguration(*this);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves a configuration.
|
* Saves a configuration.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void GpsDisplayGadgetConfiguration::saveConfig(QSettings *settings) const
|
void GpsDisplayGadgetConfiguration::saveConfig(QSettings &settings) const
|
||||||
{
|
{
|
||||||
settings->setValue("defaultSpeed", m_defaultSpeed);
|
settings.setValue("defaultSpeed", m_defaultSpeed);
|
||||||
settings->setValue("defaultDataBits", m_defaultDataBits);
|
settings.setValue("defaultDataBits", m_defaultDataBits);
|
||||||
settings->setValue("defaultFlow", m_defaultFlow);
|
settings.setValue("defaultFlow", m_defaultFlow);
|
||||||
settings->setValue("defaultParity", m_defaultParity);
|
settings.setValue("defaultParity", m_defaultParity);
|
||||||
settings->setValue("defaultStopBits", m_defaultStopBits);
|
settings.setValue("defaultStopBits", m_defaultStopBits);
|
||||||
settings->setValue("defaultPort", m_defaultPort);
|
settings.setValue("defaultPort", m_defaultPort);
|
||||||
settings->setValue("connectionMode", m_connectionMode);
|
settings.setValue("connectionMode", m_connectionMode);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,11 @@ struct PortSettings {
|
|||||||
class GpsDisplayGadgetConfiguration : public IUAVGadgetConfiguration {
|
class GpsDisplayGadgetConfiguration : public IUAVGadgetConfiguration {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
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)
|
void setConnectionMode(QString mode)
|
||||||
{
|
{
|
||||||
@ -59,7 +63,6 @@ public:
|
|||||||
{
|
{
|
||||||
return m_connectionMode;
|
return m_connectionMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set port configuration functions
|
// set port configuration functions
|
||||||
void setSpeed(QSerialPort::BaudRate speed)
|
void setSpeed(QSerialPort::BaudRate speed)
|
||||||
{
|
{
|
||||||
@ -120,9 +123,6 @@ public:
|
|||||||
return m_defaultTimeOut;
|
return m_defaultTimeOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveConfig(QSettings *settings) const;
|
|
||||||
IUAVGadgetConfiguration *clone();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_connectionMode;
|
QString m_connectionMode;
|
||||||
QString m_defaultPort;
|
QString m_defaultPort;
|
||||||
|
@ -47,9 +47,9 @@ Core::IUAVGadget *GpsDisplayGadgetFactory::createGadget(QWidget *parent)
|
|||||||
return new GpsDisplayGadget(QString("GpsDisplayGadget"), gadgetWidget, 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)
|
IOptionsPage *GpsDisplayGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||||
|
@ -44,7 +44,7 @@ public:
|
|||||||
~GpsDisplayGadgetFactory();
|
~GpsDisplayGadgetFactory();
|
||||||
|
|
||||||
Core::IUAVGadget *createGadget(QWidget *parent);
|
Core::IUAVGadget *createGadget(QWidget *parent);
|
||||||
IUAVGadgetConfiguration *createConfiguration(QSettings *qSettings);
|
IUAVGadgetConfiguration *createConfiguration(QSettings &settings);
|
||||||
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -28,9 +28,8 @@
|
|||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
Settings::Settings(QString settingsPath, QObject *parent) :
|
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
|
// default settings
|
||||||
sendToHost = "127.0.0.1";
|
sendToHost = "127.0.0.1";
|
||||||
sendToPort = 40100;
|
sendToPort = 40100;
|
||||||
@ -51,12 +50,12 @@ Settings::Settings(QString settingsPath, QObject *parent) :
|
|||||||
void Settings::read()
|
void Settings::read()
|
||||||
{
|
{
|
||||||
// network
|
// network
|
||||||
listenOnHost = settings->value("listen_on_host", listenOnHost).toString();
|
listenOnHost = settings.value("listen_on_host", listenOnHost).toString();
|
||||||
listenOnPort = settings->value("listen_on_port", listenOnPort).toInt();
|
listenOnPort = settings.value("listen_on_port", listenOnPort).toInt();
|
||||||
sendToHost = settings->value("send_to_host", sendToHost).toString();
|
sendToHost = settings.value("send_to_host", sendToHost).toString();
|
||||||
sendToPort = settings->value("send_to_port", sendToPort).toInt();
|
sendToPort = settings.value("send_to_port", sendToPort).toInt();
|
||||||
|
|
||||||
QString allChannels = settings->value("all_channels").toString();
|
QString allChannels = settings.value("all_channels").toString();
|
||||||
QString chan;
|
QString chan;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach(chan, allChannels.split(" "))
|
foreach(chan, allChannels.split(" "))
|
||||||
@ -67,31 +66,31 @@ void Settings::read()
|
|||||||
QString map = "";
|
QString map = "";
|
||||||
for (quint8 i = 0; i < 10; ++i) {
|
for (quint8 i = 0; i < 10; ++i) {
|
||||||
num = QString::number(i + 1);
|
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));
|
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;
|
sendToRX = (sendTo == "RX") ? true : false;
|
||||||
|
|
||||||
// outputs
|
// outputs
|
||||||
for (quint8 i = 0; i < 8; ++i) {
|
for (quint8 i = 0; i < 8; ++i) {
|
||||||
num = QString::number(i + 1);
|
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));
|
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;
|
takeFromTX = (takeFrom == "TX") ? true : false;
|
||||||
|
|
||||||
// video
|
// video
|
||||||
quint8 resolutionNum = settings->value("Video/number_of_resolutions", 0).toInt();
|
quint8 resolutionNum = settings.value("Video/number_of_resolutions", 0).toInt();
|
||||||
if (resolutionNum > 0) {
|
if (resolutionNum > 0) {
|
||||||
videoModes.clear();
|
videoModes.clear();
|
||||||
videoModes << resolutionNum;
|
videoModes << resolutionNum;
|
||||||
for (quint8 i = 0; i < resolutionNum; ++i) {
|
for (quint8 i = 0; i < resolutionNum; ++i) {
|
||||||
num = QString::number(i + 1);
|
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;
|
QString mode;
|
||||||
foreach(mode, modes.split(" "))
|
foreach(mode, modes.split(" "))
|
||||||
videoModes << mode.toInt();
|
videoModes << mode.toInt();
|
||||||
|
@ -77,8 +77,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
QHash<QString, quint8> channels;
|
QHash<QString, quint8> channels;
|
||||||
QSettings *settings;
|
|
||||||
QString sendToHost;
|
QString sendToHost;
|
||||||
quint16 sendToPort;
|
quint16 sendToPort;
|
||||||
QString listenOnHost;
|
QString listenOnHost;
|
||||||
|
@ -27,136 +27,138 @@
|
|||||||
|
|
||||||
#include "hitlconfiguration.h"
|
#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)
|
IUAVGadgetConfiguration(classId, parent)
|
||||||
{
|
{
|
||||||
// Default settings values
|
simSettings.simulatorId = settings.value("simulatorId", DFLT_SIMULATOR_ID).toString();
|
||||||
settings.simulatorId = "";
|
simSettings.binPath = settings.value("binPath", DFLT_BIN_PATH).toString();
|
||||||
settings.binPath = "";
|
simSettings.dataPath = settings.value("dataPath", DFLT_DATA_PATH).toString();
|
||||||
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 = "";
|
|
||||||
|
|
||||||
settings.attRawEnabled = false;
|
simSettings.hostAddress = settings.value("hostAddress", DFLT_HOST_ADDRESS).toString();
|
||||||
settings.attRawRate = 20;
|
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;
|
simSettings.latitude = settings.value("latitude", DFLT_LATITUDE).toString();
|
||||||
settings.attActHW = false;
|
simSettings.longitude = settings.value("longitude", DFLT_LONGITUDE).toString();
|
||||||
settings.attActSim = true;
|
simSettings.startSim = settings.value("startSim", DFLT_START_SIM).toBool();
|
||||||
settings.attActCalc = false;
|
simSettings.addNoise = settings.value("noiseCheckBox", DFLT_ADD_NOISE).toBool();
|
||||||
|
|
||||||
settings.gpsPositionEnabled = false;
|
simSettings.gcsReceiverEnabled = settings.value("gcsReceiverEnabled", DFLT_GCS_RECEIVER_ENABLED).toBool();
|
||||||
settings.gpsPosRate = 100;
|
simSettings.manualControlEnabled = settings.value("manualControlEnabled", DFLT_MANUAL_CONTROL_ENABLED).toBool();
|
||||||
|
|
||||||
settings.groundTruthEnabled = false;
|
simSettings.attRawEnabled = settings.value("attRawEnabled", DFLT_ATT_RAW_ENABLED).toBool();
|
||||||
settings.groundTruthRate = 100;
|
simSettings.attRawRate = settings.value("attRawRate", DFLT_ATT_RAW_RATE).toInt();
|
||||||
|
|
||||||
settings.inputCommand = false;
|
simSettings.attStateEnabled = settings.value("attStateEnabled", DFLT_ATT_STATE_ENABLED).toBool();
|
||||||
settings.gcsReceiverEnabled = false;
|
simSettings.attActHW = settings.value("attActHW", DFLT_ATT_ACT_HW).toBool();
|
||||||
settings.manualControlEnabled = false;
|
simSettings.attActSim = settings.value("attActSim", DFLT_ATT_ACT_SIM).toBool();
|
||||||
settings.minOutputPeriod = 100;
|
simSettings.attActCalc = settings.value("attActCalc", DFLT_ATT_ACT_CALC).toBool();
|
||||||
|
|
||||||
settings.airspeedStateEnabled = false;
|
simSettings.baroSensorEnabled = settings.value("baroSensorEnabled", DFLT_BARO_SENSOR_ENABLED).toBool();
|
||||||
settings.airspeedStateRate = 100;
|
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
|
simSettings.groundTruthEnabled = settings.value("groundTruthEnabled", DFLT_GROUND_TRUTH_ENABLED).toBool();
|
||||||
if (qSettings != 0) {
|
simSettings.groundTruthRate = settings.value("groundTruthRate", DFLT_GROUND_TRUTH_RATE).toInt();
|
||||||
settings.simulatorId = qSettings->value("simulatorId").toString();
|
|
||||||
settings.binPath = qSettings->value("binPath").toString();
|
|
||||||
settings.dataPath = qSettings->value("dataPath").toString();
|
|
||||||
|
|
||||||
settings.hostAddress = qSettings->value("hostAddress").toString();
|
simSettings.inputCommand = settings.value("inputCommand", DFLT_INPUT_COMMAND).toBool();
|
||||||
settings.remoteAddress = qSettings->value("remoteAddress").toString();
|
simSettings.minOutputPeriod = settings.value("minOutputPeriod", DFLT_MIN_INPUT_PERIOD).toInt();
|
||||||
settings.outPort = qSettings->value("outPort").toInt();
|
|
||||||
settings.inPort = qSettings->value("inPort").toInt();
|
|
||||||
|
|
||||||
settings.latitude = qSettings->value("latitude").toString();
|
simSettings.airspeedStateEnabled = settings.value("airspeedStateEnabled", DFLT_AIRSPEED_STATE_ENABLED).toBool();
|
||||||
settings.longitude = qSettings->value("longitude").toString();
|
simSettings.airspeedStateRate = settings.value("airspeedStateRate", DFLT_AIRSPEED_STATE_RATE).toInt();
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
IUAVGadgetConfiguration *HITLConfiguration::clone() const
|
||||||
return m;
|
{
|
||||||
|
return new HITLConfiguration(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves a configuration.
|
* Saves a configuration.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void HITLConfiguration::saveConfig(QSettings *qSettings) const
|
void HITLConfiguration::saveConfig(QSettings &settings) const
|
||||||
{
|
{
|
||||||
qSettings->setValue("simulatorId", settings.simulatorId);
|
settings.setValue("simulatorId", simSettings.simulatorId);
|
||||||
qSettings->setValue("binPath", settings.binPath);
|
settings.setValue("binPath", simSettings.binPath);
|
||||||
qSettings->setValue("dataPath", settings.dataPath);
|
settings.setValue("dataPath", simSettings.dataPath);
|
||||||
|
|
||||||
qSettings->setValue("hostAddress", settings.hostAddress);
|
settings.setValue("hostAddress", simSettings.hostAddress);
|
||||||
qSettings->setValue("remoteAddress", settings.remoteAddress);
|
settings.setValue("remoteAddress", simSettings.remoteAddress);
|
||||||
qSettings->setValue("outPort", settings.outPort);
|
settings.setValue("outPort", simSettings.outPort);
|
||||||
qSettings->setValue("inPort", settings.inPort);
|
settings.setValue("inPort", simSettings.inPort);
|
||||||
|
|
||||||
qSettings->setValue("latitude", settings.latitude);
|
settings.setValue("latitude", simSettings.latitude);
|
||||||
qSettings->setValue("longitude", settings.longitude);
|
settings.setValue("longitude", simSettings.longitude);
|
||||||
qSettings->setValue("addNoise", settings.addNoise);
|
settings.setValue("addNoise", simSettings.addNoise);
|
||||||
qSettings->setValue("startSim", settings.startSim);
|
settings.setValue("startSim", simSettings.startSim);
|
||||||
|
|
||||||
qSettings->setValue("gcsReceiverEnabled", settings.gcsReceiverEnabled);
|
settings.setValue("gcsReceiverEnabled", simSettings.gcsReceiverEnabled);
|
||||||
qSettings->setValue("manualControlEnabled", settings.manualControlEnabled);
|
settings.setValue("manualControlEnabled", simSettings.manualControlEnabled);
|
||||||
|
|
||||||
qSettings->setValue("attRawEnabled", settings.attRawEnabled);
|
settings.setValue("attRawEnabled", simSettings.attRawEnabled);
|
||||||
qSettings->setValue("attRawRate", settings.attRawRate);
|
settings.setValue("attRawRate", simSettings.attRawRate);
|
||||||
qSettings->setValue("attStateEnabled", settings.attStateEnabled);
|
settings.setValue("attStateEnabled", simSettings.attStateEnabled);
|
||||||
qSettings->setValue("attActHW", settings.attActHW);
|
settings.setValue("attActHW", simSettings.attActHW);
|
||||||
qSettings->setValue("attActSim", settings.attActSim);
|
settings.setValue("attActSim", simSettings.attActSim);
|
||||||
qSettings->setValue("attActCalc", settings.attActCalc);
|
settings.setValue("attActCalc", simSettings.attActCalc);
|
||||||
qSettings->setValue("baroSensorEnabled", settings.baroSensorEnabled);
|
settings.setValue("baroSensorEnabled", simSettings.baroSensorEnabled);
|
||||||
qSettings->setValue("baroAltRate", settings.baroAltRate);
|
settings.setValue("baroAltRate", simSettings.baroAltRate);
|
||||||
qSettings->setValue("gpsPositionEnabled", settings.gpsPositionEnabled);
|
settings.setValue("gpsPositionEnabled", simSettings.gpsPositionEnabled);
|
||||||
qSettings->setValue("gpsPosRate", settings.gpsPosRate);
|
settings.setValue("gpsPosRate", simSettings.gpsPosRate);
|
||||||
qSettings->setValue("groundTruthEnabled", settings.groundTruthEnabled);
|
settings.setValue("groundTruthEnabled", simSettings.groundTruthEnabled);
|
||||||
qSettings->setValue("groundTruthRate", settings.groundTruthRate);
|
settings.setValue("groundTruthRate", simSettings.groundTruthRate);
|
||||||
qSettings->setValue("inputCommand", settings.inputCommand);
|
settings.setValue("inputCommand", simSettings.inputCommand);
|
||||||
qSettings->setValue("minOutputPeriod", settings.minOutputPeriod);
|
settings.setValue("minOutputPeriod", simSettings.minOutputPeriod);
|
||||||
|
|
||||||
qSettings->setValue("airspeedStateEnabled", settings.airspeedStateEnabled);
|
settings.setValue("airspeedStateEnabled", simSettings.airspeedStateEnabled);
|
||||||
qSettings->setValue("airspeedStateRate", settings.airspeedStateRate);
|
settings.setValue("airspeedStateRate", simSettings.airspeedStateRate);
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
#define HITLCONFIGURATION_H
|
#define HITLCONFIGURATION_H
|
||||||
|
|
||||||
#include <coreplugin/iuavgadgetconfiguration.h>
|
#include <coreplugin/iuavgadgetconfiguration.h>
|
||||||
#include <QColor>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include <simulator.h>
|
#include <simulator.h>
|
||||||
@ -40,25 +39,26 @@ class HITLConfiguration : public IUAVGadgetConfiguration {
|
|||||||
Q_OBJECT Q_PROPERTY(SimulatorSettings settings READ Settings WRITE setSimulatorSettings)
|
Q_OBJECT Q_PROPERTY(SimulatorSettings settings READ Settings WRITE setSimulatorSettings)
|
||||||
|
|
||||||
public:
|
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() const;
|
||||||
IUAVGadgetConfiguration *clone();
|
void saveConfig(QSettings &settings) const;
|
||||||
|
|
||||||
SimulatorSettings Settings() const
|
SimulatorSettings Settings() const
|
||||||
{
|
{
|
||||||
return settings;
|
return simSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setSimulatorSettings(const SimulatorSettings & params)
|
void setSimulatorSettings(const SimulatorSettings & params)
|
||||||
{
|
{
|
||||||
settings = params;
|
simSettings = params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SimulatorSettings settings;
|
SimulatorSettings simSettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // HITLCONFIGURATION_H
|
#endif // HITLCONFIGURATION_H
|
||||||
|
@ -45,9 +45,9 @@ Core::IUAVGadget *HITLFactory::createGadget(QWidget *parent)
|
|||||||
return new HITLGadget(QString("HITL"), gadgetWidget, 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)
|
IOptionsPage *HITLFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||||
|
@ -44,7 +44,7 @@ public:
|
|||||||
~HITLFactory();
|
~HITLFactory();
|
||||||
|
|
||||||
IUAVGadget *createGadget(QWidget *parent);
|
IUAVGadget *createGadget(QWidget *parent);
|
||||||
IUAVGadgetConfiguration *createConfiguration(QSettings *qSettings);
|
IUAVGadgetConfiguration *createConfiguration(QSettings &settings);
|
||||||
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -28,13 +28,15 @@
|
|||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
#include "importexportgadgetwidget.h"
|
#include "importexportgadgetwidget.h"
|
||||||
|
|
||||||
#include "ui_importexportgadgetwidget.h"
|
#include "ui_importexportgadgetwidget.h"
|
||||||
#include "utils/xmlconfig.h"
|
#include "utils/xmlconfig.h"
|
||||||
#include "coreplugin/uavgadgetinstancemanager.h"
|
#include "coreplugin/uavgadgetinstancemanager.h"
|
||||||
#include "coreplugin/icore.h"
|
#include "coreplugin/icore.h"
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <extensionsystem/pluginspec.h>
|
#include <extensionsystem/pluginspec.h>
|
||||||
#include <QtDebug>
|
|
||||||
|
#include <QDebug>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
@ -125,18 +127,17 @@ void ImportExportGadgetWidget::exportConfiguration(const QString & fileName)
|
|||||||
bool doAllGadgets = ui->checkBoxAllGadgets->isChecked();
|
bool doAllGadgets = ui->checkBoxAllGadgets->isChecked();
|
||||||
bool doPlugins = ui->checkBoxPlugins->isChecked();
|
bool doPlugins = ui->checkBoxPlugins->isChecked();
|
||||||
|
|
||||||
QSettings::Format format = XmlConfig::XmlSettingsFormat;
|
QSettings settings(fileName, XmlConfig::XmlFormat);
|
||||||
QSettings qs(fileName, format);
|
|
||||||
|
|
||||||
if (doGeneral) {
|
if (doGeneral) {
|
||||||
Core::ICore::instance()->saveMainSettings(&qs);
|
Core::ICore::instance()->saveMainSettings(settings);
|
||||||
}
|
}
|
||||||
if (doAllGadgets) {
|
if (doAllGadgets) {
|
||||||
Core::ICore::instance()->uavGadgetInstanceManager()->saveSettings(&qs);
|
Core::ICore::instance()->uavGadgetInstanceManager()->saveSettings(settings);
|
||||||
}
|
}
|
||||||
if (doPlugins) {
|
if (doPlugins) {
|
||||||
foreach(Core::IConfigurablePlugin * plugin, getConfigurables()) {
|
foreach(Core::IConfigurablePlugin * plugin, getConfigurables()) {
|
||||||
Core::ICore::instance()->saveSettings(plugin, &qs);
|
Core::ICore::instance()->saveSettings(plugin, settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,17 +185,17 @@ void ImportExportGadgetWidget::importConfiguration(const QString & fileName)
|
|||||||
bool doAllGadgets = ui->checkBoxAllGadgets->isChecked();
|
bool doAllGadgets = ui->checkBoxAllGadgets->isChecked();
|
||||||
bool doPlugins = ui->checkBoxPlugins->isChecked();
|
bool doPlugins = ui->checkBoxPlugins->isChecked();
|
||||||
|
|
||||||
QSettings qs(fileName, XmlConfig::XmlSettingsFormat);
|
QSettings settings(fileName, XmlConfig::XmlFormat);
|
||||||
|
|
||||||
if (doAllGadgets) {
|
if (doAllGadgets) {
|
||||||
Core::ICore::instance()->uavGadgetInstanceManager()->readSettings(&qs);
|
Core::ICore::instance()->uavGadgetInstanceManager()->readSettings(settings);
|
||||||
}
|
}
|
||||||
if (doGeneral) {
|
if (doGeneral) {
|
||||||
Core::ICore::instance()->readMainSettings(&qs);
|
Core::ICore::instance()->readMainSettings(settings);
|
||||||
}
|
}
|
||||||
if (doPlugins) {
|
if (doPlugins) {
|
||||||
foreach(Core::IConfigurablePlugin * plugin, getConfigurables()) {
|
foreach(Core::IConfigurablePlugin * plugin, getConfigurables()) {
|
||||||
Core::ICore::instance()->readSettings(plugin, &qs);
|
Core::ICore::instance()->readSettings(plugin, settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ TARGET = IPconnection
|
|||||||
|
|
||||||
QT += network widgets
|
QT += network widgets
|
||||||
|
|
||||||
DEFINES += IPconnection_LIBRARY
|
DEFINES += IPCONNECTION_LIBRARY
|
||||||
|
|
||||||
include(../../plugin.pri)
|
include(../../plugin.pri)
|
||||||
include(ipconnection_dependencies.pri)
|
include(ipconnection_dependencies.pri)
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file IPconnection_global.h
|
* @file ipconnection_global.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
|
||||||
|
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* @addtogroup GCSPlugins GCS Plugins
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
* @{
|
* @{
|
||||||
* @addtogroup IPConnPlugin IP Telemetry Plugin
|
* @addtogroup IPConnPlugin IP Telemetry Plugin
|
||||||
* @{
|
* @{
|
||||||
* @brief IP Connection Plugin impliment telemetry over TCP/IP and UDP/IP
|
* @brief IP Connection Plugin implements telemetry over TCP/IP and UDP/IP
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -25,15 +26,15 @@
|
|||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef IPconnection_GLOBAL_H
|
#ifndef IPCONNECTION_GLOBAL_H
|
||||||
#define IPconnection_GLOBAL_H
|
#define IPCONNECTION_GLOBAL_H
|
||||||
|
|
||||||
#include <QtCore/qglobal.h>
|
#include <QtCore/qglobal.h>
|
||||||
|
|
||||||
#if defined(IPconnection_LIBRARY)
|
#if defined(IPCONNECTION_LIBRARY)
|
||||||
# define IPconnection_EXPORT Q_DECL_EXPORT
|
# define IPCONNECTION_EXPORT Q_DECL_EXPORT
|
||||||
#else
|
#else
|
||||||
# define IPconnection_EXPORT Q_DECL_IMPORT
|
# define IPCONNECTION_EXPORT Q_DECL_IMPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // IPconnection_GLOBAL_H
|
#endif // IPCONNECTION_GLOBAL_H
|
||||||
|
@ -9,12 +9,9 @@ class IPConnection : public QObject {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
IPConnection(IPConnectionConnection *connection);
|
||||||
IPConnection(IPconnectionConnection *connection);
|
|
||||||
// virtual ~IPConnection();
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void onOpenDevice(QString HostName, int Port, bool UseTCP);
|
void onOpenDevice(QString HostName, int Port, bool UseTCP);
|
||||||
void onCloseDevice(QAbstractSocket *ipSocket);
|
void onCloseDevice(QAbstractSocket *ipSocket);
|
||||||
};
|
};
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file IPconnectionconfiguration.cpp
|
* @file ipconnectionconfiguration.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
|
||||||
|
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* @addtogroup GCSPlugins GCS Plugins
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
* @{
|
* @{
|
||||||
* @addtogroup IPConnPlugin IP Telemetry Plugin
|
* @addtogroup IPConnPlugin IP Telemetry Plugin
|
||||||
* @{
|
* @{
|
||||||
* @brief IP Connection Plugin impliment telemetry over TCP/IP and UDP/IP
|
* @brief IP Connection Plugin implements telemetry over TCP/IP and UDP/IP
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -26,66 +27,40 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ipconnectionconfiguration.h"
|
#include "ipconnectionconfiguration.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
IPconnectionConfiguration::IPconnectionConfiguration(QString classId, QSettings *qSettings, QObject *parent) :
|
IPConnectionConfiguration::IPConnectionConfiguration(QString classId, QSettings &settings, QObject *parent) :
|
||||||
IUAVGadgetConfiguration(classId, parent),
|
IUAVGadgetConfiguration(classId, parent)
|
||||||
m_HostName("127.0.0.1"),
|
|
||||||
m_Port(1000),
|
|
||||||
m_UseTCP(1)
|
|
||||||
{
|
{
|
||||||
Q_UNUSED(qSettings);
|
m_hostName = settings.value("HostName", "").toString();
|
||||||
|
m_port = settings.value("Port", 9000).toInt();
|
||||||
settings = Core::ICore::instance()->settings();
|
m_useTCP = settings.value("UseTCP", true).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
IPconnectionConfiguration::~IPconnectionConfiguration()
|
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());
|
return new IPConnectionConfiguration(*this);
|
||||||
|
|
||||||
m->m_Port = m_Port;
|
|
||||||
m->m_HostName = m_HostName;
|
|
||||||
m->m_UseTCP = m_UseTCP;
|
|
||||||
return m;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves a configuration.
|
* Saves a configuration.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void IPconnectionConfiguration::saveConfig(QSettings *qSettings) const
|
void IPConnectionConfiguration::saveConfig(QSettings &settings) const
|
||||||
{
|
{
|
||||||
qSettings->setValue("port", m_Port);
|
settings.setValue("HostName", m_hostName);
|
||||||
qSettings->setValue("hostName", m_HostName);
|
settings.setValue("Port", m_port);
|
||||||
qSettings->setValue("useTCP", m_UseTCP);
|
settings.setValue("UseTCP", m_useTCP);
|
||||||
}
|
|
||||||
|
|
||||||
void IPconnectionConfiguration::savesettings() const
|
|
||||||
{
|
|
||||||
settings->beginGroup(QLatin1String("IPconnection"));
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void IPconnectionConfiguration::restoresettings()
|
|
||||||
{
|
|
||||||
settings->beginGroup(QLatin1String("IPconnection"));
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file IPconnectionconfiguration.h
|
* @file ipconnectionconfiguration.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
|
||||||
|
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* @addtogroup GCSPlugins GCS Plugins
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
* @{
|
* @{
|
||||||
* @addtogroup IPConnPlugin IP Telemetry Plugin
|
* @addtogroup IPConnPlugin IP Telemetry Plugin
|
||||||
* @{
|
* @{
|
||||||
* @brief IP Connection Plugin impliment telemetry over TCP/IP and UDP/IP
|
* @brief IP Connection Plugin implements telemetry over TCP/IP and UDP/IP
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -25,64 +26,60 @@
|
|||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef IPconnectionCONFIGURATION_H
|
#ifndef IPCONFIGURATIONCONFIGURATION_H
|
||||||
#define IPconnectionCONFIGURATION_H
|
#define IPCONFIGURATIONCONFIGURATION_H
|
||||||
|
|
||||||
#include <coreplugin/iuavgadgetconfiguration.h>
|
#include <coreplugin/iuavgadgetconfiguration.h>
|
||||||
#include <QtCore/QString>
|
|
||||||
#include <QtCore/QSettings>
|
#include <QString>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
|
||||||
class IPconnectionConfiguration : public IUAVGadgetConfiguration {
|
class IPConnectionConfiguration : public IUAVGadgetConfiguration {
|
||||||
Q_OBJECT Q_PROPERTY(QString HostName READ HostName WRITE setHostName)
|
Q_OBJECT Q_PROPERTY(QString HostName READ hostName WRITE setHostName)
|
||||||
Q_PROPERTY(int Port READ Port WRITE setPort)
|
Q_PROPERTY(int Port READ port WRITE setPort)
|
||||||
Q_PROPERTY(int UseTCP READ UseTCP WRITE setUseTCP)
|
Q_PROPERTY(int UseTCP READ useTCP WRITE setUseTCP)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit IPconnectionConfiguration(QString classId, QSettings *qSettings = 0, QObject *parent = 0);
|
explicit IPConnectionConfiguration(QString classId, QSettings &settings, QObject *parent = 0);
|
||||||
|
explicit IPConnectionConfiguration(const IPConnectionConfiguration &obj);
|
||||||
|
|
||||||
virtual ~IPconnectionConfiguration();
|
virtual ~IPConnectionConfiguration();
|
||||||
void saveConfig(QSettings *settings) const;
|
|
||||||
// void savesettings(QSettings* settings) const;
|
|
||||||
// void restoresettings(QSettings* settings);
|
|
||||||
void savesettings() const;
|
|
||||||
void restoresettings();
|
|
||||||
IUAVGadgetConfiguration *clone();
|
|
||||||
|
|
||||||
QString HostName() const
|
IUAVGadgetConfiguration *clone() const;
|
||||||
{
|
void saveConfig(QSettings &settings) const;
|
||||||
return m_HostName;
|
|
||||||
}
|
|
||||||
int Port() const
|
|
||||||
{
|
|
||||||
return m_Port;
|
|
||||||
}
|
|
||||||
int UseTCP() const
|
|
||||||
{
|
|
||||||
return m_UseTCP;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
QString hostName() const
|
||||||
|
{
|
||||||
|
return m_hostName;
|
||||||
|
}
|
||||||
|
int port() const
|
||||||
|
{
|
||||||
|
return m_port;
|
||||||
|
}
|
||||||
|
int useTCP() const
|
||||||
|
{
|
||||||
|
return m_useTCP;
|
||||||
|
}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setHostName(QString HostName)
|
void setHostName(QString hostName)
|
||||||
{
|
{
|
||||||
m_HostName = HostName;
|
m_hostName = hostName;
|
||||||
}
|
}
|
||||||
void setPort(int Port)
|
void setPort(int port)
|
||||||
{
|
{
|
||||||
m_Port = Port;
|
m_port = port;
|
||||||
}
|
}
|
||||||
void setUseTCP(int UseTCP)
|
void setUseTCP(int useTCP)
|
||||||
{
|
{
|
||||||
m_UseTCP = UseTCP;
|
m_useTCP = useTCP;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_HostName;
|
QString m_hostName;
|
||||||
int m_Port;
|
int m_port;
|
||||||
int m_UseTCP;
|
int m_useTCP;
|
||||||
QSettings *settings;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // IPconnectionCONFIGURATION_H
|
#endif // IPCONFIGURATIONCONFIGURATION_H
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file IPconnectionoptionspage.cpp
|
* @file ipconnectionoptionspage.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
|
||||||
|
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* @addtogroup GCSPlugins GCS Plugins
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
* @{
|
* @{
|
||||||
* @addtogroup IPConnPlugin IP Telemetry Plugin
|
* @addtogroup IPConnPlugin IP Telemetry Plugin
|
||||||
* @{
|
* @{
|
||||||
* @brief IP Connection Plugin impliment telemetry over TCP/IP and UDP/IP
|
* @brief IP Connection Plugin implements telemetry over TCP/IP and UDP/IP
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -26,49 +27,44 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ipconnectionoptionspage.h"
|
#include "ipconnectionoptionspage.h"
|
||||||
#include "ipconnectionconfiguration.h"
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QComboBox>
|
|
||||||
#include <QSpinBox>
|
|
||||||
#include <QDoubleSpinBox>
|
|
||||||
#include <QRadioButton>
|
|
||||||
#include <QHBoxLayout>
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
|
|
||||||
#include "ui_ipconnectionoptionspage.h"
|
#include "ui_ipconnectionoptionspage.h"
|
||||||
|
|
||||||
|
#include "ipconnectionconfiguration.h"
|
||||||
|
|
||||||
IPconnectionOptionsPage::IPconnectionOptionsPage(IPconnectionConfiguration *config, QObject *parent) :
|
IPConnectionOptionsPage::IPConnectionOptionsPage(IPConnectionConfiguration *config, QObject *parent) :
|
||||||
IOptionsPage(parent),
|
IOptionsPage(parent), m_page(0), m_config(config)
|
||||||
m_config(config)
|
|
||||||
{}
|
{}
|
||||||
IPconnectionOptionsPage::~IPconnectionOptionsPage()
|
|
||||||
|
IPConnectionOptionsPage::~IPConnectionOptionsPage()
|
||||||
{}
|
{}
|
||||||
QWidget *IPconnectionOptionsPage::createPage(QWidget *parent)
|
|
||||||
|
QWidget *IPConnectionOptionsPage::createPage(QWidget *parent)
|
||||||
{
|
{
|
||||||
m_page = new Ui::IPconnectionOptionsPage();
|
m_page = new Ui::IPconnectionOptionsPage();
|
||||||
QWidget *w = new QWidget(parent);
|
QWidget *w = new QWidget(parent);
|
||||||
m_page->setupUi(w);
|
m_page->setupUi(w);
|
||||||
|
|
||||||
m_page->Port->setValue(m_config->Port());
|
m_page->Port->setValue(m_config->port());
|
||||||
m_page->HostName->setText(m_config->HostName());
|
m_page->HostName->setText(m_config->hostName());
|
||||||
m_page->UseTCP->setChecked(m_config->UseTCP() ? true : false);
|
m_page->UseTCP->setChecked(m_config->useTCP() ? true : false);
|
||||||
m_page->UseUDP->setChecked(m_config->UseTCP() ? false : true);
|
m_page->UseUDP->setChecked(m_config->useTCP() ? false : true);
|
||||||
|
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IPconnectionOptionsPage::apply()
|
void IPConnectionOptionsPage::apply()
|
||||||
{
|
{
|
||||||
m_config->setPort(m_page->Port->value());
|
m_config->setPort(m_page->Port->value());
|
||||||
m_config->setHostName(m_page->HostName->text());
|
m_config->setHostName(m_page->HostName->text());
|
||||||
m_config->setUseTCP(m_page->UseTCP->isChecked() ? 1 : 0);
|
m_config->setUseTCP(m_page->UseTCP->isChecked() ? 1 : 0);
|
||||||
m_config->savesettings();
|
|
||||||
|
|
||||||
|
// FIXME this signal is too low level (and duplicated all over the place)
|
||||||
|
// FIXME this signal will trigger (amongst other things) the saving of the configuration !
|
||||||
emit availableDevChanged();
|
emit availableDevChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IPconnectionOptionsPage::finish()
|
void IPConnectionOptionsPage::finish()
|
||||||
{
|
{
|
||||||
delete m_page;
|
delete m_page;
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file IPconnectionoptionspage.h
|
* @file ipconnectionoptionspage.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
|
||||||
|
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* @addtogroup GCSPlugins GCS Plugins
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
* @{
|
* @{
|
||||||
* @addtogroup IPConnPlugin IP Telemetry Plugin
|
* @addtogroup IPConnPlugin IP Telemetry Plugin
|
||||||
* @{
|
* @{
|
||||||
* @brief IP Connection Plugin impliment telemetry over TCP/IP and UDP/IP
|
* @brief IP Connection Plugin implements telemetry over TCP/IP and UDP/IP
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -25,16 +26,12 @@
|
|||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef IPconnectionOPTIONSPAGE_H
|
#ifndef IPCONNECTIONOPTIONSPAGE_H
|
||||||
#define IPconnectionOPTIONSPAGE_H
|
#define IPCONNECTIONOPTIONSPAGE_H
|
||||||
|
|
||||||
#include "coreplugin/dialogs/ioptionspage.h"
|
#include "coreplugin/dialogs/ioptionspage.h"
|
||||||
|
|
||||||
class IPconnectionConfiguration;
|
class IPConnectionConfiguration;
|
||||||
|
|
||||||
namespace Core {
|
|
||||||
class IUAVGadgetConfiguration;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class IPconnectionOptionsPage;
|
class IPconnectionOptionsPage;
|
||||||
@ -42,11 +39,11 @@ class IPconnectionOptionsPage;
|
|||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
|
||||||
class IPconnectionOptionsPage : public IOptionsPage {
|
class IPConnectionOptionsPage : public IOptionsPage {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit IPconnectionOptionsPage(IPconnectionConfiguration *config, QObject *parent = 0);
|
explicit IPConnectionOptionsPage(IPConnectionConfiguration *config, QObject *parent = 0);
|
||||||
virtual ~IPconnectionOptionsPage();
|
virtual ~IPConnectionOptionsPage();
|
||||||
|
|
||||||
QString id() const
|
QString id() const
|
||||||
{
|
{
|
||||||
@ -72,10 +69,9 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void availableDevChanged();
|
void availableDevChanged();
|
||||||
|
|
||||||
public slots:
|
|
||||||
private:
|
private:
|
||||||
IPconnectionConfiguration *m_config;
|
|
||||||
Ui::IPconnectionOptionsPage *m_page;
|
Ui::IPconnectionOptionsPage *m_page;
|
||||||
|
IPConnectionConfiguration *m_config;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // IPconnectionOPTIONSPAGE_H
|
#endif // IPCONNECTIONOPTIONSPAGE_H
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file IPconnectionplugin.cpp
|
* @file ipconnectionplugin.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
|
||||||
|
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* @addtogroup GCSPlugins GCS Plugins
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
* @{
|
* @{
|
||||||
* @addtogroup IPConnPlugin IP Telemetry Plugin
|
* @addtogroup IPConnPlugin IP Telemetry Plugin
|
||||||
* @{
|
* @{
|
||||||
* @brief IP Connection Plugin impliment telemetry over TCP/IP and UDP/IP
|
* @brief IP Connection Plugin implements telemetry over TCP/IP and UDP/IP
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -29,12 +30,12 @@
|
|||||||
|
|
||||||
#include "ipconnectionplugin.h"
|
#include "ipconnectionplugin.h"
|
||||||
|
|
||||||
|
#include "ipconnection_internal.h"
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include "ipconnection_internal.h"
|
#include <coreplugin/threadmanager.h>
|
||||||
|
|
||||||
#include <QtCore/QtPlugin>
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QtNetwork/QAbstractSocket>
|
#include <QtNetwork/QAbstractSocket>
|
||||||
@ -42,11 +43,9 @@
|
|||||||
#include <QtNetwork/QUdpSocket>
|
#include <QtNetwork/QUdpSocket>
|
||||||
#include <QWaitCondition>
|
#include <QWaitCondition>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <coreplugin/threadmanager.h>
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
// Communication between IPconnectionConnection::OpenDevice() and IPConnection::onOpenDevice()
|
// Communication between IPConnectionConnection::OpenDevice() and IPConnection::onOpenDevice()
|
||||||
QString errorMsg;
|
QString errorMsg;
|
||||||
QWaitCondition openDeviceWait;
|
QWaitCondition openDeviceWait;
|
||||||
QWaitCondition closeDeviceWait;
|
QWaitCondition closeDeviceWait;
|
||||||
@ -54,7 +53,7 @@ QWaitCondition closeDeviceWait;
|
|||||||
QMutex ipConMutex;
|
QMutex ipConMutex;
|
||||||
QAbstractSocket *ret;
|
QAbstractSocket *ret;
|
||||||
|
|
||||||
IPConnection::IPConnection(IPconnectionConnection *connection) : QObject()
|
IPConnection::IPConnection(IPConnectionConnection *connection) : QObject()
|
||||||
{
|
{
|
||||||
moveToThread(Core::ICore::instance()->threadManager()->getRealTimeThread());
|
moveToThread(Core::ICore::instance()->threadManager()->getRealTimeThread());
|
||||||
|
|
||||||
@ -117,14 +116,11 @@ void IPConnection::onCloseDevice(QAbstractSocket *ipSocket)
|
|||||||
|
|
||||||
IPConnection *connection = 0;
|
IPConnection *connection = 0;
|
||||||
|
|
||||||
IPconnectionConnection::IPconnectionConnection()
|
IPConnectionConnection::IPConnectionConnection(IPConnectionConfiguration *config) : m_config(config)
|
||||||
{
|
{
|
||||||
ipSocket = NULL;
|
m_ipSocket = NULL;
|
||||||
// create all our objects
|
|
||||||
m_config = new IPconnectionConfiguration("IP Network Telemetry", NULL, this);
|
|
||||||
m_config->restoresettings();
|
|
||||||
|
|
||||||
m_optionspage = new IPconnectionOptionsPage(m_config, this);
|
m_optionsPage = new IPConnectionOptionsPage(m_config, this);
|
||||||
|
|
||||||
if (!connection) {
|
if (!connection) {
|
||||||
connection = new IPConnection(this);
|
connection = new IPConnection(this);
|
||||||
@ -132,17 +128,17 @@ IPconnectionConnection::IPconnectionConnection()
|
|||||||
|
|
||||||
// just signal whenever we have a device event...
|
// just signal whenever we have a device event...
|
||||||
QMainWindow *mw = Core::ICore::instance()->mainWindow();
|
QMainWindow *mw = Core::ICore::instance()->mainWindow();
|
||||||
QObject::connect(mw, SIGNAL(deviceChange()),
|
QObject::connect(mw, SIGNAL(deviceChange()), this, SLOT(onEnumerationChanged()));
|
||||||
this, SLOT(onEnumerationChanged()));
|
QObject::connect(m_optionsPage, SIGNAL(availableDevChanged()), this, SLOT(onEnumerationChanged()));
|
||||||
QObject::connect(m_optionspage, SIGNAL(availableDevChanged()),
|
|
||||||
this, SLOT(onEnumerationChanged()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IPconnectionConnection::~IPconnectionConnection()
|
IPConnectionConnection::~IPConnectionConnection()
|
||||||
{ // clean up out resources...
|
{
|
||||||
if (ipSocket) {
|
// clean up out resources...
|
||||||
ipSocket->close();
|
if (m_ipSocket) {
|
||||||
delete (ipSocket);
|
m_ipSocket->close();
|
||||||
|
delete m_ipSocket;
|
||||||
|
m_ipSocket = NULL;
|
||||||
}
|
}
|
||||||
if (connection) {
|
if (connection) {
|
||||||
delete connection;
|
delete connection;
|
||||||
@ -150,81 +146,80 @@ IPconnectionConnection::~IPconnectionConnection()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IPconnectionConnection::onEnumerationChanged()
|
void IPConnectionConnection::onEnumerationChanged()
|
||||||
{ // no change from serial plugin
|
{
|
||||||
emit availableDevChanged(this);
|
emit availableDevChanged(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList <Core::IConnection::device> IPConnectionConnection::availableDevices()
|
||||||
QList <Core::IConnection::device> IPconnectionConnection::availableDevices()
|
|
||||||
{
|
{
|
||||||
QList <Core::IConnection::device> list;
|
QList <Core::IConnection::device> list;
|
||||||
device d;
|
device d;
|
||||||
if (m_config->HostName().length() > 1) {
|
if (m_config->hostName().length() > 1) {
|
||||||
d.displayName = (const QString)m_config->HostName();
|
d.displayName = (const QString)m_config->hostName();
|
||||||
} else {
|
} else {
|
||||||
d.displayName = "Unconfigured";
|
d.displayName = tr("Unconfigured");
|
||||||
}
|
}
|
||||||
d.name = (const QString)m_config->HostName();
|
d.name = (const QString)m_config->hostName();
|
||||||
// we only have one "device" as defined by the configuration m_config
|
// we only have one "device" as defined by the configuration m_config
|
||||||
list.append(d);
|
list.append(d);
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
QIODevice *IPconnectionConnection::openDevice(const QString &)
|
QIODevice *IPConnectionConnection::openDevice(const QString &)
|
||||||
{
|
{
|
||||||
QString HostName;
|
QString hostName;
|
||||||
int Port;
|
int port;
|
||||||
bool UseTCP;
|
bool useTCP;
|
||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
|
|
||||||
// get the configuration info
|
// get the configuration info
|
||||||
HostName = m_config->HostName();
|
hostName = m_config->hostName();
|
||||||
Port = m_config->Port();
|
port = m_config->port();
|
||||||
UseTCP = m_config->UseTCP();
|
useTCP = m_config->useTCP();
|
||||||
|
|
||||||
if (ipSocket) {
|
if (m_ipSocket) {
|
||||||
// Andrew: close any existing socket... this should never occur
|
// Andrew: close any existing socket... this should never occur
|
||||||
ipConMutex.lock();
|
ipConMutex.lock();
|
||||||
emit CloseSocket(ipSocket);
|
emit CloseSocket(m_ipSocket);
|
||||||
closeDeviceWait.wait(&ipConMutex);
|
closeDeviceWait.wait(&ipConMutex);
|
||||||
ipConMutex.unlock();
|
ipConMutex.unlock();
|
||||||
ipSocket = NULL;
|
m_ipSocket = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ipConMutex.lock();
|
ipConMutex.lock();
|
||||||
emit CreateSocket(HostName, Port, UseTCP);
|
emit CreateSocket(hostName, port, useTCP);
|
||||||
openDeviceWait.wait(&ipConMutex);
|
openDeviceWait.wait(&ipConMutex);
|
||||||
ipConMutex.unlock();
|
ipConMutex.unlock();
|
||||||
ipSocket = ret;
|
m_ipSocket = ret;
|
||||||
if (ipSocket == NULL) {
|
if (m_ipSocket == NULL) {
|
||||||
msgBox.setText((const QString)errorMsg);
|
msgBox.setText((const QString)errorMsg);
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
}
|
}
|
||||||
return ipSocket;
|
return m_ipSocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IPconnectionConnection::closeDevice(const QString &)
|
void IPConnectionConnection::closeDevice(const QString &)
|
||||||
{
|
{
|
||||||
if (ipSocket) {
|
if (m_ipSocket) {
|
||||||
ipConMutex.lock();
|
ipConMutex.lock();
|
||||||
emit CloseSocket(ipSocket);
|
emit CloseSocket(m_ipSocket);
|
||||||
closeDeviceWait.wait(&ipConMutex);
|
closeDeviceWait.wait(&ipConMutex);
|
||||||
ipConMutex.unlock();
|
ipConMutex.unlock();
|
||||||
ipSocket = NULL;
|
m_ipSocket = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString IPconnectionConnection::connectionName()
|
QString IPConnectionConnection::connectionName()
|
||||||
{ // updated from serial plugin
|
{
|
||||||
return QString("Network telemetry port");
|
return QString("Network telemetry port");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString IPconnectionConnection::shortName()
|
QString IPConnectionConnection::shortName()
|
||||||
{ // updated from serial plugin
|
{
|
||||||
if (m_config->UseTCP()) {
|
if (m_config->useTCP()) {
|
||||||
return QString("TCP");
|
return QString("TCP");
|
||||||
} else {
|
} else {
|
||||||
return QString("UDP");
|
return QString("UDP");
|
||||||
@ -232,29 +227,55 @@ QString IPconnectionConnection::shortName()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
IPconnectionPlugin::IPconnectionPlugin()
|
IPConnectionPlugin::IPConnectionPlugin() : m_connection(0), m_config(0)
|
||||||
{ // no change from serial plugin
|
{}
|
||||||
|
|
||||||
|
IPConnectionPlugin::~IPConnectionPlugin()
|
||||||
|
{
|
||||||
|
// manually remove the options page object
|
||||||
|
removeObject(m_connection->optionsPage());
|
||||||
}
|
}
|
||||||
|
|
||||||
IPconnectionPlugin::~IPconnectionPlugin()
|
bool IPConnectionPlugin::initialize(const QStringList &arguments, QString *errorString)
|
||||||
{ // manually remove the options page object
|
{
|
||||||
removeObject(m_connection->Optionspage());
|
Q_UNUSED(arguments);
|
||||||
|
Q_UNUSED(errorString);
|
||||||
|
|
||||||
|
Core::ICore::instance()->readSettings(this);
|
||||||
|
|
||||||
|
m_connection = new IPConnectionConnection(m_config);
|
||||||
|
|
||||||
|
// must manage this registration of child object ourselves
|
||||||
|
// if we use an autorelease here it causes the GCS to crash
|
||||||
|
// as it is deleting objects as the app closes...
|
||||||
|
addObject(m_connection->optionsPage());
|
||||||
|
|
||||||
|
// FIXME this is really a contrived way to save the settings...
|
||||||
|
// needs to be done centrally from
|
||||||
|
QObject::connect(m_connection, &IPConnectionConnection::availableDevChanged,
|
||||||
|
[this]() { Core::ICore::instance()->saveSettings(this); }
|
||||||
|
);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IPconnectionPlugin::extensionsInitialized()
|
void IPConnectionPlugin::extensionsInitialized()
|
||||||
{
|
{
|
||||||
addAutoReleasedObject(m_connection);
|
addAutoReleasedObject(m_connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IPconnectionPlugin::initialize(const QStringList &arguments, QString *errorString)
|
void IPConnectionPlugin::readConfig(QSettings &settings, Core::UAVConfigInfo *configInfo)
|
||||||
{
|
{
|
||||||
Q_UNUSED(arguments);
|
Q_UNUSED(configInfo);
|
||||||
Q_UNUSED(errorString);
|
|
||||||
m_connection = new IPconnectionConnection();
|
|
||||||
// must manage this registration of child object ourselves
|
|
||||||
// if we use an autorelease here it causes the GCS to crash
|
|
||||||
// as it is deleting objects as the app closes...
|
|
||||||
addObject(m_connection->Optionspage());
|
|
||||||
|
|
||||||
return true;
|
m_config = new IPConnectionConfiguration("IPConnection", settings, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IPConnectionPlugin::saveConfig(QSettings &settings, Core::UAVConfigInfo *configInfo) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(configInfo);
|
||||||
|
|
||||||
|
if (m_config) {
|
||||||
|
m_config->saveConfig(settings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file IPconnectionplugin.h
|
* @file ipconnectionplugin.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
|
||||||
|
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* @addtogroup GCSPlugins GCS Plugins
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
* @{
|
* @{
|
||||||
* @addtogroup IPConnPlugin IP Telemetry Plugin
|
* @addtogroup IPConnPlugin IP Telemetry Plugin
|
||||||
* @{
|
* @{
|
||||||
* @brief IP Connection Plugin impliment telemetry over TCP/IP and UDP/IP
|
* @brief IP Connection Plugin implements telemetry over TCP/IP and UDP/IP
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -25,15 +26,16 @@
|
|||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef IPconnectionPLUGIN_H
|
#ifndef IPCONNECTIONPLUGIN_H
|
||||||
#define IPconnectionPLUGIN_H
|
#define IPCONNECTIONPLUGIN_H
|
||||||
|
|
||||||
#include "ipconnection_global.h"
|
#include "ipconnection_global.h"
|
||||||
#include "ipconnectionoptionspage.h"
|
#include "ipconnectionoptionspage.h"
|
||||||
#include "ipconnectionconfiguration.h"
|
#include "ipconnectionconfiguration.h"
|
||||||
#include "coreplugin/iconnection.h"
|
|
||||||
#include <extensionsystem/iplugin.h>
|
#include <extensionsystem/iplugin.h>
|
||||||
// #include <QtCore/QSettings>
|
#include <coreplugin/iconfigurableplugin.h>
|
||||||
|
#include <coreplugin/iconnection.h>
|
||||||
|
|
||||||
class QAbstractSocket;
|
class QAbstractSocket;
|
||||||
class QTcpSocket;
|
class QTcpSocket;
|
||||||
@ -46,12 +48,12 @@ class IConnection;
|
|||||||
* Plugin will add a instance of this class to the pool,
|
* Plugin will add a instance of this class to the pool,
|
||||||
* so the connection manager can use it.
|
* so the connection manager can use it.
|
||||||
*/
|
*/
|
||||||
class IPconnection_EXPORT IPconnectionConnection : public Core::IConnection {
|
class IPCONNECTION_EXPORT IPConnectionConnection : public Core::IConnection {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IPconnectionConnection();
|
IPConnectionConnection(IPConnectionConfiguration *config);
|
||||||
virtual ~IPconnectionConnection();
|
virtual ~IPConnectionConnection();
|
||||||
|
|
||||||
virtual QList <Core::IConnection::device> availableDevices();
|
virtual QList <Core::IConnection::device> availableDevices();
|
||||||
virtual QIODevice *openDevice(const QString &deviceName);
|
virtual QIODevice *openDevice(const QString &deviceName);
|
||||||
@ -60,42 +62,44 @@ public:
|
|||||||
virtual QString connectionName();
|
virtual QString connectionName();
|
||||||
virtual QString shortName();
|
virtual QString shortName();
|
||||||
|
|
||||||
IPconnectionConfiguration *Config() const
|
IPConnectionOptionsPage *optionsPage() const
|
||||||
{
|
{
|
||||||
return m_config;
|
return m_optionsPage;
|
||||||
}
|
|
||||||
IPconnectionOptionsPage *Optionspage() const
|
|
||||||
{
|
|
||||||
return m_optionspage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void onEnumerationChanged();
|
void onEnumerationChanged();
|
||||||
|
|
||||||
signals: // For the benefit of IPConnection
|
signals:
|
||||||
|
// For the benefit of IPConnection
|
||||||
|
// FIXME change to camel case
|
||||||
void CreateSocket(QString HostName, int Port, bool UseTCP);
|
void CreateSocket(QString HostName, int Port, bool UseTCP);
|
||||||
void CloseSocket(QAbstractSocket *socket);
|
void CloseSocket(QAbstractSocket *socket);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QAbstractSocket *ipSocket;
|
QAbstractSocket *m_ipSocket;
|
||||||
IPconnectionConfiguration *m_config;
|
// FIXME m_config and m_optionsPage belong in IPConnectionPlugin
|
||||||
IPconnectionOptionsPage *m_optionspage;
|
IPConnectionConfiguration *m_config;
|
||||||
// QSettings* settings;
|
IPConnectionOptionsPage *m_optionsPage;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IPconnection_EXPORT IPconnectionPlugin : public ExtensionSystem::IPlugin {
|
class IPCONNECTION_EXPORT IPConnectionPlugin : public Core::IConfigurablePlugin {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PLUGIN_METADATA(IID "OpenPilot.IPconnection")
|
Q_PLUGIN_METADATA(IID "OpenPilot.IPConnection")
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IPconnectionPlugin();
|
IPConnectionPlugin();
|
||||||
~IPconnectionPlugin();
|
~IPConnectionPlugin();
|
||||||
|
|
||||||
virtual bool initialize(const QStringList &arguments, QString *error_message);
|
virtual bool initialize(const QStringList &arguments, QString *error_message);
|
||||||
virtual void extensionsInitialized();
|
virtual void extensionsInitialized();
|
||||||
|
|
||||||
|
void readConfig(QSettings &settings, Core::UAVConfigInfo *configInfo);
|
||||||
|
void saveConfig(QSettings &settings, Core::UAVConfigInfo *configInfo) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IPconnectionConnection *m_connection;
|
IPConnectionConnection *m_connection;
|
||||||
|
IPConnectionConfiguration *m_config;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // IPconnectionPLUGIN_H
|
#endif // IPCONNECTIONPLUGIN_H
|
||||||
|
@ -32,92 +32,78 @@
|
|||||||
* Loads a saved configuration or defaults if non exist.
|
* Loads a saved configuration or defaults if non exist.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
LineardialGadgetConfiguration::LineardialGadgetConfiguration(QString classId, QSettings *qSettings, QObject *parent) :
|
LineardialGadgetConfiguration::LineardialGadgetConfiguration(QString classId, QSettings &settings, QObject *parent) :
|
||||||
IUAVGadgetConfiguration(classId, 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)
|
|
||||||
{
|
{
|
||||||
// if a saved configuration exists load it
|
QString dFile = settings.value("dFile").toString();
|
||||||
if (qSettings != 0) {
|
|
||||||
QString dFile = qSettings->value("dFile").toString();
|
dialFile = Utils::InsertDataPath(dFile);
|
||||||
dialFile = Utils::InsertDataPath(dFile);
|
sourceDataObject = settings.value("sourceDataObject", "Unknown").toString();
|
||||||
sourceDataObject = qSettings->value("sourceDataObject").toString();
|
sourceObjectField = settings.value("sourceObjectField", "Unknown").toString();
|
||||||
sourceObjectField = qSettings->value("sourceObjectField").toString();
|
minValue = settings.value("minValue", 0).toDouble();
|
||||||
minValue = qSettings->value("minValue").toDouble();
|
maxValue = settings.value("maxValue", 100).toDouble();
|
||||||
maxValue = qSettings->value("maxValue").toDouble();
|
redMin = settings.value("redMin", 0).toDouble();
|
||||||
redMin = qSettings->value("redMin").toDouble();
|
redMax = settings.value("redMax", 33).toDouble();
|
||||||
redMax = qSettings->value("redMax").toDouble();
|
yellowMin = settings.value("yellowMin", 33).toDouble();
|
||||||
yellowMin = qSettings->value("yellowMin").toDouble();
|
yellowMax = settings.value("yellowMax", 66).toDouble();
|
||||||
yellowMax = qSettings->value("yellowMax").toDouble();
|
greenMin = settings.value("greenMin", 66).toDouble();
|
||||||
greenMin = qSettings->value("greenMin").toDouble();
|
greenMax = settings.value("greenMax", 100).toDouble();
|
||||||
greenMax = qSettings->value("greenMax").toDouble();
|
font = settings.value("font").toString();
|
||||||
font = qSettings->value("font").toString();
|
decimalPlaces = settings.value("decimalPlaces", 0).toInt();
|
||||||
decimalPlaces = qSettings->value("decimalPlaces").toInt();
|
factor = settings.value("factor", 1.0).toDouble();
|
||||||
factor = qSettings->value("factor").toDouble();
|
useOpenGLFlag = settings.value("useOpenGLFlag").toBool();
|
||||||
useOpenGLFlag = qSettings->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.
|
* Clones a configuration.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
IUAVGadgetConfiguration *LineardialGadgetConfiguration::clone()
|
IUAVGadgetConfiguration *LineardialGadgetConfiguration::clone() const
|
||||||
{
|
{
|
||||||
LineardialGadgetConfiguration *m = new LineardialGadgetConfiguration(this->classId());
|
return new LineardialGadgetConfiguration(*this);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves a configuration.
|
* Saves a configuration.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void LineardialGadgetConfiguration::saveConfig(QSettings *qSettings) const
|
void LineardialGadgetConfiguration::saveConfig(QSettings &settings) const
|
||||||
{
|
{
|
||||||
QString dFile = Utils::RemoveDataPath(dialFile);
|
QString dFile = Utils::RemoveDataPath(dialFile);
|
||||||
|
|
||||||
qSettings->setValue("dFile", dFile);
|
settings.setValue("dFile", dFile);
|
||||||
qSettings->setValue("sourceDataObject", sourceDataObject);
|
settings.setValue("sourceDataObject", sourceDataObject);
|
||||||
qSettings->setValue("sourceObjectField", sourceObjectField);
|
settings.setValue("sourceObjectField", sourceObjectField);
|
||||||
qSettings->setValue("minValue", minValue);
|
settings.setValue("minValue", minValue);
|
||||||
qSettings->setValue("maxValue", maxValue);
|
settings.setValue("maxValue", maxValue);
|
||||||
qSettings->setValue("redMin", redMin);
|
settings.setValue("redMin", redMin);
|
||||||
qSettings->setValue("redMax", redMax);
|
settings.setValue("redMax", redMax);
|
||||||
qSettings->setValue("yellowMin", yellowMin);
|
settings.setValue("yellowMin", yellowMin);
|
||||||
qSettings->setValue("yellowMax", yellowMax);
|
settings.setValue("yellowMax", yellowMax);
|
||||||
qSettings->setValue("greenMin", greenMin);
|
settings.setValue("greenMin", greenMin);
|
||||||
qSettings->setValue("greenMax", greenMax);
|
settings.setValue("greenMax", greenMax);
|
||||||
qSettings->setValue("font", font);
|
settings.setValue("font", font);
|
||||||
qSettings->setValue("decimalPlaces", decimalPlaces);
|
settings.setValue("decimalPlaces", decimalPlaces);
|
||||||
qSettings->setValue("factor", factor);
|
settings.setValue("factor", factor);
|
||||||
qSettings->setValue("useOpenGLFlag", useOpenGLFlag);
|
settings.setValue("useOpenGLFlag", useOpenGLFlag);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,11 @@ using namespace Core;
|
|||||||
class LineardialGadgetConfiguration : public IUAVGadgetConfiguration {
|
class LineardialGadgetConfiguration : public IUAVGadgetConfiguration {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
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
|
// set dial configuration functions
|
||||||
void setDialFile(QString filename)
|
void setDialFile(QString filename)
|
||||||
@ -61,12 +65,10 @@ public:
|
|||||||
{
|
{
|
||||||
redMin = min; redMax = max;
|
redMin = min; redMax = max;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setFont(QString text)
|
void setFont(QString text)
|
||||||
{
|
{
|
||||||
font = text;
|
font = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setFactor(double val)
|
void setFactor(double val)
|
||||||
{
|
{
|
||||||
factor = val;
|
factor = val;
|
||||||
@ -75,7 +77,6 @@ public:
|
|||||||
{
|
{
|
||||||
decimalPlaces = val;
|
decimalPlaces = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSourceDataObject(QString text)
|
void setSourceDataObject(QString text)
|
||||||
{
|
{
|
||||||
sourceDataObject = text;
|
sourceDataObject = text;
|
||||||
@ -84,7 +85,6 @@ public:
|
|||||||
{
|
{
|
||||||
sourceObjectField = text;
|
sourceObjectField = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setUseOpenGL(bool flag)
|
void setUseOpenGL(bool flag)
|
||||||
{
|
{
|
||||||
useOpenGLFlag = flag;
|
useOpenGLFlag = flag;
|
||||||
@ -152,9 +152,6 @@ public:
|
|||||||
return useOpenGLFlag;
|
return useOpenGLFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveConfig(QSettings *settings) const;
|
|
||||||
IUAVGadgetConfiguration *clone();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// A linear or "bargraph" dial contains:
|
// A linear or "bargraph" dial contains:
|
||||||
// * A SVG background file
|
// * A SVG background file
|
||||||
|
@ -47,9 +47,9 @@ Core::IUAVGadget *LineardialGadgetFactory::createGadget(QWidget *parent)
|
|||||||
return new LineardialGadget(QString("LineardialGadget"), gadgetWidget, 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)
|
IOptionsPage *LineardialGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||||
|
@ -44,7 +44,7 @@ public:
|
|||||||
~LineardialGadgetFactory();
|
~LineardialGadgetFactory();
|
||||||
|
|
||||||
Core::IUAVGadget *createGadget(QWidget *parent);
|
Core::IUAVGadget *createGadget(QWidget *parent);
|
||||||
IUAVGadgetConfiguration *createConfiguration(QSettings *qSettings);
|
IUAVGadgetConfiguration *createConfiguration(QSettings &settings);
|
||||||
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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("SoundCollectionPath", Utils::RemoveDataPath(getSoundCollectionPath()));
|
||||||
settings->setValue(QLatin1String("CurrentLanguage"), getCurrentLanguage());
|
settings.setValue(QLatin1String("CurrentLanguage"), getCurrentLanguage());
|
||||||
settings->setValue(QLatin1String("ObjectField"), getObjectField());
|
settings.setValue(QLatin1String("ObjectField"), getObjectField());
|
||||||
settings->setValue(QLatin1String("DataObject"), getDataObject());
|
settings.setValue(QLatin1String("DataObject"), getDataObject());
|
||||||
settings->setValue(QLatin1String("RangeLimit"), getCondition());
|
settings.setValue(QLatin1String("RangeLimit"), getCondition());
|
||||||
settings->setValue(QLatin1String("Value1"), singleValue());
|
settings.setValue(QLatin1String("Value1"), singleValue());
|
||||||
settings->setValue(QLatin1String("Value2"), valueRange2());
|
settings.setValue(QLatin1String("Value2"), valueRange2());
|
||||||
settings->setValue(QLatin1String("Sound1"), getSound1());
|
settings.setValue(QLatin1String("Sound1"), getSound1());
|
||||||
settings->setValue(QLatin1String("Sound2"), getSound2());
|
settings.setValue(QLatin1String("Sound2"), getSound2());
|
||||||
settings->setValue(QLatin1String("Sound3"), getSound3());
|
settings.setValue(QLatin1String("Sound3"), getSound3());
|
||||||
settings->setValue(QLatin1String("SayOrder"), getSayOrder());
|
settings.setValue(QLatin1String("SayOrder"), getSayOrder());
|
||||||
settings->setValue(QLatin1String("Repeat"), retryValue());
|
settings.setValue(QLatin1String("Repeat"), retryValue());
|
||||||
settings->setValue(QLatin1String("ExpireTimeout"), lifetime());
|
settings.setValue(QLatin1String("ExpireTimeout"), lifetime());
|
||||||
settings->setValue(QLatin1String("Mute"), mute());
|
settings.setValue(QLatin1String("Mute"), mute());
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationItem::restoreState(QSettings *settings)
|
void NotificationItem::restoreState(QSettings &settings)
|
||||||
{
|
{
|
||||||
// settings = Core::ICore::instance()->settings();
|
// settings = Core::ICore::instance()->settings();
|
||||||
setSoundCollectionPath(Utils::InsertDataPath(settings->value(QLatin1String("SoundCollectionPath"), tr("")).toString()));
|
setSoundCollectionPath(Utils::InsertDataPath(settings.value(QLatin1String("SoundCollectionPath"), tr("")).toString()));
|
||||||
setCurrentLanguage(settings->value(QLatin1String("CurrentLanguage"), tr("")).toString());
|
setCurrentLanguage(settings.value(QLatin1String("CurrentLanguage"), tr("")).toString());
|
||||||
setDataObject(settings->value(QLatin1String("DataObject"), tr("")).toString());
|
setDataObject(settings.value(QLatin1String("DataObject"), tr("")).toString());
|
||||||
setObjectField(settings->value(QLatin1String("ObjectField"), tr("")).toString());
|
setObjectField(settings.value(QLatin1String("ObjectField"), tr("")).toString());
|
||||||
setCondition(settings->value(QLatin1String("RangeLimit"), tr("")).toInt());
|
setCondition(settings.value(QLatin1String("RangeLimit"), tr("")).toInt());
|
||||||
setSound1(settings->value(QLatin1String("Sound1"), tr("")).toString());
|
setSound1(settings.value(QLatin1String("Sound1"), tr("")).toString());
|
||||||
setSound2(settings->value(QLatin1String("Sound2"), tr("")).toString());
|
setSound2(settings.value(QLatin1String("Sound2"), tr("")).toString());
|
||||||
setSound3(settings->value(QLatin1String("Sound3"), tr("")).toString());
|
setSound3(settings.value(QLatin1String("Sound3"), tr("")).toString());
|
||||||
setSayOrder(settings->value(QLatin1String("SayOrder"), tr("")).toInt());
|
setSayOrder(settings.value(QLatin1String("SayOrder"), tr("")).toInt());
|
||||||
QVariant value = settings->value(QLatin1String("Value1"), tr(""));
|
QVariant value = settings.value(QLatin1String("Value1"), tr(""));
|
||||||
setSingleValue(value);
|
setSingleValue(value);
|
||||||
setValueRange2(settings->value(QLatin1String("Value2"), tr("")).toDouble());
|
setValueRange2(settings.value(QLatin1String("Value2"), tr("")).toDouble());
|
||||||
setRetryValue(settings->value(QLatin1String("Repeat"), tr("")).toInt());
|
setRetryValue(settings.value(QLatin1String("Repeat"), tr("")).toInt());
|
||||||
setLifetime(settings->value(QLatin1String("ExpireTimeout"), tr("")).toInt());
|
setLifetime(settings.value(QLatin1String("ExpireTimeout"), tr("")).toInt());
|
||||||
setMute(settings->value(QLatin1String("Mute"), tr("")).toInt());
|
setMute(settings.value(QLatin1String("Mute"), tr("")).toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationItem::serialize(QDataStream & stream)
|
void NotificationItem::serialize(QDataStream & stream)
|
||||||
@ -149,7 +149,7 @@ void NotificationItem::serialize(QDataStream & stream)
|
|||||||
stream << this->_dataObject;
|
stream << this->_dataObject;
|
||||||
stream << this->_objectField;
|
stream << this->_objectField;
|
||||||
stream << this->_condition;
|
stream << this->_condition;
|
||||||
qNotifyDebug() << "getOptionsPageValues seriaize" << _condition;
|
qNotifyDebug() << "getOptionsPageValues serialize" << _condition;
|
||||||
stream << this->_sound1;
|
stream << this->_sound1;
|
||||||
stream << this->_sound2;
|
stream << this->_sound2;
|
||||||
stream << this->_sound3;
|
stream << this->_sound3;
|
||||||
|
@ -177,9 +177,8 @@ public:
|
|||||||
_mute = value;
|
_mute = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveState(QSettings *settings) const;
|
void saveState(QSettings &settings) const;
|
||||||
void restoreState(QSettings *settings);
|
void restoreState(QSettings &settings);
|
||||||
|
|
||||||
|
|
||||||
UAVDataObject *getUAVObject(void);
|
UAVDataObject *getUAVObject(void);
|
||||||
UAVObjectField *getUAVObjectField(void);
|
UAVObjectField *getUAVObjectField(void);
|
||||||
@ -208,7 +207,7 @@ public:
|
|||||||
* Returns sound caption name, needed to create string representation of notification.
|
* Returns sound caption name, needed to create string representation of notification.
|
||||||
*
|
*
|
||||||
* @return success - string == <sound filename>, if sound file exists
|
* @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);
|
QString getSoundCaption(QString fileName);
|
||||||
|
|
||||||
|
@ -81,48 +81,48 @@ void SoundNotifyPlugin::extensionsInitialized()
|
|||||||
connectNotifications();
|
connectNotifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundNotifyPlugin::saveConfig(QSettings *settings, UAVConfigInfo *configInfo)
|
void SoundNotifyPlugin::saveConfig(QSettings &settings, UAVConfigInfo *configInfo) const
|
||||||
{
|
{
|
||||||
configInfo->setVersion(VERSION);
|
configInfo->setVersion(VERSION);
|
||||||
|
|
||||||
settings->beginWriteArray("Current");
|
settings.beginWriteArray("Current");
|
||||||
settings->setArrayIndex(0);
|
settings.setArrayIndex(0);
|
||||||
currentNotification.saveState(settings);
|
currentNotification.saveState(settings);
|
||||||
settings->endArray();
|
settings.endArray();
|
||||||
|
|
||||||
settings->beginGroup("listNotifies");
|
settings.beginGroup("listNotifies");
|
||||||
settings->remove("");
|
settings.remove("");
|
||||||
settings->endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings->beginWriteArray("listNotifies");
|
settings.beginWriteArray("listNotifies");
|
||||||
for (int i = 0; i < _notificationList.size(); i++) {
|
for (int i = 0; i < _notificationList.size(); i++) {
|
||||||
settings->setArrayIndex(i);
|
settings.setArrayIndex(i);
|
||||||
_notificationList.at(i)->saveState(settings);
|
_notificationList.at(i)->saveState(settings);
|
||||||
}
|
}
|
||||||
settings->endArray();
|
settings.endArray();
|
||||||
settings->setValue(QLatin1String("EnableSound"), enableSound);
|
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.
|
// Just for migration to the new format.
|
||||||
// Q_ASSERT(configInfo->version() == UAVConfigVersion());
|
// Q_ASSERT(configInfo->version() == UAVConfigVersion());
|
||||||
|
|
||||||
settings->beginReadArray("Current");
|
settings.beginReadArray("Current");
|
||||||
settings->setArrayIndex(0);
|
settings.setArrayIndex(0);
|
||||||
currentNotification.restoreState(settings);
|
currentNotification.restoreState(settings);
|
||||||
settings->endArray();
|
settings.endArray();
|
||||||
|
|
||||||
// read list of notifications from settings
|
// read list of notifications from settings
|
||||||
int size = settings->beginReadArray("listNotifies");
|
int size = settings.beginReadArray("listNotifies");
|
||||||
for (int i = 0; i < size; ++i) {
|
for (int i = 0; i < size; ++i) {
|
||||||
settings->setArrayIndex(i);
|
settings.setArrayIndex(i);
|
||||||
NotificationItem *notification = new NotificationItem;
|
NotificationItem *notification = new NotificationItem;
|
||||||
notification->restoreState(settings);
|
notification->restoreState(settings);
|
||||||
_notificationList.append(notification);
|
_notificationList.append(notification);
|
||||||
}
|
}
|
||||||
settings->endArray();
|
settings.endArray();
|
||||||
setEnableSound(settings->value(QLatin1String("EnableSound"), 0).toBool());
|
setEnableSound(settings.value(QLatin1String("EnableSound"), 0).toBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundNotifyPlugin::onTelemetryManagerAdded(QObject *obj)
|
void SoundNotifyPlugin::onTelemetryManagerAdded(QObject *obj)
|
||||||
|
@ -56,8 +56,8 @@ public:
|
|||||||
|
|
||||||
void extensionsInitialized();
|
void extensionsInitialized();
|
||||||
bool initialize(const QStringList & arguments, QString *errorString);
|
bool initialize(const QStringList & arguments, QString *errorString);
|
||||||
void readConfig(QSettings *qSettings, Core::UAVConfigInfo *configInfo);
|
void readConfig(QSettings &settings, Core::UAVConfigInfo *configInfo);
|
||||||
void saveConfig(QSettings *qSettings, Core::UAVConfigInfo *configInfo);
|
void saveConfig(QSettings &settings, Core::UAVConfigInfo *configInfo) const;
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,57 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
*
|
|
||||||
* @file notifypluginfactory.cpp
|
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
||||||
* @brief
|
|
||||||
* @see The GNU Public License (GPL) Version 3
|
|
||||||
* @defgroup notifyplugin
|
|
||||||
* @{
|
|
||||||
*
|
|
||||||
*****************************************************************************/
|
|
||||||
/*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*/
|
|
||||||
#include "notifypluginfactory.h"
|
|
||||||
// #include "notifypluginwidget.h"
|
|
||||||
#include "notifyplugin.h"
|
|
||||||
#include "notifypluginconfiguration.h"
|
|
||||||
#include "notifypluginoptionspage.h"
|
|
||||||
#include <coreplugin/iuavgadget.h>
|
|
||||||
|
|
||||||
NotifyPluginFactory::NotifyPluginFactory(QObject *parent) :
|
|
||||||
IUAVGadgetFactory(QString("Notify Plugin"),
|
|
||||||
tr("Notify Plugin"),
|
|
||||||
parent)
|
|
||||||
{}
|
|
||||||
|
|
||||||
NotifyPluginFactory::~NotifyPluginFactory()
|
|
||||||
{}
|
|
||||||
|
|
||||||
Core::IUAVGadget *NotifyPluginFactory::createGadget(QWidget *parent)
|
|
||||||
{
|
|
||||||
// NotifyPluginWidget* gadgetWidget = new NotifyPluginWidget(parent);
|
|
||||||
return (Core::IUAVGadget *)0; // new NotifyPlugin(QString("NotifyPlugin"), gadgetWidget, parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
IUAVGadgetConfiguration *NotifyPluginFactory::createConfiguration(const QByteArray &state)
|
|
||||||
{
|
|
||||||
return new NotifyPluginConfiguration(QString("Notify Plugin"), state);
|
|
||||||
}
|
|
||||||
|
|
||||||
IOptionsPage *NotifyPluginFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
|
||||||
{
|
|
||||||
return new NotifyPluginOptionsPage(qobject_cast<NotifyPluginConfiguration *>(config));
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
*
|
|
||||||
* @file notifypluginfactory.h
|
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
||||||
* @brief
|
|
||||||
* @see The GNU Public License (GPL) Version 3
|
|
||||||
* @defgroup notifyplugin
|
|
||||||
* @{
|
|
||||||
*
|
|
||||||
*****************************************************************************/
|
|
||||||
/*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef NOTIFYPLUGINFACTORY_H
|
|
||||||
#define NOTIFYPLUGINFACTORY_H
|
|
||||||
|
|
||||||
|
|
||||||
#include <coreplugin/iuavgadgetfactory.h>
|
|
||||||
|
|
||||||
namespace Core {
|
|
||||||
class IUAVGadget;
|
|
||||||
class IUAVGadgetFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
using namespace Core;
|
|
||||||
|
|
||||||
class NotifyPluginFactory : public IUAVGadgetFactory {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
NotifyPluginFactory(QObject *parent = 0);
|
|
||||||
~NotifyPluginFactory();
|
|
||||||
|
|
||||||
Core::IUAVGadget *createGadget(QWidget *parent);
|
|
||||||
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
|
|
||||||
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // NOTIFYPLUGINFACTORY_H
|
|
@ -1,55 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
*
|
|
||||||
* @file notifyplugingadget.h
|
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
||||||
* @brief
|
|
||||||
* @see The GNU Public License (GPL) Version 3
|
|
||||||
* @defgroup notifyplugin
|
|
||||||
* @{
|
|
||||||
*
|
|
||||||
*****************************************************************************/
|
|
||||||
/*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef NOTIFYPLUGINGADGET_H
|
|
||||||
#define NOTIFYPLUGINGADGET_H
|
|
||||||
|
|
||||||
#include <coreplugin/iuavgadget.h>
|
|
||||||
// #include "NotifyPlugingadgetwidget.h"
|
|
||||||
|
|
||||||
class IUAVGadget;
|
|
||||||
class QWidget;
|
|
||||||
class QString;
|
|
||||||
// class NotifyPluginGadgetWidget;
|
|
||||||
|
|
||||||
using namespace Core;
|
|
||||||
|
|
||||||
class NotifyPluginGadget : public Core::IUAVGadget {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
NotifyPluginGadget(QString classId, NotifyPluginGadgetWidget *widget, QWidget *parent = 0);
|
|
||||||
~NotifyPluginGadget();
|
|
||||||
|
|
||||||
// QWidget *widget() { return m_widget; }
|
|
||||||
void loadConfiguration(IUAVGadgetConfiguration *config);
|
|
||||||
|
|
||||||
private:
|
|
||||||
// NotifyPluginGadgetWidget *m_widget;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // NOTIFYPLUGINGADGET_H
|
|
@ -35,7 +35,6 @@
|
|||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QtAlgorithms>
|
#include <QtAlgorithms>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QtCore/QSettings>
|
|
||||||
#include <QTableWidget>
|
#include <QTableWidget>
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
|
@ -29,112 +29,80 @@
|
|||||||
#include "utils/pathutils.h"
|
#include "utils/pathutils.h"
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, QSettings *qSettings, QObject *parent) :
|
OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, QSettings &settings, QObject *parent) :
|
||||||
IUAVGadgetConfiguration(classId, 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)
|
|
||||||
{
|
{
|
||||||
// if a saved configuration exists load it
|
m_defaultWaypointAltitude = settings.value("defaultWaypointAltitude", 15).toReal();
|
||||||
if (qSettings != 0) {
|
m_defaultWaypointVelocity = settings.value("defaultWaypointVelocity", 2).toReal();
|
||||||
QString mapProvider = qSettings->value("mapProvider").toString();
|
m_opacity = settings.value("overlayOpacity", 1).toReal();
|
||||||
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();
|
|
||||||
|
|
||||||
if (!mapProvider.isEmpty()) {
|
m_mapProvider = settings.value("mapProvider", "GoogleHybrid").toString();
|
||||||
m_mapProvider = mapProvider;
|
m_defaultZoom = settings.value("defaultZoom", 2).toInt();
|
||||||
}
|
m_defaultLatitude = settings.value("defaultLatitude").toDouble();
|
||||||
m_defaultZoom = zoom;
|
m_defaultLongitude = settings.value("defaultLongitude").toDouble();
|
||||||
m_defaultLatitude = latitude;
|
m_useOpenGL = settings.value("useOpenGL").toBool();
|
||||||
m_defaultLongitude = longitude;
|
m_showTileGridLines = settings.value("showTileGridLines").toBool();
|
||||||
m_useOpenGL = useOpenGL;
|
m_uavSymbol = settings.value("uavSymbol", QString::fromUtf8(":/uavs/images/mapquad.png")).toString();
|
||||||
m_showTileGridLines = showTileGridLines;
|
|
||||||
m_uavSymbol = uavSymbol;
|
|
||||||
|
|
||||||
m_maxUpdateRate = max_update_rate;
|
m_maxUpdateRate = settings.value("maxUpdateRate", 2000).toInt();
|
||||||
if (m_maxUpdateRate < 100 || m_maxUpdateRate > 5000) {
|
if (m_maxUpdateRate < 100 || m_maxUpdateRate > 5000) {
|
||||||
m_maxUpdateRate = 2000;
|
m_maxUpdateRate = 2000;
|
||||||
}
|
|
||||||
|
|
||||||
if (!accessMode.isEmpty()) {
|
|
||||||
m_accessMode = accessMode;
|
|
||||||
}
|
|
||||||
m_useMemoryCache = useMemoryCache;
|
|
||||||
if (!cacheLocation.isEmpty()) {
|
|
||||||
m_cacheLocation = Utils::InsertStoragePath(cacheLocation);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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_mapProvider = obj.m_mapProvider;
|
||||||
|
m_defaultZoom = obj.m_defaultZoom;
|
||||||
m->m_mapProvider = m_mapProvider;
|
m_defaultLatitude = obj.m_defaultLatitude;
|
||||||
m->m_defaultZoom = m_defaultZoom;
|
m_defaultLongitude = obj.m_defaultLongitude;
|
||||||
m->m_defaultLatitude = m_defaultLatitude;
|
m_useOpenGL = obj.m_useOpenGL;
|
||||||
m->m_defaultLongitude = m_defaultLongitude;
|
m_showTileGridLines = obj.m_showTileGridLines;
|
||||||
m->m_useOpenGL = m_useOpenGL;
|
m_accessMode = obj.m_accessMode;
|
||||||
m->m_showTileGridLines = m_showTileGridLines;
|
m_useMemoryCache = obj.m_useMemoryCache;
|
||||||
m->m_accessMode = m_accessMode;
|
m_cacheLocation = obj.m_cacheLocation;
|
||||||
m->m_useMemoryCache = m_useMemoryCache;
|
m_uavSymbol = obj.m_uavSymbol;
|
||||||
m->m_cacheLocation = m_cacheLocation;
|
m_maxUpdateRate = obj.m_maxUpdateRate;
|
||||||
m->m_uavSymbol = m_uavSymbol;
|
m_opacity = obj.m_opacity;
|
||||||
m->m_maxUpdateRate = m_maxUpdateRate;
|
m_defaultWaypointAltitude = obj.m_defaultWaypointAltitude;
|
||||||
m->m_opacity = m_opacity;
|
m_defaultWaypointVelocity = obj.m_defaultWaypointVelocity;
|
||||||
m->m_defaultWaypointAltitude = m_defaultWaypointAltitude;
|
|
||||||
m->m_defaultWaypointVelocity = m_defaultWaypointVelocity;
|
|
||||||
|
|
||||||
return m;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IUAVGadgetConfiguration *OPMapGadgetConfiguration::clone() const
|
||||||
|
{
|
||||||
|
return new OPMapGadgetConfiguration(*this);
|
||||||
|
}
|
||||||
|
|
||||||
void OPMapGadgetConfiguration::save() const
|
void OPMapGadgetConfiguration::save() const
|
||||||
{
|
{
|
||||||
if (!m_settings) {
|
QSettings settings;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
void OPMapGadgetConfiguration::saveConfig(QSettings &settings) const
|
||||||
qSettings->setValue("defaultWaypointVelocity", m_defaultWaypointVelocity);
|
{
|
||||||
|
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)
|
void OPMapGadgetConfiguration::setCacheLocation(QString cacheLocation)
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,8 @@
|
|||||||
#define OPMAP_GADGETCONFIGURATION_H
|
#define OPMAP_GADGETCONFIGURATION_H
|
||||||
|
|
||||||
#include <coreplugin/iuavgadgetconfiguration.h>
|
#include <coreplugin/iuavgadgetconfiguration.h>
|
||||||
#include <QtCore/QString>
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
|
||||||
@ -50,10 +51,13 @@ class OPMapGadgetConfiguration : public IUAVGadgetConfiguration {
|
|||||||
Q_PROPERTY(qreal defaultWaypointVelocity READ defaultWaypointVelocity WRITE setDefaultWaypointVelocity)
|
Q_PROPERTY(qreal defaultWaypointVelocity READ defaultWaypointVelocity WRITE setDefaultWaypointVelocity)
|
||||||
|
|
||||||
public:
|
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() const;
|
||||||
IUAVGadgetConfiguration *clone();
|
void saveConfig(QSettings &settings) const;
|
||||||
|
|
||||||
|
void save() const;
|
||||||
|
|
||||||
QString mapProvider() const
|
QString mapProvider() const
|
||||||
{
|
{
|
||||||
@ -114,7 +118,6 @@ public:
|
|||||||
return m_defaultWaypointVelocity;
|
return m_defaultWaypointVelocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void save() const;
|
|
||||||
public slots:
|
public slots:
|
||||||
void setMapProvider(QString provider)
|
void setMapProvider(QString provider)
|
||||||
{
|
{
|
||||||
@ -184,7 +187,6 @@ private:
|
|||||||
QString m_cacheLocation;
|
QString m_cacheLocation;
|
||||||
QString m_uavSymbol;
|
QString m_uavSymbol;
|
||||||
int m_maxUpdateRate;
|
int m_maxUpdateRate;
|
||||||
QSettings *m_settings;
|
|
||||||
qreal m_opacity;
|
qreal m_opacity;
|
||||||
qreal m_defaultWaypointAltitude;
|
qreal m_defaultWaypointAltitude;
|
||||||
qreal m_defaultWaypointVelocity;
|
qreal m_defaultWaypointVelocity;
|
||||||
|
@ -45,9 +45,9 @@ Core::IUAVGadget *OPMapGadgetFactory::createGadget(QWidget *parent)
|
|||||||
return new OPMapGadget(QString("OPMapGadget"), gadgetWidget, 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)
|
IOptionsPage *OPMapGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||||
|
@ -45,7 +45,7 @@ public:
|
|||||||
~OPMapGadgetFactory();
|
~OPMapGadgetFactory();
|
||||||
|
|
||||||
Core::IUAVGadget *createGadget(QWidget *parent);
|
Core::IUAVGadget *createGadget(QWidget *parent);
|
||||||
IUAVGadgetConfiguration *createConfiguration(QSettings *qSettings);
|
IUAVGadgetConfiguration *createConfiguration(QSettings &settings);
|
||||||
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -310,14 +310,14 @@ void PfdQmlContext::loadConfiguration(PfdQmlGadgetConfiguration *config)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PfdQmlContext::saveState(QSettings *settings)
|
void PfdQmlContext::saveState(QSettings &settings) const
|
||||||
{
|
{
|
||||||
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()) {
|
if (!file.isEmpty()) {
|
||||||
setModelFile(file);
|
setModelFile(file);
|
||||||
|
@ -105,8 +105,8 @@ public:
|
|||||||
Q_INVOKABLE void resetConsumedEnergy();
|
Q_INVOKABLE void resetConsumedEnergy();
|
||||||
|
|
||||||
void loadConfiguration(PfdQmlGadgetConfiguration *config);
|
void loadConfiguration(PfdQmlGadgetConfiguration *config);
|
||||||
void saveState(QSettings *);
|
void saveState(QSettings &) const;
|
||||||
void restoreState(QSettings *);
|
void restoreState(QSettings &);
|
||||||
|
|
||||||
void apply(QQmlContext *context);
|
void apply(QQmlContext *context);
|
||||||
|
|
||||||
|
@ -52,12 +52,12 @@ void PfdQmlGadget::loadConfiguration(IUAVGadgetConfiguration *config)
|
|||||||
m_qmlGadgetWidget->loadConfiguration(m);
|
m_qmlGadgetWidget->loadConfiguration(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PfdQmlGadget::saveState(QSettings *settings)
|
void PfdQmlGadget::saveState(QSettings &settings) const
|
||||||
{
|
{
|
||||||
m_qmlGadgetWidget->saveState(settings);
|
m_qmlGadgetWidget->saveState(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PfdQmlGadget::restoreState(QSettings *settings)
|
void PfdQmlGadget::restoreState(QSettings &settings)
|
||||||
{
|
{
|
||||||
m_qmlGadgetWidget->restoreState(settings);
|
m_qmlGadgetWidget->restoreState(settings);
|
||||||
}
|
}
|
||||||
|
@ -46,8 +46,8 @@ public:
|
|||||||
QWidget *widget();
|
QWidget *widget();
|
||||||
|
|
||||||
void loadConfiguration(IUAVGadgetConfiguration *config);
|
void loadConfiguration(IUAVGadgetConfiguration *config);
|
||||||
void saveState(QSettings *);
|
void saveState(QSettings &) const;
|
||||||
void restoreState(QSettings *);
|
void restoreState(QSettings &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PfdQmlGadgetWidget *m_qmlGadgetWidget;
|
PfdQmlGadgetWidget *m_qmlGadgetWidget;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user