diff --git a/src/blackcore/context.cpp b/src/blackcore/context.cpp index 47330cb82..c3bdfb697 100644 --- a/src/blackcore/context.cpp +++ b/src/blackcore/context.cpp @@ -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(); diff --git a/src/blackcore/context.h b/src/blackcore/context.h index 682ee6b9c..e5396b8f3 100644 --- a/src/blackcore/context.h +++ b/src/blackcore/context.h @@ -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(); }; diff --git a/src/blackcore/context_all_impl.h b/src/blackcore/context_all_impl.h index 16ec82466..c4f75916f 100644 --- a/src/blackcore/context_all_impl.h +++ b/src/blackcore/context_all_impl.h @@ -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 diff --git a/src/blackcore/context_all_interfaces.h b/src/blackcore/context_all_interfaces.h index 59472f732..5e738e6cc 100644 --- a/src/blackcore/context_all_interfaces.h +++ b/src/blackcore/context_all_interfaces.h @@ -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 diff --git a/src/blackcore/context_all_proxies.h b/src/blackcore/context_all_proxies.h index 72a9f72c5..186d178f6 100644 --- a/src/blackcore/context_all_proxies.h +++ b/src/blackcore/context_all_proxies.h @@ -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 diff --git a/src/blackcore/context_application.cpp b/src/blackcore/context_application.cpp index 19f005fbc..dfd3c62f3 100644 --- a/src/blackcore/context_application.cpp +++ b/src/blackcore/context_application.cpp @@ -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 { diff --git a/src/blackcore/context_application_impl.cpp b/src/blackcore/context_application_impl.cpp index e555ec5bc..fa11fa03b 100644 --- a/src/blackcore/context_application_impl.cpp +++ b/src/blackcore/context_application_impl.cpp @@ -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 diff --git a/src/blackcore/context_audio.h b/src/blackcore/context_audio.h index 296da78a5..a720e5f53 100644 --- a/src/blackcore/context_audio.h +++ b/src/blackcore/context_audio.h @@ -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; diff --git a/src/blackcore/context_audio_empty.h b/src/blackcore/context_audio_empty.h index 3c0da93b2..70e735116 100644 --- a/src/blackcore/context_audio_empty.h +++ b/src/blackcore/context_audio_empty.h @@ -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); diff --git a/src/blackcore/context_audio_impl.cpp b/src/blackcore/context_audio_impl.cpp index bc029cb12..d62237035 100644 --- a/src/blackcore/context_audio_impl.cpp +++ b/src/blackcore/context_audio_impl.cpp @@ -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); diff --git a/src/blackcore/context_audio_impl.h b/src/blackcore/context_audio_impl.h index 90085eb8d..749c604c6 100644 --- a/src/blackcore/context_audio_impl.h +++ b/src/blackcore/context_audio_impl.h @@ -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 @@ -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 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 m_voice; //!< underlying voice lib std::unique_ptr m_audioMixer; int m_outVolumeBeforeMute = 90; @@ -168,6 +167,9 @@ namespace BlackCore QList> m_unusedVoiceChannels; QHash> m_voiceChannelMapping; + + // settings + CSetting m_audioSettings { this }; }; } // namespace diff --git a/src/blackcore/context_audio_proxy.cpp b/src/blackcore/context_audio_proxy.cpp index 57d92a7ba..53813322e 100644 --- a/src/blackcore/context_audio_proxy.cpp +++ b/src/blackcore/context_audio_proxy.cpp @@ -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); } diff --git a/src/blackcore/context_audio_proxy.h b/src/blackcore/context_audio_proxy.h index 2eda66a3d..a2045e5fc 100644 --- a/src/blackcore/context_audio_proxy.h +++ b/src/blackcore/context_audio_proxy.h @@ -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; diff --git a/src/blackcore/context_network_impl.cpp b/src/blackcore/context_network_impl.cpp index 0e034a816..8f1789cb8 100644 --- a/src/blackcore/context_network_impl.cpp +++ b/src/blackcore/context_network_impl.cpp @@ -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()); diff --git a/src/blackcore/context_network_impl.h b/src/blackcore/context_network_impl.h index fd4af5050..3b253461e 100644 --- a/src/blackcore/context_network_impl.h +++ b/src/blackcore/context_network_impl.h @@ -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" diff --git a/src/blackcore/context_ownaircraft_impl.cpp b/src/blackcore/context_ownaircraft_impl.cpp index 9e5a6cb5e..8401d84c4 100644 --- a/src/blackcore/context_ownaircraft_impl.cpp +++ b/src/blackcore/context_ownaircraft_impl.cpp @@ -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(); diff --git a/src/blackcore/context_ownaircraft_impl.h b/src/blackcore/context_ownaircraft_impl.h index 97de26f56..4847784e4 100644 --- a/src/blackcore/context_ownaircraft_impl.h +++ b/src/blackcore/context_ownaircraft_impl.h @@ -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" diff --git a/src/blackcore/context_runtime.cpp b/src/blackcore/context_runtime.cpp index fdb87db57..d53d36601 100644 --- a/src/blackcore/context_runtime.cpp +++ b/src/blackcore/context_runtime.cpp @@ -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(&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); } diff --git a/src/blackcore/context_runtime.h b/src/blackcore/context_runtime.h index bb2c28f67..b42f91006 100644 --- a/src/blackcore/context_runtime.h +++ b/src/blackcore/context_runtime.h @@ -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 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) diff --git a/src/blackcore/context_settings.cpp b/src/blackcore/context_settings.cpp deleted file mode 100644 index 8d8584e36..000000000 --- a/src/blackcore/context_settings.cpp +++ /dev/null @@ -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; - } - } - -} diff --git a/src/blackcore/context_settings.h b/src/blackcore/context_settings.h deleted file mode 100644 index 98e2f344e..000000000 --- a/src/blackcore/context_settings.h +++ /dev/null @@ -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 - -//! \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 diff --git a/src/blackcore/context_settings_impl.cpp b/src/blackcore/context_settings_impl.cpp deleted file mode 100644 index 7baa531b3..000000000 --- a/src/blackcore/context_settings_impl.cpp +++ /dev/null @@ -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 -#include - -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(SettingsAudio)); - } - } - else - { - msgs.push_back( - CStatusMessage({CLogCategory::validation()}, CStatusMessage::SeverityError, QString("Wrong path: %1").arg(this->getSettingsFileName())) - ); - } - return msgs; - } - -} // namespace diff --git a/src/blackcore/context_settings_impl.h b/src/blackcore/context_settings_impl.h deleted file mode 100644 index 05ebf3807..000000000 --- a/src/blackcore/context_settings_impl.h +++ /dev/null @@ -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 diff --git a/src/blackcore/context_settings_proxy.cpp b/src/blackcore/context_settings_proxy.cpp deleted file mode 100644 index 41180dc87..000000000 --- a/src/blackcore/context_settings_proxy.cpp +++ /dev/null @@ -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 -#include -#include - -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(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(QLatin1Literal("value"), path, command, value); - } - - /* - * Write settings - */ - BlackMisc::CStatusMessage CContextSettingsProxy::write() const - { - return this->m_dBusInterface->callDBusRet(QLatin1Literal("write")); - } - - /* - * Read settings - */ - CStatusMessage CContextSettingsProxy::read() - { - return this->m_dBusInterface->callDBusRet(QLatin1Literal("read")); - } - - /* - * Reset settings - */ - CStatusMessage CContextSettingsProxy::reset(bool write) - { - return this->m_dBusInterface->callDBusRet(QLatin1Literal("reset"), write); - } - - /* - * File name - */ - QString CContextSettingsProxy::getSettingsFileName() const - { - return this->m_dBusInterface->callDBusRet(QLatin1Literal("getSettingsFileName")); - } - - /* - * As JSON string - */ - QString CContextSettingsProxy::getSettingsAsJsonString() const - { - return this->m_dBusInterface->callDBusRet(QLatin1Literal("getSettingsAsJsonString")); - } - -} // namespace diff --git a/src/blackcore/context_settings_proxy.h b/src/blackcore/context_settings_proxy.h deleted file mode 100644 index f82343df1..000000000 --- a/src/blackcore/context_settings_proxy.h +++ /dev/null @@ -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 diff --git a/src/blackcore/context_simulator.h b/src/blackcore/context_simulator.h index 5d812577c..2f08b45dd 100644 --- a/src/blackcore/context_simulator.h +++ b/src/blackcore/context_simulator.h @@ -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; diff --git a/src/blackcore/context_simulator_impl.cpp b/src/blackcore/context_simulator_impl.cpp index 18cb360dd..aff4e817b 100644 --- a/src/blackcore/context_simulator_impl.cpp +++ b/src/blackcore/context_simulator_impl.cpp @@ -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 #include 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(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(); } diff --git a/src/blackcore/context_simulator_impl.h b/src/blackcore/context_simulator_impl.h index 6b2f905b7..60eafae2e 100644 --- a/src/blackcore/context_simulator_impl.h +++ b/src/blackcore/context_simulator_impl.h @@ -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; diff --git a/src/blackcore/context_simulator_proxy.cpp b/src/blackcore/context_simulator_proxy.cpp index 8fb8aaa38..dc41c86c9 100644 --- a/src/blackcore/context_simulator_proxy.cpp +++ b/src/blackcore/context_simulator_proxy.cpp @@ -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(QLatin1Literal("iconForModel"), modelString); diff --git a/src/blackcore/context_simulator_proxy.h b/src/blackcore/context_simulator_proxy.h index 3e11e192f..f4f569af8 100644 --- a/src/blackcore/context_simulator_proxy.h +++ b/src/blackcore/context_simulator_proxy.h @@ -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; diff --git a/src/blackcore/settings/audio.h b/src/blackcore/settings/audio.h new file mode 100644 index 000000000..304dc2ff7 --- /dev/null +++ b/src/blackcore/settings/audio.h @@ -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 + { + //! \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 diff --git a/src/blackgui/components/audiosetupcomponent.cpp b/src/blackgui/components/audiosetupcomponent.cpp index 7de929951..15a925758 100644 --- a/src/blackgui/components/audiosetupcomponent.cpp +++ b/src/blackgui/components/audiosetupcomponent.cpp @@ -9,9 +9,7 @@ #include "audiosetupcomponent.h" #include "ui_audiosetupcomponent.h" -#include "blackcore/context_settings.h" #include "blackcore/context_audio.h" -#include "blackmisc/setaudio.h" #include "blackmisc/logmessage.h" using namespace BlackCore; @@ -19,8 +17,8 @@ using namespace BlackMisc; using namespace BlackGui; using namespace BlackMisc::Aviation; using namespace BlackMisc::Audio; +using namespace BlackMisc::Audio::Settings; using namespace BlackMisc::PhysicalQuantities; -using namespace BlackMisc::Settings; namespace BlackGui { @@ -44,9 +42,6 @@ namespace BlackGui void CAudioSetupComponent::runtimeHasBeenSet() { - Q_ASSERT_X(this->getIContextSettings(), Q_FUNC_INFO, "missing settings"); - this->connect(this->getIContextSettings(), &IContextSettings::changedSettings, this, &CAudioSetupComponent::ps_changedSettings); - // based on audio context Q_ASSERT_X(this->getIContextAudio(), Q_FUNC_INFO, "missing audio"); if (this->getIContextAudio()) @@ -67,26 +62,16 @@ namespace BlackGui this->connect(this->getIContextAudio(), &IContextAudio::changedAudioDevices, this, &CAudioSetupComponent::ps_onAudioDevicesChanged); this->connect(this->getIContextAudio(), &IContextAudio::changedSelectedAudioDevices, this, &CAudioSetupComponent::ps_onCurrentAudioDevicesChanged); } - this->reloadSettings(); + this->ps_reloadSettings(); this->ui->tb_ExpandNotificationSounds->setChecked(false); // collapse } - void CAudioSetupComponent::ps_changedSettings(uint typeValue) + void CAudioSetupComponent::ps_reloadSettings() { - IContextSettings::SettingsType type = static_cast(typeValue); - this->reloadSettings(); - Q_UNUSED(type); - } - - void CAudioSetupComponent::reloadSettings() - { - // local copy - CSettingsAudio as = this->getIContextSettings()->getAudioSettings(); - - // fake setting for sound notifications + CSettingsAudio as(m_audioSettings.get()); this->ui->cb_SetupAudioPlayNotificationSounds->setChecked(true); - this->ui->cb_SetupAudioNotificationTextMessage->setChecked(as.getNotificationFlag(BlackSound::CNotificationSounds::NotificationTextMessagePrivate)); - this->ui->cb_SetupAudioNotificationVoiceRoom->setChecked(as.getNotificationFlag(BlackSound::CNotificationSounds::NotificationVoiceRoomJoined)); + this->ui->cb_SetupAudioNotificationTextMessage->setChecked(as.getNotificationFlag(CNotificationSounds::NotificationTextMessagePrivate)); + this->ui->cb_SetupAudioNotificationVoiceRoom->setChecked(as.getNotificationFlag(CNotificationSounds::NotificationVoiceRoomJoined)); } void CAudioSetupComponent::ps_onToggleNotificationSoundsVisibility(bool checked) diff --git a/src/blackgui/components/audiosetupcomponent.h b/src/blackgui/components/audiosetupcomponent.h index 1964978a9..3dab9df47 100644 --- a/src/blackgui/components/audiosetupcomponent.h +++ b/src/blackgui/components/audiosetupcomponent.h @@ -13,7 +13,8 @@ #define BLACKGUI_AUDIOSETUPCOMPONENT_H #include "blackgui/blackguiexport.h" -#include "enableforruntime.h" +#include "blackgui/components/enableforruntime.h" +#include "blackcore/settings/audio.h" #include "blackmisc/audio/audiodeviceinfolist.h" #include #include @@ -41,18 +42,13 @@ namespace BlackGui //! Play notification sounds (at all) bool playNotificationSounds() const; - public slots: - //! Reload settings - void reloadSettings(); - protected: //! \copydoc CRuntimeBasedComponent::runtimeHasBeenSet virtual void runtimeHasBeenSet() override; private slots: - - //! Settings have been changed - void ps_changedSettings(uint typeValue); + //! Reload settings + void ps_reloadSettings(); /*! * \brief Audio device selected @@ -77,6 +73,8 @@ namespace BlackGui void initAudioDeviceLists(); QScopedPointer ui; + BlackCore::CSetting m_audioSettings { this, &CAudioSetupComponent::ps_reloadSettings }; + }; } // namespace } // namespace diff --git a/src/blackgui/components/enableforruntime.cpp b/src/blackgui/components/enableforruntime.cpp index 56574f020..820604a74 100644 --- a/src/blackgui/components/enableforruntime.cpp +++ b/src/blackgui/components/enableforruntime.cpp @@ -11,6 +11,8 @@ #include "blackcore/context_all_interfaces.h" #include +using namespace BlackMisc::Audio; + namespace BlackGui { namespace Components @@ -91,18 +93,6 @@ namespace BlackGui return this->m_runtime->getIContextOwnAircraft(); } - BlackCore::IContextSettings *CEnableForRuntime::getIContextSettings() - { - if (!this->m_runtime) return nullptr; - return this->m_runtime->getIContextSettings(); - } - - const BlackCore::IContextSettings *CEnableForRuntime::getIContextSettings() const - { - if (!this->m_runtime) return nullptr; - return this->m_runtime->getIContextSettings(); - } - const BlackCore::IContextSimulator *CEnableForRuntime::getIContextSimulator() const { if (!this->m_runtime) return nullptr; @@ -115,7 +105,7 @@ namespace BlackGui return this->m_runtime->getIContextSimulator(); } - void CEnableForRuntime::playNotifcationSound(BlackSound::CNotificationSounds::Notification notification) const + void CEnableForRuntime::playNotifcationSound(CNotificationSounds::Notification notification) const { if (!this->getIContextAudio()) return; this->getIContextAudio()->playNotification(notification, true); diff --git a/src/blackgui/components/enableforruntime.h b/src/blackgui/components/enableforruntime.h index 446a3f4a7..e12041348 100644 --- a/src/blackgui/components/enableforruntime.h +++ b/src/blackgui/components/enableforruntime.h @@ -14,7 +14,7 @@ #include "blackgui/blackguiexport.h" #include "blackcore/context_runtime.h" -#include "blackmisc/notificationsounds.h" +#include "blackmisc/audio/notificationsounds.h" #include namespace BlackCore @@ -95,12 +95,6 @@ namespace BlackGui //! Context for own aircraft BlackCore::IContextOwnAircraft *getIContextOwnAircraft(); - //! Context for settings - BlackCore::IContextSettings *getIContextSettings(); - - //! Context for settings - const BlackCore::IContextSettings *getIContextSettings() const; - //! Context for simulator const BlackCore::IContextSimulator *getIContextSimulator() const; @@ -118,7 +112,7 @@ namespace BlackGui bool hasRemoteApplicationContext() const { return this->m_runtime->hasRemoteApplicationContext(); } //! Play a given notification sound - void playNotifcationSound(BlackSound::CNotificationSounds::Notification notification) const; + void playNotifcationSound(BlackMisc::Audio::CNotificationSounds::Notification notification) const; private: BlackCore::CRuntime *m_runtime; diff --git a/src/blackgui/components/logincomponent.cpp b/src/blackgui/components/logincomponent.cpp index 823b627a5..6c671755b 100644 --- a/src/blackgui/components/logincomponent.cpp +++ b/src/blackgui/components/logincomponent.cpp @@ -10,7 +10,6 @@ #include "logincomponent.h" #include "ui_logincomponent.h" #include "blackcore/context_network.h" -#include "blackcore/context_settings.h" #include "blackcore/context_ownaircraft.h" #include "blackcore/context_audio.h" #include "blackcore/context_simulator.h" @@ -134,15 +133,13 @@ namespace BlackGui void CLoginComponent::runtimeHasBeenSet() { Q_ASSERT(getIContextNetwork()); - Q_ASSERT(getIContextSettings()); connect(getIContextNetwork(), &IContextNetwork::webServiceDataRead, this, &CLoginComponent::ps_onWebServiceDataRead); - connect(getIContextSettings(), &IContextSettings::changedSettings, this, &CLoginComponent::ps_onSettingsChanged); // inital setup, if data already available ps_validateAircraftValues(); ps_validateVatsimValues(); ps_onWebServiceDataRead(CEntityFlags::VatsimDataFile, CEntityFlags::ReadFinished, -1); - CServerList otherServers = this->m_trafficNetworkServers.get(); + CServerList otherServers(this->m_trafficNetworkServers.get()); // add a testserver when no servers can be loaded if (otherServers.isEmpty() && CProject::isRunningInBetaOrDeveloperEnvironment()) @@ -454,10 +451,9 @@ namespace BlackGui return validVatsimId && validHomeAirport && validVatsimPassword && validRealUserName; } - void CLoginComponent::ps_onSettingsChanged(uint settingsType) + void CLoginComponent::ps_reloadSettings() { - if (settingsType != static_cast(IContextSettings::SettingsNetwork)) { return; } - CServerList otherServers = this->m_trafficNetworkServers.get(); + CServerList otherServers(this->m_trafficNetworkServers.get()); this->ui->cbp_OtherServers->setServers(otherServers); } diff --git a/src/blackgui/components/logincomponent.h b/src/blackgui/components/logincomponent.h index 22765eed7..b5019f325 100644 --- a/src/blackgui/components/logincomponent.h +++ b/src/blackgui/components/logincomponent.h @@ -76,7 +76,7 @@ namespace BlackGui bool ps_validateVatsimValues(); //! Settings have been changed - void ps_onSettingsChanged(uint settingsType); + void ps_reloadSettings(); //! Logoff countdown void ps_logoffCountdown(); @@ -85,7 +85,6 @@ namespace BlackGui void ps_reverseLookupModel(); private: - //! GUI aircraft values, formatted struct CGuiAircraftValues { @@ -148,7 +147,7 @@ namespace BlackGui QScopedPointer ui; const int LogoffIntervalSeconds = 10; QTimer *m_logoffCountdownTimer { nullptr }; - BlackCore::CSetting m_trafficNetworkServers { this }; + BlackCore::CSetting m_trafficNetworkServers { this, &CLoginComponent::ps_reloadSettings }; BlackCore::CData m_setup {this}; //!< setup cache }; diff --git a/src/blackgui/components/settingscomponent.cpp b/src/blackgui/components/settingscomponent.cpp index d525ec775..7613231ad 100644 --- a/src/blackgui/components/settingscomponent.cpp +++ b/src/blackgui/components/settingscomponent.cpp @@ -13,11 +13,9 @@ #include "blackgui/stylesheetutility.h" #include "blackcore/dbus_server.h" #include "blackcore/context_network.h" -#include "blackcore/context_settings.h" #include "blackcore/context_audio.h" #include "blackmisc/input/keyboardkeylist.h" #include "blackmisc/logmessage.h" -#include "blackmisc/settingsblackmiscclasses.h" #include using namespace BlackCore; @@ -28,7 +26,6 @@ using namespace BlackMisc::Aviation; using namespace BlackMisc::Audio; using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::Geo; -using namespace BlackMisc::Settings; using namespace BlackMisc::Input; namespace BlackGui @@ -71,17 +68,6 @@ namespace BlackGui return this->ui->hs_SettingsGuiUserRefreshTime->value(); } - /* - * Reload settings - */ - void CSettingsComponent::reloadSettings() - { - // reload components - //! \todo Settings are loaded twice, this here is for init but each component also consumes the signal changed slot - this->ui->comp_AudioSetup->reloadSettings(); - this->ui->comp_SettingsServersComponent->reloadSettings(); - } - /* * Set tab */ @@ -95,9 +81,6 @@ namespace BlackGui */ void CSettingsComponent::runtimeHasBeenSet() { - Q_ASSERT_X(this->getIContextSettings(), Q_FUNC_INFO, "Missing settings"); - this->connect(this->getIContextSettings(), &IContextSettings::changedSettings, this, &CSettingsComponent::ps_changedSettings); - // Opacity, intervals this->connect(this->ui->hs_SettingsGuiOpacity, &QSlider::valueChanged, this, &CSettingsComponent::changedWindowsOpacity); this->connect(this->ui->hs_SettingsGuiAircraftRefreshTime, &QSlider::valueChanged, this, &CSettingsComponent::changedAircraftUpdateInterval); @@ -121,16 +104,6 @@ namespace BlackGui Q_UNUSED(connected); } - /* - * Settings did change - */ - void CSettingsComponent::ps_changedSettings(uint typeValue) - { - IContextSettings::SettingsType type = static_cast(typeValue); - this->reloadSettings(); - Q_UNUSED(type); - } - /* * Font has been changed */ diff --git a/src/blackgui/components/settingscomponent.h b/src/blackgui/components/settingscomponent.h index 4b12bd4f0..67db00fb0 100644 --- a/src/blackgui/components/settingscomponent.h +++ b/src/blackgui/components/settingscomponent.h @@ -26,7 +26,6 @@ namespace BlackGui { namespace Components { - //! Settings component class BLACKGUI_EXPORT CSettingsComponent : public QTabWidget, @@ -82,9 +81,6 @@ namespace BlackGui void changedUsersUpdateInterval(int seconds); public slots: - //! Reload settings - void reloadSettings(); - //! Set the tab void setSettingsTab(SettingTab tab); @@ -93,10 +89,6 @@ namespace BlackGui virtual void runtimeHasBeenSet() override; private slots: - - //! Settings have been changed - void ps_changedSettings(uint typeValue); - //! Font has been changed void ps_fontChanged(); diff --git a/src/blackgui/components/settingsnetworkserverscomponent.cpp b/src/blackgui/components/settingsnetworkserverscomponent.cpp index 3769ed5d3..7044c507e 100644 --- a/src/blackgui/components/settingsnetworkserverscomponent.cpp +++ b/src/blackgui/components/settingsnetworkserverscomponent.cpp @@ -10,11 +10,9 @@ #include "settingsnetworkserverscomponent.h" #include "ui_settingsnetworkserverscomponent.h" #include "blackcore/context_network.h" -#include "blackcore/context_settings.h" #include "blackcore/setupreader.h" #include "blackmisc/logmessage.h" #include "blackmisc/project.h" -#include "blackmisc/settingsblackmiscclasses.h" #include using namespace BlackCore; @@ -24,7 +22,6 @@ using namespace BlackMisc; using namespace BlackMisc::Network; using namespace BlackMisc::Aviation; using namespace BlackMisc::Audio; -using namespace BlackMisc::Settings; namespace BlackGui { @@ -46,7 +43,7 @@ namespace BlackGui CSettingsNetworkServersComponent::~CSettingsNetworkServersComponent() { } - void CSettingsNetworkServersComponent::reloadSettings() + void CSettingsNetworkServersComponent::ps_reloadSettings() { CServerList serverList(m_trafficNetworkServers.get()); diff --git a/src/blackgui/components/settingsnetworkserverscomponent.h b/src/blackgui/components/settingsnetworkserverscomponent.h index 1b0bc0954..b752224f0 100644 --- a/src/blackgui/components/settingsnetworkserverscomponent.h +++ b/src/blackgui/components/settingsnetworkserverscomponent.h @@ -39,11 +39,10 @@ namespace BlackGui //! Destructor ~CSettingsNetworkServersComponent(); - public slots: - //! Reload settings - void reloadSettings(); - private slots: + //! Reload settings + void ps_reloadSettings(); + //! Network server selected void ps_networkServerSelected(const QModelIndex &index); @@ -52,7 +51,7 @@ namespace BlackGui private: QScopedPointer ui; - BlackCore::CSetting m_trafficNetworkServers { this }; + BlackCore::CSetting m_trafficNetworkServers { this, &CSettingsNetworkServersComponent::ps_reloadSettings }; BlackCore::CData m_setup {this}; //!< setup cache }; } // ns diff --git a/src/blackgui/components/settingssimulatorcomponent.cpp b/src/blackgui/components/settingssimulatorcomponent.cpp index 5789bfb24..8e87199d2 100644 --- a/src/blackgui/components/settingssimulatorcomponent.cpp +++ b/src/blackgui/components/settingssimulatorcomponent.cpp @@ -7,11 +7,9 @@ #include "blackmisc/simulation/simulatedaircraftlist.h" #include "blackmisc/logmessage.h" #include "blackmisc/variant.h" - #include using namespace BlackMisc; -using namespace BlackMisc::Settings; using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::Simulation; using namespace BlackMisc::Aviation; diff --git a/src/blackgui/components/simulatorcomponent.cpp b/src/blackgui/components/simulatorcomponent.cpp index 222166cc0..8fe0f48ac 100644 --- a/src/blackgui/components/simulatorcomponent.cpp +++ b/src/blackgui/components/simulatorcomponent.cpp @@ -9,7 +9,6 @@ #include "simulatorcomponent.h" #include "ui_simulatorcomponent.h" -#include "blackcore/context_settings.h" #include "blackcore/context_simulator.h" #include "blackcore/context_ownaircraft.h" #include "blackcore/simulator.h" diff --git a/src/blackgui/components/textmessagecomponent.cpp b/src/blackgui/components/textmessagecomponent.cpp index 6ddf3e035..1ba1e7f6f 100644 --- a/src/blackgui/components/textmessagecomponent.cpp +++ b/src/blackgui/components/textmessagecomponent.cpp @@ -11,7 +11,7 @@ #include "ui_textmessagecomponent.h" #include "blackcore/context_audio.h" #include "blackmisc/network/user.h" -#include "blackmisc/notificationsounds.h" +#include "blackmisc/audio/notificationsounds.h" #include "blackmisc/logmessage.h" #include "blackmisc/simplecommandparser.h" #include "blackmisc/simulation/simulatedaircraftlist.h" @@ -24,9 +24,9 @@ using namespace BlackMisc; using namespace BlackGui; using namespace BlackGui::Views; using namespace BlackMisc::Network; +using namespace BlackMisc::Audio; using namespace BlackMisc::Aviation; using namespace BlackMisc::PhysicalQuantities; -using namespace BlackMisc::Settings; using namespace BlackMisc::Simulation; namespace BlackGui @@ -272,7 +272,7 @@ namespace BlackGui // sound if (this->getIContextAudio()) { - this->getIContextAudio()->playNotification(BlackSound::CNotificationSounds::NotificationTextMessagePrivate, true); + this->getIContextAudio()->playNotification(CNotificationSounds::NotificationTextMessagePrivate, true); } } diff --git a/src/blackgui/components/voiceroomscomponent.cpp b/src/blackgui/components/voiceroomscomponent.cpp index 8bbe0e209..1d8fc7b1b 100644 --- a/src/blackgui/components/voiceroomscomponent.cpp +++ b/src/blackgui/components/voiceroomscomponent.cpp @@ -11,10 +11,9 @@ #include "ui_voiceroomscomponent.h" #include "blackcore/context_audio.h" #include "blackcore/context_ownaircraft.h" -#include "blackmisc/notificationsounds.h" +#include "blackmisc/audio/notificationsounds.h" using namespace BlackCore; -using namespace BlackSound; using namespace BlackMisc::Audio; namespace BlackGui diff --git a/src/blackmisc/audio/audio.h b/src/blackmisc/audio/audio.h index d54e087d8..037cbcbd5 100644 --- a/src/blackmisc/audio/audio.h +++ b/src/blackmisc/audio/audio.h @@ -21,5 +21,6 @@ #include "blackmisc/audio/audiodeviceinfolist.h" #include "blackmisc/audio/voiceroom.h" #include "blackmisc/audio/voiceroomlist.h" +#include "blackmisc/audio/settings/settingsaudio.h" #endif // guard diff --git a/src/blackmisc/audio/notificationsounds.h b/src/blackmisc/audio/notificationsounds.h new file mode 100644 index 000000000..bb98280c1 --- /dev/null +++ b/src/blackmisc/audio/notificationsounds.h @@ -0,0 +1,54 @@ +/* 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 BLACKMISC_NOTIFICATIONSOUNDS_H +#define BLACKMISC_NOTIFICATIONSOUNDS_H + +#include + +namespace BlackMisc +{ + namespace Audio + { + /*! + * Simplified enums to play sounds. + * \remarks Currently located in project BlackMisc (i.e. outside project BlackSound) + * as this allows to trigger sounds without using Multimedia libraries. + */ + struct CNotificationSounds + { + //! How to play? + enum PlayMode + { + Single, + SingleWithAutomaticDeletion, + EndlessLoop + }; + + //! Play notification + enum Notification + { + NotificationError = 0, + NotificationLogin, + NotificationLogoff, + NotificationTextMessagePrivate, + NotificationVoiceRoomJoined, + NotificationVoiceRoomLeft, + NotificationsLoadSounds //!< end marker and force loading of sounds, keep as last element + }; + }; + } // ns +} // ns + +Q_DECLARE_METATYPE(BlackMisc::Audio::CNotificationSounds::PlayMode) +Q_DECLARE_METATYPE(BlackMisc::Audio::CNotificationSounds::Notification) + +#endif // guard diff --git a/src/blackmisc/audio/settings/settingsaudio.cpp b/src/blackmisc/audio/settings/settingsaudio.cpp new file mode 100644 index 000000000..c41634301 --- /dev/null +++ b/src/blackmisc/audio/settings/settingsaudio.cpp @@ -0,0 +1,60 @@ +/* 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. + */ + +#include "settingsaudio.h" +#include "logmessage.h" + +using namespace BlackMisc::Audio; + +namespace BlackMisc +{ + namespace Audio + { + namespace Settings + { + CSettingsAudio::CSettingsAudio() + { + this->initDefaultValues(); + } + + bool CSettingsAudio::getNotificationFlag(CNotificationSounds::Notification notification) const + { + const int i = static_cast(notification); + if (i >= m_notificationFlags.length()) return true; // default + QChar f = m_notificationFlags.at(i); + return '1' == f; + } + + QString CSettingsAudio::convertToQString(bool i18n) const + { + Q_UNUSED(i18n); + QString s("Notification flags:"); + s.append(" ").append(m_notificationFlags); + return s; + } + + void CSettingsAudio::initDefaultValues() + { + this->initNotificationFlags(); + } + + void CSettingsAudio::initNotificationFlags() + { + // if we add flags in the future, we automatically extend ... + static const int l = 1 + static_cast(CNotificationSounds::Notification::NotificationsLoadSounds); + if (this->m_notificationFlags.length() < l) + { + int cl = m_notificationFlags.length(); + this->m_notificationFlags.append(QString(l - cl, '1')); + } + } + + } // namespace + } // namespace +} // namespace diff --git a/src/blackmisc/audio/settings/settingsaudio.h b/src/blackmisc/audio/settings/settingsaudio.h new file mode 100644 index 000000000..674c31aa4 --- /dev/null +++ b/src/blackmisc/audio/settings/settingsaudio.h @@ -0,0 +1,62 @@ +/* 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 BLACKMISC_AUDIO_SETTINGS_AUDIO_H +#define BLACKMISC_AUDIO_SETTINGS_AUDIO_H + +#include "blackmisc/blackmiscexport.h" +#include "blackmisc/valueobject.h" +#include "blackmisc/statusmessagelist.h" +#include "blackmisc/audio/notificationsounds.h" +#include + +namespace BlackMisc +{ + namespace Audio + { + namespace Settings + { + //! Value object encapsulating information of audio related settings. + class BLACKMISC_EXPORT CSettingsAudio : public CValueObject + { + public: + //! Default constructor. + CSettingsAudio(); + + //! Notification flag (play notification?) + bool getNotificationFlag(BlackMisc::Audio::CNotificationSounds::Notification notification) const; + + //! Notification flag (play notification?) + void setNotificationFlag(BlackMisc::Audio::CNotificationSounds::Notification notification, bool value); + + //! \copydoc BlackCore::IContextSettings::value + BlackMisc::CStatusMessage value(const QString &path, const QString &command, const BlackMisc::CVariant &value, bool &changedFlag); + + //! Init with meaningful default values + void initDefaultValues(); + + //! \copydoc CValueObject::convertToQString + QString convertToQString(bool i18n = false) const; + + private: + BLACK_ENABLE_TUPLE_CONVERSION(CSettingsAudio) + QString m_notificationFlags; //!< play notification for notification x, a little trick to use a string here (streamable, hashable, ..) + void initNotificationFlags(); //!< init flags + }; + + } // namespace + } // namespace +} // namespace + +Q_DECLARE_METATYPE(BlackMisc::Audio::Settings::CSettingsAudio) +BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Audio::Settings::CSettingsAudio, (o.m_notificationFlags)) + +#endif // guard diff --git a/src/blackmisc/blackmisc.pro b/src/blackmisc/blackmisc.pro index 901fb9e2a..b685ee6de 100644 --- a/src/blackmisc/blackmisc.pro +++ b/src/blackmisc/blackmisc.pro @@ -34,6 +34,7 @@ HEADERS += *.h \ $$PWD/geo/*.h \ $$PWD/input/*.h \ $$PWD/audio/*.h \ + $$PWD/audio/settings/*.h \ $$PWD/simulation/*.h \ $$PWD/simulation/fscommon/*.h \ $$PWD/simulation/fsx/*.h \ @@ -48,6 +49,7 @@ SOURCES += *.cpp \ $$PWD/input/*.cpp \ $$PWD/geo/*.cpp \ $$PWD/audio/*.cpp \ + $$PWD/audio/settings/*.cpp \ $$PWD/simulation/*.cpp \ $$PWD/simulation/fscommon/*.cpp \ $$PWD/simulation/fsx/*.cpp \ diff --git a/src/blackmisc/blackmiscfreefunctions.cpp b/src/blackmisc/blackmiscfreefunctions.cpp index bbcf05e8a..93abd09b3 100644 --- a/src/blackmisc/blackmiscfreefunctions.cpp +++ b/src/blackmisc/blackmiscfreefunctions.cpp @@ -12,7 +12,6 @@ #include "geo/geo.h" #include "audio/audio.h" #include "input/input.h" -#include "settingsblackmiscclasses.h" #include "propertyindexlist.h" #include "propertyindexvariantmap.h" #include "namevariantpairlist.h" @@ -43,19 +42,15 @@ void BlackMisc::Geo::registerMetadata() CLongitude::registerMetadata(); } -void BlackMisc::Settings::registerMetadata() -{ - CSettingsAudio::registerMetadata(); -} - void BlackMisc::Audio::registerMetadata() { CAudioDeviceInfo::registerMetadata(); CAudioDeviceInfoList::registerMetadata(); CVoiceRoom::registerMetadata(); CVoiceRoomList::registerMetadata(); - qDBusRegisterMetaType(); - qDBusRegisterMetaType(); + Settings::CSettingsAudio::registerMetadata(); + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); } void BlackMisc::Input::registerMetadata() @@ -101,7 +96,6 @@ void BlackMisc::registerMetadata() Math::registerMetadata(); Geo::registerMetadata(); Network::registerMetadata(); - Settings::registerMetadata(); Simulation::registerMetadata(); Audio::registerMetadata(); Weather::registerMetadata(); diff --git a/src/blackmisc/blackmiscfreefunctions.h b/src/blackmisc/blackmiscfreefunctions.h index db0480183..333d6a03c 100644 --- a/src/blackmisc/blackmiscfreefunctions.h +++ b/src/blackmisc/blackmiscfreefunctions.h @@ -23,7 +23,6 @@ #include #include #include - #include /*! @@ -75,12 +74,6 @@ namespace BlackMisc BLACKMISC_EXPORT void registerMetadata(); } - namespace Settings - { - //! Register metadata for settings - BLACKMISC_EXPORT void registerMetadata(); - } - namespace Audio { //! Register metadata for audio / voice diff --git a/src/blackmisc/notificationsounds.h b/src/blackmisc/notificationsounds.h deleted file mode 100644 index 0bb2f942b..000000000 --- a/src/blackmisc/notificationsounds.h +++ /dev/null @@ -1,52 +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 BLACKMISC_NOTIFICATIONSOUNDS_H -#define BLACKMISC_NOTIFICATIONSOUNDS_H - -#include - -namespace BlackSound -{ - - /*! - * Simplified enums to play sounds. - * \remarks Currently located in project BlackMisc (i.e. outside project BlackSound) - * as this allows to trigger sounds without using Multimedia libraries. - */ - struct CNotificationSounds - { - //! How to play? - enum PlayMode - { - Single, - SingleWithAutomaticDeletion, - EndlessLoop - }; - - //! Play notification - enum Notification - { - NotificationError = 0, - NotificationLogin, - NotificationLogoff, - NotificationTextMessagePrivate, - NotificationVoiceRoomJoined, - NotificationVoiceRoomLeft, - NotificationsLoadSounds //!< end marker and force loading of sounds, keep as last element - }; - }; -} // ns - -Q_DECLARE_METATYPE(BlackSound::CNotificationSounds::PlayMode) -Q_DECLARE_METATYPE(BlackSound::CNotificationSounds::Notification) - -#endif // guard diff --git a/src/blackmisc/setaudio.cpp b/src/blackmisc/setaudio.cpp deleted file mode 100644 index 8612568e4..000000000 --- a/src/blackmisc/setaudio.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include "setaudio.h" -#include "logmessage.h" -using namespace BlackSound; - -namespace BlackMisc -{ - namespace Settings - { - /* - * Constructor - */ - CSettingsAudio::CSettingsAudio() - { - this->initDefaultValues(); - } - - /* - * Flag - */ - bool CSettingsAudio::getNotificationFlag(CNotificationSounds::Notification notification) const - { - const int i = static_cast(notification); - if (i >= m_notificationFlags.length()) return true; // default - QChar f = m_notificationFlags.at(i); - return '1' == f; - } - - /* - * Convert to string - */ - QString CSettingsAudio::convertToQString(bool i18n) const - { - Q_UNUSED(i18n); - QString s("Notification flags:"); - s.append(" ").append(m_notificationFlags); - return s; - } - - /* - * Default values - */ - void CSettingsAudio::initDefaultValues() - { - this->initNotificationFlags(); - } - - /* - * Flags - */ - void CSettingsAudio::initNotificationFlags() - { - // if we add flags in the future, we automatically extend ... - static const int l = 1 + static_cast(CNotificationSounds::Notification::NotificationsLoadSounds); - if (this->m_notificationFlags.length() < l) - { - int cl = m_notificationFlags.length(); - this->m_notificationFlags.append(QString(l - cl, '1')); - } - } - - /* - * Value - */ - BlackMisc::CStatusMessage CSettingsAudio::value(const QString &path, const QString &command, const CVariant &value, bool &changedFlag) - { - // TODO: This needs to be refactored to a smarter way to delegate commands - changedFlag = false; - if (path == CSettingsAudio::ValueNotificationFlag()) - { - if (command == CSettingUtilities::CmdSetTrue() || command == CSettingUtilities::CmdSetFalse()) - { - CNotificationSounds::Notification index = static_cast(value.toInt()); - char value = (command == CSettingUtilities::CmdSetTrue()) ? '1' : '0' ; - this->initNotificationFlags(); - this->m_notificationFlags.replace(index, 1, value); - return {}; - } - } - return CLogMessage(CLogCategory::validation()).error("wrong path: %1") << path; - } - } // namespace -} // namespace diff --git a/src/blackmisc/setaudio.h b/src/blackmisc/setaudio.h deleted file mode 100644 index deaa5b308..000000000 --- a/src/blackmisc/setaudio.h +++ /dev/null @@ -1,67 +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 BLACKMISC_SETTINGS_AUDIO_H -#define BLACKMISC_SETTINGS_AUDIO_H - -#include "blackmiscexport.h" -#include "valueobject.h" -#include "statusmessagelist.h" -#include "settingutilities.h" -#include "notificationsounds.h" -#include - -namespace BlackMisc -{ - namespace Settings - { - //! Value object encapsulating information of audio related settings. - class BLACKMISC_EXPORT CSettingsAudio : public CValueObject - { - public: - //! Default constructor. - CSettingsAudio(); - - //! Path - static const QString &ValueNotificationFlag() - { - static const QString value("notificationflag"); - return value; - } - - //! Notification flag (play notification?) - bool getNotificationFlag(BlackSound::CNotificationSounds::Notification notification) const; - - //! Notification flag (play notification?) - void setNotificationFlag(BlackSound::CNotificationSounds::Notification notification, bool value); - - //! \copydoc BlackCore::IContextSettings::value - BlackMisc::CStatusMessage value(const QString &path, const QString &command, const BlackMisc::CVariant &value, bool &changedFlag); - - //! Init with meaningful default values - void initDefaultValues(); - - //! \copydoc CValueObject::convertToQString - QString convertToQString(bool i18n = false) const; - - private: - BLACK_ENABLE_TUPLE_CONVERSION(CSettingsAudio) - QString m_notificationFlags; //!< play notification for notification x, a little trick to use a string here (streamable, hashable, ..) - void initNotificationFlags(); //!< init flags - }; - - } // namespace -} // namespace - -Q_DECLARE_METATYPE(BlackMisc::Settings::CSettingsAudio) -BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Settings::CSettingsAudio, (o.m_notificationFlags)) - -#endif // guard diff --git a/src/blackmisc/setnetwork.h b/src/blackmisc/setnetwork.h deleted file mode 100644 index 3a51208b7..000000000 --- a/src/blackmisc/setnetwork.h +++ /dev/null @@ -1,113 +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 BLACKMISC_SETTINGS_NETWORK_H -#define BLACKMISC_SETTINGS_NETWORK_H - -#include "blackmiscexport.h" -#include "network/serverlist.h" -#include "valueobject.h" -#include "statusmessagelist.h" -#include "settingutilities.h" -#include - -namespace BlackMisc -{ - class CVariant; - - namespace Settings - { - //! Value object encapsulating information of network related settings. - //! \remarks Not only traffic network settings, but also URLs, DBus address, ... - class BLACKMISC_EXPORT CSettingsNetwork : public CValueObject - { - public: - //! Default constructor. - CSettingsNetwork(); - - //! Destructor. - virtual ~CSettingsNetwork() {} - - //! Current server - //! \deprecated shall not be used anymore - static const QString &CmdSetCurrentServer() - { - static const QString cmd("currenttrafficserver"); - return cmd; - } - - //! Path - static const QString &ValueTrafficServers() - { - static const QString value("trafficservers"); - return value; - } - - //! Path - static const QString &ValueBookingServiceUrl() - { - static const QString value("bookingserviceurl"); - return value; - } - - //! Path - static const QString &ValueDBusServerAddress() - { - static const QString value("dbuserveraddress"); - return value; - } - - //! Denotes a session DBus server - static const QString &sessionDBusServer() - { - static QString session("session"); - return session; - } - - //! Value object, traffic network server objects - BlackMisc::Network::CServerList getTrafficNetworkServers() const { return m_trafficNetworkServers; } - - //! Selected traffic network server - //! \deprecated Shall not be used anymore - BlackMisc::Network::CServer getCurrentTrafficNetworkServer() const { return m_trafficNetworkServerCurrent; } - - //! Address for DBus Server - QString getDBusServerAddress() const { return m_dbusServerAddress; } - - //! Selected traffic network server - bool setCurrentNetworkServer(const BlackMisc::Network::CServer ¤tServer); - - //! Traffic network server objects - void addTrafficNetworkServer(const BlackMisc::Network::CServer &server) { m_trafficNetworkServers.push_back(server); } - - //! \copydoc BlackCore::IContextSettings::value - BlackMisc::CStatusMessage value(const QString &path, const QString &command, const CVariant &value, bool &changedFlag); - - //! Init with meaningful default values - void initDefaultValues(); - - //! \copydoc CValueObject::convertToQString - QString convertToQString(bool i18n = false) const; - - private: - BLACK_ENABLE_TUPLE_CONVERSION(CSettingsNetwork) - BlackMisc::Network::CServerList m_trafficNetworkServers; - BlackMisc::Network::CServer m_trafficNetworkServerCurrent; - QString m_dbusServerAddress; - }; - - } // namespace -} // namespace - -Q_DECLARE_METATYPE(BlackMisc::Settings::CSettingsNetwork) -BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Settings::CSettingsNetwork, (o.m_trafficNetworkServers, o.m_trafficNetworkServerCurrent, o.m_dbusServerAddress)) - -#endif // guard diff --git a/src/blackmisc/settingsblackmiscclasses.h b/src/blackmisc/settingsblackmiscclasses.h deleted file mode 100644 index 336028ae8..000000000 --- a/src/blackmisc/settingsblackmiscclasses.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef BLACKMISC_SETTINGSBLACKMISCCLASSES_H -#define BLACKMISC_SETTINGSBLACKMISCCLASSES_H - -#include "blackmisc/setaudio.h" - -#endif // guard diff --git a/src/blackmisc/settingutilities.cpp b/src/blackmisc/settingutilities.cpp deleted file mode 100644 index d1149c9d8..000000000 --- a/src/blackmisc/settingutilities.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include "settingutilities.h" -#include -#include - -namespace BlackMisc -{ - namespace Settings - { - /* - * leading path - */ - QString CSettingUtilities::removeLeadingPath(const QString &path) - { - int sl = path.indexOf('/'); - Q_ASSERT(sl >= 0); - Q_ASSERT(path.length() > sl + 2); - return path.mid(sl + 1); - } - - /* - * Append paths - */ - QString CSettingUtilities::appendPaths(const QString &part1, const QString &part2, const QString &part3) - { - QString p(part1); - if (part2.isEmpty()) return p; - p.append('/').append(part2); - if (part3.isEmpty()) return p; - p.append('/').append(part3); - return p; - } - - /* - * Init settings dir, if required create it - */ - bool CSettingUtilities::initSettingsDirectory() - { - QDir dir(CSettingUtilities::getSettingsDirectory()); - if (dir.exists()) return true; - return dir.mkpath("."); - } - - /* - * Directory - */ - const QString &CSettingUtilities::getSettingsDirectory() - { - static QString dir = QStandardPaths::writableLocation(QStandardPaths::DataLocation).append("/BlackBox"); - return dir; - } - - /* - * File - */ - const QString &CSettingUtilities::getSettingsFile() - { - static QString file(QString(CSettingUtilities::getSettingsDirectory()).append("/settings.json")); - return file; - } - } -} diff --git a/src/blackmisc/settingutilities.h b/src/blackmisc/settingutilities.h deleted file mode 100644 index 50302c8a9..000000000 --- a/src/blackmisc/settingutilities.h +++ /dev/null @@ -1,89 +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 BLACKMISC_SETTINGUTILITIES_H -#define BLACKMISC_SETTINGUTILITIES_H - -#include "blackmiscexport.h" -#include "blackmisc/statusmessagelist.h" - -namespace BlackMisc -{ - namespace Settings - { - //! Helper / utility methods for settings - class BLACKMISC_EXPORT CSettingUtilities - { - private: - CSettingUtilities() {} - - public: - //! Command validate - static const QString &CmdValidate() - { - static const QString cmd("validate"); - return cmd; - } - - //! Command Update - static const QString &CmdUpdate() - { - static const QString cmd("update"); - return cmd; - } - - //! Command Remove - static const QString &CmdRemove() - { - static const QString cmd("remove"); - return cmd; - } - - //! Command Add - static const QString &CmdAdd() - { - static const QString cmd("add"); - return cmd; - } - - //! Command Set boolean value true - static const QString &CmdSetTrue() - { - static const QString cmd("set:true"); - return cmd; - } - - //! Command Set boolean value false - static const QString &CmdSetFalse() - { - static const QString cmd("set:false"); - return cmd; - } - - //! Remove leading path - static QString removeLeadingPath(const QString &path); - - //! Append setting paths - static QString appendPaths(const QString &part1, const QString &part2, const QString &part3 = ""); - - //! prepare the settings directory, if required create it - static bool initSettingsDirectory(); - - //! get the settings directory - static const QString &getSettingsDirectory(); - - //! get the settings directory - static const QString &getSettingsFile(); - - }; - } // namespace -} // namespace -#endif // guard diff --git a/src/blacksound/soundgenerator.h b/src/blacksound/soundgenerator.h index 945eb9ca9..86acb444f 100644 --- a/src/blacksound/soundgenerator.h +++ b/src/blacksound/soundgenerator.h @@ -16,7 +16,7 @@ #include "blackmisc/aviation/selcal.h" #include "blackmisc/audio/audiodeviceinfo.h" #include "blackmisc/pq/time.h" -#include "blackmisc/notificationsounds.h" +#include "blackmisc/audio/notificationsounds.h" #include #include #include @@ -64,14 +64,14 @@ namespace BlackSound //! \param mode play once? //! \param parent //! \see PlayMode - CSoundGenerator(const QAudioDeviceInfo &device, const QAudioFormat &format, const QList &tones, CNotificationSounds::PlayMode mode, QObject *parent = nullptr); + CSoundGenerator(const QAudioDeviceInfo &device, const QAudioFormat &format, const QList &tones, BlackMisc::Audio::CNotificationSounds::PlayMode mode, QObject *parent = nullptr); //! Constructor //! \param tones list of Tones //! \param mode play once? //! \param parent //! \see PlayMode - CSoundGenerator(const QList &tones, CNotificationSounds::PlayMode mode, QObject *parent = nullptr); + CSoundGenerator(const QList &tones, BlackMisc::Audio::CNotificationSounds::PlayMode mode, QObject *parent = nullptr); //! Destructor ~CSoundGenerator(); @@ -169,7 +169,7 @@ namespace BlackSound //! Play notification //! \param volume 0-100 //! \param notification - static void playNotificationSound(int volume, CNotificationSounds::Notification notification); + static void playNotificationSound(int volume, BlackMisc::Audio::CNotificationSounds::Notification notification); //! For debugging purposes void static printAllQtSoundDevices(QTextStream &qtout); @@ -202,17 +202,17 @@ namespace BlackSound void generateData(); private: - QList m_tones; //!< tones to be played - qint64 m_position; //!< position in buffer - CNotificationSounds::PlayMode m_playMode; //!< end data provisioning after playing all tones, play endless loop - bool m_endReached; //!< indicates end in combination with single play - qint64 m_oneCycleDurationMs; //!< how long is one cycle of tones - QByteArray m_buffer; //!< generated buffer for data - QAudioDeviceInfo m_device; //!< audio device - QAudioFormat m_audioFormat; //!< used format + QList m_tones; //!< tones to be played + qint64 m_position; //!< position in buffer + BlackMisc::Audio::CNotificationSounds::PlayMode m_playMode; //!< end data provisioning after playing all tones, play endless loop + bool m_endReached; //!< indicates end in combination with single play + qint64 m_oneCycleDurationMs; //!< how long is one cycle of tones + QByteArray m_buffer; //!< generated buffer for data + QAudioDeviceInfo m_device; //!< audio device + QAudioFormat m_audioFormat; //!< used format QScopedPointer m_audioOutput; - QTimer *m_pushTimer = nullptr; //!< Push mode timer - QIODevice *m_pushModeIODevice = nullptr; //!< IO device when used in push mode + QTimer *m_pushTimer = nullptr; //!< Push mode timer + QIODevice *m_pushModeIODevice = nullptr; //!< IO device when used in push mode QThread *m_ownThread = nullptr; static QDateTime s_selcalStarted; @@ -226,8 +226,8 @@ namespace BlackSound //! Header for saving .wav files struct RiffHeader { - chunk descriptor; // "RIFF" - char type[4]; // "WAVE" + chunk descriptor; //!< "RIFF" + char type[4]; //!< "WAVE" }; //! Header for saving .wav files diff --git a/src/swiftcore/main.cpp b/src/swiftcore/main.cpp index 1a77fbea5..5cc7f91c6 100644 --- a/src/swiftcore/main.cpp +++ b/src/swiftcore/main.cpp @@ -9,7 +9,6 @@ #include "swiftcore.h" #include "blackcore/context_runtime.h" -#include "blackcore/context_settings.h" #include "blackcore/context_application.h" #include "blackcore/context_application_impl.h" #include "blackcore/dbus_server.h" diff --git a/src/swiftdata/swiftdata.cpp b/src/swiftdata/swiftdata.cpp index 24c9b342b..b2ba2c20b 100644 --- a/src/swiftdata/swiftdata.cpp +++ b/src/swiftdata/swiftdata.cpp @@ -113,11 +113,14 @@ void CSwiftData::initMenu() this->ui->menu_WindowMinimize->setIcon(this->style()->standardIcon(QStyle::SP_TitleBarMinButton)); connect(this->ui->menu_FileExit, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked); connect(this->ui->menu_FileSettingsDirectory, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked); + connect(this->ui->menu_FileCacheDirectory, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked); connect(this->ui->menu_FileResetSettings, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked); connect(this->ui->menu_FileReloadStyleSheets, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked); + connect(this->ui->menu_WindowFont, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked); connect(this->ui->menu_WindowMinimize, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked); connect(this->ui->menu_WindowToggleOnTop, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked); + connect(this->ui->menu_MappingMaxData, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked); connect(this->ui->menu_MappingMaxMapping, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked); @@ -127,7 +130,6 @@ void CSwiftData::initMenu() connect(this->ui->menu_InternalsSetup, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked); connect(this->ui->menu_InternalsDeleteCachedFiles, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked); connect(this->ui->menu_InternalsDisplayCachedFiles, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked); - connect(this->ui->menu_InternalsJsonBootstrapTemplate, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked); } diff --git a/src/swiftdata/swiftdata.ui b/src/swiftdata/swiftdata.ui index 8cbccfeac..900bfb593 100644 --- a/src/swiftdata/swiftdata.ui +++ b/src/swiftdata/swiftdata.ui @@ -80,6 +80,7 @@ File + @@ -232,6 +233,11 @@ Delete cached fies + + + Cache directory + + diff --git a/src/swiftdata/swiftdata_menus.cpp b/src/swiftdata/swiftdata_menus.cpp index c25d1612e..d0aa46967 100644 --- a/src/swiftdata/swiftdata_menus.cpp +++ b/src/swiftdata/swiftdata_menus.cpp @@ -14,6 +14,8 @@ #include "blackgui/components/logcomponent.h" #include "blackgui/stylesheetutility.h" #include "blackgui/roles.h" +#include "blackcore/datacache.h" +#include "blackcore/settingscache.h" #include "blackmisc/statusmessagelist.h" #include "blackmisc/logmessage.h" #include "blackmisc/project.h" @@ -24,6 +26,7 @@ #include using namespace BlackGui; +using namespace BlackCore; using namespace BlackGui::Components; using namespace BlackMisc; @@ -53,7 +56,12 @@ void CSwiftData::ps_onMenuClicked() } else if (sender == this->ui->menu_FileSettingsDirectory) { - QString path; + QString path(QDir::toNativeSeparators(CSettingsCache::persistentStore())); + QDesktopServices::openUrl(QUrl("file:///" + path)); + } + else if (sender == this->ui->menu_FileCacheDirectory) + { + QString path(QDir::toNativeSeparators(CDataCache::persistentStore())); QDesktopServices::openUrl(QUrl("file:///" + path)); } else if (sender == this->ui->menu_FileResetSettings) diff --git a/src/swiftgui_standard/introwindow.cpp b/src/swiftgui_standard/introwindow.cpp index 88fac3d14..dda9a52a5 100644 --- a/src/swiftgui_standard/introwindow.cpp +++ b/src/swiftgui_standard/introwindow.cpp @@ -10,8 +10,8 @@ #include "introwindow.h" #include "ui_introwindow.h" #include "blackcore/dbus_server.h" +#include "blackcore/settingscache.h" #include "blackmisc/network/networkutils.h" -#include "blackmisc/settingutilities.h" #include "blackmisc/project.h" #include #include @@ -100,7 +100,7 @@ void CIntroWindow::buttonClicked() const } else if (sender == this->ui->pb_SettingsDir) { - QString path = QDir::toNativeSeparators(BlackMisc::Settings::CSettingUtilities::getSettingsDirectory()); + QString path(QDir::toNativeSeparators(CSettingsCache::persistentStore())); QDesktopServices::openUrl(QUrl("file:///" + path)); } else if (sender == this->ui->pb_CoreStart) diff --git a/src/swiftgui_standard/swiftguistd.cpp b/src/swiftgui_standard/swiftguistd.cpp index 78dcb40b3..1b879555c 100644 --- a/src/swiftgui_standard/swiftguistd.cpp +++ b/src/swiftgui_standard/swiftguistd.cpp @@ -20,7 +20,7 @@ #include "blackcore/context_ownaircraft.h" #include "blackcore/network.h" #include "blackmisc/logmessage.h" -#include "blackmisc/notificationsounds.h" +#include "blackmisc/audio/notificationsounds.h" #include #include @@ -33,7 +33,6 @@ using namespace BlackMisc::Network; using namespace BlackMisc::Aviation; using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::Geo; -using namespace BlackMisc::Settings; using namespace BlackMisc::Audio; using namespace BlackMisc::Input; @@ -275,13 +274,13 @@ void SwiftGuiStd::ps_onConnectionStatusChanged(BlackCore::INetwork::ConnectionSt switch (to) { case INetwork::Connected: - this->playNotifcationSound(BlackSound::CNotificationSounds::NotificationLogin); + this->playNotifcationSound(CNotificationSounds::NotificationLogin); break; case INetwork::Disconnected: - this->playNotifcationSound(BlackSound::CNotificationSounds::NotificationLogoff); + this->playNotifcationSound(CNotificationSounds::NotificationLogoff); break; case INetwork::DisconnectedError: - this->playNotifcationSound(BlackSound::CNotificationSounds::NotificationError); + this->playNotifcationSound(CNotificationSounds::NotificationError); break; default: break; diff --git a/src/swiftgui_standard/swiftguistd.h b/src/swiftgui_standard/swiftguistd.h index 7378e0af6..65d61c916 100644 --- a/src/swiftgui_standard/swiftguistd.h +++ b/src/swiftgui_standard/swiftguistd.h @@ -187,7 +187,7 @@ private: void stopAllTimers(bool disconnectSignalSlots); //! Play notifcation sound - void playNotifcationSound(BlackSound::CNotificationSounds::Notification notification) const; + void playNotifcationSound(BlackMisc::Audio::CNotificationSounds::Notification notification) const; //! Display console void displayConsole(); diff --git a/src/swiftgui_standard/swiftguistd.ui b/src/swiftgui_standard/swiftguistd.ui index df1e66fa4..77f3d3e58 100644 --- a/src/swiftgui_standard/swiftguistd.ui +++ b/src/swiftgui_standard/swiftguistd.ui @@ -314,6 +314,7 @@ File + @@ -522,6 +523,11 @@ Display cached files + + + Cache directory + + diff --git a/src/swiftgui_standard/swiftguistd_aircraft.cpp b/src/swiftgui_standard/swiftguistd_aircraft.cpp index 7f20baaae..4bb847892 100644 --- a/src/swiftgui_standard/swiftguistd_aircraft.cpp +++ b/src/swiftgui_standard/swiftguistd_aircraft.cpp @@ -20,7 +20,6 @@ using namespace BlackMisc::Aviation; using namespace BlackMisc::Simulation; using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::Geo; -using namespace BlackMisc::Settings; using namespace BlackMisc::Audio; /* diff --git a/src/swiftgui_standard/swiftguistd_init.cpp b/src/swiftgui_standard/swiftguistd_init.cpp index a542e1822..e020f126c 100644 --- a/src/swiftgui_standard/swiftguistd_init.cpp +++ b/src/swiftgui_standard/swiftguistd_init.cpp @@ -166,10 +166,13 @@ void SwiftGuiStd::initGuiSignals() connect(this->ui->menu_TestLocationsEDDM, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked); connect(this->ui->menu_TestLocationsEDNX, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked); connect(this->ui->menu_TestLocationsEDRY, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked); + connect(this->ui->menu_FileExit, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked); connect(this->ui->menu_FileSettingsDirectory, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked); + connect(this->ui->menu_FileCacheDirectory, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked); connect(this->ui->menu_FileResetSettings, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked); connect(this->ui->menu_FileReloadStyleSheets, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked); + connect(this->ui->menu_WindowFont, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked); connect(this->ui->menu_WindowMinimize, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked); connect(this->ui->menu_WindowToggleOnTop, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked); @@ -223,7 +226,6 @@ void SwiftGuiStd::initialDataReads() return; } - this->ui->comp_MainInfoArea->getSettingsComponent()->reloadSettings(); // init read this->ps_reloadOwnAircraft(); // init read, independent of traffic network CLogMessage(this).info("Initial data read"); } diff --git a/src/swiftgui_standard/swiftguistd_menus.cpp b/src/swiftgui_standard/swiftguistd_menus.cpp index 54118caea..60421350c 100644 --- a/src/swiftgui_standard/swiftguistd_menus.cpp +++ b/src/swiftgui_standard/swiftguistd_menus.cpp @@ -9,6 +9,8 @@ #include "swiftguistd.h" #include "ui_swiftguistd.h" +#include "blackcore/datacache.h" +#include "blackcore/settingscache.h" #include "blackgui/stylesheetutility.h" #include "blackgui/components/settingscomponent.h" #include "blackgui/components/logcomponent.h" @@ -21,7 +23,9 @@ #include #include + using namespace BlackGui; +using namespace BlackCore; using namespace BlackMisc; using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::Aviation; @@ -52,11 +56,6 @@ void SwiftGuiStd::ps_onMenuClicked() { this->setTestPosition("N 40° 7′ 6.3588", "E 16° 33′ 39.924", CAltitude(100, CAltitude::MeanSeaLevel, CLengthUnit::m())); } - else if (sender == this->ui->menu_ReloadSettings) - { - this->ui->comp_MainInfoArea->getSettingsComponent()->reloadSettings(); - CLogMessage(this).info("Settings reloaded"); - } else if (sender == this->ui->menu_FileReloadStyleSheets) { CStyleSheetUtility::instance().read(); @@ -81,13 +80,17 @@ void SwiftGuiStd::ps_onMenuClicked() } else if (sender == this->ui->menu_FileSettingsDirectory) { - QString path = QDir::toNativeSeparators(BlackMisc::Settings::CSettingUtilities::getSettingsDirectory()); + QString path(QDir::toNativeSeparators(CSettingsCache::persistentStore())); + QDesktopServices::openUrl(QUrl("file:///" + path)); + } + else if (sender == this->ui->menu_FileCacheDirectory) + { + QString path(QDir::toNativeSeparators(CDataCache::persistentStore())); QDesktopServices::openUrl(QUrl("file:///" + path)); } else if (sender == this->ui->menu_FileResetSettings) { - Q_ASSERT(this->getIContextSettings()); - this->getIContextSettings()->reset(true); + //! \todo } else if (sender == this->ui->menu_Internals) {