Merge pull request #4776 from dmitrio95/newwizard_thumbnails

Do not generate thumbnails before their usage in New Score Wizard
This commit is contained in:
anatoly-os 2019-03-07 14:09:31 +02:00 committed by GitHub
commit f797e46976
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 10 deletions

View file

@ -11,6 +11,8 @@
//=============================================================================
#include "scoreInfo.h"
#include "icons.h"
#include "musescore.h"
namespace Ms {
@ -20,6 +22,14 @@ namespace Ms {
QPixmap ScoreInfo::pixmap() const
{
if (_pixmap.isNull()) {
// load or generate an actual thumbnail for the score
_pixmap = mscore->extractThumbnail(filePath());
if (_pixmap.isNull()) {
// couldn't load/generate thumbnail so display generic icon
_pixmap = icons[int(Icons::file_ICON)]->pixmap(QSize(50,60));
}
}
return _pixmap;
}

View file

@ -20,7 +20,7 @@ namespace Ms {
//---------------------------------------------------------
class ScoreInfo : public QFileInfo {
QPixmap _pixmap;
mutable QPixmap _pixmap;
public:
ScoreInfo() {}

View file

@ -101,16 +101,9 @@ TemplateItem* TemplateBrowser::genTemplateItem(QTreeWidgetItem* p, const QFileIn
const qreal cornerRadius = 12.0;
painter.drawRoundedRect(QRect(QPoint(0, 0), thumbnailSize), cornerRadius, cornerRadius);
painter.end();
QPixmapCache::insert(fi.filePath(), pm);
}
else {
// load or generate an actual thumbnail for the score
pm = mscore->extractThumbnail(fi.filePath());
if (pm.isNull()) {
// couldn't load/generate thumbnail so display generic icon
pm = icons[int(Icons::file_ICON)]->pixmap(QSize(50,60));
}
}
QPixmapCache::insert(fi.filePath(), pm);
}
si.setPixmap(pm);