--- a/src/eric7/MicroPython/WifiDialogs/WifiApConfigDialog.py Thu Feb 23 13:31:55 2023 +0100 +++ b/src/eric7/MicroPython/WifiDialogs/WifiApConfigDialog.py Fri Feb 24 14:11:20 2023 +0100 @@ -21,10 +21,12 @@ Class implementing a dialog to configure the Access Point interface. """ - def __init__(self, parent=None): + def __init__(self, withIP, parent=None): """ Constructor + @param withIP flag indicating to ask the user for an IP configuration + @type bool @param parent reference to the parent widget (defaults to None) @type QWidget (optional) """ @@ -45,11 +47,7 @@ self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False) - self.apSsidEdit.textChanged.connect(self.__updateOk) - self.apPasswordEdit.textChanged.connect(self.__updateOk) - self.apSecurityComboBox.currentIndexChanged.connect(self.__updateOk) - - # populate the field with data saved to the preferences + # populate the WiFi fields with data saved to the preferences self.apSsidEdit.setText(Preferences.getMicroPython("WifiApName")) self.apPasswordEdit.setText(Preferences.getMicroPython("WifiApPassword")) index = self.apSecurityComboBox.findData( @@ -59,6 +57,29 @@ index = 5 # default it to WPA/WPA2 in case of an issue self.apSecurityComboBox.setCurrentIndex(index) + self.__withIP = withIP + + self.ipv4GroupBox.setVisible(withIP) + if withIP: + # populate the IPv4 configuration with data saved to the preferences + self.addressEdit.setText(Preferences.getMicroPython("WifiApAddress")) + self.netmaskEdit.setText(Preferences.getMicroPython("WifiApNetmask")) + self.gatewayEdit.setText(Preferences.getMicroPython("WifiApGateway")) + self.dnsEdit.setText(Preferences.getMicroPython("WifiApDNS")) + + # connect the IPv4 fields + self.addressEdit.addressChanged.connect(self.__updateOk) + self.netmaskEdit.addressChanged.connect(self.__updateOk) + self.gatewayEdit.addressChanged.connect(self.__updateOk) + self.dnsEdit.addressChanged.connect(self.__updateOk) + + # connect the WiFi fields + self.apSsidEdit.textChanged.connect(self.__updateOk) + self.apPasswordEdit.textChanged.connect(self.__updateOk) + self.apSecurityComboBox.currentIndexChanged.connect(self.__updateOk) + + self.__updateOk() + msh = self.minimumSizeHint() self.resize(max(self.width(), msh.width()), msh.height()) @@ -71,6 +92,13 @@ if self.apSecurityComboBox.currentData() != 0: # security needs a password enable &= bool(self.apPasswordEdit.text()) + if self.__withIP: + enable &= ( + self.addressEdit.hasAcceptableInput() + and self.netmaskEdit.hasAcceptableInput() + and self.gatewayEdit.hasAcceptableInput() + and self.dnsEdit.hasAcceptableInput() + ) self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enable) @@ -99,9 +127,20 @@ and a flag indicating to save the parameters to the settings @rtype tuple of (str, str, int, bool) """ + if self.__withIP: + ifconfig = ( + self.addressEdit.text(), + self.netmaskEdit.text(), + self.gatewayEdit.text(), + self.dnsEdit.text(), + ) + else: + ifconfig = ("", "", "", "") + return ( self.apSsidEdit.text(), self.apPasswordEdit.text(), self.apSecurityComboBox.currentData(), self.rememberCheckBox.isChecked(), + ifconfig, )