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

View file

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