--- a/src/eric7/MicroPython/WifiDialogs/WifiApConfigDialog.py Fri Apr 25 16:22:02 2025 +0200 +++ b/src/eric7/MicroPython/WifiDialogs/WifiApConfigDialog.py Fri Apr 25 16:23:02 2025 +0200 @@ -21,29 +21,50 @@ Class implementing a dialog to configure the Access Point interface. """ - def __init__(self, withIP, parent=None): + def __init__(self, withIP, securityModes, parent=None): """ Constructor @param withIP flag indicating to ask the user for an IP configuration @type bool + @param securityModes list of supported security modes + @type list of str @param parent reference to the parent widget (defaults to None) @type QWidget (optional) """ super().__init__(parent) self.setupUi(self) + self.__securityMapping = { + "SEC_DPP": "DPP", + "SEC_OPEN": self.tr("Open"), + "SEC_OWE": "OWE", + "SEC_WAPI": "WAPI", + "SEC_WEP": "WEP", + "SEC_WPA": "WPA", + "SEC_WPA_WPA2": "WPA/WPA2", + "SEC_WPA2": "WPA2", + "SEC_WPA2_ENT": "WPA2 Enterprise", + "SEC_WPA2_WPA3": "WPA2/WPA3", + "SEC_WPA2_WPA3_ENT": "WPA2/WPA3 Enterprise", + "SEC_WPA3": "WPA3", + "SEC_WPA3_ENT": "WPA3 Enterprise", + "SEC_WPA3_ENT_192": "WPA3 Enterprise (192-bit)", + "SEC_WPA3_EXT_PSK": "WPA3 Extended", + "SEC_WPA3_EXT_PSK_MIXED_MODE": "WPA3 Extended, Mixed Mode", + } + self.apShowPasswordButton.setIcon(EricPixmapCache.getIcon("showPassword")) # populate the WiFi security mode combo box - self.apSecurityComboBox.addItem(self.tr("open"), 0) - self.apSecurityComboBox.addItem("WEP", 1) - self.apSecurityComboBox.addItem("WPA", 2) - self.apSecurityComboBox.addItem("WPA2", 3) - self.apSecurityComboBox.addItem("WPA/WPA2", 4) - self.apSecurityComboBox.addItem("WPA2 (CCMP)", 5) - self.apSecurityComboBox.addItem("WPA3", 6) - self.apSecurityComboBox.addItem("WPA2/WPA3", 7) + for securityMode in sorted(securityModes): + try: + self.apSecurityComboBox.addItem( + self.__securityMapping[securityMode], securityMode + ) + except KeyError: + self.apSecurityComboBox.addItem(securityMode, securityMode) + self.apSecurityComboBox.model().sort(0) self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False) @@ -54,7 +75,8 @@ Preferences.getMicroPython("WifiApAuthMode") ) if index == -1: - index = 5 # default it to WPA/WPA2 in case of an issue + index = self.apSecurityComboBox.findData("SEC_WPA_WPA2") + # default it to WPA/WPA2 in case of an issue self.apSecurityComboBox.setCurrentIndex(index) self.hostnameEdit.setText(Preferences.getMicroPython("WifiApHostname")) @@ -90,7 +112,7 @@ Private method to update the enabled state of the OK button. """ enable = bool(self.apSsidEdit.text()) - if self.apSecurityComboBox.currentData() != 0: + if self.apSecurityComboBox.currentData() != "SEC_OPEN": # security needs a password enable &= bool(self.apPasswordEdit.text()) if self.__withIP: @@ -138,6 +160,8 @@ Preferences.setMicroPython("WifiApGateway", self.gatewayEdit.text()) Preferences.setMicroPython("WifiApDNS", self.dnsEdit.text()) + Preferences.syncPreferences() + super().accept() def getApConfig(self):