|
30 | 30 | // todo: use widget options to decouple gui from engine() |
31 | 31 | extern Engine& engine(); |
32 | 32 |
|
| 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 | + |
33 | 44 | MediaBrowser::MediaBrowser(const MediaWidgetOptions& options) : _options(options) {} |
34 | 45 |
|
35 | 46 | int MediaBrowser::showList(const MediaGroupList& list, const MediaWidgetOptions& options) { |
@@ -114,11 +125,7 @@ int MediaBrowser::showFolders(const MediaGroupList& list, const MediaWidgetOptio |
114 | 125 |
|
115 | 126 | auto f = QtConcurrent::map(index, [&](Media& m) { |
116 | 127 | 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); |
122 | 129 | m.setImage(img); |
123 | 130 | m.readMetadata(); |
124 | 131 | }); |
@@ -198,7 +205,7 @@ int MediaBrowser::showSets(const MediaGroupList& list, const MediaWidgetOptions& |
198 | 205 | index.removeFirst(); |
199 | 206 |
|
200 | 207 | 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)); |
202 | 209 | m.readMetadata(); |
203 | 210 | }); |
204 | 211 | while (f.isRunning()) { |
|
0 commit comments