diff --git a/selfdrive/ui/qt/offroad/settings.h b/selfdrive/ui/qt/offroad/settings.h index f4ca65233e..037aa7070a 100644 --- a/selfdrive/ui/qt/offroad/settings.h +++ b/selfdrive/ui/qt/offroad/settings.h @@ -15,6 +15,10 @@ #include "selfdrive/ui/qt/util.h" #include "selfdrive/ui/qt/widgets/controls.h" +#ifdef SUNNYPILOT +#include "selfdrive/ui/sunnypilot/qt/widgets/sp_priv_controls.h" +#endif + // ********** settings window + top-level panels ********** class SettingsWindow : public QFrame { Q_OBJECT diff --git a/selfdrive/ui/qt/widgets/controls.cc b/selfdrive/ui/qt/widgets/controls.cc index 238051cf5e..09c23eb80c 100644 --- a/selfdrive/ui/qt/widgets/controls.cc +++ b/selfdrive/ui/qt/widgets/controls.cc @@ -178,15 +178,6 @@ ParamControl::ParamControl(const QString ¶m, const QString &title, const QSt : ToggleControl(title, desc, icon, false, parent) { key = param.toStdString(); QObject::connect(this, &ParamControl::toggleFlipped, this, &ParamControl::toggleClicked); - - hlayout->removeWidget(&toggle); - hlayout->insertWidget(0, &toggle); - - hlayout->removeWidget(this->icon_label); - this->icon_pixmap = QPixmap(icon).scaledToWidth(20, Qt::SmoothTransformation); - this->icon_label->setPixmap(this->icon_pixmap); - this->icon_label->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); - hlayout->insertWidget(1, this->icon_label); } void ParamControl::toggleClicked(bool state) { diff --git a/selfdrive/ui/qt/widgets/controls.h b/selfdrive/ui/qt/widgets/controls.h index 3466b67f5e..01f1eccbf9 100644 --- a/selfdrive/ui/qt/widgets/controls.h +++ b/selfdrive/ui/qt/widgets/controls.h @@ -181,8 +181,6 @@ public: refresh(); } - bool isToggled() { return params.getBool(key); } - private: void toggleClicked(bool state); void setIcon(bool state) { @@ -193,8 +191,14 @@ private: } } +#ifdef SUNNYPILOT +protected: +#endif std::string key; Params params; +#ifdef SUNNYPILOT +private: +#endif QPixmap active_icon_pixmap; bool confirm = false; bool store_confirm = false; diff --git a/selfdrive/ui/sunnypilot/SConscript b/selfdrive/ui/sunnypilot/SConscript index d345af9412..8d5f1d5512 100644 --- a/selfdrive/ui/sunnypilot/SConscript +++ b/selfdrive/ui/sunnypilot/SConscript @@ -15,7 +15,8 @@ widgets_src = [ "sunnypilot/qt/offroad/models_fetcher.cc", "sunnypilot/qt/offroad/speed_limit_warning_settings.cc", "sunnypilot/qt/offroad/speed_limit_policy_settings.cc", - "sunnypilot/qt/offroad/sunnylink_settings.cc" + "sunnypilot/qt/offroad/sunnylink_settings.cc", + "sunnypilot/qt/widgets/sp_priv_controls.cc" ] network_src = [ diff --git a/selfdrive/ui/sunnypilot/qt/offroad/custom_offsets_settings.h b/selfdrive/ui/sunnypilot/qt/offroad/custom_offsets_settings.h index 63a5a817be..0b693ffc0c 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/custom_offsets_settings.h +++ b/selfdrive/ui/sunnypilot/qt/offroad/custom_offsets_settings.h @@ -1,6 +1,6 @@ #pragma once -#include "selfdrive/ui/qt/widgets/controls.h" +#include "selfdrive/ui/sunnypilot/qt/widgets/sp_priv_controls.h" #include "selfdrive/ui/qt/widgets/scrollview.h" class CameraOffset : public SPOptionControl { @@ -38,7 +38,7 @@ signals: private: Params params; - std::map toggles; + std::map toggles; CameraOffset *camera_offset; PathOffset *path_offset; diff --git a/selfdrive/ui/sunnypilot/qt/offroad/display_settings.cc b/selfdrive/ui/sunnypilot/qt/offroad/display_settings.cc index 02d723c363..cceb2ef7e9 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/display_settings.cc +++ b/selfdrive/ui/sunnypilot/qt/offroad/display_settings.cc @@ -38,7 +38,7 @@ DisplayPanel::DisplayPanel(QWidget *parent) : ListWidget(parent, false) { connect(brightness_control, &SPOptionControl::updateLabels, brightness_control, &BrightnessControl::refresh); for (auto &[param, title, desc, icon] : toggle_defs) { - auto toggle = new ParamControl(param, title, desc, icon, this); + auto toggle = new ParamControlSP(param, title, desc, icon, this); addItem(toggle); toggles[param.toStdString()] = toggle; diff --git a/selfdrive/ui/sunnypilot/qt/offroad/display_settings.h b/selfdrive/ui/sunnypilot/qt/offroad/display_settings.h index b8083b53fc..ee1e6b6308 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/display_settings.h +++ b/selfdrive/ui/sunnypilot/qt/offroad/display_settings.h @@ -1,6 +1,6 @@ #pragma once -#include "selfdrive/ui/qt/widgets/controls.h" +#include "selfdrive/ui/sunnypilot/qt/widgets/sp_priv_controls.h" class OnroadScreenOff : public SPOptionControl { Q_OBJECT @@ -62,7 +62,7 @@ public slots: private: Params params; - std::map toggles; + std::map toggles; OnroadScreenOff *onroad_screen_off; OnroadScreenOffBrightness *onroad_screen_off_brightness; diff --git a/selfdrive/ui/sunnypilot/qt/offroad/lane_change_settings.cc b/selfdrive/ui/sunnypilot/qt/offroad/lane_change_settings.cc index e950ab71c3..684568c57d 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/lane_change_settings.cc +++ b/selfdrive/ui/sunnypilot/qt/offroad/lane_change_settings.cc @@ -47,7 +47,7 @@ LaneChangeSettings::LaneChangeSettings(QWidget* parent) : QWidget(parent) { connect(pause_lateral_speed, &SPOptionControl::updateLabels, pause_lateral_speed, &PauseLateralSpeed::refresh); for (auto &[param, title, desc, icon] : toggle_defs) { - auto toggle = new ParamControl(param, title, desc, icon, this); + auto toggle = new ParamControlSP(param, title, desc, icon, this); list->addItem(toggle); toggles[param.toStdString()] = toggle; diff --git a/selfdrive/ui/sunnypilot/qt/offroad/lane_change_settings.h b/selfdrive/ui/sunnypilot/qt/offroad/lane_change_settings.h index dd8e1748bd..6c2d0d5708 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/lane_change_settings.h +++ b/selfdrive/ui/sunnypilot/qt/offroad/lane_change_settings.h @@ -1,7 +1,7 @@ #pragma once #include "selfdrive/ui/ui.h" -#include "selfdrive/ui/qt/widgets/controls.h" +#include "selfdrive/ui/sunnypilot/qt/widgets/sp_priv_controls.h" #include "selfdrive/ui/qt/widgets/scrollview.h" class AutoLaneChangeTimer : public SPOptionControl { @@ -50,7 +50,7 @@ public slots: private: Params params; - std::map toggles; + std::map toggles; AutoLaneChangeTimer *auto_lane_change_timer; PauseLateralSpeed *pause_lateral_speed; diff --git a/selfdrive/ui/sunnypilot/qt/offroad/mads_settings.cc b/selfdrive/ui/sunnypilot/qt/offroad/mads_settings.cc index 0a3ced7c69..678b495d19 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/mads_settings.cc +++ b/selfdrive/ui/sunnypilot/qt/offroad/mads_settings.cc @@ -44,7 +44,7 @@ MadsSettings::MadsSettings(QWidget* parent) : QWidget(parent) { list->addItem(dlob_settings); for (auto &[param, title, desc, icon] : toggle_defs) { - auto toggle = new ParamControl(param, title, desc, icon, this); + auto toggle = new ParamControlSP(param, title, desc, icon, this); list->addItem(toggle); toggles[param.toStdString()] = toggle; diff --git a/selfdrive/ui/sunnypilot/qt/offroad/mads_settings.h b/selfdrive/ui/sunnypilot/qt/offroad/mads_settings.h index 2a949c97a4..afdf0caeed 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/mads_settings.h +++ b/selfdrive/ui/sunnypilot/qt/offroad/mads_settings.h @@ -1,7 +1,7 @@ #pragma once #include "selfdrive/ui/ui.h" -#include "selfdrive/ui/qt/widgets/controls.h" +#include "selfdrive/ui/sunnypilot/qt/widgets/sp_priv_controls.h" #include "selfdrive/ui/qt/widgets/scrollview.h" class MadsSettings : public QWidget { @@ -19,7 +19,7 @@ public slots: private: Params params; - std::map toggles; + std::map toggles; ButtonParamControl *dlob_settings; }; diff --git a/selfdrive/ui/sunnypilot/qt/offroad/monitoring_settings.cc b/selfdrive/ui/sunnypilot/qt/offroad/monitoring_settings.cc index 7d740a3586..6afa087eb4 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/monitoring_settings.cc +++ b/selfdrive/ui/sunnypilot/qt/offroad/monitoring_settings.cc @@ -15,7 +15,7 @@ MonitoringPanel::MonitoringPanel(QWidget *parent) : QFrame(parent) { }; for (auto &[param, title, desc, icon] : toggle_defs) { - auto toggle = new ParamControl(param, title, desc, icon, this); + auto toggle = new ParamControlSP(param, title, desc, icon, this); list->addItem(toggle); toggles[param.toStdString()] = toggle; diff --git a/selfdrive/ui/sunnypilot/qt/offroad/monitoring_settings.h b/selfdrive/ui/sunnypilot/qt/offroad/monitoring_settings.h index 214d2f8ac0..8f184a4413 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/monitoring_settings.h +++ b/selfdrive/ui/sunnypilot/qt/offroad/monitoring_settings.h @@ -1,6 +1,6 @@ #pragma once -#include "selfdrive/ui/qt/widgets/controls.h" +#include "selfdrive/ui/sunnypilot/qt/widgets/sp_priv_controls.h" #include "selfdrive/ui/qt/widgets/scrollview.h" class MonitoringPanel : public QFrame { @@ -13,5 +13,5 @@ private: QStackedLayout* main_layout = nullptr; QWidget* monitoringScreen = nullptr; Params params; - std::map toggles; + std::map toggles; }; diff --git a/selfdrive/ui/sunnypilot/qt/offroad/osm_settings.h b/selfdrive/ui/sunnypilot/qt/offroad/osm_settings.h index cc2556b150..587b214350 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/osm_settings.h +++ b/selfdrive/ui/sunnypilot/qt/offroad/osm_settings.h @@ -9,7 +9,7 @@ #include "common/swaglog.h" #include "selfdrive/ui/qt/network/wifi_manager.h" -#include "selfdrive/ui/qt/widgets/controls.h" +#include "selfdrive/ui/sunnypilot/qt/widgets/sp_priv_controls.h" #include "selfdrive/ui/sunnypilot/qt/offroad/locations_fetcher.h" #include "selfdrive/ui/qt/widgets/scrollview.h" #include "selfdrive/ui/qt/util.h" @@ -31,7 +31,7 @@ private: QWidget* osmScreen = nullptr; Params params; Params mem_params{ Hardware::PC() ? "": "/dev/shm/params"}; - std::map toggles; + std::map toggles; std::optional> mapSizeFuture; const SubMaster &sm = *uiState()->sm; diff --git a/selfdrive/ui/sunnypilot/qt/offroad/sp_priv_settings.cc b/selfdrive/ui/sunnypilot/qt/offroad/sp_priv_settings.cc index bccb332039..26fff880a6 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/sp_priv_settings.cc +++ b/selfdrive/ui/sunnypilot/qt/offroad/sp_priv_settings.cc @@ -123,7 +123,7 @@ TogglesPanelSP::TogglesPanelSP(SettingsWindow *parent) : TogglesPanel(parent) { QObject::connect(uiState(), &UIState::uiUpdate, this, &TogglesPanelSP::updateState); for (auto &[param, title, desc, icon] : toggle_defs) { - auto toggle = new ParamControl(param, title, desc, icon, this); + auto toggle = new ParamControlSP(param, title, desc, icon, this); bool locked = params.getBool((param + "Lock").toStdString()); toggle->setEnabled(!locked); diff --git a/selfdrive/ui/sunnypilot/qt/offroad/sp_priv_settings.h b/selfdrive/ui/sunnypilot/qt/offroad/sp_priv_settings.h index 6fbb2de6f0..f99b0ce075 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/sp_priv_settings.h +++ b/selfdrive/ui/sunnypilot/qt/offroad/sp_priv_settings.h @@ -13,6 +13,7 @@ private slots: void updateState(const UIState &s) override; private: + std::map toggles; ButtonParamControl *accel_personality_setting; ParamWatcher *param_watcher; diff --git a/selfdrive/ui/sunnypilot/qt/offroad/speed_limit_control_settings.h b/selfdrive/ui/sunnypilot/qt/offroad/speed_limit_control_settings.h index 877064e577..3e66956d0c 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/speed_limit_control_settings.h +++ b/selfdrive/ui/sunnypilot/qt/offroad/speed_limit_control_settings.h @@ -1,7 +1,7 @@ #pragma once #include "selfdrive/ui/ui.h" -#include "selfdrive/ui/qt/widgets/controls.h" +#include "selfdrive/ui/sunnypilot/qt/widgets/sp_priv_controls.h" #include "selfdrive/ui/qt/widgets/scrollview.h" #include "selfdrive/ui/qt/util.h" @@ -33,7 +33,7 @@ public slots: private: Params params; - std::map toggles; + std::map toggles; SpeedLimitValueOffset *slvo; ButtonParamControl *speed_limit_offset_settings; diff --git a/selfdrive/ui/sunnypilot/qt/offroad/speed_limit_warning_settings.cc b/selfdrive/ui/sunnypilot/qt/offroad/speed_limit_warning_settings.cc index 16557c1228..7b7c9676ac 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/speed_limit_warning_settings.cc +++ b/selfdrive/ui/sunnypilot/qt/offroad/speed_limit_warning_settings.cc @@ -23,7 +23,7 @@ SpeedLimitWarningSettings::SpeedLimitWarningSettings(QWidget* parent) : QWidget( speed_limit_warning_settings->showDescription(); list->addItem(speed_limit_warning_settings); - speed_limit_warning_flash = new ParamControl( + speed_limit_warning_flash = new ParamControlSP( "SpeedLimitWarningFlash", tr("Warning with speed limit flash"), tr("When Speed Limit Warning is enabled, the speed limit sign will alert the driver when the cruising speed is faster than then speed limit plus the offset."), diff --git a/selfdrive/ui/sunnypilot/qt/offroad/speed_limit_warning_settings.h b/selfdrive/ui/sunnypilot/qt/offroad/speed_limit_warning_settings.h index ce3c48ac3f..1a7d3c2144 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/speed_limit_warning_settings.h +++ b/selfdrive/ui/sunnypilot/qt/offroad/speed_limit_warning_settings.h @@ -1,7 +1,7 @@ #pragma once #include "selfdrive/ui/ui.h" -#include "selfdrive/ui/qt/widgets/controls.h" +#include "selfdrive/ui/sunnypilot/qt/widgets/sp_priv_controls.h" #include "selfdrive/ui/qt/widgets/scrollview.h" #include "selfdrive/ui/qt/util.h" @@ -33,11 +33,11 @@ public slots: private: Params params; - std::map toggles; + std::map toggles; SpeedLimitWarningValueOffset *slwvo; ButtonParamControl *speed_limit_warning_offset_settings; - ParamControl *speed_limit_warning_flash; + ParamControlSP *speed_limit_warning_flash; ButtonParamControl *speed_limit_warning_settings; ParamWatcher *param_watcher; diff --git a/selfdrive/ui/sunnypilot/qt/offroad/sunnylink_settings.cc b/selfdrive/ui/sunnypilot/qt/offroad/sunnylink_settings.cc index c363e5655f..3f00c92c37 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/sunnylink_settings.cc +++ b/selfdrive/ui/sunnypilot/qt/offroad/sunnylink_settings.cc @@ -17,7 +17,7 @@ SunnylinkPanel::SunnylinkPanel(QWidget* parent) : QFrame(parent) { connect(uiState(), &UIState::sunnylinkDeviceUsersChanged, this, &SunnylinkPanel::updateLabels); auto list = new ListWidget(this, false); - sunnylinkEnabledBtn = new ParamControl( + sunnylinkEnabledBtn = new ParamControlSP( "SunnylinkEnabled", tr("Enable sunnylink"), sunnylinkBtnDescription, @@ -29,12 +29,12 @@ SunnylinkPanel::SunnylinkPanel(QWidget* parent) : QFrame(parent) { list->addItem(horizontal_line()); sunnylinkBtnDescription = tr("This is the master switch, it will allow you to cutoff any sunnylink requests should you want to do that."); - connect(sunnylinkEnabledBtn, &ParamControl::showDescriptionEvent, [=]() { + connect(sunnylinkEnabledBtn, &ParamControlSP::showDescriptionEvent, [=]() { //resets the description to the default one for the easter egg sunnylinkEnabledBtn->setDescription(sunnylinkBtnDescription); }); - connect(sunnylinkEnabledBtn, &ParamControl::toggleFlipped, [=](bool enabled) { + connect(sunnylinkEnabledBtn, &ParamControlSP::toggleFlipped, [=](bool enabled) { if (enabled) { auto proud_description = ""+ tr("🎉Welcome back! We're excited to see you've enabled sunnylink again! 🚀")+ ""; sunnylinkEnabledBtn->showDescription(); diff --git a/selfdrive/ui/sunnypilot/qt/offroad/sunnylink_settings.h b/selfdrive/ui/sunnypilot/qt/offroad/sunnylink_settings.h index 5a7ead697a..dbcaa73868 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/sunnylink_settings.h +++ b/selfdrive/ui/sunnypilot/qt/offroad/sunnylink_settings.h @@ -7,7 +7,7 @@ #include "selfdrive/ui/ui.h" #include "selfdrive/ui/qt/util.h" -#include "selfdrive/ui/qt/widgets/controls.h" +#include "selfdrive/ui/sunnypilot/qt/widgets/sp_priv_controls.h" #include "selfdrive/ui/qt/widgets/scrollview.h" const QString SUNNYLINK_BASE_URL = util::getenv("SUNNYLINK_API_HOST", "https://stg.api.sunnypilot.ai").c_str(); @@ -78,7 +78,7 @@ public slots: private: - ParamControl* sunnylinkEnabledBtn; + ParamControlSP* sunnylinkEnabledBtn; QStackedLayout* main_layout = nullptr; QWidget* sunnylinkScreen = nullptr; ScrollView *scrollView = nullptr; diff --git a/selfdrive/ui/sunnypilot/qt/offroad/sunnypilot_settings.cc b/selfdrive/ui/sunnypilot/qt/offroad/sunnypilot_settings.cc index 055bb648a4..5240aa1949 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/sunnypilot_settings.cc +++ b/selfdrive/ui/sunnypilot/qt/offroad/sunnypilot_settings.cc @@ -251,7 +251,7 @@ SunnypilotPanel::SunnypilotPanel(QWidget *parent) : QFrame(parent) { dlp_settings->showDescription(); for (auto &[param, title, desc, icon] : toggle_defs) { - auto toggle = new ParamControl(param, title, desc, icon, this); + auto toggle = new ParamControlSP(param, title, desc, icon, this); list->addItem(toggle); toggles[param.toStdString()] = toggle; diff --git a/selfdrive/ui/sunnypilot/qt/offroad/sunnypilot_settings.h b/selfdrive/ui/sunnypilot/qt/offroad/sunnypilot_settings.h index 379a9a2875..363ca8473e 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/sunnypilot_settings.h +++ b/selfdrive/ui/sunnypilot/qt/offroad/sunnypilot_settings.h @@ -9,7 +9,7 @@ #include "selfdrive/ui/sunnypilot/qt/offroad/speed_limit_warning_settings.h" #include "selfdrive/ui/sunnypilot/qt/offroad/speed_limit_policy_settings.h" #include "selfdrive/ui/qt/util.h" -#include "selfdrive/ui/qt/widgets/controls.h" +#include "selfdrive/ui/sunnypilot/qt/widgets/sp_priv_controls.h" #include "selfdrive/ui/qt/widgets/scrollview.h" class TorqueFriction : public SPOptionControl { @@ -60,7 +60,7 @@ private: LaneChangeSettings* lane_change_settings = nullptr; CustomOffsetsSettings* custom_offsets_settings = nullptr; Params params; - std::map toggles; + std::map toggles; ParamWatcher *param_watcher; TorqueFriction *friction; diff --git a/selfdrive/ui/sunnypilot/qt/offroad/vehicle_settings.cc b/selfdrive/ui/sunnypilot/qt/offroad/vehicle_settings.cc index 42222f0b2b..00a9dc4b26 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/vehicle_settings.cc +++ b/selfdrive/ui/sunnypilot/qt/offroad/vehicle_settings.cc @@ -72,7 +72,7 @@ SPVehiclesTogglesPanel::SPVehiclesTogglesPanel(VehiclePanel *parent) : ListWidge // Hyundai/Kia/Genesis addItem(new LabelControl(tr("Hyundai/Kia/Genesis"))); - auto hkgSmoothStop = new ParamControl( + auto hkgSmoothStop = new ParamControlSP( "HkgSmoothStop", tr("HKG CAN: Smoother Stopping Performance (Beta)"), tr("Smoother stopping behind a stopped car or desired stopping event. This is only applicable to HKG CAN platforms using openpilot longitudinal control."), @@ -83,7 +83,7 @@ SPVehiclesTogglesPanel::SPVehiclesTogglesPanel(VehiclePanel *parent) : ListWidge // Subaru addItem(new LabelControl(tr("Subaru"))); - auto subaruManualParkingBrakeSng = new ParamControl( + auto subaruManualParkingBrakeSng = new ParamControlSP( "SubaruManualParkingBrakeSng", tr("Manual Parking Brake: Stop and Go (Beta)"), tr("Experimental feature to enable stop and go for Subaru Global models with manual handbrake. Models with electric parking brake should keep this disabled. Thanks to martinl for this implementation!"), @@ -94,7 +94,7 @@ SPVehiclesTogglesPanel::SPVehiclesTogglesPanel(VehiclePanel *parent) : ListWidge // Toyota/Lexus addItem(new LabelControl(tr("Toyota/Lexus"))); - stockLongToyota = new ParamControl( + stockLongToyota = new ParamControlSP( "StockLongToyota", tr("Enable Stock Toyota Longitudinal Control"), tr("sunnypilot will not take over control of gas and brakes. Stock Toyota longitudinal control will be used."), @@ -103,7 +103,7 @@ SPVehiclesTogglesPanel::SPVehiclesTogglesPanel(VehiclePanel *parent) : ListWidge stockLongToyota->setConfirmation(true, false); addItem(stockLongToyota); - auto lkasToggle = new ParamControl( + auto lkasToggle = new ParamControlSP( "LkasToggle", tr("Allow M.A.D.S. toggling w/ LKAS Button (Beta)"), QString("%1
" @@ -115,7 +115,7 @@ SPVehiclesTogglesPanel::SPVehiclesTogglesPanel(VehiclePanel *parent) : ListWidge lkasToggle->setConfirmation(true, false); addItem(lkasToggle); - auto toyotaTss2LongTune = new ParamControl( + auto toyotaTss2LongTune = new ParamControlSP( "ToyotaTSS2Long", tr("Toyota TSS2 Longitudinal: Custom Tuning"), tr("Smoother longitudinal performance for Toyota/Lexus TSS2/LSS2 cars. Big thanks to dragonpilot-community for this implementation."), @@ -124,7 +124,7 @@ SPVehiclesTogglesPanel::SPVehiclesTogglesPanel(VehiclePanel *parent) : ListWidge toyotaTss2LongTune->setConfirmation(true, false); addItem(toyotaTss2LongTune); - auto toyotaAbh = new ParamControl( + auto toyotaAbh = new ParamControlSP( "ToyotaAutoHold", tr("Enable Automatic Brake Hold (AHB)"), QString("%1

%2

%3") @@ -136,7 +136,7 @@ SPVehiclesTogglesPanel::SPVehiclesTogglesPanel(VehiclePanel *parent) : ListWidge toyotaAbh->setConfirmation(true, false); addItem(toyotaAbh); - toyotaEnhancedBsm = new ParamControl( + toyotaEnhancedBsm = new ParamControlSP( "ToyotaEnhancedBsm", tr("Enable Enhanced Blind Spot Monitor"), "", @@ -145,7 +145,7 @@ SPVehiclesTogglesPanel::SPVehiclesTogglesPanel(VehiclePanel *parent) : ListWidge toyotaEnhancedBsm->setConfirmation(true, false); addItem(toyotaEnhancedBsm); - auto toyotaSngHack = new ParamControl( + auto toyotaSngHack = new ParamControlSP( "ToyotaSnG", tr("Enable Toyota Stop and Go Hack"), tr("sunnypilot will allow some Toyota/Lexus cars to auto resume during stop and go traffic. This feature is only applicable to certain models. Use at your own risk."), @@ -154,7 +154,7 @@ SPVehiclesTogglesPanel::SPVehiclesTogglesPanel(VehiclePanel *parent) : ListWidge toyotaSngHack->setConfirmation(true, false); addItem(toyotaSngHack); - auto toyotaAutoLock = new ParamControl( + auto toyotaAutoLock = new ParamControlSP( "ToyotaAutoLock", tr("Enable Toyota Door Auto Locking"), tr("sunnypilot will attempt to lock the doors when drive above 10 km/h (6.2 mph).\nReboot Required."), @@ -163,7 +163,7 @@ SPVehiclesTogglesPanel::SPVehiclesTogglesPanel(VehiclePanel *parent) : ListWidge toyotaAutoLock->setConfirmation(true, false); addItem(toyotaAutoLock); - auto toyotaAutoUnlock = new ParamControl( + auto toyotaAutoUnlock = new ParamControlSP( "ToyotaAutoUnlockByShifter", tr("Enable Toyota Door Auto Unlocking"), tr("sunnypilot will attempt to unlock the doors when shift to gear P.\nReboot Required."), @@ -174,7 +174,7 @@ SPVehiclesTogglesPanel::SPVehiclesTogglesPanel(VehiclePanel *parent) : ListWidge // Volkswagen addItem(new LabelControl(tr("Volkswagen"))); - auto volkswagenCCOnly = new ParamControl( + auto volkswagenCCOnly = new ParamControlSP( "VwCCOnly", tr("Enable CC Only support"), tr("sunnypilot supports Volkswagen MQB CC only platforms with this toggle enabled. Only enable this toggle if your car does not have ACC from the factory."), diff --git a/selfdrive/ui/sunnypilot/qt/offroad/vehicle_settings.h b/selfdrive/ui/sunnypilot/qt/offroad/vehicle_settings.h index b210225f49..a154d6df97 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/vehicle_settings.h +++ b/selfdrive/ui/sunnypilot/qt/offroad/vehicle_settings.h @@ -5,7 +5,7 @@ #include "common/watchdog.h" #include "selfdrive/ui/ui.h" #include "selfdrive/ui/qt/util.h" -#include "selfdrive/ui/qt/widgets/controls.h" +#include "selfdrive/ui/sunnypilot/qt/widgets/sp_priv_controls.h" #include "selfdrive/ui/qt/widgets/scrollview.h" class VehiclePanel : public QWidget { @@ -44,8 +44,8 @@ private: Params params; bool is_onroad = false; - ParamControl *stockLongToyota; - ParamControl *toyotaEnhancedBsm; + ParamControlSP *stockLongToyota; + ParamControlSP *toyotaEnhancedBsm; const QString toyotaEnhancedBsmDescription = QString("%1

" "%2") diff --git a/selfdrive/ui/sunnypilot/qt/offroad/visuals_settings.cc b/selfdrive/ui/sunnypilot/qt/offroad/visuals_settings.cc index 364c1e2f6d..1c535bf126 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/visuals_settings.cc +++ b/selfdrive/ui/sunnypilot/qt/offroad/visuals_settings.cc @@ -92,7 +92,7 @@ VisualsPanel::VisualsPanel(QWidget *parent) : ListWidget(parent) { chevron_info_settings->showDescription(); for (auto &[param, title, desc, icon] : toggle_defs) { - auto toggle = new ParamControl(param, title, desc, icon, this); + auto toggle = new ParamControlSP(param, title, desc, icon, this); addItem(toggle); toggles[param.toStdString()] = toggle; diff --git a/selfdrive/ui/sunnypilot/qt/offroad/visuals_settings.h b/selfdrive/ui/sunnypilot/qt/offroad/visuals_settings.h index 3ea5825f59..38367912c4 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/visuals_settings.h +++ b/selfdrive/ui/sunnypilot/qt/offroad/visuals_settings.h @@ -1,7 +1,7 @@ #pragma once #include "selfdrive/ui/ui.h" -#include "selfdrive/ui/qt/widgets/controls.h" +#include "selfdrive/ui/sunnypilot/qt/widgets/sp_priv_controls.h" class VisualsPanel : public ListWidget { Q_OBJECT @@ -11,7 +11,7 @@ public: private: Params params; - std::map toggles; + std::map toggles; ButtonParamControl *dev_ui_settings; ButtonParamControl *chevron_info_settings; diff --git a/selfdrive/ui/sunnypilot/qt/widgets/sp_priv_controls.cc b/selfdrive/ui/sunnypilot/qt/widgets/sp_priv_controls.cc new file mode 100644 index 0000000000..a43b1700f9 --- /dev/null +++ b/selfdrive/ui/sunnypilot/qt/widgets/sp_priv_controls.cc @@ -0,0 +1,14 @@ +#include "selfdrive/ui/sunnypilot/qt/widgets/sp_priv_controls.h" + +ParamControlSP::ParamControlSP(const QString ¶m, const QString &title, const QString &desc, const QString &icon, QWidget *parent) + : ParamControl(param, title, desc, icon, parent) { + + hlayout->removeWidget(&toggle); + hlayout->insertWidget(0, &toggle); + + hlayout->removeWidget(this->icon_label); + this->icon_pixmap = QPixmap(icon).scaledToWidth(20, Qt::SmoothTransformation); + this->icon_label->setPixmap(this->icon_pixmap); + this->icon_label->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); + hlayout->insertWidget(1, this->icon_label); +} diff --git a/selfdrive/ui/sunnypilot/qt/widgets/sp_priv_controls.h b/selfdrive/ui/sunnypilot/qt/widgets/sp_priv_controls.h new file mode 100644 index 0000000000..624b88d6a1 --- /dev/null +++ b/selfdrive/ui/sunnypilot/qt/widgets/sp_priv_controls.h @@ -0,0 +1,12 @@ +#pragma once + +#include "selfdrive/ui/qt/widgets/controls.h" + +class ParamControlSP : public ParamControl { + Q_OBJECT + +public: + ParamControlSP(const QString ¶m, const QString &title, const QString &desc, const QString &icon, QWidget *parent = nullptr); + + bool isToggled() { return params.getBool(key); } +};