More scaled pixmaps for dither pattern icons

This commit is contained in:
Matthias Koefferlein 2022-09-18 18:02:37 +02:00
parent e5fabb2b13
commit a6d4cdd254
3 changed files with 33 additions and 4 deletions

View File

@ -134,6 +134,7 @@ public:
*
* @param width The desired width (-1 for default)
* @param height The desired height (-1 for default)
* @param frame_width The width of the frame around the bitmap
*/
QBitmap get_bitmap (int width = -1, int height = -1, int frame_width = -1) const;
#endif

View File

@ -54,8 +54,8 @@
</property>
<property name="iconSize">
<size>
<width>34</width>
<height>36</height>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="movement">

View File

@ -77,8 +77,16 @@ namespace {
void
SelectStippleForm::update ()
{
#if QT_VERSION >= 0x050000
double dpr = devicePixelRatio ();
#else
double dpr = 1.0;
#endif
mp_ui->stipple_items->clear ();
QSize icon_size = mp_ui->stipple_items->iconSize ();
if (m_include_nil) {
new QListWidgetItem (QObject::tr ("None"), mp_ui->stipple_items);
}
@ -91,21 +99,41 @@ SelectStippleForm::update ()
// fill the list of stipple items
for (lay::DitherPattern::iterator i = m_pattern.begin (); i != m_pattern.begin_custom (); ++i) {
std::string name (i->name ());
if (name.empty ()) {
name = tl::sprintf ("#%d", std::distance (m_pattern.begin (), i));
}
new QListWidgetItem (QIcon (i->get_bitmap ()), tl::to_qstring (name), mp_ui->stipple_items);
lay::DitherPatternInfo dp_info = *i;
dp_info.scale_pattern (dpr);
QBitmap bitmap = dp_info.get_bitmap (icon_size.width () * dpr, icon_size.height () * dpr, dpr);
#if QT_VERSION >= 0x050000
bitmap.setDevicePixelRatio (dpr);
#endif
new QListWidgetItem (QIcon (bitmap), tl::to_qstring (name), mp_ui->stipple_items);
}
for (std::vector <lay::DitherPattern::iterator>::const_iterator i = iters.begin (); i != iters.end (); ++i) {
if ((*i)->order_index () > 0) {
std::string name ((*i)->name ());
if (name.empty ()) {
name = tl::sprintf ("custom #%d", (*i)->order_index ());
}
new QListWidgetItem (QIcon ((*i)->get_bitmap ()), tl::to_qstring (name), mp_ui->stipple_items);
lay::DitherPatternInfo dp_info = **i;
dp_info.scale_pattern (dpr);
QBitmap bitmap = dp_info.get_bitmap (icon_size.width () * dpr, icon_size.height () * dpr, dpr);
#if QT_VERSION >= 0x050000
bitmap.setDevicePixelRatio (dpr);
#endif
new QListWidgetItem (QIcon (bitmap), tl::to_qstring (name), mp_ui->stipple_items);
}
}
}