From 1e74eb0547c8fc08d9dd8781f3eae67e3100e5f4 Mon Sep 17 00:00:00 2001 From: grekiki Date: Tue, 23 Feb 2021 14:40:56 +0100 Subject: [PATCH] Qt-UI Close settings when screen turns off (#20117) old-commit-hash: b8052001942cad72b3095381ce6e8e719312e35a --- selfdrive/ui/qt/home.cc | 3 ++- selfdrive/ui/qt/home.hpp | 2 ++ selfdrive/ui/qt/window.cc | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/selfdrive/ui/qt/home.cc b/selfdrive/ui/qt/home.cc index e71902c25b..740003b3e6 100644 --- a/selfdrive/ui/qt/home.cc +++ b/selfdrive/ui/qt/home.cc @@ -144,6 +144,7 @@ HomeWindow::HomeWindow(QWidget* parent) : QWidget(parent) { 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(glWindow, SIGNAL(screen_shutoff()), this, SIGNAL(closeSettings())); QObject::connect(this, SIGNAL(openSettings()), home, SLOT(refresh())); setLayout(layout); setStyleSheet(R"( @@ -241,8 +242,8 @@ void GLWindow::backlightUpdate() { if (!ui_state.awake) { brightness = 0; + emit screen_shutoff(); } - std::thread{set_backlight, brightness}.detach(); } diff --git a/selfdrive/ui/qt/home.hpp b/selfdrive/ui/qt/home.hpp index 419c279334..98ebc77f44 100644 --- a/selfdrive/ui/qt/home.hpp +++ b/selfdrive/ui/qt/home.hpp @@ -28,6 +28,7 @@ public: signals: void offroadTransition(bool offroad); + void screen_shutoff(); protected: void initializeGL() override; @@ -85,6 +86,7 @@ public: signals: void offroadTransition(bool offroad); void openSettings(); + void closeSettings(); protected: void mousePressEvent(QMouseEvent* e) override; diff --git a/selfdrive/ui/qt/window.cc b/selfdrive/ui/qt/window.cc index 239eb6a6ac..e26a500237 100644 --- a/selfdrive/ui/qt/window.cc +++ b/selfdrive/ui/qt/window.cc @@ -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(closeSettings()), this, SLOT(closeSettings())); QObject::connect(homeWindow, SIGNAL(offroadTransition(bool)), this, SLOT(offroadTransition(bool))); QObject::connect(settingsWindow, SIGNAL(closeSettings()), this, SLOT(closeSettings()));