eric6/MicroPython/MicroPythonWidget.py

branch
maintenance
changeset 7607
dd1054be15aa
parent 7595
5db6bfeff23e
child 7609
d5aff4fd0ef8
diff -r 707442ffadc3 -r dd1054be15aa eric6/MicroPython/MicroPythonWidget.py
--- a/eric6/MicroPython/MicroPythonWidget.py	Sat May 02 14:04:18 2020 +0200
+++ b/eric6/MicroPython/MicroPythonWidget.py	Sun May 31 17:26:14 2020 +0200
@@ -16,7 +16,7 @@
 from PyQt5.QtGui import QColor, QKeySequence, QTextCursor, QBrush
 from PyQt5.QtWidgets import (
     QWidget, QMenu, QApplication, QHBoxLayout, QSpacerItem, QSizePolicy,
-    QTextEdit, QToolButton
+    QTextEdit, QToolButton, QDialog
 )
 
 from E5Gui.E5ZoomWidget import E5ZoomWidget
@@ -295,7 +295,7 @@
         self.deviceInfoLabel.clear()
         
         self.deviceTypeComboBox.addItem("", "")
-        devices = MicroPythonDevices.getFoundDevices()
+        devices, unknownDevices = MicroPythonDevices.getFoundDevices()
         if devices:
             self.deviceInfoLabel.setText(
                 self.tr("%n supported device(s) detected.", "", len(devices)))
@@ -325,6 +325,39 @@
         
         self.on_deviceTypeComboBox_activated(index)
         self.deviceTypeComboBox.setCurrentIndex(index)
+        
+        if unknownDevices:
+            ignoredUnknown = {
+                tuple(d)
+                for d in Preferences.getMicroPython("IgnoredUnknownDevices")
+            }
+            newUnknownDevices = set(unknownDevices) - ignoredUnknown
+            if newUnknownDevices:
+                button = E5MessageBox.information(
+                    self,
+                    self.tr("Unknown MicroPython Device"),
+                    self.tr(
+                        '<p>Detected these unknown serial devices</p>'
+                        '<ul>'
+                        '<li>{0}</li>'
+                        '</ul>'
+                        '<p>Please report them together with the board name'
+                        ' and a short description to <a href="mailto:'
+                        'eric-bugs@eric-ide.python-projects.org"> the eric'
+                        ' bug reporting address</a> if it is a MicroPython'
+                        ' board.</p>'
+                    ).format("</li><li>".join([
+                        self.tr("{0} ({1:04x}/{2:04x})").format(desc, vid, pid)
+                        for vid, pid, desc in newUnknownDevices])),
+                    E5MessageBox.StandardButtons(
+                        E5MessageBox.Ignore |
+                        E5MessageBox.Ok
+                    )
+                )
+                if button == E5MessageBox.Ignore:
+                    ignoredUnknown = list(ignoredUnknown | newUnknownDevices)
+                    Preferences.setMicroPython("IgnoredUnknownDevices",
+                                               ignoredUnknown)
     
     def __handlePreferencesChanged(self):
         """
@@ -1175,6 +1208,9 @@
                 self.tr("Show Documentation"), self.__showDocumentation)
             act.setEnabled(self.__device.hasDocumentationUrl())
         self.__superMenu.addSeparator()
+        self.__superMenu.addAction(self.tr("Ignored Serial Devices"),
+                                   self.__manageIgnored)
+        self.__superMenu.addSeparator()
         self.__superMenu.addAction(self.tr("Configure"), self.__configure)
     
     @pyqtSlot()
@@ -1508,6 +1544,22 @@
         e5App().getObject("UserInterface").launchHelpViewer(url)
     
     @pyqtSlot()
+    def __manageIgnored(self):
+        """
+        Private slot to manage the list of ignored serial devices.
+        """
+        # TODO: implement this
+        from .IgnoredDevicesDialog import IgnoredDevicesDialog
+        
+        dlg = IgnoredDevicesDialog(
+            Preferences.getMicroPython("IgnoredUnknownDevices"),
+            self)
+        if dlg.exec_() == QDialog.Accepted:
+            ignoredDevices = dlg.getDevices()
+            Preferences.setMicroPython("IgnoredUnknownDevices",
+                                       ignoredDevices)
+    
+    @pyqtSlot()
     def __configure(self):
         """
         Private slot to open the MicroPython configuration page.

eric ide

mercurial