mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
refactor: Fix some clang-tidy warnings
This commit is contained in:
@@ -261,7 +261,7 @@ namespace swift::core
|
||||
switch (application)
|
||||
{
|
||||
case CApplicationInfo::PilotClientCore: searchFor = "core"; break;
|
||||
case CApplicationInfo::Laucher: searchFor = "launcher"; break;
|
||||
case CApplicationInfo::Launcher: searchFor = "launcher"; break;
|
||||
case CApplicationInfo::MappingTool: searchFor = "data"; break;
|
||||
case CApplicationInfo::PilotClientGui: searchFor = "gui"; break;
|
||||
default: break;
|
||||
@@ -278,8 +278,8 @@ namespace swift::core
|
||||
|
||||
bool CApplication::startLauncher()
|
||||
{
|
||||
static const QString launcher = CApplication::getExecutableForApplication(CApplicationInfo::Application::Laucher);
|
||||
if (launcher.isEmpty() || CApplication::isApplicationRunning(CApplicationInfo::Laucher)) { return false; }
|
||||
static const QString launcher = CApplication::getExecutableForApplication(CApplicationInfo::Application::Launcher);
|
||||
if (launcher.isEmpty() || CApplication::isApplicationRunning(CApplicationInfo::Launcher)) { return false; }
|
||||
|
||||
// const QStringList args = this->argumentsJoined({}, { "--dbus", "--core", "--coreaudio" });
|
||||
const QStringList args = this->argumentsJoined({}, { "--dbus", "--core" });
|
||||
|
||||
@@ -676,7 +676,7 @@ namespace swift::gui
|
||||
addMenuForStyleSheets(menu);
|
||||
QAction *a = nullptr;
|
||||
bool c = false;
|
||||
if (this->getApplicationInfo().getApplication() != CApplicationInfo::Laucher)
|
||||
if (this->getApplicationInfo().getApplication() != CApplicationInfo::Launcher)
|
||||
{
|
||||
menu.addSeparator();
|
||||
a = menu.addAction(CIcons::swiftLauncher24(), "Start swift launcher");
|
||||
|
||||
@@ -15,8 +15,6 @@ SWIFT_DEFINE_VALUEOBJECT_MIXINS(swift::misc, CApplicationInfo)
|
||||
|
||||
namespace swift::misc
|
||||
{
|
||||
CApplicationInfo::CApplicationInfo() {}
|
||||
|
||||
CApplicationInfo::CApplicationInfo(Application app) : m_app(app),
|
||||
m_wordSize(CBuildConfig::buildWordSize()),
|
||||
m_exePath(QCoreApplication::applicationDirPath()),
|
||||
@@ -43,7 +41,7 @@ namespace swift::misc
|
||||
|
||||
switch (getApplication())
|
||||
{
|
||||
case Laucher: return launcher;
|
||||
case Launcher: return launcher;
|
||||
case PilotClientCore: return core;
|
||||
case PilotClientGui: return gui;
|
||||
case MappingTool: return mapping;
|
||||
@@ -94,7 +92,7 @@ namespace swift::misc
|
||||
{
|
||||
switch (getApplication())
|
||||
{
|
||||
case Laucher: return CIcons::SwiftLauncher16;
|
||||
case Launcher: return CIcons::SwiftLauncher16;
|
||||
case PilotClientCore: return CIcons::SwiftCore16;
|
||||
case PilotClientGui: return CIcons::Swift16;
|
||||
case MappingTool: return CIcons::SwiftDatabase16;
|
||||
@@ -218,7 +216,7 @@ namespace swift::misc
|
||||
if (a.contains("test")) { return CApplicationInfo::UnitTest; } // names like testcore
|
||||
if (a.contains("sample")) { return CApplicationInfo::Sample; }
|
||||
if (a.contains("core")) { return CApplicationInfo::PilotClientCore; }
|
||||
if (a.contains("launcher")) { return CApplicationInfo::Laucher; }
|
||||
if (a.contains("launcher")) { return CApplicationInfo::Launcher; }
|
||||
if (a.contains("gui")) { return CApplicationInfo::PilotClientGui; }
|
||||
if (a.contains("data") || a.contains("mapping")) { return CApplicationInfo::MappingTool; }
|
||||
return CApplicationInfo::Unknown;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace swift::misc
|
||||
enum Application
|
||||
{
|
||||
Unknown,
|
||||
Laucher,
|
||||
Launcher,
|
||||
PilotClientCore,
|
||||
PilotClientGui,
|
||||
MappingTool,
|
||||
@@ -52,7 +52,7 @@ namespace swift::misc
|
||||
};
|
||||
|
||||
//! Default constructor.
|
||||
CApplicationInfo();
|
||||
CApplicationInfo() = default;
|
||||
|
||||
//! Constructor.
|
||||
CApplicationInfo(Application app);
|
||||
@@ -154,7 +154,7 @@ namespace swift::misc
|
||||
//! Name of swift core
|
||||
static const QString &swiftCore();
|
||||
|
||||
//! Info automatically initalized
|
||||
//! Info automatically initialized
|
||||
static const CApplicationInfo &autoInfo();
|
||||
|
||||
//! File name of the application info file
|
||||
@@ -165,7 +165,7 @@ namespace swift::misc
|
||||
|
||||
private:
|
||||
int m_app = static_cast<int>(Unknown);
|
||||
int m_wordSize;
|
||||
int m_wordSize {};
|
||||
QString m_exePath;
|
||||
QString m_applicationDataDir;
|
||||
QString m_version;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace swift::misc
|
||||
typename QMap<T, T>::iterator insert(const T &value) { return QMap<T, T>::insert(value, value); }
|
||||
|
||||
//! Default constructor.
|
||||
QOrderedSet() {}
|
||||
QOrderedSet() = default;
|
||||
|
||||
//! Initializer list constructor.
|
||||
QOrderedSet(std::initializer_list<T> il)
|
||||
@@ -104,37 +104,37 @@ namespace swift::misc
|
||||
{
|
||||
public:
|
||||
//! STL compatibility
|
||||
typedef T key_type;
|
||||
using key_type = T;
|
||||
|
||||
//! STL compatibility
|
||||
typedef T value_type;
|
||||
using value_type = T;
|
||||
|
||||
//! STL compatibility
|
||||
typedef T &reference;
|
||||
using reference = T &;
|
||||
|
||||
//! STL compatibility
|
||||
typedef const T &const_reference;
|
||||
using const_reference = const T &;
|
||||
|
||||
//! STL compatibility
|
||||
typedef T *pointer;
|
||||
using pointer = T *;
|
||||
|
||||
//! STL compatibility
|
||||
typedef const T *const_pointer;
|
||||
using const_pointer = const T *;
|
||||
|
||||
//! STL compatibility
|
||||
typedef typename QOrderedSet<T>::const_iterator const_iterator;
|
||||
using const_iterator = typename QOrderedSet<T>::const_iterator;
|
||||
|
||||
//! STL compatibility
|
||||
typedef const_iterator iterator; // can't modify elements in-place
|
||||
using iterator = const_iterator; // can't modify elements in-place
|
||||
|
||||
//! STL compatibility
|
||||
typedef ptrdiff_t difference_type;
|
||||
using difference_type = ptrdiff_t;
|
||||
|
||||
//! STL compatibility
|
||||
typedef int size_type;
|
||||
using size_type = int;
|
||||
|
||||
//! Default constructor.
|
||||
CCollection() {}
|
||||
CCollection() = default;
|
||||
|
||||
//! Initializer list constructor.
|
||||
CCollection(std::initializer_list<T> il) : m_impl(il) {}
|
||||
|
||||
@@ -44,4 +44,4 @@ namespace swift::misc::Compare
|
||||
}
|
||||
} // ns
|
||||
|
||||
#endif
|
||||
#endif // SWIFT_MISC_COMPAREFUNCTIONS_H
|
||||
|
||||
@@ -41,4 +41,4 @@ namespace swift::misc
|
||||
};
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
#endif // SWIFT_MISC_COMPRESSUTILS_H
|
||||
|
||||
@@ -5,14 +5,10 @@
|
||||
#include "misc/fileutils.h"
|
||||
#include "misc/worker.h"
|
||||
|
||||
#include <QStringBuilder>
|
||||
|
||||
SWIFT_DEFINE_VALUEOBJECT_MIXINS(swift::misc, CCrashInfo)
|
||||
|
||||
namespace swift::misc
|
||||
{
|
||||
CCrashInfo::CCrashInfo() {}
|
||||
|
||||
QString CCrashInfo::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
@@ -38,8 +34,7 @@ namespace swift::misc
|
||||
QVariant CCrashInfo::propertyByIndex(CPropertyIndexRef index) const
|
||||
{
|
||||
if (index.isMyself()) { return QVariant::fromValue(*this); }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
switch (index.frontCasted<ColumnIndex>())
|
||||
{
|
||||
case IndexUserName: return QVariant::fromValue(m_userName);
|
||||
case IndexInfo: return QVariant::fromValue(m_info);
|
||||
@@ -57,8 +52,7 @@ namespace swift::misc
|
||||
(*this) = variant.value<CCrashInfo>();
|
||||
return;
|
||||
}
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
switch (index.frontCasted<ColumnIndex>())
|
||||
{
|
||||
case IndexUserName: this->setUserName(variant.toString()); break;
|
||||
case IndexInfo: this->setUserName(variant.toString()); break;
|
||||
@@ -71,8 +65,7 @@ namespace swift::misc
|
||||
int CCrashInfo::comparePropertyByIndex(CPropertyIndexRef index, const CCrashInfo &compareValue) const
|
||||
{
|
||||
if (index.isMyself()) { return this->getInfo().compare(compareValue.getInfo()); }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
switch (index.frontCasted<ColumnIndex>())
|
||||
{
|
||||
case IndexUserName: return this->getUserName().compare(compareValue.getUserName());
|
||||
case IndexInfo: return this->getInfo().compare(compareValue.getInfo());
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace swift::misc
|
||||
};
|
||||
|
||||
//! Default constructor.
|
||||
CCrashInfo();
|
||||
CCrashInfo() = default;
|
||||
|
||||
//! Get user name
|
||||
const QString &getUserName() const { return m_userName; }
|
||||
@@ -104,4 +104,4 @@ namespace swift::misc
|
||||
|
||||
Q_DECLARE_METATYPE(swift::misc::CCrashInfo)
|
||||
|
||||
#endif // guard
|
||||
#endif // SWIFT_MISC_CRASHINFO_H
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
#include "misc/datacache.h"
|
||||
#include "misc/atomicfile.h"
|
||||
#include "misc/directoryutils.h"
|
||||
#include "misc/identifier.h"
|
||||
#include "misc/logmessage.h"
|
||||
#include "misc/processinfo.h"
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include "misc/identifier.h"
|
||||
#include "misc/propertyindexref.h"
|
||||
#include "misc/statusmessage.h"
|
||||
#include "misc/logcategories.h"
|
||||
#include "misc/valuecache.h"
|
||||
#include "misc/valuecacheprivate.h"
|
||||
#include "misc/variantmap.h"
|
||||
|
||||
@@ -38,7 +38,7 @@ int main(int argc, char *argv[])
|
||||
CGuiApplication::highDpiScreenSupport(CGuiApplication::scaleFactor(argc, argv));
|
||||
QApplication qa(argc, argv); // needed
|
||||
Q_UNUSED(qa)
|
||||
CGuiApplication a(CApplicationInfo::swiftLauncher(), CApplicationInfo::Laucher, CIcons::swiftLauncher1024());
|
||||
CGuiApplication a(CApplicationInfo::swiftLauncher(), CApplicationInfo::Launcher, CIcons::swiftLauncher1024());
|
||||
a.addNetworkOptions(); // so it can be passed (hand over) to started applications
|
||||
a.addDBusAddressOption(); // required by the dbus server address selector
|
||||
const QCommandLineOption installerOption { { "i", "installer" }, QCoreApplication::translate("main", "Installer setup.") };
|
||||
|
||||
@@ -408,7 +408,7 @@ void CSwiftLauncher::saveSetup()
|
||||
bool CSwiftLauncher::warnAboutOtherSwiftApplications()
|
||||
{
|
||||
CApplicationInfoList running = CGuiApplication::getRunningApplications();
|
||||
running.removeApplication(CApplicationInfo::Laucher);
|
||||
running.removeApplication(CApplicationInfo::Launcher);
|
||||
if (running.isEmpty()) { return true; }
|
||||
|
||||
// getting here means another application is running
|
||||
|
||||
Reference in New Issue
Block a user