From 897a2bcedce0e4b88cab91b965c4dad1a7353242 Mon Sep 17 00:00:00 2001 From: Nayan Date: Fri, 9 May 2025 22:50:52 -0400 Subject: [PATCH] ui: update Quiet Mode button behavior (#880) * fix style handling * vector them --------- Co-authored-by: Jason Wen --- .../qt/offroad/settings/device_panel.cc | 1 + selfdrive/ui/sunnypilot/qt/widgets/controls.h | 19 +++++-------------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/selfdrive/ui/sunnypilot/qt/offroad/settings/device_panel.cc b/selfdrive/ui/sunnypilot/qt/offroad/settings/device_panel.cc index 70ead6e28..e6855c4b4 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/settings/device_panel.cc +++ b/selfdrive/ui/sunnypilot/qt/offroad/settings/device_panel.cc @@ -116,6 +116,7 @@ DevicePanelSP::DevicePanelSP(SettingsWindowSP *parent) : DevicePanel(parent) { rebootBtn, poweroffBtn, offroadBtn, + buttons["quietModeBtn"], }; QObject::connect(uiState(), &UIState::offroadTransition, [=](bool offroad) { diff --git a/selfdrive/ui/sunnypilot/qt/widgets/controls.h b/selfdrive/ui/sunnypilot/qt/widgets/controls.h index 21c317eac..2a1bc20ac 100644 --- a/selfdrive/ui/sunnypilot/qt/widgets/controls.h +++ b/selfdrive/ui/sunnypilot/qt/widgets/controls.h @@ -658,16 +658,6 @@ public: } } -protected: - // Override mouse release event to handle style updates smoothly - void mouseReleaseEvent(QMouseEvent *event) override { - if (!key.empty()) { - bool next_state = !params.getBool(key); - updateStyle(next_state); - } - QPushButton::mouseReleaseEvent(event); - } - private: std::string key = ""; Params params; @@ -676,13 +666,14 @@ private: QString btn_enabled_off_style = "QPushButton:enabled { background-color: #393939; }"; QString btn_enabled_on_style = "QPushButton:enabled { background-color: #1e79e8; }"; - QString btn_pressed_style = "QPushButton:pressed { background-color: #4A4A4A; }"; - QString btn_disabled_stype = "QPushButton:disabled { background-color: #121212; color: #5C5C5C; }"; + QString btn_off_pressed_style = "QPushButton:pressed { background-color: #4A4A4A; }"; + QString btn_on_pressed_style = "QPushButton:pressed { background-color: #1E8FFF; }"; + QString btn_disabled_style = "QPushButton:disabled { background-color: #121212; color: #5C5C5C; }"; void updateStyle(bool enabled) { QString enabled_style = enabled ? btn_enabled_on_style : btn_enabled_off_style; - - setStyleSheet(buttonStyle + enabled_style + btn_pressed_style + btn_disabled_stype); + QString pressed_style = enabled ? btn_on_pressed_style : btn_off_pressed_style; + setStyleSheet(buttonStyle + enabled_style + pressed_style + btn_disabled_style); } };