Skip to content

Commit 99df0bd

Browse files
committed
Folder view: scale video thumbnails
1 parent 12ee694 commit 99df0bd

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

gui/mediabrowser.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@
3030
// todo: use widget options to decouple gui from engine()
3131
extern Engine& engine();
3232

33+
static QImage loadThumb(const Media& m, const MediaWidgetOptions& options) {
34+
QImage img;
35+
if (m.type() == Media::TypeVideo) {
36+
img = VideoContext::frameGrab(m.path(), -1, true);
37+
img = Media(img).loadImage(QSize(0, options.iconSize));
38+
}
39+
else
40+
img = m.loadImage(QSize(0, options.iconSize));
41+
return img;
42+
}
43+
3344
MediaBrowser::MediaBrowser(const MediaWidgetOptions& options) : _options(options) {}
3445

3546
int MediaBrowser::showList(const MediaGroupList& list, const MediaWidgetOptions& options) {
@@ -114,11 +125,7 @@ int MediaBrowser::showFolders(const MediaGroupList& list, const MediaWidgetOptio
114125

115126
auto f = QtConcurrent::map(index, [&](Media& m) {
116127
const Media& first = folders[m.path()][0][0];
117-
QImage img;
118-
if (first.type() == Media::TypeVideo)
119-
img = VideoContext::frameGrab(first.path(), -1, true);
120-
else
121-
img = first.loadImage(QSize(0, options.iconSize));
128+
QImage img = loadThumb(first, options);
122129
m.setImage(img);
123130
m.readMetadata();
124131
});
@@ -198,7 +205,7 @@ int MediaBrowser::showSets(const MediaGroupList& list, const MediaWidgetOptions&
198205
index.removeFirst();
199206

200207
auto f = QtConcurrent::map(index, [&](Media& m) {
201-
m.setImage(sets[m.path()][0][0].loadImage(QSize{0, options.iconSize}));
208+
m.setImage(loadThumb(sets[m.path()][0][0], options));
202209
m.readMetadata();
203210
});
204211
while (f.isRunning()) {

0 commit comments

Comments
 (0)