diff --git a/libs/editor/settings/ui/wiredconnectionwidget.ui b/libs/editor/settings/ui/wiredconnectionwidget.ui --- a/libs/editor/settings/ui/wiredconnectionwidget.ui +++ b/libs/editor/settings/ui/wiredconnectionwidget.ui @@ -6,8 +6,8 @@ 0 0 - 401 - 217 + 437 + 232 @@ -27,16 +27,6 @@ - - - - Cloned MAC address: - - - clonedMacAddress - - - @@ -51,6 +41,16 @@ + + + + Cloned MAC address: + + + clonedMacAddress + + + @@ -124,95 +124,123 @@ Speed: + + + + + + Duplex: + - speed + duplex - - + + + + false + 0 0 - Request that the device use only the specified speed. In MBit/s, example 100 == 100Mbit/s - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - Mbit/s + Request that the device use the specified duplex mode. Either "half" or "full" - + 1 - - 9999 - - - 100 - + + + Half + + + + + Full + + - - - - Duplex: + + + + - - duplex + + Link negotiation: - - + + 0 0 - Request that the device use the specified duplex mode. Either "half" or "full" + Device link negotiation. If “Manual” is chosen, “Speed” and “Duplex” values will be forced without checking +the device compatibility. If unsure, leave here “Ignore” or pick “Automatic”. - Full + Ignore - Half + Automatic + + + + + Manual - - + + + + false + 0 0 - Allow auto-negotiation of port speed and duplex mode - - - Allow auto-negotiation - - - true + Request that the device use only the specified speed. - - false + + 1 + + + 10 Mb/s + + + + + 100 Mb/s + + + + + 1 Gb/s + + + + + 10 Gb/s + + @@ -239,74 +267,8 @@ clonedMacAddress btnRandomMacAddr mtu - speed duplex - - - autonegotiate - toggled(bool) - speedLabel - setHidden(bool) - - - 80 - 290 - - - 81 - 117 - - - - - autonegotiate - toggled(bool) - speed - setHidden(bool) - - - 80 - 290 - - - 245 - 118 - - - - - autonegotiate - toggled(bool) - duplexLabel - setHidden(bool) - - - 80 - 290 - - - 81 - 147 - - - - - autonegotiate - toggled(bool) - duplex - setHidden(bool) - - - 80 - 290 - - - 298 - 143 - - - - + diff --git a/libs/editor/settings/wiredconnectionwidget.h b/libs/editor/settings/wiredconnectionwidget.h --- a/libs/editor/settings/wiredconnectionwidget.h +++ b/libs/editor/settings/wiredconnectionwidget.h @@ -35,6 +35,17 @@ Q_OBJECT public: + enum LinkNegotiation { + Ignore = 0, + Automatic, + Manual + }; + + enum Duplex { + Half = 0, + Full + }; + explicit WiredConnectionWidget(const NetworkManager::Setting::Ptr &setting, QWidget* parent = nullptr, Qt::WindowFlags f = {}); ~WiredConnectionWidget() override; diff --git a/libs/editor/settings/wiredconnectionwidget.cpp b/libs/editor/settings/wiredconnectionwidget.cpp --- a/libs/editor/settings/wiredconnectionwidget.cpp +++ b/libs/editor/settings/wiredconnectionwidget.cpp @@ -32,21 +32,19 @@ qsrand(QTime::currentTime().msec()); m_widget->setupUi(this); - m_widget->speedLabel->setHidden(true); - m_widget->speed->setHidden(true); - m_widget->duplexLabel->setHidden(true); - m_widget->duplex->setHidden(true); connect(m_widget->btnRandomMacAddr, &QPushButton::clicked, this, &WiredConnectionWidget::generateRandomClonedMac); // Connect for setting check watchChangedSetting(); // Connect for validity check - connect(m_widget->autonegotiate, &QCheckBox::stateChanged, this, &WiredConnectionWidget::slotWidgetChanged); connect(m_widget->clonedMacAddress, &KLineEdit::textChanged, this, &WiredConnectionWidget::slotWidgetChanged); connect(m_widget->macAddress, &HwAddrComboBox::hwAddressChanged, this, &WiredConnectionWidget::slotWidgetChanged); - connect(m_widget->speed, QOverload::of(&QSpinBox::valueChanged), this, &WiredConnectionWidget::slotWidgetChanged); + connect(m_widget->linkNegotiation, QOverload::of(&QComboBox::currentIndexChanged), this, [this] (int index) { + m_widget->duplex->setEnabled(index == LinkNegotiation::Manual); + m_widget->speed->setEnabled(index == LinkNegotiation::Manual); + }); KAcceleratorManager::manage(this); @@ -74,19 +72,33 @@ m_widget->mtu->setValue(wiredSetting->mtu()); } - if (!wiredSetting->autoNegotiate()) { - m_widget->autonegotiate->setChecked(false); + if (wiredSetting->autoNegotiate()) { + m_widget->linkNegotiation->setCurrentIndex(LinkNegotiation::Automatic); + } else if (wiredSetting->speed() && wiredSetting->duplexType() != NetworkManager::WiredSetting::UnknownDuplexType) { + m_widget->linkNegotiation->setCurrentIndex(LinkNegotiation::Manual); + } - if (wiredSetting->speed()) { - m_widget->speed->setValue(wiredSetting->speed()); + if (wiredSetting->speed()) { + switch(wiredSetting->speed()) { + case 10: + m_widget->speed->setCurrentIndex(0); + break; + case 100: + m_widget->speed->setCurrentIndex(1); + break; + case 1000: + m_widget->speed->setCurrentIndex(2); + break; + case 10000: + m_widget->speed->setCurrentIndex(3); + break; } + } - // Default to "Full" duplex when duplex type is not set - if (wiredSetting->duplexType() == NetworkManager::WiredSetting::Full || wiredSetting->duplexType() == NetworkManager::WiredSetting::UnknownDuplexType) { - m_widget->duplex->setCurrentIndex(0); - } else { - m_widget->duplex->setCurrentIndex(1); - } + if (wiredSetting->duplexType() != NetworkManager::WiredSetting::Half) { + m_widget->duplex->setCurrentIndex(Duplex::Full); + } else { + m_widget->duplex->setCurrentIndex(Duplex::Half); } } @@ -104,21 +116,35 @@ wiredSetting.setMtu(m_widget->mtu->value()); } - if (m_widget->autonegotiate->isChecked()) { - wiredSetting.setAutoNegotiate(true); + if (m_widget->linkNegotiation->currentIndex() == LinkNegotiation::Automatic || m_widget->linkNegotiation->currentIndex() == LinkNegotiation::Ignore) { wiredSetting.setDuplexType(NetworkManager::WiredSetting::UnknownDuplexType); wiredSetting.setSpeed(0); } else { - wiredSetting.setAutoNegotiate(false); - wiredSetting.setSpeed(m_widget->speed->value()); + switch (m_widget->speed->currentIndex()) { + case 0: + wiredSetting.setSpeed(10); + break; + case 1: + wiredSetting.setSpeed(100); + break; + case 2: + wiredSetting.setSpeed(1000); + break; + case 3: + wiredSetting.setSpeed(10000); + break; + } - if (m_widget->duplex->currentIndex() == 0) { + if (m_widget->duplex->currentIndex() == Duplex::Full) { wiredSetting.setDuplexType(NetworkManager::WiredSetting::Full); } else { wiredSetting.setDuplexType(NetworkManager::WiredSetting::Half); } } + wiredSetting.setAutoNegotiate(m_widget->linkNegotiation->currentIndex() == LinkNegotiation::Automatic); + + return wiredSetting.toMap(); } @@ -150,11 +176,5 @@ } } - if (!m_widget->autonegotiate->isChecked()) { - if (!m_widget->speed->value()) { - return false; - } - } - return true; }