ui/sidebar: Fix the inconsistent padding in different languages. (#28746)

cleanup
old-commit-hash: 7ac22a0d7abb51e604e23a3b8d9500328bafac18
This commit is contained in:
Dean Lee
2023-07-01 04:40:28 +08:00
committed by GitHub
parent 82893982e5
commit 7ac669d510
4 changed files with 2 additions and 17 deletions
+1 -1
View File
@@ -391,7 +391,7 @@ void AnnotatedCameraWidget::drawHud(QPainter &p) {
}
void AnnotatedCameraWidget::drawText(QPainter &p, int x, int y, const QString &text, int alpha) {
QRect real_rect = getTextRect(p, 0, text);
QRect real_rect = p.fontMetrics().boundingRect(text);
real_rect.moveCenter({x, y - real_rect.height() / 2});
p.setPen(QColor(0xff, 0xff, 0xff, alpha));
+1 -9
View File
@@ -21,15 +21,7 @@ void Sidebar::drawMetric(QPainter &p, const QPair<QString, QString> &label, QCol
p.setPen(QColor(0xff, 0xff, 0xff));
configFont(p, "Inter", 35, "SemiBold");
QRect label_rect = getTextRect(p, Qt::AlignCenter, label.first);
label_rect.setWidth(218);
label_rect.moveLeft(rect.left() + 22);
label_rect.moveTop(rect.top() + 19);
p.drawText(label_rect, Qt::AlignCenter, label.first);
label_rect.moveTop(rect.top() + 65);
p.drawText(label_rect, Qt::AlignCenter, label.second);
p.drawText(rect.adjusted(22, 0, 0, 0), Qt::AlignCenter, label.first + "\n" + label.second);
}
Sidebar::Sidebar(QWidget *parent) : QFrame(parent), onroad(false), flag_pressed(false), settings_pressed(false) {
-6
View File
@@ -162,12 +162,6 @@ QPixmap loadPixmap(const QString &fileName, const QSize &size, Qt::AspectRatioMo
}
}
QRect getTextRect(QPainter &p, int flags, const QString &text) {
QFontMetrics fm(p.font());
QRect init_rect = fm.boundingRect(text);
return fm.boundingRect(init_rect, flags, text);
}
void drawRoundedRect(QPainter &painter, const QRectF &rect, qreal xRadiusTop, qreal yRadiusTop, qreal xRadiusBottom, qreal yRadiusBottom){
qreal w_2 = rect.width() / 2;
qreal h_2 = rect.height() / 2;
-1
View File
@@ -25,6 +25,5 @@ QWidget* topWidget (QWidget* widget);
QPixmap loadPixmap(const QString &fileName, const QSize &size = {}, Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio);
QPixmap bootstrapPixmap(const QString &id);
QRect getTextRect(QPainter &p, int flags, const QString &text);
void drawRoundedRect(QPainter &painter, const QRectF &rect, qreal xRadiusTop, qreal yRadiusTop, qreal xRadiusBottom, qreal yRadiusBottom);
QColor interpColor(float xv, std::vector<float> xp, std::vector<QColor> fp);