Skip to content

Commit

Permalink
cabana: add button to skip to the end of stream (commaai#29953)
Browse files Browse the repository at this point in the history
  • Loading branch information
deanlee authored Sep 17, 2023
1 parent 8a0711a commit 6f97987
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
20 changes: 17 additions & 3 deletions tools/cabana/videowidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,24 @@ VideoWidget::VideoWidget(QWidget *parent) : QFrame(parent) {
}

// btn controls
QButtonGroup *group = new QButtonGroup(this);
group->setExclusive(true);

QHBoxLayout *control_layout = new QHBoxLayout();
play_btn = new QPushButton();
play_btn->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
control_layout->addWidget(play_btn);
if (can->liveStreaming()) {
control_layout->addWidget(skip_to_end_btn = new QPushButton(utils::icon("skip-end-fill"), {}));
skip_to_end_btn->setToolTip(tr("Skip to the end"));
QObject::connect(skip_to_end_btn, &QPushButton::clicked, [group]() {
// set speed to 1.0
group->buttons()[2]->click();
can->pause(false);
can->seekTo(can->totalSeconds() + 1);
});
}

QButtonGroup *group = new QButtonGroup(this);
group->setExclusive(true);
for (float speed : {0.1, 0.5, 1., 2.}) {
QPushButton *btn = new QPushButton(QString("%1x").arg(speed), this);
btn->setCheckable(true);
Expand Down Expand Up @@ -121,7 +132,10 @@ void VideoWidget::setMaximumTime(double sec) {
}

void VideoWidget::updateTimeRange(double min, double max, bool is_zoomed) {
if (can->liveStreaming()) return;
if (can->liveStreaming()) {
skip_to_end_btn->setEnabled(!is_zoomed);
return;
}

if (!is_zoomed) {
min = 0;
Expand Down
1 change: 1 addition & 0 deletions tools/cabana/videowidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class VideoWidget : public QFrame {
QLabel *end_time_label;
QLabel *time_label;
QPushButton *play_btn;
QPushButton *skip_to_end_btn = nullptr;
InfoLabel *alert_label;
Slider *slider;
};

0 comments on commit 6f97987

Please sign in to comment.