Fixed problem with image on Color Buttons in 'Auto' mode - pixel garbage

This commit is contained in:
Matthias Koefferlein 2024-03-28 21:07:11 +01:00
parent 97a33f8d66
commit b5ee7d3892
1 changed files with 5 additions and 10 deletions

View File

@ -419,12 +419,6 @@ LineStyleSelectionButton::update_menu ()
unsigned int n = palette.style_by_index (i);
if (int (n) < std::distance (patterns.begin (), patterns.end ())) {
#if QT_VERSION > 0x050000
double dpr = devicePixelRatio ();
#else
double dpr = 1.0;
#endif
lay::LineStyleInfo info = patterns.begin () [n];
std::string name (info.name ());
@ -1226,13 +1220,14 @@ ColorButton::set_color_internal (QColor c)
double dpr = 1.0;
#endif
QPixmap pixmap (rt.width () * dpr, rt.height () * dpr);
QImage image (rt.width () * dpr, rt.height () * dpr, QImage::Format_ARGB32);
#if QT_VERSION >= 0x50000
pixmap.setDevicePixelRatio (dpr);
image.setDevicePixelRatio (dpr);
#endif
image.fill (Qt::transparent);
QColor text_color = palette ().color (QPalette::Active, QPalette::Text);
QPainter pxpainter (&pixmap);
QPainter pxpainter (&image);
QPen frame_pen (text_color);
frame_pen.setWidthF (1.0);
frame_pen.setJoinStyle (Qt::MiterJoin);
@ -1253,7 +1248,7 @@ ColorButton::set_color_internal (QColor c)
}
QPushButton::setIcon (QIcon (pixmap));
QPushButton::setIcon (QIcon (QPixmap::fromImage (image)));
}
QColor