Changeset View
Changeset View
Standalone View
Standalone View
src/panels/information/informationpanelcontent.cpp
| Show First 20 Lines • Show All 190 Lines • ▼ Show 20 Line(s) | 181 | { | |||
|---|---|---|---|---|---|
| 191 | // with a small delay to prevent a flickering when the next preview | 191 | // with a small delay to prevent a flickering when the next preview | ||
| 192 | // can be shown within a short timeframe. This timer is not started | 192 | // can be shown within a short timeframe. This timer is not started | ||
| 193 | // for directories, as directory previews might fail and return the | 193 | // for directories, as directory previews might fail and return the | ||
| 194 | // same icon. | 194 | // same icon. | ||
| 195 | if (!m_item.isDir()) { | 195 | if (!m_item.isDir()) { | ||
| 196 | m_outdatedPreviewTimer->start(); | 196 | m_outdatedPreviewTimer->start(); | ||
| 197 | } | 197 | } | ||
| 198 | 198 | | |||
| 199 | // PreviewJob does not support devicePixelRatio | ||||
| 200 | // manually compute size according to devicePixelRatioF | ||||
| 201 | auto size = QSize(qRound(m_preview->width() * devicePixelRatioF()), | ||||
| 202 | qRound(m_preview->height() * devicePixelRatioF())); | ||||
| 199 | QStringList plugins = KIO::PreviewJob::availablePlugins(); | 203 | QStringList plugins = KIO::PreviewJob::availablePlugins(); | ||
| 200 | m_previewJob = new KIO::PreviewJob(KFileItemList() << m_item, | 204 | m_previewJob = new KIO::PreviewJob(KFileItemList() << m_item, | ||
| 201 | QSize(m_preview->width(), m_preview->height()), | 205 | size, | ||
| 202 | &plugins); | 206 | &plugins); | ||
| 203 | m_previewJob->setScaleType(KIO::PreviewJob::Unscaled); | 207 | m_previewJob->setScaleType(KIO::PreviewJob::Unscaled); | ||
| 204 | m_previewJob->setIgnoreMaximumSize(m_item.isLocalFile()); | 208 | m_previewJob->setIgnoreMaximumSize(m_item.isLocalFile()); | ||
| 205 | if (m_previewJob->uiDelegate()) { | 209 | if (m_previewJob->uiDelegate()) { | ||
| 206 | KJobWidgets::setWindow(m_previewJob, this); | 210 | KJobWidgets::setWindow(m_previewJob, this); | ||
| 207 | } | 211 | } | ||
| 208 | 212 | | |||
| 209 | connect(m_previewJob.data(), &KIO::PreviewJob::gotPreview, | 213 | connect(m_previewJob.data(), &KIO::PreviewJob::gotPreview, | ||
| ▲ Show 20 Lines • Show All 154 Lines • ▼ Show 20 Line(s) | |||||
| 364 | } | 368 | } | ||
| 365 | 369 | | |||
| 366 | void InformationPanelContent::showPreview(const KFileItem& item, | 370 | void InformationPanelContent::showPreview(const KFileItem& item, | ||
| 367 | const QPixmap& pixmap) | 371 | const QPixmap& pixmap) | ||
| 368 | { | 372 | { | ||
| 369 | m_outdatedPreviewTimer->stop(); | 373 | m_outdatedPreviewTimer->stop(); | ||
| 370 | 374 | | |||
| 371 | QPixmap p = pixmap; | 375 | QPixmap p = pixmap; | ||
| 376 | p.setDevicePixelRatio(devicePixelRatioF()); | ||||
| 372 | KIconLoader::global()->drawOverlays(item.overlays(), p, KIconLoader::Desktop); | 377 | KIconLoader::global()->drawOverlays(item.overlays(), p, KIconLoader::Desktop); | ||
| 373 | 378 | | |||
| 374 | if (m_isVideo) { | 379 | if (m_isVideo) { | ||
| 375 | // adds a play arrow | 380 | // adds a play arrow | ||
| 376 | 381 | | |||
| 377 | // compute relative pixel positions | 382 | // compute relative pixel positions | ||
| 378 | const int zeroX = static_cast<int>(p.width() / 2 - PLAY_ARROW_SIZE / 2 / devicePixelRatio()); | 383 | const int zeroX = static_cast<int>(p.width() / 2 - PLAY_ARROW_SIZE / 2 / devicePixelRatio()); | ||
| 379 | const int zeroY = static_cast<int>(p.height() / 2 - PLAY_ARROW_SIZE / 2 / devicePixelRatio()); | 384 | const int zeroY = static_cast<int>(p.height() / 2 - PLAY_ARROW_SIZE / 2 / devicePixelRatio()); | ||
| ▲ Show 20 Lines • Show All 114 Lines • Show Last 20 Lines | |||||