8 """ |
8 """ |
9 |
9 |
10 from PyQt6.QtCore import QObject, pyqtSlot |
10 from PyQt6.QtCore import QObject, pyqtSlot |
11 from PyQt6.QtWidgets import QDialog, QMenu |
11 from PyQt6.QtWidgets import QDialog, QMenu |
12 |
12 |
|
13 from eric7 import Globals |
13 from eric7.EricGui.EricOverrideCursor import EricOverrideCursor |
14 from eric7.EricGui.EricOverrideCursor import EricOverrideCursor |
14 from eric7.EricWidgets import EricMessageBox |
15 from eric7.EricWidgets import EricMessageBox |
15 |
16 |
16 |
17 |
17 class WifiController(QObject): |
18 class WifiController(QObject): |
193 dlg = WifiConnectionDialog() |
194 dlg = WifiConnectionDialog() |
194 if dlg.exec() == QDialog.DialogCode.Accepted: |
195 if dlg.exec() == QDialog.DialogCode.Accepted: |
195 ssid, password = dlg.getConnectionParameters() |
196 ssid, password = dlg.getConnectionParameters() |
196 success, error = self.__mpy.getDevice().writeCredentials(ssid, password) |
197 success, error = self.__mpy.getDevice().writeCredentials(ssid, password) |
197 if success: |
198 if success: |
198 EricMessageBox.information( |
199 if self.__mpy.getDevice().hasCircuitPython(): |
199 None, |
200 # CircuitPython will reset for the REPL, so no auto-connect |
200 self.tr("Write WiFi Credentials"), |
201 # available. |
201 self.tr( |
202 if Globals.versionToTuple( |
202 "<p>The WiFi credentials were saved on the device. The device" |
203 self.__mpy.getDevice().getDeviceData("release") |
203 " will connect to the WiFi network at boot time.</p>" |
204 ) >= (8, 0, 0): |
204 ), |
205 EricMessageBox.information( |
205 ) |
206 None, |
|
207 self.tr("Write WiFi Credentials"), |
|
208 self.tr( |
|
209 "<p>The WiFi credentials were saved on the device. The" |
|
210 " device will connect to the WiFi network at boot time." |
|
211 "</p>" |
|
212 ), |
|
213 ) |
|
214 else: |
|
215 EricMessageBox.information( |
|
216 None, |
|
217 self.tr("Write WiFi Credentials"), |
|
218 self.tr( |
|
219 "<p>The WiFi credentials and a connect script were" |
|
220 " saved on the device. Use the script by simply" |
|
221 " importing it.</p>" |
|
222 ), |
|
223 ) |
|
224 else: |
|
225 EricMessageBox.information( |
|
226 None, |
|
227 self.tr("Write WiFi Credentials"), |
|
228 self.tr( |
|
229 "<p>The WiFi credentials were saved on the device. The" |
|
230 " device will connect to the WiFi network at boot time.</p>" |
|
231 ), |
|
232 ) |
206 else: |
233 else: |
207 EricMessageBox.critical( |
234 EricMessageBox.critical( |
208 None, |
235 None, |
209 self.tr("Write WiFi Credentials"), |
236 self.tr("Write WiFi Credentials"), |
210 self.tr( |
237 self.tr( |