Clang-Tidy and Clazy fixes

This commit is contained in:
Jonas Kvinge
2021-06-20 19:04:08 +02:00
parent 755abec636
commit 1295033fae
374 changed files with 1304 additions and 900 deletions

View File

@@ -294,7 +294,7 @@ void TranscodeDialog::UpdateProgress() {
int progress = (finished_success_ + finished_failed_) * 100;
QMap<QString, float> current_jobs = transcoder_->GetProgress();
QList<float> values = current_jobs.values();
QList<float> values = current_jobs.values(); // clazy:exclude=qt6-deprecated-api-fixes
for (const float value : values) {
progress += qBound(0, int(value * 100), 99);
}
@@ -389,7 +389,7 @@ void TranscodeDialog::SetFilenames(const QStringList &filenames) {
void TranscodeDialog::Remove() { qDeleteAll(ui_->files->selectedItems()); }
void TranscodeDialog::LogLine(const QString message) {
void TranscodeDialog::LogLine(const QString &message) {
QString date(QDateTime::currentDateTime().toString(Qt::TextDate));
log_ui_->log->appendPlainText(QString("%1: %2").arg(date, message));
@@ -410,7 +410,7 @@ void TranscodeDialog::Options() {
TranscoderPreset preset = ui_->format->itemData(ui_->format->currentIndex()).value<TranscoderPreset>();
TranscoderOptionsDialog dialog(preset.type_, this);
TranscoderOptionsDialog dialog(preset.filetype_, this);
if (dialog.is_valid()) {
dialog.exec();
}

View File

@@ -76,7 +76,7 @@ class TranscodeDialog : public QDialog {
void Cancel();
void JobComplete(const QString &input, const QString &output, bool success);
void AllJobsComplete();
void LogLine(const QString message);
void LogLine(const QString &message);
void Options();
void AddDestination();
void accept() override;

View File

@@ -48,8 +48,8 @@
int Transcoder::JobFinishedEvent::sEventType = -1;
TranscoderPreset::TranscoderPreset(Song::FileType type, const QString &name, const QString &extension, const QString &codec_mimetype, const QString &muxer_mimetype)
: type_(type),
TranscoderPreset::TranscoderPreset(const Song::FileType filetype, const QString &name, const QString &extension, const QString &codec_mimetype, const QString &muxer_mimetype)
: filetype_(filetype),
name_(name),
extension_(extension),
codec_mimetype_(codec_mimetype),
@@ -187,7 +187,7 @@ GstElement *Transcoder::CreateElementForMimeType(const QString &element_type, co
Transcoder::JobFinishedEvent::JobFinishedEvent(JobState *state, bool success)
: QEvent(QEvent::Type(sEventType)), state_(state), success_(success) {}
void Transcoder::JobState::PostFinished(bool success) {
void Transcoder::JobState::PostFinished(const bool success) {
if (success) {
emit parent_->LogLine(tr("Successfully written %1").arg(QDir::toNativeSeparators(job_.output)));
@@ -235,37 +235,37 @@ QList<TranscoderPreset> Transcoder::GetAllPresets() {
}
TranscoderPreset Transcoder::PresetForFileType(Song::FileType type) {
TranscoderPreset Transcoder::PresetForFileType(const Song::FileType filetype) {
switch (type) {
switch (filetype) {
case Song::FileType_WAV:
return TranscoderPreset(type, "Wav", "wav", QString(), "audio/x-wav");
return TranscoderPreset(filetype, "Wav", "wav", QString(), "audio/x-wav");
case Song::FileType_FLAC:
return TranscoderPreset(type, "FLAC", "flac", "audio/x-flac");
return TranscoderPreset(filetype, "FLAC", "flac", "audio/x-flac");
case Song::FileType_WavPack:
return TranscoderPreset(type, "WavPack", "wv", "audio/x-wavpack");
return TranscoderPreset(filetype, "WavPack", "wv", "audio/x-wavpack");
case Song::FileType_OggFlac:
return TranscoderPreset(type, "Ogg FLAC", "ogg", "audio/x-flac", "application/ogg");
return TranscoderPreset(filetype, "Ogg FLAC", "ogg", "audio/x-flac", "application/ogg");
case Song::FileType_OggVorbis:
return TranscoderPreset(type, "Ogg Vorbis", "ogg", "audio/x-vorbis", "application/ogg");
return TranscoderPreset(filetype, "Ogg Vorbis", "ogg", "audio/x-vorbis", "application/ogg");
case Song::FileType_OggOpus:
return TranscoderPreset(type, "Ogg Opus", "opus", "audio/x-opus", "application/ogg");
return TranscoderPreset(filetype, "Ogg Opus", "opus", "audio/x-opus", "application/ogg");
case Song::FileType_OggSpeex:
return TranscoderPreset(type, "Ogg Speex", "spx", "audio/x-speex", "application/ogg");
return TranscoderPreset(filetype, "Ogg Speex", "spx", "audio/x-speex", "application/ogg");
case Song::FileType_MPEG:
return TranscoderPreset(type, "MP3", "mp3", "audio/mpeg, mpegversion=(int)1, layer=(int)3");
return TranscoderPreset(filetype, "MP3", "mp3", "audio/mpeg, mpegversion=(int)1, layer=(int)3");
case Song::FileType_MP4:
return TranscoderPreset(type, "M4A AAC", "mp4", "audio/mpeg, mpegversion=(int)4", "audio/mp4");
return TranscoderPreset(filetype, "M4A AAC", "mp4", "audio/mpeg, mpegversion=(int)4", "audio/mp4");
case Song::FileType_ASF:
return TranscoderPreset(type, "Windows Media audio", "wma", "audio/x-wma", "video/x-ms-asf");
return TranscoderPreset(filetype, "Windows Media audio", "wma", "audio/x-wma", "video/x-ms-asf");
default:
qLog(Warning) << "Unsupported format in PresetForFileType:" << type;
qLog(Warning) << "Unsupported format in PresetForFileType:" << filetype;
return TranscoderPreset();
}
}
Song::FileType Transcoder::PickBestFormat(QList<Song::FileType> supported) {
Song::FileType Transcoder::PickBestFormat(const QList<Song::FileType> &supported) {
if (supported.isEmpty()) return Song::FileType_Unknown;
@@ -282,7 +282,7 @@ Song::FileType Transcoder::PickBestFormat(QList<Song::FileType> supported) {
}
QString Transcoder::GetFile(const QString &input, const TranscoderPreset &preset, const QString output) {
QString Transcoder::GetFile(const QString &input, const TranscoderPreset &preset, const QString &output) {
QFileInfo fileinfo_output;
@@ -500,7 +500,7 @@ bool Transcoder::event(QEvent *e) {
gst_bus_set_sync_handler(gst_pipeline_get_bus(GST_PIPELINE(finished_event->state_->pipeline_)), nullptr, nullptr, nullptr);
// Remove it from the list - this will also destroy the GStreamer pipeline
current_jobs_.erase(it);
current_jobs_.erase(it); // clazy:exclude=strict-iterators
// Emit the finished signal
emit JobComplete(input, output, finished_event->success_);
@@ -535,7 +535,7 @@ void Transcoder::Cancel() {
}
// Remove the job, this destroys the GStreamer pipeline too
it = current_jobs_.erase(it);
it = current_jobs_.erase(it); // clazy:exclude=strict-iterators
}
}

View File

@@ -40,10 +40,10 @@
#include "core/song.h"
struct TranscoderPreset {
explicit TranscoderPreset() : type_(Song::FileType_Unknown) {}
TranscoderPreset(Song::FileType type, const QString &name, const QString &extension, const QString &codec_mimetype, const QString &muxer_mimetype_ = QString());
explicit TranscoderPreset() : filetype_(Song::FileType_Unknown) {}
TranscoderPreset(const Song::FileType filetype, const QString &name, const QString &extension, const QString &codec_mimetype, const QString &muxer_mimetype_ = QString());
Song::FileType type_;
Song::FileType filetype_;
QString name_;
QString extension_;
QString codec_mimetype_;
@@ -57,14 +57,14 @@ class Transcoder : public QObject {
public:
explicit Transcoder(QObject *parent = nullptr, const QString &settings_postfix = "");
static TranscoderPreset PresetForFileType(Song::FileType type);
static TranscoderPreset PresetForFileType(const Song::FileType filetype);
static QList<TranscoderPreset> GetAllPresets();
static Song::FileType PickBestFormat(QList<Song::FileType> supported);
static Song::FileType PickBestFormat(const QList<Song::FileType> &supported);
int max_threads() const { return max_threads_; }
void set_max_threads(int count) { max_threads_ = count; }
QString GetFile(const QString &input, const TranscoderPreset &preset, const QString output = QString());
QString GetFile(const QString &input, const TranscoderPreset &preset, const QString &output = QString());
void AddJob(const QString &input, const TranscoderPreset &preset, const QString &output);
QMap<QString, float> GetProgress() const;
@@ -99,13 +99,15 @@ class Transcoder : public QObject {
convert_element_(nullptr) {}
~JobState();
void PostFinished(bool success);
void PostFinished(const bool success);
void ReportError(GstMessage *msg);
Job job_;
Transcoder *parent_;
GstElement *pipeline_;
GstElement *convert_element_;
private:
Q_DISABLE_COPY(JobState)
};
// Event passed from a GStreamer callback to the Transcoder when a job finishes.
@@ -116,6 +118,8 @@ class Transcoder : public QObject {
JobState *state_;
bool success_;
private:
Q_DISABLE_COPY(JobFinishedEvent)
};
enum StartJobStatus {

View File

@@ -30,6 +30,8 @@
class Ui_TranscoderOptionsAAC;
class TranscoderOptionsAAC : public TranscoderOptionsInterface {
Q_OBJECT
public:
explicit TranscoderOptionsAAC(QWidget *parent = nullptr);
~TranscoderOptionsAAC() override;

View File

@@ -30,6 +30,8 @@
class Ui_TranscoderOptionsASF;
class TranscoderOptionsASF : public TranscoderOptionsInterface {
Q_OBJECT
public:
explicit TranscoderOptionsASF(QWidget *parent = nullptr);
~TranscoderOptionsASF() override;

View File

@@ -30,6 +30,8 @@
class Ui_TranscoderOptionsFLAC;
class TranscoderOptionsFLAC : public TranscoderOptionsInterface {
Q_OBJECT
public:
explicit TranscoderOptionsFLAC(QWidget *parent = nullptr);
~TranscoderOptionsFLAC() override;

View File

@@ -27,6 +27,8 @@
#include <QString>
class TranscoderOptionsInterface : public QWidget {
Q_OBJECT
public:
explicit TranscoderOptionsInterface(QWidget *parent) : QWidget(parent) {}
~TranscoderOptionsInterface() override {}

View File

@@ -30,6 +30,8 @@
class Ui_TranscoderOptionsOpus;
class TranscoderOptionsOpus : public TranscoderOptionsInterface {
Q_OBJECT
public:
explicit TranscoderOptionsOpus(QWidget *parent = nullptr);
~TranscoderOptionsOpus() override;

View File

@@ -30,6 +30,8 @@
class Ui_TranscoderOptionsSpeex;
class TranscoderOptionsSpeex : public TranscoderOptionsInterface {
Q_OBJECT
public:
explicit TranscoderOptionsSpeex(QWidget *parent = nullptr);
~TranscoderOptionsSpeex() override;

View File

@@ -50,7 +50,7 @@ void TranscoderOptionsVorbis::Load() {
#define GET_BITRATE(variable, property) \
int variable = s.value(property, -1).toInt(); \
variable = variable == -1 ? 0 : variable / 1000
(variable) = ((variable) == -1 ? 0 : (variable) / 1000)
GET_BITRATE(bitrate, "bitrate");
GET_BITRATE(min_bitrate, "min-bitrate");
@@ -73,8 +73,8 @@ void TranscoderOptionsVorbis::Save() {
s.beginGroup(kSettingsGroup + settings_postfix_);
#define GET_BITRATE(variable, ui_slider) \
int variable = ui_slider->value(); \
variable = variable == 0 ? -1 : variable * 1000
int variable = (ui_slider)->value(); \
(variable) = ((variable) == 0 ? -1 : (variable) * 1000)
GET_BITRATE(bitrate, ui_->bitrate_slider);
GET_BITRATE(min_bitrate, ui_->min_bitrate_slider);

View File

@@ -30,6 +30,8 @@
class Ui_TranscoderOptionsVorbis;
class TranscoderOptionsVorbis : public TranscoderOptionsInterface {
Q_OBJECT
public:
explicit TranscoderOptionsVorbis(QWidget *parent = nullptr);
~TranscoderOptionsVorbis() override;

View File

@@ -29,6 +29,8 @@
class Ui_TranscoderOptionsWavPack;
class TranscoderOptionsWavPack : public TranscoderOptionsInterface {
Q_OBJECT
public:
explicit TranscoderOptionsWavPack(QWidget *parent = nullptr);
~TranscoderOptionsWavPack() override;