mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 04:36:01 +08:00
Update Cura.qml to use Actions as singleton instead of instantiating them
This commit is contained in:
parent
fbbe6cde78
commit
207bdb3cd5
@ -9,6 +9,8 @@ import QtQuick.Dialogs 1.1
|
|||||||
|
|
||||||
import UM 1.1 as UM
|
import UM 1.1 as UM
|
||||||
|
|
||||||
|
import "."
|
||||||
|
|
||||||
UM.MainWindow
|
UM.MainWindow
|
||||||
{
|
{
|
||||||
id: base
|
id: base
|
||||||
@ -53,7 +55,7 @@ UM.MainWindow
|
|||||||
title: catalog.i18nc("@title:menu menubar:toplevel","&File");
|
title: catalog.i18nc("@title:menu menubar:toplevel","&File");
|
||||||
|
|
||||||
MenuItem {
|
MenuItem {
|
||||||
action: actions.open;
|
action: Actions.open;
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu
|
Menu
|
||||||
@ -115,11 +117,11 @@ UM.MainWindow
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem { action: actions.reloadAll; }
|
MenuItem { action: Actions.reloadAll; }
|
||||||
|
|
||||||
MenuSeparator { }
|
MenuSeparator { }
|
||||||
|
|
||||||
MenuItem { action: actions.quit; }
|
MenuItem { action: Actions.quit; }
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu
|
Menu
|
||||||
@ -127,17 +129,17 @@ UM.MainWindow
|
|||||||
//: Edit menu
|
//: Edit menu
|
||||||
title: catalog.i18nc("@title:menu menubar:toplevel","&Edit");
|
title: catalog.i18nc("@title:menu menubar:toplevel","&Edit");
|
||||||
|
|
||||||
MenuItem { action: actions.undo; }
|
MenuItem { action: Actions.undo; }
|
||||||
MenuItem { action: actions.redo; }
|
MenuItem { action: Actions.redo; }
|
||||||
MenuSeparator { }
|
MenuSeparator { }
|
||||||
MenuItem { action: actions.deleteSelection; }
|
MenuItem { action: Actions.deleteSelection; }
|
||||||
MenuItem { action: actions.deleteAll; }
|
MenuItem { action: Actions.deleteAll; }
|
||||||
MenuItem { action: actions.resetAllTranslation; }
|
MenuItem { action: Actions.resetAllTranslation; }
|
||||||
MenuItem { action: actions.resetAll; }
|
MenuItem { action: Actions.resetAll; }
|
||||||
MenuSeparator { }
|
MenuSeparator { }
|
||||||
MenuItem { action: actions.groupObjects;}
|
MenuItem { action: Actions.groupObjects;}
|
||||||
MenuItem { action: actions.mergeObjects;}
|
MenuItem { action: Actions.mergeObjects;}
|
||||||
MenuItem { action: actions.unGroupObjects;}
|
MenuItem { action: Actions.unGroupObjects;}
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu
|
Menu
|
||||||
@ -201,10 +203,10 @@ UM.MainWindow
|
|||||||
|
|
||||||
ExclusiveGroup { id: machineVariantsGroup; }
|
ExclusiveGroup { id: machineVariantsGroup; }
|
||||||
|
|
||||||
MenuSeparator { visible: UM.MachineManager.hasVariants; }
|
// MenuSeparator { visible: UM.MachineManager.hasVariants; }
|
||||||
|
|
||||||
MenuItem { action: actions.addMachine; }
|
MenuItem { action: Actions.addMachine; }
|
||||||
MenuItem { action: actions.configureMachines; }
|
MenuItem { action: Actions.configureMachines; }
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu
|
Menu
|
||||||
@ -277,11 +279,11 @@ UM.MainWindow
|
|||||||
|
|
||||||
MenuSeparator { id: profileMenuSeparator }
|
MenuSeparator { id: profileMenuSeparator }
|
||||||
|
|
||||||
MenuItem { action: actions.updateProfile; }
|
MenuItem { action: Actions.updateProfile; }
|
||||||
MenuItem { action: actions.resetProfile; }
|
MenuItem { action: Actions.resetProfile; }
|
||||||
MenuItem { action: actions.addProfile; }
|
MenuItem { action: Actions.addProfile; }
|
||||||
MenuSeparator { }
|
MenuSeparator { }
|
||||||
MenuItem { action: actions.manageProfiles; }
|
MenuItem { action: Actions.manageProfiles; }
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu
|
Menu
|
||||||
@ -323,7 +325,7 @@ UM.MainWindow
|
|||||||
//: Settings menu
|
//: Settings menu
|
||||||
title: catalog.i18nc("@title:menu menubar:toplevel","&Settings");
|
title: catalog.i18nc("@title:menu menubar:toplevel","&Settings");
|
||||||
|
|
||||||
MenuItem { action: actions.preferences; }
|
MenuItem { action: Actions.preferences; }
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu
|
Menu
|
||||||
@ -331,11 +333,11 @@ UM.MainWindow
|
|||||||
//: Help menu
|
//: Help menu
|
||||||
title: catalog.i18nc("@title:menu menubar:toplevel","&Help");
|
title: catalog.i18nc("@title:menu menubar:toplevel","&Help");
|
||||||
|
|
||||||
MenuItem { action: actions.showEngineLog; }
|
MenuItem { action: Actions.showEngineLog; }
|
||||||
MenuItem { action: actions.documentation; }
|
MenuItem { action: Actions.documentation; }
|
||||||
MenuItem { action: actions.reportBug; }
|
MenuItem { action: Actions.reportBug; }
|
||||||
MenuSeparator { }
|
MenuSeparator { }
|
||||||
MenuItem { action: actions.about; }
|
MenuItem { action: Actions.about; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -425,7 +427,7 @@ UM.MainWindow
|
|||||||
left: parent.left;
|
left: parent.left;
|
||||||
//leftMargin: UM.Theme.getSize("loadfile_margin").width
|
//leftMargin: UM.Theme.getSize("loadfile_margin").width
|
||||||
}
|
}
|
||||||
action: actions.open;
|
action: Actions.open;
|
||||||
}
|
}
|
||||||
|
|
||||||
Image
|
Image
|
||||||
@ -513,22 +515,12 @@ UM.MainWindow
|
|||||||
|
|
||||||
width: UM.Theme.getSize("sidebar").width;
|
width: UM.Theme.getSize("sidebar").width;
|
||||||
|
|
||||||
addMachineAction: actions.addMachine;
|
addMachineAction: Actions.addMachine;
|
||||||
configureMachinesAction: actions.configureMachines;
|
configureMachinesAction: Actions.configureMachines;
|
||||||
addProfileAction: actions.addProfile;
|
addProfileAction: Actions.addProfile;
|
||||||
updateProfileAction: actions.updateProfile;
|
updateProfileAction: Actions.updateProfile;
|
||||||
resetProfileAction: actions.resetProfile;
|
resetProfileAction: Actions.resetProfile;
|
||||||
manageProfilesAction: actions.manageProfiles;
|
manageProfilesAction: Actions.manageProfiles;
|
||||||
|
|
||||||
configureSettingsAction: Action
|
|
||||||
{
|
|
||||||
onTriggered:
|
|
||||||
{
|
|
||||||
preferences.visible = true;
|
|
||||||
preferences.setPage(2);
|
|
||||||
preferences.getCurrentItem().scrollToSection(source.key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -561,73 +553,16 @@ UM.MainWindow
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Actions
|
Connections
|
||||||
{
|
{
|
||||||
id: actions;
|
target: Actions.preferences
|
||||||
|
onTriggered: preferences.visible = true
|
||||||
open.onTriggered: openDialog.open();
|
|
||||||
|
|
||||||
quit.onTriggered: base.visible = false;
|
|
||||||
|
|
||||||
undo.onTriggered: UM.OperationStack.undo();
|
|
||||||
undo.enabled: UM.OperationStack.canUndo;
|
|
||||||
redo.onTriggered: UM.OperationStack.redo();
|
|
||||||
redo.enabled: UM.OperationStack.canRedo;
|
|
||||||
|
|
||||||
deleteSelection.onTriggered:
|
|
||||||
{
|
|
||||||
Printer.deleteSelection();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteObject.onTriggered:
|
Connections
|
||||||
{
|
{
|
||||||
if(objectContextMenu.objectId != 0)
|
target: Actions.addProfile
|
||||||
{
|
onTriggered:
|
||||||
Printer.deleteObject(objectContextMenu.objectId);
|
|
||||||
objectContextMenu.objectId = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
multiplyObject.onTriggered:
|
|
||||||
{
|
|
||||||
if(objectContextMenu.objectId != 0)
|
|
||||||
{
|
|
||||||
Printer.multiplyObject(objectContextMenu.objectId, 1);
|
|
||||||
objectContextMenu.objectId = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
centerObject.onTriggered:
|
|
||||||
{
|
|
||||||
if(objectContextMenu.objectId != 0)
|
|
||||||
{
|
|
||||||
Printer.centerObject(objectContextMenu.objectId);
|
|
||||||
objectContextMenu.objectId = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
groupObjects.onTriggered:
|
|
||||||
{
|
|
||||||
Printer.groupSelected();
|
|
||||||
}
|
|
||||||
|
|
||||||
unGroupObjects.onTriggered:
|
|
||||||
{
|
|
||||||
Printer.ungroupSelected();
|
|
||||||
}
|
|
||||||
|
|
||||||
mergeObjects.onTriggered:
|
|
||||||
{
|
|
||||||
Printer.mergeSelected();
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteAll.onTriggered: Printer.deleteAll();
|
|
||||||
resetAllTranslation.onTriggered: Printer.resetAllTranslation();
|
|
||||||
resetAll.onTriggered: Printer.resetAll();
|
|
||||||
reloadAll.onTriggered: Printer.reloadAll();
|
|
||||||
|
|
||||||
addMachine.onTriggered: addMachineDialog.visible = true;
|
|
||||||
addProfile.onTriggered:
|
|
||||||
{
|
{
|
||||||
UM.MachineManager.createProfile();
|
UM.MachineManager.createProfile();
|
||||||
preferences.setPage(4);
|
preferences.setPage(4);
|
||||||
@ -636,26 +571,37 @@ UM.MainWindow
|
|||||||
// Show the renameDialog after a very short delay so the preference page has time to initiate
|
// Show the renameDialog after a very short delay so the preference page has time to initiate
|
||||||
showProfileNameDialogTimer.start();
|
showProfileNameDialogTimer.start();
|
||||||
}
|
}
|
||||||
updateProfile.onTriggered: UM.ActiveProfile.updateProfile();
|
}
|
||||||
resetProfile.onTriggered: UM.ActiveProfile.discardChanges();
|
|
||||||
|
|
||||||
preferences.onTriggered: preferences.visible = true;
|
Connections
|
||||||
configureMachines.onTriggered:
|
{
|
||||||
|
target: Actions.configureMachines
|
||||||
|
onTriggered:
|
||||||
{
|
{
|
||||||
preferences.visible = true;
|
preferences.visible = true;
|
||||||
preferences.setPage(3);
|
preferences.setPage(3);
|
||||||
}
|
}
|
||||||
manageProfiles.onTriggered:
|
}
|
||||||
|
|
||||||
|
Connections
|
||||||
|
{
|
||||||
|
target: Actions.manageProfiles
|
||||||
|
onTriggered:
|
||||||
{
|
{
|
||||||
preferences.visible = true;
|
preferences.visible = true;
|
||||||
preferences.setPage(4);
|
preferences.setPage(4);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
documentation.onTriggered: CuraActions.openDocumentation();
|
Connections
|
||||||
reportBug.onTriggered: CuraActions.openBugReportPage();
|
{
|
||||||
showEngineLog.onTriggered: engineLog.visible = true;
|
target: Actions.configureSettingVisibility
|
||||||
about.onTriggered: aboutDialog.visible = true;
|
onTriggered:
|
||||||
toggleFullScreen.onTriggered: base.toggleFullscreen();
|
{
|
||||||
|
preferences.visible = true;
|
||||||
|
preferences.setPage(2);
|
||||||
|
preferences.getCurrentItem().scrollToSection(source.key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer
|
Timer
|
||||||
@ -672,29 +618,68 @@ UM.MainWindow
|
|||||||
id: objectContextMenu;
|
id: objectContextMenu;
|
||||||
|
|
||||||
property variant objectId: -1;
|
property variant objectId: -1;
|
||||||
MenuItem { action: actions.centerObject; }
|
MenuItem { action: Actions.centerObject; }
|
||||||
MenuItem { action: actions.deleteObject; }
|
MenuItem { action: Actions.deleteObject; }
|
||||||
MenuItem { action: actions.multiplyObject; }
|
MenuItem { action: Actions.multiplyObject; }
|
||||||
MenuSeparator { }
|
MenuSeparator { }
|
||||||
MenuItem { action: actions.deleteAll; }
|
MenuItem { action: Actions.deleteAll; }
|
||||||
MenuItem { action: actions.reloadAll; }
|
MenuItem { action: Actions.reloadAll; }
|
||||||
MenuItem { action: actions.resetAllTranslation; }
|
MenuItem { action: Actions.resetAllTranslation; }
|
||||||
MenuItem { action: actions.resetAll; }
|
MenuItem { action: Actions.resetAll; }
|
||||||
MenuItem { action: actions.groupObjects; }
|
MenuItem { action: Actions.groupObjects; }
|
||||||
MenuItem { action: actions.mergeObjects; }
|
MenuItem { action: Actions.mergeObjects; }
|
||||||
MenuItem { action: actions.unGroupObjects; }
|
MenuItem { action: Actions.unGroupObjects; }
|
||||||
|
|
||||||
|
Connections
|
||||||
|
{
|
||||||
|
target: Actions.deleteObject
|
||||||
|
onTriggered:
|
||||||
|
{
|
||||||
|
if(objectContextMenu.objectId != 0)
|
||||||
|
{
|
||||||
|
Printer.deleteObject(objectContextMenu.objectId);
|
||||||
|
objectContextMenu.objectId = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections
|
||||||
|
{
|
||||||
|
target: Actions.multiplyObject
|
||||||
|
onTriggered:
|
||||||
|
{
|
||||||
|
if(objectContextMenu.objectId != 0)
|
||||||
|
{
|
||||||
|
Printer.multiplyObject(objectContextMenu.objectId, 1);
|
||||||
|
objectContextMenu.objectId = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections
|
||||||
|
{
|
||||||
|
target: Actions.centerObject
|
||||||
|
onTriggered:
|
||||||
|
{
|
||||||
|
if(objectContextMenu.objectId != 0)
|
||||||
|
{
|
||||||
|
Printer.centerObject(objectContextMenu.objectId);
|
||||||
|
objectContextMenu.objectId = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu
|
Menu
|
||||||
{
|
{
|
||||||
id: contextMenu;
|
id: contextMenu;
|
||||||
MenuItem { action: actions.deleteAll; }
|
MenuItem { action: Actions.deleteAll; }
|
||||||
MenuItem { action: actions.reloadAll; }
|
MenuItem { action: Actions.reloadAll; }
|
||||||
MenuItem { action: actions.resetAllTranslation; }
|
MenuItem { action: Actions.resetAllTranslation; }
|
||||||
MenuItem { action: actions.resetAll; }
|
MenuItem { action: Actions.resetAll; }
|
||||||
MenuItem { action: actions.groupObjects; }
|
MenuItem { action: Actions.groupObjects; }
|
||||||
MenuItem { action: actions.mergeObjects; }
|
MenuItem { action: Actions.mergeObjects; }
|
||||||
MenuItem { action: actions.unGroupObjects; }
|
MenuItem { action: Actions.unGroupObjects; }
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections
|
Connections
|
||||||
@ -713,6 +698,18 @@ UM.MainWindow
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections
|
||||||
|
{
|
||||||
|
target: Actions.quit
|
||||||
|
onTriggered: base.visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections
|
||||||
|
{
|
||||||
|
target: Actions.toggleFullScreen
|
||||||
|
onTriggered: base.toggleFullscreen();
|
||||||
|
}
|
||||||
|
|
||||||
FileDialog
|
FileDialog
|
||||||
{
|
{
|
||||||
id: openDialog;
|
id: openDialog;
|
||||||
@ -737,21 +734,45 @@ UM.MainWindow
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections
|
||||||
|
{
|
||||||
|
target: Actions.open
|
||||||
|
onTriggered: openDialog.open()
|
||||||
|
}
|
||||||
|
|
||||||
EngineLog
|
EngineLog
|
||||||
{
|
{
|
||||||
id: engineLog;
|
id: engineLog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections
|
||||||
|
{
|
||||||
|
target: Actions.showEngineLog
|
||||||
|
onTriggered: engineLog.visible = true;
|
||||||
|
}
|
||||||
|
|
||||||
AddMachineDialog
|
AddMachineDialog
|
||||||
{
|
{
|
||||||
id: addMachineDialog
|
id: addMachineDialog
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections
|
||||||
|
{
|
||||||
|
target: Actions.addMachine
|
||||||
|
onTriggered: addMachineDialog.visible = true;
|
||||||
|
}
|
||||||
|
|
||||||
AboutDialog
|
AboutDialog
|
||||||
{
|
{
|
||||||
id: aboutDialog
|
id: aboutDialog
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections
|
||||||
|
{
|
||||||
|
target: Actions.about
|
||||||
|
onTriggered: aboutDialog.visible = true;
|
||||||
|
}
|
||||||
|
|
||||||
Connections
|
Connections
|
||||||
{
|
{
|
||||||
target: Printer
|
target: Printer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user