Skip to content

Commit

Permalink
cabana: reduce minimum size (commaai#30223)
Browse files Browse the repository at this point in the history
reduce minimumsize
  • Loading branch information
deanlee authored Oct 12, 2023
1 parent 47813ae commit 818d298
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
1 change: 1 addition & 0 deletions tools/cabana/binaryview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ BinaryView::BinaryView(QWidget *parent) : QTableView(parent) {
delegate = new BinaryItemDelegate(this);
setItemDelegate(delegate);
horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
horizontalHeader()->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
verticalHeader()->setSectionsClickable(false);
verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);
verticalHeader()->setDefaultSectionSize(CELL_HEIGHT);
Expand Down
4 changes: 4 additions & 0 deletions tools/cabana/chart/chartswidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,10 @@ void ChartsWidget::doAutoScroll() {
}
}

QSize ChartsWidget::minimumSizeHint() const {
return QSize(CHART_MIN_WIDTH, QWidget::minimumSizeHint().height());
}

void ChartsWidget::resizeEvent(QResizeEvent *event) {
QWidget::resizeEvent(event);
updateLayout();
Expand Down
1 change: 1 addition & 0 deletions tools/cabana/chart/chartswidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public slots:
void seriesChanged();

private:
QSize minimumSizeHint() const override;
void resizeEvent(QResizeEvent *event) override;
bool event(QEvent *event) override;
void alignCharts();
Expand Down
6 changes: 4 additions & 2 deletions tools/cabana/detailwidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,13 @@ void DetailWidget::refresh() {
for (auto s : binary_view->getOverlappingSignals()) {
warnings.push_back(tr("%1 has overlapping bits.").arg(s->name));
}
name_label->setText(QString("%1 (%2)").arg(msgName(msg_id), msg->transmitter));
} else {
warnings.push_back(tr("Drag-Select in binary view to create new signal."));
name_label->setText(msgName(msg_id));
}

QString msg_name = msg ? QString("%1 (%2)").arg(msg->name, msg->transmitter) : msgName(msg_id);
name_label->setText(msg_name);
name_label->setToolTip(msg_name);
remove_btn->setEnabled(msg != nullptr);

if (!warnings.isEmpty()) {
Expand Down
16 changes: 10 additions & 6 deletions tools/cabana/videowidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ VideoWidget::VideoWidget(QWidget *parent) : QFrame(parent) {
group->setExclusive(true);

QHBoxLayout *control_layout = new QHBoxLayout();
play_btn = new QPushButton();
play_btn = new QToolButton();
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"), {}));
control_layout->addWidget(skip_to_end_btn = new QToolButton(this));
skip_to_end_btn->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
skip_to_end_btn->setIcon(utils::icon("skip-end-fill"));
skip_to_end_btn->setToolTip(tr("Skip to the end"));
QObject::connect(skip_to_end_btn, &QPushButton::clicked, [group]() {
QObject::connect(skip_to_end_btn, &QToolButton::clicked, [group]() {
// set speed to 1.0
group->buttons()[2]->click();
can->pause(false);
Expand All @@ -54,17 +56,19 @@ VideoWidget::VideoWidget(QWidget *parent) : QFrame(parent) {
}

for (float speed : {0.1, 0.5, 1., 2.}) {
QPushButton *btn = new QPushButton(QString("%1x").arg(speed), this);
QToolButton *btn = new QToolButton(this);
btn->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
btn->setText(QString("%1x").arg(speed));
btn->setCheckable(true);
QObject::connect(btn, &QPushButton::clicked, [speed]() { can->setSpeed(speed); });
QObject::connect(btn, &QToolButton::clicked, [speed]() { can->setSpeed(speed); });
control_layout->addWidget(btn);
group->addButton(btn);
if (speed == 1.0) btn->setChecked(true);
}
main_layout->addLayout(control_layout);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);

QObject::connect(play_btn, &QPushButton::clicked, []() { can->pause(!can->isPaused()); });
QObject::connect(play_btn, &QToolButton::clicked, []() { can->pause(!can->isPaused()); });
QObject::connect(can, &AbstractStream::paused, this, &VideoWidget::updatePlayBtnState);
QObject::connect(can, &AbstractStream::resume, this, &VideoWidget::updatePlayBtnState);
QObject::connect(&settings, &Settings::changed, this, &VideoWidget::updatePlayBtnState);
Expand Down
6 changes: 3 additions & 3 deletions tools/cabana/videowidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

#include <QFuture>
#include <QLabel>
#include <QPushButton>
#include <QSlider>
#include <QToolButton>

#include "selfdrive/ui/qt/widgets/cameraview.h"
#include "tools/cabana/streams/abstractstream.h"
Expand Down Expand Up @@ -80,8 +80,8 @@ class VideoWidget : public QFrame {
double maximum_time = 0;
QLabel *end_time_label;
QLabel *time_label;
QPushButton *play_btn;
QPushButton *skip_to_end_btn = nullptr;
QToolButton *play_btn;
QToolButton *skip_to_end_btn = nullptr;
InfoLabel *alert_label;
Slider *slider;
};

0 comments on commit 818d298

Please sign in to comment.