mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-25 02:05:43 +08:00
refs #273, added settings for simulator
* added class * adjusted settings context * adjusted "global" methods as register metadata * improved settings utility * renamed "settingsallclasses" as settings can also be in other namespaces, settingsallclasses now in core
This commit is contained in:
@@ -11,11 +11,9 @@
|
||||
#include "blackinput/keyboard.h"
|
||||
#include "blackmisc/hwkeyboardkeylist.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include "blackmisc/settingutilities.h"
|
||||
#include "blackmisc/setnetwork.h"
|
||||
#include "blackmisc/setaudio.h"
|
||||
#include "blackmisc/dbus.h"
|
||||
#include "blackmisc/variant.h"
|
||||
#include "blackcore/settingsallclasses.h"
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
|
||||
@@ -38,7 +36,8 @@ namespace BlackCore
|
||||
{
|
||||
SettingsHotKeys,
|
||||
SettingsNetwork,
|
||||
SettingsAudio
|
||||
SettingsAudio,
|
||||
SettingsSimulator
|
||||
};
|
||||
|
||||
protected:
|
||||
@@ -82,6 +81,13 @@ namespace BlackCore
|
||||
return s;
|
||||
}
|
||||
|
||||
//! Path for simulator settings
|
||||
static const QString &PathSimulatorSettings()
|
||||
{
|
||||
static QString s("simulator");
|
||||
return s;
|
||||
}
|
||||
|
||||
//! Root path
|
||||
static const QString &PathRoot()
|
||||
{
|
||||
@@ -123,6 +129,9 @@ namespace BlackCore
|
||||
//! Audio settings
|
||||
virtual BlackMisc::Settings::CSettingsAudio getAudioSettings() const = 0;
|
||||
|
||||
//! Audio settings
|
||||
virtual BlackSim::Settings::CSettingsSimulator getSimulatorSettings() const = 0;
|
||||
|
||||
//! Hotkeys
|
||||
virtual BlackMisc::Hardware::CKeyboardKeyList getHotkeys() const = 0;
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ using namespace BlackMisc;
|
||||
using namespace BlackMisc::Settings;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Hardware;
|
||||
using namespace BlackSim::Settings;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
@@ -62,7 +63,7 @@ namespace BlackCore
|
||||
if (jsonObject.contains(IContextSettings::PathAudioSettings()))
|
||||
{
|
||||
this->m_settingsAudio.fromJson(
|
||||
jsonObject.value(IContextSettings::PathNetworkSettings()).toObject()
|
||||
jsonObject.value(IContextSettings::PathAudioSettings()).toObject()
|
||||
);
|
||||
}
|
||||
else
|
||||
@@ -70,6 +71,18 @@ namespace BlackCore
|
||||
this->m_settingsAudio.initDefaultValues();
|
||||
}
|
||||
|
||||
// init simulator
|
||||
if (jsonObject.contains(IContextSettings::PathSimulatorSettings()))
|
||||
{
|
||||
this->m_settingsSimulator.fromJson(
|
||||
jsonObject.value(IContextSettings::PathSimulatorSettings()).toObject()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->m_settingsSimulator.initDefaultValues();
|
||||
}
|
||||
|
||||
// init own members
|
||||
if (jsonObject.contains(IContextSettings::PathHotkeys()))
|
||||
{
|
||||
@@ -129,6 +142,7 @@ namespace BlackCore
|
||||
this->m_hotkeys.initAsHotkeyList(true);
|
||||
this->m_settingsNetwork.initDefaultValues();
|
||||
this->m_settingsAudio.initDefaultValues();
|
||||
this->m_settingsSimulator.initDefaultValues();
|
||||
this->emitCompletelyChanged();
|
||||
if (write)
|
||||
return this->write();
|
||||
@@ -152,6 +166,7 @@ namespace BlackCore
|
||||
QJsonObject jsonObject;
|
||||
jsonObject.insert(IContextSettings::PathNetworkSettings(), this->m_settingsNetwork.toJson());
|
||||
jsonObject.insert(IContextSettings::PathAudioSettings(), this->m_settingsAudio.toJson());
|
||||
jsonObject.insert(IContextSettings::PathSimulatorSettings(), this->m_settingsSimulator.toJson());
|
||||
jsonObject.insert(IContextSettings::PathHotkeys(), this->m_hotkeys.toJson());
|
||||
QJsonDocument doc(jsonObject);
|
||||
return doc;
|
||||
@@ -165,6 +180,7 @@ namespace BlackCore
|
||||
emit this->changedSettings(IContextSettings::SettingsHotKeys);
|
||||
emit this->changedSettings(IContextSettings::SettingsNetwork);
|
||||
emit this->changedSettings(IContextSettings::SettingsAudio);
|
||||
emit this->changedSettings(IContextSettings::SettingsSimulator);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -191,6 +207,14 @@ namespace BlackCore
|
||||
return this->m_settingsAudio;
|
||||
}
|
||||
|
||||
/*
|
||||
* Simulator settings
|
||||
*/
|
||||
CSettingsSimulator CContextSettings::getSimulatorSettings() const
|
||||
{
|
||||
return this->m_settingsSimulator;
|
||||
}
|
||||
|
||||
/*
|
||||
* Pass value
|
||||
*/
|
||||
|
||||
@@ -10,9 +10,7 @@
|
||||
#include "dbus_server.h"
|
||||
#include "context_runtime.h"
|
||||
|
||||
#include "blackmisc/setnetwork.h"
|
||||
#include "blackmisc/setaudio.h"
|
||||
|
||||
#include "blackcore/settingsallclasses.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include "blackmisc/hwkeyboardkeylist.h"
|
||||
|
||||
@@ -20,7 +18,7 @@ namespace BlackCore
|
||||
{
|
||||
|
||||
/*!
|
||||
* \brief Settings context implementation
|
||||
* Settings context implementation
|
||||
*/
|
||||
class CContextSettings : public IContextSettings
|
||||
{
|
||||
@@ -30,10 +28,10 @@ namespace BlackCore
|
||||
friend class IContextSettings;
|
||||
|
||||
protected:
|
||||
//! \brief Constructor
|
||||
//! Constructor
|
||||
CContextSettings(CRuntimeConfig::ContextMode mode, CRuntime *runtime = nullptr);
|
||||
|
||||
//! \brief Register myself in DBus
|
||||
//! Register myself in DBus
|
||||
CContextSettings *registerWithDBus(CDBusServer *server)
|
||||
{
|
||||
if (!server || this->m_mode != CRuntimeConfig::LocalInDbusServer) return this;
|
||||
@@ -45,7 +43,7 @@ namespace BlackCore
|
||||
//! Destructor
|
||||
virtual ~CContextSettings() {}
|
||||
|
||||
//! \brief settings file
|
||||
//! settings file
|
||||
const QString &getSettingsDirectory() const { return BlackMisc::Settings::CSettingUtilities::getSettingsDirectory(); }
|
||||
|
||||
//! \copydoc IContextSettings::value()
|
||||
@@ -58,10 +56,13 @@ namespace BlackCore
|
||||
//! \copydoc IContextSettings::getAudioSettings()
|
||||
virtual BlackMisc::Settings::CSettingsAudio getAudioSettings() const override;
|
||||
|
||||
//! \copydoc IContextSettings::getSimulatorSettings()
|
||||
virtual BlackSim::Settings::CSettingsSimulator getSimulatorSettings() const override;
|
||||
|
||||
//! \copydoc IContextSettings::getHotkeys()
|
||||
virtual BlackMisc::Hardware::CKeyboardKeyList getHotkeys() const override;
|
||||
|
||||
//! \brief read settings
|
||||
//! read settings
|
||||
virtual BlackMisc::CStatusMessage read() override;
|
||||
|
||||
//! \copydoc IContextSettings::write
|
||||
@@ -79,6 +80,7 @@ namespace BlackCore
|
||||
private:
|
||||
BlackMisc::Settings::CSettingsNetwork m_settingsNetwork;
|
||||
BlackMisc::Settings::CSettingsAudio m_settingsAudio;
|
||||
BlackSim::Settings::CSettingsSimulator m_settingsSimulator;
|
||||
BlackMisc::Hardware::CKeyboardKeyList m_hotkeys;
|
||||
QJsonDocument toJsonDocument() const;
|
||||
void emitCompletelyChanged();
|
||||
|
||||
@@ -15,6 +15,7 @@ using namespace BlackMisc;
|
||||
using namespace BlackMisc::Settings;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Hardware;
|
||||
using namespace BlackSim::Settings;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
@@ -57,6 +58,14 @@ namespace BlackCore
|
||||
return this->m_dBusInterface->callDBusRet<CSettingsAudio>(QLatin1Literal("getAudioSettings"));
|
||||
}
|
||||
|
||||
/*
|
||||
* Relay to DBus
|
||||
*/
|
||||
CSettingsSimulator CContextSettingsProxy::getSimulatorSettings() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<CSettingsSimulator>(QLatin1Literal("getSimulatorSettings"));
|
||||
}
|
||||
|
||||
/*
|
||||
* Relay to DBus
|
||||
*/
|
||||
|
||||
@@ -52,6 +52,9 @@ namespace BlackCore
|
||||
//! \copydoc IContextSettings::getAudioSettings()
|
||||
virtual BlackMisc::Settings::CSettingsAudio getAudioSettings() const override;
|
||||
|
||||
//! \copydoc IContextSettings::getSimulatorSettings()
|
||||
virtual BlackSim::Settings::CSettingsSimulator getSimulatorSettings() const override;
|
||||
|
||||
//! \copydoc IContextSettings::getHotkeys()
|
||||
virtual BlackMisc::Hardware::CKeyboardKeyList getHotkeys() const override;
|
||||
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
#include "context.h"
|
||||
#include "blackcore/dbus_server.h"
|
||||
#include "blackcore/context_runtime.h"
|
||||
#include "blackmisc/nwaircraftmodel.h"
|
||||
#include "blackmisc/avaircraft.h"
|
||||
#include "blacksim/simulatorinfo.h"
|
||||
#include "blacksim/simulatorinfolist.h"
|
||||
#include "blackmisc/nwaircraftmodel.h"
|
||||
#include "blackmisc/avaircraft.h"
|
||||
#include "blackmisc/project.h"
|
||||
#include <QObject>
|
||||
|
||||
|
||||
12
src/blackcore/settingsallclasses.h
Normal file
12
src/blackcore/settingsallclasses.h
Normal file
@@ -0,0 +1,12 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef BLACKCORE_SETTINGSALLCLASSES_H
|
||||
#define BLACKCORE_SETTINGSALLCLASSES_H
|
||||
|
||||
#include "blackmisc/settingsblackmiscclasses.h"
|
||||
#include "blacksim/setsimulator.h"
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user