mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-18 20:28:01 -06:00
WIP: Add Welcome Page and use CTRL+Alt+D to trigger
This commit is contained in:
parent
3b63f92d55
commit
ac012e8f09
5 changed files with 91 additions and 0 deletions
|
@ -59,6 +59,8 @@ from cura.Scene.CuraSceneNode import CuraSceneNode
|
||||||
|
|
||||||
from cura.Scene.CuraSceneController import CuraSceneController
|
from cura.Scene.CuraSceneController import CuraSceneController
|
||||||
|
|
||||||
|
from cura.UI.WelcomePagesModel import WelcomePagesModel
|
||||||
|
|
||||||
from UM.Settings.SettingDefinition import SettingDefinition, DefinitionPropertyType
|
from UM.Settings.SettingDefinition import SettingDefinition, DefinitionPropertyType
|
||||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||||
from UM.Settings.SettingFunction import SettingFunction
|
from UM.Settings.SettingFunction import SettingFunction
|
||||||
|
@ -208,6 +210,8 @@ class CuraApplication(QtApplication):
|
||||||
self._cura_scene_controller = None
|
self._cura_scene_controller = None
|
||||||
self._machine_error_checker = None
|
self._machine_error_checker = None
|
||||||
|
|
||||||
|
self._welcome_pages_model = WelcomePagesModel(self)
|
||||||
|
|
||||||
self._quality_profile_drop_down_menu_model = None
|
self._quality_profile_drop_down_menu_model = None
|
||||||
self._custom_quality_profile_drop_down_menu_model = None
|
self._custom_quality_profile_drop_down_menu_model = None
|
||||||
self._cura_API = CuraAPI(self)
|
self._cura_API = CuraAPI(self)
|
||||||
|
@ -745,6 +749,8 @@ class CuraApplication(QtApplication):
|
||||||
# Initialize Cura API
|
# Initialize Cura API
|
||||||
self._cura_API.initialize()
|
self._cura_API.initialize()
|
||||||
|
|
||||||
|
self._welcome_pages_model.initialize()
|
||||||
|
|
||||||
# Detect in which mode to run and execute that mode
|
# Detect in which mode to run and execute that mode
|
||||||
if self._is_headless:
|
if self._is_headless:
|
||||||
self.runWithoutGUI()
|
self.runWithoutGUI()
|
||||||
|
@ -843,6 +849,10 @@ class CuraApplication(QtApplication):
|
||||||
def getSettingVisibilityPresetsModel(self, *args) -> SettingVisibilityPresetsModel:
|
def getSettingVisibilityPresetsModel(self, *args) -> SettingVisibilityPresetsModel:
|
||||||
return self._setting_visibility_presets_model
|
return self._setting_visibility_presets_model
|
||||||
|
|
||||||
|
@pyqtSlot(result = QObject)
|
||||||
|
def getWelcomePagesModel(self, *args) -> "WelcomePagesModel":
|
||||||
|
return self._welcome_pages_model
|
||||||
|
|
||||||
def getCuraFormulaFunctions(self, *args) -> "CuraFormulaFunctions":
|
def getCuraFormulaFunctions(self, *args) -> "CuraFormulaFunctions":
|
||||||
if self._cura_formula_functions is None:
|
if self._cura_formula_functions is None:
|
||||||
self._cura_formula_functions = CuraFormulaFunctions(self)
|
self._cura_formula_functions = CuraFormulaFunctions(self)
|
||||||
|
@ -975,6 +985,8 @@ class CuraApplication(QtApplication):
|
||||||
qmlRegisterSingletonType(SimpleModeSettingsManager, "Cura", 1, 0, "SimpleModeSettingsManager", self.getSimpleModeSettingsManager)
|
qmlRegisterSingletonType(SimpleModeSettingsManager, "Cura", 1, 0, "SimpleModeSettingsManager", self.getSimpleModeSettingsManager)
|
||||||
qmlRegisterSingletonType(MachineActionManager.MachineActionManager, "Cura", 1, 0, "MachineActionManager", self.getMachineActionManager)
|
qmlRegisterSingletonType(MachineActionManager.MachineActionManager, "Cura", 1, 0, "MachineActionManager", self.getMachineActionManager)
|
||||||
|
|
||||||
|
qmlRegisterType(WelcomePagesModel, "Cura", 1, 0, "WelcomePageModel")
|
||||||
|
|
||||||
qmlRegisterType(NetworkMJPGImage, "Cura", 1, 0, "NetworkMJPGImage")
|
qmlRegisterType(NetworkMJPGImage, "Cura", 1, 0, "NetworkMJPGImage")
|
||||||
|
|
||||||
qmlRegisterSingletonType(ObjectsModel, "Cura", 1, 0, "ObjectsModel", self.getObjectsModel)
|
qmlRegisterSingletonType(ObjectsModel, "Cura", 1, 0, "ObjectsModel", self.getObjectsModel)
|
||||||
|
|
45
cura/UI/WelcomePagesModel.py
Normal file
45
cura/UI/WelcomePagesModel.py
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
|
||||||
|
|
||||||
|
import os
|
||||||
|
from typing import TYPE_CHECKING, Optional
|
||||||
|
|
||||||
|
from PyQt5.QtCore import QUrl, Qt
|
||||||
|
|
||||||
|
from UM.Qt.ListModel import ListModel
|
||||||
|
from UM.Resources import Resources
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from PyQt5.QtCore import QObject
|
||||||
|
|
||||||
|
|
||||||
|
class WelcomePagesModel(ListModel):
|
||||||
|
|
||||||
|
IdRole = Qt.UserRole + 1 # Page ID
|
||||||
|
PageUrlRole = Qt.UserRole + 2 # URL to the page's QML file
|
||||||
|
NextPageIdRole = Qt.UserRole + 3 # The next page ID it should go to
|
||||||
|
|
||||||
|
def __init__(self, parent: Optional["QObject"] = None) -> None:
|
||||||
|
super().__init__(parent)
|
||||||
|
|
||||||
|
self.addRoleName(self.IdRole, "id")
|
||||||
|
self.addRoleName(self.PageUrlRole, "page_url")
|
||||||
|
self.addRoleName(self.NextPageIdRole, "next_page_id")
|
||||||
|
|
||||||
|
self._pages = []
|
||||||
|
|
||||||
|
def initialize(self) -> None:
|
||||||
|
from cura.CuraApplication import CuraApplication
|
||||||
|
# Add default welcome pages
|
||||||
|
self._pages.append({"id": "welcome",
|
||||||
|
"page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles,
|
||||||
|
os.path.join("WelcomePages", "WelcomeContent.qml"))),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
self.setItems(self._pages)
|
||||||
|
|
||||||
|
def addPage(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = ["WelcomePagesModel"]
|
0
cura/UI/__init__.py
Normal file
0
cura/UI/__init__.py
Normal file
|
@ -69,10 +69,19 @@ Item
|
||||||
|
|
||||||
property alias browsePackages: browsePackagesAction
|
property alias browsePackages: browsePackagesAction
|
||||||
|
|
||||||
|
property alias showOnBoarding: showOnBoarding
|
||||||
|
|
||||||
UM.I18nCatalog{id: catalog; name: "cura"}
|
UM.I18nCatalog{id: catalog; name: "cura"}
|
||||||
|
|
||||||
|
|
||||||
Controls2.Action
|
Controls2.Action
|
||||||
|
{
|
||||||
|
id: showOnBoarding
|
||||||
|
text: catalog.i18nc("@action:inmenu", "Show On boarding")
|
||||||
|
shortcut: "Ctrl+Alt+D"
|
||||||
|
}
|
||||||
|
|
||||||
|
Action
|
||||||
{
|
{
|
||||||
id: showTroubleShootingAction
|
id: showTroubleShootingAction
|
||||||
onTriggered: Qt.openUrlExternally("https://ultimaker.com/en/troubleshooting")
|
onTriggered: Qt.openUrlExternally("https://ultimaker.com/en/troubleshooting")
|
||||||
|
|
|
@ -14,6 +14,7 @@ import Cura 1.1 as Cura
|
||||||
import "Dialogs"
|
import "Dialogs"
|
||||||
import "Menus"
|
import "Menus"
|
||||||
import "MainWindow"
|
import "MainWindow"
|
||||||
|
import "WelcomePages"
|
||||||
|
|
||||||
UM.MainWindow
|
UM.MainWindow
|
||||||
{
|
{
|
||||||
|
@ -41,6 +42,30 @@ UM.MainWindow
|
||||||
tooltip.hide();
|
tooltip.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WelcomeDialog
|
||||||
|
{
|
||||||
|
id: welcomeDialog
|
||||||
|
visible: false
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle
|
||||||
|
{
|
||||||
|
id: greyOutBackground
|
||||||
|
anchors.fill: parent
|
||||||
|
visible: welcomeDialog.visible
|
||||||
|
color: "black"
|
||||||
|
opacity: 0.7
|
||||||
|
z: stageMenu.z + 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections
|
||||||
|
{
|
||||||
|
target: Cura.Actions.showOnBoarding
|
||||||
|
onTriggered:
|
||||||
|
{
|
||||||
|
welcomeDialog.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted:
|
Component.onCompleted:
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue