Sat, 22 May 2021 19:58:24 +0200
Sorted the eric specific extensions into packages named like the corresponding PyQt packages (i.e. EricCore,EricGui and EricWidgets).
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
7923
91e843545d9a
Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7836
diff
changeset
|
3 | # Copyright (c) 2019 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a file manager for MicroPython devices. |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | import os |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
11 | import shutil |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | |
8318
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
13 | from PyQt6.QtCore import pyqtSlot, Qt, QPoint |
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
14 | from PyQt6.QtWidgets import ( |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
15 | QWidget, QTreeWidgetItem, QHeaderView, QMenu, QInputDialog, QLineEdit, |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
16 | QDialog |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
17 | ) |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | |
8358
144a6b854f70
Sorted the eric specific extensions into packages named like the corresponding PyQt packages (i.e. EricCore,EricGui and EricWidgets).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8356
diff
changeset
|
19 | from EricWidgets import EricMessageBox, EricPathPickerDialog |
144a6b854f70
Sorted the eric specific extensions into packages named like the corresponding PyQt packages (i.e. EricCore,EricGui and EricWidgets).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8356
diff
changeset
|
20 | from EricWidgets.EricPathPicker import EricPathPickerModes |
144a6b854f70
Sorted the eric specific extensions into packages named like the corresponding PyQt packages (i.e. EricCore,EricGui and EricWidgets).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8356
diff
changeset
|
21 | from EricWidgets.EricFileSaveConfirmDialog import confirmOverwrite |
144a6b854f70
Sorted the eric specific extensions into packages named like the corresponding PyQt packages (i.e. EricCore,EricGui and EricWidgets).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8356
diff
changeset
|
22 | from EricWidgets.EricApplication import ericApp |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | from .Ui_MicroPythonFileManagerWidget import Ui_MicroPythonFileManagerWidget |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7089
diff
changeset
|
26 | from .MicroPythonFileManager import MicroPythonFileManager |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
27 | from .MicroPythonFileSystemUtilities import ( |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
28 | mtime2string, mode2string, decoratedName, listdirStat |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | ) |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
31 | from UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
32 | |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | import UI.PixmapCache |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | import Preferences |
7080
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
35 | import Utilities |
7088
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
36 | import Globals |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | class MicroPythonFileManagerWidget(QWidget, Ui_MicroPythonFileManagerWidget): |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | """ |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | Class implementing a file manager for MicroPython devices. |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | """ |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
43 | def __init__(self, commandsInterface, deviceWithLocalAccess, parent=None): |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | """ |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | Constructor |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7089
diff
changeset
|
47 | @param commandsInterface reference to the commands interface object |
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7089
diff
changeset
|
48 | @type MicroPythonCommandsInterface |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
49 | @param deviceWithLocalAccess flag indicating the device supports file |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
50 | access via a local directory |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
51 | @type bool |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | @param parent reference to the parent widget |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | @type QWidget |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | """ |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
55 | super().__init__(parent) |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | self.setupUi(self) |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
58 | self.__repl = parent |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
59 | self.__deviceWithLocalAccess = deviceWithLocalAccess |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
60 | |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
61 | self.syncButton.setIcon(UI.PixmapCache.getIcon("2rightarrow")) |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | self.putButton.setIcon(UI.PixmapCache.getIcon("1rightarrow")) |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
63 | self.putAsButton.setIcon(UI.PixmapCache.getIcon("putAs")) |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | self.getButton.setIcon(UI.PixmapCache.getIcon("1leftarrow")) |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
65 | self.getAsButton.setIcon(UI.PixmapCache.getIcon("getAs")) |
7080
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
66 | self.localUpButton.setIcon(UI.PixmapCache.getIcon("1uparrow")) |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
67 | self.localHomeButton.setIcon(UI.PixmapCache.getIcon("home")) |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
68 | self.localReloadButton.setIcon(UI.PixmapCache.getIcon("reload")) |
7080
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
69 | self.deviceUpButton.setIcon(UI.PixmapCache.getIcon("1uparrow")) |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
70 | self.deviceHomeButton.setIcon(UI.PixmapCache.getIcon("home")) |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
71 | self.deviceReloadButton.setIcon(UI.PixmapCache.getIcon("reload")) |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
73 | self.deviceUpButton.setEnabled(not self.__repl.isMicrobit()) |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
74 | self.deviceHomeButton.setEnabled(not self.__repl.isMicrobit()) |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
75 | |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | self.putButton.setEnabled(False) |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
77 | self.putAsButton.setEnabled(False) |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | self.getButton.setEnabled(False) |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
79 | self.getAsButton.setEnabled(False) |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
81 | self.localFileTreeWidget.header().setSortIndicator( |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
82 | 0, Qt.SortOrder.AscendingOrder) |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
83 | self.deviceFileTreeWidget.header().setSortIndicator( |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
84 | 0, Qt.SortOrder.AscendingOrder) |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
85 | |
7083
217862c28319
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
86 | self.__progressInfoDialog = None |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7089
diff
changeset
|
87 | self.__fileManager = MicroPythonFileManager(commandsInterface, self) |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | self.__fileManager.longListFiles.connect(self.__handleLongListFiles) |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | self.__fileManager.currentDir.connect(self.__handleCurrentDir) |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
91 | self.__fileManager.currentDirChanged.connect(self.__handleCurrentDir) |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
92 | self.__fileManager.putFileDone.connect(self.__newDeviceList) |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
93 | self.__fileManager.getFileDone.connect(self.__handleGetDone) |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
94 | self.__fileManager.rsyncDone.connect(self.__handleRsyncDone) |
7083
217862c28319
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
95 | self.__fileManager.rsyncProgressMessage.connect( |
217862c28319
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
96 | self.__handleRsyncProgressMessage) |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
97 | self.__fileManager.removeDirectoryDone.connect(self.__newDeviceList) |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
98 | self.__fileManager.createDirectoryDone.connect(self.__newDeviceList) |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
99 | self.__fileManager.deleteFileDone.connect(self.__newDeviceList) |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
100 | self.__fileManager.fsinfoDone.connect(self.__fsInfoResultReceived) |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
102 | self.__fileManager.error.connect(self.__handleError) |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
103 | |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
104 | self.localFileTreeWidget.customContextMenuRequested.connect( |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
105 | self.__showLocalContextMenu) |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
106 | self.deviceFileTreeWidget.customContextMenuRequested.connect( |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
107 | self.__showDeviceContextMenu) |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
108 | |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
109 | self.__localMenu = QMenu(self) |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
110 | self.__localMenu.addAction(self.tr("Change Directory"), |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
111 | self.__changeLocalDirectory) |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
112 | self.__localMenu.addAction( |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
113 | self.tr("Create Directory"), self.__createLocalDirectory) |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
114 | self.__localDelDirTreeAct = self.__localMenu.addAction( |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
115 | self.tr("Delete Directory Tree"), self.__deleteLocalDirectoryTree) |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
116 | self.__localMenu.addSeparator() |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
117 | self.__localDelFileAct = self.__localMenu.addAction( |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
118 | self.tr("Delete File"), self.__deleteLocalFile) |
7137
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
119 | self.__localMenu.addSeparator() |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
120 | act = self.__localMenu.addAction(self.tr("Show Hidden Files")) |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
121 | act.setCheckable(True) |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
122 | act.setChecked(Preferences.getMicroPython("ShowHiddenLocal")) |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
123 | act.triggered[bool].connect(self.__localHiddenChanged) |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
124 | |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
125 | self.__deviceMenu = QMenu(self) |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
126 | if not self.__repl.isMicrobit(): |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
127 | self.__deviceMenu.addAction( |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
128 | self.tr("Change Directory"), self.__changeDeviceDirectory) |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
129 | self.__deviceMenu.addAction( |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
130 | self.tr("Create Directory"), self.__createDeviceDirectory) |
7131
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
131 | if not self.__deviceWithLocalAccess: |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
132 | self.__devDelDirAct = self.__deviceMenu.addAction( |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
133 | self.tr("Delete Directory"), self.__deleteDeviceDirectory) |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
134 | self.__devDelDirTreeAct = self.__deviceMenu.addAction( |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
135 | self.tr("Delete Directory Tree"), |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
136 | self.__deleteDeviceDirectoryTree) |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
137 | self.__deviceMenu.addSeparator() |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
138 | self.__devDelFileAct = self.__deviceMenu.addAction( |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
139 | self.tr("Delete File"), self.__deleteDeviceFile) |
7137
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
140 | self.__deviceMenu.addSeparator() |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
141 | act = self.__deviceMenu.addAction(self.tr("Show Hidden Files")) |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
142 | act.setCheckable(True) |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
143 | act.setChecked(Preferences.getMicroPython("ShowHiddenDevice")) |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
144 | act.triggered[bool].connect(self.__deviceHiddenChanged) |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
145 | if not parent.isMicrobit(): |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
146 | self.__deviceMenu.addSeparator() |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
147 | self.__deviceMenu.addAction( |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
148 | self.tr("Show Filesystem Info"), self.__showFileSystemInfo) |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
149 | |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
150 | def start(self): |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
151 | """ |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
152 | Public method to start the widget. |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
153 | """ |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7089
diff
changeset
|
154 | dirname = "" |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8327
diff
changeset
|
155 | vm = ericApp().getObject("ViewManager") |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
156 | aw = vm.activeWindow() |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
157 | if aw: |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
158 | dirname = os.path.dirname(aw.getFileName()) |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
159 | if not dirname: |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
160 | dirname = ( |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
161 | Preferences.getMicroPython("MpyWorkspace") or |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
162 | Preferences.getMultiProject("Workspace") or |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
163 | os.path.expanduser("~") |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
164 | ) |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | self.__listLocalFiles(dirname) |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
166 | |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
167 | if self.__deviceWithLocalAccess: |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
168 | dirname = self.__repl.getDeviceWorkspace() |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
169 | if dirname: |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
170 | self.__listLocalFiles(dirname, True) |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
171 | return |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
172 | |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
173 | # list files via device script |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
174 | self.__fileManager.pwd() |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
175 | |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
176 | def stop(self): |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
177 | """ |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
178 | Public method to stop the widget. |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
179 | """ |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7089
diff
changeset
|
180 | pass |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
181 | |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
182 | @pyqtSlot(str, str) |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
183 | def __handleError(self, method, error): |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
184 | """ |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
185 | Private slot to handle errors. |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
186 | |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
187 | @param method name of the method the error occured in |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
188 | @type str |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
189 | @param error error message |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
190 | @type str |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
191 | """ |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8327
diff
changeset
|
192 | EricMessageBox.warning( |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
193 | self, |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
194 | self.tr("Error handling device"), |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
195 | self.tr("<p>There was an error communicating with the connected" |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
196 | " device.</p><p>Method: {0}</p><p>Message: {1}</p>") |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
197 | .format(method, error)) |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
198 | |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
199 | @pyqtSlot(str) |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
200 | def __handleCurrentDir(self, dirname): |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
201 | """ |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
202 | Private slot to handle a change of the current directory of the device. |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
203 | |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
204 | @param dirname name of the current directory |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
205 | @type str |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
206 | """ |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
207 | self.deviceCwd.setText(dirname) |
7137
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
208 | self.__newDeviceList() |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
209 | |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
210 | @pyqtSlot(tuple) |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
211 | def __handleLongListFiles(self, filesList): |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
212 | """ |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
213 | Private slot to receive a long directory listing. |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
214 | |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
215 | @param filesList tuple containing tuples with name, mode, size and time |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
216 | for each directory entry |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
217 | @type tuple of (str, str, str, str) |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
218 | """ |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
219 | self.deviceFileTreeWidget.clear() |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
220 | for name, mode, size, dateTime in filesList: |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
221 | itm = QTreeWidgetItem(self.deviceFileTreeWidget, |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
222 | [name, mode, size, dateTime]) |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
223 | itm.setTextAlignment(1, Qt.AlignmentFlag.AlignHCenter) |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
224 | itm.setTextAlignment(2, Qt.AlignmentFlag.AlignRight) |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
225 | self.deviceFileTreeWidget.header().resizeSections( |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
226 | QHeaderView.ResizeMode.ResizeToContents) |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
227 | |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
228 | def __listLocalFiles(self, dirname="", localDevice=False): |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
229 | """ |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
230 | Private method to populate the local files list. |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
231 | |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
232 | @param dirname name of the local directory to be listed |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
233 | @type str |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
234 | @param localDevice flag indicating device access via local file system |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
235 | @type bool |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
236 | """ |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
237 | if not dirname: |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
238 | dirname = os.getcwd() |
7080
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
239 | if dirname.endswith(os.sep): |
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
240 | dirname = dirname[:-1] |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
241 | if localDevice: |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
242 | self.deviceCwd.setText(dirname) |
7137
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
243 | showHidden = Preferences.getMicroPython("ShowHiddenDevice") |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
244 | else: |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
245 | self.localCwd.setText(dirname) |
7137
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
246 | showHidden = Preferences.getMicroPython("ShowHiddenLocal") |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
247 | |
7137
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
248 | filesStatList = listdirStat(dirname, showHidden=showHidden) |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
249 | filesList = [( |
7080
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
250 | decoratedName(f, s[0], os.path.isdir(os.path.join(dirname, f))), |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
251 | mode2string(s[0]), |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
252 | str(s[6]), |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
253 | mtime2string(s[8])) for f, s in filesStatList] |
8259
2bbec88047dd
Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8234
diff
changeset
|
254 | fileTreeWidget = ( |
2bbec88047dd
Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8234
diff
changeset
|
255 | self.deviceFileTreeWidget |
2bbec88047dd
Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8234
diff
changeset
|
256 | if localDevice else |
2bbec88047dd
Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8234
diff
changeset
|
257 | self.localFileTreeWidget |
2bbec88047dd
Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8234
diff
changeset
|
258 | ) |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
259 | fileTreeWidget.clear() |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
260 | for item in filesList: |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
261 | itm = QTreeWidgetItem(fileTreeWidget, item) |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
262 | itm.setTextAlignment(1, Qt.AlignmentFlag.AlignHCenter) |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
263 | itm.setTextAlignment(2, Qt.AlignmentFlag.AlignRight) |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
264 | fileTreeWidget.header().resizeSections( |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
265 | QHeaderView.ResizeMode.ResizeToContents) |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
266 | |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
267 | @pyqtSlot(QTreeWidgetItem, int) |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
268 | def on_localFileTreeWidget_itemActivated(self, item, column): |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
269 | """ |
7080
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
270 | Private slot to handle the activation of a local item. |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
271 | |
7080
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
272 | If the item is a directory, the list will be re-populated for this |
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
273 | directory. |
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
274 | |
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
275 | @param item reference to the activated item |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
276 | @type QTreeWidgetItem |
7080
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
277 | @param column column of the activation |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
278 | @type int |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
279 | """ |
7080
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
280 | name = os.path.join(self.localCwd.text(), item.text(0)) |
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
281 | if name.endswith("/"): |
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
282 | # directory names end with a '/' |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
283 | self.__listLocalFiles(name[:-1]) |
7080
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
284 | elif Utilities.MimeTypes.isTextFile(name): |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8327
diff
changeset
|
285 | ericApp().getObject("ViewManager").getEditor(name) |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
286 | |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
287 | @pyqtSlot() |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
288 | def on_localFileTreeWidget_itemSelectionChanged(self): |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
289 | """ |
7080
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
290 | Private slot handling a change of selection in the local pane. |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
291 | """ |
7080
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
292 | enable = bool(len(self.localFileTreeWidget.selectedItems())) |
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
293 | if enable: |
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
294 | enable &= not ( |
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
295 | self.localFileTreeWidget.selectedItems()[0].text(0) |
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
296 | .endswith("/")) |
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
297 | self.putButton.setEnabled(enable) |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
298 | self.putAsButton.setEnabled(enable) |
7080
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
299 | |
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
300 | @pyqtSlot() |
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
301 | def on_localUpButton_clicked(self): |
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
302 | """ |
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
303 | Private slot to go up one directory level. |
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
304 | """ |
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
305 | cwd = self.localCwd.text() |
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
306 | dirname = os.path.dirname(cwd) |
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
307 | self.__listLocalFiles(dirname) |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
308 | |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
309 | @pyqtSlot() |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
310 | def on_localHomeButton_clicked(self): |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
311 | """ |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
312 | Private slot to change directory to the configured workspace. |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
313 | """ |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
314 | dirname = ( |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
315 | Preferences.getMicroPython("MpyWorkspace") or |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
316 | Preferences.getMultiProject("Workspace") or |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
317 | os.path.expanduser("~") |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
318 | ) |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
319 | self.__listLocalFiles(dirname) |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
320 | |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
321 | @pyqtSlot() |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
322 | def on_localReloadButton_clicked(self): |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
323 | """ |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
324 | Private slot to reload the local list. |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
325 | """ |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
326 | dirname = self.localCwd.text() |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
327 | self.__listLocalFiles(dirname) |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
328 | |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
329 | @pyqtSlot(QTreeWidgetItem, int) |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
330 | def on_deviceFileTreeWidget_itemActivated(self, item, column): |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
331 | """ |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
332 | Private slot to handle the activation of a device item. |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
333 | |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
334 | If the item is a directory, the current working directory is changed |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
335 | and the list will be re-populated for this directory. |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
336 | |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
337 | @param item reference to the activated item |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
338 | @type QTreeWidgetItem |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
339 | @param column column of the activation |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
340 | @type int |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
341 | """ |
7131
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
342 | if self.__deviceWithLocalAccess: |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
343 | name = os.path.join(self.deviceCwd.text(), item.text(0)) |
7131
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
344 | if name.endswith("/"): |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
345 | # directory names end with a '/' |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
346 | self.__listLocalFiles(name[:-1], True) |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
347 | elif Utilities.MimeTypes.isTextFile(name): |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8327
diff
changeset
|
348 | ericApp().getObject("ViewManager").getEditor(name) |
7131
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
349 | else: |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
350 | cwd = self.deviceCwd.text() |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
351 | if cwd.endswith("/"): |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
352 | name = cwd + item.text(0) |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
353 | else: |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
354 | name = "{0}/{1}".format(cwd, item.text(0)) |
7131
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
355 | if name.endswith("/"): |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
356 | # directory names end with a '/' |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
357 | self.__fileManager.cd(name[:-1]) |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
358 | |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
359 | @pyqtSlot() |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
360 | def on_deviceFileTreeWidget_itemSelectionChanged(self): |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
361 | """ |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
362 | Private slot handling a change of selection in the local pane. |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
363 | """ |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
364 | enable = bool(len(self.deviceFileTreeWidget.selectedItems())) |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
365 | if enable: |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
366 | enable &= not ( |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
367 | self.deviceFileTreeWidget.selectedItems()[0].text(0) |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
368 | .endswith("/")) |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
369 | self.getButton.setEnabled(enable) |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
370 | self.getAsButton.setEnabled(enable) |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
371 | |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
372 | @pyqtSlot() |
7080
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
373 | def on_deviceUpButton_clicked(self): |
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
374 | """ |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
375 | Private slot to go up one directory level on the device. |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
376 | """ |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
377 | cwd = self.deviceCwd.text() |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
378 | dirname = os.path.dirname(cwd) |
7131
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
379 | if self.__deviceWithLocalAccess: |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
380 | self.__listLocalFiles(dirname, True) |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
381 | else: |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
382 | self.__fileManager.cd(dirname) |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
383 | |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
384 | @pyqtSlot() |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
385 | def on_deviceHomeButton_clicked(self): |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
386 | """ |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
387 | Private slot to move to the device home directory. |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
388 | """ |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
389 | if self.__deviceWithLocalAccess: |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
390 | dirname = self.__repl.getDeviceWorkspace() |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
391 | if dirname: |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
392 | self.__listLocalFiles(dirname, True) |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
393 | return |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
394 | |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
395 | # list files via device script |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
396 | self.__fileManager.cd("/") |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
397 | |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8058
diff
changeset
|
398 | @pyqtSlot() |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
399 | def on_deviceReloadButton_clicked(self): |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
400 | """ |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
401 | Private slot to reload the device list. |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
402 | """ |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
403 | dirname = self.deviceCwd.text() |
7131
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
404 | if self.__deviceWithLocalAccess: |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
405 | self.__listLocalFiles(dirname, True) |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
406 | else: |
7131
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
407 | if dirname: |
7137
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
408 | self.__newDeviceList() |
7131
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
409 | else: |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
410 | self.__fileManager.pwd() |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
411 | |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
412 | def __isFileInList(self, filename, treeWidget): |
7080
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
413 | """ |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
414 | Private method to check, if a file name is contained in a tree widget. |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
415 | |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
416 | @param filename name of the file to check |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
417 | @type str |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
418 | @param treeWidget reference to the tree widget to be checked against |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
419 | @return flag indicating that the file name is present |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
420 | @rtype bool |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
421 | """ |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
422 | itemCount = treeWidget.topLevelItemCount() |
8221
0572a215bd2f
Applied some more code simplifications suggested by the new Simplify checker (Y110, Y111: use any() or all()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
423 | return ( |
0572a215bd2f
Applied some more code simplifications suggested by the new Simplify checker (Y110, Y111: use any() or all()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
424 | itemCount > 0 and |
0572a215bd2f
Applied some more code simplifications suggested by the new Simplify checker (Y110, Y111: use any() or all()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
425 | any(treeWidget.topLevelItem(row).text(0) == filename |
0572a215bd2f
Applied some more code simplifications suggested by the new Simplify checker (Y110, Y111: use any() or all()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
426 | for row in range(itemCount)) |
0572a215bd2f
Applied some more code simplifications suggested by the new Simplify checker (Y110, Y111: use any() or all()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
427 | ) |
7080
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
428 | |
9a3adf033f90
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7078
diff
changeset
|
429 | @pyqtSlot() |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
430 | def on_putButton_clicked(self, putAs=False): |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
431 | """ |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
432 | Private slot to copy the selected file to the connected device. |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
433 | |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
434 | @param putAs flag indicating to give it a new name |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
435 | @type bool |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
436 | """ |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
437 | selectedItems = self.localFileTreeWidget.selectedItems() |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
438 | if selectedItems: |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
439 | filename = selectedItems[0].text(0).strip() |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
440 | if not filename.endswith("/"): |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
441 | # it is really a file |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
442 | if putAs: |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
443 | deviceFilename, ok = QInputDialog.getText( |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
444 | self, |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
445 | self.tr("Put File As"), |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
446 | self.tr("Enter a new name for the file"), |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
447 | QLineEdit.EchoMode.Normal, |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
448 | filename) |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
449 | if not ok or not filename: |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
450 | return |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
451 | else: |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
452 | deviceFilename = filename |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
453 | |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
454 | if self.__isFileInList(deviceFilename, |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
455 | self.deviceFileTreeWidget): |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
456 | # ask for overwrite permission |
7083
217862c28319
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
457 | action, resultFilename = confirmOverwrite( |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
458 | deviceFilename, self.tr("Copy File to Device"), |
7083
217862c28319
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
459 | self.tr("The given file exists already" |
217862c28319
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
460 | " (Enter file name only)."), |
217862c28319
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
461 | False, self) |
217862c28319
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
462 | if action == "cancel": |
217862c28319
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
463 | return |
217862c28319
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
464 | elif action == "rename": |
217862c28319
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
465 | deviceFilename = os.path.basename(resultFilename) |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
466 | |
7131
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
467 | if self.__deviceWithLocalAccess: |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
468 | shutil.copy2( |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
469 | os.path.join(self.localCwd.text(), filename), |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
470 | os.path.join(self.deviceCwd.text(), deviceFilename) |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
471 | ) |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
472 | self.__listLocalFiles(self.deviceCwd.text(), |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
473 | localDevice=True) |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
474 | else: |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
475 | deviceCwd = self.deviceCwd.text() |
7137
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
476 | if deviceCwd: |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
477 | if deviceCwd != "/": |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
478 | deviceFilename = deviceCwd + "/" + deviceFilename |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
479 | else: |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
480 | deviceFilename = "/" + deviceFilename |
7131
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
481 | self.__fileManager.put( |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
482 | os.path.join(self.localCwd.text(), filename), |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
483 | deviceFilename |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
484 | ) |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
485 | |
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
486 | @pyqtSlot() |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
487 | def on_putAsButton_clicked(self): |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
488 | """ |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
489 | Private slot to copy the selected file to the connected device |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
490 | with a different name. |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
491 | """ |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
492 | self.on_putButton_clicked(putAs=True) |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
493 | |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
494 | @pyqtSlot() |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
495 | def on_getButton_clicked(self, getAs=False): |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
496 | """ |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
497 | Private slot to copy the selected file from the connected device. |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
498 | |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
499 | @param getAs flag indicating to give it a new name |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
500 | @type bool |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
501 | """ |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
502 | selectedItems = self.deviceFileTreeWidget.selectedItems() |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
503 | if selectedItems: |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
504 | filename = selectedItems[0].text(0).strip() |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
505 | if not filename.endswith("/"): |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
506 | # it is really a file |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
507 | if getAs: |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
508 | localFilename, ok = QInputDialog.getText( |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
509 | self, |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
510 | self.tr("Get File As"), |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
511 | self.tr("Enter a new name for the file"), |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
512 | QLineEdit.EchoMode.Normal, |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
513 | filename) |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
514 | if not ok or not filename: |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
515 | return |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
516 | else: |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
517 | localFilename = filename |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
518 | |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
519 | if self.__isFileInList(localFilename, |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
520 | self.localFileTreeWidget): |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
521 | # ask for overwrite permission |
7083
217862c28319
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
522 | action, resultFilename = confirmOverwrite( |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
523 | localFilename, self.tr("Copy File from Device"), |
7083
217862c28319
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
524 | self.tr("The given file exists already."), |
217862c28319
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
525 | True, self) |
217862c28319
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
526 | if action == "cancel": |
217862c28319
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
527 | return |
217862c28319
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
528 | elif action == "rename": |
217862c28319
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
529 | localFilename = resultFilename |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
530 | |
7131
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
531 | if self.__deviceWithLocalAccess: |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
532 | shutil.copy2( |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
533 | os.path.join(self.deviceCwd.text(), filename), |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
534 | os.path.join(self.localCwd.text(), localFilename) |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
535 | ) |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
536 | self.__listLocalFiles(self.localCwd.text()) |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
537 | else: |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
538 | deviceCwd = self.deviceCwd.text() |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
539 | if deviceCwd: |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
540 | filename = deviceCwd + "/" + filename |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
541 | self.__fileManager.get( |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
542 | filename, |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
543 | os.path.join(self.localCwd.text(), localFilename) |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
544 | ) |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
545 | |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
546 | @pyqtSlot() |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
547 | def on_getAsButton_clicked(self): |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
548 | """ |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
549 | Private slot to copy the selected file from the connected device |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
550 | with a different name. |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
551 | """ |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
552 | self.on_getButton_clicked(getAs=True) |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
553 | |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
554 | @pyqtSlot(str, str) |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
555 | def __handleGetDone(self, deviceFile, localFile): |
7078
bca506f8c756
MicroPython: started to implement the file manager widget; added the forgotten MicroPythonFileManagerWidget.[py, ui] files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
556 | """ |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
557 | Private slot handling a successful copy of a file from the device. |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
558 | |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
559 | @param deviceFile name of the file on the device |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
560 | @type str |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
561 | @param localFile name of the local file |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
562 | @type str |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
563 | """ |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
564 | self.__listLocalFiles(self.localCwd.text()) |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
565 | |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
566 | @pyqtSlot() |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
567 | def on_syncButton_clicked(self): |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
568 | """ |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
569 | Private slot to synchronize the local directory to the device. |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
570 | """ |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
571 | self.__fileManager.rsync( |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
572 | self.localCwd.text(), |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
573 | self.deviceCwd.text(), |
7131
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
574 | mirror=True, |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
575 | localDevice=self.__deviceWithLocalAccess, |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
576 | ) |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
577 | |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
578 | @pyqtSlot(str, str) |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
579 | def __handleRsyncDone(self, localDir, deviceDir): |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
580 | """ |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
581 | Private method to handle the completion of the rsync operation. |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
582 | |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
583 | @param localDir name of the local directory |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
584 | @type str |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
585 | @param deviceDir name of the device directory |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
586 | @type str |
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
587 | """ |
8058
9769eb548f0d
MicroPython: implemented some fixes for issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
588 | # simulate button presses to reload the two lists |
9769eb548f0d
MicroPython: implemented some fixes for issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
589 | self.on_localReloadButton_clicked() |
9769eb548f0d
MicroPython: implemented some fixes for issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
590 | self.on_deviceReloadButton_clicked() |
7081
ed510767c096
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7080
diff
changeset
|
591 | |
7083
217862c28319
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
592 | @pyqtSlot(str) |
217862c28319
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
593 | def __handleRsyncProgressMessage(self, message): |
217862c28319
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
594 | """ |
217862c28319
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
595 | Private slot handling progress messages sent by the file manager. |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
596 | |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
597 | @param message message to be shown |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
598 | @type str |
7083
217862c28319
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
599 | """ |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
600 | if self.__progressInfoDialog is None: |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
601 | from .MicroPythonProgressInfoDialog import ( |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
602 | MicroPythonProgressInfoDialog |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
603 | ) |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
604 | self.__progressInfoDialog = MicroPythonProgressInfoDialog(self) |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
605 | self.__progressInfoDialog.finished.connect( |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
606 | self.__progressInfoDialogFinished) |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
607 | self.__progressInfoDialog.show() |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
608 | self.__progressInfoDialog.addMessage(message) |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
609 | |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
610 | @pyqtSlot() |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
611 | def __progressInfoDialogFinished(self): |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
612 | """ |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
613 | Private slot handling the closing of the progress info dialog. |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
614 | """ |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
615 | self.__progressInfoDialog.deleteLater() |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
616 | self.__progressInfoDialog = None |
7083
217862c28319
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
617 | |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
618 | @pyqtSlot() |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
619 | def __newDeviceList(self): |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
620 | """ |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
621 | Private slot to initiate a new long list of the device directory. |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
622 | """ |
7137
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
623 | self.__fileManager.lls( |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
624 | self.deviceCwd.text(), |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
625 | showHidden=Preferences.getMicroPython("ShowHiddenDevice") |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
626 | ) |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
627 | |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
628 | ################################################################## |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
629 | ## Context menu methods for the local files below |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
630 | ################################################################## |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
631 | |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
632 | @pyqtSlot(QPoint) |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
633 | def __showLocalContextMenu(self, pos): |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
634 | """ |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
635 | Private slot to show the REPL context menu. |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
636 | |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
637 | @param pos position to show the menu at |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
638 | @type QPoint |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
639 | """ |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
640 | hasSelection = bool(len(self.localFileTreeWidget.selectedItems())) |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
641 | if hasSelection: |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
642 | name = self.localFileTreeWidget.selectedItems()[0].text(0) |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
643 | isDir = name.endswith("/") |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
644 | isFile = not isDir |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
645 | else: |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
646 | isDir = False |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
647 | isFile = False |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
648 | self.__localDelDirTreeAct.setEnabled(isDir) |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
649 | self.__localDelFileAct.setEnabled(isFile) |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
650 | |
7759
51aa6c6b66f7
Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
651 | self.__localMenu.exec(self.localFileTreeWidget.mapToGlobal(pos)) |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
652 | |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
653 | @pyqtSlot() |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
654 | def __changeLocalDirectory(self, localDevice=False): |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
655 | """ |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
656 | Private slot to change the local directory. |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
657 | |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
658 | @param localDevice flag indicating device access via local file system |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
659 | @type bool |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
660 | """ |
8234
fcb6b4b96274
Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8221
diff
changeset
|
661 | cwdWidget = self.deviceCwd if localDevice else self.localCwd |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
662 | |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8327
diff
changeset
|
663 | dirPath, ok = EricPathPickerDialog.getPath( |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
664 | self, |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
665 | self.tr("Change Directory"), |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
666 | self.tr("Select Directory"), |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8327
diff
changeset
|
667 | EricPathPickerModes.DIRECTORY_SHOW_FILES_MODE, |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
668 | path=cwdWidget.text(), |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
669 | defaultDirectory=cwdWidget.text(), |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
670 | ) |
7083
217862c28319
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
671 | if ok and dirPath: |
217862c28319
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
672 | if not os.path.isabs(dirPath): |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
673 | dirPath = os.path.join(cwdWidget.text(), dirPath) |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
674 | cwdWidget.setText(dirPath) |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
675 | self.__listLocalFiles(dirPath, localDevice=localDevice) |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
676 | |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
677 | @pyqtSlot() |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
678 | def __createLocalDirectory(self, localDevice=False): |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
679 | """ |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
680 | Private slot to create a local directory. |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
681 | |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
682 | @param localDevice flag indicating device access via local file system |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
683 | @type bool |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
684 | """ |
8234
fcb6b4b96274
Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8221
diff
changeset
|
685 | cwdWidget = self.deviceCwd if localDevice else self.localCwd |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
686 | |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
687 | dirPath, ok = QInputDialog.getText( |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
688 | self, |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
689 | self.tr("Create Directory"), |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
690 | self.tr("Enter directory name:"), |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
691 | QLineEdit.EchoMode.Normal) |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
692 | if ok and dirPath: |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
693 | dirPath = os.path.join(cwdWidget.text(), dirPath) |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
694 | try: |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
695 | os.mkdir(dirPath) |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
696 | self.__listLocalFiles(cwdWidget.text(), |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
697 | localDevice=localDevice) |
7836
2f0d208b8137
Changed code to not use the OSError aliases (IOError, EnvironmentError, socket.error and select.error) anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7780
diff
changeset
|
698 | except OSError as exc: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8327
diff
changeset
|
699 | EricMessageBox.critical( |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
700 | self, |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
701 | self.tr("Create Directory"), |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
702 | self.tr("""<p>The directory <b>{0}</b> could not be""" |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
703 | """ created.</p><p>Reason: {1}</p>""").format( |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
704 | dirPath, str(exc)) |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
705 | ) |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
706 | |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
707 | @pyqtSlot() |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
708 | def __deleteLocalDirectoryTree(self, localDevice=False): |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
709 | """ |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
710 | Private slot to delete a local directory tree. |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
711 | |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
712 | @param localDevice flag indicating device access via local file system |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
713 | @type bool |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
714 | """ |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
715 | if localDevice: |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
716 | cwdWidget = self.deviceCwd |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
717 | fileTreeWidget = self.deviceFileTreeWidget |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
718 | else: |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
719 | cwdWidget = self.localCwd |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
720 | fileTreeWidget = self.localFileTreeWidget |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
721 | |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
722 | if bool(len(fileTreeWidget.selectedItems())): |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
723 | name = fileTreeWidget.selectedItems()[0].text(0) |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
724 | dirname = os.path.join(cwdWidget.text(), name[:-1]) |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
725 | dlg = DeleteFilesConfirmationDialog( |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
726 | self, |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
727 | self.tr("Delete Directory Tree"), |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
728 | self.tr( |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
729 | "Do you really want to delete this directory tree?"), |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
730 | [dirname]) |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
731 | if dlg.exec() == QDialog.DialogCode.Accepted: |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
732 | try: |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
733 | shutil.rmtree(dirname) |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
734 | self.__listLocalFiles(cwdWidget.text(), |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
735 | localDevice=localDevice) |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
736 | except Exception as exc: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8327
diff
changeset
|
737 | EricMessageBox.critical( |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
738 | self, |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
739 | self.tr("Delete Directory Tree"), |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
740 | self.tr("""<p>The directory <b>{0}</b> could not be""" |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
741 | """ deleted.</p><p>Reason: {1}</p>""").format( |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
742 | dirname, str(exc)) |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
743 | ) |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
744 | |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
745 | @pyqtSlot() |
7131
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
746 | def __deleteLocalFile(self, localDevice=False): |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
747 | """ |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
748 | Private slot to delete a local file. |
7131
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
749 | |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
750 | @param localDevice flag indicating device access via local file system |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
751 | @type bool |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
752 | """ |
7131
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
753 | if localDevice: |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
754 | cwdWidget = self.deviceCwd |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
755 | fileTreeWidget = self.deviceFileTreeWidget |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
756 | else: |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
757 | cwdWidget = self.localCwd |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
758 | fileTreeWidget = self.localFileTreeWidget |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
759 | |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
760 | if bool(len(fileTreeWidget.selectedItems())): |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
761 | name = fileTreeWidget.selectedItems()[0].text(0) |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
762 | filename = os.path.join(cwdWidget.text(), name) |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
763 | dlg = DeleteFilesConfirmationDialog( |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
764 | self, |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
765 | self.tr("Delete File"), |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
766 | self.tr( |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
767 | "Do you really want to delete this file?"), |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
768 | [filename]) |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
769 | if dlg.exec() == QDialog.DialogCode.Accepted: |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
770 | try: |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
771 | os.remove(filename) |
7131
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
772 | self.__listLocalFiles(cwdWidget.text(), |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
773 | localDevice=localDevice) |
7836
2f0d208b8137
Changed code to not use the OSError aliases (IOError, EnvironmentError, socket.error and select.error) anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7780
diff
changeset
|
774 | except OSError as exc: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8327
diff
changeset
|
775 | EricMessageBox.critical( |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
776 | self, |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
777 | self.tr("Delete File"), |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
778 | self.tr("""<p>The file <b>{0}</b> could not be""" |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
779 | """ deleted.</p><p>Reason: {1}</p>""").format( |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
780 | filename, str(exc)) |
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
781 | ) |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
782 | |
7137
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
783 | @pyqtSlot(bool) |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
784 | def __localHiddenChanged(self, checked): |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
785 | """ |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
786 | Private slot handling a change of the local show hidden menu entry. |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
787 | |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
788 | @param checked new check state of the action |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
789 | @type bool |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
790 | """ |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
791 | Preferences.setMicroPython("ShowHiddenLocal", checked) |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
792 | self.on_localReloadButton_clicked() |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
793 | |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
794 | ################################################################## |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
795 | ## Context menu methods for the device files below |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
796 | ################################################################## |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
797 | |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
798 | @pyqtSlot(QPoint) |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
799 | def __showDeviceContextMenu(self, pos): |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
800 | """ |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
801 | Private slot to show the REPL context menu. |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
802 | |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
803 | @param pos position to show the menu at |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
804 | @type QPoint |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
805 | """ |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
806 | hasSelection = bool(len(self.deviceFileTreeWidget.selectedItems())) |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
807 | if hasSelection: |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
808 | name = self.deviceFileTreeWidget.selectedItems()[0].text(0) |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
809 | isDir = name.endswith("/") |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
810 | isFile = not isDir |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
811 | else: |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
812 | isDir = False |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
813 | isFile = False |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
814 | if not self.__repl.isMicrobit(): |
7131
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
815 | if not self.__deviceWithLocalAccess: |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
816 | self.__devDelDirAct.setEnabled(isDir) |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
817 | self.__devDelDirTreeAct.setEnabled(isDir) |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
818 | self.__devDelFileAct.setEnabled(isFile) |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
819 | |
7759
51aa6c6b66f7
Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
820 | self.__deviceMenu.exec(self.deviceFileTreeWidget.mapToGlobal(pos)) |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
821 | |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
822 | @pyqtSlot() |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
823 | def __changeDeviceDirectory(self): |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
824 | """ |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
825 | Private slot to change the current directory of the device. |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
826 | |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
827 | Note: This triggers a re-population of the device list for the new |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
828 | current directory. |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
829 | """ |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
830 | if self.__deviceWithLocalAccess: |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
831 | self.__changeLocalDirectory(True) |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
832 | else: |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
833 | dirPath, ok = QInputDialog.getText( |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
834 | self, |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
835 | self.tr("Change Directory"), |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
836 | self.tr("Enter the directory path on the device:"), |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
837 | QLineEdit.EchoMode.Normal, |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
838 | self.deviceCwd.text()) |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
839 | if ok and dirPath: |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
840 | if not dirPath.startswith("/"): |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
841 | dirPath = self.deviceCwd.text() + "/" + dirPath |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
842 | self.__fileManager.cd(dirPath) |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
843 | |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
844 | @pyqtSlot() |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
845 | def __createDeviceDirectory(self): |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
846 | """ |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
847 | Private slot to create a directory on the device. |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
848 | """ |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
849 | if self.__deviceWithLocalAccess: |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
850 | self.__createLocalDirectory(True) |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
851 | else: |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
852 | dirPath, ok = QInputDialog.getText( |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
853 | self, |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
854 | self.tr("Create Directory"), |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
855 | self.tr("Enter directory name:"), |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
856 | QLineEdit.EchoMode.Normal) |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
857 | if ok and dirPath: |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
858 | self.__fileManager.mkdir(dirPath) |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
859 | |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
860 | @pyqtSlot() |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
861 | def __deleteDeviceDirectory(self): |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
862 | """ |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
863 | Private slot to delete an empty directory on the device. |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
864 | """ |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
865 | if self.__deviceWithLocalAccess: |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
866 | self.__deleteLocalDirectoryTree(True) |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
867 | else: |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
868 | if bool(len(self.deviceFileTreeWidget.selectedItems())): |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
869 | name = self.deviceFileTreeWidget.selectedItems()[0].text(0) |
7131
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
870 | cwd = self.deviceCwd.text() |
7137
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
871 | if cwd: |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
872 | if cwd != "/": |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
873 | dirname = cwd + "/" + name[:-1] |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
874 | else: |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
875 | dirname = "/" + name[:-1] |
7131
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
876 | else: |
7137
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
877 | dirname = name[:-1] |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
878 | dlg = DeleteFilesConfirmationDialog( |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
879 | self, |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
880 | self.tr("Delete Directory"), |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
881 | self.tr( |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
882 | "Do you really want to delete this directory?"), |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
883 | [dirname]) |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
884 | if dlg.exec() == QDialog.DialogCode.Accepted: |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
885 | self.__fileManager.rmdir(dirname) |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
886 | |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
887 | @pyqtSlot() |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
888 | def __deleteDeviceDirectoryTree(self): |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
889 | """ |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
890 | Private slot to delete a directory and all its subdirectories |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
891 | recursively. |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
892 | """ |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
893 | if self.__deviceWithLocalAccess: |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
894 | self.__deleteLocalDirectoryTree(True) |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
895 | else: |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
896 | if bool(len(self.deviceFileTreeWidget.selectedItems())): |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
897 | name = self.deviceFileTreeWidget.selectedItems()[0].text(0) |
7131
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
898 | cwd = self.deviceCwd.text() |
7137
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
899 | if cwd: |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
900 | if cwd != "/": |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
901 | dirname = cwd + "/" + name[:-1] |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
902 | else: |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
903 | dirname = "/" + name[:-1] |
7131
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
904 | else: |
7137
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
905 | dirname = name[:-1] |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
906 | dlg = DeleteFilesConfirmationDialog( |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
907 | self, |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
908 | self.tr("Delete Directory Tree"), |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
909 | self.tr( |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
910 | "Do you really want to delete this directory tree?"), |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
911 | [dirname]) |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
912 | if dlg.exec() == QDialog.DialogCode.Accepted: |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
913 | self.__fileManager.rmdir(dirname, recursive=True) |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
914 | |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
915 | @pyqtSlot() |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
916 | def __deleteDeviceFile(self): |
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
917 | """ |
7084
3eddfc540614
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7083
diff
changeset
|
918 | Private slot to delete a file. |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
919 | """ |
7131
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
920 | if self.__deviceWithLocalAccess: |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
921 | self.__deleteLocalFile(True) |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
922 | else: |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
923 | if bool(len(self.deviceFileTreeWidget.selectedItems())): |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
924 | name = self.deviceFileTreeWidget.selectedItems()[0].text(0) |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
925 | dirname = self.deviceCwd.text() |
7137
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
926 | if dirname: |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
927 | if dirname != "/": |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
928 | filename = dirname + "/" + name |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
929 | else: |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
930 | filename = "/" + name |
7131
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
931 | else: |
7137
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
932 | filename = name |
7131
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
933 | dlg = DeleteFilesConfirmationDialog( |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
934 | self, |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
935 | self.tr("Delete File"), |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
936 | self.tr( |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
937 | "Do you really want to delete this file?"), |
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
938 | [filename]) |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
939 | if dlg.exec() == QDialog.DialogCode.Accepted: |
7131
f75e990caf99
MicroPythonFileManager: finished the file access via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
940 | self.__fileManager.delete(filename) |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
941 | |
7137
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
942 | @pyqtSlot(bool) |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
943 | def __deviceHiddenChanged(self, checked): |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
944 | """ |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
945 | Private slot handling a change of the device show hidden menu entry. |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
946 | |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
947 | @param checked new check state of the action |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
948 | @type bool |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
949 | """ |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
950 | Preferences.setMicroPython("ShowHiddenDevice", checked) |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
951 | self.on_deviceReloadButton_clicked() |
4ed2573947ff
MicroPythonFileManagerWidget: added option to show hidden files to the local and device files list context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
952 | |
7082
ec199ef0cfc6
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7081
diff
changeset
|
953 | @pyqtSlot() |
7088
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
954 | def __showFileSystemInfo(self): |
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
955 | """ |
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
956 | Private slot to show some file system information. |
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
957 | """ |
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
958 | self.__fileManager.fileSystemInfo() |
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
959 | |
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
960 | @pyqtSlot(tuple) |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
961 | def __fsInfoResultReceived(self, fsinfo): |
7088
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
962 | """ |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
963 | Private slot to show the file system information of the device. |
7088
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
964 | |
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
965 | @param fsinfo tuple of tuples containing the file system name, the |
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
966 | total size, the used size and the free size |
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
967 | @type tuple of tuples of (str, int, int, int) |
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
968 | """ |
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
969 | msg = self.tr("<h3>Filesystem Information</h3>") |
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
970 | for name, totalSize, usedSize, freeSize in fsinfo: |
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
971 | msg += self.tr( |
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
972 | "<h4>{0}</h4" |
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
973 | "<table>" |
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
974 | "<tr><td>Total Size: </td><td align='right'>{1}</td></tr>" |
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
975 | "<tr><td>Used Size: </td><td align='right'>{2}</td></tr>" |
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
976 | "<tr><td>Free Size: </td><td align='right'>{3}</td></tr>" |
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
977 | "</table>" |
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
978 | ).format(name, |
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
979 | Globals.dataString(totalSize), |
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
980 | Globals.dataString(usedSize), |
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
981 | Globals.dataString(freeSize), |
7089
9f9816b19aa4
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7088
diff
changeset
|
982 | ) |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8327
diff
changeset
|
983 | EricMessageBox.information( |
7088
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
984 | self, |
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
985 | self.tr("Filesystem Information"), |
e29b0ee86b29
MicroPython: continued implementing the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
986 | msg) |