diff --git a/libs/ui/ipv4widget.cpp b/libs/ui/ipv4widget.cpp index 9a7261e..fd6f83c 100644 --- a/libs/ui/ipv4widget.cpp +++ b/libs/ui/ipv4widget.cpp @@ -232,7 +232,8 @@ void IpV4Widget::writeConfig() { Q_D(IpV4Widget); // save method - switch ( d->ui.method->currentIndex()) { + int currentMethod = d->ui.method->currentIndex(); + switch (currentMethod) { case IpV4WidgetPrivate::AutomaticOnlyIPMethodIndex: d->setting->setMethod(Knm::Ipv4Setting::EnumMethod::Automatic); d->setting->setIgnoredhcpdns(true); @@ -278,7 +279,11 @@ void IpV4Widget::writeConfig() addresses.prepend(addr); } - d->setting->setAddresses(addresses); + if (currentMethod == IpV4WidgetPrivate::ManualMethodIndex) { + d->setting->setAddresses(addresses); + } else { + d->setting->setAddresses(QList()); + } QList dnsList; @@ -300,8 +305,15 @@ void IpV4Widget::writeConfig() dnsSearchEntries = tempStr.split(QLatin1Char(','), QString::SkipEmptyParts); } - d->setting->setDns(dnsList); - d->setting->setDnssearch(dnsSearchEntries); + if (currentMethod == IpV4WidgetPrivate::ManualMethodIndex || + currentMethod == IpV4WidgetPrivate::AutomaticOnlyIPMethodIndex || + currentMethod == IpV4WidgetPrivate::AutomaticMethodIndex) { + d->setting->setDns(dnsList); + d->setting->setDnssearch(dnsSearchEntries); + } else { + d->setting->setDns(QList()); + d->setting->setDnssearch(QStringList()); + } // dhcp client ID d->setting->setDhcpclientid(d->ui.dhcpClientId->text()); diff --git a/libs/ui/ipv6widget.cpp b/libs/ui/ipv6widget.cpp index 895196e..f45c65b 100644 --- a/libs/ui/ipv6widget.cpp +++ b/libs/ui/ipv6widget.cpp @@ -201,7 +201,8 @@ void IpV6Widget::writeConfig() { Q_D(IpV6Widget); // save method - switch ( d->ui.method->currentIndex()) { + int currentMethod = d->ui.method->currentIndex(); + switch (currentMethod) { case IpV6WidgetPrivate::AutomaticMethodIndex: d->setting->setMethod(Knm::Ipv6Setting::EnumMethod::Automatic); d->setting->setIgnoredhcpdns(false); @@ -250,7 +251,11 @@ void IpV6Widget::writeConfig() addresses.prepend(addr); } - d->setting->setAddresses(addresses); + if (currentMethod == IpV6WidgetPrivate::ManualMethodIndex) { + d->setting->setAddresses(addresses); + } else { + d->setting->setAddresses(QList()); + } QList dnsList; @@ -272,8 +277,15 @@ void IpV6Widget::writeConfig() dnsSearchEntries = tempStr.split(QLatin1Char(','), QString::SkipEmptyParts); } - d->setting->setDns(dnsList); - d->setting->setDnssearch(dnsSearchEntries); + if (currentMethod == IpV6WidgetPrivate::ManualMethodIndex || + currentMethod == IpV6WidgetPrivate::AutomaticAddressesOnlyMethodIndex || + currentMethod == IpV6WidgetPrivate::AutomaticMethodIndex) { + d->setting->setDns(dnsList); + d->setting->setDnssearch(dnsSearchEntries); + } else { + d->setting->setDns(QList()); + d->setting->setDnssearch(QStringList()); + } // routing d->setting->setNeverdefault(d->ui.routesSettings->neverdefault());