mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-12 15:25:34 +08:00
Removed settings context
* removed old settings related classes * moved notifications to BlackMisc::Audio * added audio settings where needed refs #464 refs #337
This commit is contained in:
committed by
Mathew Sutcliffe
parent
821e0417ae
commit
ac61a3458d
@@ -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
|
||||
|
||||
54
src/blackmisc/audio/notificationsounds.h
Normal file
54
src/blackmisc/audio/notificationsounds.h
Normal file
@@ -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 <QMetaType>
|
||||
|
||||
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
|
||||
60
src/blackmisc/audio/settings/settingsaudio.cpp
Normal file
60
src/blackmisc/audio/settings/settingsaudio.cpp
Normal file
@@ -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<int>(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<int>(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
|
||||
62
src/blackmisc/audio/settings/settingsaudio.h
Normal file
62
src/blackmisc/audio/settings/settingsaudio.h
Normal file
@@ -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 <QJsonObject>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Audio
|
||||
{
|
||||
namespace Settings
|
||||
{
|
||||
//! Value object encapsulating information of audio related settings.
|
||||
class BLACKMISC_EXPORT CSettingsAudio : public CValueObject<CSettingsAudio>
|
||||
{
|
||||
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
|
||||
@@ -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 \
|
||||
|
||||
@@ -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<BlackSound::CNotificationSounds::PlayMode>();
|
||||
qDBusRegisterMetaType<BlackSound::CNotificationSounds::Notification>();
|
||||
Settings::CSettingsAudio::registerMetadata();
|
||||
qDBusRegisterMetaType<BlackMisc::Audio::CNotificationSounds::PlayMode>();
|
||||
qDBusRegisterMetaType<BlackMisc::Audio::CNotificationSounds::Notification>();
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include <QDBusArgument>
|
||||
#include <QTextStream>
|
||||
#include <QDataStream>
|
||||
|
||||
#include <memory>
|
||||
|
||||
/*!
|
||||
@@ -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
|
||||
|
||||
@@ -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 <QMetaType>
|
||||
|
||||
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
|
||||
@@ -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<int>(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<int>(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<CNotificationSounds::Notification>(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
|
||||
@@ -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 <QJsonObject>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Settings
|
||||
{
|
||||
//! Value object encapsulating information of audio related settings.
|
||||
class BLACKMISC_EXPORT CSettingsAudio : public CValueObject<CSettingsAudio>
|
||||
{
|
||||
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
|
||||
@@ -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 <QJsonObject>
|
||||
|
||||
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<CSettingsNetwork>
|
||||
{
|
||||
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
|
||||
@@ -1,6 +0,0 @@
|
||||
#ifndef BLACKMISC_SETTINGSBLACKMISCCLASSES_H
|
||||
#define BLACKMISC_SETTINGSBLACKMISCCLASSES_H
|
||||
|
||||
#include "blackmisc/setaudio.h"
|
||||
|
||||
#endif // guard
|
||||
@@ -1,61 +0,0 @@
|
||||
#include "settingutilities.h"
|
||||
#include <QStandardPaths>
|
||||
#include <QDir>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user