|
|
|
#include "generalsettingstab.h"
|
|
|
|
#include "ui_generalsettingstab.h"
|
|
|
|
|
|
|
|
GeneralSettingsTab::GeneralSettingsTab(QWidget *parent) :
|
|
|
|
QWidget(parent),
|
|
|
|
ui(new Ui::GeneralSettingsTab)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
ui->meteredConnectionComboBox->addItems(QStringList() << tr("Automatic") << tr("Yes") << tr("No"));
|
|
|
|
}
|
|
|
|
|
|
|
|
GeneralSettingsTab::~GeneralSettingsTab()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Refer to connectionsettingsengine.cpp for configuration map details
|
|
|
|
|
|
|
|
QVariantMap GeneralSettingsTab::readSettings()
|
|
|
|
{
|
|
|
|
QVariantMap output;
|
|
|
|
output.insert("autoconnectEnabled", QVariant(ui->autoconnectCheckBox->isChecked()));
|
|
|
|
output.insert("autoconnectPriority", QVariant(ui->autoconnectPrioritySpinBox->value()));
|
|
|
|
output.insert("allUsersMayConnect", QVariant(ui->allUsersMayConnectCheckBox->isChecked()));
|
|
|
|
output.insert("vpnAutoconnectEnabled", QVariant(ui->vpnAutoconnectCheckBox->isChecked()));
|
|
|
|
output.insert("autoconnectVpn", QVariant(ui->vpnSelectComboBox->currentText()));
|
|
|
|
switch (ui->meteredConnectionComboBox->currentIndex()) {
|
|
|
|
case 0:
|
|
|
|
output.insert("meteredConnection", ConnectionSettingsEngine::MeteredAutomatic);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
output.insert("meteredConnection", ConnectionSettingsEngine::MeteredYes);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
output.insert("meteredConnection", ConnectionSettingsEngine::MeteredNo);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GeneralSettingsTab::loadSettings(QVariantMap settings)
|
|
|
|
{
|
|
|
|
if (settings["autoconnectEnabled"].isValid()) {
|
|
|
|
ui->autoconnectCheckBox->setChecked(settings["autoconnectEnabled"].toBool());
|
|
|
|
}
|
|
|
|
if (settings["autoconnectPriority"].isValid()) {
|
|
|
|
ui->autoconnectPrioritySpinBox->setValue(settings["autoconnectPriority"].toInt());
|
|
|
|
}
|
|
|
|
if (settings["allUsersMayConnect"].isValid()) {
|
|
|
|
ui->allUsersMayConnectCheckBox->setChecked(settings["allUsersMayConnect"].toBool());
|
|
|
|
}
|
|
|
|
if (settings["vpnAutoconnectEnabled"].isValid()) {
|
|
|
|
ui->vpnAutoconnectCheckBox->setChecked(settings["vpnAutoconnectEnabled"].toBool());
|
|
|
|
}
|
|
|
|
if (settings["autoconnectVpn"].isValid()) {
|
|
|
|
ui->vpnSelectComboBox->setCurrentText(settings["autoconnectVpn"].toString());
|
|
|
|
}
|
|
|
|
if (settings["meteredConnection"].isValid()) {
|
|
|
|
switch(settings["meteredConnection"].toInt()) {
|
|
|
|
case ConnectionSettingsEngine::MeteredAutomatic:
|
|
|
|
ui->meteredConnectionComboBox->setCurrentIndex(0);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::MeteredYes:
|
|
|
|
ui->meteredConnectionComboBox->setCurrentIndex(1);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::MeteredNo:
|
|
|
|
ui->meteredConnectionComboBox->setCurrentIndex(2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|