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.
110 lines
3.9 KiB
110 lines
3.9 KiB
#include "ethernetsettingstab.h"
|
|
#include "ui_ethernetsettingstab.h"
|
|
|
|
EthernetSettingsTab::EthernetSettingsTab(QWidget *parent) :
|
|
QWidget(parent),
|
|
ui(new Ui::EthernetSettingsTab)
|
|
{
|
|
ui->setupUi(this);
|
|
ui->clonedMacAddressLineEdit->setInputMask("HH:HH:HH:HH:HH:HH;_");
|
|
ui->speedComboBox->addItems(QStringList() << tr("Unknown") << 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"));
|
|
ui->duplexComboBox->addItems(QStringList() << tr("Unknown") << tr("Half") << tr("Full"));
|
|
connect(ui->linkNegotiationComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EthernetSettingsTab::onLinkNegotiationChanged);
|
|
}
|
|
|
|
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->clonedMacAddressLineEdit->text()));
|
|
output.insert("mtu", QVariant(ui->mtuSpinBox->value()));
|
|
output.insert("autoLinkNegotiation", ConnectionSettingsEngine::LinkNegotiation(ui->linkNegotiationComboBox->currentIndex()));
|
|
switch (ui->speedComboBox->currentIndex()) {
|
|
case 0:
|
|
output.insert("linkSpeed", ConnectionSettingsEngine::SpeedUnknown);
|
|
break;
|
|
case 1:
|
|
output.insert("linkSpeed", ConnectionSettingsEngine::Speed10Mbps);
|
|
break;
|
|
case 2:
|
|
output.insert("linkSpeed", ConnectionSettingsEngine::Speed100Mbps);
|
|
break;
|
|
case 3:
|
|
output.insert("linkSpeed", ConnectionSettingsEngine::Speed1Gbps);
|
|
break;
|
|
case 4:
|
|
output.insert("linkSpeed", ConnectionSettingsEngine::Speed2_5Gbps);
|
|
break;
|
|
case 5:
|
|
output.insert("linkSpeed", ConnectionSettingsEngine::Speed5Gbps);
|
|
break;
|
|
case 6:
|
|
output.insert("linkSpeed", ConnectionSettingsEngine::Speed10Gbps);
|
|
break;
|
|
case 7:
|
|
output.insert("linkSpeed", ConnectionSettingsEngine::Speed40Gbps);
|
|
break;
|
|
case 8:
|
|
output.insert("linkSpeed", ConnectionSettingsEngine::Speed100Gbps);
|
|
break;
|
|
}
|
|
switch (ui->duplexComboBox->currentIndex()) {
|
|
case 0:
|
|
output.insert("duplexMode", ConnectionSettingsEngine::DuplexUnknown);
|
|
break;
|
|
case 1:
|
|
output.insert("duplexMode", ConnectionSettingsEngine::DuplexHalf);
|
|
break;
|
|
case 2:
|
|
output.insert("duplexMode", ConnectionSettingsEngine::DuplexFull);
|
|
break;
|
|
}
|
|
|
|
return output;
|
|
}
|
|
|
|
void EthernetSettingsTab::loadSettings(QVariantMap settings)
|
|
{
|
|
if (settings["device"].isValid()) {
|
|
ui->deviceComboBox->setCurrentText(settings["device"].toString());
|
|
}
|
|
if (settings["clonedMacAddress"].isValid()) {
|
|
ui->clonedMacAddressLineEdit->setText(settings["clonedMacAddress"].toString());
|
|
}
|
|
if (settings["mtu"].isValid()) {
|
|
ui->mtuSpinBox->setValue(settings["mtu"].toInt());
|
|
}
|
|
if (settings["autoLinkNegotiation"].isValid()) {
|
|
ui->linkNegotiationComboBox->setCurrentIndex(settings["autoLinkNegotiation"].toInt());
|
|
onLinkNegotiationChanged(settings["autoLinkNegotiation"].toInt());
|
|
}
|
|
if (settings["linkSpeed"].isValid()) {
|
|
ui->speedComboBox->setCurrentIndex(settings["linkSpeed"].toInt());
|
|
}
|
|
if (settings["duplexMode"].isValid()) {
|
|
ui->duplexComboBox->setCurrentIndex(settings["duplexMode"].toInt());
|
|
}
|
|
}
|
|
|
|
void EthernetSettingsTab::onLinkNegotiationChanged(int index)
|
|
{
|
|
switch (index) {
|
|
case 0:
|
|
case 1:
|
|
ui->speedComboBox->setEnabled(false);
|
|
ui->duplexComboBox->setEnabled(false);
|
|
break;
|
|
case 2:
|
|
ui->speedComboBox->setEnabled(true);
|
|
ui->duplexComboBox->setEnabled(true);
|
|
}
|
|
}
|