mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Profile: add "synchronous" mode for picture plotting
The thumbnails were fetched in the background to achieve a snappier UI. The problem with that is that on LaTeX etc. export only placeholder thumbnails were shown. Therefore, implement a synchronous mode. This only tries to fetch cached thumbnails or calculate thumbnails for images. Videos and remote files are not supported. Fixes #1963 Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
403c920f29
commit
a16cca1fcb
6 changed files with 40 additions and 15 deletions
|
|
@ -456,8 +456,23 @@ void Thumbnailer::imageDownloadFailed(QString filename)
|
|||
workingOn.remove(filename);
|
||||
}
|
||||
|
||||
QImage Thumbnailer::fetchThumbnail(const QString &filename)
|
||||
QImage Thumbnailer::fetchThumbnail(const QString &filename, bool synchronous)
|
||||
{
|
||||
if (synchronous) {
|
||||
// In synchronous mode, first try the thumbnail cache.
|
||||
Thumbnail thumbnail = getThumbnailFromCache(filename);
|
||||
if (!thumbnail.img.isNull())
|
||||
return thumbnail.img;
|
||||
|
||||
// If that didn't work, try to thumbnail the image.
|
||||
thumbnail = getHashedImage(filename, false);
|
||||
if (thumbnail.type == MEDIATYPE_STILL_LOADING || thumbnail.img.isNull())
|
||||
return failImage; // No support for delayed thumbnails (web).
|
||||
|
||||
int size = maxThumbnailSize();
|
||||
return thumbnail.img.scaled(size, size, Qt::KeepAspectRatio);
|
||||
}
|
||||
|
||||
QMutexLocker l(&lock);
|
||||
|
||||
// We are not currently fetching this thumbnail - add it to the list.
|
||||
|
|
|
|||
|
|
@ -31,9 +31,13 @@ public:
|
|||
static Thumbnailer *instance();
|
||||
|
||||
// Schedule a thumbnail for fetching or calculation.
|
||||
// Returns a placeholder thumbnail. The actual thumbnail will be sent
|
||||
// via a signal later.
|
||||
QImage fetchThumbnail(const QString &filename);
|
||||
// If synchronous is false, returns a placeholder thumbnail.
|
||||
// The actual thumbnail will be sent via a signal later.
|
||||
// If synchronous is true, try to fetch the actual thumbnail.
|
||||
// In this mode only precalculated thumbnails or thumbnails
|
||||
// from pictures are returned. Video extraction and remote
|
||||
// images are not supported.
|
||||
QImage fetchThumbnail(const QString &filename, bool synchronous);
|
||||
|
||||
// Schedule multiple thumbnails for forced recalculation
|
||||
void calculateThumbnails(const QVector<QString> &filenames);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue