mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 02:06:08 +08:00
Removed settings context
* removed old settings related classes * moved notifications to BlackMisc::Audio * added audio settings where needed refs #464 refs #337
This commit is contained in:
committed by
Mathew Sutcliffe
parent
821e0417ae
commit
ac61a3458d
@@ -61,16 +61,6 @@ namespace BlackCore
|
||||
return this->getRuntime()->getIContextOwnAircraft();
|
||||
}
|
||||
|
||||
IContextSettings *CContext::getIContextSettings()
|
||||
{
|
||||
return this->getRuntime()->getIContextSettings();
|
||||
}
|
||||
|
||||
const IContextSettings *CContext::getIContextSettings() const
|
||||
{
|
||||
return this->getRuntime()->getIContextSettings();
|
||||
}
|
||||
|
||||
IContextSimulator *CContext::getIContextSimulator()
|
||||
{
|
||||
return this->getRuntime()->getIContextSimulator();
|
||||
|
||||
@@ -97,12 +97,6 @@ namespace BlackCore
|
||||
//! Context for own aircraft
|
||||
const IContextOwnAircraft *getIContextOwnAircraft() const;
|
||||
|
||||
//! Settings
|
||||
IContextSettings *getIContextSettings();
|
||||
|
||||
//! Settings
|
||||
const IContextSettings *getIContextSettings() const;
|
||||
|
||||
//! Context for simulator
|
||||
const IContextSimulator *getIContextSimulator() const;
|
||||
|
||||
@@ -119,14 +113,15 @@ namespace BlackCore
|
||||
virtual QString getPathAndContextId() const = 0;
|
||||
|
||||
protected:
|
||||
CRuntimeConfig::ContextMode m_mode; //!< How context is used
|
||||
qint64 m_contextId; //!< unique identifer, avoid redirection rountrips
|
||||
bool m_debugEnabled = false; //!< debug messages enabled
|
||||
|
||||
//! Constructor
|
||||
CContext(CRuntimeConfig::ContextMode mode, QObject *parent) :
|
||||
QObject(parent), m_mode(mode), m_contextId(QDateTime::currentMSecsSinceEpoch())
|
||||
{}
|
||||
|
||||
CRuntimeConfig::ContextMode m_mode; //!< How context is used
|
||||
qint64 m_contextId; //!< unique identifer, avoid redirection rountrips
|
||||
|
||||
//! Path and context id
|
||||
QString buildPathAndContextId(const QString &path) const
|
||||
{
|
||||
@@ -139,8 +134,6 @@ namespace BlackCore
|
||||
BlackMisc::CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).warning("Empty context called, details: %1") << functionName;
|
||||
}
|
||||
|
||||
bool m_debugEnabled = false; //!< debug messages enabled
|
||||
|
||||
//! Standard message when status message is returned in empty context
|
||||
static const BlackMisc::CStatusMessage &statusMessageEmptyContext();
|
||||
};
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "context_audio_impl.h"
|
||||
#include "context_network_impl.h"
|
||||
#include "context_ownaircraft_impl.h"
|
||||
#include "context_settings_impl.h"
|
||||
#include "context_simulator_impl.h"
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "context_audio.h"
|
||||
#include "context_network.h"
|
||||
#include "context_ownaircraft.h"
|
||||
#include "context_settings.h"
|
||||
#include "context_simulator.h"
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
#include "context_audio_proxy.h"
|
||||
#include "context_network_proxy.h"
|
||||
#include "context_ownaircraft_proxy.h"
|
||||
#include "context_settings_proxy.h"
|
||||
#include "context_simulator_proxy.h"
|
||||
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "blackcore/context_application.h"
|
||||
#include "blackcore/context_application_impl.h"
|
||||
#include "blackcore/context_application_proxy.h"
|
||||
#include "blackcore/context_settings.h"
|
||||
#include "blackcore/input_manager.h"
|
||||
#include "blackcore/settingscache.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
@@ -21,7 +20,6 @@
|
||||
|
||||
using namespace BlackCore;
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Settings;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include "context_runtime.h"
|
||||
#include "input_manager.h"
|
||||
#include "settingscache.h"
|
||||
#include "blackmisc/settingutilities.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/loghandler.h"
|
||||
#include <QtMsgHandler>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "blackcoreexport.h"
|
||||
#include "blackcore/context.h"
|
||||
#include "blackmisc/notificationsounds.h"
|
||||
#include "blackmisc/audio/notificationsounds.h"
|
||||
#include "blackmisc/identifier.h"
|
||||
#include "blackmisc/genericdbusinterface.h"
|
||||
#include "blackmisc/audio/audiodeviceinfolist.h"
|
||||
@@ -148,7 +148,7 @@ namespace BlackCore
|
||||
//! Play notification sound
|
||||
//! \param notification CSoundGenerator::Notification
|
||||
//! \param considerSettings consider settings (notification on/off), false means settings ignored
|
||||
virtual void playNotification(BlackSound::CNotificationSounds::Notification notification, bool considerSettings) const = 0;
|
||||
virtual void playNotification(BlackMisc::Audio::CNotificationSounds::Notification notification, bool considerSettings) const = 0;
|
||||
|
||||
//! Enable audio loopback
|
||||
virtual void enableAudioLoopback(bool enable = true) = 0;
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
//! \copydoc IContextAudio::playNotification()
|
||||
virtual void playNotification(BlackSound::CNotificationSounds::Notification notification, bool considerSettings) const override
|
||||
virtual void playNotification(BlackMisc::Audio::CNotificationSounds::Notification notification, bool considerSettings) const override
|
||||
{
|
||||
Q_UNUSED(notification);
|
||||
Q_UNUSED(considerSettings);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "voice_vatlib.h"
|
||||
|
||||
#include "blacksound/soundgenerator.h"
|
||||
#include "blackmisc/notificationsounds.h"
|
||||
#include "blackmisc/audio/notificationsounds.h"
|
||||
#include "blackmisc/audio/voiceroomlist.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/simplecommandparser.h"
|
||||
@@ -26,14 +26,11 @@ using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Audio;
|
||||
using namespace BlackMisc::Input;
|
||||
using namespace BlackMisc::Audio;
|
||||
using namespace BlackSound;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
/*
|
||||
* Init this context
|
||||
*/
|
||||
CContextAudio::CContextAudio(CRuntimeConfig::ContextMode mode, CRuntime *runtime) :
|
||||
IContextAudio(mode, runtime),
|
||||
m_voice(new CVoiceVatlib())
|
||||
@@ -75,17 +72,11 @@ namespace BlackCore
|
||||
m_unusedVoiceChannels.push_back(m_channel2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Cleanup
|
||||
*/
|
||||
CContextAudio::~CContextAudio()
|
||||
{
|
||||
this->leaveAllVoiceRooms();
|
||||
}
|
||||
|
||||
/*
|
||||
* Voice rooms for COM
|
||||
*/
|
||||
CVoiceRoomList CContextAudio::getComVoiceRoomsWithAudioStatus() const
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
@@ -93,9 +84,6 @@ namespace BlackCore
|
||||
return getComVoiceRooms();
|
||||
}
|
||||
|
||||
/*
|
||||
* Voice rooms for COM
|
||||
*/
|
||||
CVoiceRoom CContextAudio::getVoiceRoom(BlackMisc::Aviation::CComSystem::ComUnit comUnitValue, bool withAudioStatus) const
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
@@ -109,9 +97,6 @@ namespace BlackCore
|
||||
return CVoiceRoom();
|
||||
}
|
||||
|
||||
/*
|
||||
* Voice rooms for COM (const)
|
||||
*/
|
||||
CVoiceRoomList CContextAudio::getComVoiceRooms() const
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
@@ -143,9 +128,6 @@ namespace BlackCore
|
||||
return voiceRoomList;
|
||||
}
|
||||
|
||||
/*
|
||||
* Leave all voice rooms
|
||||
*/
|
||||
void CContextAudio::leaveAllVoiceRooms()
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
@@ -157,9 +139,6 @@ namespace BlackCore
|
||||
m_unusedVoiceChannels.push_back(m_channel2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Audio devices
|
||||
*/
|
||||
CAudioDeviceInfoList CContextAudio::getAudioDevices() const
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
@@ -169,9 +148,6 @@ namespace BlackCore
|
||||
return devices;
|
||||
}
|
||||
|
||||
/*
|
||||
* Audio default devices
|
||||
*/
|
||||
CAudioDeviceInfoList CContextAudio::getCurrentAudioDevices() const
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
@@ -182,9 +158,6 @@ namespace BlackCore
|
||||
return devices;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set current device
|
||||
*/
|
||||
void CContextAudio::setCurrentAudioDevice(const CAudioDeviceInfo &audioDevice)
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
@@ -265,18 +238,12 @@ namespace BlackCore
|
||||
emit changedMute(muted);
|
||||
}
|
||||
|
||||
/*
|
||||
* Muted?
|
||||
*/
|
||||
bool CContextAudio::isMuted() const
|
||||
{
|
||||
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;
|
||||
return m_voiceOutputDevice->getOutputVolume() < 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set voice rooms
|
||||
*/
|
||||
void CContextAudio::setComVoiceRooms(const CVoiceRoomList &newRooms)
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
@@ -414,24 +381,22 @@ namespace BlackCore
|
||||
Q_ASSERT(this->m_voice);
|
||||
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << selcal;
|
||||
CAudioDeviceInfo outputDevice = m_voiceOutputDevice->getCurrentOutputDevice();
|
||||
BlackSound::CSoundGenerator::playSelcal(90, selcal, outputDevice);
|
||||
CSoundGenerator::playSelcal(90, selcal, outputDevice);
|
||||
}
|
||||
|
||||
/*
|
||||
* Notification
|
||||
*/
|
||||
void CContextAudio::playNotification(BlackSound::CNotificationSounds::Notification notification, bool considerSettings) const
|
||||
void CContextAudio::playNotification(CNotificationSounds::Notification notification, bool considerSettings) const
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << notification;
|
||||
|
||||
if (considerSettings)
|
||||
bool play = !considerSettings || m_audioSettings.get().getNotificationFlag(notification);
|
||||
if (play)
|
||||
{
|
||||
Q_ASSERT(this->getIContextSettings());
|
||||
bool play = this->getIContextSettings()->getAudioSettings().getNotificationFlag(notification);
|
||||
if (!play) return;
|
||||
CSoundGenerator::playNotificationSound(90, notification);
|
||||
}
|
||||
BlackSound::CSoundGenerator::playNotificationSound(90, notification);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -513,7 +478,7 @@ namespace BlackCore
|
||||
* Connection status changed
|
||||
*/
|
||||
void CContextAudio::ps_connectionStatusChanged(BlackCore::IVoiceChannel::ConnectionStatus oldStatus,
|
||||
BlackCore::IVoiceChannel::ConnectionStatus newStatus)
|
||||
BlackCore::IVoiceChannel::ConnectionStatus newStatus)
|
||||
{
|
||||
Q_UNUSED(oldStatus);
|
||||
|
||||
|
||||
@@ -12,17 +12,17 @@
|
||||
#ifndef BLACKCORE_CONTEXTAUDIO_IMPL_H
|
||||
#define BLACKCORE_CONTEXTAUDIO_IMPL_H
|
||||
|
||||
#include "blackcoreexport.h"
|
||||
#include "context_audio.h"
|
||||
#include "context_settings.h"
|
||||
#include "context_runtime.h"
|
||||
#include "dbus_server.h"
|
||||
#include "voice.h"
|
||||
#include "voice_channel.h"
|
||||
#include "audio_device.h"
|
||||
#include "audio_mixer.h"
|
||||
#include "actionbind.h"
|
||||
#include "blackcore/blackcoreexport.h"
|
||||
#include "blackcore/context_audio.h"
|
||||
#include "blackcore/context_runtime.h"
|
||||
#include "blackcore/dbus_server.h"
|
||||
#include "blackcore/voice.h"
|
||||
#include "blackcore/voice_channel.h"
|
||||
#include "blackcore/audio_device.h"
|
||||
#include "blackcore/audio_mixer.h"
|
||||
#include "blackcore/actionbind.h"
|
||||
#include "blackinput/keyboard.h"
|
||||
#include "blackcore/settings/audio.h"
|
||||
#include "blackmisc/audio/voiceroomlist.h"
|
||||
|
||||
#include <QThread>
|
||||
@@ -98,7 +98,7 @@ namespace BlackCore
|
||||
virtual void playSelcalTone(const BlackMisc::Aviation::CSelcal &selcal) const override;
|
||||
|
||||
//! \copydoc IContextAudio::playNotification()
|
||||
virtual void playNotification(BlackSound::CNotificationSounds::Notification notification, bool considerSettings) const override;
|
||||
virtual void playNotification(BlackMisc::Audio::CNotificationSounds::Notification notification, bool considerSettings) const override;
|
||||
|
||||
//! \copydoc IContextAudio::enableAudioLoopback()
|
||||
virtual void enableAudioLoopback(bool enable = true) override;
|
||||
@@ -147,15 +147,14 @@ namespace BlackCore
|
||||
void ps_userLeftRoom(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
private:
|
||||
const int MinUnmuteVolume = 20; //!< minimum volume when unmuted
|
||||
|
||||
//! Connection in transition
|
||||
bool inTransitionState() const;
|
||||
|
||||
//! Voice channel by room
|
||||
QSharedPointer<IVoiceChannel> getVoiceChannelBy(const BlackMisc::Audio::CVoiceRoom &voiceRoom);
|
||||
|
||||
const int MinUnmuteVolume = 20; //!< minimum volume when unmuted
|
||||
CActionBind m_actionPtt { "/Voice/Activate push-to-talk", this, &CContextAudio::ps_setVoiceTransmission };
|
||||
|
||||
std::unique_ptr<IVoice> m_voice; //!< underlying voice lib
|
||||
std::unique_ptr<IAudioMixer> m_audioMixer;
|
||||
int m_outVolumeBeforeMute = 90;
|
||||
@@ -168,6 +167,9 @@ namespace BlackCore
|
||||
|
||||
QList<QSharedPointer<IVoiceChannel>> m_unusedVoiceChannels;
|
||||
QHash<BlackMisc::Aviation::CComSystem::ComUnit, QSharedPointer<IVoiceChannel>> m_voiceChannelMapping;
|
||||
|
||||
// settings
|
||||
CSetting<BlackCore::Settings::Audio::AudioSettings> m_audioSettings { this };
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Notification sound
|
||||
*/
|
||||
void CContextAudioProxy::playNotification(BlackSound::CNotificationSounds::Notification notification, bool considerSettings) const
|
||||
void CContextAudioProxy::playNotification(CNotificationSounds::Notification notification, bool considerSettings) const
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("playNotification"), notification, considerSettings);
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace BlackCore
|
||||
virtual void playSelcalTone(const BlackMisc::Aviation::CSelcal &selcal) const override;
|
||||
|
||||
//! \copydoc IContextAudio::playNotification
|
||||
virtual void playNotification(BlackSound::CNotificationSounds::Notification notification, bool considerSettings) const override;
|
||||
virtual void playNotification(BlackMisc::Audio::CNotificationSounds::Notification notification, bool considerSettings) const override;
|
||||
|
||||
//! \copydoc IContextAudio::enableAudioLoopback()
|
||||
virtual void enableAudioLoopback(bool enable = true) override;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include "context_network_impl.h"
|
||||
#include "context_runtime.h"
|
||||
#include "context_settings.h"
|
||||
#include "context_application.h"
|
||||
#include "context_simulator.h"
|
||||
#include "context_ownaircraft_impl.h"
|
||||
@@ -41,7 +40,6 @@ namespace BlackCore
|
||||
IContextNetwork(mode, runtime)
|
||||
{
|
||||
Q_ASSERT(this->getRuntime());
|
||||
Q_ASSERT(this->getIContextSettings());
|
||||
Q_ASSERT(this->getIContextOwnAircraft());
|
||||
Q_ASSERT(this->getIContextOwnAircraft()->isUsingImplementingObject());
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
#include "blackcoreexport.h"
|
||||
#include "blackcore/context_network.h"
|
||||
#include "blackcore/context_settings.h"
|
||||
#include "blackcore/context_runtime.h"
|
||||
#include "blackcore/dbus_server.h"
|
||||
#include "blackcore/network.h"
|
||||
@@ -22,7 +21,6 @@
|
||||
#include "blackmisc/aviation/atcstationlist.h"
|
||||
#include "blackmisc/aviation/aircraftsituationlist.h"
|
||||
#include "blackmisc/weather/metarset.h"
|
||||
#include "blackmisc/setnetwork.h"
|
||||
#include "blackmisc/network/clientlist.h"
|
||||
#include "blackmisc/digestsignal.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "context_audio.h"
|
||||
#include "context_application.h"
|
||||
#include "context_runtime.h"
|
||||
#include "context_settings.h"
|
||||
#include "blackmisc/simplecommandparser.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
|
||||
@@ -32,7 +31,6 @@ namespace BlackCore
|
||||
CIdentifiable(this)
|
||||
{
|
||||
Q_ASSERT(this->getRuntime());
|
||||
Q_ASSERT(this->getRuntime()->getIContextSettings());
|
||||
this->setObjectName("CContextOwnAircraft");
|
||||
|
||||
// Init own aircraft
|
||||
@@ -74,7 +72,6 @@ namespace BlackCore
|
||||
void CContextOwnAircraft::initOwnAircraft()
|
||||
{
|
||||
Q_ASSERT(this->getRuntime());
|
||||
Q_ASSERT(this->getRuntime()->getIContextSettings());
|
||||
{
|
||||
QWriteLocker l(&m_lockAircraft);
|
||||
this->m_ownAircraft.initComSystems();
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
#include "blackcoreexport.h"
|
||||
#include "blackcore/context_ownaircraft.h"
|
||||
#include "blackcore/context_settings.h"
|
||||
#include "blackcore/context_runtime.h"
|
||||
#include "blackcore/dbus_server.h"
|
||||
#include "blackcore/settings/network.h"
|
||||
|
||||
@@ -65,9 +65,6 @@ namespace BlackCore
|
||||
times.insert("DBus", time.restart());
|
||||
|
||||
// contexts
|
||||
this->m_contextSettings = IContextSettings::create(this, config.getModeSettings(), this->m_dbusServer, this->m_dbusConnection);
|
||||
times.insert("Settings", time.restart());
|
||||
|
||||
this->m_contextApplication = IContextApplication::create(this, config.getModeApplication(), this->m_dbusServer, this->m_dbusConnection);
|
||||
times.insert("Application", time.restart());
|
||||
|
||||
@@ -137,13 +134,6 @@ namespace BlackCore
|
||||
QTime time;
|
||||
time.start();
|
||||
|
||||
if (this->m_contextSettings && this->m_contextApplication)
|
||||
{
|
||||
// \todo Remove with old settings
|
||||
c = connect(this->m_contextSettings, &IContextSettings::changedSettings,
|
||||
this->getIContextApplication(), static_cast<void (IContextApplication::*)(uint)>(&IContextApplication::changeSettings));
|
||||
Q_ASSERT(c);
|
||||
}
|
||||
times.insert("Post setup, connects first", time.restart());
|
||||
|
||||
// local simulator?
|
||||
@@ -186,13 +176,6 @@ namespace BlackCore
|
||||
Q_ASSERT(c);
|
||||
}
|
||||
times.insert("Post setup, sim.connects", time.restart());
|
||||
|
||||
// connect local simulator and settings and load plugin
|
||||
if (this->m_contextSettings)
|
||||
{
|
||||
connect(this->m_contextSettings, &IContextSettings::changedSettings, this->m_contextSimulator, &IContextSimulator::settingsChanged);
|
||||
times.insert("Post setup, load sim. listener(s)", time.restart());
|
||||
}
|
||||
this->m_contextSimulator->startSimulatorPlugin(CSimulatorPluginInfo::autoPlugin());
|
||||
}
|
||||
|
||||
@@ -275,13 +258,6 @@ namespace BlackCore
|
||||
this->m_contextOwnAircraft = nullptr;
|
||||
}
|
||||
|
||||
if (this->getIContextSettings())
|
||||
{
|
||||
disconnect(this->getIContextSettings());
|
||||
this->getIContextSettings()->deleteLater();
|
||||
this->m_contextSettings = nullptr;
|
||||
}
|
||||
|
||||
if (this->getIContextApplication())
|
||||
{
|
||||
disconnect(this->getIContextApplication());
|
||||
@@ -347,16 +323,6 @@ namespace BlackCore
|
||||
return this->m_contextOwnAircraft;
|
||||
}
|
||||
|
||||
IContextSettings *CRuntime::getIContextSettings()
|
||||
{
|
||||
return this->m_contextSettings;
|
||||
}
|
||||
|
||||
const IContextSettings *CRuntime::getIContextSettings() const
|
||||
{
|
||||
return this->m_contextSettings;
|
||||
}
|
||||
|
||||
const IContextSimulator *CRuntime::getIContextSimulator() const
|
||||
{
|
||||
return this->m_contextSimulator;
|
||||
@@ -446,7 +412,6 @@ namespace BlackCore
|
||||
this->m_audio == Remote ||
|
||||
this->m_network == Remote ||
|
||||
this->m_ownAircraft == Remote ||
|
||||
this->m_settings == Remote ||
|
||||
this->m_simulator == Remote);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,13 +33,11 @@ namespace BlackCore
|
||||
class CContextAudio;
|
||||
class CContextNetwork;
|
||||
class CContextOwnAircraft;
|
||||
class CContextSettings;
|
||||
class CContextSimulator;
|
||||
class IContextApplication;
|
||||
class IContextAudio;
|
||||
class IContextNetwork;
|
||||
class IContextOwnAircraft;
|
||||
class IContextSettings;
|
||||
class IContextSimulator;
|
||||
|
||||
//! The Context runtime class
|
||||
@@ -89,12 +87,6 @@ namespace BlackCore
|
||||
//! Context for own aircraft
|
||||
const IContextOwnAircraft *getIContextOwnAircraft() const;
|
||||
|
||||
//! Context for settings
|
||||
IContextSettings *getIContextSettings();
|
||||
|
||||
//! Context for settings
|
||||
const IContextSettings *getIContextSettings() const;
|
||||
|
||||
//! Context for simulator
|
||||
IContextSimulator *getIContextSimulator();
|
||||
|
||||
@@ -158,13 +150,12 @@ namespace BlackCore
|
||||
|
||||
private:
|
||||
bool m_init = false; //!< flag
|
||||
|
||||
CSetting<Settings::Network::DBusServerAddress> m_dbusServerAddress { this };
|
||||
|
||||
// DBus
|
||||
CDBusServer *m_dbusServer = nullptr;
|
||||
CDBusServer *m_dbusServer = nullptr;
|
||||
QDBusConnection m_dbusConnection = QDBusConnection("default");
|
||||
bool m_initDBusConnection = false;
|
||||
bool m_initDBusConnection = false;
|
||||
|
||||
// contexts:
|
||||
// There is a reason why we do not use smart pointers here. When the context is deleted
|
||||
@@ -173,7 +164,6 @@ namespace BlackCore
|
||||
IContextAudio *m_contextAudio = nullptr;
|
||||
IContextNetwork *m_contextNetwork = nullptr;
|
||||
IContextOwnAircraft *m_contextOwnAircraft = nullptr;
|
||||
IContextSettings *m_contextSettings = nullptr;
|
||||
IContextSimulator *m_contextSimulator = nullptr;
|
||||
|
||||
//! initialization of DBus connection (where applicable)
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
#include "context_settings.h"
|
||||
#include "context_settings_impl.h"
|
||||
#include "context_settings_proxy.h"
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
IContextSettings *IContextSettings::create(CRuntime *parent, CRuntimeConfig::ContextMode mode, CDBusServer *server, QDBusConnection &conn)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case CRuntimeConfig::Local:
|
||||
case CRuntimeConfig::LocalInDbusServer:
|
||||
{
|
||||
CContextSettings *contextSettings = new CContextSettings(mode, parent);
|
||||
contextSettings->registerWithDBus(server);
|
||||
contextSettings->read();
|
||||
return contextSettings;
|
||||
}
|
||||
case CRuntimeConfig::Remote:
|
||||
return new BlackCore::CContextSettingsProxy(BlackCore::CDBusServer::ServiceName(), conn, mode, parent);
|
||||
default:
|
||||
qFatal("Always initialize a settings context");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKCORE_CONTEXTSETTINGS_H
|
||||
#define BLACKCORE_CONTEXTSETTINGS_H
|
||||
|
||||
#include "blackcoreexport.h"
|
||||
#include "blackcore/context.h"
|
||||
#include "blackcore/dbus_server.h"
|
||||
#include "blackinput/keyboard.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include "blackmisc/dbus.h"
|
||||
#include "blackmisc/variant.h"
|
||||
#include "blackcore/settingsallclasses.h"
|
||||
#include <QObject>
|
||||
|
||||
//! \addtogroup dbus
|
||||
//! @{
|
||||
|
||||
//! DBus interface for context
|
||||
#define BLACKCORE_CONTEXTSETTINGS_INTERFACENAME "org.swift_project.blackcore.contextsettings"
|
||||
|
||||
//! DBus object path for context
|
||||
#define BLACKCORE_CONTEXTSETTINGS_OBJECTPATH "/settings"
|
||||
|
||||
//! @}
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
/*!
|
||||
* Context settings interface
|
||||
*/
|
||||
class BLACKCORE_EXPORT IContextSettings : public CContext
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTSETTINGS_INTERFACENAME)
|
||||
|
||||
public:
|
||||
//! Settings type
|
||||
enum SettingsType
|
||||
{
|
||||
SettingsNetwork,
|
||||
SettingsAudio,
|
||||
SettingsSimulator
|
||||
};
|
||||
|
||||
protected:
|
||||
//! DBus version constructor
|
||||
IContextSettings(CRuntimeConfig::ContextMode mode, CRuntime *runtime = nullptr) : CContext(mode, runtime)
|
||||
{}
|
||||
|
||||
public:
|
||||
//! Service name
|
||||
static const QString &InterfaceName()
|
||||
{
|
||||
static QString s(BLACKCORE_CONTEXTSETTINGS_INTERFACENAME);
|
||||
return s;
|
||||
}
|
||||
|
||||
//! Service path
|
||||
static const QString &ObjectPath()
|
||||
{
|
||||
static QString s(BLACKCORE_CONTEXTSETTINGS_OBJECTPATH);
|
||||
return s;
|
||||
}
|
||||
|
||||
//! \copydoc CContext::getPathAndContextId()
|
||||
virtual QString getPathAndContextId() const { return this->buildPathAndContextId(ObjectPath()); }
|
||||
|
||||
//! Path for audio settings
|
||||
static const QString &PathAudioSettings()
|
||||
{
|
||||
static QString s("audio");
|
||||
return s;
|
||||
}
|
||||
|
||||
//! Root path
|
||||
static const QString &PathRoot()
|
||||
{
|
||||
static QString s("root");
|
||||
return s;
|
||||
}
|
||||
|
||||
//! Factory method
|
||||
static IContextSettings *create(CRuntime *parent, CRuntimeConfig::ContextMode mode, CDBusServer *server, QDBusConnection &conn);
|
||||
|
||||
//! Destructor
|
||||
virtual ~IContextSettings() {}
|
||||
|
||||
signals:
|
||||
//! Settings have been changed
|
||||
//! \sa IContextSettings::SettingsType
|
||||
void changedSettings(uint type);
|
||||
|
||||
public slots:
|
||||
//! Handle value
|
||||
virtual BlackMisc::CStatusMessageList value(const QString &path, const QString &command, const BlackMisc::CVariant &value) = 0;
|
||||
|
||||
//! Audio settings
|
||||
virtual BlackMisc::Settings::CSettingsAudio getAudioSettings() const = 0;
|
||||
|
||||
//! Save settings
|
||||
virtual BlackMisc::CStatusMessage write() const = 0;
|
||||
|
||||
//! Read settings
|
||||
virtual BlackMisc::CStatusMessage read() = 0;
|
||||
|
||||
//! Reset settings
|
||||
virtual BlackMisc::CStatusMessage reset(bool write = true) = 0;
|
||||
|
||||
//! Read settings
|
||||
virtual QString getSettingsFileName() const = 0;
|
||||
|
||||
//! Settings as JSON string
|
||||
virtual QString getSettingsAsJsonString() const = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // guard
|
||||
@@ -1,183 +0,0 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / authors
|
||||
* 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/. */
|
||||
|
||||
#include "context_settings_impl.h"
|
||||
#include "context_runtime.h"
|
||||
|
||||
#include "blackmisc/settingutilities.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include <QFile>
|
||||
#include <QJsonDocument>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Settings;
|
||||
using namespace BlackMisc::Input;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
/*
|
||||
* Init this context
|
||||
*/
|
||||
CContextSettings::CContextSettings(CRuntimeConfig::ContextMode mode, CRuntime *parent) : IContextSettings(mode, parent) {}
|
||||
|
||||
/*
|
||||
* Read settings
|
||||
*/
|
||||
CStatusMessage CContextSettings::read()
|
||||
{
|
||||
if (!CSettingUtilities::initSettingsDirectory())
|
||||
{
|
||||
return CLogMessage(this).error("Cannot init directory: %1") << this->getSettingsDirectory();
|
||||
}
|
||||
bool ok = false;
|
||||
QFile jsonFile(this->getSettingsFileName());
|
||||
QJsonObject jsonObject;
|
||||
|
||||
if (jsonFile.open(QFile::ReadOnly))
|
||||
{
|
||||
QJsonDocument doc = QJsonDocument::fromJson(jsonFile.readAll());
|
||||
jsonObject = doc.object();
|
||||
ok = true;
|
||||
}
|
||||
jsonFile.close();
|
||||
|
||||
// init audio
|
||||
if (jsonObject.contains(IContextSettings::PathAudioSettings()))
|
||||
{
|
||||
this->m_settingsAudio.convertFromJson(
|
||||
jsonObject.value(IContextSettings::PathAudioSettings()).toObject()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->m_settingsAudio.initDefaultValues();
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
return CStatusMessage(CStatusMessage::SeverityInfo, QString("Read settings: %1").arg(this->getSettingsFileName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
return CStatusMessage(CStatusMessage::SeverityError, QString("Problem reading settings: %1").arg(this->getSettingsFileName()));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Write settings
|
||||
*/
|
||||
CStatusMessage CContextSettings::write() const
|
||||
{
|
||||
if (!CSettingUtilities::initSettingsDirectory())
|
||||
{
|
||||
return CStatusMessage(CStatusMessage::SeverityError, QString("Cannot init directory: %1").arg(this->getSettingsDirectory()));
|
||||
}
|
||||
QFile jsonFile(this->getSettingsFileName());
|
||||
bool ok = false;
|
||||
if (jsonFile.open(QFile::WriteOnly))
|
||||
{
|
||||
QJsonDocument doc = this->toJsonDocument();
|
||||
ok = jsonFile.write(doc.toJson(QJsonDocument::Indented)) >= 0;
|
||||
jsonFile.close();
|
||||
}
|
||||
if (ok)
|
||||
{
|
||||
return CStatusMessage(CStatusMessage::SeverityInfo, QString("Written settings: %1").arg(this->getSettingsFileName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
return CStatusMessage(CStatusMessage::SeverityError, QString("Problem writing settings: %1").arg(this->getSettingsFileName()));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset settings
|
||||
*/
|
||||
CStatusMessage CContextSettings::reset(bool write)
|
||||
{
|
||||
this->m_settingsAudio.initDefaultValues();
|
||||
this->emitCompletelyChanged();
|
||||
if (write)
|
||||
{
|
||||
return this->write();
|
||||
}
|
||||
else
|
||||
{
|
||||
return CStatusMessage(CStatusMessage::SeverityInfo, "Reset settings data, not written");
|
||||
}
|
||||
}
|
||||
|
||||
QString CContextSettings::getSettingsAsJsonString() const
|
||||
{
|
||||
QJsonDocument doc = this->toJsonDocument();
|
||||
return QString(doc.toJson(QJsonDocument::Indented));
|
||||
}
|
||||
|
||||
/*
|
||||
* JSON document
|
||||
*/
|
||||
QJsonDocument CContextSettings::toJsonDocument() const
|
||||
{
|
||||
QJsonObject jsonObject;
|
||||
jsonObject.insert(IContextSettings::PathAudioSettings(), this->m_settingsAudio.toJson());
|
||||
QJsonDocument doc(jsonObject);
|
||||
return doc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Emit all changed signals
|
||||
*/
|
||||
void CContextSettings::emitCompletelyChanged()
|
||||
{
|
||||
emit this->changedSettings(IContextSettings::SettingsNetwork);
|
||||
emit this->changedSettings(IContextSettings::SettingsAudio);
|
||||
emit this->changedSettings(IContextSettings::SettingsSimulator);
|
||||
}
|
||||
|
||||
/*
|
||||
* Audio settings
|
||||
*/
|
||||
CSettingsAudio CContextSettings::getAudioSettings() const
|
||||
{
|
||||
return this->m_settingsAudio;
|
||||
}
|
||||
|
||||
/*
|
||||
* Pass value
|
||||
*/
|
||||
BlackMisc::CStatusMessageList CContextSettings::value(const QString &path, const QString &command, const BlackMisc::CVariant &value)
|
||||
{
|
||||
Q_ASSERT(path.length() > 3);
|
||||
Q_ASSERT(path.indexOf('/') >= 0);
|
||||
|
||||
BlackMisc::CStatusMessageList msgs;
|
||||
if (path.contains(IContextSettings::PathRoot()))
|
||||
{
|
||||
}
|
||||
|
||||
// next level
|
||||
QString nextLevelPath = CSettingUtilities::removeLeadingPath(path);
|
||||
if (path.startsWith(IContextSettings::PathAudioSettings()))
|
||||
{
|
||||
bool changed = false;
|
||||
msgs.push_back(this->m_settingsAudio.value(nextLevelPath, command, value, changed));
|
||||
if (changed)
|
||||
{
|
||||
msgs.push_back(this->write());
|
||||
emit this->changedSettings(static_cast<uint>(SettingsAudio));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
msgs.push_back(
|
||||
CStatusMessage({CLogCategory::validation()}, CStatusMessage::SeverityError, QString("Wrong path: %1").arg(this->getSettingsFileName()))
|
||||
);
|
||||
}
|
||||
return msgs;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -1,84 +0,0 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKCORE_CONTEXTSETTINGS_IMPL_H
|
||||
#define BLACKCORE_CONTEXTSETTINGS_IMPL_H
|
||||
|
||||
#include "blackcoreexport.h"
|
||||
#include "context_settings.h"
|
||||
#include "dbus_server.h"
|
||||
#include "context_runtime.h"
|
||||
|
||||
#include "blackcore/settingsallclasses.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
/*!
|
||||
* Settings context implementation
|
||||
*/
|
||||
class BLACKCORE_EXPORT CContextSettings : public IContextSettings
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTSETTINGS_INTERFACENAME)
|
||||
friend class CRuntime;
|
||||
friend class IContextSettings;
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CContextSettings(CRuntimeConfig::ContextMode mode, CRuntime *runtime = nullptr);
|
||||
|
||||
//! Register myself in DBus
|
||||
CContextSettings *registerWithDBus(CDBusServer *server)
|
||||
{
|
||||
if (!server || this->m_mode != CRuntimeConfig::LocalInDbusServer) return this;
|
||||
server->addObject(IContextSettings::ObjectPath(), this);
|
||||
return this;
|
||||
}
|
||||
|
||||
public:
|
||||
//! Destructor
|
||||
virtual ~CContextSettings() {}
|
||||
|
||||
//! \copydoc IContextSettings::value()
|
||||
virtual BlackMisc::CStatusMessageList value(const QString &path, const QString &command, const BlackMisc::CVariant &value) override;
|
||||
|
||||
public slots:
|
||||
//! \copydoc IContextSettings::getAudioSettings()
|
||||
virtual BlackMisc::Settings::CSettingsAudio getAudioSettings() const override;
|
||||
|
||||
//! read settings
|
||||
virtual BlackMisc::CStatusMessage read() override;
|
||||
|
||||
//! \copydoc IContextSettings::write
|
||||
virtual BlackMisc::CStatusMessage write() const override;
|
||||
|
||||
//! \copydoc IContextSettings::reset
|
||||
virtual BlackMisc::CStatusMessage reset(bool write = true) override;
|
||||
|
||||
//! Settings file name
|
||||
virtual QString getSettingsFileName() const override { return BlackMisc::Settings::CSettingUtilities::getSettingsFile(); }
|
||||
|
||||
//! JSON represenation
|
||||
virtual QString getSettingsAsJsonString() const override;
|
||||
|
||||
private:
|
||||
//! settings directory
|
||||
const QString &getSettingsDirectory() const { return BlackMisc::Settings::CSettingUtilities::getSettingsDirectory(); }
|
||||
|
||||
BlackMisc::Settings::CSettingsAudio m_settingsAudio;
|
||||
QJsonDocument toJsonDocument() const;
|
||||
void emitCompletelyChanged();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // guard
|
||||
@@ -1,100 +0,0 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / authors
|
||||
* 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/. */
|
||||
|
||||
#include "context_settings_proxy.h"
|
||||
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QMetaEnum>
|
||||
#include <QDBusConnection>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Settings;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Input;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
/*
|
||||
* Constructor for DBus
|
||||
*/
|
||||
CContextSettingsProxy::CContextSettingsProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextSettings(mode, runtime), m_dBusInterface(nullptr)
|
||||
{
|
||||
this->m_dBusInterface = new BlackMisc::CGenericDBusInterface(
|
||||
serviceName , IContextSettings::ObjectPath(), IContextSettings::InterfaceName(),
|
||||
connection, this);
|
||||
this->relaySignals(serviceName, connection);
|
||||
}
|
||||
|
||||
/*
|
||||
* Workaround for signals
|
||||
*/
|
||||
void CContextSettingsProxy::relaySignals(const QString &serviceName, QDBusConnection &connection)
|
||||
{
|
||||
bool s = connection.connect(serviceName, IContextSettings::ObjectPath(), IContextSettings::InterfaceName(),
|
||||
"changedSettings", this, SIGNAL(changedSettings(uint)));
|
||||
Q_ASSERT(s);
|
||||
Q_UNUSED(s);
|
||||
}
|
||||
|
||||
/*
|
||||
* Relay to DBus
|
||||
*/
|
||||
CSettingsAudio CContextSettingsProxy::getAudioSettings() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<CSettingsAudio>(QLatin1Literal("getAudioSettings"));
|
||||
}
|
||||
|
||||
/*
|
||||
* Relay to DBus, but make this no slot
|
||||
*/
|
||||
BlackMisc::CStatusMessageList CContextSettingsProxy::value(const QString &path, const QString &command, const BlackMisc::CVariant &value)
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::CStatusMessageList>(QLatin1Literal("value"), path, command, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write settings
|
||||
*/
|
||||
BlackMisc::CStatusMessage CContextSettingsProxy::write() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::CStatusMessage>(QLatin1Literal("write"));
|
||||
}
|
||||
|
||||
/*
|
||||
* Read settings
|
||||
*/
|
||||
CStatusMessage CContextSettingsProxy::read()
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::CStatusMessage>(QLatin1Literal("read"));
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset settings
|
||||
*/
|
||||
CStatusMessage CContextSettingsProxy::reset(bool write)
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::CStatusMessage>(QLatin1Literal("reset"), write);
|
||||
}
|
||||
|
||||
/*
|
||||
* File name
|
||||
*/
|
||||
QString CContextSettingsProxy::getSettingsFileName() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<QString>(QLatin1Literal("getSettingsFileName"));
|
||||
}
|
||||
|
||||
/*
|
||||
* As JSON string
|
||||
*/
|
||||
QString CContextSettingsProxy::getSettingsAsJsonString() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<QString>(QLatin1Literal("getSettingsAsJsonString"));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -1,69 +0,0 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / authors
|
||||
* 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_CONTEXTSETTINGS_PROXY_H
|
||||
#define BLACKCORE_CONTEXTSETTINGS_PROXY_H
|
||||
|
||||
#include "blackcoreexport.h"
|
||||
#include "context_settings.h"
|
||||
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include "blackmisc/genericdbusinterface.h"
|
||||
#include "blackmisc/settingutilities.h"
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
//! \brief Settings context proxy
|
||||
//! \ingroup dbus
|
||||
class BLACKCORE_EXPORT CContextSettingsProxy : public IContextSettings
|
||||
{
|
||||
Q_OBJECT
|
||||
friend class IContextSettings;
|
||||
|
||||
public:
|
||||
//! Destructor
|
||||
virtual ~CContextSettingsProxy() {}
|
||||
|
||||
private:
|
||||
BlackMisc::CGenericDBusInterface *m_dBusInterface;
|
||||
|
||||
//! Relay connection signals to local signals
|
||||
//! No idea why this has to be wired and is not done automatically
|
||||
void relaySignals(const QString &serviceName, QDBusConnection &connection);
|
||||
|
||||
protected:
|
||||
//! DBus version constructor
|
||||
CContextSettingsProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime);
|
||||
|
||||
//! Constructor
|
||||
CContextSettingsProxy(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextSettings(mode, runtime), m_dBusInterface(nullptr) {}
|
||||
|
||||
public slots:
|
||||
//! \copydoc IContextSettings::getAudioSettings()
|
||||
virtual BlackMisc::Settings::CSettingsAudio getAudioSettings() const override;
|
||||
|
||||
//! \copydoc IContextSettings::value
|
||||
virtual BlackMisc::CStatusMessageList value(const QString &path, const QString &command, const BlackMisc::CVariant &value) override;
|
||||
|
||||
//! \copydoc IContextSettings::write
|
||||
BlackMisc::CStatusMessage write() const override;
|
||||
|
||||
//! read settings
|
||||
virtual BlackMisc::CStatusMessage read() override;
|
||||
|
||||
//! \copydoc IContextSettings::reset
|
||||
virtual BlackMisc::CStatusMessage reset(bool write = true) override;
|
||||
|
||||
//! settings file name
|
||||
virtual QString getSettingsFileName() const override;
|
||||
|
||||
//! as JSON string
|
||||
virtual QString getSettingsAsJsonString() const override;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif // guard
|
||||
@@ -167,9 +167,6 @@ namespace BlackCore
|
||||
//! Simulator avialable (driver available)?
|
||||
bool isSimulatorAvailable() const { return BlackMisc::CProject::isCompiledWithFlightSimulatorSupport() && !getSimulatorPluginInfo().isUnspecified(); }
|
||||
|
||||
//! Settings have been changed
|
||||
virtual void settingsChanged(uint type) = 0;
|
||||
|
||||
//! Icon representing the model
|
||||
virtual BlackMisc::CPixmap iconForModel(const QString &modelString) const = 0;
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "context_simulator_impl.h"
|
||||
#include "context_ownaircraft_impl.h"
|
||||
#include "context_ownaircraft.h"
|
||||
#include "context_settings.h"
|
||||
#include "context_application.h"
|
||||
#include "context_network_impl.h"
|
||||
#include "plugin_manager_simulator.h"
|
||||
@@ -19,12 +18,10 @@
|
||||
#include "blackmisc/propertyindexvariantmap.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/loghandler.h"
|
||||
#include "blackmisc/settingutilities.h"
|
||||
#include <QPluginLoader>
|
||||
#include <QLibrary>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Settings;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Network;
|
||||
@@ -553,14 +550,6 @@ namespace BlackCore
|
||||
m_simulatorPlugin.second->updateOwnSimulatorCockpit(ownAircraft, originator);
|
||||
}
|
||||
|
||||
void CContextSimulator::settingsChanged(uint type)
|
||||
{
|
||||
auto settingsType = static_cast<IContextSettings::SettingsType>(type);
|
||||
if (settingsType != IContextSettings::SettingsSimulator) { return; }
|
||||
|
||||
// simulator code would go here
|
||||
}
|
||||
|
||||
CPixmap CContextSimulator::iconForModel(const QString &modelString) const
|
||||
{
|
||||
if (m_simulatorPlugin.first.isUnspecified()) { return CPixmap(); }
|
||||
|
||||
@@ -115,9 +115,6 @@ namespace BlackCore
|
||||
//! \copydoc IContextSimulator::getTimeSynchronizationOffset
|
||||
virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::settingsChanged
|
||||
virtual void settingsChanged(uint type) override;
|
||||
|
||||
//! \copydoc IContextSimulator::iconForModel
|
||||
virtual BlackMisc::CPixmap iconForModel(const QString &modelString) const override;
|
||||
|
||||
|
||||
@@ -171,11 +171,6 @@ namespace BlackCore
|
||||
m_dBusInterface->callDBus(QLatin1Literal("stopSimulatorPlugin"));
|
||||
}
|
||||
|
||||
void CContextSimulatorProxy::settingsChanged(uint type)
|
||||
{
|
||||
m_dBusInterface->callDBus(QLatin1Literal("settingsChanged"), type);
|
||||
}
|
||||
|
||||
CPixmap CContextSimulatorProxy::iconForModel(const QString &modelString) const
|
||||
{
|
||||
return m_dBusInterface->callDBusRet<CPixmap>(QLatin1Literal("iconForModel"), modelString);
|
||||
|
||||
@@ -113,9 +113,6 @@ namespace BlackCore
|
||||
//! \copydoc IContextSimulator::getTimeSynchronizationOffset
|
||||
virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::settingsChanged
|
||||
virtual void settingsChanged(uint type) override;
|
||||
|
||||
//! \copydoc IContextSimulator::iconForModel
|
||||
virtual BlackMisc::CPixmap iconForModel(const QString &modelString) const override;
|
||||
|
||||
|
||||
41
src/blackcore/settings/audio.h
Normal file
41
src/blackcore/settings/audio.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKCORE_SETTINGS_AUDIO_H
|
||||
#define BLACKCORE_SETTINGS_AUDIO_H
|
||||
|
||||
#include "blackcore/settingscache.h"
|
||||
#include "blackmisc/audio/settings/settingsaudio.h"
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
namespace Settings
|
||||
{
|
||||
namespace Audio
|
||||
{
|
||||
//! Name of text codec to use with text in FSD protocol
|
||||
struct AudioSettings : public CSettingTrait<BlackMisc::Audio::Settings::CSettingsAudio>
|
||||
{
|
||||
//! \copydoc BlackCore::CSetting::key
|
||||
static const char *key() { return "audio/setup"; }
|
||||
|
||||
//! \copydoc BlackCore::CSetting::defaultValue
|
||||
static const BlackMisc::Audio::Settings::CSettingsAudio &defaultValue() { static const BlackMisc::Audio::Settings::CSettingsAudio a; return a; }
|
||||
|
||||
//! \copydoc BlackCore::CSetting::isValid
|
||||
static bool isValid(const BlackMisc::Audio::Settings::CSettingsAudio &value) { Q_UNUSED(value); return true; }
|
||||
};
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user