diff --git a/dcc-network/qml/PageSystemProxy.qml b/dcc-network/qml/PageSystemProxy.qml index 00e6ce26..15128c1d 100644 --- a/dcc-network/qml/PageSystemProxy.qml +++ b/dcc-network/qml/PageSystemProxy.qml @@ -249,7 +249,7 @@ DccObject { parentName: root.name + "/menu/body" displayName: qsTr("Ignore the proxy configurations for the above hosts and domains") weight: 90 - visible: ignoreHosts.visibleToApp + visible: ignoreHosts && ignoreHosts.visibleToApp pageType: DccObject.Item page: Label { text: dccObj.displayName diff --git a/dcc-network/qml/SectionDNS.qml b/dcc-network/qml/SectionDNS.qml index 0acf673f..a4775115 100644 --- a/dcc-network/qml/SectionDNS.qml +++ b/dcc-network/qml/SectionDNS.qml @@ -106,6 +106,16 @@ DccObject { console.log("[DNS-Check] All DNS entries validated successfully") return true } + function addAddressData(addr) { + config.push(addr) + configChanged() + editClicked() + } + function removeAddressData(index) { + config.splice(index, 1) + configChanged() + editClicked() + } name: "dnsTitle" displayName: qsTr("DNS") @@ -153,105 +163,81 @@ DccObject { canSearch: false pageType: DccObject.Item page: DccGroupView {} - } - Component { - id: dnsComponent - DccObject { - id: dnsItem - property int index: 0 - weight: root.weight + 30 + index - name: "dns" + index - displayName: qsTr("DNS") + (index + 1) - parentName: root.parentName + "/dnsGroup" - canSearch: false - pageType: DccObject.Editor - page: RowLayout { - D.LineEdit { - text: root.config[index] - // 移除正则验证器,改用手动验证以支持IPv6 - // 显式允许所有字符输入,包括冒号 - inputMethodHints: Qt.ImhNone - onTextChanged: { - console.log("[DNS-Input] Text changed in DNS field", index, ":", text) - if (showAlert) { - errorKey = "" + DccRepeater { + model: root.config + delegate: DccObject { + id: dnsItem + weight: root.weight + 30 + index + name: "dns" + index + displayName: qsTr("DNS") + (index + 1) + parentName: root.parentName + "/dnsGroup" + canSearch: false + pageType: DccObject.Editor + page: RowLayout { + D.LineEdit { + text: root.config[index] + // 移除正则验证器,改用手动验证以支持IPv6 + // 显式允许所有字符输入,包括冒号 + inputMethodHints: Qt.ImhNone + onTextChanged: { + console.log("[DNS-Input] Text changed in DNS field", index, ":", text) + if (showAlert) { + errorKey = "" + } + if (text !== root.config[index]) { + console.log("[DNS-Input] Updating config[" + index + "] from", root.config[index], "to", text) + root.config[index] = text + root.editClicked() + } } - if (text !== root.config[index]) { - console.log("[DNS-Input] Updating config[" + index + "] from", root.config[index], "to", text) - root.config[index] = text - root.editClicked() + showAlert: errorKey === dccObj.name + alertDuration: 2000 + alertText: qsTr("Invalid IP address") + onShowAlertChanged: { + if (showAlert) { + DccApp.showPage(dccObj) + forceActiveFocus() + } } } - showAlert: errorKey === dccObj.name - alertDuration: 2000 - alertText: qsTr("Invalid IP address") - onShowAlertChanged: { - if (showAlert) { - DccApp.showPage(dccObj) - forceActiveFocus() + D.IconLabel { + Layout.margins: 0 + Layout.maximumHeight: 16 + visible: isEdit && root.config.length < 3 + // enabled: root.config.length < 3 + icon { + name: "list_add" + width: 16 + height: 16 } - } - } - D.IconLabel { - Layout.margins: 0 - Layout.maximumHeight: 16 - visible: isEdit && root.config.length < 3 - // enabled: root.config.length < 3 - icon { - name: "list_add" - width: 16 - height: 16 - } - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.LeftButton - onClicked: { - root.config.push("") - root.configChanged() + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton + onClicked: { + root.addAddressData("") + } } } - } - D.IconLabel { - Layout.margins: 0 - Layout.maximumHeight: 16 - visible: isEdit && root.config.length > 2 - // enabled: root.config.length > 2 - icon { - name: "list_delete" - width: 16 - height: 16 - } - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.LeftButton - onClicked: { - root.config.splice(index, 1) - root.configChanged() + D.IconLabel { + Layout.margins: 0 + Layout.maximumHeight: 16 + visible: isEdit && root.config.length > 2 + // enabled: root.config.length > 2 + icon { + name: "list_delete" + width: 16 + height: 16 + } + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton + onClicked: { + root.removeAddressData(index) + } } } } } } } - function addIpItem() { - let dnsItem = dnsComponent.createObject(root, { - "index": dnsItems.length - }) - DccApp.addObject(dnsItem) - dnsItems.push(dnsItem) - } - function removeIpItem() { - let tmpItem = dnsItems.pop() - DccApp.removeObject(tmpItem) - tmpItem.destroy() - } - - onConfigChanged: { - while (root.config.length > dnsItems.length) { - addIpItem() - } - while (root.config.length < dnsItems.length) { - removeIpItem() - } - } } diff --git a/dcc-network/qml/SectionIPv4.qml b/dcc-network/qml/SectionIPv4.qml index 3811be6f..ec390032 100644 --- a/dcc-network/qml/SectionIPv4.qml +++ b/dcc-network/qml/SectionIPv4.qml @@ -131,6 +131,16 @@ DccObject { addressData = [] } } + function addAddressData(addr) { + addressData.push(addr) + addressDataChanged() + editClicked() + } + function removeAddressData(index) { + addressData.splice(index, 1) + addressDataChanged() + editClicked() + } name: "ipv4Title" displayName: qsTr("IPv4") @@ -246,11 +256,10 @@ DccObject { } } } - Component { - id: ipComponent - DccObject { + DccRepeater { + model: root.addressData + delegate: DccObject { id: ipv4Item - property int index: 0 weight: root.weight + 30 + index name: "ipv4_" + index displayName: "IP-" + index @@ -290,9 +299,7 @@ DccObject { anchors.fill: parent acceptedButtons: Qt.LeftButton onClicked: { - root.addressData.push(["0.0.0.0", "255.255.255.0", ""]) - root.addressDataChanged() - root.editClicked() + root.addAddressData(["0.0.0.0", "255.255.255.0", ""]) } } } @@ -309,9 +316,7 @@ DccObject { anchors.fill: parent acceptedButtons: Qt.LeftButton onClicked: { - root.addressData.splice(index, 1) - root.addressDataChanged() - root.editClicked() + root.removeAddressData(index) } } } @@ -424,18 +429,4 @@ DccObject { } } } - onAddressDataChanged: { - while (addressData.length > ipItems.length) { - let ipItem = ipComponent.createObject(root, { - "index": ipItems.length - }) - DccApp.addObject(ipItem) - ipItems.push(ipItem) - } - while (addressData.length < ipItems.length) { - let tmpItem = ipItems.pop() - DccApp.removeObject(tmpItem) - tmpItem.destroy() - } - } } diff --git a/dcc-network/qml/SectionIPv6.qml b/dcc-network/qml/SectionIPv6.qml index 0a97cddf..e810069d 100644 --- a/dcc-network/qml/SectionIPv6.qml +++ b/dcc-network/qml/SectionIPv6.qml @@ -90,7 +90,7 @@ DccObject { return false } // 检查网关 - if (gateway[k].length !== 0) { + if (gateway[k] && gateway[k].length !== 0) { gatewayCount++ if (gatewayCount >= 2) { errorKey = k + "gateway" @@ -98,7 +98,7 @@ DccObject { return false } } - if (gateway[k].length !== 0 && !NetUtils.ipv6RegExp.test(gateway[k])) { + if (gateway[k] && gateway[k].length !== 0 && !NetUtils.ipv6RegExp.test(gateway[k])) { errorKey = k + "gateway" errorMsg = qsTr("Invalid gateway") return false @@ -121,6 +121,16 @@ DccObject { addressData = [] } } + function addAddressData(addr) { + addressData.push(addr) + addressDataChanged() + editClicked() + } + function removeAddressData(index) { + addressData.splice(index, 1) + addressDataChanged() + editClicked() + } ListModel { id: allModel @@ -247,11 +257,10 @@ DccObject { } } } - Component { - id: ipComponent - DccObject { + DccRepeater { + model: root.addressData + delegate: DccObject { id: ipv6Item - property int index: 0 weight: root.weight + 30 + index name: "ipv6_" + index visible: root.visible @@ -292,12 +301,10 @@ DccObject { anchors.fill: parent acceptedButtons: Qt.LeftButton onClicked: { - root.addressData.push({ - "address": "", - "prefix": 64 - }) - root.addressDataChanged() - root.editClicked() + root.addAddressData({ + "address": "", + "prefix": 64 + }) } } } @@ -314,9 +321,7 @@ DccObject { anchors.fill: parent acceptedButtons: Qt.LeftButton onClicked: { - root.addressData.splice(index, 1) - root.addressDataChanged() - root.editClicked() + root.removeAddressData(index) } } } @@ -434,25 +439,4 @@ DccObject { } } } - function addIpItem() { - let ipItem = ipComponent.createObject(root, { - "index": ipItems.length - }) - DccApp.addObject(ipItem) - ipItems.push(ipItem) - } - function removeIpItem() { - let tmpItem = ipItems.pop() - DccApp.removeObject(tmpItem) - tmpItem.destroy() - } - - onAddressDataChanged: { - while (root.addressData.length > ipItems.length) { - addIpItem() - } - while (root.addressData.length < ipItems.length) { - removeIpItem() - } - } } diff --git a/src/impl/networkmanager/networkmanagerprocesser.cpp b/src/impl/networkmanager/networkmanagerprocesser.cpp index 3929c7f9..a8b1d0f6 100644 --- a/src/impl/networkmanager/networkmanagerprocesser.cpp +++ b/src/impl/networkmanager/networkmanagerprocesser.cpp @@ -381,7 +381,7 @@ void NetworkManagerProcesser::checkConnectivityFinished(quint32 conntity) void NetworkManagerProcesser::onConnectivityChanged(NetworkManager::Connectivity conntity) { - dde::network::Connectivity ctity; + dde::network::Connectivity ctity = m_connectivity; switch (conntity) { case NetworkManager::Connectivity::Full: { ctity = dde::network::Connectivity::Full;