mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-16 19:28:07 -06:00
Moved view selection to previewStage
CURA-5829
This commit is contained in:
parent
3248a05819
commit
9cc7a7ca23
5 changed files with 100 additions and 69 deletions
|
@ -1,13 +1,31 @@
|
|||
# Copyright (c) 2018 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
import os.path
|
||||
|
||||
from UM.Application import Application
|
||||
from cura.Stages.CuraStage import CuraStage
|
||||
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from UM.View import View
|
||||
|
||||
class PreviewStage(CuraStage):
|
||||
def __init__(self, parent = None) -> None:
|
||||
def __init__(self, application: Application, parent = None) -> None:
|
||||
super().__init__(parent)
|
||||
Application.getInstance().engineCreatedSignal.connect(self._engineCreated)
|
||||
self._application = application
|
||||
self._application.engineCreatedSignal.connect(self._engineCreated)
|
||||
self._previously_active_view = None # type: Optional[View]
|
||||
|
||||
def _engineCreated(self):
|
||||
return
|
||||
def onStageSelected(self) -> None:
|
||||
self._previously_active_view = self._application.getController().getActiveView()
|
||||
|
||||
def onStageDeselected(self) -> None:
|
||||
if self._previously_active_view is not None:
|
||||
self._application.getController().setActiveView(self._previously_active_view.getPluginId())
|
||||
self._previously_active_view = None
|
||||
|
||||
def _engineCreated(self) -> None:
|
||||
menu_component_path = os.path.join(self._application.getPluginRegistry().getPluginPath(self.getPluginId()),
|
||||
"PreviewMenu.qml")
|
||||
self.addDisplayComponent("menu", menu_component_path)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue