mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
refs #697 BlackMisc settings renamed and reorganized.
This commit is contained in:
@@ -21,6 +21,6 @@
|
||||
#include "blackmisc/audio/audiodeviceinfolist.h"
|
||||
#include "blackmisc/audio/voiceroom.h"
|
||||
#include "blackmisc/audio/voiceroomlist.h"
|
||||
#include "blackmisc/audio/settings/settingsaudio.h"
|
||||
#include "blackmisc/audio/audiosettings.h"
|
||||
|
||||
#endif // guard
|
||||
|
||||
59
src/blackmisc/audio/audiosettings.cpp
Normal file
59
src/blackmisc/audio/audiosettings.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
/* 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 "blackmisc/audio/audiosettings.h"
|
||||
|
||||
#include <QChar>
|
||||
#include <QtGlobal>
|
||||
|
||||
using namespace BlackMisc::Audio;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Audio
|
||||
{
|
||||
CSettings::CSettings()
|
||||
{
|
||||
this->initDefaultValues();
|
||||
}
|
||||
|
||||
bool CSettings::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 CSettings::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
QString s("Notification flags:");
|
||||
s.append(" ").append(m_notificationFlags);
|
||||
return s;
|
||||
}
|
||||
|
||||
void CSettings::initDefaultValues()
|
||||
{
|
||||
this->initNotificationFlags();
|
||||
}
|
||||
|
||||
void CSettings::initNotificationFlags()
|
||||
{
|
||||
// if we add flags in the future, we automatically extend ...
|
||||
constexpr 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
|
||||
65
src/blackmisc/audio/audiosettings.h
Normal file
65
src/blackmisc/audio/audiosettings.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/* 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_H
|
||||
#define BLACKMISC_AUDIO_SETTINGS_H
|
||||
|
||||
#include "blackmisc/audio/notificationsounds.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/metaclass.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include "blackmisc/valueobject.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QString>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Audio
|
||||
{
|
||||
//! Value object encapsulating information of audio related settings.
|
||||
class BLACKMISC_EXPORT CSettings : public CValueObject<CSettings>
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
CSettings();
|
||||
|
||||
//! 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);
|
||||
|
||||
//! Settings value
|
||||
BlackMisc::CStatusMessage value(const QString &path, const QString &command, const BlackMisc::CVariant &value, bool &changedFlag);
|
||||
|
||||
//! Init with meaningful default values
|
||||
void initDefaultValues();
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
private:
|
||||
QString m_notificationFlags; //!< play notification for notification x, a little trick to use a string here (streamable, hashable, ..)
|
||||
void initNotificationFlags(); //!< init flags
|
||||
|
||||
BLACK_METACLASS(
|
||||
CSettings,
|
||||
BLACK_METAMEMBER(notificationFlags)
|
||||
);
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Audio::CSettings)
|
||||
|
||||
#endif // guard
|
||||
@@ -23,7 +23,7 @@ namespace BlackMisc
|
||||
CAudioDeviceInfoList::registerMetadata();
|
||||
CVoiceRoom::registerMetadata();
|
||||
CVoiceRoomList::registerMetadata();
|
||||
Settings::CSettingsAudio::registerMetadata();
|
||||
CSettings::registerMetadata();
|
||||
qDBusRegisterMetaType<BlackMisc::Audio::CNotificationSounds::PlayMode>();
|
||||
qDBusRegisterMetaType<BlackMisc::Audio::CNotificationSounds::Notification>();
|
||||
}
|
||||
|
||||
@@ -1,62 +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.
|
||||
*/
|
||||
|
||||
#include "blackmisc/audio/settings/settingsaudio.h"
|
||||
|
||||
#include <QChar>
|
||||
#include <QtGlobal>
|
||||
|
||||
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 ...
|
||||
constexpr 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
|
||||
@@ -1,69 +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_AUDIO_SETTINGS_AUDIO_H
|
||||
#define BLACKMISC_AUDIO_SETTINGS_AUDIO_H
|
||||
|
||||
#include "blackmisc/audio/notificationsounds.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/metaclass.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include "blackmisc/valueobject.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QString>
|
||||
|
||||
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);
|
||||
|
||||
//! Settings value
|
||||
BlackMisc::CStatusMessage value(const QString &path, const QString &command, const BlackMisc::CVariant &value, bool &changedFlag);
|
||||
|
||||
//! Init with meaningful default values
|
||||
void initDefaultValues();
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
private:
|
||||
QString m_notificationFlags; //!< play notification for notification x, a little trick to use a string here (streamable, hashable, ..)
|
||||
void initNotificationFlags(); //!< init flags
|
||||
|
||||
BLACK_METACLASS(
|
||||
CSettingsAudio,
|
||||
BLACK_METAMEMBER(notificationFlags)
|
||||
);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Audio::Settings::CSettingsAudio)
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user