Clang-Tidy and Clazy fixes
This commit is contained in:
@@ -28,6 +28,8 @@
|
||||
#include <QPalette>
|
||||
|
||||
class Appearance : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Appearance(QObject *parent = nullptr);
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "application.h"
|
||||
|
||||
#include <functional>
|
||||
#include <chrono>
|
||||
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
@@ -90,6 +91,8 @@
|
||||
# include "moodbar/moodbarloader.h"
|
||||
#endif
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
class ApplicationImpl {
|
||||
public:
|
||||
explicit ApplicationImpl(Application *app) :
|
||||
@@ -102,7 +105,7 @@ class ApplicationImpl {
|
||||
database_([=]() {
|
||||
Database *db = new Database(app, app);
|
||||
app->MoveToNewThread(db);
|
||||
QTimer::singleShot(30000, db, &Database::DoBackup);
|
||||
QTimer::singleShot(30s, db, &Database::DoBackup);
|
||||
return db;
|
||||
}),
|
||||
appearance_([=]() { return new Appearance(app); }),
|
||||
@@ -288,7 +291,7 @@ void Application::Exit() {
|
||||
|
||||
void Application::ExitReceived() {
|
||||
|
||||
QObject *obj = static_cast<QObject*>(sender());
|
||||
QObject *obj = sender();
|
||||
QObject::disconnect(obj, nullptr, this, nullptr);
|
||||
|
||||
qLog(Debug) << obj << "successfully exited.";
|
||||
|
||||
@@ -362,7 +362,7 @@ void CommandlineOptions::Load(const QByteArray &serialized) {
|
||||
}
|
||||
|
||||
QString CommandlineOptions::tr(const char *source_text) {
|
||||
return QObject::tr(source_text);
|
||||
return QObject::tr(source_text); // clazy:exclude=tr-non-literal
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &s, const CommandlineOptions &a) {
|
||||
|
||||
@@ -487,7 +487,7 @@ bool Database::CheckErrors(const QSqlQuery &query) {
|
||||
|
||||
}
|
||||
|
||||
bool Database::IntegrityCheck(QSqlDatabase db) {
|
||||
bool Database::IntegrityCheck(const QSqlDatabase &db) {
|
||||
|
||||
qLog(Debug) << "Starting database integrity check";
|
||||
int task_id = app_->task_manager()->StartTask(tr("Integrity check"));
|
||||
@@ -559,7 +559,7 @@ void Database::BackupFile(const QString &filename) {
|
||||
sqlite3 *source_connection = nullptr;
|
||||
sqlite3 *dest_connection = nullptr;
|
||||
|
||||
BOOST_SCOPE_EXIT((&source_connection)(&dest_connection)(task_id)(app_)) {
|
||||
BOOST_SCOPE_EXIT((&source_connection)(&dest_connection)(task_id)(app_)) { // clazy:exclude=rule-of-three NOLINT(google-explicit-constructor)
|
||||
// Harmless to call sqlite3_close() with a nullptr pointer.
|
||||
sqlite3_close(source_connection);
|
||||
sqlite3_close(dest_connection);
|
||||
|
||||
@@ -103,7 +103,7 @@ class Database : public QObject {
|
||||
void UpdateDatabaseSchema(int version, QSqlDatabase &db);
|
||||
void UrlEncodeFilenameColumn(const QString &table, QSqlDatabase &db);
|
||||
QStringList SongsTables(QSqlDatabase &db, int schema_version) const;
|
||||
bool IntegrityCheck(QSqlDatabase db);
|
||||
bool IntegrityCheck(const QSqlDatabase &db);
|
||||
void BackupFile(const QString &filename);
|
||||
bool OpenDatabase(const QString &filename, sqlite3 **connection) const;
|
||||
|
||||
@@ -140,6 +140,8 @@ class Database : public QObject {
|
||||
};
|
||||
|
||||
class MemoryDatabase : public Database {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MemoryDatabase(Application *app, QObject *parent = nullptr)
|
||||
: Database(app, parent, ":memory:") {}
|
||||
|
||||
@@ -35,8 +35,9 @@
|
||||
|
||||
const int DeleteFiles::kBatchSize = 50;
|
||||
|
||||
DeleteFiles::DeleteFiles(TaskManager *task_manager, std::shared_ptr<MusicStorage> storage, const bool use_trash)
|
||||
: thread_(nullptr),
|
||||
DeleteFiles::DeleteFiles(TaskManager *task_manager, std::shared_ptr<MusicStorage> storage, const bool use_trash, QObject *parent)
|
||||
: QObject(parent),
|
||||
thread_(nullptr),
|
||||
task_manager_(task_manager),
|
||||
storage_(storage),
|
||||
use_trash_(use_trash),
|
||||
@@ -68,6 +69,7 @@ void DeleteFiles::Start(const SongList &songs) {
|
||||
void DeleteFiles::Start(const QStringList &filenames) {
|
||||
|
||||
SongList songs;
|
||||
songs.reserve(filenames.count());
|
||||
for (const QString &filename : filenames) {
|
||||
Song song;
|
||||
song.set_url(QUrl::fromLocalFile(filename));
|
||||
|
||||
@@ -39,7 +39,7 @@ class DeleteFiles : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DeleteFiles(TaskManager *task_manager, std::shared_ptr<MusicStorage> storage, const bool use_trash);
|
||||
explicit DeleteFiles(TaskManager *task_manager, std::shared_ptr<MusicStorage> storage, const bool use_trash, QObject *parent = nullptr);
|
||||
~DeleteFiles() override;
|
||||
|
||||
static const int kBatchSize;
|
||||
|
||||
@@ -39,6 +39,8 @@ class FilesystemMusicStorage : public virtual MusicStorage {
|
||||
|
||||
private:
|
||||
QString root_;
|
||||
|
||||
Q_DISABLE_COPY(FilesystemMusicStorage)
|
||||
};
|
||||
|
||||
#endif // FILESYSTEMMUSICSTORAGE_H
|
||||
|
||||
@@ -35,7 +35,7 @@ struct IconProperties {
|
||||
bool allow_system_icon;
|
||||
};
|
||||
|
||||
static const QMap<QString, IconProperties> iconmapper_ = {
|
||||
static const QMap<QString, IconProperties> iconmapper_ = { // clazy:exclude=non-pod-global-static
|
||||
|
||||
{ "albums", { {"media-optical"}} },
|
||||
{ "alsa", { {}} },
|
||||
|
||||
@@ -13,11 +13,15 @@ class GlobalShortcutsBackendMacOS;
|
||||
|
||||
class PlatformInterface {
|
||||
public:
|
||||
PlatformInterface() = default;
|
||||
virtual ~PlatformInterface() {}
|
||||
|
||||
// Called when the application should show itself.
|
||||
virtual void Activate() = 0;
|
||||
virtual bool LoadUrl(const QString &url) = 0;
|
||||
|
||||
virtual ~PlatformInterface() {}
|
||||
private:
|
||||
Q_DISABLE_COPY(PlatformInterface)
|
||||
};
|
||||
|
||||
namespace mac {
|
||||
|
||||
@@ -1745,7 +1745,7 @@ void MainWindow::PlaylistMenuHidden() {
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::PlaylistRightClick(const QPoint &global_pos, const QModelIndex &index) {
|
||||
void MainWindow::PlaylistRightClick(const QPoint global_pos, const QModelIndex &index) {
|
||||
|
||||
QModelIndex source_index = index;
|
||||
if (index.model() == app_->playlist_manager()->current()->proxy()) {
|
||||
@@ -2148,6 +2148,7 @@ void MainWindow::AddFile() {
|
||||
|
||||
// Convert to URLs
|
||||
QList<QUrl> urls;
|
||||
urls.reserve(file_names.count());
|
||||
for (const QString &path : file_names) {
|
||||
urls << QUrl::fromLocalFile(QFileInfo(path).canonicalFilePath());
|
||||
}
|
||||
@@ -2550,6 +2551,7 @@ void MainWindow::CopyFilesToDevice(const QList<QUrl> &urls) {
|
||||
void MainWindow::EditFileTags(const QList<QUrl> &urls) {
|
||||
|
||||
SongList songs;
|
||||
songs.reserve(urls.count());
|
||||
for (const QUrl &url : urls) {
|
||||
Song song;
|
||||
song.set_url(url);
|
||||
@@ -2628,8 +2630,10 @@ void MainWindow::PlaylistCopyUrl() {
|
||||
|
||||
void MainWindow::PlaylistQueue() {
|
||||
|
||||
const QModelIndexList selected_rows = ui_->playlist->view()->selectionModel()->selectedRows();
|
||||
QModelIndexList indexes;
|
||||
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
||||
indexes.reserve(selected_rows.count());
|
||||
for (const QModelIndex &proxy_index : selected_rows) {
|
||||
indexes << app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
|
||||
}
|
||||
|
||||
@@ -2639,8 +2643,10 @@ void MainWindow::PlaylistQueue() {
|
||||
|
||||
void MainWindow::PlaylistQueuePlayNext() {
|
||||
|
||||
QModelIndexList selected_rows = ui_->playlist->view()->selectionModel()->selectedRows();
|
||||
QModelIndexList indexes;
|
||||
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
||||
indexes.reserve(selected_rows.count());
|
||||
for (const QModelIndex &proxy_index : selected_rows) {
|
||||
indexes << app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
|
||||
}
|
||||
|
||||
@@ -2650,9 +2656,10 @@ void MainWindow::PlaylistQueuePlayNext() {
|
||||
|
||||
void MainWindow::PlaylistSkip() {
|
||||
|
||||
const QModelIndexList selected_rows = ui_->playlist->view()->selectionModel()->selectedRows();
|
||||
QModelIndexList indexes;
|
||||
|
||||
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
||||
indexes.reserve(selected_rows.count());
|
||||
for (const QModelIndex &proxy_index : selected_rows) {
|
||||
indexes << app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
|
||||
}
|
||||
|
||||
@@ -2904,7 +2911,7 @@ void MainWindow::AutoCompleteTagsAccepted() {
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::HandleNotificationPreview(OSDBase::Behaviour type, QString line1, QString line2) {
|
||||
void MainWindow::HandleNotificationPreview(const OSDBase::Behaviour type, const QString &line1, const QString &line2) {
|
||||
|
||||
if (!app_->playlist_manager()->current()->GetAllSongs().isEmpty()) {
|
||||
// Show a preview notification for the first song in the current playlist
|
||||
|
||||
@@ -149,7 +149,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
void ForceShowOSD(const Song &song, const bool toggle);
|
||||
|
||||
void PlaylistMenuHidden();
|
||||
void PlaylistRightClick(const QPoint &global_pos, const QModelIndex &idx);
|
||||
void PlaylistRightClick(const QPoint global_pos, const QModelIndex &idx);
|
||||
void PlaylistCurrentChanged(const QModelIndex ¤t);
|
||||
void PlaylistViewSelectionModelChanged();
|
||||
void PlaylistPlay();
|
||||
@@ -246,7 +246,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
void Exit();
|
||||
void DoExit();
|
||||
|
||||
void HandleNotificationPreview(const OSDBase::Behaviour type, QString line1, QString line2);
|
||||
void HandleNotificationPreview(const OSDBase::Behaviour type, const QString &line1, const QString &line2);
|
||||
|
||||
void ShowConsole();
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ using boost::multi_index::multi_index_container;
|
||||
using boost::multi_index::ordered_unique;
|
||||
using boost::multi_index::tag;
|
||||
|
||||
std::size_t hash_value(const QModelIndex &idx) { return qHash(idx); }
|
||||
size_t hash_value(const QModelIndex &idx) { return qHash(idx); }
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -543,6 +543,7 @@ bool MergedProxyModel::IsKnownModel(const QAbstractItemModel *model) const {
|
||||
QModelIndexList MergedProxyModel::mapFromSource(const QModelIndexList &source_indexes) const {
|
||||
|
||||
QModelIndexList ret;
|
||||
ret.reserve(source_indexes.count());
|
||||
for (const QModelIndex &idx : source_indexes) {
|
||||
ret << mapFromSource(idx);
|
||||
}
|
||||
@@ -553,6 +554,7 @@ QModelIndexList MergedProxyModel::mapFromSource(const QModelIndexList &source_in
|
||||
QModelIndexList MergedProxyModel::mapToSource(const QModelIndexList &proxy_indexes) const {
|
||||
|
||||
QModelIndexList ret;
|
||||
ret.reserve(proxy_indexes.count());
|
||||
for (const QModelIndex &idx : proxy_indexes) {
|
||||
ret << mapToSource(idx);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class MimeData : public QMimeData {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MimeData(bool clear = false, bool play_now = false, bool enqueue = false, bool enqueue_next_now = false, bool open_in_new_playlist = false)
|
||||
explicit MimeData(const bool clear = false, const bool play_now = false, const bool enqueue = false, const bool enqueue_next_now = false, const bool open_in_new_playlist = false, QObject* = nullptr)
|
||||
: override_user_settings_(false),
|
||||
clear_first_(clear),
|
||||
play_now_(play_now),
|
||||
|
||||
@@ -143,7 +143,7 @@ Mpris2::Mpris2(Application *app, QObject *parent)
|
||||
desktop_files_ << QCoreApplication::applicationName().toLower();
|
||||
desktop_file_ = desktop_files_.first();
|
||||
|
||||
data_dirs_ = QString(getenv("XDG_DATA_DIRS")).split(":");
|
||||
data_dirs_ = QString(qgetenv("XDG_DATA_DIRS")).split(":");
|
||||
data_dirs_.append("/usr/local/share");
|
||||
data_dirs_.append("/usr/share");
|
||||
|
||||
@@ -208,17 +208,17 @@ void Mpris2::EmitNotification(const QString &name, const QVariant &val, const QS
|
||||
void Mpris2::EmitNotification(const QString &name) {
|
||||
|
||||
QVariant value;
|
||||
if (name == "PlaybackStatus") value = PlaybackStatus();
|
||||
else if (name == "LoopStatus") value = LoopStatus();
|
||||
else if (name == "Shuffle") value = Shuffle();
|
||||
else if (name == "Metadata") value = Metadata();
|
||||
else if (name == "Volume") value = Volume();
|
||||
else if (name == "Position") value = Position();
|
||||
else if (name == "CanPlay") value = CanPlay();
|
||||
else if (name == "CanPause") value = CanPause();
|
||||
else if (name == "CanSeek") value = CanSeek();
|
||||
else if (name == "CanGoNext") value = CanGoNext();
|
||||
else if (name == "CanGoPrevious") value = CanGoPrevious();
|
||||
if (name == "PlaybackStatus") value = PlaybackStatus(); // clazy:exclude=qt6-deprecated-api-fixes
|
||||
else if (name == "LoopStatus") value = LoopStatus(); // clazy:exclude=qt6-deprecated-api-fixes
|
||||
else if (name == "Shuffle") value = Shuffle(); // clazy:exclude=qt6-deprecated-api-fixes
|
||||
else if (name == "Metadata") value = Metadata(); // clazy:exclude=qt6-deprecated-api-fixes
|
||||
else if (name == "Volume") value = Volume(); // clazy:exclude=qt6-deprecated-api-fixes
|
||||
else if (name == "Position") value = Position(); // clazy:exclude=qt6-deprecated-api-fixes
|
||||
else if (name == "CanPlay") value = CanPlay(); // clazy:exclude=qt6-deprecated-api-fixes
|
||||
else if (name == "CanPause") value = CanPause(); // clazy:exclude=qt6-deprecated-api-fixes
|
||||
else if (name == "CanSeek") value = CanSeek(); // clazy:exclude=qt6-deprecated-api-fixes
|
||||
else if (name == "CanGoNext") value = CanGoNext(); // clazy:exclude=qt6-deprecated-api-fixes
|
||||
else if (name == "CanGoPrevious") value = CanGoPrevious(); // clazy:exclude=qt6-deprecated-api-fixes
|
||||
|
||||
if (value.isValid()) EmitNotification(name, value);
|
||||
|
||||
@@ -594,8 +594,10 @@ MprisPlaylistList Mpris2::GetPlaylists(quint32 index, quint32 max_count, const Q
|
||||
|
||||
Q_UNUSED(order);
|
||||
|
||||
QList<Playlist*> playlists = app_->playlist_manager()->GetAllPlaylists();
|
||||
MprisPlaylistList ret;
|
||||
for (Playlist *p : app_->playlist_manager()->GetAllPlaylists()) {
|
||||
ret.reserve(playlists.count());
|
||||
for (Playlist *p : playlists) {
|
||||
MprisPlaylist mpris_playlist;
|
||||
mpris_playlist.id = MakePlaylistPath(p->id());
|
||||
mpris_playlist.name = app_->playlist_manager()->GetPlaylistName(p->id());
|
||||
|
||||
@@ -32,27 +32,27 @@
|
||||
namespace mpris {
|
||||
|
||||
inline void AddMetadata(const QString &key, const QString &metadata, QVariantMap *map) {
|
||||
if (!metadata.isEmpty()) (*map)[key] = metadata;
|
||||
if (!metadata.isEmpty()) (*map)[key] = metadata; // clazy:exclude=qt6-deprecated-api-fixes
|
||||
}
|
||||
|
||||
inline void AddMetadataAsList(const QString &key, const QString &metadata, QVariantMap *map) {
|
||||
if (!metadata.isEmpty()) (*map)[key] = QStringList() << metadata;
|
||||
if (!metadata.isEmpty()) (*map)[key] = QStringList() << metadata; // clazy:exclude=qt6-deprecated-api-fixes
|
||||
}
|
||||
|
||||
inline void AddMetadata(const QString &key, int metadata, QVariantMap *map) {
|
||||
if (metadata > 0) (*map)[key] = metadata;
|
||||
if (metadata > 0) (*map)[key] = metadata; // clazy:exclude=qt6-deprecated-api-fixes
|
||||
}
|
||||
|
||||
inline void AddMetadata(const QString &key, qint64 metadata, QVariantMap *map) {
|
||||
if (metadata > 0) (*map)[key] = metadata;
|
||||
if (metadata > 0) (*map)[key] = metadata; // clazy:exclude=qt6-deprecated-api-fixes
|
||||
}
|
||||
|
||||
inline void AddMetadata(const QString &key, double metadata, QVariantMap *map) {
|
||||
if (metadata != 0.0) (*map)[key] = metadata;
|
||||
if (metadata != 0.0) (*map)[key] = metadata; // clazy:exclude=qt6-deprecated-api-fixes
|
||||
}
|
||||
|
||||
inline void AddMetadata(const QString &key, const QDateTime &metadata, QVariantMap *map) {
|
||||
if (metadata.isValid()) (*map)[key] = metadata;
|
||||
if (metadata.isValid()) (*map)[key] = metadata; // clazy:exclude=qt6-deprecated-api-fixes
|
||||
}
|
||||
|
||||
inline QString AsMPRISDateTimeType(const qint64 time) {
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
class QObject;
|
||||
|
||||
class MultiSortFilterProxy : public QSortFilterProxyModel {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MultiSortFilterProxy(QObject *parent = nullptr);
|
||||
|
||||
|
||||
@@ -92,6 +92,9 @@ class MusicStorage {
|
||||
virtual void FinishDelete(bool success) { Q_UNUSED(success); }
|
||||
|
||||
virtual void Eject() {}
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(MusicStorage)
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(MusicStorage*)
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QMutex>
|
||||
#include <QVariant>
|
||||
@@ -43,14 +41,15 @@ NetworkProxyFactory::NetworkProxyFactory()
|
||||
type_(QNetworkProxy::HttpProxy),
|
||||
port_(8080),
|
||||
use_authentication_(false) {
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
// Linux uses environment variables to pass proxy configuration information, which systemProxyForQuery doesn't support for some reason.
|
||||
|
||||
QStringList urls;
|
||||
urls << QString::fromLocal8Bit(getenv("HTTP_PROXY"));
|
||||
urls << QString::fromLocal8Bit(getenv("http_proxy"));
|
||||
urls << QString::fromLocal8Bit(getenv("ALL_PROXY"));
|
||||
urls << QString::fromLocal8Bit(getenv("all_proxy"));
|
||||
urls << QString::fromLocal8Bit(qgetenv("HTTP_PROXY"));
|
||||
urls << QString::fromLocal8Bit(qgetenv("http_proxy"));
|
||||
urls << QString::fromLocal8Bit(qgetenv("ALL_PROXY"));
|
||||
urls << QString::fromLocal8Bit(qgetenv("all_proxy"));
|
||||
|
||||
qLog(Debug) << "Detected system proxy URLs:" << urls;
|
||||
|
||||
@@ -92,6 +91,8 @@ void NetworkProxyFactory::ReloadSettings() {
|
||||
username_ = s.value("username").toString();
|
||||
password_ = s.value("password").toString();
|
||||
|
||||
s.endGroup();
|
||||
|
||||
}
|
||||
|
||||
QList<QNetworkProxy> NetworkProxyFactory::queryProxy(const QNetworkProxyQuery &query) {
|
||||
|
||||
@@ -27,7 +27,10 @@
|
||||
// This translator tries loading strings with an empty context if it can't find any others.
|
||||
|
||||
class PoTranslator : public QTranslator {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PoTranslator(QObject *parent = nullptr) : QTranslator(parent) {}
|
||||
QString translate(const char *context, const char *source_text, const char *disambiguation = nullptr, int n = -1) const override {
|
||||
Q_UNUSED(n);
|
||||
QString ret = QTranslator::translate(context, source_text, disambiguation);
|
||||
|
||||
@@ -41,6 +41,9 @@ class SettingsProvider {
|
||||
virtual void beginWriteArray(const QString &prefix, int size = -1) = 0;
|
||||
virtual void setArrayIndex(int i) = 0;
|
||||
virtual void endArray() = 0;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(SettingsProvider)
|
||||
};
|
||||
|
||||
class DefaultSettingsProvider : public SettingsProvider {
|
||||
@@ -58,6 +61,8 @@ class DefaultSettingsProvider : public SettingsProvider {
|
||||
|
||||
private:
|
||||
QSettings backend_;
|
||||
|
||||
Q_DISABLE_COPY(DefaultSettingsProvider)
|
||||
};
|
||||
|
||||
#endif // SETTINGSPROVIDER_H
|
||||
|
||||
@@ -1586,7 +1586,7 @@ bool Song::IsSimilar(const Song &other) const {
|
||||
album().compare(other.album(), Qt::CaseInsensitive) == 0;
|
||||
}
|
||||
|
||||
uint HashSimilar(const Song &song) {
|
||||
size_t HashSimilar(const Song &song) {
|
||||
// Should compare the same fields as function IsSimilar
|
||||
return qHash(song.title().toLower()) ^ qHash(song.artist().toLower()) ^ qHash(song.album().toLower());
|
||||
}
|
||||
|
||||
@@ -403,6 +403,6 @@ size_t qHash(const Song &song);
|
||||
uint qHash(const Song &song);
|
||||
#endif
|
||||
// Hash function using field checked in IsSimilar function
|
||||
uint HashSimilar(const Song &song);
|
||||
size_t HashSimilar(const Song &song);
|
||||
|
||||
#endif // SONG_H
|
||||
|
||||
@@ -77,7 +77,7 @@ void StandardItemIconLoader::RowsAboutToBeRemoved(const QModelIndex &parent, int
|
||||
|
||||
if (item_parent && item_parent->index() == parent && item->index().row() >= begin && item->index().row() <= end) {
|
||||
cover_loader_->CancelTask(it.key());
|
||||
it = pending_covers_.erase(it);
|
||||
it = pending_covers_.erase(it); // clazy:exclude=strict-iterators
|
||||
}
|
||||
else {
|
||||
++ it;
|
||||
@@ -97,7 +97,7 @@ void StandardItemIconLoader::ModelReset() {
|
||||
|
||||
}
|
||||
|
||||
void StandardItemIconLoader::AlbumCoverLoaded(const quint64 id, const AlbumCoverLoaderResult result) {
|
||||
void StandardItemIconLoader::AlbumCoverLoaded(const quint64 id, const AlbumCoverLoaderResult &result) {
|
||||
|
||||
QStandardItem *item = pending_covers_.take(id);
|
||||
if (!item) return;
|
||||
|
||||
@@ -55,7 +55,7 @@ class StandardItemIconLoader : public QObject {
|
||||
void LoadIcon(const Song &song, QStandardItem *for_item);
|
||||
|
||||
private slots:
|
||||
void AlbumCoverLoaded(const quint64 id, const AlbumCoverLoaderResult result);
|
||||
void AlbumCoverLoaded(const quint64 id, const AlbumCoverLoaderResult &result);
|
||||
void RowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
|
||||
void ModelReset();
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ void StyleHelper::setBaseColor(const QColor &newcolor) {
|
||||
|
||||
}
|
||||
|
||||
static void verticalGradientHelper(QPainter *p, const QRect &spanRect, const QRect &rect, bool lightColored) {
|
||||
static void verticalGradientHelper(QPainter *p, const QRect spanRect, const QRect rect, bool lightColored) {
|
||||
|
||||
QColor highlight = StyleHelper::highlightColor(lightColored);
|
||||
QColor shadow = StyleHelper::shadowColor(lightColored);
|
||||
@@ -193,7 +193,7 @@ static void verticalGradientHelper(QPainter *p, const QRect &spanRect, const QRe
|
||||
|
||||
}
|
||||
|
||||
void StyleHelper::verticalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored) {
|
||||
void StyleHelper::verticalGradient(QPainter *painter, const QRect spanRect, const QRect clipRect, bool lightColored) {
|
||||
|
||||
if (StyleHelper::usePixmapCache()) {
|
||||
QColor keyColor = baseColor(lightColored);
|
||||
@@ -216,7 +216,7 @@ void StyleHelper::verticalGradient(QPainter *painter, const QRect &spanRect, con
|
||||
|
||||
}
|
||||
|
||||
static void horizontalGradientHelper(QPainter *p, const QRect &spanRect, const QRect &rect, bool lightColored) {
|
||||
static void horizontalGradientHelper(QPainter *p, const QRect spanRect, const QRect rect, bool lightColored) {
|
||||
|
||||
if (lightColored) {
|
||||
QLinearGradient shadowGradient(rect.topLeft(), rect.bottomLeft());
|
||||
@@ -249,7 +249,7 @@ static void horizontalGradientHelper(QPainter *p, const QRect &spanRect, const Q
|
||||
|
||||
}
|
||||
|
||||
void StyleHelper::horizontalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored) {
|
||||
void StyleHelper::horizontalGradient(QPainter *painter, const QRect spanRect, const QRect clipRect, bool lightColored) {
|
||||
|
||||
if (StyleHelper::usePixmapCache()) {
|
||||
QColor keyColor = baseColor(lightColored);
|
||||
@@ -272,7 +272,7 @@ void StyleHelper::horizontalGradient(QPainter *painter, const QRect &spanRect, c
|
||||
|
||||
}
|
||||
|
||||
static void menuGradientHelper(QPainter *p, const QRect &spanRect, const QRect &rect) {
|
||||
static void menuGradientHelper(QPainter *p, const QRect spanRect, const QRect rect) {
|
||||
|
||||
QLinearGradient grad(spanRect.topLeft(), spanRect.bottomLeft());
|
||||
QColor menuColor = StyleHelper::mergedColors(StyleHelper::baseColor(), QColor(244, 244, 244), 25);
|
||||
@@ -301,7 +301,7 @@ void StyleHelper::drawArrow(QStyle::PrimitiveElement element, QPainter *painter,
|
||||
QStyleOption tweakedOption(*option);
|
||||
tweakedOption.state = QStyle::State_Enabled;
|
||||
|
||||
auto drawCommonStyleArrow = [&tweakedOption, element, &p](const QRect &rect, const QColor &color) -> void
|
||||
auto drawCommonStyleArrow = [&tweakedOption, element, &p](const QRect rect, const QColor &color) -> void
|
||||
{
|
||||
static const QCommonStyle* const style = qobject_cast<QCommonStyle*>(QApplication::style());
|
||||
if (!style)
|
||||
@@ -330,7 +330,7 @@ void StyleHelper::drawArrow(QStyle::PrimitiveElement element, QPainter *painter,
|
||||
|
||||
}
|
||||
|
||||
void StyleHelper::menuGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect) {
|
||||
void StyleHelper::menuGradient(QPainter *painter, const QRect spanRect, const QRect clipRect) {
|
||||
|
||||
if (StyleHelper::usePixmapCache()) {
|
||||
QString key = QString::asprintf("mh_menu %d %d %d %d %d", spanRect.width(), spanRect.height(), clipRect.width(), clipRect.height(), StyleHelper::baseColor().rgb());
|
||||
@@ -371,7 +371,7 @@ QPixmap StyleHelper::disabledSideBarIcon(const QPixmap &enabledicon) {
|
||||
|
||||
// Draws a CSS-like border image where the defined borders are not stretched
|
||||
// Unit for rect, left, top, right and bottom is user pixels
|
||||
void StyleHelper::drawCornerImage(const QImage &img, QPainter *painter, const QRect &rect, int left, int top, int right, int bottom) {
|
||||
void StyleHelper::drawCornerImage(const QImage &img, QPainter *painter, const QRect rect, int left, int top, int right, int bottom) {
|
||||
|
||||
// source rect for drawImage() calls needs to be specified in DIP unit of the image
|
||||
const qreal imagePixelRatio = img.devicePixelRatio();
|
||||
@@ -429,7 +429,7 @@ void StyleHelper::tintImage(QImage &img, const QColor &tintColor) {
|
||||
|
||||
}
|
||||
|
||||
QLinearGradient StyleHelper::statusBarGradient(const QRect &statusBarRect) {
|
||||
QLinearGradient StyleHelper::statusBarGradient(const QRect statusBarRect) {
|
||||
|
||||
QLinearGradient grad(statusBarRect.topLeft(), QPoint(statusBarRect.center().x(), statusBarRect.bottom()));
|
||||
QColor startColor = shadowColor().darker(164);
|
||||
|
||||
@@ -78,16 +78,16 @@ public:
|
||||
static void drawArrow(QStyle::PrimitiveElement element, QPainter *painter, const QStyleOption *option);
|
||||
|
||||
// Gradients used for panels
|
||||
static void horizontalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored = false);
|
||||
static void verticalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored = false);
|
||||
static void menuGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect);
|
||||
static void horizontalGradient(QPainter *painter, const QRect spanRect, const QRect clipRect, bool lightColored = false);
|
||||
static void verticalGradient(QPainter *painter, const QRect spanRect, const QRect clipRect, bool lightColored = false);
|
||||
static void menuGradient(QPainter *painter, const QRect spanRect, const QRect clipRect);
|
||||
static bool usePixmapCache() { return true; }
|
||||
|
||||
static QPixmap disabledSideBarIcon(const QPixmap &enabledicon);
|
||||
static void drawCornerImage(const QImage &img, QPainter *painter, const QRect &rect, int left = 0, int top = 0, int right = 0, int bottom = 0);
|
||||
static void drawCornerImage(const QImage &img, QPainter *painter, const QRect rect, int left = 0, int top = 0, int right = 0, int bottom = 0);
|
||||
|
||||
static void tintImage(QImage &img, const QColor &tintColor);
|
||||
static QLinearGradient statusBarGradient(const QRect &statusBarRect);
|
||||
static QLinearGradient statusBarGradient(const QRect statusBarRect);
|
||||
|
||||
static QString dpiSpecificImageFile(const QString &fileName);
|
||||
static QString imageFileWithResolution(const QString &fileName, int dpr);
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
@@ -37,10 +39,12 @@
|
||||
#include "core/logging.h"
|
||||
#include "stylesheetloader.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
StyleSheetLoader::StyleSheetLoader(QObject *parent) : QObject(parent), timer_reset_counter_(new QTimer(this)) {
|
||||
|
||||
timer_reset_counter_->setSingleShot(true);
|
||||
timer_reset_counter_->setInterval(1000);
|
||||
timer_reset_counter_->setInterval(1s);
|
||||
|
||||
QObject::connect(timer_reset_counter_, &QTimer::timeout, this, &StyleSheetLoader::ResetCounters);
|
||||
|
||||
@@ -122,7 +126,7 @@ void StyleSheetLoader::UpdateStyleSheet(QWidget *widget, StyleSheetData styledat
|
||||
|
||||
}
|
||||
|
||||
void StyleSheetLoader::ReplaceColor(QString *css, const QString name, const QPalette &palette, QPalette::ColorRole role) const {
|
||||
void StyleSheetLoader::ReplaceColor(QString *css, const QString &name, const QPalette &palette, QPalette::ColorRole role) const {
|
||||
|
||||
css->replace("%palette-" + name + "-lighter", palette.color(role).lighter().name(), Qt::CaseInsensitive);
|
||||
css->replace("%palette-" + name + "-darker", palette.color(role).darker().name(), Qt::CaseInsensitive);
|
||||
|
||||
@@ -59,7 +59,7 @@ class StyleSheetLoader : public QObject {
|
||||
|
||||
private:
|
||||
void UpdateStyleSheet(QWidget *widget, StyleSheetData styledata);
|
||||
void ReplaceColor(QString *css, const QString name, const QPalette &palette, QPalette::ColorRole role) const;
|
||||
void ReplaceColor(QString *css, const QString &name, const QPalette &palette, QPalette::ColorRole role) const;
|
||||
|
||||
private slots:
|
||||
void ResetCounters();
|
||||
|
||||
@@ -28,6 +28,8 @@ class QObject;
|
||||
|
||||
// Improve QThread by adding a SetIoPriority function
|
||||
class Thread : public QThread {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Thread(QObject *parent = nullptr) : QThread(parent), io_priority_(Utilities::IOPRIO_CLASS_NONE) {}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "translations.h"
|
||||
#include "core/potranslator.h"
|
||||
|
||||
Translations::Translations() {}
|
||||
Translations::Translations(QObject *parent) : QObject(parent) {}
|
||||
Translations::~Translations() {
|
||||
|
||||
for (QTranslator *t : translations_) {
|
||||
|
||||
@@ -28,8 +28,10 @@
|
||||
class QTranslator;
|
||||
|
||||
class Translations : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Translations();
|
||||
explicit Translations(QObject *parent = nullptr);
|
||||
~Translations() override;
|
||||
void LoadTranslation(const QString &prefix, const QString &path, const QString &language);
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "song.h"
|
||||
#include "urlhandler.h"
|
||||
|
||||
UrlHandler::LoadResult::LoadResult(const QUrl &original_url, const Type type, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 length_nanosec, const QString error) :
|
||||
UrlHandler::LoadResult::LoadResult(const QUrl &original_url, const Type type, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 length_nanosec, const QString &error) :
|
||||
original_url_(original_url),
|
||||
type_(type),
|
||||
stream_url_(stream_url),
|
||||
@@ -39,7 +39,7 @@ UrlHandler::LoadResult::LoadResult(const QUrl &original_url, const Type type, co
|
||||
error_(error)
|
||||
{}
|
||||
|
||||
UrlHandler::LoadResult::LoadResult(const QUrl &original_url, const Type type, const QString error) :
|
||||
UrlHandler::LoadResult::LoadResult(const QUrl &original_url, const Type type, const QString &error) :
|
||||
original_url_(original_url),
|
||||
type_(type),
|
||||
filetype_(Song::FileType_Stream),
|
||||
|
||||
@@ -57,9 +57,9 @@ class UrlHandler : public QObject {
|
||||
Error,
|
||||
};
|
||||
|
||||
explicit LoadResult(const QUrl &original_url = QUrl(), const Type type = NoMoreTracks, const QUrl &stream_url = QUrl(), const Song::FileType filetype = Song::FileType_Stream, const int samplerate = -1, const int bit_depth = -1, const qint64 length_nanosec = -1, const QString error = QString());
|
||||
explicit LoadResult(const QUrl &original_url = QUrl(), const Type type = NoMoreTracks, const QUrl &stream_url = QUrl(), const Song::FileType filetype = Song::FileType_Stream, const int samplerate = -1, const int bit_depth = -1, const qint64 length_nanosec = -1, const QString &error = QString());
|
||||
|
||||
explicit LoadResult(const QUrl &original_url, const Type type, const QString error);
|
||||
explicit LoadResult(const QUrl &original_url, const Type type, const QString &error);
|
||||
|
||||
// The url that the playlist item has in Url().
|
||||
// Might be something unplayable like lastfm://...
|
||||
|
||||
@@ -109,7 +109,7 @@ static QString tr(const char *str) {
|
||||
return QCoreApplication::translate("", str);
|
||||
}
|
||||
|
||||
QString PrettyTimeDelta(int seconds) {
|
||||
QString PrettyTimeDelta(const int seconds) {
|
||||
return (seconds >= 0 ? "+" : "-") + PrettyTime(seconds);
|
||||
}
|
||||
|
||||
@@ -130,11 +130,11 @@ QString PrettyTime(int seconds) {
|
||||
|
||||
}
|
||||
|
||||
QString PrettyTimeNanosec(qint64 nanoseconds) {
|
||||
QString PrettyTimeNanosec(const qint64 nanoseconds) {
|
||||
return PrettyTime(static_cast<int>(nanoseconds / kNsecPerSec));
|
||||
}
|
||||
|
||||
QString WordyTime(quint64 seconds) {
|
||||
QString WordyTime(const quint64 seconds) {
|
||||
|
||||
quint64 days = seconds / (60 * 60 * 24);
|
||||
|
||||
@@ -148,11 +148,11 @@ QString WordyTime(quint64 seconds) {
|
||||
|
||||
}
|
||||
|
||||
QString WordyTimeNanosec(qint64 nanoseconds) {
|
||||
QString WordyTimeNanosec(const qint64 nanoseconds) {
|
||||
return WordyTime(nanoseconds / kNsecPerSec);
|
||||
}
|
||||
|
||||
QString Ago(qint64 seconds_since_epoch, const QLocale &locale) {
|
||||
QString Ago(const qint64 seconds_since_epoch, const QLocale &locale) {
|
||||
|
||||
const QDateTime now = QDateTime::currentDateTime();
|
||||
const QDateTime then = QDateTime::fromSecsSinceEpoch(seconds_since_epoch);
|
||||
@@ -167,7 +167,7 @@ QString Ago(qint64 seconds_since_epoch, const QLocale &locale) {
|
||||
|
||||
}
|
||||
|
||||
QString PrettyFutureDate(const QDate &date) {
|
||||
QString PrettyFutureDate(const QDate date) {
|
||||
|
||||
const QDate now = QDate::currentDate();
|
||||
const qint64 delta_days = now.daysTo(date);
|
||||
@@ -182,7 +182,7 @@ QString PrettyFutureDate(const QDate &date) {
|
||||
|
||||
}
|
||||
|
||||
QString PrettySize(quint64 bytes) {
|
||||
QString PrettySize(const quint64 bytes) {
|
||||
|
||||
QString ret;
|
||||
|
||||
@@ -355,7 +355,7 @@ void OpenInFileManager(const QString &path, const QUrl &url) {
|
||||
#endif
|
||||
proc.waitForFinished();
|
||||
QString desktop_file = proc.readLine().simplified();
|
||||
QStringList data_dirs = QString(getenv("XDG_DATA_DIRS")).split(":");
|
||||
QStringList data_dirs = QString(qgetenv("XDG_DATA_DIRS")).split(":");
|
||||
|
||||
QString command;
|
||||
QStringList command_params;
|
||||
@@ -384,23 +384,25 @@ void OpenInFileManager(const QString &path, const QUrl &url) {
|
||||
command = command.split("/").last();
|
||||
}
|
||||
|
||||
// Three is no QProcess::startDetachedCommand function in Qt 6, so ignore the Clazy Qt 6 deprecated API fixes for QProcess::startDetached().
|
||||
|
||||
if (command.isEmpty() || command == "exo-open") {
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
|
||||
}
|
||||
else if (command.startsWith("nautilus")) {
|
||||
proc.startDetached(command, QStringList() << command_params << "--select" << url.toLocalFile());
|
||||
proc.startDetached(command, QStringList() << command_params << "--select" << url.toLocalFile()); // clazy:exclude=qt6-deprecated-api-fixes
|
||||
}
|
||||
else if (command.startsWith("dolphin") || command.startsWith("konqueror") || command.startsWith("kfmclient")) {
|
||||
proc.startDetached(command, QStringList() << command_params << "--select" << "--new-window" << url.toLocalFile());
|
||||
proc.startDetached(command, QStringList() << command_params << "--select" << "--new-window" << url.toLocalFile()); // clazy:exclude=qt6-deprecated-api-fixes
|
||||
}
|
||||
else if (command.startsWith("caja")) {
|
||||
proc.startDetached(command, QStringList() << command_params << "--no-desktop" << path);
|
||||
proc.startDetached(command, QStringList() << command_params << "--no-desktop" << path); // clazy:exclude=qt6-deprecated-api-fixes
|
||||
}
|
||||
else if (command.startsWith("pcmanfm") || command.startsWith("thunar")) {
|
||||
proc.startDetached(command, QStringList() << command_params << path);
|
||||
proc.startDetached(command, QStringList() << command_params << path); // clazy:exclude=qt6-deprecated-api-fixes
|
||||
}
|
||||
else {
|
||||
proc.startDetached(command, QStringList() << command_params << url.toLocalFile());
|
||||
proc.startDetached(command, QStringList() << command_params << url.toLocalFile()); // clazy:exclude=qt6-deprecated-api-fixes
|
||||
}
|
||||
|
||||
}
|
||||
@@ -515,7 +517,7 @@ QByteArray Sha1CoverHash(const QString &artist, const QString &album) {
|
||||
|
||||
}
|
||||
|
||||
QString PrettySize(const QSize &size) {
|
||||
QString PrettySize(const QSize size) {
|
||||
return QString::number(size.width()) + "x" + QString::number(size.height());
|
||||
}
|
||||
|
||||
@@ -614,7 +616,7 @@ QDateTime ParseRFC822DateTime(const QString &text) {
|
||||
|
||||
}
|
||||
|
||||
const char *EnumToString(const QMetaObject &meta, const char *name, int value) {
|
||||
const char *EnumToString(const QMetaObject &meta, const char *name, const int value) {
|
||||
|
||||
int index = meta.indexOfEnumerator(name);
|
||||
if (index == -1) return "[UnknownEnum]";
|
||||
@@ -659,7 +661,7 @@ QString DecodeHtmlEntities(const QString &text) {
|
||||
|
||||
}
|
||||
|
||||
int SetThreadIOPriority(IoPriority priority) {
|
||||
int SetThreadIOPriority(const IoPriority priority) {
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
return syscall(SYS_ioprio_set, IOPRIO_WHO_PROCESS, GetThreadId(), 4 | priority << IOPRIO_CLASS_SHIFT);
|
||||
|
||||
@@ -50,14 +50,14 @@ class QXmlStreamReader;
|
||||
|
||||
namespace Utilities {
|
||||
QString PrettyTime(int seconds);
|
||||
QString PrettyTimeDelta(int seconds);
|
||||
QString PrettyTimeNanosec(qint64 nanoseconds);
|
||||
QString PrettySize(quint64 bytes);
|
||||
QString PrettySize(const QSize &size);
|
||||
QString WordyTime(quint64 seconds);
|
||||
QString WordyTimeNanosec(qint64 nanoseconds);
|
||||
QString Ago(qint64 seconds_since_epoch, const QLocale &locale);
|
||||
QString PrettyFutureDate(const QDate &date);
|
||||
QString PrettyTimeDelta(const int seconds);
|
||||
QString PrettyTimeNanosec(const qint64 nanoseconds);
|
||||
QString PrettySize(const quint64 bytes);
|
||||
QString PrettySize(const QSize size);
|
||||
QString WordyTime(const quint64 seconds);
|
||||
QString WordyTimeNanosec(const qint64 nanoseconds);
|
||||
QString Ago(const qint64 seconds_since_epoch, const QLocale &locale);
|
||||
QString PrettyFutureDate(const QDate date);
|
||||
|
||||
QString ColorToRgba(const QColor &color);
|
||||
|
||||
@@ -126,7 +126,7 @@ enum IoPriority {
|
||||
};
|
||||
static const int IOPRIO_CLASS_SHIFT = 13;
|
||||
|
||||
int SetThreadIOPriority(IoPriority priority);
|
||||
int SetThreadIOPriority(const IoPriority priority);
|
||||
int GetThreadId();
|
||||
|
||||
QString GetRandomStringWithChars(const int len);
|
||||
|
||||
Reference in New Issue
Block a user