Skip to content

Commit

Permalink
ui: Fix buttons layout recreation (commaai#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnyhaibin authored Sep 12, 2023
1 parent 311b53b commit 43c89de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions selfdrive/ui/qt/onroad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,8 @@ AnnotatedCameraWidget::AnnotatedCameraWidget(VisionStreamType type, QWidget* par
QObject::connect(uiState(), &UIState::offroadTransition, this, &AnnotatedCameraWidget::offroadTransition);
#endif

buttons_layout = new QHBoxLayout();
main_layout->addLayout(buttons_layout);
updateButtonsLayout();
}

Expand All @@ -401,7 +403,10 @@ void AnnotatedCameraWidget::offroadTransition(bool offroad) {
#endif

void AnnotatedCameraWidget::updateButtonsLayout() {
QHBoxLayout *buttons_layout = new QHBoxLayout();
QLayoutItem *item;
while ((item = buttons_layout->takeAt(0)) != nullptr) {
delete item;
}

#ifdef ENABLE_DASHCAM
buttons_layout->addWidget(recorder);
Expand All @@ -410,8 +415,6 @@ void AnnotatedCameraWidget::updateButtonsLayout() {
buttons_layout->addSpacing(map_settings_btn->isVisible() ? 60 : 0);
buttons_layout->addWidget(map_settings_btn);
buttons_layout->setAlignment(Qt::AlignBottom | Qt::AlignRight);

main_layout->addLayout(buttons_layout);
}

void AnnotatedCameraWidget::updateState(const UIState &s) {
Expand Down
1 change: 1 addition & 0 deletions selfdrive/ui/qt/onroad.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class AnnotatedCameraWidget : public CameraWidget {
uint64_t last_update_params;

QVBoxLayout *main_layout;
QHBoxLayout *buttons_layout;
ExperimentalButton *experimental_btn;
QPixmap dm_img;
QPixmap map_img;
Expand Down

0 comments on commit 43c89de

Please sign in to comment.