cabana: display the actual signal time on the track line (#28080)

Display the actual signal time on the track line
This commit is contained in:
Dean Lee 2023-05-03 03:46:28 +08:00 committed by GitHub
parent a16730a9c4
commit 50e6c43efd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -534,8 +534,8 @@ void ChartView::showTip(double sec) {
}
tooltip_x = chart()->mapToPosition({sec, 0}).x();
qreal x = tooltip_x;
QStringList text_list(QString::number(chart()->mapToValue({x, 0}).x(), 'f', 3));
qreal x = -1;
QStringList text_list;
for (auto &s : sigs) {
if (s.series->isVisible()) {
QString value = "--";
@ -553,7 +553,11 @@ void ChartView::showTip(double sec) {
.arg(s.series->color().name(), name, value, min, max);
}
}
if (x < 0) {
x = tooltip_x;
}
QPoint pt(x, chart()->plotArea().top());
text_list.push_front(QString::number(chart()->mapToValue({x, 0}).x(), 'f', 3));
QString text = "<p style='white-space:pre'>" % text_list.join("<br />") % "</p>";
tip_label.showText(pt, text, this, visible_rect);
viewport()->update();

View File

@ -30,9 +30,9 @@ void TipLabel::showText(const QPoint &pt, const QString &text, QWidget *w, const
if (!text.isEmpty()) {
QSize extra(1, 1);
resize(sizeHint() + extra);
QPoint tip_pos(pt.x() + 12, rect.top() + 2);
QPoint tip_pos(pt.x() + 8, rect.top() + 2);
if (tip_pos.x() + size().width() >= rect.right()) {
tip_pos.rx() = pt.x() - size().width() - 12;
tip_pos.rx() = pt.x() - size().width() - 8;
}
if (rect.contains({tip_pos, size()})) {
move(w->mapToGlobal(tip_pos));