don't use setCurrentIndex

pull/29068/head
Shane Smiskol 2 years ago
parent 01e8cc4195
commit 6fde765a3c
  1. 21
      selfdrive/ui/qt/maps/map_panel.cc
  2. 9
      selfdrive/ui/qt/maps/map_panel.h

@ -3,8 +3,6 @@
#include <QHBoxLayout>
#include <QWidget>
#include "selfdrive/ui/qt/maps/map.h"
#include "selfdrive/ui/qt/maps/map_settings.h"
#include "selfdrive/ui/qt/util.h"
#include "selfdrive/ui/ui.h"
@ -12,7 +10,7 @@ MapPanel::MapPanel(const QMapboxGLSettings &mapboxSettings, QWidget *parent) : Q
content_stack = new QStackedLayout(this);
content_stack->setContentsMargins(0, 0, 0, 0);
auto map = new MapWindow(mapboxSettings);
map = new MapWindow(mapboxSettings);
QObject::connect(uiState(), &UIState::offroadTransition, map, &MapWindow::offroadTransition);
QObject::connect(device(), &Device::interactiveTimeout, [=]() {
content_stack->setCurrentIndex(0);
@ -22,12 +20,12 @@ MapPanel::MapPanel(const QMapboxGLSettings &mapboxSettings, QWidget *parent) : Q
if (visible) { emit mapPanelRequested(); }
setVisible(visible);
});
QObject::connect(map, &MapWindow::requestSettings, [=](bool settings) {
content_stack->setCurrentIndex(settings ? 1 : 0);
QObject::connect(map, &MapWindow::requestSettings, [=](bool _settings) {
content_stack->setCurrentIndex(_settings ? 1 : 0);
});
content_stack->addWidget(map);
auto settings = new MapSettings(true, parent);
settings = new MapSettings(true, parent);
QObject::connect(settings, &MapSettings::closeSettings, [=]() {
content_stack->setCurrentIndex(0);
});
@ -36,8 +34,15 @@ MapPanel::MapPanel(const QMapboxGLSettings &mapboxSettings, QWidget *parent) : Q
void MapPanel::toggleMapSettings() {
// show settings if not visible, then toggle between map and settings
int new_index = isVisible() ? (1 - content_stack->currentIndex()) : 1;
content_stack->setCurrentIndex(new_index);
if (isVisible()) {
content_stack->setCurrentWidget(settings);
} else {
if (content_stack->currentWidget() == map) {
content_stack->setCurrentWidget(settings);
} else {
content_stack->setCurrentWidget(map);
}
}
emit mapPanelRequested();
show();
}

@ -4,11 +4,14 @@
#include <QMapboxGL>
#include <QStackedLayout>
#include "selfdrive/ui/qt/maps/map_settings.h"
#include "selfdrive/ui/qt/maps/map.h"
class MapPanel : public QFrame {
Q_OBJECT
public:
explicit MapPanel(const QMapboxGLSettings &settings, QWidget *parent = nullptr);
explicit MapPanel(const QMapboxGLSettings &mapboxSettings, QWidget *parent = nullptr);
signals:
void mapPanelRequested();
@ -18,4 +21,8 @@ public slots:
private:
QStackedLayout *content_stack;
MapWindow *map;
// QWidget *map;
MapSettings *settings;
// QWidget *settings;
};

Loading…
Cancel
Save