--- a/eric6/MicroPython/MicroPythonWidget.py Mon Feb 01 16:09:29 2021 +0100 +++ b/eric6/MicroPython/MicroPythonWidget.py Mon Feb 01 20:01:18 2021 +0100 @@ -10,6 +10,7 @@ import re import time import os +import functools from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QPoint, QEvent from PyQt5.QtGui import QColor, QKeySequence, QTextCursor, QBrush @@ -1163,6 +1164,21 @@ Private slot to populate the Super Menu before showing it. """ self.__superMenu.clear() + + # prepare the download menu + if self.__device: + menuEntries = self.__device.getDownloadMenuEntries() + if menuEntries: + downloadMenu = QMenu(self.tr("Downloads"), self.__superMenu) + for text, url in menuEntries: + downloadMenu.addAction( + text, + functools.partial(self.__downloadFromUrl, url) + ) + else: + downloadMenu = None + + # populate the super menu if self.__device: hasTime = self.__device.hasTimeCommands() else: @@ -1202,9 +1218,14 @@ if self.__device: self.__device.addDeviceMenuEntries(self.__superMenu) self.__superMenu.addSeparator() - act = self.__superMenu.addAction( - self.tr("Download Firmware"), self.__downloadFirmware) - act.setEnabled(self.__device.hasFirmwareUrl()) + if downloadMenu is None: + # generic download action + act = self.__superMenu.addAction( + self.tr("Download Firmware"), self.__downloadFirmware) + act.setEnabled(self.__device.hasFirmwareUrl()) + else: + # download sub-menu + self.__superMenu.addMenu(downloadMenu) self.__superMenu.addSeparator() act = self.__superMenu.addAction( self.tr("Show Documentation"), self.__showDocumentation) @@ -1544,6 +1565,20 @@ self.__device.downloadFirmware() + def __downloadFromUrl(self, url): + """ + Private method to open a web browser for the given URL. + + @param url URL to be opened + @type str + """ + if self.__device is None: + # abort silently + return + + if url: + e5App().getObject("UserInterface").launchHelpViewer(url) + @pyqtSlot() def __manageIgnored(self): """