Fix recent files on Windows

Contributes to Asana issue 33694049548880
This commit is contained in:
Arjen Hiemstra 2015-06-23 11:56:15 +02:00
parent d937eb7a17
commit 8a63b8d110
2 changed files with 13 additions and 7 deletions

View File

@ -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()

View File

@ -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)