mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-09-09 17:53:41 +08:00
9fe4d7ecc7
* Implemented custom Networking class for sunnypilot UI This modification introduced a new 'NetworkingSP' class for the sunnypilot user interface. It's based on the existing Networking class, but tailored to the specific needs of the sunnypilot UI. This class adds a new 'Scan' button to the Wi-Fi screen and implements an additional layout to accommodate both 'Scan' and 'Advanced' buttons. It also contains updates to the file inclusions in 'settings.cc' to use the new class. Moreover, the accessibility of several member variables in the original Networking class has been updated from 'private' to 'protected'. This change enhances the modifiability and extensibility of the class structure. * Add Spanish translations for networking scan messages Added translations for "Scan" and "Scanning..." in the Spanish localization file. These updates ensure proper display and functionality in the networking scan feature for Spanish-speaking users. * updating lang files * Refactor networking component and clean up unused code. Removed unnecessary comments and unused includes to enhance readability and maintainability. Refactored variable declarations for consistency and streamlined layout adjustments in the networking UI code.
116 lines
2.7 KiB
C++
116 lines
2.7 KiB
C++
#pragma once
|
|
|
|
#include <vector>
|
|
|
|
#include "selfdrive/ui/qt/network/wifi_manager.h"
|
|
#include "selfdrive/ui/qt/prime_state.h"
|
|
#include "selfdrive/ui/qt/widgets/input.h"
|
|
#include "selfdrive/ui/qt/widgets/ssh_keys.h"
|
|
#include "selfdrive/ui/qt/widgets/toggle.h"
|
|
|
|
#ifdef SUNNYPILOT
|
|
#include "selfdrive/ui/sunnypilot/qt/widgets/controls.h"
|
|
#define ButtonControl ButtonControlSP
|
|
#define ElidedLabel ElidedLabelSP
|
|
#define LabelControl LabelControlSP
|
|
#define ListWidget ListWidgetSP
|
|
#define ToggleControl ToggleControlSP
|
|
#else
|
|
#include "selfdrive/ui/qt/widgets/controls.h"
|
|
#endif
|
|
|
|
class WifiItem : public QWidget {
|
|
Q_OBJECT
|
|
public:
|
|
explicit WifiItem(const QString &connecting_text, const QString &forget_text, QWidget* parent = nullptr);
|
|
void setItem(const Network& n, const QPixmap &icon, bool show_forget_btn, const QPixmap &strength);
|
|
|
|
signals:
|
|
// Cannot pass Network by reference. it may change after the signal is sent.
|
|
void connectToNetwork(const Network n);
|
|
void forgotNetwork(const Network n);
|
|
|
|
protected:
|
|
ElidedLabel* ssidLabel;
|
|
QPushButton* connecting;
|
|
QPushButton* forgetBtn;
|
|
QLabel* iconLabel;
|
|
QLabel* strengthLabel;
|
|
Network network;
|
|
};
|
|
|
|
class WifiUI : public QWidget {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit WifiUI(QWidget *parent = 0, WifiManager* wifi = 0);
|
|
|
|
private:
|
|
WifiItem *getItem(int n);
|
|
|
|
WifiManager *wifi = nullptr;
|
|
QLabel *scanningLabel = nullptr;
|
|
QPixmap lock;
|
|
QPixmap checkmark;
|
|
QPixmap circled_slash;
|
|
QVector<QPixmap> strengths;
|
|
ListWidget *wifi_list_widget = nullptr;
|
|
std::vector<WifiItem*> wifi_items;
|
|
|
|
signals:
|
|
void connectToNetwork(const Network n);
|
|
|
|
public slots:
|
|
void refresh();
|
|
};
|
|
|
|
class AdvancedNetworking : public QWidget {
|
|
Q_OBJECT
|
|
public:
|
|
explicit AdvancedNetworking(QWidget* parent = 0, WifiManager* wifi = 0);
|
|
void setGsmVisible(bool visible);
|
|
|
|
private:
|
|
LabelControl* ipLabel;
|
|
ToggleControl* tetheringToggle;
|
|
ToggleControl* roamingToggle;
|
|
ButtonControl* editApnButton;
|
|
ButtonControl* hiddenNetworkButton;
|
|
ToggleControl* meteredToggle;
|
|
WifiManager* wifi = nullptr;
|
|
Params params;
|
|
|
|
signals:
|
|
void backPress();
|
|
void requestWifiScreen();
|
|
|
|
public slots:
|
|
void toggleTethering(bool enabled);
|
|
void refresh();
|
|
};
|
|
|
|
class Networking : public QFrame {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit Networking(QWidget* parent = 0, bool show_advanced = true);
|
|
void setPrimeType(PrimeState::Type type);
|
|
WifiManager* wifi = nullptr;
|
|
|
|
protected:
|
|
QStackedLayout* main_layout = nullptr;
|
|
QWidget* wifiScreen = nullptr;
|
|
AdvancedNetworking* an = nullptr;
|
|
WifiUI* wifiWidget;
|
|
|
|
void showEvent(QShowEvent* event) override;
|
|
void hideEvent(QHideEvent* event) override;
|
|
|
|
public slots:
|
|
void refresh();
|
|
|
|
private slots:
|
|
void connectToNetwork(const Network n);
|
|
void wrongPassword(const QString &ssid);
|
|
};
|