cabana: add button to skip to the end of stream (#29953)

old-commit-hash: 6f9798745c
test-msgs
Dean Lee 2 years ago committed by GitHub
parent e974ef9133
commit e1df1cf15c
  1. 20
      tools/cabana/videowidget.cc
  2. 1
      tools/cabana/videowidget.h

@ -35,13 +35,24 @@ VideoWidget::VideoWidget(QWidget *parent) : QFrame(parent) {
} }
// btn controls // btn controls
QButtonGroup *group = new QButtonGroup(this);
group->setExclusive(true);
QHBoxLayout *control_layout = new QHBoxLayout(); QHBoxLayout *control_layout = new QHBoxLayout();
play_btn = new QPushButton(); play_btn = new QPushButton();
play_btn->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); play_btn->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
control_layout->addWidget(play_btn); 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.}) { for (float speed : {0.1, 0.5, 1., 2.}) {
QPushButton *btn = new QPushButton(QString("%1x").arg(speed), this); QPushButton *btn = new QPushButton(QString("%1x").arg(speed), this);
btn->setCheckable(true); btn->setCheckable(true);
@ -121,7 +132,10 @@ void VideoWidget::setMaximumTime(double sec) {
} }
void VideoWidget::updateTimeRange(double min, double max, bool is_zoomed) { 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) { if (!is_zoomed) {
min = 0; min = 0;

@ -81,6 +81,7 @@ protected:
QLabel *end_time_label; QLabel *end_time_label;
QLabel *time_label; QLabel *time_label;
QPushButton *play_btn; QPushButton *play_btn;
QPushButton *skip_to_end_btn = nullptr;
InfoLabel *alert_label; InfoLabel *alert_label;
Slider *slider; Slider *slider;
}; };

Loading…
Cancel
Save