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