eric6/MicroPython/MicroPythonWidget.py

changeset 7592
f79dc58bdf62
parent 7588
881eebfefd34
child 7595
5db6bfeff23e
--- a/eric6/MicroPython/MicroPythonWidget.py	Sat May 09 12:56:17 2020 +0200
+++ b/eric6/MicroPython/MicroPythonWidget.py	Mon May 11 18:30:25 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
@@ -327,23 +327,37 @@
         self.deviceTypeComboBox.setCurrentIndex(index)
         
         if unknownDevices:
-            E5MessageBox.information(
-                self,
-                self.tr("Unknown MicroPython Device"),
-                self.tr(
-                    '<p>Detected these unknown MicroPython 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></p>'
-                ).format("</li><li>".join(
-                    ["{0} {1}".format(vid, pid)
-                     for (vid, pid) in unknownDevices]
-                ))
-            )
+            ignoredUnknown = set([
+                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):
         """
@@ -1194,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()
@@ -1527,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