Commit 56cc0c9c authored by Benjamin Arnaud's avatar Benjamin Arnaud Committed by Jean-Baptiste Kempf
Browse files

qt/covergenerator: Add the prefix property

This lets us enforce a specific prefix for the cover fileName.
parent 9e43f884
......@@ -107,6 +107,11 @@ CoverGenerator::CoverGenerator(vlc_medialibrary_t * ml, const MLItemId & itemId,
m_default = fileName;
}
/* Q_INVOKABLE */ void CoverGenerator::setPrefix(const QString & prefix)
{
m_prefix = prefix;
}
//-------------------------------------------------------------------------------------------------
// QRunnable implementation
//-------------------------------------------------------------------------------------------------
......@@ -121,9 +126,15 @@ QString CoverGenerator::execute() /* override */
int64_t id = m_id.id;
QString string = getStringType(type);
QString fileName;
// NOTE: If we don't have a valid prefix we generate one based on the item type.
if (m_prefix.isEmpty())
{
m_prefix = getPrefix(type);
}
QString fileName = QString("%1_thumbnail_%2.jpg").arg(string).arg(id);
fileName = QString("%1_thumbnail_%2.jpg").arg(m_prefix).arg(id);
fileName = dir.absoluteFilePath(fileName);
......@@ -295,7 +306,7 @@ void CoverGenerator::blur(QImage * image)
//-------------------------------------------------------------------------------------------------
QString CoverGenerator::getStringType(vlc_ml_parent_type type) const
QString CoverGenerator::getPrefix(vlc_ml_parent_type type) const
{
switch (type)
{
......
......@@ -75,6 +75,9 @@ public: // Interface
Q_INVOKABLE void setDefaultThumbnail(const QString & fileName);
// NOTE: This lets us enforce a specific prefix for the cover fileName.
Q_INVOKABLE void setPrefix(const QString & prefix);
public: // AsyncTask implementation
QString execute() override;
......@@ -85,7 +88,7 @@ private: // Functions
void blur(QImage * image);
QString getStringType(vlc_ml_parent_type type) const;
QString getPrefix(vlc_ml_parent_type type) const;
QStringList getMedias(int count, int64_t id, vlc_ml_parent_type type) const;
QStringList getGenre (int count, int64_t id) const;
......@@ -109,6 +112,8 @@ private:
int m_blur;
QString m_default;
QString m_prefix;
};
#endif // COVERGENERATOR_HPP
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment