Handle Open File events on Mac OSX

This commit is contained in:
Arjen Hiemstra 2015-08-11 16:48:50 +02:00
parent a47c8f7ef6
commit ae79139cc4

View file

@ -38,7 +38,7 @@ from . import PrintInformation
from . import CuraActions from . import CuraActions
from . import MultiMaterialDecorator from . import MultiMaterialDecorator
from PyQt5.QtCore import pyqtSlot, QUrl, Qt, pyqtSignal, pyqtProperty from PyQt5.QtCore import pyqtSlot, QUrl, Qt, pyqtSignal, pyqtProperty, QEvent
from PyQt5.QtGui import QColor, QIcon from PyQt5.QtGui import QColor, QIcon
import platform import platform
@ -170,12 +170,17 @@ class CuraApplication(QtApplication):
self.closeSplash() self.closeSplash()
for file in self.getCommandLineOption("file", []): for file in self.getCommandLineOption("file", []):
job = ReadMeshJob(os.path.abspath(file)) self._openFile(file)
job.finished.connect(self._onFileLoaded)
job.start()
self.exec_() self.exec_()
# Handle Qt events
def event(self, event):
if event.type() == QEvent.FileOpen:
self._openFile(event.file())
return super().event(event)
def registerObjects(self, engine): def registerObjects(self, engine):
engine.rootContext().setContextProperty("Printer", self) engine.rootContext().setContextProperty("Printer", self)
self._print_information = PrintInformation.PrintInformation() self._print_information = PrintInformation.PrintInformation()
@ -508,3 +513,9 @@ class CuraApplication(QtApplication):
def _reloadMeshFinished(self, job): def _reloadMeshFinished(self, job):
job._node = job.getResult() job._node = job.getResult()
def _openFile(self, file):
job = ReadMeshJob(os.path.abspath(file))
job.finished.connect(self._onFileLoaded)
job.start()