Fix icon button painting for different sizes

This commit is contained in:
johanneshilden 2017-10-11 23:33:55 +03:00
parent 067cf211b3
commit fc6f67dac0
2 changed files with 6 additions and 1 deletions

View File

@ -204,5 +204,9 @@ void QtMaterialIconButton::paintEvent(QPaintEvent *event)
QPainter icon(&pixmap);
icon.setCompositionMode(QPainter::CompositionMode_SourceIn);
icon.fillRect(pixmap.rect(), isEnabled() ? color() : disabledColor());
painter.drawPixmap(0, 0, pixmap);
QRect r(rect());
const qreal w = pixmap.width();
const qreal h = pixmap.height();
painter.drawPixmap(QRect((r.width()-w)/2, (r.height()-h)/2, w, h), pixmap);
}

View File

@ -15,6 +15,7 @@ AppBarSettingsEditor::AppBarSettingsEditor(QWidget *parent)
m_appBar->appBarLayout()->addWidget(button);
m_appBar->appBarLayout()->addStretch(1);
button->setColor(Qt::white);
button->setFixedWidth(42);
QVBoxLayout *layout = new QVBoxLayout;
setLayout(layout);