From 8a63b8d110d5925a127cd1d2b3659428dc126af9 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Tue, 23 Jun 2015 11:56:15 +0200 Subject: [PATCH] Fix recent files on Windows Contributes to Asana issue 33694049548880 --- cura/CuraApplication.py | 12 ++++++++---- resources/qml/Cura.qml | 8 +++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 45d4f3a74f..be663545e6 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -85,7 +85,7 @@ class CuraApplication(QtApplication): if not os.path.isfile(f): continue - self._recent_files.append(f) + self._recent_files.append(QUrl.fromLocalFile(f)) ## Handle loading of all plugin types (and the backend explicitly) # \sa PluginRegistery @@ -330,7 +330,7 @@ class CuraApplication(QtApplication): return log recentFilesChanged = pyqtSignal() - @pyqtProperty("QStringList", notify = recentFilesChanged) + @pyqtProperty("QVariantList", notify = recentFilesChanged) def recentFiles(self): return self._recent_files @@ -508,7 +508,7 @@ class CuraApplication(QtApplication): if type(job) is not ReadMeshJob: return - f = job.getFileName() + f = QUrl.fromLocalFile(job.getFileName()) if f in self._recent_files: self._recent_files.remove(f) @@ -516,5 +516,9 @@ class CuraApplication(QtApplication): if len(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() diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 830470c9c6..464424130a 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -37,9 +37,11 @@ UM.MainWindow { Instantiator { model: Printer.recentFiles MenuItem { - property url filePath: modelData; - text: (index + 1) + ". " + modelData.slice(modelData.lastIndexOf("/") + 1); - onTriggered: UM.MeshFileHandler.readLocalFile(filePath); + text: { + var path = modelData.toString() + return (index + 1) + ". " + path.slice(path.lastIndexOf("/") + 1); + } + onTriggered: UM.MeshFileHandler.readLocalFile(modelData); } onObjectAdded: fileMenu.insertItem(index, object) onObjectRemoved: fileMenu.removeItem(object)