Qt ui: close settings on onroad transition (#20114)

* need to test

* works

* reduce diff

* refactor

Co-authored-by: Comma Device <device@comma.ai>
old-commit-hash: dab2e1298b
This commit is contained in:
grekiki
2021-02-22 10:47:33 +01:00
committed by GitHub
parent aa5575dd06
commit 2b6237dd4c
4 changed files with 10 additions and 0 deletions

View File

@@ -143,6 +143,7 @@ HomeWindow::HomeWindow(QWidget* parent) : QWidget(parent) {
home = new OffroadHome();
layout->addWidget(home, 0, 0);
QObject::connect(glWindow, SIGNAL(offroadTransition(bool)), this, SLOT(setVisibility(bool)));
QObject::connect(glWindow, SIGNAL(offroadTransition(bool)), this, SIGNAL(offroadTransition(bool)));
QObject::connect(this, SIGNAL(openSettings()), home, SLOT(refresh()));
setLayout(layout);
setStyleSheet(R"(

View File

@@ -83,6 +83,7 @@ public:
GLWindow* glWindow;
signals:
void offroadTransition(bool offroad);
void openSettings();
protected:

View File

@@ -15,6 +15,7 @@ MainWindow::MainWindow(QWidget *parent) : QWidget(parent) {
main_layout->setMargin(0);
setLayout(main_layout);
QObject::connect(homeWindow, SIGNAL(openSettings()), this, SLOT(openSettings()));
QObject::connect(homeWindow, SIGNAL(offroadTransition(bool)), this, SLOT(offroadTransition(bool)));
QObject::connect(settingsWindow, SIGNAL(closeSettings()), this, SLOT(closeSettings()));
// start at onboarding
@@ -29,6 +30,12 @@ MainWindow::MainWindow(QWidget *parent) : QWidget(parent) {
)");
}
void MainWindow::offroadTransition(bool offroad){
if(!offroad){
closeSettings();
}
}
void MainWindow::openSettings() {
main_layout->setCurrentWidget(settingsWindow);
}

View File

@@ -23,6 +23,7 @@ private:
OnboardingWindow *onboardingWindow;
public slots:
void offroadTransition(bool offroad);
void openSettings();
void closeSettings();
};