Gui: Add BitmapFactory::empty method
This adds empty(QSize) method to bitmap factory that creates empty pixmap. This may seem useless, but after creating bitmap one needs to remember to clear it and to properly set DPR - BitmapFactory will take care of it.
This commit is contained in:
committed by
Chris Hennes
parent
2a7498c930
commit
83b2027395
@@ -136,15 +136,12 @@ QPixmap Gui::InputHintWidget::generateKeyIcon(const InputHint::UserInput key, co
|
||||
const QFontMetrics fm(font);
|
||||
const QString text = inputRepresentation(key);
|
||||
const QRect textBoundingRect = fm.tightBoundingRect(text);
|
||||
const qreal dpr = BitmapFactoryInst::getMaximumDPR();
|
||||
|
||||
const int symbolWidth = std::max(textBoundingRect.width() + padding * 2, iconSymbolHeight);
|
||||
|
||||
const QRect keyRect(margin, margin, symbolWidth, iconSymbolHeight);
|
||||
|
||||
QPixmap pixmap((symbolWidth + margin * 2) * dpr, height * dpr);
|
||||
pixmap.fill(Qt::transparent);
|
||||
pixmap.setDevicePixelRatio(dpr);
|
||||
QPixmap pixmap = BitmapFactory().empty({ symbolWidth + margin * 2, height });
|
||||
|
||||
QPainter painter(&pixmap);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
Reference in New Issue
Block a user