mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-18 03:55:55 +08:00
Catch file open events before file loaders are loaded
The event is essentially delayed. The filename is put in a list by the event handler. The list of files is then loaded after all plug-ins are loaded. Contributes to issue CURA-730.
This commit is contained in:
parent
7b9ecd4aba
commit
232713a019
@ -78,8 +78,13 @@ class CuraApplication(QtApplication):
|
|||||||
if not hasattr(sys, "frozen"):
|
if not hasattr(sys, "frozen"):
|
||||||
Resources.addSearchPath(os.path.join(os.path.abspath(os.path.dirname(__file__)), ".."))
|
Resources.addSearchPath(os.path.join(os.path.abspath(os.path.dirname(__file__)), ".."))
|
||||||
|
|
||||||
|
self._open_file_queue = [] #Files to open when plug-ins are loaded.
|
||||||
|
|
||||||
super().__init__(name = "cura", version = CuraVersion)
|
super().__init__(name = "cura", version = CuraVersion)
|
||||||
|
|
||||||
|
for file_name in self._open_file_queue: #Open all the files that were queued up while plug-ins were loading.
|
||||||
|
self._openFile(file_name)
|
||||||
|
|
||||||
self.setWindowIcon(QIcon(Resources.getPath(Resources.Images, "cura-icon.png")))
|
self.setWindowIcon(QIcon(Resources.getPath(Resources.Images, "cura-icon.png")))
|
||||||
|
|
||||||
self.setRequiredPlugins([
|
self.setRequiredPlugins([
|
||||||
@ -148,6 +153,8 @@ class CuraApplication(QtApplication):
|
|||||||
if self.getBackend() == None:
|
if self.getBackend() == None:
|
||||||
raise RuntimeError("Could not load the backend plugin!")
|
raise RuntimeError("Could not load the backend plugin!")
|
||||||
|
|
||||||
|
self._plugins_loaded = True
|
||||||
|
|
||||||
def addCommandLineOptions(self, parser):
|
def addCommandLineOptions(self, parser):
|
||||||
super().addCommandLineOptions(parser)
|
super().addCommandLineOptions(parser)
|
||||||
parser.add_argument("file", nargs="*", help="Files to load after starting the application.")
|
parser.add_argument("file", nargs="*", help="Files to load after starting the application.")
|
||||||
@ -211,8 +218,10 @@ class CuraApplication(QtApplication):
|
|||||||
# Handle Qt events
|
# Handle Qt events
|
||||||
def event(self, event):
|
def event(self, event):
|
||||||
if event.type() == QEvent.FileOpen:
|
if event.type() == QEvent.FileOpen:
|
||||||
Logger.log("i", "File open via Qt event: %s", event.file())
|
if self._plugins_loaded:
|
||||||
self._openFile(event.file())
|
self._openFile(event.file())
|
||||||
|
else:
|
||||||
|
self._open_file_queue.append(event.file())
|
||||||
|
|
||||||
return super().event(event)
|
return super().event(event)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user