mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-15 15:35:53 +08:00
Fix recent files on Windows
Contributes to Asana issue 33694049548880
This commit is contained in:
parent
d937eb7a17
commit
8a63b8d110
@ -85,7 +85,7 @@ class CuraApplication(QtApplication):
|
|||||||
if not os.path.isfile(f):
|
if not os.path.isfile(f):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self._recent_files.append(f)
|
self._recent_files.append(QUrl.fromLocalFile(f))
|
||||||
|
|
||||||
## Handle loading of all plugin types (and the backend explicitly)
|
## Handle loading of all plugin types (and the backend explicitly)
|
||||||
# \sa PluginRegistery
|
# \sa PluginRegistery
|
||||||
@ -330,7 +330,7 @@ class CuraApplication(QtApplication):
|
|||||||
return log
|
return log
|
||||||
|
|
||||||
recentFilesChanged = pyqtSignal()
|
recentFilesChanged = pyqtSignal()
|
||||||
@pyqtProperty("QStringList", notify = recentFilesChanged)
|
@pyqtProperty("QVariantList", notify = recentFilesChanged)
|
||||||
def recentFiles(self):
|
def recentFiles(self):
|
||||||
return self._recent_files
|
return self._recent_files
|
||||||
|
|
||||||
@ -508,7 +508,7 @@ class CuraApplication(QtApplication):
|
|||||||
if type(job) is not ReadMeshJob:
|
if type(job) is not ReadMeshJob:
|
||||||
return
|
return
|
||||||
|
|
||||||
f = job.getFileName()
|
f = QUrl.fromLocalFile(job.getFileName())
|
||||||
if f in self._recent_files:
|
if f in self._recent_files:
|
||||||
self._recent_files.remove(f)
|
self._recent_files.remove(f)
|
||||||
|
|
||||||
@ -516,5 +516,9 @@ class CuraApplication(QtApplication):
|
|||||||
if len(self._recent_files) > 10:
|
if len(self._recent_files) > 10:
|
||||||
del self._recent_files[10]
|
del self._recent_files[10]
|
||||||
|
|
||||||
Preferences.getInstance().setValue("cura/recent_files", ";".join(self._recent_files))
|
pref = ""
|
||||||
|
for path in self._recent_files:
|
||||||
|
pref += path.toLocalFile() + ";"
|
||||||
|
|
||||||
|
Preferences.getInstance().setValue("cura/recent_files", pref)
|
||||||
self.recentFilesChanged.emit()
|
self.recentFilesChanged.emit()
|
||||||
|
@ -37,9 +37,11 @@ UM.MainWindow {
|
|||||||
Instantiator {
|
Instantiator {
|
||||||
model: Printer.recentFiles
|
model: Printer.recentFiles
|
||||||
MenuItem {
|
MenuItem {
|
||||||
property url filePath: modelData;
|
text: {
|
||||||
text: (index + 1) + ". " + modelData.slice(modelData.lastIndexOf("/") + 1);
|
var path = modelData.toString()
|
||||||
onTriggered: UM.MeshFileHandler.readLocalFile(filePath);
|
return (index + 1) + ". " + path.slice(path.lastIndexOf("/") + 1);
|
||||||
|
}
|
||||||
|
onTriggered: UM.MeshFileHandler.readLocalFile(modelData);
|
||||||
}
|
}
|
||||||
onObjectAdded: fileMenu.insertItem(index, object)
|
onObjectAdded: fileMenu.insertItem(index, object)
|
||||||
onObjectRemoved: fileMenu.removeItem(object)
|
onObjectRemoved: fileMenu.removeItem(object)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user