mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 01:05:34 +08:00
refactor: Fix some clang-tidy warnings
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
#include "misc/comparefunctions.h"
|
||||
#include "misc/verify.h"
|
||||
|
||||
#include <QStringBuilder>
|
||||
#include <QHostInfo>
|
||||
#include <QtGlobal>
|
||||
#include <QAudioDevice>
|
||||
@@ -49,19 +48,18 @@ namespace swift::misc::audio
|
||||
|
||||
CAudioDeviceInfo CAudioDeviceInfo::getDefaultOutputDevice()
|
||||
{
|
||||
return CAudioDeviceInfo(OutputDevice, QMediaDevices::defaultAudioOutput().description());
|
||||
return { OutputDevice, QMediaDevices::defaultAudioOutput().description() };
|
||||
}
|
||||
|
||||
CAudioDeviceInfo CAudioDeviceInfo::getDefaultInputDevice()
|
||||
{
|
||||
return CAudioDeviceInfo(InputDevice, QMediaDevices::defaultAudioInput().description());
|
||||
return { InputDevice, QMediaDevices::defaultAudioInput().description() };
|
||||
}
|
||||
|
||||
QVariant CAudioDeviceInfo::propertyByIndex(CPropertyIndexRef index) const
|
||||
{
|
||||
if (index.isMyself()) { return QVariant::fromValue(*this); }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
switch (index.frontCasted<ColumnIndex>())
|
||||
{
|
||||
case IndexDeviceType: return QVariant::fromValue(this->getType());
|
||||
case IndexDeviceTypeAsString: return QVariant::fromValue(this->getTypeAsString());
|
||||
@@ -79,8 +77,7 @@ namespace swift::misc::audio
|
||||
(*this) = variant.value<CAudioDeviceInfo>();
|
||||
return;
|
||||
}
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
switch (index.frontCasted<ColumnIndex>())
|
||||
{
|
||||
case IndexDeviceType: m_type = static_cast<DeviceType>(variant.toInt()); return;
|
||||
case IndexName: m_deviceName = variant.toString(); return;
|
||||
@@ -93,8 +90,7 @@ namespace swift::misc::audio
|
||||
int CAudioDeviceInfo::comparePropertyByIndex(CPropertyIndexRef index, const CAudioDeviceInfo &compareValue) const
|
||||
{
|
||||
if (index.isMyself()) { return m_deviceName.compare(compareValue.m_deviceName, Qt::CaseInsensitive); }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
switch (index.frontCasted<ColumnIndex>())
|
||||
{
|
||||
case IndexDeviceTypeAsString:
|
||||
case IndexDeviceType: return Compare::compare(m_type, compareValue.m_type);
|
||||
|
||||
@@ -119,4 +119,4 @@ namespace swift::misc::audio
|
||||
Q_DECLARE_METATYPE(swift::misc::audio::CAudioDeviceInfo)
|
||||
Q_DECLARE_METATYPE(swift::misc::audio::CAudioDeviceInfo::DeviceType)
|
||||
|
||||
#endif // guard
|
||||
#endif // SWIFT_MISC_AUDIO_AUDIODEVICE_H
|
||||
|
||||
@@ -12,8 +12,6 @@ SWIFT_DEFINE_SEQUENCE_MIXINS(swift::misc::audio, CAudioDeviceInfo, CAudioDeviceI
|
||||
|
||||
namespace swift::misc::audio
|
||||
{
|
||||
CAudioDeviceInfoList::CAudioDeviceInfoList() {}
|
||||
|
||||
CAudioDeviceInfoList::CAudioDeviceInfoList(const CSequence &other) : CSequence(other)
|
||||
{}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace swift::misc::audio
|
||||
using CSequence::CSequence;
|
||||
|
||||
//! Default constructor.
|
||||
CAudioDeviceInfoList();
|
||||
CAudioDeviceInfoList() = default;
|
||||
|
||||
//! Construct from a base class object.
|
||||
CAudioDeviceInfoList(const CSequence &other);
|
||||
@@ -101,4 +101,4 @@ namespace swift::misc::audio
|
||||
Q_DECLARE_METATYPE(swift::misc::audio::CAudioDeviceInfoList)
|
||||
Q_DECLARE_METATYPE(swift::misc::CCollection<swift::misc::audio::CAudioDeviceInfo>)
|
||||
|
||||
#endif // guard
|
||||
#endif // SWIFT_MISC_AUDIO_AUDIODEVICELIST_H
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "misc/swiftdirectories.h"
|
||||
#include "misc/fileutils.h"
|
||||
#include <QtGlobal>
|
||||
#include <QStringBuilder>
|
||||
#include <QDir>
|
||||
|
||||
using namespace swift::misc::audio;
|
||||
@@ -76,9 +75,7 @@ namespace swift::misc::audio
|
||||
|
||||
void CSettings::setNotificationVolume(int volume)
|
||||
{
|
||||
m_notificationVolume = volume;
|
||||
if (m_notificationVolume < 0) { m_notificationVolume = 0; }
|
||||
else if (m_notificationVolume > 100) { m_notificationVolume = 100; }
|
||||
m_notificationVolume = std::clamp(volume, 0, 100);
|
||||
}
|
||||
|
||||
void CSettings::setOutVolume(int volume)
|
||||
|
||||
@@ -65,9 +65,6 @@ namespace swift::misc::audio
|
||||
bool afvBlocked() const { return this->isNotificationFlagSet(CNotificationSounds::AFVBlocked); }
|
||||
//! @}
|
||||
|
||||
//! Settings value
|
||||
CStatusMessage value(const QString &path, const QString &command, const CVariant &value, bool &changedFlag);
|
||||
|
||||
//! Directory
|
||||
void setNotificationSoundDirectory(const QString &dir);
|
||||
|
||||
@@ -167,4 +164,4 @@ namespace swift::misc::audio
|
||||
|
||||
Q_DECLARE_METATYPE(swift::misc::audio::CSettings)
|
||||
|
||||
#endif // guard
|
||||
#endif // SWIFT_MISC_AUDIO_SETTINGS_H
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace swift::misc::audio
|
||||
SWIFT_MISC_EXPORT bool startWindowsMixer();
|
||||
|
||||
//! On windows init the audio devices
|
||||
//! \remarks workaround for WSAPI driver crashes, hoping that upfront init already sets global vars. etc.
|
||||
//! \remarks workaround for WASAPI driver crashes, hoping that upfront init already sets global vars. etc.
|
||||
SWIFT_MISC_EXPORT void initWindowsAudioDevices();
|
||||
}
|
||||
|
||||
|
||||
@@ -75,4 +75,4 @@ namespace swift::misc::audio
|
||||
Q_DECLARE_METATYPE(swift::misc::audio::CNotificationSounds::Notification)
|
||||
Q_DECLARE_METATYPE(swift::misc::audio::CNotificationSounds::NotificationFlag)
|
||||
|
||||
#endif // guard
|
||||
#endif // SWIFT_MISC_NOTIFICATIONSOUNDS_H
|
||||
|
||||
@@ -10,21 +10,19 @@
|
||||
|
||||
#include <QDBusMetaType>
|
||||
|
||||
namespace swift::misc
|
||||
namespace swift::misc::audio
|
||||
{
|
||||
namespace audio
|
||||
//! Register metadata for audio / voice
|
||||
void registerMetadata()
|
||||
{
|
||||
//! Register metadata for audio / voice
|
||||
void registerMetadata()
|
||||
{
|
||||
CAudioDeviceInfo::registerMetadata();
|
||||
CAudioDeviceInfoList::registerMetadata();
|
||||
CSettings::registerMetadata();
|
||||
CAudioDeviceInfo::registerMetadata();
|
||||
CAudioDeviceInfoList::registerMetadata();
|
||||
CSettings::registerMetadata();
|
||||
|
||||
// ENUMs
|
||||
qDBusRegisterMetaType<CNotificationSounds::NotificationFlag>();
|
||||
qDBusRegisterMetaType<CAudioDeviceInfo::DeviceType>();
|
||||
}
|
||||
// ENUMs
|
||||
qDBusRegisterMetaType<CNotificationSounds::NotificationFlag>();
|
||||
qDBusRegisterMetaType<CAudioDeviceInfo::DeviceType>();
|
||||
}
|
||||
}
|
||||
|
||||
} // ns
|
||||
// ns
|
||||
|
||||
@@ -14,4 +14,4 @@ namespace swift::misc::audio
|
||||
SWIFT_MISC_EXPORT void registerMetadata();
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
#endif // SWIFT_MISC_AUDIO_REGISTERMETADATAAUDIO_H
|
||||
|
||||
Reference in New Issue
Block a user