diff -r aecd5a8c958c -r 1682f3203ae5 src/eric7/MicroPython/MicroPythonWidget.py --- a/src/eric7/MicroPython/MicroPythonWidget.py Sun Jan 21 13:00:42 2024 +0100 +++ b/src/eric7/MicroPython/MicroPythonWidget.py Sun Jan 21 15:38:51 2024 +0100 @@ -62,6 +62,9 @@ """ Class implementing the MicroPython REPL widget. + @signal aboutToDisconnect() emitted to indicate the imminent disconnect from the + currently device + @signal disconnected() emitted after the device was disconnected @signal dataReceived(data) emitted to send data received via the serial connection for further processing """ @@ -76,15 +79,20 @@ DeviceWebreplUrlRole = Qt.ItemDataRole.UserRole + 7 dataReceived = pyqtSignal(bytes) + aboutToDisconnect = pyqtSignal() + disconnected = pyqtSignal() ManualMarker = "<manual>" - def __init__(self, parent=None): + def __init__(self, parent=None, forMPyWindow=False): """ Constructor - @param parent reference to the parent widget - @type QWidget + @param parent reference to the parent widget (defaults to None) + @type QWidget (optional) + @param forMPyWindow flag indicating the MicroPythonWindow variant + (defaults to False) + @type bool (optional) """ super().__init__(parent) self.setupUi(self) @@ -92,6 +100,7 @@ self.layout().setContentsMargins(0, 3, 0, 0) self.__ui = parent + self.__forMPyWindow = forMPyWindow self.__wifiController = WifiController(self, self) self.__wifiMenu = None @@ -558,8 +567,10 @@ """ self.replWidget.clearOSD() if self.__linkConnected: + self.aboutToDisconnect.emit() with EricOverrideCursor(): self.__disconnectFromDevice() + self.disconnected.emit() if self.replButton.isChecked(): self.on_replButton_clicked(False) @@ -1126,6 +1137,9 @@ ) self.__superMenu.addSeparator() self.__superMenu.addAction(self.tr("Configure"), self.__configure) + if self.__forMPyWindow: + self.__superMenu.addSeparator() + self.__superMenu.addAction(self.tr("Quit"), self.__quit) @pyqtSlot() def __showDeviceVersion(self): @@ -1715,3 +1729,14 @@ title=title, text=out.decode("utf-8"), parent=self ) dlg.exec() + + ####################################################################### + ## Methods below are specific for the MicroPython window. + ####################################################################### + + @pyqtSlot() + def __quit(self): + """ + Private slot to quit the main (MicroPython) window. + """ + self.__ui.close()