Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dcc-network/qml/PageSystemProxy.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
164 changes: 75 additions & 89 deletions dcc-network/qml/SectionDNS.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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()
}
}
}
39 changes: 15 additions & 24 deletions dcc-network/qml/SectionIPv4.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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", ""])
}
}
}
Expand All @@ -309,9 +316,7 @@ DccObject {
anchors.fill: parent
acceptedButtons: Qt.LeftButton
onClicked: {
root.addressData.splice(index, 1)
root.addressDataChanged()
root.editClicked()
root.removeAddressData(index)
}
}
}
Expand Down Expand Up @@ -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()
}
}
}
56 changes: 20 additions & 36 deletions dcc-network/qml/SectionIPv6.qml
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ DccObject {
return false
}
// 检查网关
if (gateway[k].length !== 0) {
if (gateway[k] && gateway[k].length !== 0) {
gatewayCount++
if (gatewayCount >= 2) {
errorKey = k + "gateway"
errorMsg = qsTr("Only one gateway is allowed")
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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
})
}
}
}
Expand All @@ -314,9 +321,7 @@ DccObject {
anchors.fill: parent
acceptedButtons: Qt.LeftButton
onClicked: {
root.addressData.splice(index, 1)
root.addressDataChanged()
root.editClicked()
root.removeAddressData(index)
}
}
}
Expand Down Expand Up @@ -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()
}
}
}
2 changes: 1 addition & 1 deletion src/impl/networkmanager/networkmanagerprocesser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading