Skip to content
This repository has been archived by the owner on Jan 9, 2022. It is now read-only.

Commit

Permalink
emit signals
Browse files Browse the repository at this point in the history
  • Loading branch information
sshane committed Aug 12, 2021
1 parent b196668 commit 16b9b39
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
10 changes: 10 additions & 0 deletions selfdrive/ui/qt/maps/map.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ MapWindow::~MapWindow() {
makeCurrent();
}

void MapWindow::hideEvent(QHideEvent *event) {
emit mapVisibilitySignal(false);
QOpenGLWidget::hideEvent(event);
}

void MapWindow::showEvent(QHideEvent *event) {
emit mapVisibilitySignal(true);
QOpenGLWidget::showEvent(event);
}

void MapWindow::initLayers() {
// This doesn't work from initializeGL
if (!m_map->layerExists("modelPathLayer")) {
Expand Down
4 changes: 4 additions & 0 deletions selfdrive/ui/qt/maps/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ class MapWindow : public QOpenGLWidget {
void paintGL() final;
void resizeGL(int w, int h) override;

void hideEvent(QHideEvent *event);
void showEvent(QHideEvent *event);

QMapboxGLSettings m_settings;
QScopedPointer<QMapboxGL> m_map;

Expand Down Expand Up @@ -144,5 +147,6 @@ public slots:
void distanceChanged(float distance);
void instructionsChanged(QMap<QString, QVariant> banner, bool full);
void ETAChanged(float seconds, float seconds_typical, float distance);
void mapVisibilitySignal(bool visible);
};

12 changes: 10 additions & 2 deletions selfdrive/ui/qt/onroad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ void OnroadWindow::updateState(const UIState &s) {
}

void OnroadWindow::offroadTransition(bool offroad) {
buttons->setFixedWidth(width() / 2 - bdr_s);

#ifdef ENABLE_MAPS
if (!offroad) {
QString token = QString::fromStdString(Params().get("MapboxToken"));
Expand All @@ -93,6 +91,7 @@ void OnroadWindow::offroadTransition(bool offroad) {
QObject::connect(this, &OnroadWindow::offroadTransitionSignal, m, &MapWindow::offroadTransition);
split->addWidget(m, 0, Qt::AlignRight);
map = m;
QObject::connect(map, &MapWindow::mapVisibilitySignal, buttons, &ButtonsWindow::mapVisibilityChanged)
}
}
#endif
Expand Down Expand Up @@ -155,6 +154,15 @@ void ButtonsWindow::updateState(const UIState &s) {
// updateMlButton(s.scene.dfButtonStatus); // update model longitudinal button // TODO: add model long back first
}

void ButtonsWindow::mapVisibilityChanged(bool visible) {
qDebug() << "Map visible:" << visible << "setting width to:" << width;
if (visible) {
buttons->setFixedWidth(width() / 2 - bdr_s);
} else {
buttons->setFixedWidth(width() / 2 - bdr_s);
}
}

void ButtonsWindow::updateDfButton(int status) {
if (dfStatus != status) { // updates (resets) on car start, or on button press
dfStatus = status;
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 @@ -31,6 +31,7 @@ class ButtonsWindow : public QWidget {

public slots:
void updateState(const UIState &s);
void mapVisibilityChanged(bool visible);
};

class OnroadAlerts : public QWidget {
Expand Down

0 comments on commit 16b9b39

Please sign in to comment.