mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2024-12-17 11:10:31 +01:00
Clang-Tidy and Clazy fixes
This commit is contained in:
parent
755abec636
commit
1295033fae
@ -236,7 +236,7 @@ QString SingleApplication::currentUser() {
|
||||
* @param timeout the maximum timeout in milliseconds for blocking functions.
|
||||
* @return true if the message was sent successfuly, false otherwise.
|
||||
*/
|
||||
bool SingleApplication::sendMessage(QByteArray message, int timeout) {
|
||||
bool SingleApplication::sendMessage(const QByteArray &message, const int timeout) {
|
||||
|
||||
Q_D(SingleApplication);
|
||||
|
||||
|
@ -45,7 +45,7 @@ class SingleApplicationPrivate;
|
||||
* @brief The SingleApplication class handles multipe instances of the same Application
|
||||
* @see QApplication
|
||||
*/
|
||||
class SingleApplication : public QApplication {
|
||||
class SingleApplication : public QApplication { // clazy:exclude=ctor-missing-parent-argument
|
||||
Q_OBJECT
|
||||
|
||||
typedef QApplication app_t;
|
||||
@ -136,7 +136,7 @@ class SingleApplication : public QApplication {
|
||||
* @note sendMessage() will return false if invoked from the primary
|
||||
* instance.
|
||||
*/
|
||||
bool sendMessage(QByteArray message, int timeout = 1000);
|
||||
bool sendMessage(const QByteArray &message, const int timeout = 1000);
|
||||
|
||||
signals:
|
||||
void instanceStarted();
|
||||
|
@ -327,7 +327,7 @@ void SingleApplicationPrivate::slotConnectionEstablished() {
|
||||
connectionMap_.insert(nextConnSocket, ConnectionInfo());
|
||||
|
||||
QObject::connect(nextConnSocket, &QLocalSocket::aboutToClose, this, [nextConnSocket, this]() {
|
||||
auto &info = connectionMap_[nextConnSocket];
|
||||
const ConnectionInfo info = connectionMap_[nextConnSocket];
|
||||
slotClientConnectionClosed(nextConnSocket, info.instanceId);
|
||||
});
|
||||
|
||||
@ -337,7 +337,7 @@ void SingleApplicationPrivate::slotConnectionEstablished() {
|
||||
});
|
||||
|
||||
QObject::connect(nextConnSocket, &QLocalSocket::readyRead, this, [nextConnSocket, this]() {
|
||||
auto &info = connectionMap_[nextConnSocket];
|
||||
const ConnectionInfo info = connectionMap_[nextConnSocket];
|
||||
switch (info.stage) {
|
||||
case StageHeader:
|
||||
readInitMessageHeader(nextConnSocket);
|
||||
|
@ -236,7 +236,7 @@ QString SingleCoreApplication::currentUser() {
|
||||
* @param timeout the maximum timeout in milliseconds for blocking functions.
|
||||
* @return true if the message was sent successfuly, false otherwise.
|
||||
*/
|
||||
bool SingleCoreApplication::sendMessage(QByteArray message, int timeout) {
|
||||
bool SingleCoreApplication::sendMessage(const QByteArray &message, const int timeout) {
|
||||
|
||||
Q_D(SingleCoreApplication);
|
||||
|
||||
|
@ -135,7 +135,7 @@ class SingleCoreApplication : public QCoreApplication {
|
||||
* @note sendMessage() will return false if invoked from the primary
|
||||
* instance.
|
||||
*/
|
||||
bool sendMessage(QByteArray message, int timeout = 1000);
|
||||
bool sendMessage(const QByteArray &message, const int timeout = 1000);
|
||||
|
||||
signals:
|
||||
void instanceStarted();
|
||||
|
@ -327,7 +327,7 @@ void SingleCoreApplicationPrivate::slotConnectionEstablished() {
|
||||
connectionMap_.insert(nextConnSocket, ConnectionInfo());
|
||||
|
||||
QObject::connect(nextConnSocket, &QLocalSocket::aboutToClose, this, [nextConnSocket, this]() {
|
||||
auto &info = connectionMap_[nextConnSocket];
|
||||
const ConnectionInfo info = connectionMap_[nextConnSocket];
|
||||
slotClientConnectionClosed(nextConnSocket, info.instanceId);
|
||||
});
|
||||
|
||||
@ -337,7 +337,7 @@ void SingleCoreApplicationPrivate::slotConnectionEstablished() {
|
||||
});
|
||||
|
||||
QObject::connect(nextConnSocket, &QLocalSocket::readyRead, this, [nextConnSocket, this]() {
|
||||
auto &info = connectionMap_[nextConnSocket];
|
||||
const ConnectionInfo info = connectionMap_[nextConnSocket];
|
||||
switch (info.stage) {
|
||||
case StageHeader:
|
||||
readInitMessageHeader(nextConnSocket);
|
||||
|
@ -8,6 +8,7 @@ set(SOURCES
|
||||
)
|
||||
|
||||
set(HEADERS
|
||||
core/logging.h
|
||||
core/messagehandler.h
|
||||
core/messagereply.h
|
||||
core/workerpool.h
|
||||
|
@ -54,10 +54,10 @@ static QMap<QString, Level>* sClassLevels = nullptr;
|
||||
static QIODevice *sNullDevice = nullptr;
|
||||
|
||||
//const char* kDefaultLogLevels = "*:3";
|
||||
const char* kDefaultLogLevels = "GstEnginePipeline:2,*:3";
|
||||
const char *kDefaultLogLevels = "GstEnginePipeline:2,*:3";
|
||||
|
||||
static const char *kMessageHandlerMagic = "__logging_message__";
|
||||
static const int kMessageHandlerMagicLength = strlen(kMessageHandlerMagic);
|
||||
static const size_t kMessageHandlerMagicLength = strlen(kMessageHandlerMagic);
|
||||
static QtMessageHandler sOriginalMessageHandler = nullptr;
|
||||
|
||||
template <class T>
|
||||
@ -280,7 +280,7 @@ QString CXXDemangle(const QString &mangled_function);
|
||||
QString CXXDemangle(const QString &mangled_function) {
|
||||
|
||||
int status = 0;
|
||||
char* demangled_function = abi::__cxa_demangle(mangled_function.toLatin1().constData(), nullptr, nullptr, &status);
|
||||
char *demangled_function = abi::__cxa_demangle(mangled_function.toLatin1().constData(), nullptr, nullptr, &status);
|
||||
if (status == 0) {
|
||||
QString ret = QString::fromLatin1(demangled_function);
|
||||
free(demangled_function);
|
||||
|
@ -41,6 +41,11 @@
|
||||
namespace logging {
|
||||
|
||||
class NullDevice : public QIODevice {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
NullDevice(QObject *parent = nullptr) : QIODevice(parent) {}
|
||||
|
||||
protected:
|
||||
qint64 readData(char*, qint64) override { return -1; }
|
||||
qint64 writeData(const char*, qint64 len) override { return len; }
|
||||
|
@ -164,8 +164,9 @@ WorkerPool<HandlerType>::WorkerPool(QObject *parent)
|
||||
worker_count_ = qBound(1, QThread::idealThreadCount() / 2, 4);
|
||||
local_server_name_ = qApp->applicationName().toLower();
|
||||
|
||||
if (local_server_name_.isEmpty())
|
||||
if (local_server_name_.isEmpty()) {
|
||||
local_server_name_ = "workerpool";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -90,12 +90,17 @@
|
||||
|
||||
class FileRefFactory {
|
||||
public:
|
||||
FileRefFactory() = default;
|
||||
virtual ~FileRefFactory() {}
|
||||
virtual TagLib::FileRef *GetFileRef(const QString &filename) = 0;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(FileRefFactory)
|
||||
};
|
||||
|
||||
class TagLibFileRefFactory : public FileRefFactory {
|
||||
public:
|
||||
TagLibFileRefFactory() = default;
|
||||
TagLib::FileRef *GetFileRef(const QString &filename) override {
|
||||
#ifdef Q_OS_WIN32
|
||||
return new TagLib::FileRef(filename.toStdWString().c_str());
|
||||
@ -103,6 +108,8 @@ class TagLibFileRefFactory : public FileRefFactory {
|
||||
return new TagLib::FileRef(QFile::encodeName(filename).constData());
|
||||
#endif
|
||||
}
|
||||
private:
|
||||
Q_DISABLE_COPY(TagLibFileRefFactory)
|
||||
};
|
||||
|
||||
namespace {
|
||||
|
@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.0)
|
||||
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
|
||||
|
||||
set(SOURCES main.cpp tagreaderworker.cpp)
|
||||
set(HEADERS tagreaderworker.h)
|
||||
|
||||
if(BUILD_WITH_QT6)
|
||||
qt6_wrap_cpp(MOC ${HEADERS})
|
||||
|
@ -30,6 +30,8 @@
|
||||
class QIODevice;
|
||||
|
||||
class TagReaderWorker : public AbstractMessageHandler<spb::tagreader::Message> {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TagReaderWorker(QIODevice *socket, QObject *parent = nullptr);
|
||||
|
||||
|
@ -249,11 +249,13 @@ set(SOURCES
|
||||
set(HEADERS
|
||||
core/mainwindow.h
|
||||
core/application.h
|
||||
core/appearance.h
|
||||
core/player.h
|
||||
core/database.h
|
||||
core/deletefiles.h
|
||||
core/filesystemwatcherinterface.h
|
||||
core/mergedproxymodel.h
|
||||
core/multisortfilterproxy.h
|
||||
core/networkaccessmanager.h
|
||||
core/threadsafenetworkdiskcache.h
|
||||
core/networktimeouts.h
|
||||
@ -261,8 +263,11 @@ set(HEADERS
|
||||
core/songloader.h
|
||||
core/tagreaderclient.h
|
||||
core/taskmanager.h
|
||||
core/thread.h
|
||||
core/urlhandler.h
|
||||
core/standarditemiconloader.h
|
||||
core/translations.h
|
||||
core/potranslator.h
|
||||
core/mimedata.h
|
||||
core/stylesheetloader.h
|
||||
|
||||
@ -304,6 +309,7 @@ set(HEADERS
|
||||
playlist/playlistlistcontainer.h
|
||||
playlist/playlistlistmodel.h
|
||||
playlist/playlistlistview.h
|
||||
playlist/playlistlistsortfiltermodel.h
|
||||
playlist/playlistmanager.h
|
||||
playlist/playlistsaveoptionsdialog.h
|
||||
playlist/playlistsequence.h
|
||||
@ -324,10 +330,13 @@ set(HEADERS
|
||||
playlistparsers/parserbase.h
|
||||
playlistparsers/playlistparser.h
|
||||
playlistparsers/plsparser.h
|
||||
playlistparsers/wplparser.h
|
||||
playlistparsers/xmlparser.h
|
||||
playlistparsers/xspfparser.h
|
||||
|
||||
smartplaylists/playlistgenerator.h
|
||||
smartplaylists/playlistgeneratorinserter.h
|
||||
smartplaylists/playlistquerygenerator.h
|
||||
smartplaylists/playlistgeneratormimedata.h
|
||||
smartplaylists/smartplaylistquerywizardplugin.h
|
||||
smartplaylists/smartplaylistsearchpreview.h
|
||||
@ -422,6 +431,7 @@ set(HEADERS
|
||||
widgets/loginstatewidget.h
|
||||
widgets/qsearchfield.h
|
||||
widgets/ratingwidget.h
|
||||
widgets/forcescrollperpixel.h
|
||||
|
||||
osd/osdbase.h
|
||||
osd/osdpretty.h
|
||||
@ -429,14 +439,15 @@ set(HEADERS
|
||||
internet/internetservices.h
|
||||
internet/internetservice.h
|
||||
internet/internetsongmimedata.h
|
||||
internet/internetsearchview.h
|
||||
internet/internetsearchmodel.h
|
||||
internet/internetsearchsortmodel.h
|
||||
internet/internetsearchitemdelegate.h
|
||||
internet/internetsearchview.h
|
||||
internet/localredirectserver.h
|
||||
internet/internetsongsview.h
|
||||
internet/internettabsview.h
|
||||
internet/internetcollectionview.h
|
||||
internet/internetcollectionviewcontainer.h
|
||||
internet/internetsearchview.h
|
||||
|
||||
scrobbler/audioscrobbler.h
|
||||
scrobbler/scrobblerservices.h
|
||||
@ -808,13 +819,14 @@ optional_source(HAVE_GIO
|
||||
HEADERS device/giolister.h
|
||||
)
|
||||
|
||||
# mtp device
|
||||
# MTP device
|
||||
optional_source(HAVE_LIBMTP
|
||||
SOURCES
|
||||
device/mtpconnection.cpp
|
||||
device/mtpdevice.cpp
|
||||
device/mtploader.cpp
|
||||
HEADERS
|
||||
device/mtpconnection.h
|
||||
device/mtpdevice.h
|
||||
device/mtploader.h
|
||||
)
|
||||
@ -844,6 +856,14 @@ HEADERS
|
||||
transcoder/transcoder.h
|
||||
transcoder/transcodedialog.h
|
||||
transcoder/transcoderoptionsdialog.h
|
||||
transcoder/transcoderoptionsinterface.h
|
||||
transcoder/transcoderoptionsflac.h
|
||||
transcoder/transcoderoptionswavpack.h
|
||||
transcoder/transcoderoptionsvorbis.h
|
||||
transcoder/transcoderoptionsopus.h
|
||||
transcoder/transcoderoptionsspeex.h
|
||||
transcoder/transcoderoptionsaac.h
|
||||
transcoder/transcoderoptionsasf.h
|
||||
transcoder/transcoderoptionsmp3.h
|
||||
settings/transcodersettingspage.h
|
||||
UI
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
#include <QVariant>
|
||||
@ -44,6 +46,8 @@
|
||||
#include "engine/enginebase.h"
|
||||
#include "engine/enginetype.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
const char *AnalyzerContainer::kSettingsGroup = "Analyzer";
|
||||
const char *AnalyzerContainer::kSettingsFramerate = "framerate";
|
||||
|
||||
@ -90,7 +94,7 @@ AnalyzerContainer::AnalyzerContainer(QWidget *parent)
|
||||
context_menu_->addSeparator();
|
||||
|
||||
double_click_timer_->setSingleShot(true);
|
||||
double_click_timer_->setInterval(250);
|
||||
double_click_timer_->setInterval(250ms);
|
||||
QObject::connect(double_click_timer_, &QTimer::timeout, this, &AnalyzerContainer::ShowPopupMenu);
|
||||
|
||||
Load();
|
||||
|
@ -248,6 +248,8 @@ QColor ensureContrast(const QColor &bg, const QColor &fg, int amount) {
|
||||
|
||||
private:
|
||||
const QColor &c;
|
||||
|
||||
Q_DISABLE_COPY(OutputOnExit)
|
||||
};
|
||||
|
||||
OutputOnExit allocateOnTheStack(fg);
|
||||
|
@ -49,7 +49,7 @@ void FHT::makeCasTable(void) {
|
||||
float *sintab = tab_() + num_ / 2 + 1;
|
||||
|
||||
for (int ul = 0; ul < num_; ul++) {
|
||||
float d = M_PI * ul / (num_ / 2);
|
||||
float d = M_PI * ul / (num_ / 2); // NOLINT(bugprone-integer-division)
|
||||
*costab = *sintab = cos(d);
|
||||
|
||||
costab += 2;
|
||||
|
@ -56,7 +56,7 @@ const float Rainbow::RainbowAnalyzer::kPixelScale = 0.02f;
|
||||
|
||||
Rainbow::RainbowAnalyzer::RainbowType Rainbow::RainbowAnalyzer::rainbowtype;
|
||||
|
||||
Rainbow::RainbowAnalyzer::RainbowAnalyzer(const RainbowType &rbtype, QWidget *parent)
|
||||
Rainbow::RainbowAnalyzer::RainbowAnalyzer(const RainbowType rbtype, QWidget *parent)
|
||||
: Analyzer::Base(parent, 9),
|
||||
timer_id_(startTimer(kFrameIntervalMs)),
|
||||
frame_(0),
|
||||
@ -73,7 +73,7 @@ Rainbow::RainbowAnalyzer::RainbowAnalyzer(const RainbowType &rbtype, QWidget *pa
|
||||
memset(history_, 0, sizeof(history_));
|
||||
|
||||
for (int i = 0; i < kRainbowBands; ++i) {
|
||||
colors_[i] = QPen(QColor::fromHsv(i * 255 / kRainbowBands, 255, 255), kRainbowHeight[rainbowtype] / kRainbowBands, Qt::SolidLine, Qt::FlatCap, Qt::RoundJoin);
|
||||
colors_[i] = QPen(QColor::fromHsv(i * 255 / kRainbowBands, 255, 255), kRainbowHeight[rainbowtype] / kRainbowBands, Qt::SolidLine, Qt::FlatCap, Qt::RoundJoin); // NOLINT(bugprone-integer-division)
|
||||
|
||||
// pow constants computed so that
|
||||
// | band_scale(0) | ~= .5 and | band_scale(5) | ~= 32
|
||||
|
@ -50,7 +50,7 @@ class RainbowAnalyzer : public Analyzer::Base {
|
||||
Dash = 1
|
||||
};
|
||||
|
||||
RainbowAnalyzer(const RainbowType &rbtype, QWidget *parent);
|
||||
RainbowAnalyzer(const RainbowType rbtype, QWidget *parent);
|
||||
|
||||
protected:
|
||||
void transform(Analyzer::Scope&) override;
|
||||
|
@ -133,7 +133,7 @@ void SCollection::Exit() {
|
||||
|
||||
void SCollection::ExitReceived() {
|
||||
|
||||
QObject *obj = qobject_cast<QObject*>(sender());
|
||||
QObject *obj = sender();
|
||||
QObject::disconnect(obj, nullptr, this, nullptr);
|
||||
qLog(Debug) << obj << "successfully exited.";
|
||||
wait_for_exit_.removeAll(obj);
|
||||
|
@ -768,7 +768,8 @@ SongList CollectionBackend::GetSongsById(const QList<int> &ids) {
|
||||
QSqlDatabase db(db_->Connect());
|
||||
|
||||
QStringList str_ids;
|
||||
for (int id : ids) {
|
||||
str_ids.reserve(ids.count());
|
||||
for (const int id : ids) {
|
||||
str_ids << QString::number(id);
|
||||
}
|
||||
|
||||
@ -915,6 +916,7 @@ Song CollectionBackend::GetSongBySongId(const QString &song_id, QSqlDatabase &db
|
||||
SongList CollectionBackend::GetSongsBySongId(const QStringList &song_ids, QSqlDatabase &db) {
|
||||
|
||||
QStringList song_ids2;
|
||||
song_ids2.reserve(song_ids.count());
|
||||
for (const QString &song_id : song_ids) {
|
||||
song_ids2 << "'" + song_id + "'";
|
||||
}
|
||||
@ -1164,7 +1166,7 @@ CollectionBackend::AlbumList CollectionBackend::GetAlbums(const QString &artist,
|
||||
|
||||
}
|
||||
|
||||
return albums.values();
|
||||
return albums.values(); // clazy:exclude=qt6-deprecated-api-fixes
|
||||
|
||||
}
|
||||
|
||||
@ -1570,6 +1572,7 @@ void CollectionBackend::UpdateSongsRating(const QList<int> &id_list, const doubl
|
||||
QSqlDatabase db(db_->Connect());
|
||||
|
||||
QStringList id_str_list;
|
||||
id_str_list.reserve(id_list.count());
|
||||
for (int i : id_list) {
|
||||
id_str_list << QString::number(i);
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ QActionGroup *CollectionFilterWidget::CreateGroupByActions(QObject *parent) {
|
||||
|
||||
}
|
||||
|
||||
QAction *CollectionFilterWidget::CreateGroupByAction(const QString &text, QObject *parent, const CollectionModel::Grouping &grouping) {
|
||||
QAction *CollectionFilterWidget::CreateGroupByAction(const QString &text, QObject *parent, const CollectionModel::Grouping grouping) {
|
||||
|
||||
QAction *ret = new QAction(text, parent);
|
||||
ret->setCheckable(true);
|
||||
@ -354,7 +354,7 @@ void CollectionFilterWidget::GroupByClicked(QAction *action) {
|
||||
|
||||
}
|
||||
|
||||
void CollectionFilterWidget::GroupingChanged(const CollectionModel::Grouping &g) {
|
||||
void CollectionFilterWidget::GroupingChanged(const CollectionModel::Grouping g) {
|
||||
|
||||
if (!settings_group_.isEmpty()) {
|
||||
// Save the settings
|
||||
@ -372,7 +372,7 @@ void CollectionFilterWidget::GroupingChanged(const CollectionModel::Grouping &g)
|
||||
|
||||
}
|
||||
|
||||
void CollectionFilterWidget::CheckCurrentGrouping(const CollectionModel::Grouping &g) {
|
||||
void CollectionFilterWidget::CheckCurrentGrouping(CollectionModel::Grouping g) {
|
||||
|
||||
for (QAction *action : group_by_group_->actions()) {
|
||||
if (action->property("group_by").isNull()) continue;
|
||||
|
@ -96,7 +96,7 @@ class CollectionFilterWidget : public QWidget {
|
||||
void keyReleaseEvent(QKeyEvent *e) override;
|
||||
|
||||
private slots:
|
||||
void GroupingChanged(const CollectionModel::Grouping &g);
|
||||
void GroupingChanged(const CollectionModel::Grouping g);
|
||||
void GroupByClicked(QAction *action);
|
||||
void SaveGroupBy();
|
||||
void ShowGroupingManager();
|
||||
@ -105,8 +105,8 @@ class CollectionFilterWidget : public QWidget {
|
||||
void FilterDelayTimeout();
|
||||
|
||||
private:
|
||||
static QAction *CreateGroupByAction(const QString &text, QObject *parent, const CollectionModel::Grouping &grouping);
|
||||
void CheckCurrentGrouping(const CollectionModel::Grouping &g);
|
||||
static QAction *CreateGroupByAction(const QString &text, QObject *parent, const CollectionModel::Grouping grouping);
|
||||
void CheckCurrentGrouping(CollectionModel::Grouping g);
|
||||
|
||||
private:
|
||||
Ui_CollectionFilterWidget *ui_;
|
||||
|
@ -50,6 +50,9 @@ class CollectionItem : public SimpleTreeItem<CollectionItem> {
|
||||
int container_level;
|
||||
Song metadata;
|
||||
CollectionItem *compilation_artist_node_;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(CollectionItem)
|
||||
};
|
||||
|
||||
#endif // COLLECTIONITEM_H
|
||||
|
@ -125,10 +125,9 @@ bool CollectionItemDelegate::helpEvent(QHelpEvent *event, QAbstractItemView *vie
|
||||
|
||||
if (!event || !view) return false;
|
||||
|
||||
QHelpEvent *he = static_cast<QHelpEvent*>(event);
|
||||
QString text = displayText(idx.data(), QLocale::system());
|
||||
|
||||
if (text.isEmpty() || !he) return false;
|
||||
if (text.isEmpty() || !event) return false;
|
||||
|
||||
switch (event->type()) {
|
||||
case QEvent::ToolTip: {
|
||||
@ -138,12 +137,12 @@ bool CollectionItemDelegate::helpEvent(QHelpEvent *event, QAbstractItemView *vie
|
||||
bool is_elided = displayed_text.width() < real_text.width();
|
||||
|
||||
if (is_elided) {
|
||||
QToolTip::showText(he->globalPos(), text, view);
|
||||
QToolTip::showText(event->globalPos(), text, view);
|
||||
}
|
||||
else if (idx.data(Qt::ToolTipRole).isValid()) {
|
||||
// If the item has a tooltip text, display it
|
||||
QString tooltip_text = idx.data(Qt::ToolTipRole).toString();
|
||||
QToolTip::showText(he->globalPos(), tooltip_text, view);
|
||||
QToolTip::showText(event->globalPos(), tooltip_text, view);
|
||||
}
|
||||
else {
|
||||
// in case that another text was previously displayed
|
||||
@ -156,7 +155,7 @@ bool CollectionItemDelegate::helpEvent(QHelpEvent *event, QAbstractItemView *vie
|
||||
return true;
|
||||
|
||||
case QEvent::WhatsThis:
|
||||
QWhatsThis::showText(he->globalPos(), text, view);
|
||||
QWhatsThis::showText(event->globalPos(), text, view);
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
@ -159,7 +159,7 @@ void CollectionModel::set_show_dividers(const bool show_dividers) {
|
||||
|
||||
}
|
||||
|
||||
void CollectionModel::SaveGrouping(QString name) {
|
||||
void CollectionModel::SaveGrouping(const QString &name) {
|
||||
|
||||
qLog(Debug) << "Model, save to: " << name;
|
||||
|
||||
@ -571,7 +571,7 @@ void CollectionModel::SongsDeleted(const SongList &songs) {
|
||||
QMap<quint64, ItemAndCacheKey>::iterator i = pending_art_.begin();
|
||||
while (i != pending_art_.end()) {
|
||||
if (i.value().first == node) {
|
||||
i = pending_art_.erase(i);
|
||||
i = pending_art_.erase(i); // clazy:exclude=strict-iterators
|
||||
}
|
||||
else {
|
||||
++i;
|
||||
@ -1846,7 +1846,7 @@ bool CollectionModel::canFetchMore(const QModelIndex &parent) const {
|
||||
|
||||
}
|
||||
|
||||
void CollectionModel::SetGroupBy(const Grouping &g) {
|
||||
void CollectionModel::SetGroupBy(const Grouping g) {
|
||||
|
||||
group_by_ = g;
|
||||
|
||||
@ -1916,7 +1916,7 @@ void CollectionModel::ExpandAll(CollectionItem *item) const {
|
||||
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &s, const CollectionModel::Grouping &g) {
|
||||
QDataStream &operator<<(QDataStream &s, const CollectionModel::Grouping g) {
|
||||
s << quint32(g.first) << quint32(g.second) << quint32(g.third);
|
||||
return s;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ class CollectionDirectoryModel;
|
||||
class CollectionModel : public SimpleTreeModel<CollectionItem> {
|
||||
Q_OBJECT
|
||||
|
||||
Q_ENUMS(GroupBy)
|
||||
Q_ENUMS(GroupBy) // clazy:exclude=qenums
|
||||
|
||||
public:
|
||||
explicit CollectionModel(CollectionBackend *backend, Application *app, QObject *parent = nullptr);
|
||||
@ -118,10 +118,10 @@ class CollectionModel : public SimpleTreeModel<CollectionItem> {
|
||||
|
||||
const GroupBy &operator[](const int i) const;
|
||||
GroupBy &operator[](const int i);
|
||||
bool operator==(const Grouping &other) const {
|
||||
bool operator==(const Grouping other) const {
|
||||
return first == other.first && second == other.second && third == other.third;
|
||||
}
|
||||
bool operator!=(const Grouping &other) const { return !(*this == other); }
|
||||
bool operator!=(const Grouping other) const { return !(*this == other); }
|
||||
};
|
||||
|
||||
struct QueryResult {
|
||||
@ -162,7 +162,7 @@ class CollectionModel : public SimpleTreeModel<CollectionItem> {
|
||||
void set_show_dividers(const bool show_dividers);
|
||||
|
||||
// Save the current grouping
|
||||
void SaveGrouping(QString name);
|
||||
void SaveGrouping(const QString &name);
|
||||
|
||||
// Reload settings.
|
||||
void ReloadSettings();
|
||||
@ -195,8 +195,8 @@ class CollectionModel : public SimpleTreeModel<CollectionItem> {
|
||||
|
||||
void ExpandAll(CollectionItem *item = nullptr) const;
|
||||
|
||||
const CollectionModel::Grouping &GetGroupBy() const { return group_by_; }
|
||||
void SetGroupBy(const CollectionModel::Grouping &g);
|
||||
const CollectionModel::Grouping GetGroupBy() const { return group_by_; }
|
||||
void SetGroupBy(const CollectionModel::Grouping g);
|
||||
|
||||
signals:
|
||||
void TotalSongCountUpdated(int count);
|
||||
@ -317,7 +317,7 @@ class CollectionModel : public SimpleTreeModel<CollectionItem> {
|
||||
|
||||
Q_DECLARE_METATYPE(CollectionModel::Grouping)
|
||||
|
||||
QDataStream &operator<<(QDataStream &s, const CollectionModel::Grouping &g);
|
||||
QDataStream &operator<<(QDataStream &s, const CollectionModel::Grouping g);
|
||||
QDataStream &operator>>(QDataStream &s, CollectionModel::Grouping &g);
|
||||
|
||||
#endif // COLLECTIONMODEL_H
|
||||
|
@ -56,6 +56,9 @@ class CollectionPlaylistItem : public PlaylistItem {
|
||||
|
||||
protected:
|
||||
Song song_;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(CollectionPlaylistItem)
|
||||
};
|
||||
|
||||
#endif // COLLECTIONPLAYLISTITEM_H
|
||||
|
@ -134,8 +134,10 @@ void CollectionQuery::AddWhere(const QString &column, const QVariant &value, con
|
||||
|
||||
// Ignore 'literal' for IN
|
||||
if (!op.compare("IN", Qt::CaseInsensitive)) {
|
||||
QStringList values = value.toStringList();
|
||||
QStringList final;
|
||||
for (const QString &single_value : value.toStringList()) {
|
||||
final.reserve(values.count());
|
||||
for (const QString &single_value : values) {
|
||||
final.append("?");
|
||||
bound_values_ << single_value;
|
||||
}
|
||||
|
@ -564,13 +564,16 @@ SongList CollectionView::GetSelectedSongs() const {
|
||||
|
||||
void CollectionView::Organize() {
|
||||
|
||||
if (!organize_dialog_)
|
||||
if (!organize_dialog_) {
|
||||
organize_dialog_.reset(new OrganizeDialog(app_->task_manager(), app_->collection_backend(), this));
|
||||
}
|
||||
|
||||
organize_dialog_->SetDestinationModel(app_->collection_model()->directory_model());
|
||||
organize_dialog_->SetCopy(false);
|
||||
if (organize_dialog_->SetSongs(GetSelectedSongs()))
|
||||
const SongList songs = GetSelectedSongs();
|
||||
if (organize_dialog_->SetSongs(songs)) {
|
||||
organize_dialog_->show();
|
||||
}
|
||||
else {
|
||||
QMessageBox::warning(this, tr("Error"), tr("None of the selected songs were suitable for copying to a device"));
|
||||
}
|
||||
@ -583,7 +586,8 @@ void CollectionView::EditTracks() {
|
||||
edit_tag_dialog_.reset(new EditTagDialog(app_, this));
|
||||
QObject::connect(edit_tag_dialog_.get(), &EditTagDialog::Error, this, &CollectionView::EditTagError);
|
||||
}
|
||||
edit_tag_dialog_->SetSongs(GetSelectedSongs());
|
||||
const SongList songs = GetSelectedSongs();
|
||||
edit_tag_dialog_->SetSongs(songs);
|
||||
edit_tag_dialog_->show();
|
||||
|
||||
}
|
||||
@ -634,6 +638,7 @@ void CollectionView::ShowInBrowser() {
|
||||
|
||||
SongList songs = GetSelectedSongs();
|
||||
QList<QUrl> urls;
|
||||
urls.reserve(songs.count());
|
||||
for (const Song &song : songs) {
|
||||
urls << song.url();
|
||||
}
|
||||
@ -658,6 +663,7 @@ void CollectionView::Delete() {
|
||||
|
||||
SongList selected_songs = GetSelectedSongs();
|
||||
QStringList files;
|
||||
files.reserve(selected_songs.count());
|
||||
for (const Song &song : selected_songs) {
|
||||
files << song.url().toString();
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <cassert>
|
||||
|
||||
#include <QObject>
|
||||
@ -65,6 +66,8 @@
|
||||
#undef RemoveDirectory
|
||||
#endif
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
namespace {
|
||||
static const char *kNoMediaFile = ".nomedia";
|
||||
static const char *kNoMusicFile = ".nomusic";
|
||||
@ -95,7 +98,7 @@ CollectionWatcher::CollectionWatcher(Song::Source source, QObject *parent)
|
||||
|
||||
original_thread_ = thread();
|
||||
|
||||
rescan_timer_->setInterval(2000);
|
||||
rescan_timer_->setInterval(2s);
|
||||
rescan_timer_->setSingleShot(true);
|
||||
|
||||
periodic_scan_timer_->setInterval(86400 * kMsecPerSec);
|
||||
@ -789,6 +792,7 @@ SongList CollectionWatcher::ScanNewFile(const QString &file, const QString &path
|
||||
// Playlist parser for CUEs considers every entry in sheet valid and we don't want invalid media getting into collection!
|
||||
QString file_nfd = file.normalized(QString::NormalizationForm_D);
|
||||
SongList cue_congs = cue_parser_->Load(&cue_file, matching_cue, path, false);
|
||||
songs.reserve(cue_congs.count());
|
||||
for (Song &cue_song : cue_congs) {
|
||||
cue_song.set_source(source_);
|
||||
cue_song.set_fingerprint(fingerprint);
|
||||
|
@ -122,7 +122,7 @@ void GroupByDialog::accept() {
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void GroupByDialog::CollectionGroupingChanged(const CollectionModel::Grouping &g) {
|
||||
void GroupByDialog::CollectionGroupingChanged(const CollectionModel::Grouping g) {
|
||||
ui_->combobox_first->setCurrentIndex(p_->mapping_.get<tag_group_by>().find(g[0])->combo_box_index);
|
||||
ui_->combobox_second->setCurrentIndex(p_->mapping_.get<tag_group_by>().find(g[1])->combo_box_index);
|
||||
ui_->combobox_third->setCurrentIndex(p_->mapping_.get<tag_group_by>().find(g[2])->combo_box_index);
|
||||
|
@ -45,7 +45,7 @@ class GroupByDialog : public QDialog {
|
||||
~GroupByDialog() override;
|
||||
|
||||
public slots:
|
||||
void CollectionGroupingChanged(const CollectionModel::Grouping &g);
|
||||
void CollectionGroupingChanged(const CollectionModel::Grouping g);
|
||||
void accept() override;
|
||||
|
||||
signals:
|
||||
|
@ -73,7 +73,7 @@ SavedGroupingManager::~SavedGroupingManager() {
|
||||
delete model_;
|
||||
}
|
||||
|
||||
QString SavedGroupingManager::GroupByToString(const CollectionModel::GroupBy &g) {
|
||||
QString SavedGroupingManager::GroupByToString(const CollectionModel::GroupBy g) {
|
||||
|
||||
switch (g) {
|
||||
case CollectionModel::GroupBy_None:
|
||||
|
@ -46,7 +46,7 @@ class SavedGroupingManager : public QDialog {
|
||||
void UpdateModel();
|
||||
void SetFilter(CollectionFilterWidget *filter) { filter_ = filter; }
|
||||
|
||||
static QString GroupByToString(const CollectionModel::GroupBy &g);
|
||||
static QString GroupByToString(const CollectionModel::GroupBy g);
|
||||
|
||||
private slots:
|
||||
void UpdateButtonState();
|
||||
|
@ -71,10 +71,9 @@ bool ContextItemDelegate::helpEvent(QHelpEvent *event, QAbstractItemView *view,
|
||||
|
||||
if (!event || !view) return false;
|
||||
|
||||
QHelpEvent *he = static_cast<QHelpEvent*>(event);
|
||||
QString text = displayText(idx.data(), QLocale::system());
|
||||
|
||||
if (text.isEmpty() || !he) return false;
|
||||
if (text.isEmpty() || !event) return false;
|
||||
|
||||
switch (event->type()) {
|
||||
case QEvent::ToolTip: {
|
||||
@ -84,12 +83,12 @@ bool ContextItemDelegate::helpEvent(QHelpEvent *event, QAbstractItemView *view,
|
||||
bool is_elided = displayed_text.width() < real_text.width();
|
||||
|
||||
if (is_elided) {
|
||||
QToolTip::showText(he->globalPos(), text, view);
|
||||
QToolTip::showText(event->globalPos(), text, view);
|
||||
}
|
||||
else if (idx.data(Qt::ToolTipRole).isValid()) {
|
||||
// If the item has a tooltip text, display it
|
||||
QString tooltip_text = idx.data(Qt::ToolTipRole).toString();
|
||||
QToolTip::showText(he->globalPos(), tooltip_text, view);
|
||||
QToolTip::showText(event->globalPos(), tooltip_text, view);
|
||||
}
|
||||
else {
|
||||
// in case that another text was previously displayed
|
||||
@ -102,7 +101,7 @@ bool ContextItemDelegate::helpEvent(QHelpEvent *event, QAbstractItemView *view,
|
||||
return true;
|
||||
|
||||
case QEvent::WhatsThis:
|
||||
QWhatsThis::showText(he->globalPos(), text, view);
|
||||
QWhatsThis::showText(event->globalPos(), text, view);
|
||||
return true;
|
||||
|
||||
default:
|
||||
@ -408,8 +407,10 @@ void ContextAlbumsView::CopyToDevice() {
|
||||
|
||||
void ContextAlbumsView::ShowInBrowser() {
|
||||
|
||||
const SongList songs = GetSelectedSongs();
|
||||
QList<QUrl> urls;
|
||||
for (const Song &song : GetSelectedSongs()) {
|
||||
urls.reserve(songs.count());
|
||||
for (const Song &song : songs) {
|
||||
urls << song.url();
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -621,6 +621,7 @@ void AlbumCoverChoiceController::SaveCoverEmbeddedAutomatic(const Song &song, co
|
||||
SongList songs = watcher->result();
|
||||
watcher->deleteLater();
|
||||
QList<QUrl> urls;
|
||||
urls.reserve(songs.count());
|
||||
for (const Song &s : songs) urls << s.url();
|
||||
if (result.is_jpeg()) {
|
||||
qint64 id = app_->album_cover_loader()->SaveEmbeddedCoverAsync(urls, result.image_data);
|
||||
@ -665,6 +666,7 @@ void AlbumCoverChoiceController::SaveCoverEmbeddedAutomatic(const Song &song, co
|
||||
SongList songs = watcher->result();
|
||||
watcher->deleteLater();
|
||||
QList<QUrl> urls;
|
||||
urls.reserve(songs.count());
|
||||
for (const Song &s : songs) urls << s.url();
|
||||
qint64 id = app_->album_cover_loader()->SaveEmbeddedCoverAsync(urls, cover_filename);
|
||||
QMutexLocker l(&mutex_cover_save_tasks_);
|
||||
@ -678,7 +680,7 @@ void AlbumCoverChoiceController::SaveCoverEmbeddedAutomatic(const Song &song, co
|
||||
|
||||
}
|
||||
|
||||
void AlbumCoverChoiceController::SaveCoverEmbeddedAutomatic(const QList<QUrl> urls, const QImage &image) {
|
||||
void AlbumCoverChoiceController::SaveCoverEmbeddedAutomatic(const QList<QUrl> &urls, const QImage &image) {
|
||||
|
||||
app_->album_cover_loader()->SaveEmbeddedCoverAsync(urls, image);
|
||||
|
||||
|
@ -145,7 +145,7 @@ class AlbumCoverChoiceController : public QWidget {
|
||||
void SaveCoverEmbeddedAutomatic(const Song &song, const AlbumCoverImageResult &result);
|
||||
void SaveCoverEmbeddedAutomatic(const Song &song, const QUrl &cover_url);
|
||||
void SaveCoverEmbeddedAutomatic(const Song &song, const QString &cover_filename);
|
||||
void SaveCoverEmbeddedAutomatic(const QList<QUrl> urls, const QImage &image);
|
||||
void SaveCoverEmbeddedAutomatic(const QList<QUrl> &urls, const QImage &image);
|
||||
|
||||
static bool CanAcceptDrag(const QDragEnterEvent *e);
|
||||
|
||||
|
@ -43,7 +43,7 @@ void AlbumCoverExporter::SetDialogResult(const AlbumCoverExport::DialogResult &d
|
||||
dialog_result_ = dialog_result;
|
||||
}
|
||||
|
||||
void AlbumCoverExporter::AddExportRequest(Song song) {
|
||||
void AlbumCoverExporter::AddExportRequest(const Song &song) {
|
||||
requests_.append(new CoverExportRunnable(dialog_result_, song));
|
||||
all_ = requests_.count();
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class AlbumCoverExporter : public QObject {
|
||||
static const int kMaxConcurrentRequests;
|
||||
|
||||
void SetDialogResult(const AlbumCoverExport::DialogResult &dialog_result);
|
||||
void AddExportRequest(Song song);
|
||||
void AddExportRequest(const Song &song);
|
||||
void StartExporting();
|
||||
void Cancel();
|
||||
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
@ -32,6 +34,8 @@
|
||||
#include "albumcoverfetcher.h"
|
||||
#include "albumcoverfetchersearch.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
const int AlbumCoverFetcher::kMaxConcurrentRequests = 5;
|
||||
|
||||
AlbumCoverFetcher::AlbumCoverFetcher(CoverProviders *cover_providers, QObject *parent, NetworkAccessManager *network)
|
||||
@ -41,7 +45,7 @@ AlbumCoverFetcher::AlbumCoverFetcher(CoverProviders *cover_providers, QObject *p
|
||||
next_id_(0),
|
||||
request_starter_(new QTimer(this)) {
|
||||
|
||||
request_starter_->setInterval(1000);
|
||||
request_starter_->setInterval(1s);
|
||||
QObject::connect(request_starter_, &QTimer::timeout, this, &AlbumCoverFetcher::StartRequests);
|
||||
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ void AlbumCoverLoader::CancelTask(const quint64 id) {
|
||||
QMutexLocker l(&mutex_load_image_async_);
|
||||
for (QQueue<Task>::iterator it = tasks_.begin(); it != tasks_.end(); ++it) {
|
||||
if (it->id == id) {
|
||||
tasks_.erase(it);
|
||||
tasks_.erase(it); // clazy:exclude=strict-iterators
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -245,7 +245,7 @@ void AlbumCoverLoader::CancelTasks(const QSet<quint64> &ids) {
|
||||
QMutexLocker l(&mutex_load_image_async_);
|
||||
for (QQueue<Task>::iterator it = tasks_.begin(); it != tasks_.end();) {
|
||||
if (ids.contains(it->id)) {
|
||||
it = tasks_.erase(it);
|
||||
it = tasks_.erase(it); // clazy:exclude=strict-iterators
|
||||
}
|
||||
else {
|
||||
++it;
|
||||
@ -531,7 +531,7 @@ void AlbumCoverLoader::RemoteFetchFinished(QNetworkReply *reply, const QUrl &cov
|
||||
|
||||
}
|
||||
|
||||
qint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QString song_filename, const QString &cover_filename) {
|
||||
qint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QString &song_filename, const QString &cover_filename) {
|
||||
|
||||
QMutexLocker l(&mutex_save_image_async_);
|
||||
qint64 id = ++save_image_async_id_;
|
||||
@ -540,7 +540,7 @@ qint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QString song_filename, con
|
||||
|
||||
}
|
||||
|
||||
qint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QString song_filename, const QImage &image) {
|
||||
qint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QString &song_filename, const QImage &image) {
|
||||
|
||||
QMutexLocker l(&mutex_save_image_async_);
|
||||
qint64 id = ++save_image_async_id_;
|
||||
@ -549,7 +549,7 @@ qint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QString song_filename, con
|
||||
|
||||
}
|
||||
|
||||
qint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QString song_filename, const QByteArray &image_data) {
|
||||
qint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QString &song_filename, const QByteArray &image_data) {
|
||||
|
||||
QMutexLocker l(&mutex_save_image_async_);
|
||||
qint64 id = ++save_image_async_id_;
|
||||
@ -558,7 +558,7 @@ qint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QString song_filename, con
|
||||
|
||||
}
|
||||
|
||||
qint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QList<QUrl> urls, const QString &cover_filename) {
|
||||
qint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QList<QUrl> &urls, const QString &cover_filename) {
|
||||
|
||||
QMutexLocker l(&mutex_save_image_async_);
|
||||
qint64 id = ++save_image_async_id_;
|
||||
@ -567,7 +567,7 @@ qint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QList<QUrl> urls, const QS
|
||||
|
||||
}
|
||||
|
||||
qint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QList<QUrl> urls, const QImage &image) {
|
||||
qint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QList<QUrl> &urls, const QImage &image) {
|
||||
|
||||
QMutexLocker l(&mutex_save_image_async_);
|
||||
qint64 id = ++save_image_async_id_;
|
||||
@ -576,7 +576,7 @@ qint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QList<QUrl> urls, const QI
|
||||
|
||||
}
|
||||
|
||||
qint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QList<QUrl> urls, const QByteArray &image_data) {
|
||||
qint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QList<QUrl> &urls, const QByteArray &image_data) {
|
||||
|
||||
QMutexLocker l(&mutex_save_image_async_);
|
||||
qint64 id = ++save_image_async_id_;
|
||||
@ -585,7 +585,7 @@ qint64 AlbumCoverLoader::SaveEmbeddedCoverAsync(const QList<QUrl> urls, const QB
|
||||
|
||||
}
|
||||
|
||||
void AlbumCoverLoader::SaveEmbeddedCover(const qint64 id, const QString song_filename, const QByteArray &image_data) {
|
||||
void AlbumCoverLoader::SaveEmbeddedCover(const qint64 id, const QString &song_filename, const QByteArray &image_data) {
|
||||
|
||||
TagReaderReply *reply = TagReaderClient::Instance()->SaveEmbeddedArt(song_filename, image_data);
|
||||
tagreader_save_embedded_art_requests_.insert(id, reply);
|
||||
@ -594,7 +594,7 @@ void AlbumCoverLoader::SaveEmbeddedCover(const qint64 id, const QString song_fil
|
||||
|
||||
}
|
||||
|
||||
void AlbumCoverLoader::SaveEmbeddedCover(const qint64 id, const QString song_filename, const QImage &image) {
|
||||
void AlbumCoverLoader::SaveEmbeddedCover(const qint64 id, const QString &song_filename, const QImage &image) {
|
||||
|
||||
QByteArray image_data;
|
||||
|
||||
@ -610,7 +610,7 @@ void AlbumCoverLoader::SaveEmbeddedCover(const qint64 id, const QString song_fil
|
||||
|
||||
}
|
||||
|
||||
void AlbumCoverLoader::SaveEmbeddedCover(const qint64 id, const QString song_filename, const QString &cover_filename) {
|
||||
void AlbumCoverLoader::SaveEmbeddedCover(const qint64 id, const QString &song_filename, const QString &cover_filename) {
|
||||
|
||||
QFile file(cover_filename);
|
||||
|
||||
@ -626,7 +626,7 @@ void AlbumCoverLoader::SaveEmbeddedCover(const qint64 id, const QString song_fil
|
||||
|
||||
}
|
||||
|
||||
void AlbumCoverLoader::SaveEmbeddedCover(const qint64 id, const QList<QUrl> urls, const QImage &image) {
|
||||
void AlbumCoverLoader::SaveEmbeddedCover(const qint64 id, const QList<QUrl> &urls, const QImage &image) {
|
||||
|
||||
if (image.isNull()) {
|
||||
for (const QUrl &url : urls) {
|
||||
@ -651,7 +651,7 @@ void AlbumCoverLoader::SaveEmbeddedCover(const qint64 id, const QList<QUrl> urls
|
||||
|
||||
}
|
||||
|
||||
void AlbumCoverLoader::SaveEmbeddedCover(const qint64 id, const QList<QUrl> urls, const QString &cover_filename) {
|
||||
void AlbumCoverLoader::SaveEmbeddedCover(const qint64 id, const QList<QUrl> &urls, const QString &cover_filename) {
|
||||
|
||||
QFile file(cover_filename);
|
||||
|
||||
@ -666,7 +666,7 @@ void AlbumCoverLoader::SaveEmbeddedCover(const qint64 id, const QList<QUrl> urls
|
||||
|
||||
}
|
||||
|
||||
void AlbumCoverLoader::SaveEmbeddedCover(const qint64 id, const QList<QUrl> urls, const QByteArray &image_data) {
|
||||
void AlbumCoverLoader::SaveEmbeddedCover(const qint64 id, const QList<QUrl> &urls, const QByteArray &image_data) {
|
||||
|
||||
for (const QUrl &url : urls) {
|
||||
SaveEmbeddedCover(id, url.toLocalFile(), image_data);
|
||||
|
@ -81,12 +81,12 @@ class AlbumCoverLoader : public QObject {
|
||||
void CancelTask(const quint64 id);
|
||||
void CancelTasks(const QSet<quint64> &ids);
|
||||
|
||||
qint64 SaveEmbeddedCoverAsync(const QString song_filename, const QString &cover_filename);
|
||||
qint64 SaveEmbeddedCoverAsync(const QString song_filename, const QImage &image);
|
||||
qint64 SaveEmbeddedCoverAsync(const QString song_filename, const QByteArray &image_data);
|
||||
qint64 SaveEmbeddedCoverAsync(const QList<QUrl> urls, const QString &cover_filename);
|
||||
qint64 SaveEmbeddedCoverAsync(const QList<QUrl> urls, const QImage &image);
|
||||
qint64 SaveEmbeddedCoverAsync(const QList<QUrl> urls, const QByteArray &image_data);
|
||||
qint64 SaveEmbeddedCoverAsync(const QString &song_filename, const QString &cover_filename);
|
||||
qint64 SaveEmbeddedCoverAsync(const QString &song_filename, const QImage &image);
|
||||
qint64 SaveEmbeddedCoverAsync(const QString &song_filename, const QByteArray &image_data);
|
||||
qint64 SaveEmbeddedCoverAsync(const QList<QUrl> &urls, const QString &cover_filename);
|
||||
qint64 SaveEmbeddedCoverAsync(const QList<QUrl> &urls, const QImage &image);
|
||||
qint64 SaveEmbeddedCoverAsync(const QList<QUrl> &urls, const QByteArray &image_data);
|
||||
|
||||
signals:
|
||||
void ExitFinished();
|
||||
@ -98,12 +98,12 @@ class AlbumCoverLoader : public QObject {
|
||||
void ProcessTasks();
|
||||
void RemoteFetchFinished(QNetworkReply *reply, const QUrl &cover_url);
|
||||
|
||||
void SaveEmbeddedCover(const qint64 id, const QString song_filename, const QString &cover_filename);
|
||||
void SaveEmbeddedCover(const qint64 id, const QString song_filename, const QImage &image);
|
||||
void SaveEmbeddedCover(const qint64 id, const QString song_filename, const QByteArray &image_data);
|
||||
void SaveEmbeddedCover(const qint64 id, const QList<QUrl> urls, const QImage &image);
|
||||
void SaveEmbeddedCover(const qint64 id, const QList<QUrl> urls, const QString &cover_filename);
|
||||
void SaveEmbeddedCover(const qint64 id, const QList<QUrl> urls, const QByteArray &image_data);
|
||||
void SaveEmbeddedCover(const qint64 id, const QString &song_filename, const QString &cover_filename);
|
||||
void SaveEmbeddedCover(const qint64 id, const QString &song_filename, const QImage &image);
|
||||
void SaveEmbeddedCover(const qint64 id, const QString &song_filename, const QByteArray &image_data);
|
||||
void SaveEmbeddedCover(const qint64 id, const QList<QUrl> &urls, const QImage &image);
|
||||
void SaveEmbeddedCover(const qint64 id, const QList<QUrl> &urls, const QString &cover_filename);
|
||||
void SaveEmbeddedCover(const qint64 id, const QList<QUrl> &urls, const QByteArray &image_data);
|
||||
|
||||
void SaveEmbeddedArtFinished(const qint64 id, TagReaderReply *reply, const bool cleared);
|
||||
|
||||
|
@ -594,7 +594,7 @@ bool AlbumCoverManager::eventFilter(QObject *obj, QEvent *e) {
|
||||
|
||||
if (obj == ui_->albums && e->type() == QEvent::ContextMenu) {
|
||||
context_menu_items_ = ui_->albums->selectedItems();
|
||||
if (context_menu_items_.isEmpty()) return false;
|
||||
if (context_menu_items_.isEmpty()) return QMainWindow::eventFilter(obj, e);
|
||||
|
||||
bool some_with_covers = false;
|
||||
bool some_unset = false;
|
||||
@ -624,6 +624,7 @@ bool AlbumCoverManager::eventFilter(QObject *obj, QEvent *e) {
|
||||
context_menu_->popup(context_menu_event->globalPos());
|
||||
return true;
|
||||
}
|
||||
|
||||
return QMainWindow::eventFilter(obj, e);
|
||||
|
||||
}
|
||||
|
@ -67,6 +67,9 @@ class AlbumItem : public QListWidgetItem {
|
||||
public:
|
||||
AlbumItem(const QIcon &icon, const QString &text, QListWidget *parent = nullptr, int type = Type) : QListWidgetItem(icon, text, parent, type) {};
|
||||
QList<QUrl> urls;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(AlbumItem)
|
||||
};
|
||||
|
||||
class AlbumCoverManager : public QMainWindow {
|
||||
|
@ -57,6 +57,7 @@ QMimeData *AlbumCoverManagerList::mimeData(const QList<QListWidgetItem*> items)
|
||||
|
||||
// Get URLs from the songs
|
||||
QList<QUrl> urls;
|
||||
urls.reserve(songs.count());
|
||||
for (const Song &song : songs) {
|
||||
urls << song.url();
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ AlbumCoverImageResult AlbumCoverSearcher::Exec(const QString &artist, const QStr
|
||||
return AlbumCoverImageResult();
|
||||
|
||||
AlbumCoverImageResult result;
|
||||
result.image_data = selected.data(Role_ImageData).value<QByteArray>();
|
||||
result.image_data = selected.data(Role_ImageData).toByteArray();
|
||||
result.image = selected.data(Role_Image).value<QImage>();
|
||||
result.mime_type = Utilities::MimeTypeFromData(result.image_data);
|
||||
|
||||
|
@ -52,6 +52,8 @@ class Application;
|
||||
class Ui_AlbumCoverSearcher;
|
||||
|
||||
class SizeOverlayDelegate : public QStyledItemDelegate {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static const int kMargin;
|
||||
static const int kPaddingX;
|
||||
|
@ -32,7 +32,8 @@
|
||||
#include "albumcoverexport.h"
|
||||
#include "coverexportrunnable.h"
|
||||
|
||||
CoverExportRunnable::CoverExportRunnable(const AlbumCoverExport::DialogResult &dialog_result, const Song &song) :
|
||||
CoverExportRunnable::CoverExportRunnable(const AlbumCoverExport::DialogResult &dialog_result, const Song &song, QObject *parent) :
|
||||
QObject(parent),
|
||||
dialog_result_(dialog_result),
|
||||
song_(song) {}
|
||||
|
||||
|
@ -34,7 +34,7 @@ class CoverExportRunnable : public QObject, public QRunnable {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CoverExportRunnable(const AlbumCoverExport::DialogResult &dialog_result, const Song &song);
|
||||
explicit CoverExportRunnable(const AlbumCoverExport::DialogResult &dialog_result, const Song &song, QObject *parent = nullptr);
|
||||
|
||||
void run() override;
|
||||
|
||||
|
@ -61,7 +61,7 @@ void CoverProviders::ReloadSettings() {
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(CoversSettingsPage::kSettingsGroup);
|
||||
QStringList providers_enabled = s.value("providers", QStringList() << all_providers.values()).toStringList();
|
||||
QStringList providers_enabled = s.value("providers", QStringList() << all_providers.values()).toStringList(); // clazy:exclude=qt6-deprecated-api-fixes
|
||||
s.endGroup();
|
||||
|
||||
int i = 0;
|
||||
@ -71,7 +71,7 @@ void CoverProviders::ReloadSettings() {
|
||||
if (provider) {
|
||||
provider->set_enabled(true);
|
||||
provider->set_order(++i);
|
||||
new_providers << provider;
|
||||
new_providers << provider; // clazy:exclude=reserve-candidates
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -310,7 +310,7 @@ void DeezerCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id)
|
||||
emit SearchFinished(id, CoverProviderSearchResults());
|
||||
}
|
||||
else {
|
||||
CoverProviderSearchResults cover_results = results.values();
|
||||
CoverProviderSearchResults cover_results = results.values(); // clazy:exclude=qt6-deprecated-api-fixes
|
||||
std::stable_sort(cover_results.begin(), cover_results.end(), AlbumCoverFetcherSearch::CoverProviderSearchResultCompareNumber);
|
||||
emit SearchFinished(id, cover_results);
|
||||
}
|
||||
|
@ -268,12 +268,14 @@ void DiscogsCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id)
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonArray array_results;
|
||||
if (value_results.isArray()) {
|
||||
array_results = value_results.toArray();
|
||||
if (!value_results.isArray()) {
|
||||
Error("Missing results array.", value_results);
|
||||
EndSearch(search);
|
||||
return;
|
||||
}
|
||||
|
||||
for (const QJsonValueRef value_result : array_results) {
|
||||
QJsonArray array_results = value_results.toArray();
|
||||
for (QJsonValueRef value_result : array_results) {
|
||||
|
||||
if (!value_result.isObject()) {
|
||||
Error("Invalid Json reply, results value is not a object.");
|
||||
@ -328,7 +330,7 @@ void DiscogsCoverProvider::StartReleaseRequest(std::shared_ptr<DiscogsCoverSearc
|
||||
|
||||
}
|
||||
|
||||
void DiscogsCoverProvider::SendReleaseRequest(const DiscogsCoverReleaseContext release) {
|
||||
void DiscogsCoverProvider::SendReleaseRequest(const DiscogsCoverReleaseContext &release) {
|
||||
|
||||
QNetworkReply *reply = CreateRequest(release.url);
|
||||
QObject::connect(reply, &QNetworkReply::finished, this, [this, reply, release]() { HandleReleaseReply(reply, release.search_id, release.id); } );
|
||||
|
@ -81,7 +81,7 @@ class DiscogsCoverProvider : public JsonCoverProvider {
|
||||
typedef QList<Param> ParamList;
|
||||
|
||||
void SendSearchRequest(std::shared_ptr<DiscogsCoverSearchContext> search);
|
||||
void SendReleaseRequest(const DiscogsCoverReleaseContext release);
|
||||
void SendReleaseRequest(const DiscogsCoverReleaseContext &release);
|
||||
QNetworkReply *CreateRequest(QUrl url, const ParamList ¶ms_provided = ParamList());
|
||||
QByteArray GetReplyData(QNetworkReply *reply);
|
||||
void StartReleaseRequest(std::shared_ptr<DiscogsCoverSearchContext> search, const quint64 release_id, const QUrl &url);
|
||||
|
@ -205,7 +205,7 @@ void SpotifyCoverProvider::RedirectArrived() {
|
||||
|
||||
}
|
||||
|
||||
void SpotifyCoverProvider::RequestAccessToken(const QString code, const QUrl redirect_url) {
|
||||
void SpotifyCoverProvider::RequestAccessToken(const QString &code, const QUrl &redirect_url) {
|
||||
|
||||
refresh_login_timer_.stop();
|
||||
|
||||
@ -250,7 +250,7 @@ void SpotifyCoverProvider::RequestAccessToken(const QString code, const QUrl red
|
||||
|
||||
}
|
||||
|
||||
void SpotifyCoverProvider::HandleLoginSSLErrors(QList<QSslError> ssl_errors) {
|
||||
void SpotifyCoverProvider::HandleLoginSSLErrors(const QList<QSslError> &ssl_errors) {
|
||||
|
||||
for (const QSslError &ssl_error : ssl_errors) {
|
||||
login_errors_ += ssl_error.errorString();
|
||||
|
@ -56,7 +56,7 @@ class SpotifyCoverProvider : public JsonCoverProvider {
|
||||
bool IsAuthenticated() const override { return !access_token_.isEmpty(); }
|
||||
|
||||
private slots:
|
||||
void HandleLoginSSLErrors(QList<QSslError> ssl_errors);
|
||||
void HandleLoginSSLErrors(const QList<QSslError> &ssl_errors);
|
||||
void RedirectArrived();
|
||||
void AccessTokenRequestFinished(QNetworkReply *reply);
|
||||
void HandleSearchReply(QNetworkReply *reply, const int id, const QString &extract);
|
||||
@ -66,7 +66,7 @@ class SpotifyCoverProvider : public JsonCoverProvider {
|
||||
QByteArray GetReplyData(QNetworkReply *reply);
|
||||
void AuthError(const QString &error = QString(), const QVariant &debug = QVariant());
|
||||
void Error(const QString &error, const QVariant &debug = QVariant()) override;
|
||||
void RequestAccessToken(const QString code = QString(), const QUrl redirect_url = QUrl());
|
||||
void RequestAccessToken(const QString &code = QString(), const QUrl &redirect_url = QUrl());
|
||||
|
||||
private:
|
||||
typedef QPair<QString, QString> Param;
|
||||
|
@ -33,8 +33,8 @@ class Application;
|
||||
class DeviceLister;
|
||||
class DeviceManager;
|
||||
|
||||
CddaDevice::CddaDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, DeviceManager *manager, Application *app, int database_id, bool first_time)
|
||||
: ConnectedDevice(url, lister, unique_id, manager, app, database_id, first_time), cdda_song_loader_(url) {
|
||||
CddaDevice::CddaDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, DeviceManager *manager, Application *app, int database_id, bool first_time, QObject *parent)
|
||||
: ConnectedDevice(url, lister, unique_id, manager, app, database_id, first_time, parent), cdda_song_loader_(url) {
|
||||
|
||||
QObject::connect(&cdda_song_loader_, &CddaSongLoader::SongsLoaded, this, &CddaDevice::SongsLoaded);
|
||||
QObject::connect(&cdda_song_loader_, &CddaSongLoader::SongsDurationLoaded, this, &CddaDevice::SongsLoaded);
|
||||
|
@ -46,7 +46,7 @@ class CddaDevice : public ConnectedDevice {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Q_INVOKABLE explicit CddaDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, DeviceManager *manager, Application *app, int database_id, bool first_time);
|
||||
Q_INVOKABLE explicit CddaDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, DeviceManager *manager, Application *app, const int database_id, const bool first_time, QObject *parent = nullptr);
|
||||
|
||||
bool Init() override;
|
||||
void Refresh() override;
|
||||
|
@ -38,7 +38,7 @@ class CddaLister : public DeviceLister {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CddaLister() {}
|
||||
explicit CddaLister(QObject *parent = nullptr) : DeviceLister(parent) {}
|
||||
|
||||
QStringList DeviceUniqueIDs() override;
|
||||
QVariantList DeviceIcons(const QString &id) override;
|
||||
|
@ -126,7 +126,8 @@ void CddaSongLoader::LoadSongs() {
|
||||
}
|
||||
|
||||
SongList songs;
|
||||
for (int track_number = 1; track_number <= num_tracks; track_number++) {
|
||||
songs.reserve(num_tracks);
|
||||
for (int track_number = 1; track_number <= num_tracks; ++track_number) {
|
||||
// Init song
|
||||
Song song(Song::Source_CDDA);
|
||||
song.set_id(track_number);
|
||||
@ -216,8 +217,9 @@ void CddaSongLoader::AudioCDTagsLoaded(const QString &artist, const QString &alb
|
||||
|
||||
MusicBrainzClient *musicbrainz_client = qobject_cast<MusicBrainzClient*>(sender());
|
||||
musicbrainz_client->deleteLater();
|
||||
SongList songs;
|
||||
if (results.empty()) return;
|
||||
SongList songs;
|
||||
songs.reserve(results.count());
|
||||
int track_number = 1;
|
||||
for (const MusicBrainzClient::Result &ret : results) {
|
||||
Song song(Song::Source_CDDA);
|
||||
|
@ -38,8 +38,8 @@
|
||||
#include "devicemanager.h"
|
||||
#include "deviceinfo.h"
|
||||
|
||||
ConnectedDevice::ConnectedDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, DeviceManager *manager, Application *app, int database_id, bool first_time)
|
||||
: QObject(manager),
|
||||
ConnectedDevice::ConnectedDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, DeviceManager *manager, Application *app, const int database_id, const bool first_time, QObject *parent)
|
||||
: QObject(parent),
|
||||
app_(app),
|
||||
url_(url),
|
||||
first_time_(first_time),
|
||||
|
@ -43,7 +43,7 @@ class ConnectedDevice : public QObject, public virtual MusicStorage, public std:
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConnectedDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, DeviceManager *manager, Application *app, int database_id, bool first_time);
|
||||
explicit ConnectedDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, DeviceManager *manager, Application *app, const int database_id, const bool first_time, QObject *parent = nullptr);
|
||||
~ConnectedDevice() override;
|
||||
|
||||
virtual bool Init() = 0;
|
||||
|
@ -45,6 +45,7 @@ DeviceDatabaseBackend::Device DeviceInfo::SaveToDb() const {
|
||||
ret.transcode_format_ = transcode_format_;
|
||||
|
||||
QStringList unique_ids;
|
||||
unique_ids.reserve(backends_.count());
|
||||
for (const Backend &backend : backends_) {
|
||||
unique_ids << backend.unique_id_;
|
||||
}
|
||||
|
@ -121,6 +121,8 @@ class DeviceInfo : public SimpleTreeItem<DeviceInfo> {
|
||||
bool unmount_;
|
||||
bool forget_;
|
||||
|
||||
Q_DISABLE_COPY(DeviceInfo)
|
||||
|
||||
};
|
||||
|
||||
#endif // DEVICEINFO_H
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user