mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-22 01:40:02 +00:00
review comments
This commit is contained in:
parent
35c0972671
commit
1b6ee5d6cd
|
@ -156,9 +156,9 @@ QPixmap KFileItemListView::createDragPixmap(const KItemSet& indexes) const
|
|||
yCount = xCount;
|
||||
}
|
||||
|
||||
qreal dpr = scene()->views()[0]->devicePixelRatio();
|
||||
const qreal dpr = scene()->views()[0]->devicePixelRatio();
|
||||
// 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.fill(Qt::transparent);
|
||||
|
||||
|
|
|
@ -493,7 +493,7 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem& item, const QPi
|
|||
const QString mimeTypeGroup = mimeType.left(slashIndex);
|
||||
if (mimeTypeGroup == QLatin1String("image")) {
|
||||
if (m_enlargeSmallPreviews) {
|
||||
KPixmapModifier::applyFrame(scaledPixmap, m_iconSize * scaledPixmap.devicePixelRatio());
|
||||
KPixmapModifier::applyFrame(scaledPixmap, m_iconSize);
|
||||
} else {
|
||||
// Assure that small previews don't get enlarged. Instead they
|
||||
// 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() &&
|
||||
scaledPixmap.height() < contentSize.height();
|
||||
if (enlargingRequired) {
|
||||
QSize frameSize = scaledPixmap.size();
|
||||
frameSize.scale(m_iconSize * scaledPixmap.devicePixelRatio(), Qt::KeepAspectRatio);
|
||||
QSize frameSize = scaledPixmap.size() / scaledPixmap.devicePixelRatio();
|
||||
frameSize.scale(m_iconSize, Qt::KeepAspectRatio);
|
||||
|
||||
QPixmap largeFrame(frameSize);
|
||||
largeFrame.fill(Qt::transparent);
|
||||
|
@ -517,11 +517,11 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem& item, const QPi
|
|||
} else {
|
||||
// The image must be shrinked as it is too large to fit into
|
||||
// the available icon size
|
||||
KPixmapModifier::applyFrame(scaledPixmap, m_iconSize * scaledPixmap.devicePixelRatio());
|
||||
KPixmapModifier::applyFrame(scaledPixmap, m_iconSize);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
KPixmapModifier::scale(scaledPixmap, m_iconSize * scaledPixmap.devicePixelRatio());
|
||||
KPixmapModifier::scale(scaledPixmap, m_iconSize);
|
||||
}
|
||||
|
||||
QHash<QByteArray, QVariant> data = rolesData(item);
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
#include <QTextLayout>
|
||||
#include <QTextLine>
|
||||
#include <QPixmapCache>
|
||||
#include <QDebug>
|
||||
#include <QGuiApplication>
|
||||
|
||||
// #define KSTANDARDITEMLISTWIDGET_DEBUG
|
||||
|
@ -956,9 +955,8 @@ void KStandardItemListWidget::updatePixmapCache()
|
|||
}
|
||||
const QStringList overlays = values["iconOverlays"].toStringList();
|
||||
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
|
||||
// is scaled to the maximum available size.
|
||||
KPixmapModifier::scale(m_pixmap, QSize(maxIconWidth, maxIconHeight) * qApp->devicePixelRatio());
|
||||
|
@ -1357,9 +1355,10 @@ void KStandardItemListWidget::updateAdditionalInfoTextColor()
|
|||
|
||||
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;
|
||||
KPixmapModifier::scale(scaledPixmap, m_scaledPixmapSize * qApp->devicePixelRatio());
|
||||
scaledPixmap.setDevicePixelRatio(qApp->devicePixelRatio());
|
||||
painter->drawPixmap(m_pixmapPos, scaledPixmap);
|
||||
|
||||
#ifdef KSTANDARDITEMLISTWIDGET_DEBUG
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <QPainter>
|
||||
#include <QPixmap>
|
||||
#include <QSize>
|
||||
#include <QGuiApplication>
|
||||
|
||||
|
||||
#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)
|
||||
{
|
||||
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
|
||||
const QSize size(scaledSize.width() - (TileSet::LeftMargin + TileSet::RightMargin) * dpr,
|
||||
scaledSize.height() - (TileSet::TopMargin + TileSet::BottomMargin) * dpr);
|
||||
scale(icon, size);
|
||||
const QSize size(scaledSize.width() - TileSet::LeftMargin - TileSet::RightMargin,
|
||||
scaledSize.height() - TileSet::TopMargin - TileSet::BottomMargin);
|
||||
scale(icon, size * dpr);
|
||||
icon.setDevicePixelRatio(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.fill(Qt::transparent);
|
||||
|
||||
QPainter painter;
|
||||
painter.begin(&framedIcon);
|
||||
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.drawPixmap(TileSet::LeftMargin, TileSet::TopMargin, icon);
|
||||
|
||||
|
|
|
@ -37,7 +37,8 @@ public:
|
|||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue