Merge pull request #4776 from dmitrio95/newwizard_thumbnails
Do not generate thumbnails before their usage in New Score Wizard
This commit is contained in:
commit
f797e46976
3 changed files with 13 additions and 10 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace Ms {
|
|||
//---------------------------------------------------------
|
||||
|
||||
class ScoreInfo : public QFileInfo {
|
||||
QPixmap _pixmap;
|
||||
mutable QPixmap _pixmap;
|
||||
|
||||
public:
|
||||
ScoreInfo() {}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue