Cabana: Fix title overlapping on chart with long names (#26494)

fix title overlapping
pull/26502/head
Dean Lee 2 years ago committed by GitHub
parent 102669a232
commit 29f24c7491
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      tools/cabana/chartswidget.cc
  2. 2
      tools/cabana/chartswidget.h

@ -207,7 +207,6 @@ ChartView::ChartView(const QString &id, const Signal *sig, QWidget *parent)
item_group->setZValue(chart->zValue() + 10);
// title
msg_title = new QGraphicsTextItem(chart);
QToolButton *remove_btn = new QToolButton();
remove_btn->setText("X");
remove_btn->setAutoRaise(true);
@ -236,13 +235,11 @@ ChartView::ChartView(const QString &id, const Signal *sig, QWidget *parent)
void ChartView::resizeEvent(QResizeEvent *event) {
QChartView::resizeEvent(event);
msg_title->setPos(11, 6);
close_btn_proxy->setPos(event->size().width() - close_btn_proxy->size().width() - 11, 8);
}
void ChartView::updateTitle() {
chart()->setTitle(signal->name.c_str());
msg_title->setHtml(tr("%1 <font color=\"gray\">%2</font>").arg(dbc()->msg(id)->name).arg(id));
chart()->setTitle(tr("<font color=\"gray\" text-align:left>%1 %2</font> <b>%3</b>").arg(dbc()->msg(id)->name).arg(id).arg(signal->name.c_str()));
}
void ChartView::updateFromSettings() {
@ -250,7 +247,6 @@ void ChartView::updateFromSettings() {
chart()->setTheme(settings.chart_theme == 0 ? QChart::ChartThemeLight : QChart::QChart::ChartThemeDark);
auto color = chart()->titleBrush().color();
line_marker->setPen(QPen(color, 2));
msg_title->setDefaultTextColor(color);
}
void ChartView::setRange(double min, double max, bool force_update) {

@ -44,7 +44,7 @@ private:
QGraphicsItemGroup *item_group;
QGraphicsLineItem *line_marker, *track_line;
QGraphicsEllipseItem *track_ellipse;
QGraphicsTextItem *value_text, *msg_title;
QGraphicsTextItem *value_text;
QGraphicsProxyWidget *close_btn_proxy;
QVector<QPointF> vals;
};

Loading…
Cancel
Save