Skip to content
Snippets Groups Projects
Commit d054bae9 authored by Pierre Lamot's avatar Pierre Lamot Committed by Rémi Denis-Courmont
Browse files

qml: update default placeholder of generated covers

parent e669d03e
No related branches found
No related tags found
Loading
......@@ -82,6 +82,20 @@ QHash<int, QByteArray> MLGenreModel::roleNames() const
};
}
QString MLGenreModel::getCoverDefault() const
{
return m_coverDefault;
}
void MLGenreModel::setCoverDefault(const QString& defaultCover)
{
if (m_coverDefault == defaultCover)
return;
m_coverDefault = defaultCover;
emit coverDefaultChanged();
}
void MLGenreModel::onVlcMlEvent(const MLEvent &event)
{
switch (event.i_type)
......@@ -137,7 +151,7 @@ QString MLGenreModel::getCover(MLGenre * genre) const
genre->setGenerator(true);
m_mediaLib->runOnMLThread<Context>(this,
//ML thread
[genreId]
[genreId, coverDefault = m_coverDefault]
(vlc_medialibrary_t* ml, Context& ctx)
{
CoverGenerator generator{ml, genreId};
......@@ -152,7 +166,8 @@ QString MLGenreModel::getCover(MLGenre * genre) const
generator.setBlur(MLGENREMODEL_COVER_BLUR);
generator.setDefaultThumbnail(":/noart_album.svg");
if (!coverDefault.isEmpty())
generator.setDefaultThumbnail(coverDefault);
if (generator.cachedFileAvailable())
ctx.cover = generator.cachedFileURL();
......
......@@ -31,6 +31,9 @@ class MLGenreModel : public MLBaseModel
{
Q_OBJECT
Q_PROPERTY(QString coverDefault READ getCoverDefault WRITE setCoverDefault
NOTIFY coverDefaultChanged FINAL)
public:
enum Roles
{
......@@ -49,6 +52,12 @@ public:
QHash<int, QByteArray> roleNames() const override;
QString getCoverDefault() const;
void setCoverDefault(const QString& defaultCover);
signals:
void coverDefaultChanged() const;
protected:
QVariant itemRoleData(MLItem *item, int role) const override;
......@@ -61,6 +70,8 @@ private:
QString getCover(MLGenre * genre) const;
QString m_coverDefault;
private:
struct Loader : public BaseLoader
{
......
......@@ -316,7 +316,8 @@ QString MLPlaylistListModel::getCover(MLPlaylist * playlist) const
generator.setSize(coverSize);
generator.setDefaultThumbnail(coverDefault);
if (!coverDefault.isEmpty())
generator.setDefaultThumbnail(coverDefault);
generator.setPrefix(coverPrefix);
......
......@@ -74,6 +74,8 @@ FocusScope {
id: genreModel
ml: MediaLib
coverDefault: VLCStyle.noArtAlbumCover
onCountChanged: {
if (genreModel.count > 0 && !selectionModel.hasSelection) {
root.resetFocus()
......
......@@ -176,7 +176,7 @@ FocusScope {
coverSize: (isMusic) ? Qt.size(512, 512)
: Qt.size(1024, 640)
coverDefault: (isMusic) ? ":/noart_album.svg" : ":/noart_videoCover.svg"
coverDefault: (isMusic) ? VLCStyle.noArtAlbumCover : VLCStyle.noArtVideoCover
coverPrefix: (isMusic) ? "playlist-music" : "playlist-video"
......
......@@ -47,7 +47,7 @@ static const QString COVERGENERATOR_STORAGE = "/art/qt-covers";
static const int COVERGENERATOR_COUNT = 2;
static const QString COVERGENERATOR_DEFAULT = ":/noart.png";
static const QString COVERGENERATOR_DEFAULT = ":/noart_albumCover.svg";
//-------------------------------------------------------------------------------------------------
// Ctor / dtor
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment