diff --git a/modules/gui/qt/maininterface/mainui.cpp b/modules/gui/qt/maininterface/mainui.cpp index 43d18a3f04e126162e8072cd8414237cdca0fd91..634596485220595678ef5afb4ef2ac374c9088da 100644 --- a/modules/gui/qt/maininterface/mainui.cpp +++ b/modules/gui/qt/maininterface/mainui.cpp @@ -80,8 +80,6 @@ using namespace vlc::playlist; namespace { -const QString MLCUSTOMCOVER_PROVIDERID = "mlcustomcover"; - template<class T> class SingletonRegisterHelper { @@ -163,10 +161,7 @@ bool MainUI::setup(QQmlEngine* engine) if (m_mainCtx->hasMediaLibrary()) { - auto customCover = new MLCustomCover(MLCUSTOMCOVER_PROVIDERID, m_mainCtx->getMediaLibrary()); - m_mainCtx->getMediaLibrary()->setCustomCover(customCover); - - engine->addImageProvider(MLCUSTOMCOVER_PROVIDERID, customCover); + engine->addImageProvider(MLCustomCover::providerId, new MLCustomCover(m_mainCtx->getMediaLibrary())); } #if QT_VERSION < QT_VERSION_CHECK(6, 5, 0) diff --git a/modules/gui/qt/medialibrary/medialib.cpp b/modules/gui/qt/medialibrary/medialib.cpp index a19f93b85c74c43cb0c387bdec86e558b194051e..5fb0b8fb21f1865331e8ad5fc4839d7b5c883545 100644 --- a/modules/gui/qt/medialibrary/medialib.cpp +++ b/modules/gui/qt/medialibrary/medialib.cpp @@ -540,13 +540,3 @@ void MediaLib::runOnMLThreadTargetDestroyed(QObject * object) //no need to disconnect QObject::destroyed, as object is currently being destroyed } } - -MLCustomCover *MediaLib::customCover() const -{ - return m_customCover; -} - -void MediaLib::setCustomCover(MLCustomCover *newCustomCover) -{ - m_customCover = newCustomCover; -} diff --git a/modules/gui/qt/medialibrary/medialib.hpp b/modules/gui/qt/medialibrary/medialib.hpp index 84f305dd94e40af1decfffbcc0154e334c0cf721..68d0b763e124ea26a4e811434bf0d50d2e75607e 100644 --- a/modules/gui/qt/medialibrary/medialib.hpp +++ b/modules/gui/qt/medialibrary/medialib.hpp @@ -27,9 +27,6 @@ #include "mlthreadpool.hpp" #include "mlqmltypes.hpp" - -class MLCustomCover; - namespace vlc { namespace playlist { class Media; @@ -177,9 +174,6 @@ public: */ void cancelMLTask(const QObject* object, quint64 taskId); - MLCustomCover *customCover() const; - void setCustomCover(MLCustomCover *newCustomCover); - signals: void discoveryStarted(); void discoveryCompleted(); @@ -200,7 +194,6 @@ private slots: private: qt_intf_t* m_intf; vlc::playlist::PlaylistController* m_playlistController = nullptr; - MLCustomCover *m_customCover {}; bool m_idle = false; bool m_discoveryPending = false; diff --git a/modules/gui/qt/medialibrary/mlcustomcover.cpp b/modules/gui/qt/medialibrary/mlcustomcover.cpp index 9d66683186128574ad31989d24c4e09354f2bf0e..c8a3728ac1fba86b39739cc157340fedec94e8e0 100644 --- a/modules/gui/qt/medialibrary/mlcustomcover.cpp +++ b/modules/gui/qt/medialibrary/mlcustomcover.cpp @@ -281,18 +281,17 @@ private: }; -MLCustomCover::MLCustomCover(const QString &providerId, MediaLib *ml) - : m_providerId {providerId} - , m_ml {ml} +MLCustomCover::MLCustomCover(MediaLib *ml) + : m_ml {ml} { } -QString MLCustomCover::get(const MLItemId &parentId, const QSize &size, const QString &defaultCover +QString MLCustomCover::url(const MLItemId &parentId, const QSize &size, const QString &defaultCover , const int countX, const int countY, const int blur, const bool split_duplicate) { QUrl url; url.setScheme(QStringLiteral("image")); - url.setHost(m_providerId); + url.setHost(MLCustomCover::providerId); url.setQuery(toQuery({parentId, size, countX, countY, blur, split_duplicate, defaultCover})); return url.toString(); } diff --git a/modules/gui/qt/medialibrary/mlcustomcover.hpp b/modules/gui/qt/medialibrary/mlcustomcover.hpp index 297d6fd9437a838a765f1c6fa673ae255ccc85d5..dce077b77f94a6d5f6f268c43c1db993a3732b16 100644 --- a/modules/gui/qt/medialibrary/mlcustomcover.hpp +++ b/modules/gui/qt/medialibrary/mlcustomcover.hpp @@ -31,9 +31,11 @@ class MediaLib; class MLCustomCover : public QQuickAsyncImageProvider { public: - MLCustomCover(const QString &providerId, MediaLib *ml); + MLCustomCover(MediaLib *ml); - QString get(const MLItemId &parentId + inline static const char* providerId = "mlcustomcover"; + + static QString url(const MLItemId &parentId , const QSize &size , const QString &defaultCover , const int countX = 2 @@ -44,7 +46,6 @@ public: QQuickImageResponse *requestImageResponse(const QString &id, const QSize &requestedSize); private: - const QString m_providerId; MediaLib *m_ml = nullptr; }; diff --git a/modules/gui/qt/medialibrary/mlgenremodel.cpp b/modules/gui/qt/medialibrary/mlgenremodel.cpp index 6b2f96b731de00e7580705066177d40e2294fafd..f36af5f71a6291608ebb6e794b004031390de9b4 100644 --- a/modules/gui/qt/medialibrary/mlgenremodel.cpp +++ b/modules/gui/qt/medialibrary/mlgenremodel.cpp @@ -126,13 +126,13 @@ vlc_ml_sorting_criteria_t MLGenreModel::nameToCriteria(QByteArray name) const QString MLGenreModel::getCover(MLGenre * genre) const { - return ml()->customCover()->get(genre->getId() - , QSize(MLGENREMODEL_COVER_WIDTH, MLGENREMODEL_COVER_HEIGHT) - , m_coverDefault - , MLGENREMODEL_COVER_COUNTX - , MLGENREMODEL_COVER_COUNTY - , MLGENREMODEL_COVER_BLUR - , true); + return MLCustomCover::url(genre->getId() + , QSize(MLGENREMODEL_COVER_WIDTH, MLGENREMODEL_COVER_HEIGHT) + , m_coverDefault + , MLGENREMODEL_COVER_COUNTX + , MLGENREMODEL_COVER_COUNTY + , MLGENREMODEL_COVER_BLUR + , true); } //------------------------------------------------------------------------------------------------- diff --git a/modules/gui/qt/medialibrary/mlplaylistlistmodel.cpp b/modules/gui/qt/medialibrary/mlplaylistlistmodel.cpp index a66537984e381bbfd5b84a4f2f17cebd11a7a282..9dd8a5179be0fe69cfcb9b19075dcf300759bb7d 100644 --- a/modules/gui/qt/medialibrary/mlplaylistlistmodel.cpp +++ b/modules/gui/qt/medialibrary/mlplaylistlistmodel.cpp @@ -358,10 +358,10 @@ void MLPlaylistListModel::setTransactionPending(const bool value) QString MLPlaylistListModel::getCover(MLPlaylist * playlist) const { - return ml()->customCover()->get(playlist->getId() - , m_coverSize - , m_coverDefault - , PLAYLIST_COVERX, PLAYLIST_COVERY); + return MLCustomCover::url(playlist->getId() + , m_coverSize + , m_coverDefault + , PLAYLIST_COVERX, PLAYLIST_COVERY); } //------------------------------------------------------------------------------------------------- diff --git a/modules/gui/qt/medialibrary/mlvideofoldersmodel.cpp b/modules/gui/qt/medialibrary/mlvideofoldersmodel.cpp index 973eb6390a72a1b8f0a46f5440fe412811a76a5e..a3df944fef7217547e911bc6667056222050e47d 100644 --- a/modules/gui/qt/medialibrary/mlvideofoldersmodel.cpp +++ b/modules/gui/qt/medialibrary/mlvideofoldersmodel.cpp @@ -83,9 +83,9 @@ QVariant MLVideoFoldersModel::itemRoleData(MLItem * item, const int role) const return QVariant::fromValue( getFirstSymbol(folder->getTitle()) ); case FOLDER_THUMBNAIL: { - return ml()->customCover()->get(folder->getId() - , QSize(MLVIDEOFOLDERSMODEL_COVER_WIDTH, MLVIDEOFOLDERSMODEL_COVER_HEIGHT) - , QStringLiteral(":/placeholder/noart_videoCover.svg")); + return MLCustomCover::url(folder->getId() + , QSize(MLVIDEOFOLDERSMODEL_COVER_WIDTH, MLVIDEOFOLDERSMODEL_COVER_HEIGHT) + , QStringLiteral(":/placeholder/noart_videoCover.svg")); } case FOLDER_DURATION: return QVariant::fromValue(folder->getDuration()); diff --git a/modules/gui/qt/medialibrary/mlvideogroupsmodel.cpp b/modules/gui/qt/medialibrary/mlvideogroupsmodel.cpp index 5f402753ef9535164c1c319d71fca07d5cff42fb..6512f24c58926f9574630fe0b66e257f2665f220 100644 --- a/modules/gui/qt/medialibrary/mlvideogroupsmodel.cpp +++ b/modules/gui/qt/medialibrary/mlvideogroupsmodel.cpp @@ -94,9 +94,11 @@ QVariant MLVideoGroupsModel::itemRoleData(MLItem * item, const int role) const / return QVariant::fromValue(group->getTitle()); case VIDEO_THUMBNAIL: { - return ml()->customCover()->get(group->getId() - , QSize(MLVIDEOGROUPSMODEL_COVER_WIDTH, MLVIDEOGROUPSMODEL_COVER_HEIGHT) - , QStringLiteral(":/placeholder/noart_videoCover.svg")); + return MLCustomCover::url( + group->getId(), + QSize(MLVIDEOGROUPSMODEL_COVER_WIDTH, MLVIDEOGROUPSMODEL_COVER_HEIGHT), + QStringLiteral(":/placeholder/noart_videoCover.svg") + ); } case VIDEO_DURATION: return QVariant::fromValue(group->getDuration());