Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device. eric7

Tue, 14 Feb 2023 10:05:29 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 14 Feb 2023 10:05:29 +0100
branch
eric7
changeset 9763
52f982c08301
parent 9762
333374cf3a18
child 9764
57496966803c

Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.

src/eric7/APIs/Python3/eric7.api file | annotate | diff | comparison | revisions
src/eric7/Documentation/Help/source.qch file | annotate | diff | comparison | revisions
src/eric7/Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
src/eric7/Documentation/Source/eric7.MicroPython.MicroPythonWidget.html file | annotate | diff | comparison | revisions
src/eric7/MicroPython/Devices/CircuitPythonDevices.py file | annotate | diff | comparison | revisions
src/eric7/MicroPython/Devices/DeviceBase.py file | annotate | diff | comparison | revisions
src/eric7/MicroPython/Devices/EspDevices.py file | annotate | diff | comparison | revisions
src/eric7/MicroPython/Devices/GenericMicroPythonDevices.py file | annotate | diff | comparison | revisions
src/eric7/MicroPython/Devices/MicrobitDevices.py file | annotate | diff | comparison | revisions
src/eric7/MicroPython/Devices/PyBoardDevices.py file | annotate | diff | comparison | revisions
src/eric7/MicroPython/Devices/RP2040Devices.py file | annotate | diff | comparison | revisions
src/eric7/MicroPython/Devices/TeensyDevices.py file | annotate | diff | comparison | revisions
src/eric7/MicroPython/MicroPythonWidget.py file | annotate | diff | comparison | revisions
src/eric7/MicroPython/MicroPythonWidget.ui file | annotate | diff | comparison | revisions
--- a/src/eric7/APIs/Python3/eric7.api	Tue Feb 14 09:43:26 2023 +0100
+++ b/src/eric7/APIs/Python3/eric7.api	Tue Feb 14 10:05:29 2023 +0100
@@ -2852,10 +2852,8 @@
 eric7.MicroPython.MicroPythonWidget.MicroPythonWidget.on_connectButton_clicked?4()
 eric7.MicroPython.MicroPythonWidget.MicroPythonWidget.on_deviceTypeComboBox_activated?4(index)
 eric7.MicroPython.MicroPythonWidget.MicroPythonWidget.on_filesButton_clicked?4(checked)
-eric7.MicroPython.MicroPythonWidget.MicroPythonWidget.on_openButton_clicked?4()
 eric7.MicroPython.MicroPythonWidget.MicroPythonWidget.on_replButton_clicked?4(checked)
 eric7.MicroPython.MicroPythonWidget.MicroPythonWidget.on_runButton_clicked?4()
-eric7.MicroPython.MicroPythonWidget.MicroPythonWidget.on_saveButton_clicked?4()
 eric7.MicroPython.MicroPythonWidget.MicroPythonWidget.setActionButtons?4(**kwargs)
 eric7.MicroPython.MicroPythonWidget.MicroPythonWidget?1(parent=None)
 eric7.MicroPython.ShowModulesDialog.ShowModulesDialog.getSelection?4()
Binary file src/eric7/Documentation/Help/source.qch has changed
--- a/src/eric7/Documentation/Help/source.qhp	Tue Feb 14 09:43:26 2023 +0100
+++ b/src/eric7/Documentation/Help/source.qhp	Tue Feb 14 10:05:29 2023 +0100
@@ -10716,10 +10716,8 @@
       <keyword name="MicroPythonWidget.on_connectButton_clicked" id="MicroPythonWidget.on_connectButton_clicked" ref="eric7.MicroPython.MicroPythonWidget.html#MicroPythonWidget.on_connectButton_clicked" />
       <keyword name="MicroPythonWidget.on_deviceTypeComboBox_activated" id="MicroPythonWidget.on_deviceTypeComboBox_activated" ref="eric7.MicroPython.MicroPythonWidget.html#MicroPythonWidget.on_deviceTypeComboBox_activated" />
       <keyword name="MicroPythonWidget.on_filesButton_clicked" id="MicroPythonWidget.on_filesButton_clicked" ref="eric7.MicroPython.MicroPythonWidget.html#MicroPythonWidget.on_filesButton_clicked" />
-      <keyword name="MicroPythonWidget.on_openButton_clicked" id="MicroPythonWidget.on_openButton_clicked" ref="eric7.MicroPython.MicroPythonWidget.html#MicroPythonWidget.on_openButton_clicked" />
       <keyword name="MicroPythonWidget.on_replButton_clicked" id="MicroPythonWidget.on_replButton_clicked" ref="eric7.MicroPython.MicroPythonWidget.html#MicroPythonWidget.on_replButton_clicked" />
       <keyword name="MicroPythonWidget.on_runButton_clicked" id="MicroPythonWidget.on_runButton_clicked" ref="eric7.MicroPython.MicroPythonWidget.html#MicroPythonWidget.on_runButton_clicked" />
-      <keyword name="MicroPythonWidget.on_saveButton_clicked" id="MicroPythonWidget.on_saveButton_clicked" ref="eric7.MicroPython.MicroPythonWidget.html#MicroPythonWidget.on_saveButton_clicked" />
       <keyword name="MicroPythonWidget.setActionButtons" id="MicroPythonWidget.setActionButtons" ref="eric7.MicroPython.MicroPythonWidget.html#MicroPythonWidget.setActionButtons" />
       <keyword name="MicrobitDevice" id="MicrobitDevice" ref="eric7.MicroPython.Devices.MicrobitDevices.html#MicrobitDevice" />
       <keyword name="MicrobitDevice (Constructor)" id="MicrobitDevice (Constructor)" ref="eric7.MicroPython.Devices.MicrobitDevices.html#MicrobitDevice.__init__" />
--- a/src/eric7/Documentation/Source/eric7.MicroPython.MicroPythonWidget.html	Tue Feb 14 09:43:26 2023 +0100
+++ b/src/eric7/Documentation/Source/eric7.MicroPython.MicroPythonWidget.html	Tue Feb 14 10:05:29 2023 +0100
@@ -268,10 +268,6 @@
 <td>Private slot to open a file manager window to the connected device.</td>
 </tr>
 <tr>
-<td><a href="#MicroPythonWidget.on_openButton_clicked">on_openButton_clicked</a></td>
-<td>Private slot to open a file of the connected device.</td>
-</tr>
-<tr>
 <td><a href="#MicroPythonWidget.on_replButton_clicked">on_replButton_clicked</a></td>
 <td>Private slot to connect to enable or disable the REPL widget.</td>
 </tr>
@@ -280,10 +276,6 @@
 <td>Private slot to execute the script of the active editor on the selected device.</td>
 </tr>
 <tr>
-<td><a href="#MicroPythonWidget.on_saveButton_clicked">on_saveButton_clicked</a></td>
-<td>Private slot to save the current editor to the connected device.</td>
-</tr>
-<tr>
 <td><a href="#MicroPythonWidget.setActionButtons">setActionButtons</a></td>
 <td>Public method to set the enabled state of the various action buttons.</td>
 </tr>
@@ -359,11 +351,19 @@
 </p>
 <a NAME="MicroPythonWidget.__connectToDevice" ID="MicroPythonWidget.__connectToDevice"></a>
 <h4>MicroPythonWidget.__connectToDevice</h4>
-<b>__connectToDevice</b>(<i></i>)
+<b>__connectToDevice</b>(<i>withAutostart=False</i>)
 
 <p>
         Private method to connect to the selected device.
 </p>
+<dl>
+
+<dt><i>withAutostart</i> (bool)</dt>
+<dd>
+flag indicating to start the repl and file manager
+            automatically
+</dd>
+</dl>
 <a NAME="MicroPythonWidget.__crossCompile" ID="MicroPythonWidget.__crossCompile"></a>
 <h4>MicroPythonWidget.__crossCompile</h4>
 <b>__crossCompile</b>(<i>pythonFile="", title=""</i>)
@@ -973,13 +973,6 @@
 state of the button
 </dd>
 </dl>
-<a NAME="MicroPythonWidget.on_openButton_clicked" ID="MicroPythonWidget.on_openButton_clicked"></a>
-<h4>MicroPythonWidget.on_openButton_clicked</h4>
-<b>on_openButton_clicked</b>(<i></i>)
-
-<p>
-        Private slot to open a file of the connected device.
-</p>
 <a NAME="MicroPythonWidget.on_replButton_clicked" ID="MicroPythonWidget.on_replButton_clicked"></a>
 <h4>MicroPythonWidget.on_replButton_clicked</h4>
 <b>on_replButton_clicked</b>(<i>checked</i>)
@@ -1009,13 +1002,6 @@
         If the REPL is not active yet, it will be activated, which might cause
         an unconnected device to be connected.
 </p>
-<a NAME="MicroPythonWidget.on_saveButton_clicked" ID="MicroPythonWidget.on_saveButton_clicked"></a>
-<h4>MicroPythonWidget.on_saveButton_clicked</h4>
-<b>on_saveButton_clicked</b>(<i></i>)
-
-<p>
-        Private slot to save the current editor to the connected device.
-</p>
 <a NAME="MicroPythonWidget.setActionButtons" ID="MicroPythonWidget.setActionButtons"></a>
 <h4>MicroPythonWidget.setActionButtons</h4>
 <b>setActionButtons</b>(<i>**kwargs</i>)
--- a/src/eric7/MicroPython/Devices/CircuitPythonDevices.py	Tue Feb 14 09:43:26 2023 +0100
+++ b/src/eric7/MicroPython/Devices/CircuitPythonDevices.py	Tue Feb 14 10:05:29 2023 +0100
@@ -62,13 +62,11 @@
         Public method to enable the supported action buttons.
         """
         super().setButtons()
+
         self.microPython.setActionButtons(
             run=True, repl=True, files=True, chart=HAS_QTCHART
         )
 
-        if self.__deviceVolumeMounted():
-            self.microPython.setActionButtons(open=True, save=True)
-
     def forceInterrupt(self):
         """
         Public method to determine the need for an interrupt when opening the
--- a/src/eric7/MicroPython/Devices/DeviceBase.py	Tue Feb 14 09:43:26 2023 +0100
+++ b/src/eric7/MicroPython/Devices/DeviceBase.py	Tue Feb 14 10:05:29 2023 +0100
@@ -102,7 +102,7 @@
         Public method to enable the supported action buttons.
         """
         self.microPython.setActionButtons(
-            open=False, save=False, run=False, repl=False, files=False, chart=False
+            run=False, repl=False, files=False, chart=False
         )
 
     def forceInterrupt(self):
--- a/src/eric7/MicroPython/Devices/EspDevices.py	Tue Feb 14 09:43:26 2023 +0100
+++ b/src/eric7/MicroPython/Devices/EspDevices.py	Tue Feb 14 10:05:29 2023 +0100
@@ -48,6 +48,7 @@
         Public method to enable the supported action buttons.
         """
         super().setButtons()
+
         self.microPython.setActionButtons(
             run=True, repl=True, files=True, chart=HAS_QTCHART
         )
--- a/src/eric7/MicroPython/Devices/GenericMicroPythonDevices.py	Tue Feb 14 09:43:26 2023 +0100
+++ b/src/eric7/MicroPython/Devices/GenericMicroPythonDevices.py	Tue Feb 14 10:05:29 2023 +0100
@@ -59,13 +59,11 @@
         Public method to enable the supported action buttons.
         """
         super().setButtons()
+
         self.microPython.setActionButtons(
             run=True, repl=True, files=True, chart=HAS_QTCHART
         )
 
-        if self.__directAccess and self.__deviceVolumeMounted():
-            self.microPython.setActionButtons(open=True, save=True)
-
     def deviceName(self):
         """
         Public method to get the name of the device.
--- a/src/eric7/MicroPython/Devices/MicrobitDevices.py	Tue Feb 14 09:43:26 2023 +0100
+++ b/src/eric7/MicroPython/Devices/MicrobitDevices.py	Tue Feb 14 10:05:29 2023 +0100
@@ -58,6 +58,7 @@
         Public method to enable the supported action buttons.
         """
         super().setButtons()
+
         self.microPython.setActionButtons(
             run=True, repl=True, files=True, chart=HAS_QTCHART
         )
--- a/src/eric7/MicroPython/Devices/PyBoardDevices.py	Tue Feb 14 09:43:26 2023 +0100
+++ b/src/eric7/MicroPython/Devices/PyBoardDevices.py	Tue Feb 14 10:05:29 2023 +0100
@@ -57,13 +57,11 @@
         Public method to enable the supported action buttons.
         """
         super().setButtons()
+
         self.microPython.setActionButtons(
             run=True, repl=True, files=True, chart=HAS_QTCHART
         )
 
-        if self.__deviceVolumeMounted():
-            self.microPython.setActionButtons(open=True, save=True)
-
     def forceInterrupt(self):
         """
         Public method to determine the need for an interrupt when opening the
--- a/src/eric7/MicroPython/Devices/RP2040Devices.py	Tue Feb 14 09:43:26 2023 +0100
+++ b/src/eric7/MicroPython/Devices/RP2040Devices.py	Tue Feb 14 10:05:29 2023 +0100
@@ -46,6 +46,7 @@
         Public method to enable the supported action buttons.
         """
         super().setButtons()
+
         self.microPython.setActionButtons(
             run=True, repl=True, files=True, chart=HAS_QTCHART
         )
--- a/src/eric7/MicroPython/Devices/TeensyDevices.py	Tue Feb 14 09:43:26 2023 +0100
+++ b/src/eric7/MicroPython/Devices/TeensyDevices.py	Tue Feb 14 10:05:29 2023 +0100
@@ -45,6 +45,7 @@
         Public method to enable the supported action buttons.
         """
         super().setButtons()
+
         self.microPython.setActionButtons(
             run=True, repl=True, files=True, chart=HAS_QTCHART
         )
--- a/src/eric7/MicroPython/MicroPythonWidget.py	Tue Feb 14 09:43:26 2023 +0100
+++ b/src/eric7/MicroPython/MicroPythonWidget.py	Tue Feb 14 10:05:29 2023 +0100
@@ -237,9 +237,6 @@
 
         self.deviceIconLabel.setPixmap(Devices.getDeviceIcon("", False))
 
-        self.openButton.setIcon(EricPixmapCache.getIcon("open"))
-        self.saveButton.setIcon(EricPixmapCache.getIcon("fileSaveAs"))
-
         self.checkButton.setIcon(EricPixmapCache.getIcon("question"))
         self.runButton.setIcon(EricPixmapCache.getIcon("start"))
         self.replButton.setIcon(EricPixmapCache.getIcon("terminal"))
@@ -535,10 +532,6 @@
             are 'run', 'repl', 'files', 'chart', 'open', 'save'
         @type dict
         """
-        if "open" in kwargs:
-            self.openButton.setEnabled(kwargs["open"] and self.__connected)
-        if "save" in kwargs:
-            self.saveButton.setEnabled(kwargs["save"] and self.__connected)
         if "run" in kwargs:
             self.runButton.setEnabled(kwargs["run"] and self.__connected)
         if "repl" in kwargs:
@@ -721,7 +714,7 @@
                 self.on_chartButton_clicked(False)
         else:
             with EricOverrideCursor():
-                self.__connectToDevice()
+                self.__connectToDevice(withAutostart=True)
 
     @pyqtSlot()
     def __clear(self):
@@ -1130,9 +1123,13 @@
         else:
             return ""
 
-    def __connectToDevice(self):
+    def __connectToDevice(self, withAutostart=False):
         """
         Private method to connect to the selected device.
+
+        @param withAutostart flag indicating to start the repl and file manager
+            automatically
+        @type bool
         """
         from .ConnectionSelectionDialog import ConnectionSelectionDialog
 
@@ -1190,6 +1187,13 @@
                 )
 
         self.__device.setButtons()
+        if withAutostart:
+            self.on_replButton_clicked(
+                self.replButton.isEnabled() and self.__linkConnected
+            )
+            self.on_filesButton_clicked(
+                self.filesButton.isEnabled() and self.__connected
+            )
 
     def __disconnectFromDevice(self):
         """
@@ -1247,41 +1251,6 @@
         if self.replButton.isChecked():
             self.__device.runScript(script)
 
-    @pyqtSlot()
-    def on_openButton_clicked(self):
-        """
-        Private slot to open a file of the connected device.
-        """
-        if not self.__device:
-            self.__showNoDeviceMessage()
-            return
-
-        workspace = self.getDeviceWorkspace()
-        if workspace:
-            fileName = EricFileDialog.getOpenFileName(
-                self,
-                self.tr("Open Python File"),
-                workspace,
-                self.tr("Python3 Files (*.py);;All Files (*)"),
-            )
-            if fileName:
-                ericApp().getObject("ViewManager").openSourceFile(fileName)
-
-    @pyqtSlot()
-    def on_saveButton_clicked(self):
-        """
-        Private slot to save the current editor to the connected device.
-        """
-        if not self.__device:
-            self.__showNoDeviceMessage()
-            return
-
-        aw = ericApp().getObject("ViewManager").activeWindow()
-        if aw:
-            workspace = self.getDeviceWorkspace()
-            if workspace:
-                aw.saveFileAs(workspace)
-
     @pyqtSlot(bool)
     def on_chartButton_clicked(self, checked):
         """
--- a/src/eric7/MicroPython/MicroPythonWidget.ui	Tue Feb 14 09:43:26 2023 +0100
+++ b/src/eric7/MicroPython/MicroPythonWidget.ui	Tue Feb 14 10:05:29 2023 +0100
@@ -77,30 +77,6 @@
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout_2">
      <item>
-      <widget class="QToolButton" name="openButton">
-       <property name="toolTip">
-        <string>Press to open a file of the connected device</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QToolButton" name="saveButton">
-       <property name="toolTip">
-        <string>Press to save the current editor to the connected device</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="Line" name="line">
-       <property name="lineWidth">
-        <number>2</number>
-       </property>
-       <property name="orientation">
-        <enum>Qt::Vertical</enum>
-       </property>
-      </widget>
-     </item>
-     <item>
       <widget class="QToolButton" name="runButton">
        <property name="toolTip">
         <string>Press to run the current script on the selected device</string>
@@ -194,8 +170,6 @@
   <tabstop>deviceTypeComboBox</tabstop>
   <tabstop>checkButton</tabstop>
   <tabstop>menuButton</tabstop>
-  <tabstop>openButton</tabstop>
-  <tabstop>saveButton</tabstop>
   <tabstop>runButton</tabstop>
   <tabstop>replButton</tabstop>
   <tabstop>filesButton</tabstop>

eric ide

mercurial