Retain tethering status between reboots

This commit is contained in:
FrogAi
2024-01-12 22:39:30 -07:00
parent 34e5afb096
commit a37d8e5830
6 changed files with 18 additions and 0 deletions

View File

@@ -130,6 +130,10 @@ AdvancedNetworking::AdvancedNetworking(QWidget* parent, WifiManager* wifi): QWid
tetheringToggle = new ToggleControl(tr("Enable Tethering"), "", "", wifi->isTetheringEnabled());
list->addItem(tetheringToggle);
QObject::connect(tetheringToggle, &ToggleControl::toggleFlipped, this, &AdvancedNetworking::toggleTethering);
if (params.getBool("TetheringEnabled")) {
tetheringToggle->setVisualOn();
uiState()->scene.tethering_enabled = true;
}
// Change tethering password
ButtonControl *editPasswordButton = new ButtonControl(tr("Tethering Password"), tr("EDIT"));
@@ -232,6 +236,8 @@ void AdvancedNetworking::refresh() {
void AdvancedNetworking::toggleTethering(bool enabled) {
wifi->setTetheringEnabled(enabled);
tetheringToggle->setEnabled(false);
params.putBool("TetheringEnabled", enabled);
uiState()->scene.tethering_enabled = enabled;
}
// WifiUI functions

View File

@@ -127,6 +127,10 @@ public:
QObject::connect(&toggle, &Toggle::stateChanged, this, &ToggleControl::toggleFlipped);
}
void setVisualOn() {
toggle.togglePosition();
}
void setEnabled(bool enabled) {
toggle.setEnabled(enabled);
toggle.update();