diff --git a/dcc-network/qml/NetPasswordEdit.qml b/dcc-network/qml/NetPasswordEdit.qml index 46c2655c..9698bcd4 100644 --- a/dcc-network/qml/NetPasswordEdit.qml +++ b/dcc-network/qml/NetPasswordEdit.qml @@ -4,6 +4,8 @@ import QtQuick 2.15 import org.deepin.dtk 1.0 as D +import org.deepin.dcc 1.0 + D.PasswordEdit { property var dataItem property bool newInput: false diff --git a/dcc-network/qml/SectionPPPOE.qml b/dcc-network/qml/SectionPPPOE.qml index 91e2d23c..e6272630 100644 --- a/dcc-network/qml/SectionPPPOE.qml +++ b/dcc-network/qml/SectionPPPOE.qml @@ -92,29 +92,10 @@ DccTitleObject { displayName: qsTr("Password") weight: 30 pageType: DccObject.Editor - page: D.PasswordEdit { - property bool newInput: false - placeholderText: qsTr("Required") + page: NetPasswordEdit { + dataItem: root text: config.hasOwnProperty("password") ? config.password : "" - echoButtonVisible: newInput - onTextChanged: { - if (showAlert) { - errorKey = "" - } - if (config.password !== text) { - config.password = text - root.editClicked() - } - } - showAlert: errorKey === dccObj.name - alertDuration: 2000 - onShowAlertChanged: { - if (showAlert) { - DccApp.showPage(dccObj) - forceActiveFocus() - } - } - Component.onCompleted: newInput = !config.hasOwnProperty("password") + onTextUpdated: config.password = text } } } diff --git a/dcc-network/qml/SectionVPN.qml b/dcc-network/qml/SectionVPN.qml index 40f0f6ea..79bd2633 100644 --- a/dcc-network/qml/SectionVPN.qml +++ b/dcc-network/qml/SectionVPN.qml @@ -806,26 +806,10 @@ DccTitleObject { weight: 180 visible: ((vpnType & NetUtils.VpnTypeEnum["strongswan"]) && (dataMap["method"] === "eap" || dataMap["method"] === "psk")) || (dataMap["password-flags"] === "0" && ((vpnType & (NetUtils.VpnTypeEnum["l2tp"] | NetUtils.VpnTypeEnum["pptp"])) || (vpnType & (NetUtils.VpnTypeEnum["openvpn"])) && (dataMap["connection-type"] === "password" || dataMap["connection-type"] === "password-tls"))) pageType: DccObject.Editor - page: D.PasswordEdit { - placeholderText: qsTr("Required") + page: NetPasswordEdit { + dataItem: root text: secretMap.hasOwnProperty(dccObj.name) ? secretMap[dccObj.name] : "" - onTextChanged: { - if (showAlert) { - errorKey = "" - } - if (secretMap[dccObj.name] !== text) { - secretMap[dccObj.name] = text - root.editClicked() - } - } - showAlert: errorKey === dccObj.name - alertDuration: 2000 - onShowAlertChanged: { - if (showAlert) { - DccApp.showPage(dccObj) - forceActiveFocus() - } - } + onTextUpdated: secretMap[dccObj.name] = text } } DccObject { @@ -1086,26 +1070,10 @@ DccTitleObject { weight: 380 visible: dataMap["Xauth password-flags"] === "0" && (vpnType & (NetUtils.VpnTypeEnum["vpnc"])) pageType: DccObject.Editor - page: D.PasswordEdit { - placeholderText: qsTr("Required") + page: NetPasswordEdit { + dataItem: root text: secretMap.hasOwnProperty(dccObj.name) ? secretMap[dccObj.name] : "" - onTextChanged: { - if (showAlert) { - errorKey = "" - } - if (secretMap[dccObj.name] !== text) { - secretMap[dccObj.name] = text - root.editClicked() - } - } - showAlert: errorKey === dccObj.name - alertDuration: 2000 - onShowAlertChanged: { - if (showAlert) { - DccApp.showPage(dccObj) - forceActiveFocus() - } - } + onTextUpdated: secretMap[dccObj.name] = text } } DccObject { @@ -1153,26 +1121,10 @@ DccTitleObject { weight: 410 visible: dataMap["IPSec secret-flags"] === "0" && (vpnType & (NetUtils.VpnTypeEnum["vpnc"])) pageType: DccObject.Editor - page: D.PasswordEdit { - placeholderText: qsTr("Required") + page: NetPasswordEdit { + dataItem: root text: secretMap.hasOwnProperty(dccObj.name) ? secretMap[dccObj.name] : "" - onTextChanged: { - if (showAlert) { - errorKey = "" - } - if (secretMap[dccObj.name] !== text) { - secretMap[dccObj.name] = text - root.editClicked() - } - } - showAlert: errorKey === dccObj.name - alertDuration: 2000 - onShowAlertChanged: { - if (showAlert) { - DccApp.showPage(dccObj) - forceActiveFocus() - } - } + onTextUpdated: secretMap[dccObj.name] = text } } DccObject { @@ -2076,7 +2028,7 @@ DccTitleObject { visible: dataMap["proxy-type"] !== "none" pageType: DccObject.Editor page: D.SpinBox { - value: dataMap.hasOwnProperty(dccObj.name) ? parseInt(dataMap[dccObj.name], 10) : 1300 + value: dataMap.hasOwnProperty(dccObj.name) ? parseInt(dataMap[dccObj.name], 10) : 0 from: 0 to: 65535 onValueChanged: { @@ -2115,26 +2067,10 @@ DccTitleObject { weight: 60 visible: dataMap["proxy-type"] === "http" pageType: DccObject.Editor - page: D.PasswordEdit { - placeholderText: qsTr("Required") + page: NetPasswordEdit { text: secretMap.hasOwnProperty(dccObj.name) ? secretMap[dccObj.name] : "" - onTextChanged: { - if (showAlert) { - errorKey = "" - } - if (secretMap[dccObj.name] !== text) { - secretMap[dccObj.name] = text - root.editClicked() - } - } - showAlert: errorKey === dccObj.name - alertDuration: 2000 - onShowAlertChanged: { - if (showAlert) { - DccApp.showPage(dccObj) - forceActiveFocus() - } - } + dataItem: root + onTextUpdated: secretMap[dccObj.name] = text } } } diff --git a/dcc-network/qml/SystemProxyConfigItem.qml b/dcc-network/qml/SystemProxyConfigItem.qml index 05128557..cc9f084b 100644 --- a/dcc-network/qml/SystemProxyConfigItem.qml +++ b/dcc-network/qml/SystemProxyConfigItem.qml @@ -15,20 +15,20 @@ DccObject { id: root property var config: null property bool hasAuth: config.auth - property bool userAlert: false - property bool passwordAlert: false property bool hasUrl: false + property string errorKey: "" + signal editClicked + function checkInput() { + errorKey = "" if (hasAuth) { - userAlert = false - if (!config.user || config.user.lenght === 0) { - userAlert = true + if (!config.user || config.user.length === 0) { + errorKey = "user" return false } - passwordAlert = false - if (!config.password || config.password.lenght === 0) { - passwordAlert = true + if (!config.password || config.password.length === 0) { + errorKey = "password" return false } } @@ -106,9 +106,11 @@ DccObject { bottomInset: 4 text: config.user placeholderText: qsTr("Required") - showAlert: userAlert + showAlert: errorKey === dccObj.name onTextChanged: { - userAlert = false + if (showAlert) { + errorKey = "" + } if (config.user !== text) { config.user = text } @@ -128,24 +130,10 @@ DccObject { visible: hasAuth weight: 50 pageType: DccObject.Editor - page: D.PasswordEdit { - topInset: 4 - bottomInset: 4 + page: NetPasswordEdit { + dataItem: root text: config.password - placeholderText: qsTr("Required") - showAlert: passwordAlert - onTextChanged: { - passwordAlert = false - if (config.password !== text) { - config.password = text - } - } - onShowAlertChanged: { - if (showAlert) { - DccApp.showPage(dccObj) - forceActiveFocus() - } - } + onTextUpdated: config.password = text } } }