eric6/MicroPython/MicroPythonFileManagerWidget.py

changeset 8067
a467ab075be0
parent 8058
9769eb548f0d
child 8143
2c730d5fd177
diff -r 1208cdae96b6 -r a467ab075be0 eric6/MicroPython/MicroPythonFileManagerWidget.py
--- a/eric6/MicroPython/MicroPythonFileManagerWidget.py	Thu Feb 04 14:35:50 2021 +0100
+++ b/eric6/MicroPython/MicroPythonFileManagerWidget.py	Thu Feb 04 14:38:01 2021 +0100
@@ -64,11 +64,14 @@
         self.getButton.setIcon(UI.PixmapCache.getIcon("1leftarrow"))
         self.getAsButton.setIcon(UI.PixmapCache.getIcon("getAs"))
         self.localUpButton.setIcon(UI.PixmapCache.getIcon("1uparrow"))
+        self.localHomeButton.setIcon(UI.PixmapCache.getIcon("home"))
         self.localReloadButton.setIcon(UI.PixmapCache.getIcon("reload"))
         self.deviceUpButton.setIcon(UI.PixmapCache.getIcon("1uparrow"))
+        self.deviceHomeButton.setIcon(UI.PixmapCache.getIcon("home"))
         self.deviceReloadButton.setIcon(UI.PixmapCache.getIcon("reload"))
         
         self.deviceUpButton.setEnabled(not self.__repl.isMicrobit())
+        self.deviceHomeButton.setEnabled(not self.__repl.isMicrobit())
         
         self.putButton.setEnabled(False)
         self.putAsButton.setEnabled(False)
@@ -154,16 +157,21 @@
         if aw:
             dirname = os.path.dirname(aw.getFileName())
         if not dirname:
-            dirname = (Preferences.getMultiProject("Workspace") or
-                       os.path.expanduser("~"))
+            dirname = (
+                Preferences.getMicroPython("MpyWorkspace") or
+                Preferences.getMultiProject("Workspace") or
+                os.path.expanduser("~")
+            )
         self.__listLocalFiles(dirname)
         
         if self.__deviceWithLocalAccess:
             dirname = self.__repl.getDeviceWorkspace()
             if dirname:
                 self.__listLocalFiles(dirname, True)
-        else:
-            self.__fileManager.pwd()
+                return
+        
+        # list files via device script
+        self.__fileManager.pwd()
     
     def stop(self):
         """
@@ -298,6 +306,18 @@
         self.__listLocalFiles(dirname)
     
     @pyqtSlot()
+    def on_localHomeButton_clicked(self):
+        """
+        Private slot to change directory to the configured workspace.
+        """
+        dirname = (
+            Preferences.getMicroPython("MpyWorkspace") or
+            Preferences.getMultiProject("Workspace") or
+            os.path.expanduser("~")
+        )
+        self.__listLocalFiles(dirname)
+    
+    @pyqtSlot()
     def on_localReloadButton_clicked(self):
         """
         Private slot to reload the local list.
@@ -318,14 +338,19 @@
         @param column column of the activation
         @type int
         """
-        name = os.path.join(self.deviceCwd.text(), item.text(0))
         if self.__deviceWithLocalAccess:
+            name = os.path.join(self.deviceCwd.text(), item.text(0))
             if name.endswith("/"):
                 # directory names end with a '/'
                 self.__listLocalFiles(name[:-1], True)
             elif Utilities.MimeTypes.isTextFile(name):
                 e5App().getObject("ViewManager").getEditor(name)
         else:
+            cwd = self.deviceCwd.text()
+            if cwd.endswith("/"):
+                name = cwd + item.text(0)
+            else:
+                name = "{0}/{1}".format(cwd, item.text(0))
             if name.endswith("/"):
                 # directory names end with a '/'
                 self.__fileManager.cd(name[:-1])
@@ -356,6 +381,20 @@
             self.__fileManager.cd(dirname)
     
     @pyqtSlot()
+    def on_deviceHomeButton_clicked(self):
+        """
+        Private slot to move to the device home directory.
+        """
+        if self.__deviceWithLocalAccess:
+            dirname = self.__repl.getDeviceWorkspace()
+            if dirname:
+                self.__listLocalFiles(dirname, True)
+                return
+        
+        # list files via device script
+        self.__fileManager.cd("/")
+    
+    @pyqtSlot()
     def on_deviceReloadButton_clicked(self):
         """
         Private slot to reload the device list.

eric ide

mercurial