Use QUrl to parse fileUrl

CURA-3495
This commit is contained in:
Lipu Fei 2017-03-21 09:58:16 +01:00
parent f3167bb84b
commit 9e5513ade6

View file

@ -1269,15 +1269,10 @@ class CuraApplication(QtApplication):
"""
Checks if the given file URL is a valid project file.
"""
file_url_prefix = 'file:///'
file_name = file_url
if file_name.startswith(file_url_prefix):
file_name = file_name[len(file_url_prefix):]
workspace_reader = self.getWorkspaceFileHandler().getReaderForFile(file_name)
file_path = QUrl(file_url).toLocalFile()
workspace_reader = self.getWorkspaceFileHandler().getReaderForFile(file_path)
if workspace_reader is None:
return False # non-project files won't get a reader
result = workspace_reader.preRead(file_name, show_dialog=False)
result = workspace_reader.preRead(file_path, show_dialog=False)
return result == WorkspaceReader.PreReadResult.accepted