mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-18 10:56:11 +00:00
Use QFontMetrics instead of fontMetrics()
This commit is contained in:
parent
3e0bc74e77
commit
bbd4961468
@ -1114,7 +1114,7 @@ void MainWindow::initBackForwardMenu()
|
||||
connect(button, &QWidget::customContextMenuRequested, button,
|
||||
[menu, button](const QPoint &pos) { menu->exec(button->mapToGlobal(pos)); });
|
||||
|
||||
QFontMetrics metrics(fontMetrics());
|
||||
QFontMetrics metrics(font());
|
||||
// Roughly 10-16 lines depending on padding size, no need to calculate more precisely
|
||||
menu->setMaximumHeight(metrics.lineSpacing() * 20);
|
||||
|
||||
|
@ -48,8 +48,9 @@ void ColorOptionDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o
|
||||
|
||||
ColorOption currCO = index.data(Qt::UserRole).value<ColorOption>();
|
||||
|
||||
QFontMetrics fm = QFontMetrics(painter->font());
|
||||
int penWidth = painter->pen().width();
|
||||
int fontHeight = painter->fontMetrics().height();
|
||||
int fontHeight = fm.height();
|
||||
QPoint tl = option.rect.topLeft();
|
||||
|
||||
QRect optionNameRect;
|
||||
@ -126,9 +127,9 @@ void ColorOptionDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o
|
||||
|
||||
painter->setPen(qApp->palette().text().color());
|
||||
|
||||
QString name =
|
||||
painter->fontMetrics().elidedText(optionInfoMap__[currCO.optionName].displayingtext,
|
||||
Qt::ElideRight, optionNameRect.width());
|
||||
QFontMetrics fm2 = QFontMetrics(painter->font());
|
||||
QString name = fm2.elidedText(optionInfoMap__[currCO.optionName].displayingtext,
|
||||
Qt::ElideRight, optionNameRect.width());
|
||||
painter->drawText(optionNameRect, name);
|
||||
|
||||
QPainterPath roundedOptionRect;
|
||||
@ -155,7 +156,8 @@ void ColorOptionDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o
|
||||
painter->setPen(currCO.color);
|
||||
painter->fillPath(roundedColorRect, currCO.color);
|
||||
|
||||
QString desc = painter->fontMetrics().elidedText(
|
||||
QFontMetrics fm3 = QFontMetrics(painter->font());
|
||||
QString desc = fm3.elidedText(
|
||||
currCO.optionName + ": " + optionInfoMap__[currCO.optionName].info, Qt::ElideRight,
|
||||
descTextRect.width());
|
||||
painter->setPen(qApp->palette().text().color());
|
||||
@ -197,7 +199,8 @@ QPixmap ColorOptionDelegate::getPixmapFromSvg(const QString &fileName, const QCo
|
||||
data.replace(QRegularExpression("#[0-9a-fA-F]{6}"), QString("%1").arg(after.name()));
|
||||
|
||||
QSvgRenderer svgRenderer(data.toUtf8());
|
||||
QPixmap pix(QSize(qApp->fontMetrics().height(), qApp->fontMetrics().height()));
|
||||
QFontMetrics fm = QFontMetrics(qApp->font());
|
||||
QPixmap pix(QSize(fm.height(), fm.height()));
|
||||
pix.fill(Qt::transparent);
|
||||
|
||||
QPainter pixPainter(&pix);
|
||||
|
@ -211,7 +211,7 @@ QString DisassemblyWidget::getWidgetType()
|
||||
|
||||
QFontMetrics DisassemblyWidget::getFontMetrics()
|
||||
{
|
||||
return mDisasTextEdit->fontMetrics();
|
||||
return QFontMetrics(mDisasTextEdit->font());
|
||||
}
|
||||
|
||||
QList<DisassemblyLine> DisassemblyWidget::getLines()
|
||||
|
@ -119,8 +119,9 @@ void SimpleTextGraphView::drawBlock(QPainter &p, GraphView::GraphBlock &block, b
|
||||
|
||||
p.setPen(palette().color(QPalette::WindowText));
|
||||
// Render node text
|
||||
QFontMetrics fm = QFontMetrics(p.font());
|
||||
auto x = block.x + padding / 2;
|
||||
int y = block.y + padding / 2 + p.fontMetrics().ascent();
|
||||
int y = block.y + padding / 2 + fm.ascent();
|
||||
p.drawText(QPoint(x, y), content.text);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user