move to advanced settings

pull/21750/head
ShaneSmiskol 4 years ago
parent 8552085603
commit a34a919a2a
  1. 15
      selfdrive/ui/qt/offroad/networking.cc
  2. 6
      selfdrive/ui/qt/offroad/settings.cc
  3. 17
      selfdrive/ui/qt/offroad/wifiManager.cc
  4. 3
      selfdrive/ui/qt/offroad/wifiManager.h

@ -67,13 +67,6 @@ Networking::Networking(QWidget* parent, bool show_advanced) : QFrame(parent) {
} }
)"); )");
main_layout->setCurrentWidget(wifiScreen); main_layout->setCurrentWidget(wifiScreen);
// roaming timer
QTimer* timer = new QTimer(this);
QObject::connect(timer, &QTimer::timeout, this, [=]() {
wifi->setRoaming(params.getBool("GsmRoaming"));
});
timer->start(10000);
} }
void Networking::refresh() { void Networking::refresh() {
@ -158,6 +151,14 @@ AdvancedNetworking::AdvancedNetworking(QWidget* parent, WifiManager* wifi): QWid
main_layout->addWidget(new SshToggle()); main_layout->addWidget(new SshToggle());
main_layout->addWidget(horizontal_line(), 0); main_layout->addWidget(horizontal_line(), 0);
main_layout->addWidget(new SshControl()); main_layout->addWidget(new SshControl());
main_layout->addWidget(horizontal_line(), 0);
// Roaming toggle
ToggleControl *roamingToggle = new ToggleControl("Enable Roaming", "", "", wifi->isRoamingEnabled());
QObject::connect(roamingToggle, &SshToggle::toggleFlipped, [=](bool state) {
wifi->setRoamingEnabled(state);
});
main_layout->addWidget(roamingToggle);
main_layout->addStretch(1); main_layout->addStretch(1);
} }

@ -81,12 +81,6 @@ TogglesPanel::TogglesPanel(QWidget *parent) : QWidget(parent) {
this)); this));
#endif #endif
toggles.append(new ParamControl("GsmRoaming",
"Enable Roaming",
"Allows mobile network roaming",
"../assets/offroad/icon_map.png",
this));
bool record_lock = Params().getBool("RecordFrontLock"); bool record_lock = Params().getBool("RecordFrontLock");
record_toggle->setEnabled(!record_lock); record_toggle->setEnabled(!record_lock);

@ -422,21 +422,32 @@ NetworkType WifiManager::currentNetworkType() {
return NetworkType::NONE; return NetworkType::NONE;
} }
void WifiManager::setRoaming(bool roaming) { void WifiManager::setRoamingEnabled(bool roaming) {
const QDBusObjectPath &path = getConnectionPath("lte"); const QDBusObjectPath &path = getConnectionPath("lte");
if (!path.path().isEmpty()) { if (!path.path().isEmpty()) {
QDBusInterface nm(NM_DBUS_SERVICE, path.path(), NM_DBUS_INTERFACE_SETTINGS_CONNECTION, bus); QDBusInterface nm(NM_DBUS_SERVICE, path.path(), NM_DBUS_INTERFACE_SETTINGS_CONNECTION, bus);
nm.setTimeout(DBUS_TIMEOUT); nm.setTimeout(DBUS_TIMEOUT);
Connection settings = QDBusReply<Connection>(nm.call("GetSettings")).value(); Connection settings = QDBusReply<Connection>(nm.call("GetSettings")).value();
bool prevRoaming = !settings.value("gsm").value("home-only").toBool(); if (settings.value("gsm").value("home-only").toBool() == roaming) {
if (!settings.value("gsm").contains("home-only") || prevRoaming != roaming) { // set if unset or param is changed
settings["gsm"]["home-only"] = !roaming; settings["gsm"]["home-only"] = !roaming;
nm.call("Update", QVariant::fromValue(settings)); nm.call("Update", QVariant::fromValue(settings));
} }
} }
} }
bool WifiManager::isRoamingEnabled() {
const QDBusObjectPath &path = getConnectionPath("lte");
if (!path.path().isEmpty()) {
QDBusInterface nm(NM_DBUS_SERVICE, path.path(), NM_DBUS_INTERFACE_SETTINGS_CONNECTION, bus);
nm.setTimeout(DBUS_TIMEOUT);
const Connection &settings = QDBusReply<Connection>(nm.call("GetSettings")).value();
return !settings.value("gsm").value("home-only").toBool();
}
return false;
}
// Functions for tethering // Functions for tethering
void WifiManager::addTetheringConnection() { void WifiManager::addTetheringConnection() {
Connection connection; Connection connection;

@ -49,7 +49,8 @@ public:
bool isKnownConnection(const QString &ssid); bool isKnownConnection(const QString &ssid);
void activateWifiConnection(const QString &ssid); void activateWifiConnection(const QString &ssid);
NetworkType currentNetworkType(); NetworkType currentNetworkType();
void setRoaming(bool roaming); void setRoamingEnabled(bool roaming);
bool isRoamingEnabled();
void connect(const Network &ssid); void connect(const Network &ssid);
void connect(const Network &ssid, const QString &password); void connect(const Network &ssid, const QString &password);

Loading…
Cancel
Save