Changeset View
Changeset View
Standalone View
Standalone View
lib/thumbnailview/thumbnailview.cpp
Show First 20 Lines • Show All 381 Lines • ▼ Show 20 Line(s) | 380 | { | |||
---|---|---|---|---|---|
382 | // mWaitingThumbnail | 382 | // mWaitingThumbnail | ||
383 | const auto dpr = devicePixelRatioF(); | 383 | const auto dpr = devicePixelRatioF(); | ||
384 | int waitingThumbnailSize; | 384 | int waitingThumbnailSize; | ||
385 | if (value.width() > 64 * dpr) { | 385 | if (value.width() > 64 * dpr) { | ||
386 | waitingThumbnailSize = qRound(48 * dpr); | 386 | waitingThumbnailSize = qRound(48 * dpr); | ||
387 | } else { | 387 | } else { | ||
388 | waitingThumbnailSize = qRound(32 * dpr); | 388 | waitingThumbnailSize = qRound(32 * dpr); | ||
389 | } | 389 | } | ||
390 | QPixmap icon = DesktopIcon(QStringLiteral("chronometer"), waitingThumbnailSize); | 390 | QPixmap icon = QIcon::fromTheme(QStringLiteral("chronometer")).pixmap(waitingThumbnailSize); | ||
vkrause: btw, QIcon::pixmap exists in a single argument variant as well, so you don't have to repeat the… | |||||
391 | QPixmap pix(value); | 391 | QPixmap pix(value); | ||
392 | pix.fill(Qt::transparent); | 392 | pix.fill(Qt::transparent); | ||
393 | QPainter painter(&pix); | 393 | QPainter painter(&pix); | ||
394 | painter.setOpacity(0.5); | 394 | painter.setOpacity(0.5); | ||
395 | painter.drawPixmap((value.width() - icon.width()) / 2, (value.height() - icon.height()) / 2, icon); | 395 | painter.drawPixmap((value.width() - icon.width()) / 2, (value.height() - icon.height()) / 2, icon); | ||
396 | painter.end(); | 396 | painter.end(); | ||
397 | d->mWaitingThumbnail = pix; | 397 | d->mWaitingThumbnail = pix; | ||
398 | d->mWaitingThumbnail.setDevicePixelRatio(dpr); | 398 | d->mWaitingThumbnail.setDevicePixelRatio(dpr); | ||
▲ Show 20 Lines • Show All 200 Lines • ▼ Show 20 Line(s) | 595 | if (kind == MimeTypeUtils::KIND_VIDEO) { | |||
599 | const QPixmap pix = KIconLoader::global()->loadIcon(item.iconName(), KIconLoader::Desktop, d->mThumbnailSize.height()); | 599 | const QPixmap pix = KIconLoader::global()->loadIcon(item.iconName(), KIconLoader::Desktop, d->mThumbnailSize.height()); | ||
600 | thumbnail.initAsIcon(pix); | 600 | thumbnail.initAsIcon(pix); | ||
601 | } else if (kind == MimeTypeUtils::KIND_DIR) { | 601 | } else if (kind == MimeTypeUtils::KIND_DIR) { | ||
602 | // Special case for folders because ThumbnailProvider does not return a | 602 | // Special case for folders because ThumbnailProvider does not return a | ||
603 | // thumbnail if there is no images | 603 | // thumbnail if there is no images | ||
604 | thumbnail.mWaitingForThumbnail = false; | 604 | thumbnail.mWaitingForThumbnail = false; | ||
605 | return; | 605 | return; | ||
606 | } else { | 606 | } else { | ||
607 | thumbnail.initAsIcon(DesktopIcon(QStringLiteral("image-missing"), 48)); | 607 | thumbnail.initAsIcon(QIcon::fromTheme(QStringLiteral("image-missing")).pixmap(48)); | ||
608 | thumbnail.mFullSize = thumbnail.mGroupPix.size(); | 608 | thumbnail.mFullSize = thumbnail.mGroupPix.size(); | ||
609 | } | 609 | } | ||
610 | update(thumbnail.mIndex); | 610 | update(thumbnail.mIndex); | ||
611 | } | 611 | } | ||
612 | 612 | | |||
613 | QPixmap ThumbnailView::thumbnailForIndex(const QModelIndex& index, QSize* fullSize) | 613 | QPixmap ThumbnailView::thumbnailForIndex(const QModelIndex& index, QSize* fullSize) | ||
614 | { | 614 | { | ||
615 | KFileItem item = fileItemForIndex(index); | 615 | KFileItem item = fileItemForIndex(index); | ||
Show All 25 Lines | 637 | if (thumbnail.mGroupPix.isNull() || thumbnail.mGroupPix.height() < groupSize) { | |||
641 | if (kind == MimeTypeUtils::KIND_ARCHIVE) { | 641 | if (kind == MimeTypeUtils::KIND_ARCHIVE) { | ||
642 | // No thumbnails for archives | 642 | // No thumbnails for archives | ||
643 | thumbnail.mWaitingForThumbnail = false; | 643 | thumbnail.mWaitingForThumbnail = false; | ||
644 | } else if (!d->mCreateThumbnailsForRemoteUrls && !UrlUtils::urlIsFastLocalFile(url)) { | 644 | } else if (!d->mCreateThumbnailsForRemoteUrls && !UrlUtils::urlIsFastLocalFile(url)) { | ||
645 | // If we don't want thumbnails for remote urls, use | 645 | // If we don't want thumbnails for remote urls, use | ||
646 | // "folder-remote" icon for remote folders, so that they do | 646 | // "folder-remote" icon for remote folders, so that they do | ||
647 | // not look like regular folders | 647 | // not look like regular folders | ||
648 | thumbnail.mWaitingForThumbnail = false; | 648 | thumbnail.mWaitingForThumbnail = false; | ||
649 | thumbnail.initAsIcon(DesktopIcon(QStringLiteral("folder-remote"), groupSize)); | 649 | thumbnail.initAsIcon(QIcon::fromTheme(QStringLiteral("folder-remote")).pixmap(groupSize)); | ||
650 | } else { | 650 | } else { | ||
651 | // set mWaitingForThumbnail to true (necessary in the case | 651 | // set mWaitingForThumbnail to true (necessary in the case | ||
652 | // 'thumbnail' already existed before, but with a too small | 652 | // 'thumbnail' already existed before, but with a too small | ||
653 | // mGroupPix) | 653 | // mGroupPix) | ||
654 | thumbnail.mWaitingForThumbnail = true; | 654 | thumbnail.mWaitingForThumbnail = true; | ||
655 | } | 655 | } | ||
656 | } | 656 | } | ||
657 | } | 657 | } | ||
▲ Show 20 Lines • Show All 381 Lines • Show Last 20 Lines |
btw, QIcon::pixmap exists in a single argument variant as well, so you don't have to repeat the size in the common case of a square icon :)