mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-04 13:02:09 +08:00
Retain network tethering
This commit is contained in:
@@ -41,6 +41,10 @@ FrogPilotUIState::FrogPilotUIState(QObject *parent) : QObject(parent) {
|
||||
});
|
||||
|
||||
wifi = new WifiManager(this);
|
||||
|
||||
if (params.getInt("TetheringEnabled") == 1) {
|
||||
wifi->setTetheringEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
FrogPilotUIState *frogpilotUIState() {
|
||||
|
||||
@@ -131,9 +131,16 @@ AdvancedNetworking::AdvancedNetworking(QWidget* parent, WifiManager* wifi): QWid
|
||||
|
||||
ListWidget *list = new ListWidget(this);
|
||||
// Enable tethering layout
|
||||
tetheringToggle = new ToggleControl(tr("Enable Tethering"), "", "", wifi->isTetheringEnabled());
|
||||
std::vector<QString> tetheringSelection{tr("Off"), tr("Always"), tr("Only Onroad"), tr("Until Reboot")};
|
||||
tetheringToggle = new ButtonParamControl("TetheringEnabled", tr("Enable Tethering"),
|
||||
tr("Share your device's internet connection with other devices, either all the time or only while driving."),
|
||||
"", tetheringSelection);
|
||||
if (params.getInt("TetheringEnabled") == 3) {
|
||||
params.remove("TetheringEnabled");
|
||||
tetheringToggle->setCheckedButton(0);
|
||||
}
|
||||
list->addItem(tetheringToggle);
|
||||
QObject::connect(tetheringToggle, &ToggleControl::toggleFlipped, this, &AdvancedNetworking::toggleTethering);
|
||||
QObject::connect(tetheringToggle, &MultiButtonControl::buttonClicked, this, &AdvancedNetworking::toggleTethering);
|
||||
|
||||
// Change tethering password
|
||||
ButtonControl *editPasswordButton = new ButtonControl(tr("Tethering Password"), tr("EDIT"));
|
||||
@@ -252,10 +259,10 @@ void AdvancedNetworking::refresh() {
|
||||
update();
|
||||
}
|
||||
|
||||
void AdvancedNetworking::toggleTethering(bool enabled) {
|
||||
wifi->setTetheringEnabled(enabled);
|
||||
void AdvancedNetworking::toggleTethering(int id) {
|
||||
wifi->setTetheringEnabled(id == 1 || id == 2 && uiState()->scene.started || id == 3);
|
||||
tetheringToggle->setEnabled(false);
|
||||
if (enabled) {
|
||||
if (id != 0) {
|
||||
wifiMeteredToggle->setEnabled(false);
|
||||
wifiMeteredToggle->setCheckedButton(0);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "selfdrive/ui/qt/widgets/input.h"
|
||||
#include "selfdrive/ui/qt/widgets/ssh_keys.h"
|
||||
#include "selfdrive/ui/qt/widgets/toggle.h"
|
||||
#include "selfdrive/ui/ui.h"
|
||||
|
||||
class WifiItem : public QWidget {
|
||||
Q_OBJECT
|
||||
@@ -61,7 +62,7 @@ public:
|
||||
|
||||
private:
|
||||
LabelControl* ipLabel;
|
||||
ToggleControl* tetheringToggle;
|
||||
ButtonParamControl* tetheringToggle;
|
||||
ToggleControl* roamingToggle;
|
||||
ButtonControl* editApnButton;
|
||||
ButtonControl* hiddenNetworkButton;
|
||||
@@ -75,7 +76,7 @@ signals:
|
||||
void requestWifiScreen();
|
||||
|
||||
public slots:
|
||||
void toggleTethering(bool enabled);
|
||||
void toggleTethering(int id);
|
||||
void refresh();
|
||||
};
|
||||
|
||||
|
||||
@@ -123,6 +123,9 @@ void UIState::updateStatus(FrogPilotUIState *fs) {
|
||||
emit offroadTransition(!scene.started);
|
||||
|
||||
// FrogPilot variables
|
||||
if (frogpilot_toggles.value("tethering_config").toInt() == 2) {
|
||||
fs->wifi->setTetheringEnabled(scene.started);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user