14 |
14 |
15 from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QPoint, QEvent |
15 from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QPoint, QEvent |
16 from PyQt5.QtGui import QColor, QKeySequence, QTextCursor, QBrush |
16 from PyQt5.QtGui import QColor, QKeySequence, QTextCursor, QBrush |
17 from PyQt5.QtWidgets import ( |
17 from PyQt5.QtWidgets import ( |
18 QWidget, QMenu, QApplication, QHBoxLayout, QSpacerItem, QSizePolicy, |
18 QWidget, QMenu, QApplication, QHBoxLayout, QSpacerItem, QSizePolicy, |
19 QTextEdit, QToolButton |
19 QTextEdit, QToolButton, QDialog |
20 ) |
20 ) |
21 |
21 |
22 from E5Gui.E5ZoomWidget import E5ZoomWidget |
22 from E5Gui.E5ZoomWidget import E5ZoomWidget |
23 from E5Gui import E5MessageBox, E5FileDialog |
23 from E5Gui import E5MessageBox, E5FileDialog |
24 from E5Gui.E5Application import e5App |
24 from E5Gui.E5Application import e5App |
293 |
293 |
294 self.deviceTypeComboBox.clear() |
294 self.deviceTypeComboBox.clear() |
295 self.deviceInfoLabel.clear() |
295 self.deviceInfoLabel.clear() |
296 |
296 |
297 self.deviceTypeComboBox.addItem("", "") |
297 self.deviceTypeComboBox.addItem("", "") |
298 devices = MicroPythonDevices.getFoundDevices() |
298 devices, unknownDevices = MicroPythonDevices.getFoundDevices() |
299 if devices: |
299 if devices: |
300 self.deviceInfoLabel.setText( |
300 self.deviceInfoLabel.setText( |
301 self.tr("%n supported device(s) detected.", "", len(devices))) |
301 self.tr("%n supported device(s) detected.", "", len(devices))) |
302 |
302 |
303 index = 0 |
303 index = 0 |
323 # we are still connected, so disconnect |
323 # we are still connected, so disconnect |
324 self.on_connectButton_clicked() |
324 self.on_connectButton_clicked() |
325 |
325 |
326 self.on_deviceTypeComboBox_activated(index) |
326 self.on_deviceTypeComboBox_activated(index) |
327 self.deviceTypeComboBox.setCurrentIndex(index) |
327 self.deviceTypeComboBox.setCurrentIndex(index) |
|
328 |
|
329 if unknownDevices: |
|
330 ignoredUnknown = { |
|
331 tuple(d) |
|
332 for d in Preferences.getMicroPython("IgnoredUnknownDevices") |
|
333 } |
|
334 newUnknownDevices = set(unknownDevices) - ignoredUnknown |
|
335 if newUnknownDevices: |
|
336 button = E5MessageBox.information( |
|
337 self, |
|
338 self.tr("Unknown MicroPython Device"), |
|
339 self.tr( |
|
340 '<p>Detected these unknown serial devices</p>' |
|
341 '<ul>' |
|
342 '<li>{0}</li>' |
|
343 '</ul>' |
|
344 '<p>Please report them together with the board name' |
|
345 ' and a short description to <a href="mailto:' |
|
346 'eric-bugs@eric-ide.python-projects.org"> the eric' |
|
347 ' bug reporting address</a> if it is a MicroPython' |
|
348 ' board.</p>' |
|
349 ).format("</li><li>".join([ |
|
350 self.tr("{0} ({1:04x}/{2:04x})").format(desc, vid, pid) |
|
351 for vid, pid, desc in newUnknownDevices])), |
|
352 E5MessageBox.StandardButtons( |
|
353 E5MessageBox.Ignore | |
|
354 E5MessageBox.Ok |
|
355 ) |
|
356 ) |
|
357 if button == E5MessageBox.Ignore: |
|
358 ignoredUnknown = list(ignoredUnknown | newUnknownDevices) |
|
359 Preferences.setMicroPython("IgnoredUnknownDevices", |
|
360 ignoredUnknown) |
328 |
361 |
329 def __handlePreferencesChanged(self): |
362 def __handlePreferencesChanged(self): |
330 """ |
363 """ |
331 Private slot to handle a change in preferences. |
364 Private slot to handle a change in preferences. |
332 """ |
365 """ |
1173 self.__superMenu.addSeparator() |
1206 self.__superMenu.addSeparator() |
1174 act = self.__superMenu.addAction( |
1207 act = self.__superMenu.addAction( |
1175 self.tr("Show Documentation"), self.__showDocumentation) |
1208 self.tr("Show Documentation"), self.__showDocumentation) |
1176 act.setEnabled(self.__device.hasDocumentationUrl()) |
1209 act.setEnabled(self.__device.hasDocumentationUrl()) |
1177 self.__superMenu.addSeparator() |
1210 self.__superMenu.addSeparator() |
|
1211 self.__superMenu.addAction(self.tr("Ignored Serial Devices"), |
|
1212 self.__manageIgnored) |
|
1213 self.__superMenu.addSeparator() |
1178 self.__superMenu.addAction(self.tr("Configure"), self.__configure) |
1214 self.__superMenu.addAction(self.tr("Configure"), self.__configure) |
1179 |
1215 |
1180 @pyqtSlot() |
1216 @pyqtSlot() |
1181 def __showDeviceVersion(self): |
1217 def __showDeviceVersion(self): |
1182 """ |
1218 """ |
1506 |
1542 |
1507 url = self.__device.getFirmwareUrl() |
1543 url = self.__device.getFirmwareUrl() |
1508 e5App().getObject("UserInterface").launchHelpViewer(url) |
1544 e5App().getObject("UserInterface").launchHelpViewer(url) |
1509 |
1545 |
1510 @pyqtSlot() |
1546 @pyqtSlot() |
|
1547 def __manageIgnored(self): |
|
1548 """ |
|
1549 Private slot to manage the list of ignored serial devices. |
|
1550 """ |
|
1551 # TODO: implement this |
|
1552 from .IgnoredDevicesDialog import IgnoredDevicesDialog |
|
1553 |
|
1554 dlg = IgnoredDevicesDialog( |
|
1555 Preferences.getMicroPython("IgnoredUnknownDevices"), |
|
1556 self) |
|
1557 if dlg.exec_() == QDialog.Accepted: |
|
1558 ignoredDevices = dlg.getDevices() |
|
1559 Preferences.setMicroPython("IgnoredUnknownDevices", |
|
1560 ignoredDevices) |
|
1561 |
|
1562 @pyqtSlot() |
1511 def __configure(self): |
1563 def __configure(self): |
1512 """ |
1564 """ |
1513 Private slot to open the MicroPython configuration page. |
1565 Private slot to open the MicroPython configuration page. |
1514 """ |
1566 """ |
1515 e5App().getObject("UserInterface").showPreferences("microPythonPage") |
1567 e5App().getObject("UserInterface").showPreferences("microPythonPage") |