NOISSUE fix display of svg icons in instance toolbar

This commit is contained in:
Petr Mrázek 2017-11-14 01:03:32 +01:00
parent 322922e013
commit b000b33661

View File

@ -99,23 +99,17 @@ void LabeledToolButton::resizeEvent(QResizeEvent * event)
void LabeledToolButton::resetIcon() void LabeledToolButton::resetIcon()
{ {
// prevent the label from changing our height auto iconSz = m_icon.actualSize(QSize(160, 80));
auto sizes = m_icon.availableSizes(); float w = iconSz.width();
if(sizes.count() > 0) float h = iconSz.height();
{ float ar = w/h;
//auto maxSz = size(); // FIXME: hardcoded max size of 160x80
auto iconSz = sizes[0]; int newW = 80 * ar;
float w = iconSz.width(); if(newW > 160)
float h = iconSz.height(); newW = 160;
float ar = w/h; QSize newSz (newW, 80);
// FIXME: hardcoded max size of 160x80 auto pixmap = m_icon.pixmap(newSz);
int newW = 80 * ar; m_label->setPixmap(pixmap);
if(newW > 160) m_label->setMinimumHeight(80);
newW = 160; m_label->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );
QSize newSz (newW, 80);
auto pixmap = m_icon.pixmap(newSz);
m_label->setPixmap(pixmap);
m_label->setMinimumHeight(80);
m_label->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );
}
} }