mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-15 01:05:35 +08:00
refs #258, settings for voice room notifications
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include "blackmisc/settingutilities.h"
|
||||
#include "blackmisc/setnetwork.h"
|
||||
#include "blackmisc/setaudio.h"
|
||||
#include "blackmisc/dbus.h"
|
||||
#include "blackmisc/variant.h"
|
||||
#include <QObject>
|
||||
@@ -36,7 +37,8 @@ namespace BlackCore
|
||||
enum SettingsType
|
||||
{
|
||||
SettingsHotKeys,
|
||||
SettingsNetwork
|
||||
SettingsNetwork,
|
||||
SettingsAudio
|
||||
};
|
||||
|
||||
protected:
|
||||
@@ -70,20 +72,21 @@ namespace BlackCore
|
||||
return s;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Path for network settings
|
||||
* \remarks no to be confused with DBus paths
|
||||
*/
|
||||
//! 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;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Path for hotkeys
|
||||
* \remarks no to be confused with DBus paths
|
||||
*/
|
||||
//! Path for hotkeys
|
||||
static const QString &PathHotkeys()
|
||||
{
|
||||
static QString s("hotkeys");
|
||||
@@ -111,6 +114,9 @@ namespace BlackCore
|
||||
//! Network settings
|
||||
virtual BlackMisc::Settings::CSettingsNetwork getNetworkSettings() const = 0;
|
||||
|
||||
//! Audio settings
|
||||
virtual BlackMisc::Settings::CSettingsAudio getAudioSettings() const = 0;
|
||||
|
||||
//! Hotkeys
|
||||
virtual BlackMisc::Hardware::CKeyboardKeyList getHotkeys() const = 0;
|
||||
|
||||
|
||||
@@ -36,21 +36,21 @@ namespace BlackCore
|
||||
}
|
||||
bool ok = false;
|
||||
QFile jsonFile(this->getSettingsFileName());
|
||||
QJsonObject obj;
|
||||
QJsonObject jsonObject;
|
||||
|
||||
if (jsonFile.open(QFile::ReadOnly))
|
||||
{
|
||||
QJsonDocument doc = QJsonDocument::fromJson(jsonFile.readAll());
|
||||
obj = doc.object();
|
||||
jsonObject = doc.object();
|
||||
ok = true;
|
||||
}
|
||||
jsonFile.close();
|
||||
|
||||
// init network
|
||||
if (obj.contains(IContextSettings::PathNetworkSettings()))
|
||||
if (jsonObject.contains(IContextSettings::PathNetworkSettings()))
|
||||
{
|
||||
this->m_settingsNetwork.fromJson(
|
||||
obj.value(IContextSettings::PathNetworkSettings()).toObject()
|
||||
jsonObject.value(IContextSettings::PathNetworkSettings()).toObject()
|
||||
);
|
||||
}
|
||||
else
|
||||
@@ -58,11 +58,23 @@ namespace BlackCore
|
||||
this->m_settingsNetwork.initDefaultValues();
|
||||
}
|
||||
|
||||
// init audio
|
||||
if (jsonObject.contains(IContextSettings::PathAudioSettings()))
|
||||
{
|
||||
this->m_settingsAudio.fromJson(
|
||||
jsonObject.value(IContextSettings::PathNetworkSettings()).toObject()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->m_settingsAudio.initDefaultValues();
|
||||
}
|
||||
|
||||
// init own members
|
||||
if (obj.contains(IContextSettings::PathHotkeys()))
|
||||
if (jsonObject.contains(IContextSettings::PathHotkeys()))
|
||||
{
|
||||
this->m_hotkeys.fromJson(
|
||||
obj.value(IContextSettings::PathHotkeys()).toObject()
|
||||
jsonObject.value(IContextSettings::PathHotkeys()).toObject()
|
||||
);
|
||||
}
|
||||
this->m_hotkeys.initAsHotkeyList(false); // update missing parts
|
||||
@@ -116,6 +128,7 @@ namespace BlackCore
|
||||
{
|
||||
this->m_hotkeys.initAsHotkeyList(true);
|
||||
this->m_settingsNetwork.initDefaultValues();
|
||||
this->m_settingsAudio.initDefaultValues();
|
||||
this->emitCompletelyChanged();
|
||||
if (write)
|
||||
return this->write();
|
||||
@@ -136,10 +149,11 @@ namespace BlackCore
|
||||
*/
|
||||
QJsonDocument CContextSettings::toJsonDocument() const
|
||||
{
|
||||
QJsonObject obj;
|
||||
obj.insert(IContextSettings::PathNetworkSettings(), this->m_settingsNetwork.toJson());
|
||||
obj.insert(IContextSettings::PathHotkeys(), this->m_hotkeys.toJson());
|
||||
QJsonDocument doc(obj);
|
||||
QJsonObject jsonObject;
|
||||
jsonObject.insert(IContextSettings::PathNetworkSettings(), this->m_settingsNetwork.toJson());
|
||||
jsonObject.insert(IContextSettings::PathAudioSettings(), this->m_settingsAudio.toJson());
|
||||
jsonObject.insert(IContextSettings::PathHotkeys(), this->m_hotkeys.toJson());
|
||||
QJsonDocument doc(jsonObject);
|
||||
return doc;
|
||||
}
|
||||
|
||||
@@ -150,6 +164,7 @@ namespace BlackCore
|
||||
{
|
||||
emit this->changedSettings(IContextSettings::SettingsHotKeys);
|
||||
emit this->changedSettings(IContextSettings::SettingsNetwork);
|
||||
emit this->changedSettings(IContextSettings::SettingsAudio);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -168,6 +183,14 @@ namespace BlackCore
|
||||
return this->m_settingsNetwork;
|
||||
}
|
||||
|
||||
/*
|
||||
* Audio settings
|
||||
*/
|
||||
CSettingsAudio CContextSettings::getAudioSettings() const
|
||||
{
|
||||
return this->m_settingsAudio;
|
||||
}
|
||||
|
||||
/*
|
||||
* Pass value
|
||||
*/
|
||||
@@ -204,6 +227,15 @@ namespace BlackCore
|
||||
emit this->changedSettings(static_cast<uint>(SettingsNetwork));
|
||||
}
|
||||
}
|
||||
else if (path.startsWith(IContextSettings::PathAudioSettings()))
|
||||
{
|
||||
msgs = this->m_settingsAudio.value(nextLevelPath, command, value, changed);
|
||||
if (changed)
|
||||
{
|
||||
msgs.push_back(this->write());
|
||||
emit this->changedSettings(static_cast<uint>(SettingsAudio));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// wrong path
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "context_runtime.h"
|
||||
|
||||
#include "blackmisc/setnetwork.h"
|
||||
#include "blackmisc/setaudio.h"
|
||||
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include "blackmisc/hwkeyboardkeylist.h"
|
||||
|
||||
@@ -52,6 +54,9 @@ namespace BlackCore
|
||||
//! \copydoc IContextSettings::getNetworkSettings()
|
||||
virtual BlackMisc::Settings::CSettingsNetwork getNetworkSettings() const override;
|
||||
|
||||
//! \copydoc IContextSettings::getAudioSettings()
|
||||
virtual BlackMisc::Settings::CSettingsAudio getAudioSettings() const override;
|
||||
|
||||
//! \copydoc IContextSettings::getHotkeys()
|
||||
virtual BlackMisc::Hardware::CKeyboardKeyList getHotkeys() const override;
|
||||
|
||||
@@ -72,6 +77,7 @@ namespace BlackCore
|
||||
|
||||
private:
|
||||
BlackMisc::Settings::CSettingsNetwork m_settingsNetwork;
|
||||
BlackMisc::Settings::CSettingsAudio m_settingsAudio;
|
||||
BlackMisc::Hardware::CKeyboardKeyList m_hotkeys;
|
||||
QJsonDocument toJsonDocument() const;
|
||||
void emitCompletelyChanged();
|
||||
|
||||
@@ -50,7 +50,15 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
/*
|
||||
* Relay tp DBus
|
||||
* Relay to DBus
|
||||
*/
|
||||
CSettingsAudio CContextSettingsProxy::getAudioSettings() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<CSettingsAudio>(QLatin1Literal("getAudioSettings"));
|
||||
}
|
||||
|
||||
/*
|
||||
* Relay to DBus
|
||||
*/
|
||||
CKeyboardKeyList CContextSettingsProxy::getHotkeys() const
|
||||
{
|
||||
|
||||
@@ -49,6 +49,9 @@ namespace BlackCore
|
||||
//! \copydoc IContextSettings::getNetworkSettings()
|
||||
virtual BlackMisc::Settings::CSettingsNetwork getNetworkSettings() const override;
|
||||
|
||||
//! \copydoc IContextSettings::getAudioSettings()
|
||||
virtual BlackMisc::Settings::CSettingsAudio getAudioSettings() const override;
|
||||
|
||||
//! \copydoc IContextSettings::getHotkeys()
|
||||
virtual BlackMisc::Hardware::CKeyboardKeyList getHotkeys() const override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user