remove some code setting pixel density ratio for pixmaps
update
This commit is contained in:
@@ -1129,8 +1129,8 @@ private:
|
||||
auto colorMapping = std::map<unsigned long, unsigned long>();
|
||||
colorMapping[defaultCrosshairColor] = color;
|
||||
|
||||
qreal fullIconWidth = 32 * pixelRatio;
|
||||
qreal iconWidth = 16 * pixelRatio;
|
||||
constexpr qreal fullIconWidth = 32;
|
||||
constexpr qreal iconWidth = 16;
|
||||
QPixmap cursorPixmap =
|
||||
Gui::BitmapFactory().pixmapFromSvg("Sketcher_Crosshair",
|
||||
QSizeF(fullIconWidth, fullIconWidth),
|
||||
@@ -1143,7 +1143,6 @@ private:
|
||||
cursorPainter.end();
|
||||
int hotX = 8;
|
||||
int hotY = 8;
|
||||
cursorPixmap.setDevicePixelRatio(pixelRatio);
|
||||
// only X11 needs hot point coordinates to be scaled
|
||||
if (qGuiApp->platformName() == QLatin1String("xcb")) {
|
||||
hotX *= pixelRatio;
|
||||
@@ -1422,17 +1421,16 @@ public:
|
||||
auto colorMapping = std::map<unsigned long, unsigned long>();
|
||||
colorMapping[defaultCrosshairColor] = color;
|
||||
|
||||
qreal fullIconWidth = 32 * pixelRatio;
|
||||
qreal iconWidth = 16 * pixelRatio;
|
||||
QPixmap cursorPixmap = Gui::BitmapFactory().pixmapFromSvg("Sketcher_Crosshair", QSizeF(fullIconWidth, fullIconWidth), colorMapping),
|
||||
icon = Gui::BitmapFactory().pixmapFromSvg("Constraint_Dimension", QSizeF(iconWidth, iconWidth));
|
||||
constexpr qreal fullIconWidth = 32;
|
||||
constexpr qreal iconWidth = 16;
|
||||
QPixmap cursorPixmap = Gui::BitmapFactory().pixmapFromSvg("Sketcher_Crosshair", QSizeF(fullIconWidth, fullIconWidth), colorMapping);
|
||||
QPixmap icon = Gui::BitmapFactory().pixmapFromSvg("Constraint_Dimension", QSizeF(iconWidth, iconWidth));
|
||||
QPainter cursorPainter;
|
||||
cursorPainter.begin(&cursorPixmap);
|
||||
cursorPainter.drawPixmap(16 * pixelRatio, 16 * pixelRatio, icon);
|
||||
cursorPainter.end();
|
||||
int hotX = 8;
|
||||
int hotY = 8;
|
||||
cursorPixmap.setDevicePixelRatio(pixelRatio);
|
||||
// only X11 needs hot point coordinates to be scaled
|
||||
if (qGuiApp->platformName() == QLatin1String("xcb")) {
|
||||
hotX *= pixelRatio;
|
||||
|
||||
@@ -406,12 +406,7 @@ DrawSketchHandler::suggestedConstraintsPixmaps(std::vector<AutoConstraint>& sugg
|
||||
break;
|
||||
}
|
||||
if (!iconType.isEmpty()) {
|
||||
qreal pixelRatio = 1;
|
||||
Gui::View3DInventorViewer* viewer = getViewer();
|
||||
if (viewer) {
|
||||
pixelRatio = viewer->devicePixelRatio();
|
||||
}
|
||||
int iconWidth = 16 * pixelRatio;
|
||||
constexpr int iconWidth = 16;
|
||||
QPixmap icon = Gui::BitmapFactory().pixmapFromSvg(iconType.toStdString().c_str(),
|
||||
QSize(iconWidth, iconWidth));
|
||||
pixmaps.push_back(icon);
|
||||
|
||||
@@ -1364,12 +1364,7 @@ protected:
|
||||
|
||||
QPixmap icon(std::string name)
|
||||
{
|
||||
qreal pixelRatio = 1;
|
||||
Gui::View3DInventorViewer* viewer = getViewer();
|
||||
if (viewer) {
|
||||
pixelRatio = viewer->devicePixelRatio();
|
||||
}
|
||||
int width = 16 * pixelRatio;
|
||||
constexpr int width = 16;
|
||||
return Gui::BitmapFactory().pixmapFromSvg(name.c_str(), QSize(width, width));
|
||||
}
|
||||
|
||||
|
||||
@@ -572,14 +572,10 @@ QPixmap QGVPage::prepareCursorPixmap(const char* iconName, QPoint& hotspot)
|
||||
{
|
||||
|
||||
QPointF floatHotspot(hotspot);
|
||||
double pixelRatio = getDevicePixelRatio();
|
||||
|
||||
// Due to impossibility to query cursor size via Qt API, we stick to (32x32)*device_pixel_ratio
|
||||
// Due to impossibility to query cursor size via Qt API, we stick to (32x32)
|
||||
// as FreeCAD Wiki suggests - see https://wiki.freecad.org/HiDPI_support#Custom_cursor_size
|
||||
double cursorSize = 32.0 * pixelRatio;
|
||||
|
||||
QPixmap pixmap = Gui::BitmapFactory().pixmapFromSvg(iconName, QSizeF(cursorSize, cursorSize));
|
||||
pixmap.setDevicePixelRatio(pixelRatio);
|
||||
QPixmap pixmap = Gui::BitmapFactory().pixmapFromSvg(iconName, QSizeF(32, 32));
|
||||
|
||||
// The default (and here expected) SVG cursor graphics size is 64x64 pixels, thus we must adjust
|
||||
// the 64x64 based hotspot position for our 32x32 based cursor pixmaps accordingly
|
||||
@@ -590,7 +586,7 @@ QPixmap QGVPage::prepareCursorPixmap(const char* iconName, QPoint& hotspot)
|
||||
// therefore we must take care of the transformation ourselves...
|
||||
// Refer to QTBUG-68571 - https://bugreports.qt.io/browse/QTBUG-68571
|
||||
if (qGuiApp->platformName() == QLatin1String("xcb")) {
|
||||
floatHotspot *= pixelRatio;
|
||||
floatHotspot *= getDevicePixelRatio();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user