Changeset View
Changeset View
Standalone View
Standalone View
lib/document/loadingdocumentimpl.cpp
Show First 20 Lines • Show All 73 Lines • ▼ Show 20 Line(s) | |||||
74 | #undef LOG | 74 | #undef LOG | ||
75 | //#define ENABLE_LOG | 75 | //#define ENABLE_LOG | ||
76 | #ifdef ENABLE_LOG | 76 | #ifdef ENABLE_LOG | ||
77 | #define LOG(x) //qDebug() << x | 77 | #define LOG(x) //qDebug() << x | ||
78 | #else | 78 | #else | ||
79 | #define LOG(x) ; | 79 | #define LOG(x) ; | ||
80 | #endif | 80 | #endif | ||
81 | 81 | | |||
82 | const int MIN_PREV_SIZE = 1000; | | |||
83 | | ||||
84 | const int HEADER_SIZE = 256; | 82 | const int HEADER_SIZE = 256; | ||
85 | 83 | | |||
86 | struct LoadingDocumentImplPrivate | 84 | struct LoadingDocumentImplPrivate | ||
87 | { | 85 | { | ||
88 | LoadingDocumentImpl* q; | 86 | LoadingDocumentImpl* q; | ||
89 | QPointer<KIO::TransferJob> mTransferJob; | 87 | QPointer<KIO::TransferJob> mTransferJob; | ||
90 | QFuture<bool> mMetaInfoFuture; | 88 | QFuture<bool> mMetaInfoFuture; | ||
91 | QFutureWatcher<bool> mMetaInfoFutureWatcher; | 89 | QFutureWatcher<bool> mMetaInfoFutureWatcher; | ||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Line(s) | 203 | if (KDcrawIface::KDcraw::rawFilesList().contains(QString::fromLatin1(mFormatHint))) { | |||
207 | 205 | | |||
208 | // if the image is in format supported by dcraw, fetch its embedded preview | 206 | // if the image is in format supported by dcraw, fetch its embedded preview | ||
209 | mJpegContent.reset(new JpegContent()); | 207 | mJpegContent.reset(new JpegContent()); | ||
210 | 208 | | |||
211 | // use KDcraw for getting the embedded preview | 209 | // use KDcraw for getting the embedded preview | ||
212 | // KDcraw functionality cloned locally (temp. solution) | 210 | // KDcraw functionality cloned locally (temp. solution) | ||
213 | bool ret = KDcrawIface::KDcraw::loadEmbeddedPreview(previewData, buffer); | 211 | bool ret = KDcrawIface::KDcraw::loadEmbeddedPreview(previewData, buffer); | ||
214 | 212 | | |||
215 | QImage originalImage; | 213 | if (!ret) { | ||
216 | if (!ret || !originalImage.loadFromData(previewData) || qMin(originalImage.width(), originalImage.height()) < MIN_PREV_SIZE) { | 214 | // if the embedded preview loading failed, load half preview instead. | ||
217 | // if the embedded preview loading failed or gets just a small image, load | 215 | // That's slower but it works even for images containing | ||
218 | // half preview instead. That's slower but it works even for images containing | | |||
219 | // small (160x120px) or none embedded preview. | 216 | // small (160x120px) or none embedded preview. | ||
220 | if (!KDcrawIface::KDcraw::loadHalfPreview(previewData, buffer)) { | 217 | if (!KDcrawIface::KDcraw::loadHalfPreview(previewData, buffer)) { | ||
221 | qWarning() << "unable to get half preview for " << q->document()->url().fileName(); | 218 | qWarning() << "unable to get half preview for " << q->document()->url().fileName(); | ||
222 | return false; | 219 | return false; | ||
223 | } | 220 | } | ||
224 | } | 221 | } | ||
225 | 222 | | |||
226 | buffer.close(); | 223 | buffer.close(); | ||
▲ Show 20 Lines • Show All 329 Lines • Show Last 20 Lines |