mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-18 03:15:34 +08:00
Ref T376, voice setup and settings
This commit is contained in:
@@ -22,5 +22,6 @@
|
|||||||
#include "blackmisc/audio/voiceroom.h"
|
#include "blackmisc/audio/voiceroom.h"
|
||||||
#include "blackmisc/audio/voiceroomlist.h"
|
#include "blackmisc/audio/voiceroomlist.h"
|
||||||
#include "blackmisc/audio/audiosettings.h"
|
#include "blackmisc/audio/audiosettings.h"
|
||||||
|
#include "blackmisc/audio/voicesetup.h"
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
#include "registermetadataaudio.h"
|
#include "registermetadataaudio.h"
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
|
|
||||||
#include <QDBusMetaType>
|
#include <QDBusMetaType>
|
||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
@@ -24,6 +23,9 @@ namespace BlackMisc
|
|||||||
CVoiceRoom::registerMetadata();
|
CVoiceRoom::registerMetadata();
|
||||||
CVoiceRoomList::registerMetadata();
|
CVoiceRoomList::registerMetadata();
|
||||||
CSettings::registerMetadata();
|
CSettings::registerMetadata();
|
||||||
|
CVoiceSetup::registerMetadata();
|
||||||
|
|
||||||
|
// struct
|
||||||
qDBusRegisterMetaType<BlackMisc::Audio::CNotificationSounds::PlayMode>();
|
qDBusRegisterMetaType<BlackMisc::Audio::CNotificationSounds::PlayMode>();
|
||||||
qDBusRegisterMetaType<BlackMisc::Audio::CNotificationSounds::Notification>();
|
qDBusRegisterMetaType<BlackMisc::Audio::CNotificationSounds::Notification>();
|
||||||
}
|
}
|
||||||
|
|||||||
41
src/blackmisc/audio/settings/voicesettings.h
Normal file
41
src/blackmisc/audio/settings/voicesettings.h
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/* Copyright (C) 2018
|
||||||
|
* 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_VOICESETTINGS_H
|
||||||
|
#define BLACKMISC_AUDIO_SETTINGS_VOICESETTINGS_H
|
||||||
|
|
||||||
|
#include "blackmisc/audio/voicesetup.h"
|
||||||
|
#include "blackmisc/statusmessagelist.h"
|
||||||
|
#include "blackmisc/settingscache.h"
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
namespace Audio
|
||||||
|
{
|
||||||
|
namespace Settings
|
||||||
|
{
|
||||||
|
//! Voice settings
|
||||||
|
struct TVoiceSetup : public TSettingTrait<CVoiceSetup>
|
||||||
|
{
|
||||||
|
//! \copydoc BlackMisc::TSettingTrait::key
|
||||||
|
static const char *key() { return "audio/currentvoicesetup"; }
|
||||||
|
|
||||||
|
//! \copydoc BlackCore::TSettingTrait::humanReadable
|
||||||
|
static const QString &humanReadable() { static const QString name("Voice setup"); return name; }
|
||||||
|
|
||||||
|
//! \copydoc BlackCore::TSettingTrait::isValid
|
||||||
|
static bool isValid(const CVoiceSetup &setup) { return setup.validate().isSuccess(); }
|
||||||
|
};
|
||||||
|
} // ns
|
||||||
|
} // ns
|
||||||
|
} // ns
|
||||||
|
|
||||||
|
#endif
|
||||||
85
src/blackmisc/audio/voicesetup.cpp
Normal file
85
src/blackmisc/audio/voicesetup.cpp
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
/* Copyright (C) 2018
|
||||||
|
* 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/voicesetup.h"
|
||||||
|
#include "blackmisc/logcategorylist.h"
|
||||||
|
#include "blackmisc/stringutils.h"
|
||||||
|
#include "blackmisc/verify.h"
|
||||||
|
#include "blackmisc/comparefunctions.h"
|
||||||
|
|
||||||
|
#include <Qt>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
namespace Audio
|
||||||
|
{
|
||||||
|
QString CVoiceSetup::convertToQString(bool i18n) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(i18n);
|
||||||
|
static const QString s("Port: %1");
|
||||||
|
return s.arg(getVatsimUdpVoicePort());
|
||||||
|
}
|
||||||
|
|
||||||
|
CStatusMessageList CVoiceSetup::validate() const
|
||||||
|
{
|
||||||
|
static const CLogCategoryList cats(CLogCategoryList(this).join({ CLogCategory::validation()}));
|
||||||
|
CStatusMessageList msgs;
|
||||||
|
if (this->getVatsimUdpVoicePort() < 1 || this->getVatsimUdpVoicePort() > 65535) { msgs.push_back(CStatusMessage(CStatusMessage::SeverityError, "Invalid voice port")); }
|
||||||
|
msgs.addCategories(cats);
|
||||||
|
return msgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CVoiceSetup &CVoiceSetup::vatsimStandard()
|
||||||
|
{
|
||||||
|
static const CVoiceSetup s;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
CVoiceSetup::CVoiceSetup(int vatsimUdpPort) : m_vatismVoiceUdpPort(vatsimUdpPort)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
CVariant CVoiceSetup::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||||
|
{
|
||||||
|
if (index.isMyself()) { return CVariant::from(*this); }
|
||||||
|
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case IndexVatsimVoiceUdpPort: return CVariant::fromValue(m_vatismVoiceUdpPort);
|
||||||
|
default: return CValueObject::propertyByIndex(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CVoiceSetup::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||||
|
{
|
||||||
|
if (index.isMyself()) { (*this) = variant.to<CVoiceSetup>(); return; }
|
||||||
|
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case IndexVatsimVoiceUdpPort: m_vatismVoiceUdpPort = variant.toInt(); break;
|
||||||
|
default:
|
||||||
|
CValueObject::setPropertyByIndex(index, variant);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int CVoiceSetup::comparePropertyByIndex(const CPropertyIndex &index, const CVoiceSetup &compareValue) const
|
||||||
|
{
|
||||||
|
if (index.isMyself()) { return this->convertToQString(true).compare(compareValue.convertToQString()); }
|
||||||
|
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case IndexVatsimVoiceUdpPort: return Compare::compare(m_vatismVoiceUdpPort, compareValue.m_vatismVoiceUdpPort);
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
BLACK_VERIFY_X(false, Q_FUNC_INFO, qUtf8Printable("No comparison for index " + index.toQString()));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
} // namespace
|
||||||
81
src/blackmisc/audio/voicesetup.h
Normal file
81
src/blackmisc/audio/voicesetup.h
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
/* Copyright (C) 2018
|
||||||
|
* 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_VOICESETUP_H
|
||||||
|
#define BLACKMISC_AUDIO_VOICESETUP_H
|
||||||
|
|
||||||
|
#include "blackmisc/statusmessagelist.h"
|
||||||
|
#include "blackmisc/valueobject.h"
|
||||||
|
#include "blackmisc/metaclass.h"
|
||||||
|
#include "blackmisc/propertyindex.h"
|
||||||
|
#include "blackmisc/blackmiscexport.h"
|
||||||
|
|
||||||
|
#include <QMetaType>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
namespace Audio
|
||||||
|
{
|
||||||
|
//! Value object for a voice setup
|
||||||
|
class BLACKMISC_EXPORT CVoiceSetup : public CValueObject<CVoiceSetup>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! Properties by index
|
||||||
|
enum ColumnIndex
|
||||||
|
{
|
||||||
|
IndexVatsimVoiceUdpPort = CPropertyIndex::GlobalIndexCVoiceSetup,
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Default constructor.
|
||||||
|
CVoiceSetup() {}
|
||||||
|
|
||||||
|
//! Setup with values
|
||||||
|
CVoiceSetup(int vatsimUdpPort);
|
||||||
|
|
||||||
|
//! The voice UDP port
|
||||||
|
void setVatsimUdpVoicePort(int port) { m_vatismVoiceUdpPort = port;}
|
||||||
|
|
||||||
|
//! VATSIM UDP voice port
|
||||||
|
int getVatsimUdpVoicePort() const { return m_vatismVoiceUdpPort; }
|
||||||
|
|
||||||
|
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||||
|
CVariant propertyByIndex(const CPropertyIndex &index) const;
|
||||||
|
|
||||||
|
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||||
|
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
|
||||||
|
|
||||||
|
//! \copydoc BlackMisc::Mixin::Index::comparePropertyByIndex
|
||||||
|
int comparePropertyByIndex(const CPropertyIndex &index, const CVoiceSetup &compareValue) const;
|
||||||
|
|
||||||
|
//! \copydoc BlackMisc::Mixin::String::toQString()
|
||||||
|
QString convertToQString(bool i18n = false) const;
|
||||||
|
|
||||||
|
//! Validate
|
||||||
|
CStatusMessageList validate() const;
|
||||||
|
|
||||||
|
//! Standard FSD setup for official VATSIM servers
|
||||||
|
static const CVoiceSetup &vatsimStandard();
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_vatismVoiceUdpPort = 3290;
|
||||||
|
|
||||||
|
BLACK_METACLASS(
|
||||||
|
CVoiceSetup,
|
||||||
|
BLACK_METAMEMBER(vatismVoiceUdpPort)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
} // namespace
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::Audio::CVoiceSetup)
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
@@ -26,6 +26,7 @@ TRANSLATIONS += translations/blackmisc_i18n_de.ts \
|
|||||||
|
|
||||||
HEADERS += *.h \
|
HEADERS += *.h \
|
||||||
$$PWD/audio/*.h \
|
$$PWD/audio/*.h \
|
||||||
|
$$PWD/audio/settings/*.h \
|
||||||
$$PWD/aviation/*.h \
|
$$PWD/aviation/*.h \
|
||||||
$$PWD/db/*.h \
|
$$PWD/db/*.h \
|
||||||
$$PWD/geo/*.h \
|
$$PWD/geo/*.h \
|
||||||
@@ -47,6 +48,7 @@ HEADERS += *.h \
|
|||||||
|
|
||||||
SOURCES += *.cpp \
|
SOURCES += *.cpp \
|
||||||
$$PWD/audio/*.cpp \
|
$$PWD/audio/*.cpp \
|
||||||
|
# $$PWD/audio/settings/*.cpp \
|
||||||
$$PWD/aviation/*.cpp \
|
$$PWD/aviation/*.cpp \
|
||||||
$$PWD/db/*.cpp \
|
$$PWD/db/*.cpp \
|
||||||
$$PWD/geo/*.cpp \
|
$$PWD/geo/*.cpp \
|
||||||
|
|||||||
@@ -124,12 +124,13 @@ namespace BlackMisc
|
|||||||
GlobalIndexCRole = 6300,
|
GlobalIndexCRole = 6300,
|
||||||
GlobalIndexCServer = 6400,
|
GlobalIndexCServer = 6400,
|
||||||
GlobalIndexCFsdSetup = 6500,
|
GlobalIndexCFsdSetup = 6500,
|
||||||
GlobalIndexCNetworkSettings = 6600,
|
GlobalIndexCVoiceSetup = 6600,
|
||||||
GlobalIndexCUrl = 6700,
|
GlobalIndexCNetworkSettings = 6700,
|
||||||
GlobalIndexCUrlLog = 6800,
|
GlobalIndexCUrl = 6800,
|
||||||
GlobalIndexCRemoteFile = 6900,
|
GlobalIndexCUrlLog = 6900,
|
||||||
GlobalIndexCEcosystem = 7000,
|
GlobalIndexCRemoteFile = 7000,
|
||||||
GlobalIndexCRawFsdMessage = 7100,
|
GlobalIndexCEcosystem = 7100,
|
||||||
|
GlobalIndexCRawFsdMessage = 7200,
|
||||||
GlobalIndexCAircraftModel = 8000,
|
GlobalIndexCAircraftModel = 8000,
|
||||||
GlobalIndexCSimulatedAircraft = 8100,
|
GlobalIndexCSimulatedAircraft = 8100,
|
||||||
GlobalIndexCTextMessage = 8200,
|
GlobalIndexCTextMessage = 8200,
|
||||||
|
|||||||
Reference in New Issue
Block a user