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.

104 lines
3.8 KiB

#include "ethernetsettingstab.h"
#include "ui_ethernetsettingstab.h"
EthernetSettingsTab::EthernetSettingsTab(QWidget *parent) :
QWidget(parent),
ui(new Ui::EthernetSettingsTab)
{
ui->setupUi(this);
ui->speedComboBox->addItems(QStringList() << tr("10 Mb/s") << tr("100 Mb/s") << tr("1 Gb/s") << tr("2.5 Gb/s") << tr("10 Gb/s") << tr("40 Gb/s") << tr("100 Gb/s"));
ui->linkNegotiationComboBox->addItems(QStringList() << tr("Ignore") << tr("Automatic") << tr("Manual"));
}
EthernetSettingsTab::~EthernetSettingsTab()
{
delete ui;
}
// Refer to connectionsettingsengine.cpp for configuration map details
QVariantMap EthernetSettingsTab::readSettings()
{
QVariantMap output;
output.insert("device", QVariant(ui->deviceComboBox->currentText()));
output.insert("clonedMacAddress", QVariant(ui->clonedMacAddressComboBox->currentText()));
output.insert("mtu", QVariant(ui->mtuSpinBox->value()));
output.insert("linkNegotiation", QVariant(ui->linkNegotiationComboBox->currentText()));
switch(ui->speedComboBox->currentIndex()) {
case 0:
output.insert("linkSpeed", ConnectionSettingsEngine::Speed10Mbps);
break;
case 1:
output.insert("linkSpeed", ConnectionSettingsEngine::Speed100Mbps);
break;
case 2:
output.insert("linkSpeed", ConnectionSettingsEngine::Speed1Gbps);
break;
case 3:
output.insert("linkSpeed", ConnectionSettingsEngine::Speed2_5Gbps);
break;
case 4:
output.insert("linkSpeed", ConnectionSettingsEngine::Speed5Gbps);
break;
case 5:
output.insert("linkSpeed", ConnectionSettingsEngine::Speed10Gbps);
break;
case 6:
output.insert("linkSpeed", ConnectionSettingsEngine::Speed40Gbps);
break;
case 7:
output.insert("linkSpeed", ConnectionSettingsEngine::Speed100Gbps);
break;
}
output.insert("speedMbps", QVariant(ui->speedComboBox->currentData()));
output.insert("duplexMode", QVariant(ui->duplexComboBox->currentText()));
return output;
}
void EthernetSettingsTab::loadSettings(QVariantMap settings)
{
if (settings["device"].isValid()) {
ui->deviceComboBox->setCurrentText(settings["device"].toString());
}
if (settings["clonedMacAddress"].isValid()) {
ui->clonedMacAddressComboBox->setCurrentText(settings["clonedMacAddress"].toString());
}
if (settings["mtu"].isValid()) {
ui->mtuSpinBox->setValue(settings["mtu"].toInt());
}
if (settings["linkNegotiation"].isValid()) {
ui->linkNegotiationComboBox->setCurrentText(settings["linkNegotiation"].toString());
}
if (settings["linkSpeed"].isValid()) {
switch(settings["linkSpeed"].toInt()) {
case ConnectionSettingsEngine::Speed10Mbps:
ui->speedComboBox->setCurrentIndex(0);
break;
case ConnectionSettingsEngine::Speed100Mbps:
ui->speedComboBox->setCurrentIndex(1);
break;
case ConnectionSettingsEngine::Speed1Gbps:
ui->speedComboBox->setCurrentIndex(2);
break;
case ConnectionSettingsEngine::Speed2_5Gbps:
ui->speedComboBox->setCurrentIndex(3);
break;
case ConnectionSettingsEngine::Speed5Gbps:
ui->speedComboBox->setCurrentIndex(4);
break;
case ConnectionSettingsEngine::Speed10Gbps:
ui->speedComboBox->setCurrentIndex(5);
break;
case ConnectionSettingsEngine::Speed40Gbps:
ui->speedComboBox->setCurrentIndex(6);
break;
case ConnectionSettingsEngine::Speed100Gbps:
ui->speedComboBox->setCurrentIndex(7);
break;
}
}
if (settings["duplexMode"].isValid()) {
ui->duplexComboBox->setCurrentText(settings["duplexMode"].toString());
}
}