diff --git a/selfdrive/ui/qt/network/networking.h b/selfdrive/ui/qt/network/networking.h index 2d924588f0..a5bb83f8ac 100644 --- a/selfdrive/ui/qt/network/networking.h +++ b/selfdrive/ui/qt/network/networking.h @@ -97,7 +97,7 @@ public: void setPrimeType(PrimeState::Type type); WifiManager* wifi = nullptr; -private: +protected: QStackedLayout* main_layout = nullptr; QWidget* wifiScreen = nullptr; AdvancedNetworking* an = nullptr; diff --git a/selfdrive/ui/sunnypilot/SConscript b/selfdrive/ui/sunnypilot/SConscript index 629d014b70..7cf552d32f 100644 --- a/selfdrive/ui/sunnypilot/SConscript +++ b/selfdrive/ui/sunnypilot/SConscript @@ -4,6 +4,7 @@ widgets_src = [ "sunnypilot/qt/widgets/drive_stats.cc", "sunnypilot/qt/widgets/prime.cc", "sunnypilot/qt/widgets/scrollview.cc", + "sunnypilot/qt/network/networking.cc", ] qt_util = [ diff --git a/selfdrive/ui/sunnypilot/qt/network/networking.cc b/selfdrive/ui/sunnypilot/qt/network/networking.cc new file mode 100644 index 0000000000..3db65a5b51 --- /dev/null +++ b/selfdrive/ui/sunnypilot/qt/network/networking.cc @@ -0,0 +1,45 @@ +#include "selfdrive/ui/sunnypilot/qt/network/networking.h" +#include +#include +#include + +NetworkingSP::NetworkingSP(QWidget *parent) : Networking(parent) { + auto vlayout = wifiScreen->findChild(); + auto hlayout = new QHBoxLayout(); + + // Create and setup scan button + auto scanButton = new QPushButton(tr("Scan")); + scanButton->setObjectName("scan_btn"); + scanButton->setFixedSize(400, 100); + + connect(wifi, &WifiManager::refreshSignal, this, [=]() { scanButton->setText(tr("Scan")); scanButton->setEnabled(true); }); + connect(scanButton, &QPushButton::clicked, [=]() { scanButton->setText(tr("Scanning...")); scanButton->setEnabled(false); wifi->requestScan(); }); + + hlayout->addWidget(scanButton); + hlayout->addStretch(1); + + // Look for an existing Advanced button + QPushButton* existingAdvanced = wifiScreen->findChild("advanced_btn"); + if (existingAdvanced) { + hlayout->addWidget(existingAdvanced); + } + + // Insert our new layout at the top of vlayout + vlayout->setMargin(40); + vlayout->insertLayout(0, hlayout); + + // Add our scan button to the existing style selectors + auto newStyleSheet = styleSheet().replace( + ", #advanced_btn ", + ", #advanced_btn, #scan_btn " + ).replace( + ", #advanced_btn:pressed", + ", #advanced_btn:pressed, #scan_btn:pressed" + ).append(R"( + #scan_btn:disabled { + background-color: #121212; + color: #33FFFFFF; + } + )"); + setStyleSheet(newStyleSheet); +} diff --git a/selfdrive/ui/sunnypilot/qt/network/networking.h b/selfdrive/ui/sunnypilot/qt/network/networking.h new file mode 100644 index 0000000000..3370751bf5 --- /dev/null +++ b/selfdrive/ui/sunnypilot/qt/network/networking.h @@ -0,0 +1,17 @@ +/** +* Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors. + * + * This file is part of sunnypilot and is licensed under the MIT License. + * See the LICENSE.md file in the root directory for more details. + */ + +#pragma once +#include "selfdrive/ui/qt/network/networking.h" + + +class NetworkingSP : public Networking { + Q_OBJECT + +public: + explicit NetworkingSP(QWidget *parent = nullptr); +}; diff --git a/selfdrive/ui/sunnypilot/qt/offroad/settings/settings.cc b/selfdrive/ui/sunnypilot/qt/offroad/settings/settings.cc index 9338b93220..3dbaca1aa7 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/settings/settings.cc +++ b/selfdrive/ui/sunnypilot/qt/offroad/settings/settings.cc @@ -7,9 +7,9 @@ #include "selfdrive/ui/sunnypilot/qt/offroad/settings/settings.h" -#include "selfdrive/ui/qt/network/networking.h" #include "selfdrive/ui/sunnypilot/qt/widgets/scrollview.h" #include "selfdrive/ui/qt/offroad/developer_panel.h" +#include "selfdrive/ui/sunnypilot/qt/network/networking.h" #include "selfdrive/ui/sunnypilot/qt/offroad/settings/device_panel.h" #include "selfdrive/ui/sunnypilot/qt/offroad/settings/software_panel.h" @@ -66,8 +66,8 @@ SettingsWindowSP::SettingsWindowSP(QWidget *parent) : SettingsWindow(parent) { TogglesPanelSP *toggles = new TogglesPanelSP(this); QObject::connect(this, &SettingsWindowSP::expandToggleDescription, toggles, &TogglesPanel::expandToggleDescription); - auto networking = new Networking(this); - QObject::connect(uiState()->prime_state, &PrimeState::changed, networking, &Networking::setPrimeType); + auto networking = new NetworkingSP(this); + QObject::connect(uiState()->prime_state, &PrimeState::changed, networking, &NetworkingSP::setPrimeType); QList panels = { PanelInfo(" " + tr("Device"), device, "../../sunnypilot/selfdrive/assets/offroad/icon_home.svg"), diff --git a/selfdrive/ui/translations/main_ar.ts b/selfdrive/ui/translations/main_ar.ts index 9bcda5568b..7a8bbdf498 100644 --- a/selfdrive/ui/translations/main_ar.ts +++ b/selfdrive/ui/translations/main_ar.ts @@ -507,6 +507,21 @@ Pause Steering: ALC will be paused after the brake pedal is manually pressed.كلمة مرور خاطئة + + NetworkingSP + + Advanced + متقدم + + + Scan + + + + Scanning... + + + OffroadAlert diff --git a/selfdrive/ui/translations/main_de.ts b/selfdrive/ui/translations/main_de.ts index 9b83f74562..7a014c7441 100644 --- a/selfdrive/ui/translations/main_de.ts +++ b/selfdrive/ui/translations/main_de.ts @@ -503,6 +503,21 @@ Pause Steering: ALC will be paused after the brake pedal is manually pressed.Falsches Passwort + + NetworkingSP + + Advanced + Erweitert + + + Scan + + + + Scanning... + + + OffroadAlert diff --git a/selfdrive/ui/translations/main_es.ts b/selfdrive/ui/translations/main_es.ts index 0e50b06ceb..aa11fd6780 100644 --- a/selfdrive/ui/translations/main_es.ts +++ b/selfdrive/ui/translations/main_es.ts @@ -503,6 +503,17 @@ Pause Steering: ALC will be paused after the brake pedal is manually pressed.Contraseña incorrecta + + NetworkingSP + + Scan + Escanear + + + Scanning... + Escaneando... + + OffroadAlert diff --git a/selfdrive/ui/translations/main_fr.ts b/selfdrive/ui/translations/main_fr.ts index bb6b95eb62..658e8d7151 100644 --- a/selfdrive/ui/translations/main_fr.ts +++ b/selfdrive/ui/translations/main_fr.ts @@ -503,6 +503,21 @@ Pause Steering: ALC will be paused after the brake pedal is manually pressed.Mot de passe incorrect + + NetworkingSP + + Advanced + Avancé + + + Scan + + + + Scanning... + + + OffroadAlert diff --git a/selfdrive/ui/translations/main_ja.ts b/selfdrive/ui/translations/main_ja.ts index a6104916ea..09e45b367a 100644 --- a/selfdrive/ui/translations/main_ja.ts +++ b/selfdrive/ui/translations/main_ja.ts @@ -502,6 +502,21 @@ Pause Steering: ALC will be paused after the brake pedal is manually pressed.パスワードが間違っています + + NetworkingSP + + Advanced + 詳細 + + + Scan + + + + Scanning... + + + OffroadAlert diff --git a/selfdrive/ui/translations/main_ko.ts b/selfdrive/ui/translations/main_ko.ts index 25add50046..c90c6bfc18 100644 --- a/selfdrive/ui/translations/main_ko.ts +++ b/selfdrive/ui/translations/main_ko.ts @@ -502,6 +502,21 @@ Pause Steering: ALC will be paused after the brake pedal is manually pressed.비밀번호가 틀렸습니다 + + NetworkingSP + + Advanced + 고급 설정 + + + Scan + + + + Scanning... + + + OffroadAlert diff --git a/selfdrive/ui/translations/main_pt-BR.ts b/selfdrive/ui/translations/main_pt-BR.ts index e1c0fc11ca..244cd6f76e 100644 --- a/selfdrive/ui/translations/main_pt-BR.ts +++ b/selfdrive/ui/translations/main_pt-BR.ts @@ -503,6 +503,21 @@ Pause Steering: ALC will be paused after the brake pedal is manually pressed.Senha incorreta + + NetworkingSP + + Advanced + Avançado + + + Scan + + + + Scanning... + + + OffroadAlert diff --git a/selfdrive/ui/translations/main_th.ts b/selfdrive/ui/translations/main_th.ts index a79c23d1c9..15a8d4b16e 100644 --- a/selfdrive/ui/translations/main_th.ts +++ b/selfdrive/ui/translations/main_th.ts @@ -502,6 +502,21 @@ Pause Steering: ALC will be paused after the brake pedal is manually pressed.รหัสผ่านผิด + + NetworkingSP + + Advanced + ขั้นสูง + + + Scan + + + + Scanning... + + + OffroadAlert diff --git a/selfdrive/ui/translations/main_tr.ts b/selfdrive/ui/translations/main_tr.ts index f43c332a74..4652de1197 100644 --- a/selfdrive/ui/translations/main_tr.ts +++ b/selfdrive/ui/translations/main_tr.ts @@ -502,6 +502,21 @@ Pause Steering: ALC will be paused after the brake pedal is manually pressed.Yalnış parola + + NetworkingSP + + Advanced + Gelişmiş Seçenekler + + + Scan + + + + Scanning... + + + OffroadAlert diff --git a/selfdrive/ui/translations/main_zh-CHS.ts b/selfdrive/ui/translations/main_zh-CHS.ts index 204171430d..915804f7e9 100644 --- a/selfdrive/ui/translations/main_zh-CHS.ts +++ b/selfdrive/ui/translations/main_zh-CHS.ts @@ -502,6 +502,21 @@ Pause Steering: ALC will be paused after the brake pedal is manually pressed.密码错误 + + NetworkingSP + + Advanced + 高级 + + + Scan + + + + Scanning... + + + OffroadAlert diff --git a/selfdrive/ui/translations/main_zh-CHT.ts b/selfdrive/ui/translations/main_zh-CHT.ts index f5cf33d543..6b47598370 100644 --- a/selfdrive/ui/translations/main_zh-CHT.ts +++ b/selfdrive/ui/translations/main_zh-CHT.ts @@ -502,6 +502,21 @@ Pause Steering: ALC will be paused after the brake pedal is manually pressed.密碼錯誤 + + NetworkingSP + + Advanced + 進階 + + + Scan + + + + Scanning... + + + OffroadAlert