Changeset View
Changeset View
Standalone View
Standalone View
thumbnail/thumbnail.cpp
Show First 20 Lines • Show All 461 Lines • ▼ Show 20 Line(s) | 450 | { | |||
---|---|---|---|---|---|
462 | 462 | | |||
463 | // TODO: the margins are optimized for the Oxygen iconset | 463 | // TODO: the margins are optimized for the Oxygen iconset | ||
464 | // Provide a fallback solution for other iconsets (e. g. draw folder | 464 | // Provide a fallback solution for other iconsets (e. g. draw folder | ||
465 | // only as small overlay, use no margins) | 465 | // only as small overlay, use no margins) | ||
466 | 466 | | |||
467 | QString localFile = directory.path(); | 467 | QString localFile = directory.path(); | ||
468 | 468 | | |||
469 | KFileItem item(QUrl::fromLocalFile(localFile)); | 469 | KFileItem item(QUrl::fromLocalFile(localFile)); | ||
470 | const QPixmap folder = QIcon::fromTheme(item.iconName()).pixmap(qMin(m_width, m_height)); | 470 | const int extent = qMin(m_width, m_height); | ||
471 | QPixmap folder = QIcon::fromTheme(item.iconName()).pixmap(extent); | ||||
472 | | ||||
473 | // Scale up base icon to ensure overlays are rendered with | ||||
474 | // the best quality possible even for low-res custom folder icons | ||||
475 | if (qMax(folder.width(), folder.height()) < extent) { | ||||
476 | folder = folder.scaled(extent, extent, Qt::KeepAspectRatio, Qt::SmoothTransformation); | ||||
477 | } | ||||
471 | 478 | | |||
472 | const int folderWidth = folder.width(); | 479 | const int folderWidth = folder.width(); | ||
473 | const int folderHeight = folder.height(); | 480 | const int folderHeight = folder.height(); | ||
474 | 481 | | |||
475 | const int topMargin = folderHeight * 30 / 100; | 482 | const int topMargin = folderHeight * 30 / 100; | ||
476 | const int bottomMargin = folderHeight / 6; | 483 | const int bottomMargin = folderHeight / 6; | ||
477 | const int leftMargin = folderWidth / 13; | 484 | const int leftMargin = folderWidth / 13; | ||
478 | const int rightMargin = leftMargin; | 485 | const int rightMargin = leftMargin; | ||
▲ Show 20 Lines • Show All 287 Lines • Show Last 20 Lines |