Maybe fixing icon issue on MacOS

This commit is contained in:
Matthias Koefferlein 2025-12-09 22:30:58 +01:00
parent 1e8321d8fb
commit ec2c160792
1 changed files with 7 additions and 1 deletions

View File

@ -707,6 +707,12 @@ LayerSelectionComboBox::do_update_layer_list ()
int icon_width = iconSize ().width (); int icon_width = iconSize ().width ();
int icon_height = iconSize ().height (); int icon_height = iconSize ().height ();
#if QT_VERSION >= 0x050000
double dpr = devicePixelRatio ();
#else
double dpr = 1.0;
#endif
LPIPairCompareOp cmp_op; LPIPairCompareOp cmp_op;
std::map<std::pair<db::LayerProperties, int>, std::string, LPIPairCompareOp> name_for_layer (cmp_op); std::map<std::pair<db::LayerProperties, int>, std::string, LPIPairCompareOp> name_for_layer (cmp_op);
std::map<std::pair<db::LayerProperties, int>, QIcon, LPIPairCompareOp> icon_for_layer; std::map<std::pair<db::LayerProperties, int>, QIcon, LPIPairCompareOp> icon_for_layer;
@ -715,7 +721,7 @@ LayerSelectionComboBox::do_update_layer_list ()
if (lp->cellview_index () == mp_private->cv_index && ! lp->has_children () && (mp_private->all_layers || lp->layer_index () >= 0) && lp->source (true).layer_props () != db::LayerProperties ()) { if (lp->cellview_index () == mp_private->cv_index && ! lp->has_children () && (mp_private->all_layers || lp->layer_index () >= 0) && lp->source (true).layer_props () != db::LayerProperties ()) {
std::pair <db::LayerProperties, int> k (lp->source (true).layer_props (), lp->layer_index ()); std::pair <db::LayerProperties, int> k (lp->source (true).layer_props (), lp->layer_index ());
name_for_layer.insert (std::make_pair (k, lp->display_string (mp_private->view, true, true /*always show source*/))); name_for_layer.insert (std::make_pair (k, lp->display_string (mp_private->view, true, true /*always show source*/)));
QIcon icon = QIcon (QPixmap::fromImage (mp_private->view->icon_for_layer (lp, icon_width, icon_height).to_image ())); QIcon icon = QIcon (QPixmap::fromImage (mp_private->view->icon_for_layer (lp, icon_width, icon_height, dpr, 0, true).to_image ()));
icon_for_layer.insert (std::make_pair (k, icon)); icon_for_layer.insert (std::make_pair (k, icon));
mp_private->layers.push_back (k); mp_private->layers.push_back (k);
} }