Formatting

This commit is contained in:
Jonas Kvinge 2021-06-12 20:53:23 +02:00
parent 427b9c1ebc
commit f786a17014
117 changed files with 444 additions and 434 deletions

View File

@ -56,7 +56,7 @@
template class Analyzer::Base<QWidget>;
#endif
Analyzer::Base::Base(QWidget *parent, uint scopeSize)
Analyzer::Base::Base(QWidget *parent, const uint scopeSize)
: QWidget(parent),
timeout_(40),
fht_(new FHT(scopeSize)),
@ -139,7 +139,7 @@ int Analyzer::Base::resizeExponent(int exp) {
}
int Analyzer::Base::resizeForBands(int bands) {
int Analyzer::Base::resizeForBands(const int bands) {
int exp = 0;
if (bands <= 8)

View File

@ -72,7 +72,7 @@ class Base : public QWidget {
virtual void framerateChanged() {}
protected:
explicit Base(QWidget*, uint scopeSize = 7);
explicit Base(QWidget*, const uint scopeSize = 7);
void hideEvent(QHideEvent*) override;
void showEvent(QShowEvent*) override;
@ -82,10 +82,10 @@ class Base : public QWidget {
void polishEvent();
int resizeExponent(int);
int resizeForBands(int);
int resizeForBands(const int);
virtual void init() {}
virtual void transform(Scope&);
virtual void analyze(QPainter& p, const Scope&, bool new_frame) = 0;
virtual void analyze(QPainter &p, const Scope&, const bool new_frame) = 0;
virtual void demo(QPainter &p);
protected:

View File

@ -65,11 +65,11 @@ BoomAnalyzer::BoomAnalyzer(QWidget* parent)
}
void BoomAnalyzer::changeK_barHeight(int newValue) {
void BoomAnalyzer::changeK_barHeight(const int newValue) {
K_barHeight_ = static_cast<double>(newValue) / 1000;
}
void BoomAnalyzer::changeF_peakSpeed(int newValue) {
void BoomAnalyzer::changeF_peakSpeed(const int newValue) {
F_peakSpeed_ = static_cast<double>(newValue) / 1000;
}
@ -110,7 +110,7 @@ void BoomAnalyzer::transform(Scope& s) {
}
void BoomAnalyzer::analyze(QPainter& p, const Scope& scope, bool new_frame) {
void BoomAnalyzer::analyze(QPainter &p, const Scope &scope, const bool new_frame) {
if (!new_frame || engine_->state() == Engine::Paused) {
p.drawPixmap(0, 0, canvas_);

View File

@ -45,7 +45,7 @@ class BoomAnalyzer : public Analyzer::Base {
static const char *kName;
void transform(Analyzer::Scope &s) override;
void analyze(QPainter &p, const Analyzer::Scope&, bool new_frame) override;
void analyze(QPainter &p, const Analyzer::Scope&, const bool new_frame) override;
public slots:
void changeK_barHeight(int);

View File

@ -78,7 +78,7 @@ SCollection::~SCollection() {
}
if (watcher_thread_) {
watcher_thread_->exit();
watcher_thread_->wait(5000 /* five seconds */);
watcher_thread_->wait(5000);
}
backend_->deleteLater();

View File

@ -93,6 +93,7 @@ void MacFSListener::UpdateStreamAsync() {
}
void MacFSListener::UpdateStream() {
if (stream_) {
FSEventStreamStop(stream_);
FSEventStreamInvalidate(stream_);
@ -123,5 +124,5 @@ void MacFSListener::UpdateStream() {
FSEventStreamScheduleWithRunLoop(stream_, run_loop_, kCFRunLoopDefaultMode);
FSEventStreamStart(stream_);
}
}

View File

@ -152,7 +152,7 @@ int DeviceDatabaseBackend::AddDevice(const Device &device) {
}
void DeviceDatabaseBackend::RemoveDevice(int id) {
void DeviceDatabaseBackend::RemoveDevice(const int id) {
QMutexLocker l(db_->Mutex());
QSqlDatabase db(db_->Connect());
@ -176,7 +176,7 @@ void DeviceDatabaseBackend::RemoveDevice(int id) {
}
void DeviceDatabaseBackend::SetDeviceOptions(int id, const QString &friendly_name, const QString &icon_name, MusicStorage::TranscodeMode mode, Song::FileType format) {
void DeviceDatabaseBackend::SetDeviceOptions(const int id, const QString &friendly_name, const QString &icon_name, const MusicStorage::TranscodeMode mode, const Song::FileType format) {
QMutexLocker l(db_->Mutex());
QSqlDatabase db(db_->Connect());
@ -198,4 +198,3 @@ void DeviceDatabaseBackend::SetDeviceOptions(int id, const QString &friendly_nam
db_->CheckErrors(q);
}

View File

@ -65,9 +65,9 @@ class DeviceDatabaseBackend : public QObject {
DeviceList GetAllDevices();
int AddDevice(const Device &device);
void RemoveDevice(int id);
void RemoveDevice(const int id);
void SetDeviceOptions(int id, const QString &friendly_name, const QString &icon_name, MusicStorage::TranscodeMode mode, Song::FileType format);
void SetDeviceOptions(const int id, const QString &friendly_name, const QString &icon_name, const MusicStorage::TranscodeMode mode, const Song::FileType format);
private slots:
void Exit();

View File

@ -107,7 +107,7 @@ void GPodDevice::Close() {
}
void GPodDevice::LoadFinished(Itdb_iTunesDB *db, bool success) {
void GPodDevice::LoadFinished(Itdb_iTunesDB *db, const bool success) {
QMutexLocker l(&db_mutex_);
db_ = db;

View File

@ -73,7 +73,7 @@ class GPodDevice : public ConnectedDevice, public virtual MusicStorage {
void FinishDelete(bool success) override;
protected slots:
void LoadFinished(Itdb_iTunesDB *db, bool success);
void LoadFinished(Itdb_iTunesDB *db, const bool success);
void LoaderError(const QString &message);
protected:

View File

@ -49,7 +49,7 @@ class DeviceManager;
bool MtpDevice::sInitializedLibMTP = false;
MtpDevice::MtpDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, DeviceManager *manager, Application *app, int database_id, bool first_time)
MtpDevice::MtpDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, DeviceManager *manager, Application *app, const int database_id, const bool first_time)
: ConnectedDevice(url, lister, unique_id, manager, app, database_id, first_time),
loader_(nullptr),
loader_thread_(nullptr),
@ -112,7 +112,7 @@ void MtpDevice::Close() {
}
void MtpDevice::LoadFinished(bool success, MtpConnection *connection) {
void MtpDevice::LoadFinished(const bool success, MtpConnection *connection) {
connection_.reset(connection);
@ -190,7 +190,7 @@ bool MtpDevice::CopyToStorage(const CopyJob &job) {
}
void MtpDevice::FinishCopy(bool success) {
void MtpDevice::FinishCopy(const bool success) {
if (success) {
if (!songs_to_add_.isEmpty()) backend_->AddOrUpdateSongs(songs_to_add_);
@ -234,7 +234,7 @@ bool MtpDevice::DeleteFromStorage(const DeleteJob &job) {
}
void MtpDevice::FinishDelete(bool success) { FinishCopy(success); }
void MtpDevice::FinishDelete(const bool success) { FinishCopy(success); }
bool MtpDevice::GetSupportedFiletypes(QList<Song::FileType> *ret) {
@ -286,4 +286,3 @@ bool MtpDevice::GetSupportedFiletypes(QList<Song::FileType> *ret, LIBMTP_mtpdevi
return true;
}

View File

@ -48,7 +48,7 @@ class MtpDevice : public ConnectedDevice {
Q_OBJECT
public:
Q_INVOKABLE MtpDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, DeviceManager *manager, Application *app, int database_id, bool first_time);
Q_INVOKABLE MtpDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, DeviceManager *manager, Application *app, const int database_id, const bool first_time);
~MtpDevice() override;
static QStringList url_schemes() { return QStringList() << "mtp"; }
@ -64,11 +64,11 @@ class MtpDevice : public ConnectedDevice {
bool StartCopy(QList<Song::FileType> *supported_types) override;
bool CopyToStorage(const CopyJob &job) override;
void FinishCopy(bool success) override;
void FinishCopy(const bool success) override;
void StartDelete() override;
bool DeleteFromStorage(const DeleteJob &job) override;
void FinishDelete(bool success) override;
void FinishDelete(const bool success) override;
private slots:
void LoadFinished(bool success, MtpConnection *connection);

View File

@ -168,7 +168,7 @@ void Equalizer::AddPreset(const QString& name, const Params& params) {
}
}
void Equalizer::PresetChanged(int index) {
void Equalizer::PresetChanged(const int index) {
PresetChanged(ui_->preset->itemData(index).toString());
}
@ -292,7 +292,7 @@ void Equalizer::StereoBalancerEnabledChangedSlot(const bool enabled) {
}
void Equalizer::StereoBalanceSliderChanged(int) {
void Equalizer::StereoBalanceSliderChanged(const int) {
emit StereoBalanceChanged(stereo_balance());
Save();

View File

@ -81,7 +81,7 @@ class Equalizer : public QDialog {
void EqualizerEnabledChangedSlot(const bool enabled);
void EqualizerParametersChangedSlot();
void PresetChanged(const QString &name);
void PresetChanged(int index);
void PresetChanged(const int index);
void SavePreset();
void DelPreset();
void Save();

View File

@ -43,6 +43,7 @@ class MacMonitorWrapper {
};
bool GlobalShortcutGrabber::HandleMacEvent(NSEvent *event) {
ret_ = mac::KeySequenceFromNSEvent(event);
UpdateText();
if ([[event charactersIgnoringModifiers] length] != 0) {
@ -50,13 +51,16 @@ bool GlobalShortcutGrabber::HandleMacEvent(NSEvent* event) {
return true;
}
return ret_ == QKeySequence(Qt::Key_Escape);
}
void GlobalShortcutGrabber::SetupMacEventHandler() {
id monitor = [NSEvent addLocalMonitorForEventsMatchingMask: NSEventMaskKeyDown handler:^(NSEvent *event) {
return HandleMacEvent(event) ? event : nil;
}];
wrapper_ = new MacMonitorWrapper(monitor);
}
void GlobalShortcutGrabber::TeardownMacEventHandler() { delete wrapper_; }

View File

@ -88,7 +88,8 @@ bool GlobalShortcutsBackendMacOS::DoRegister() {
// Always enable media keys.
mac::SetShortcutHandler(this);
for (const GlobalShortcutsManager::Shortcut& shortcut : manager_->shortcuts().values()) {
QList<GlobalShortcutsManager::Shortcut> shortcuts = manager_->shortcuts().values();
for (const GlobalShortcutsManager::Shortcut &shortcut : shortcuts) {
shortcuts_[shortcut.action->shortcut()] = shortcut.action;
}

View File

@ -43,7 +43,8 @@ bool GlobalShortcutsBackendSystem::DoRegister() {
if (!gshortcut_init_) gshortcut_init_ = new GlobalShortcut(this);
for (const GlobalShortcutsManager::Shortcut &shortcut : manager_->shortcuts().values()) {
QList<GlobalShortcutsManager::Shortcut> shortcuts = manager_->shortcuts().values();
for (const GlobalShortcutsManager::Shortcut &shortcut : shortcuts) {
AddShortcut(shortcut.action);
}

View File

@ -113,7 +113,7 @@ void AcoustidClient::CancelAll() {
namespace {
// Struct used when extracting results in RequestFinished
struct IdSource {
IdSource(const QString& id, int source)
IdSource(const QString &id, const int source)
: id_(id), nb_sources_(source) {}
bool operator<(const IdSource &other) const {

View File

@ -557,17 +557,17 @@ QPoint OSDPretty::current_pos() const {
}
void OSDPretty::set_background_color(QRgb color) {
void OSDPretty::set_background_color(const QRgb color) {
background_color_ = color;
if (isVisible()) update();
}
void OSDPretty::set_background_opacity(qreal opacity) {
void OSDPretty::set_background_opacity(const qreal opacity) {
background_opacity_ = opacity;
if (isVisible()) update();
}
void OSDPretty::set_foreground_color(QRgb color) {
void OSDPretty::set_foreground_color(const QRgb color) {
foreground_color_ = QColor(color);
@ -579,11 +579,11 @@ void OSDPretty::set_foreground_color(QRgb color) {
}
void OSDPretty::set_popup_duration(int msec) {
void OSDPretty::set_popup_duration(const int msec) {
timeout_->setInterval(msec);
}
void OSDPretty::set_font(QFont font) {
void OSDPretty::set_font(const QFont font) {
font_ = font;

View File

@ -77,13 +77,13 @@ class OSDPretty : public QWidget {
void ShowMessage(const QString &summary, const QString &message, const QImage &image);
// Popup duration in seconds. Only used in Mode_Popup.
void set_popup_duration(int msec);
void set_popup_duration(const int msec);
// These will get overwritten when ReloadSettings() is called
void set_foreground_color(QRgb color);
void set_background_color(QRgb color);
void set_background_opacity(qreal opacity);
void set_font(QFont font);
void set_foreground_color(const QRgb color);
void set_background_color(const QRgb color);
void set_background_opacity(const qreal opacity);
void set_font(const QFont font);
QRgb foreground_color() const { return foreground_color_.rgb(); }
QRgb background_color() const { return background_color_.rgb(); }
@ -104,7 +104,7 @@ class OSDPretty : public QWidget {
void setVisible(bool visible) override;
bool toggle_mode() const { return toggle_mode_; }
void set_toggle_mode(bool toggle_mode) { toggle_mode_ = toggle_mode; }
void set_toggle_mode(const bool toggle_mode) { toggle_mode_ = toggle_mode; }
signals:
void PositionChanged();

View File

@ -81,8 +81,8 @@ class PlaylistSequence : public QWidget {
void ShuffleModeChanged(PlaylistSequence::ShuffleMode mode);
private slots:
void RepeatActionTriggered(QAction *);
void ShuffleActionTriggered(QAction *);
void RepeatActionTriggered(QAction *action);
void ShuffleActionTriggered(QAction *action);
private:
void Load();

View File

@ -69,7 +69,8 @@ void FileViewList::contextMenuEvent(QContextMenuEvent *e) {
QList<QUrl> FileViewList::UrlListFromSelection() const {
QList<QUrl> urls;
for (const QModelIndex& index : menu_selection_.indexes()) {
const QModelIndexList indexes = menu_selection_.indexes();
for (const QModelIndex &index : indexes) {
if (index.column() == 0)
urls << QUrl::fromLocalFile(qobject_cast<QFileSystemModel*>(model())->fileInfo(index).canonicalFilePath());
}
@ -119,7 +120,8 @@ MimeData *FileViewList::MimeDataFromSelection() const {
QStringList FileViewList::FilenamesFromSelection() const {
QStringList filenames;
for (const QModelIndex& index : menu_selection_.indexes()) {
const QModelIndexList indexes = menu_selection_.indexes();
for (const QModelIndex &index : indexes) {
if (index.column() == 0)
filenames << qobject_cast<QFileSystemModel*>(model())->filePath(index);
}

View File

@ -59,7 +59,6 @@ const QRgb FreeSpaceBar::kColorBar1 = qRgb(250, 148, 76);
const QRgb FreeSpaceBar::kColorBar2 = qRgb(214, 102, 24);
const QRgb FreeSpaceBar::kColorBorder = qRgb(174, 168, 162);
FreeSpaceBar::FreeSpaceBar(QWidget *parent)
: QWidget(parent),
free_(100),
@ -232,17 +231,21 @@ void FreeSpaceBar::DrawText(QPainter* p, const QRect &r) {
}
QString FreeSpaceBar::TextForSize(const QString &prefix, qint64 size) const {
QString FreeSpaceBar::TextForSize(const QString &prefix, const qint64 size) const {
QString ret;
if (size > 0)
if (size > 0) {
ret = Utilities::PrettySize(size);
else if (size < 0)
}
else if (size < 0) {
ret = "-" + Utilities::PrettySize(-size);
else
}
else {
ret = "0 MB";
}
if (!prefix.isEmpty()) ret.prepend(prefix + " ");
return ret;
}

View File

@ -56,9 +56,9 @@ class FreeSpaceBar : public QWidget {
static const QRgb kColorBar2;
static const QRgb kColorBorder;
void set_free_bytes(qint64 bytes) { free_ = bytes; update(); }
void set_additional_bytes(qint64 bytes) { additional_ = bytes; update(); }
void set_total_bytes(qint64 bytes) { total_ = bytes; update(); }
void set_free_bytes(const qint64 bytes) { free_ = bytes; update(); }
void set_additional_bytes(const qint64 bytes) { additional_ = bytes; update(); }
void set_total_bytes(const qint64 bytes) { total_ = bytes; update(); }
void set_free_text(const QString &text) { free_text_ = text; update(); }
void set_additional_text(const QString &text) { additional_text_ = text; update(); }
@ -77,7 +77,7 @@ class FreeSpaceBar : public QWidget {
QColor color;
};
QString TextForSize(const QString &prefix, qint64 size) const;
QString TextForSize(const QString &prefix, const qint64 size) const;
void DrawBar(QPainter *p, const QRect &r);
void DrawText(QPainter *p, const QRect &r);

View File

@ -48,7 +48,7 @@
#include <QFlags>
#include <QtEvents>
SliderSlider::SliderSlider(Qt::Orientation orientation, QWidget* parent, uint max)
SliderSlider::SliderSlider(const Qt::Orientation orientation, QWidget *parent, const uint max)
: QSlider(orientation, parent),
sliding_(false),
outside_(false),

View File

@ -44,7 +44,7 @@ class SliderSlider : public QSlider {
Q_OBJECT
public:
explicit SliderSlider(Qt::Orientation, QWidget*, const uint max = 0);
explicit SliderSlider(const Qt::Orientation, QWidget*, const uint max = 0);
virtual void setValue(int);