better device ratio support

This commit is contained in:
Roy Qu 2022-04-02 18:42:43 +08:00
parent 9302439fcb
commit 65b328396c
3 changed files with 5 additions and 3 deletions

View File

@ -30,6 +30,7 @@
#include "utils.h"
#include "settings.h"
#include "widgets/customdisablediconengine.h"
#include <QApplication>
IconsManager* pIconsManager;
@ -250,10 +251,12 @@ IconsManager::PPixmap IconsManager::createSVGIcon(const QString &filename, int w
QSvgRenderer renderer(filename);
if (!renderer.isValid())
return mDefaultIconPixmap;
PPixmap icon = std::make_shared<QPixmap>(width,height);
qreal dpr=qApp->devicePixelRatio();
PPixmap icon = std::make_shared<QPixmap>(width*dpr,height*dpr);
icon->fill(Qt::transparent);
QPainter painter(icon.get());
renderer.render(&painter,icon->rect());
icon->setDevicePixelRatio(dpr);
return icon;
}

View File

@ -5978,7 +5978,6 @@ void SynEdit::paintEvent(QPaintEvent *event)
cacheRC.setTop(rcClip.top()*dpr);
cacheRC.setWidth(rcClip.width()*dpr);
cacheRC.setHeight(rcClip.height()*dpr);
qDebug()<<rcClip<<rcCaret<<cacheRC;
painter.drawImage(rcCaret,*mContentImage,cacheRC);
} else {
QRect rcDraw;

View File

@ -76,6 +76,6 @@ void CustomDisabledIconEngine::setPixmap(const QPixmap &pixmap)
}
}
mDisabledPixmap = QPixmap::fromImage(image);
mDisabledPixmap.setDevicePixelRatio(mPixmap.devicePixelRatioF());
}
}