mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-26 00:12:05 +08:00
cabana: scrub by shift dragging on graph (#27545)
* cabana: scrub by shift dragging on graph * not while live streaming
This commit is contained in:
@@ -668,6 +668,16 @@ void ChartView::mousePressEvent(QMouseEvent *event) {
|
||||
if (dropAction == Qt::MoveAction) {
|
||||
return;
|
||||
}
|
||||
} else if (event->button() == Qt::LeftButton && QApplication::keyboardModifiers().testFlag(Qt::ShiftModifier)) {
|
||||
if (!can->liveStreaming()) {
|
||||
// Save current playback state when scrubbing
|
||||
resume_after_scrub = !can->isPaused();
|
||||
if (resume_after_scrub) {
|
||||
can->pause(true);
|
||||
}
|
||||
|
||||
is_scrubbing = true;
|
||||
}
|
||||
} else {
|
||||
QChartView::mousePressEvent(event);
|
||||
}
|
||||
@@ -701,9 +711,25 @@ void ChartView::mouseReleaseEvent(QMouseEvent *event) {
|
||||
} else {
|
||||
QGraphicsView::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
// Resume playback if we were scrubbing
|
||||
is_scrubbing = false;
|
||||
if (resume_after_scrub) {
|
||||
can->pause(false);
|
||||
resume_after_scrub = false;
|
||||
}
|
||||
}
|
||||
|
||||
void ChartView::mouseMoveEvent(QMouseEvent *ev) {
|
||||
// Scrubbing
|
||||
if (is_scrubbing && QApplication::keyboardModifiers().testFlag(Qt::ShiftModifier)) {
|
||||
double t = chart()->mapToValue({(double)ev->x(), (double)ev->y()}).x();
|
||||
// Prevent seeking past the end of the route
|
||||
t = std::clamp(t, 0., can->totalSeconds());
|
||||
can->seekTo(t);
|
||||
return;
|
||||
}
|
||||
|
||||
auto rubber = findChild<QRubberBand *>();
|
||||
bool is_zooming = rubber && rubber->isVisible();
|
||||
const auto plot_area = chart()->plotArea();
|
||||
|
||||
@@ -97,6 +97,8 @@ private:
|
||||
double cur_sec = 0;
|
||||
const QString mime_type = "application/x-cabanachartview";
|
||||
SeriesType series_type = SeriesType::Line;
|
||||
bool is_scrubbing = false;
|
||||
bool resume_after_scrub = false;
|
||||
friend class ChartsWidget;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user