Changeset View
Changeset View
Standalone View
Standalone View
src/panels/information/informationpanelcontent.cpp
Show First 20 Lines • Show All 189 Lines • ▼ Show 20 Line(s) | 180 | { | |||
---|---|---|---|---|---|
190 | // with a small delay to prevent a flickering when the next preview | 190 | // with a small delay to prevent a flickering when the next preview | ||
191 | // can be shown within a short timeframe. This timer is not started | 191 | // can be shown within a short timeframe. This timer is not started | ||
192 | // for directories, as directory previews might fail and return the | 192 | // for directories, as directory previews might fail and return the | ||
193 | // same icon. | 193 | // same icon. | ||
194 | if (!m_item.isDir()) { | 194 | if (!m_item.isDir()) { | ||
195 | m_outdatedPreviewTimer->start(); | 195 | m_outdatedPreviewTimer->start(); | ||
196 | } | 196 | } | ||
197 | 197 | | |||
198 | // PreviewJob does not support devicePixelRatio | ||||
199 | // manually compute size according to devicePixelRatioF | ||||
200 | auto size = QSize(qRound(m_preview->width() * devicePixelRatioF()), | ||||
201 | qRound(m_preview->height() * devicePixelRatioF())); | ||||
198 | QStringList plugins = KIO::PreviewJob::availablePlugins(); | 202 | QStringList plugins = KIO::PreviewJob::availablePlugins(); | ||
199 | m_previewJob = new KIO::PreviewJob(KFileItemList() << m_item, | 203 | m_previewJob = new KIO::PreviewJob(KFileItemList() << m_item, size, &plugins); | ||
200 | QSize(m_preview->width(), m_preview->height()), | | |||
201 | &plugins); | | |||
202 | m_previewJob->setScaleType(KIO::PreviewJob::Unscaled); | 204 | m_previewJob->setScaleType(KIO::PreviewJob::Unscaled); | ||
203 | m_previewJob->setIgnoreMaximumSize(m_item.isLocalFile()); | 205 | m_previewJob->setIgnoreMaximumSize(m_item.isLocalFile()); | ||
204 | if (m_previewJob->uiDelegate()) { | 206 | if (m_previewJob->uiDelegate()) { | ||
205 | KJobWidgets::setWindow(m_previewJob, this); | 207 | KJobWidgets::setWindow(m_previewJob, this); | ||
206 | } | 208 | } | ||
207 | 209 | | |||
208 | connect(m_previewJob.data(), &KIO::PreviewJob::gotPreview, | 210 | connect(m_previewJob.data(), &KIO::PreviewJob::gotPreview, | ||
209 | this, &InformationPanelContent::showPreview); | 211 | this, &InformationPanelContent::showPreview); | ||
Show All 17 Lines | 227 | if (InformationPanelSettings::previewsShown()) { | |||
227 | const QUrl itemUrl = m_item.url(); | 229 | const QUrl itemUrl = m_item.url(); | ||
228 | const bool isSearchUrl = itemUrl.scheme().contains(QLatin1String("search")) && m_item.localPath().isEmpty(); | 230 | const bool isSearchUrl = itemUrl.scheme().contains(QLatin1String("search")) && m_item.localPath().isEmpty(); | ||
229 | if (isSearchUrl) { | 231 | if (isSearchUrl) { | ||
230 | m_preview->show(); | 232 | m_preview->show(); | ||
231 | 233 | | |||
232 | // in the case of a search-URL the URL is not readable for humans | 234 | // in the case of a search-URL the URL is not readable for humans | ||
233 | // (at least not useful to show in the Information Panel) | 235 | // (at least not useful to show in the Information Panel) | ||
234 | m_preview->setPixmap( | 236 | m_preview->setPixmap( | ||
235 | QIcon::fromTheme(QStringLiteral("baloo")).pixmap(KIconLoader::SizeEnormous, KIconLoader::SizeEnormous) | 237 | QIcon::fromTheme(QStringLiteral("baloo")).pixmap(m_preview->height(), m_preview->width()) | ||
236 | ); | 238 | ); | ||
237 | } else { | 239 | } else { | ||
238 | 240 | | |||
239 | refreshPixmapView(); | 241 | refreshPixmapView(); | ||
240 | 242 | | |||
241 | const QString mimeType = m_item.mimetype(); | 243 | const QString mimeType = m_item.mimetype(); | ||
242 | const bool isAnimatedImage = m_preview->isAnimatedImage(itemUrl.toLocalFile()); | 244 | const bool isAnimatedImage = m_preview->isAnimatedImage(itemUrl.toLocalFile()); | ||
243 | m_isVideo = !isAnimatedImage && mimeType.startsWith(QLatin1String("video/")); | 245 | m_isVideo = !isAnimatedImage && mimeType.startsWith(QLatin1String("video/")); | ||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Line(s) | 308 | { | |||
308 | // multiple items running, and thus a race condition (bug 250787). | 310 | // multiple items running, and thus a race condition (bug 250787). | ||
309 | if (m_previewJob) { | 311 | if (m_previewJob) { | ||
310 | m_previewJob->kill(); | 312 | m_previewJob->kill(); | ||
311 | } | 313 | } | ||
312 | 314 | | |||
313 | m_preview->stopAnimatedImage(); | 315 | m_preview->stopAnimatedImage(); | ||
314 | 316 | | |||
315 | m_preview->setPixmap( | 317 | m_preview->setPixmap( | ||
316 | QIcon::fromTheme(QStringLiteral("dialog-information")).pixmap(KIconLoader::SizeEnormous, KIconLoader::SizeEnormous) | 318 | QIcon::fromTheme(QStringLiteral("dialog-information")).pixmap(m_preview->height(), m_preview->width()) | ||
317 | ); | 319 | ); | ||
318 | setNameLabelText(i18ncp("@label", "%1 item selected", "%1 items selected", items.count())); | 320 | setNameLabelText(i18ncp("@label", "%1 item selected", "%1 items selected", items.count())); | ||
319 | 321 | | |||
320 | m_metaDataWidget->setItems(items); | 322 | m_metaDataWidget->setItems(items); | ||
321 | 323 | | |||
322 | m_phononWidget->hide(); | 324 | m_phononWidget->hide(); | ||
323 | 325 | | |||
324 | m_item = KFileItem(); | 326 | m_item = KFileItem(); | ||
Show All 27 Lines | 330 | { | |||
352 | } | 354 | } | ||
353 | 355 | | |||
354 | return QWidget::eventFilter(obj, event); | 356 | return QWidget::eventFilter(obj, event); | ||
355 | } | 357 | } | ||
356 | 358 | | |||
357 | void InformationPanelContent::showIcon(const KFileItem& item) | 359 | void InformationPanelContent::showIcon(const KFileItem& item) | ||
358 | { | 360 | { | ||
359 | m_outdatedPreviewTimer->stop(); | 361 | m_outdatedPreviewTimer->stop(); | ||
360 | QPixmap pixmap = QIcon::fromTheme(item.iconName()).pixmap(KIconLoader::SizeEnormous, KIconLoader::SizeEnormous); | 362 | QPixmap pixmap = QIcon::fromTheme(item.iconName()).pixmap(m_preview->width(), m_preview->height()); | ||
361 | KIconLoader::global()->drawOverlays(item.overlays(), pixmap, KIconLoader::Desktop); | 363 | KIconLoader::global()->drawOverlays(item.overlays(), pixmap, KIconLoader::Desktop); | ||
362 | m_preview->setPixmap(pixmap); | 364 | m_preview->setPixmap(pixmap); | ||
363 | } | 365 | } | ||
364 | 366 | | |||
365 | void InformationPanelContent::showPreview(const KFileItem& item, | 367 | void InformationPanelContent::showPreview(const KFileItem& item, | ||
366 | const QPixmap& pixmap) | 368 | const QPixmap& pixmap) | ||
367 | { | 369 | { | ||
368 | m_outdatedPreviewTimer->stop(); | 370 | m_outdatedPreviewTimer->stop(); | ||
369 | 371 | | |||
370 | QPixmap p = pixmap; | 372 | QPixmap p = pixmap; | ||
371 | KIconLoader::global()->drawOverlays(item.overlays(), p, KIconLoader::Desktop); | 373 | p.setDevicePixelRatio(devicePixelRatioF()); | ||
372 | 374 | | |||
373 | if (m_isVideo) { | 375 | if (m_isVideo) { | ||
374 | // adds a play arrow | 376 | // adds a play arrow | ||
375 | 377 | | |||
376 | // compute relative pixel positions | 378 | // compute relative pixel positions | ||
377 | const int zeroX = static_cast<int>(p.width() / 2 - PLAY_ARROW_SIZE / 2 / devicePixelRatio()); | 379 | const int zeroX = static_cast<int>(p.width() / 2 - PLAY_ARROW_SIZE / 2 / devicePixelRatio()); | ||
378 | const int zeroY = static_cast<int>(p.height() / 2 - PLAY_ARROW_SIZE / 2 / devicePixelRatio()); | 380 | const int zeroY = static_cast<int>(p.height() / 2 - PLAY_ARROW_SIZE / 2 / devicePixelRatio()); | ||
379 | 381 | | |||
▲ Show 20 Lines • Show All 113 Lines • Show Last 20 Lines |