You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.7 KiB
84 lines
2.7 KiB
#include "connectionsettingsengine.h"
|
|
#include "ui_wifisettingstab.h"
|
|
#include "wifisettingstab.h"
|
|
|
|
#include <NetworkManagerQt/Utils>
|
|
|
|
WifiSettingsTab::WifiSettingsTab(QWidget *parent) :
|
|
QWidget(parent),
|
|
ui(new Ui::WifiSettingsTab)
|
|
{
|
|
ui->setupUi(this);
|
|
ui->modeComboBox->addItems(QStringList() << tr("Infrastructure") << tr("Adhoc") << tr("Access Point"));
|
|
}
|
|
|
|
WifiSettingsTab::~WifiSettingsTab()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
QVariantMap WifiSettingsTab::readSettings()
|
|
{
|
|
QVariantMap output;
|
|
output.insert("device", QVariant(ui->deviceComboBox->currentText()));
|
|
output.insert("clonedMacAddress", QVariant(ui->clonedMacAddressLineEdit->text()));
|
|
output.insert("ssid", ui->ssidComboBox->currentText());
|
|
switch (ui->modeComboBox->currentIndex()) {
|
|
case 0: // Infrastructure
|
|
output.insert("wifiMode", ConnectionSettingsEngine::WifiModeInfrastructure);
|
|
break;
|
|
case 1: // Adhoc
|
|
output.insert("wifiMode", ConnectionSettingsEngine::WifiModeAdhoc);
|
|
break;
|
|
case 2: // Access Point
|
|
output.insert("wifiMode", ConnectionSettingsEngine::WifiModeAccessPoint);
|
|
break;
|
|
}
|
|
output.insert("bssid", ui->bssidComboBox->currentText());
|
|
output.insert("clonedMacAddress", QVariant(ui->clonedMacAddressLineEdit->text()));
|
|
output.insert("mtu", QVariant(ui->mtuSpinBox->value()));
|
|
output.insert("isWifiHidden", ui->hiddenNetworkCheckbox->isChecked());
|
|
return output;
|
|
}
|
|
|
|
void WifiSettingsTab::loadSettings(QVariantMap settings)
|
|
{
|
|
if (settings["device"].isValid()) {
|
|
ui->deviceComboBox->setCurrentText(settings["device"].toString());
|
|
}
|
|
|
|
if (settings["ssid"].isValid()) {
|
|
ui->ssidComboBox->setCurrentText(settings["ssid"].toString());
|
|
}
|
|
|
|
if (settings["wifiMode"].isValid()) {
|
|
switch (settings["wifiMode"].toInt()) {
|
|
case ConnectionSettingsEngine::WifiModeInfrastructure:
|
|
ui->modeComboBox->setCurrentIndex(0);
|
|
break;
|
|
case ConnectionSettingsEngine::WifiModeAdhoc:
|
|
ui->modeComboBox->setCurrentIndex(1);
|
|
break;
|
|
case ConnectionSettingsEngine::WifiModeAccessPoint:
|
|
ui->modeComboBox->setCurrentIndex(2);
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (settings["bssid"].isValid()) {
|
|
ui->bssidComboBox->setCurrentText(settings["bssid"].toString());
|
|
}
|
|
|
|
if (settings["clonedMacAddress"].isValid()) {
|
|
ui->clonedMacAddressLineEdit->setText(settings["clonedMacAddress"].toString());
|
|
}
|
|
|
|
if (settings["mtu"].isValid()) {
|
|
ui->mtuSpinBox->setValue(settings["mtu"].toInt());
|
|
}
|
|
|
|
if (settings["isWifiHidden"].isValid()) {
|
|
ui->hiddenNetworkCheckbox->setChecked(settings["isWifiHidden"].toBool());
|
|
}
|
|
}
|