30 @type QObject (optional) |
30 @type QObject (optional) |
31 """ |
31 """ |
32 super().__init__(parent) |
32 super().__init__(parent) |
33 |
33 |
34 self.__mpy = microPython |
34 self.__mpy = microPython |
|
35 self.__mpy.disconnected.connect(self.__disconnectedFromDevice) |
35 |
36 |
36 self.__wifiStatusDialog = None |
37 self.__wifiStatusDialog = None |
37 |
38 |
38 def createMenu(self, menu): |
39 def createMenu(self, menu): |
39 """ |
40 """ |
84 self.__mpy.getDevice().addDeviceWifiEntries(wifiMenu) |
85 self.__mpy.getDevice().addDeviceWifiEntries(wifiMenu) |
85 |
86 |
86 return wifiMenu |
87 return wifiMenu |
87 |
88 |
88 @pyqtSlot() |
89 @pyqtSlot() |
89 def __showWifiStatus(self): |
90 def __disconnectedFromDevice(self): |
90 """ |
91 """ |
91 Private slot to show a dialog with the WiFi status of the current device. |
92 Private slot handling disconnection from a device. |
92 """ |
93 """ |
93 from .WifiStatusDialog import WifiStatusDialog |
|
94 |
|
95 if self.__wifiStatusDialog is not None: |
94 if self.__wifiStatusDialog is not None: |
96 self.__wifiStatusDialog.deleteLater() |
95 self.__wifiStatusDialog.deleteLater() |
97 self.__wifiStatusDialog = None |
96 self.__wifiStatusDialog = None |
98 |
97 |
|
98 @pyqtSlot() |
|
99 def __showWifiStatus(self): |
|
100 """ |
|
101 Private slot to show a dialog with the WiFi status of the current device. |
|
102 """ |
|
103 from .WifiStatusDialog import WifiStatusDialog |
|
104 |
|
105 if self.__wifiStatusDialog is not None: |
|
106 self.__wifiStatusDialog.deleteLater() |
|
107 self.__wifiStatusDialog = None |
|
108 |
99 self.__wifiStatusDialog = WifiStatusDialog( |
109 self.__wifiStatusDialog = WifiStatusDialog( |
100 microPython=self.__mpy, parent=self.__mpy |
110 microPython=self.__mpy, parent=self.__mpy |
101 ) |
111 ) |
102 self.__wifiStatusDialog.show() |
112 self.__wifiStatusDialog.show() |
103 |
113 |
104 @pyqtSlot() |
114 @pyqtSlot() |
105 def __connectWifi(self): |
115 def __connectWifi(self): |
106 """ |
116 """ |
107 Private slot to connect the current device to a WiFi network. |
117 Private slot to connect the current device to a WiFi network. |
108 """ |
118 """ |
109 # TODO: add country to WiFi connection |
|
110 from .WifiConnectionDialog import WifiConnectionDialog |
119 from .WifiConnectionDialog import WifiConnectionDialog |
111 |
120 |
112 dlg = WifiConnectionDialog(parent=self.__mpy) |
121 dlg = WifiConnectionDialog( |
|
122 withCountry=self.__mpy.getDevice().hasWifiCountry(), |
|
123 parent=self.__mpy, |
|
124 ) |
113 if dlg.exec() == QDialog.DialogCode.Accepted: |
125 if dlg.exec() == QDialog.DialogCode.Accepted: |
114 ssid, password, hostname = dlg.getConnectionParameters() |
126 ssid, password, hostname = dlg.getConnectionParameters() |
|
127 country = dlg.getCountryCode() |
115 success, error = self.__mpy.getDevice().connectWifi( |
128 success, error = self.__mpy.getDevice().connectWifi( |
116 ssid, password, hostname |
129 ssid, password, hostname, country |
117 ) |
130 ) |
118 if success: |
131 if success: |
119 EricMessageBox.information( |
132 EricMessageBox.information( |
120 None, |
133 None, |
121 self.tr("Connect WiFi"), |
134 self.tr("Connect WiFi"), |