mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
review comments
This commit is contained in:
parent
35c0972671
commit
1b6ee5d6cd
|
@ -156,7 +156,7 @@ QPixmap KFileItemListView::createDragPixmap(const KItemSet& indexes) const
|
||||||
yCount = xCount;
|
yCount = xCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal dpr = scene()->views()[0]->devicePixelRatio();
|
const qreal dpr = scene()->views()[0]->devicePixelRatio();
|
||||||
// Draw the selected items into the grid cells.
|
// Draw the selected items into the grid cells.
|
||||||
QPixmap dragPixmap(QSize(xCount * size + xCount, yCount * size + yCount) * dpr);
|
QPixmap dragPixmap(QSize(xCount * size + xCount, yCount * size + yCount) * dpr);
|
||||||
dragPixmap.setDevicePixelRatio(dpr);
|
dragPixmap.setDevicePixelRatio(dpr);
|
||||||
|
|
|
@ -493,7 +493,7 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem& item, const QPi
|
||||||
const QString mimeTypeGroup = mimeType.left(slashIndex);
|
const QString mimeTypeGroup = mimeType.left(slashIndex);
|
||||||
if (mimeTypeGroup == QLatin1String("image")) {
|
if (mimeTypeGroup == QLatin1String("image")) {
|
||||||
if (m_enlargeSmallPreviews) {
|
if (m_enlargeSmallPreviews) {
|
||||||
KPixmapModifier::applyFrame(scaledPixmap, m_iconSize * scaledPixmap.devicePixelRatio());
|
KPixmapModifier::applyFrame(scaledPixmap, m_iconSize);
|
||||||
} else {
|
} else {
|
||||||
// Assure that small previews don't get enlarged. Instead they
|
// Assure that small previews don't get enlarged. Instead they
|
||||||
// should be shown centered within the frame.
|
// should be shown centered within the frame.
|
||||||
|
@ -501,8 +501,8 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem& item, const QPi
|
||||||
const bool enlargingRequired = scaledPixmap.width() < contentSize.width() &&
|
const bool enlargingRequired = scaledPixmap.width() < contentSize.width() &&
|
||||||
scaledPixmap.height() < contentSize.height();
|
scaledPixmap.height() < contentSize.height();
|
||||||
if (enlargingRequired) {
|
if (enlargingRequired) {
|
||||||
QSize frameSize = scaledPixmap.size();
|
QSize frameSize = scaledPixmap.size() / scaledPixmap.devicePixelRatio();
|
||||||
frameSize.scale(m_iconSize * scaledPixmap.devicePixelRatio(), Qt::KeepAspectRatio);
|
frameSize.scale(m_iconSize, Qt::KeepAspectRatio);
|
||||||
|
|
||||||
QPixmap largeFrame(frameSize);
|
QPixmap largeFrame(frameSize);
|
||||||
largeFrame.fill(Qt::transparent);
|
largeFrame.fill(Qt::transparent);
|
||||||
|
@ -517,11 +517,11 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem& item, const QPi
|
||||||
} else {
|
} else {
|
||||||
// The image must be shrinked as it is too large to fit into
|
// The image must be shrinked as it is too large to fit into
|
||||||
// the available icon size
|
// the available icon size
|
||||||
KPixmapModifier::applyFrame(scaledPixmap, m_iconSize * scaledPixmap.devicePixelRatio());
|
KPixmapModifier::applyFrame(scaledPixmap, m_iconSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
KPixmapModifier::scale(scaledPixmap, m_iconSize * scaledPixmap.devicePixelRatio());
|
KPixmapModifier::scale(scaledPixmap, m_iconSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<QByteArray, QVariant> data = rolesData(item);
|
QHash<QByteArray, QVariant> data = rolesData(item);
|
||||||
|
|
|
@ -40,7 +40,6 @@
|
||||||
#include <QTextLayout>
|
#include <QTextLayout>
|
||||||
#include <QTextLine>
|
#include <QTextLine>
|
||||||
#include <QPixmapCache>
|
#include <QPixmapCache>
|
||||||
#include <QDebug>
|
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
|
|
||||||
// #define KSTANDARDITEMLISTWIDGET_DEBUG
|
// #define KSTANDARDITEMLISTWIDGET_DEBUG
|
||||||
|
@ -956,9 +955,8 @@ void KStandardItemListWidget::updatePixmapCache()
|
||||||
}
|
}
|
||||||
const QStringList overlays = values["iconOverlays"].toStringList();
|
const QStringList overlays = values["iconOverlays"].toStringList();
|
||||||
m_pixmap = pixmapForIcon(iconName, overlays, maxIconHeight);
|
m_pixmap = pixmapForIcon(iconName, overlays, maxIconHeight);
|
||||||
// qDebug() << "attempt 2 - setting pixmap to one of size " << m_pixmap.size() << m_pixmap.devicePixelRatio();
|
|
||||||
|
|
||||||
} else if (m_pixmap.width() / qApp->devicePixelRatio() != maxIconWidth || m_pixmap.height() / qApp->devicePixelRatio() != maxIconHeight) {
|
} else if (m_pixmap.width() / m_pixmap.devicePixelRatio() != maxIconWidth || m_pixmap.height() / m_pixmap.devicePixelRatio() != maxIconHeight) {
|
||||||
// A custom pixmap has been applied. Assure that the pixmap
|
// A custom pixmap has been applied. Assure that the pixmap
|
||||||
// is scaled to the maximum available size.
|
// is scaled to the maximum available size.
|
||||||
KPixmapModifier::scale(m_pixmap, QSize(maxIconWidth, maxIconHeight) * qApp->devicePixelRatio());
|
KPixmapModifier::scale(m_pixmap, QSize(maxIconWidth, maxIconHeight) * qApp->devicePixelRatio());
|
||||||
|
@ -1357,9 +1355,10 @@ void KStandardItemListWidget::updateAdditionalInfoTextColor()
|
||||||
|
|
||||||
void KStandardItemListWidget::drawPixmap(QPainter* painter, const QPixmap& pixmap)
|
void KStandardItemListWidget::drawPixmap(QPainter* painter, const QPixmap& pixmap)
|
||||||
{
|
{
|
||||||
if (m_scaledPixmapSize * qApp->devicePixelRatio() != pixmap.size()) {
|
if (m_scaledPixmapSize != pixmap.size() / pixmap.devicePixelRatio()) {
|
||||||
QPixmap scaledPixmap = pixmap;
|
QPixmap scaledPixmap = pixmap;
|
||||||
KPixmapModifier::scale(scaledPixmap, m_scaledPixmapSize * qApp->devicePixelRatio());
|
KPixmapModifier::scale(scaledPixmap, m_scaledPixmapSize * qApp->devicePixelRatio());
|
||||||
|
scaledPixmap.setDevicePixelRatio(qApp->devicePixelRatio());
|
||||||
painter->drawPixmap(m_pixmapPos, scaledPixmap);
|
painter->drawPixmap(m_pixmapPos, scaledPixmap);
|
||||||
|
|
||||||
#ifdef KSTANDARDITEMLISTWIDGET_DEBUG
|
#ifdef KSTANDARDITEMLISTWIDGET_DEBUG
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
|
#include <QGuiApplication>
|
||||||
|
|
||||||
|
|
||||||
#include <config-X11.h> // for HAVE_XRENDER
|
#include <config-X11.h> // for HAVE_XRENDER
|
||||||
|
@ -374,22 +375,23 @@ void KPixmapModifier::scale(QPixmap& pixmap, const QSize& scaledSize)
|
||||||
void KPixmapModifier::applyFrame(QPixmap& icon, const QSize& scaledSize)
|
void KPixmapModifier::applyFrame(QPixmap& icon, const QSize& scaledSize)
|
||||||
{
|
{
|
||||||
static TileSet tileSet;
|
static TileSet tileSet;
|
||||||
qreal dpr = icon.devicePixelRatio();
|
qreal dpr = qApp->devicePixelRatio();
|
||||||
|
|
||||||
// Resize the icon to the maximum size minus the space required for the frame
|
// Resize the icon to the maximum size minus the space required for the frame
|
||||||
const QSize size(scaledSize.width() - (TileSet::LeftMargin + TileSet::RightMargin) * dpr,
|
const QSize size(scaledSize.width() - TileSet::LeftMargin - TileSet::RightMargin,
|
||||||
scaledSize.height() - (TileSet::TopMargin + TileSet::BottomMargin) * dpr);
|
scaledSize.height() - TileSet::TopMargin - TileSet::BottomMargin);
|
||||||
scale(icon, size);
|
scale(icon, size * dpr);
|
||||||
|
icon.setDevicePixelRatio(dpr);
|
||||||
|
|
||||||
QPixmap framedIcon(icon.size().width() + (TileSet::LeftMargin + TileSet::RightMargin) * dpr,
|
QPixmap framedIcon(icon.size().width() + (TileSet::LeftMargin + TileSet::RightMargin) * dpr,
|
||||||
icon.size().height() + (TileSet::TopMargin + TileSet::BottomMargin * dpr) );
|
icon.size().height() + (TileSet::TopMargin + TileSet::BottomMargin) * dpr);
|
||||||
framedIcon.setDevicePixelRatio(dpr);
|
framedIcon.setDevicePixelRatio(dpr);
|
||||||
framedIcon.fill(Qt::transparent);
|
framedIcon.fill(Qt::transparent);
|
||||||
|
|
||||||
QPainter painter;
|
QPainter painter;
|
||||||
painter.begin(&framedIcon);
|
painter.begin(&framedIcon);
|
||||||
painter.setCompositionMode(QPainter::CompositionMode_Source);
|
painter.setCompositionMode(QPainter::CompositionMode_Source);
|
||||||
tileSet.paint(&painter, framedIcon.rect());
|
tileSet.paint(&painter, QRect(QPoint(0,0), framedIcon.size() / dpr));
|
||||||
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
|
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
|
||||||
painter.drawPixmap(TileSet::LeftMargin, TileSet::TopMargin, icon);
|
painter.drawPixmap(TileSet::LeftMargin, TileSet::TopMargin, icon);
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,8 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resize and paint a frame round an icon
|
* Resize and paint a frame round an icon
|
||||||
* @arg scaledSize is assumed to be the scaled to the same device pixel ratio as the source icon
|
* @arg scaledSize is in device-independent pixels
|
||||||
|
* The returned image will be scaled by the application devicePixelRatio
|
||||||
*/
|
*/
|
||||||
static void applyFrame(QPixmap& icon, const QSize& scaledSize);
|
static void applyFrame(QPixmap& icon, const QSize& scaledSize);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue