From 052898ce21084117e644b35a85f4799e0e3b08b4 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 10 Jan 2022 16:55:28 +0100 Subject: [PATCH 01/16] Switch out the file, view and edit menu for controls 2 CURA-8683 --- resources/qml/Actions.qml | 329 +++++++++---------- resources/qml/Cura.qml | 5 +- resources/qml/MainWindow/ApplicationMenu.qml | 53 ++- resources/qml/Menus/EditMenu.qml | 28 ++ resources/qml/Menus/FileMenu.qml | 31 +- resources/qml/Menus/OpenFilesMenu.qml | 10 +- resources/qml/Menus/RecentFilesMenu.qml | 6 +- resources/qml/Menus/SaveProjectMenu.qml | 8 +- resources/qml/Menus/ViewMenu.qml | 66 +--- 9 files changed, 285 insertions(+), 251 deletions(-) create mode 100644 resources/qml/Menus/EditMenu.qml diff --git a/resources/qml/Actions.qml b/resources/qml/Actions.qml index aa88c9176d..6e7dd6b85f 100644 --- a/resources/qml/Actions.qml +++ b/resources/qml/Actions.qml @@ -4,69 +4,68 @@ pragma Singleton import QtQuick 2.10 -import QtQuick.Controls 1.1 -import QtQuick.Controls 2.3 as Controls2 +import QtQuick.Controls 2.4 import UM 1.1 as UM import Cura 1.0 as Cura Item { - property alias newProject: newProjectAction; - property alias open: openAction; - property alias quit: quitAction; + property alias newProject: newProjectAction + property alias open: openAction + property alias quit: quitAction - property alias undo: undoAction; - property alias redo: redoAction; + property alias undo: undoAction + property alias redo: redoAction - property alias view3DCamera: view3DCameraAction; - property alias viewFrontCamera: viewFrontCameraAction; - property alias viewTopCamera: viewTopCameraAction; - property alias viewBottomCamera: viewBottomCameraAction; - property alias viewLeftSideCamera: viewLeftSideCameraAction; - property alias viewRightSideCamera: viewRightSideCameraAction; + property alias view3DCamera: view3DCameraAction + property alias viewFrontCamera: viewFrontCameraAction + property alias viewTopCamera: viewTopCameraAction + property alias viewBottomCamera: viewBottomCameraAction + property alias viewLeftSideCamera: viewLeftSideCameraAction + property alias viewRightSideCamera: viewRightSideCameraAction - property alias deleteSelection: deleteSelectionAction; - property alias centerSelection: centerSelectionAction; - property alias multiplySelection: multiplySelectionAction; + property alias deleteSelection: deleteSelectionAction + property alias centerSelection: centerSelectionAction + property alias multiplySelection: multiplySelectionAction - property alias deleteObject: deleteObjectAction; - property alias centerObject: centerObjectAction; - property alias groupObjects: groupObjectsAction; - property alias unGroupObjects:unGroupObjectsAction; - property alias mergeObjects: mergeObjectsAction; - //property alias unMergeObjects: unMergeObjectsAction; + property alias deleteObject: deleteObjectAction + property alias centerObject: centerObjectAction + property alias groupObjects: groupObjectsAction + property alias unGroupObjects:unGroupObjectsAction + property alias mergeObjects: mergeObjectsAction + //property alias unMergeObjects: unMergeObjectsAction - property alias multiplyObject: multiplyObjectAction; + property alias multiplyObject: multiplyObjectAction - property alias selectAll: selectAllAction; - property alias deleteAll: deleteAllAction; - property alias reloadAll: reloadAllAction; - property alias arrangeAllBuildPlates: arrangeAllBuildPlatesAction; - property alias arrangeAll: arrangeAllAction; - property alias arrangeSelection: arrangeSelectionAction; - property alias resetAllTranslation: resetAllTranslationAction; - property alias resetAll: resetAllAction; + property alias selectAll: selectAllAction + property alias deleteAll: deleteAllAction + property alias reloadAll: reloadAllAction + property alias arrangeAllBuildPlates: arrangeAllBuildPlatesAction + property alias arrangeAll: arrangeAllAction + property alias arrangeSelection: arrangeSelectionAction + property alias resetAllTranslation: resetAllTranslationAction + property alias resetAll: resetAllAction - property alias addMachine: addMachineAction; - property alias configureMachines: settingsAction; - property alias addProfile: addProfileAction; - property alias updateProfile: updateProfileAction; - property alias resetProfile: resetProfileAction; - property alias manageProfiles: manageProfilesAction; + property alias addMachine: addMachineAction + property alias configureMachines: settingsAction + property alias addProfile: addProfileAction + property alias updateProfile: updateProfileAction + property alias resetProfile: resetProfileAction + property alias manageProfiles: manageProfilesAction - property alias manageMaterials: manageMaterialsAction; - property alias marketplaceMaterials: marketplaceMaterialsAction; + property alias manageMaterials: manageMaterialsAction + property alias marketplaceMaterials: marketplaceMaterialsAction - property alias preferences: preferencesAction; + property alias preferences: preferencesAction - property alias showProfileFolder: showProfileFolderAction; - property alias documentation: documentationAction; + property alias showProfileFolder: showProfileFolderAction + property alias documentation: documentationAction property alias showTroubleshooting: showTroubleShootingAction - property alias reportBug: reportBugAction; + property alias reportBug: reportBugAction property alias whatsNew: whatsNewAction - property alias about: aboutAction; + property alias about: aboutAction - property alias toggleFullScreen: toggleFullScreenAction; + property alias toggleFullScreen: toggleFullScreenAction property alias exitFullScreen: exitFullScreenAction property alias configureSettingVisibility: configureSettingVisibilityAction @@ -80,7 +79,7 @@ Item { id: showTroubleShootingAction onTriggered: Qt.openUrlExternally("https://ultimaker.com/en/troubleshooting?utm_source=cura&utm_medium=software&utm_campaign=dropdown-troubleshooting") - text: catalog.i18nc("@action:inmenu", "Show Online Troubleshooting Guide"); + text: catalog.i18nc("@action:inmenu", "Show Online Troubleshooting Guide") } Action @@ -88,7 +87,7 @@ Item id: toggleFullScreenAction shortcut: StandardKey.FullScreen text: catalog.i18nc("@action:inmenu", "Toggle Full Screen") - iconName: "view-fullscreen" + icon.name: "view-fullscreen" } Action @@ -96,27 +95,27 @@ Item id: exitFullScreenAction shortcut: StandardKey.Cancel text: catalog.i18nc("@action:inmenu", "Exit Full Screen") - iconName: "view-fullscreen" + icon.name: "view-fullscreen" } Action { - id: undoAction; - text: catalog.i18nc("@action:inmenu menubar:edit", "&Undo"); - iconName: "edit-undo"; - shortcut: StandardKey.Undo; - onTriggered: UM.OperationStack.undo(); - enabled: UM.OperationStack.canUndo; + id: undoAction + text: catalog.i18nc("@action:inmenu menubar:edit", "&Undo") + icon.name: "edit-undo" + shortcut: StandardKey.Undo + onTriggered: UM.OperationStack.undo() + enabled: UM.OperationStack.canUndo } Action { - id: redoAction; - text: catalog.i18nc("@action:inmenu menubar:edit", "&Redo"); - iconName: "edit-redo"; - shortcut: StandardKey.Redo; - onTriggered: UM.OperationStack.redo(); - enabled: UM.OperationStack.canRedo; + id: redoAction + text: catalog.i18nc("@action:inmenu menubar:edit", "&Redo") + icon.name: "edit-redo" + shortcut: StandardKey.Redo + onTriggered: UM.OperationStack.redo() + enabled: UM.OperationStack.canRedo } Action @@ -131,7 +130,7 @@ Item //- https://doc.qt.io/qt-5/macos-issues.html#menu-bar //- https://doc.qt.io/qt-5/qmenubar.html#qmenubar-as-a-global-menu-bar text: (Qt.platform.os == "osx") ? "&Quit" : catalog.i18nc("@action:inmenu menubar:file", "&Quit") - iconName: "application-exit" + icon.name: "application-exit" shortcut: StandardKey.Quit } @@ -188,7 +187,7 @@ Item //- https://doc.qt.io/qt-5/macos-issues.html#menu-bar //- https://doc.qt.io/qt-5/qmenubar.html#qmenubar-as-a-global-menu-bar text: (Qt.platform.os == "osx") ? "Configure Cura..." : catalog.i18nc("@action:inmenu", "Configure Cura...") - iconName: "configure" + icon.name: "configure" } Action @@ -201,14 +200,14 @@ Item { id: settingsAction text: catalog.i18nc("@action:inmenu menubar:printer", "Manage Pr&inters...") - iconName: "configure" + icon.name: "configure" } Action { id: manageMaterialsAction text: catalog.i18nc("@action:inmenu", "Manage Materials...") - iconName: "configure" + icon.name: "configure" shortcut: "Ctrl+K" } @@ -220,64 +219,64 @@ Item Action { - id: updateProfileAction; + id: updateProfileAction enabled: !Cura.MachineManager.stacksHaveErrors && Cura.MachineManager.hasUserSettings && Cura.MachineManager.activeQualityChangesGroup != null - text: catalog.i18nc("@action:inmenu menubar:profile","&Update profile with current settings/overrides"); - onTriggered: Cura.ContainerManager.updateQualityChanges(); + text: catalog.i18nc("@action:inmenu menubar:profile","&Update profile with current settings/overrides") + onTriggered: Cura.ContainerManager.updateQualityChanges() } Action { - id: resetProfileAction; + id: resetProfileAction enabled: Cura.MachineManager.hasUserSettings - text: catalog.i18nc("@action:inmenu menubar:profile", "&Discard current changes"); + text: catalog.i18nc("@action:inmenu menubar:profile", "&Discard current changes") onTriggered: { - forceActiveFocus(); - Cura.ContainerManager.clearUserContainers(); + forceActiveFocus() + Cura.ContainerManager.clearUserContainers() } } Action { - id: addProfileAction; + id: addProfileAction enabled: !Cura.MachineManager.stacksHaveErrors && Cura.MachineManager.hasUserSettings - text: catalog.i18nc("@action:inmenu menubar:profile", "&Create profile from current settings/overrides..."); + text: catalog.i18nc("@action:inmenu menubar:profile", "&Create profile from current settings/overrides...") } Action { id: manageProfilesAction text: catalog.i18nc("@action:inmenu menubar:profile", "Manage Profiles...") - iconName: "configure" + icon.name: "configure" shortcut: "Ctrl+J" } Action { - id: documentationAction; - text: catalog.i18nc("@action:inmenu menubar:help", "Show Online &Documentation"); - iconName: "help-contents"; - shortcut: StandardKey.Help; - onTriggered: CuraActions.openDocumentation(); + id: documentationAction + text: catalog.i18nc("@action:inmenu menubar:help", "Show Online &Documentation") + icon.name: "help-contents" + shortcut: StandardKey.Help + onTriggered: CuraActions.openDocumentation() } Action { - id: reportBugAction; - text: catalog.i18nc("@action:inmenu menubar:help", "Report a &Bug"); - iconName: "tools-report-bug"; - onTriggered: CuraActions.openBugReportPage(); + id: reportBugAction + text: catalog.i18nc("@action:inmenu menubar:help", "Report a &Bug") + icon.name: "tools-report-bug" + onTriggered: CuraActions.openBugReportPage() } Action { - id: whatsNewAction; - text: catalog.i18nc("@action:inmenu menubar:help", "What's New"); + id: whatsNewAction + text: catalog.i18nc("@action:inmenu menubar:help", "What's New") } Action { - id: aboutAction; + id: aboutAction //On MacOS, don't translate the "About" word. //Qt moves the "about" entry to a different place, and if it got renamed can't find it again when it @@ -286,60 +285,60 @@ Item //For more information, see: //- https://doc.qt.io/qt-5/macos-issues.html#menu-bar //- https://doc.qt.io/qt-5/qmenubar.html#qmenubar-as-a-global-menu-bar - text: (Qt.platform.os == "osx") ? "About..." : catalog.i18nc("@action:inmenu menubar:help", "About..."); - iconName: "help-about"; + text: (Qt.platform.os == "osx") ? "About..." : catalog.i18nc("@action:inmenu menubar:help", "About...") + icon.name: "help-about" } Action { - id: deleteSelectionAction; - text: catalog.i18nc("@action:inmenu menubar:edit", "Delete Selected"); - enabled: UM.Controller.toolsEnabled && UM.Selection.hasSelection; - iconName: "edit-delete"; + id: deleteSelectionAction + text: catalog.i18nc("@action:inmenu menubar:edit", "Delete Selected") + enabled: UM.Controller.toolsEnabled && UM.Selection.hasSelection + icon.name: "edit-delete" shortcut: StandardKey.Delete | "Backspace" - onTriggered: CuraActions.deleteSelection(); + onTriggered: CuraActions.deleteSelection() } Action { - id: centerSelectionAction; - text: catalog.i18nc("@action:inmenu menubar:edit", "Center Selected"); - enabled: UM.Controller.toolsEnabled && UM.Selection.hasSelection; - iconName: "align-vertical-center"; - onTriggered: CuraActions.centerSelection(); + id: centerSelectionAction + text: catalog.i18nc("@action:inmenu menubar:edit", "Center Selected") + enabled: UM.Controller.toolsEnabled && UM.Selection.hasSelection + icon.name: "align-vertical-center" + onTriggered: CuraActions.centerSelection() } Action { - id: multiplySelectionAction; - text: catalog.i18nc("@action:inmenu menubar:edit", "Multiply Selected"); - enabled: UM.Controller.toolsEnabled && UM.Selection.hasSelection; - iconName: "edit-duplicate"; + id: multiplySelectionAction + text: catalog.i18nc("@action:inmenu menubar:edit", "Multiply Selected") + enabled: UM.Controller.toolsEnabled && UM.Selection.hasSelection + icon.name: "edit-duplicate" shortcut: "Ctrl+M" } Action { - id: deleteObjectAction; - text: catalog.i18nc("@action:inmenu","Delete Model"); - enabled: UM.Controller.toolsEnabled; - iconName: "edit-delete"; + id: deleteObjectAction + text: catalog.i18nc("@action:inmenu","Delete Model") + enabled: UM.Controller.toolsEnabled + icon.name: "edit-delete" } Action { - id: centerObjectAction; - text: catalog.i18nc("@action:inmenu","Ce&nter Model on Platform"); + id: centerObjectAction + text: catalog.i18nc("@action:inmenu","Ce&nter Model on Platform") } Action { id: groupObjectsAction - text: catalog.i18nc("@action:inmenu menubar:edit","&Group Models"); + text: catalog.i18nc("@action:inmenu menubar:edit","&Group Models") enabled: UM.Selection.selectionCount > 1 ? true: false - iconName: "object-group" - shortcut: "Ctrl+G"; - onTriggered: CuraApplication.groupSelected(); + icon.name: "object-group" + shortcut: "Ctrl+G" + onTriggered: CuraApplication.groupSelected() } Action @@ -355,132 +354,132 @@ Item Action { id: unGroupObjectsAction - text: catalog.i18nc("@action:inmenu menubar:edit","Ungroup Models"); + text: catalog.i18nc("@action:inmenu menubar:edit","Ungroup Models") enabled: UM.Selection.isGroupSelected - iconName: "object-ungroup" - shortcut: "Ctrl+Shift+G"; - onTriggered: CuraApplication.ungroupSelected(); + icon.name: "object-ungroup" + shortcut: "Ctrl+Shift+G" + onTriggered: CuraApplication.ungroupSelected() } Action { id: mergeObjectsAction - text: catalog.i18nc("@action:inmenu menubar:edit","&Merge Models"); + text: catalog.i18nc("@action:inmenu menubar:edit","&Merge Models") enabled: UM.Selection.selectionCount > 1 ? true: false - iconName: "merge"; - shortcut: "Ctrl+Alt+G"; - onTriggered: CuraApplication.mergeSelected(); + icon.name: "merge" + shortcut: "Ctrl+Alt+G" + onTriggered: CuraApplication.mergeSelected() } Action { - id: multiplyObjectAction; - text: catalog.i18nc("@action:inmenu","&Multiply Model..."); - iconName: "edit-duplicate" + id: multiplyObjectAction + text: catalog.i18nc("@action:inmenu","&Multiply Model...") + icon.name: "edit-duplicate" } Action { - id: selectAllAction; - text: catalog.i18nc("@action:inmenu menubar:edit","Select All Models"); - enabled: UM.Controller.toolsEnabled; - iconName: "edit-select-all"; - shortcut: "Ctrl+A"; - onTriggered: CuraApplication.selectAll(); + id: selectAllAction + text: catalog.i18nc("@action:inmenu menubar:edit","Select All Models") + enabled: UM.Controller.toolsEnabled + icon.name: "edit-select-all" + shortcut: "Ctrl+A" + onTriggered: CuraApplication.selectAll() } Action { - id: deleteAllAction; - text: catalog.i18nc("@action:inmenu menubar:edit","Clear Build Plate"); - enabled: UM.Controller.toolsEnabled; - iconName: "edit-delete"; - shortcut: "Ctrl+D"; - onTriggered: CuraApplication.deleteAll(); + id: deleteAllAction + text: catalog.i18nc("@action:inmenu menubar:edit","Clear Build Plate") + enabled: UM.Controller.toolsEnabled + icon.name: "edit-delete" + shortcut: "Ctrl+D" + onTriggered: CuraApplication.deleteAll() } Action { - id: reloadAllAction; - text: catalog.i18nc("@action:inmenu menubar:file","Reload All Models"); - iconName: "document-revert"; + id: reloadAllAction + text: catalog.i18nc("@action:inmenu menubar:file","Reload All Models") + icon.name: "document-revert" shortcut: "F5" - onTriggered: CuraApplication.reloadAll(); + onTriggered: CuraApplication.reloadAll() } Action { - id: arrangeAllBuildPlatesAction; - text: catalog.i18nc("@action:inmenu menubar:edit","Arrange All Models To All Build Plates"); - onTriggered: Printer.arrangeObjectsToAllBuildPlates(); + id: arrangeAllBuildPlatesAction + text: catalog.i18nc("@action:inmenu menubar:edit","Arrange All Models To All Build Plates") + onTriggered: Printer.arrangeObjectsToAllBuildPlates() } Action { - id: arrangeAllAction; - text: catalog.i18nc("@action:inmenu menubar:edit","Arrange All Models"); - onTriggered: Printer.arrangeAll(); - shortcut: "Ctrl+R"; + id: arrangeAllAction + text: catalog.i18nc("@action:inmenu menubar:edit","Arrange All Models") + onTriggered: Printer.arrangeAll() + shortcut: "Ctrl+R" } Action { - id: arrangeSelectionAction; - text: catalog.i18nc("@action:inmenu menubar:edit","Arrange Selection"); - onTriggered: Printer.arrangeSelection(); + id: arrangeSelectionAction + text: catalog.i18nc("@action:inmenu menubar:edit","Arrange Selection") + onTriggered: Printer.arrangeSelection() } Action { - id: resetAllTranslationAction; - text: catalog.i18nc("@action:inmenu menubar:edit","Reset All Model Positions"); - onTriggered: CuraApplication.resetAllTranslation(); + id: resetAllTranslationAction + text: catalog.i18nc("@action:inmenu menubar:edit","Reset All Model Positions") + onTriggered: CuraApplication.resetAllTranslation() } Action { - id: resetAllAction; - text: catalog.i18nc("@action:inmenu menubar:edit","Reset All Model Transformations"); - onTriggered: CuraApplication.resetAll(); + id: resetAllAction + text: catalog.i18nc("@action:inmenu menubar:edit","Reset All Model Transformations") + onTriggered: CuraApplication.resetAll() } Action { - id: openAction; + id: openAction property var fileProviderModel: CuraApplication.getFileProviderModel() - text: catalog.i18nc("@action:inmenu menubar:file","&Open File(s)..."); - iconName: "document-open"; + text: catalog.i18nc("@action:inmenu menubar:file","&Open File(s)...") + icon.name: "document-open" // Unassign the shortcut when there are more than one file providers, since then the file provider's shortcut is // enabled instead, and Ctrl+O is assigned to the local file provider - shortcut: fileProviderModel.count == 1 ? StandardKey.Open : ""; + shortcut: fileProviderModel.count == 1 ? StandardKey.Open : "" } Action { id: newProjectAction - text: catalog.i18nc("@action:inmenu menubar:file","&New Project..."); + text: catalog.i18nc("@action:inmenu menubar:file","&New Project...") shortcut: StandardKey.New } Action { - id: showProfileFolderAction; - text: catalog.i18nc("@action:inmenu menubar:help","Show Configuration Folder"); + id: showProfileFolderAction + text: catalog.i18nc("@action:inmenu menubar:help","Show Configuration Folder") } Action { id: configureSettingVisibilityAction - text: catalog.i18nc("@action:menu", "Configure setting visibility..."); - iconName: "configure" + text: catalog.i18nc("@action:menu", "Configure setting visibility...") + icon.name: "configure" } Action { id: browsePackagesAction text: catalog.i18nc("@action:menu", "&Marketplace") - iconName: "plugins_browse" + icon.name: "plugins_browse" } } diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index f1fa4ed506..f959e62977 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -6,8 +6,8 @@ import QtQuick.Controls 1.4 import QtQuick.Layouts 1.1 import QtQuick.Dialogs 1.2 import QtGraphicalEffects 1.0 - -import UM 1.3 as UM +import QtQuick.Controls 2.15 as NewControls +import UM 1.5 as UM import Cura 1.1 as Cura import "Dialogs" @@ -160,7 +160,6 @@ UM.MainWindow ApplicationMenu { id: applicationMenu - window: base } Item diff --git a/resources/qml/MainWindow/ApplicationMenu.qml b/resources/qml/MainWindow/ApplicationMenu.qml index 5e1c80cd17..cb84e8be37 100644 --- a/resources/qml/MainWindow/ApplicationMenu.qml +++ b/resources/qml/MainWindow/ApplicationMenu.qml @@ -2,11 +2,10 @@ // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.7 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.4 import QtQuick.Dialogs 1.2 -import UM 1.3 as UM +import UM 1.5 as UM import Cura 1.1 as Cura import "../Menus" @@ -17,13 +16,48 @@ Item id: menu width: applicationMenu.width height: applicationMenu.height - property alias window: applicationMenu.window - UM.ApplicationMenu + Component + { + id: menuBarComponent + MenuBarItem + { + id: menuBarItem + + function replaceText(txt) + { + var index = txt.indexOf("&") + if(index >= 0) + { + txt = txt.replace(txt.substr(index, 2), ("" + txt.substr(index + 1, 1) +"")) + } + return txt + } + + contentItem: Label { + text: replaceText(menuBarItem.text) + color: "white" + verticalAlignment: Text.AlignVCenter + textFormat: Text.RichText + } + } + } + + MenuBar + { + id: applicationMenu + delegate: menuBarComponent + FileMenu {} + + EditMenu {} + ViewMenu {} + } + + /*UM.ApplicationMenu { id: applicationMenu - FileMenu { title: catalog.i18nc("@title:menu menubar:toplevel", "&File") } + //FileMenu { title: catalog.i18nc("@title:menu menubar:toplevel", "&File") } Menu { @@ -126,9 +160,10 @@ Item MenuItem { action: Cura.Actions.whatsNew } MenuItem { action: Cura.Actions.about } } - } + }*/ - Component + + /*Component { id: extensionsMenuItem @@ -214,5 +249,5 @@ Item curaExtensions.callExtensionMethod("Toolbox", "launch") curaExtensions.callExtensionMethod("Toolbox", "setViewCategoryToMaterials") } - } + }*/ } \ No newline at end of file diff --git a/resources/qml/Menus/EditMenu.qml b/resources/qml/Menus/EditMenu.qml new file mode 100644 index 0000000000..813b000aa6 --- /dev/null +++ b/resources/qml/Menus/EditMenu.qml @@ -0,0 +1,28 @@ +// Copyright (c) 2022 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.2 +import QtQuick.Controls 2.1 + +import UM 1.6 as UM +import Cura 1.0 as Cura + +Menu +{ + title: catalog.i18nc("@title:menu menubar:toplevel", "&Edit") + + UM.MenuItem { action: Cura.Actions.undo } + UM.MenuItem { action: Cura.Actions.redo } + MenuSeparator { } + UM.MenuItem { action: Cura.Actions.selectAll } + UM.MenuItem { action: Cura.Actions.arrangeAll } + UM.MenuItem { action: Cura.Actions.multiplySelection } + UM.MenuItem { action: Cura.Actions.deleteSelection } + UM.MenuItem { action: Cura.Actions.deleteAll } + UM.MenuItem { action: Cura.Actions.resetAllTranslation } + UM.MenuItem { action: Cura.Actions.resetAll } + MenuSeparator { } + UM.MenuItem { action: Cura.Actions.groupObjects } + UM.MenuItem { action: Cura.Actions.mergeObjects } + UM.MenuItem { action: Cura.Actions.unGroupObjects } +} \ No newline at end of file diff --git a/resources/qml/Menus/FileMenu.qml b/resources/qml/Menus/FileMenu.qml index 681e0b06ce..a1a2d1aaec 100644 --- a/resources/qml/Menus/FileMenu.qml +++ b/resources/qml/Menus/FileMenu.qml @@ -1,8 +1,8 @@ -// Copyright (c) 2018 Ultimaker B.V. +// Copyright (c) 2022 Ultimaker B.V. // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.2 -import QtQuick.Controls 1.1 +import QtQuick.Controls 2.1 import UM 1.6 as UM import Cura 1.0 as Cura @@ -13,31 +13,34 @@ Menu title: catalog.i18nc("@title:menu menubar:toplevel", "&File") property var fileProviderModel: CuraApplication.getFileProviderModel() - MenuItem + + UM.MenuItem { id: newProjectMenu action: Cura.Actions.newProject } - MenuItem + UM.MenuItem { id: openMenu action: Cura.Actions.open - visible: (base.fileProviderModel.count == 1) + visible: base.fileProviderModel.count == 1 + height: visible ? implicitHeight: 0 } OpenFilesMenu { id: openFilesMenu - visible: (base.fileProviderModel.count > 1) + + shouldBeVisible: base.fileProviderModel.count > 1 } RecentFilesMenu { } - MenuItem + UM.MenuItem { id: saveWorkspaceMenu - shortcut: visible ? StandardKey.Save : "" + shortcut: StandardKey.Save text: catalog.i18nc("@title:menu menubar:file", "&Save Project...") visible: saveProjectMenu.model.count == 1 enabled: UM.WorkspaceFileHandler.enabled @@ -62,13 +65,13 @@ Menu { id: saveProjectMenu model: projectOutputDevicesModel - visible: model.count > 1 + shouldBeVisible: model.count > 1 enabled: UM.WorkspaceFileHandler.enabled } MenuSeparator { } - MenuItem + UM.MenuItem { id: saveAsMenu text: catalog.i18nc("@title:menu menubar:file", "&Export...") @@ -79,18 +82,18 @@ Menu } } - MenuItem + UM.MenuItem { id: exportSelectionMenu text: catalog.i18nc("@action:inmenu menubar:file", "Export Selection...") enabled: UM.Selection.hasSelection - iconName: "document-save-as" + icon.name: "document-save-as" onTriggered: UM.OutputDeviceManager.requestWriteSelectionToDevice("local_file", PrintInformation.jobName, { "filter_by_machine": false, "preferred_mimetypes": "application/vnd.ms-package.3dmanufacturing-3dmodel+xml"}) } MenuSeparator { } - MenuItem + UM.MenuItem { id: reloadAllMenu action: Cura.Actions.reloadAll @@ -98,5 +101,5 @@ Menu MenuSeparator { } - MenuItem { action: Cura.Actions.quit } + UM.MenuItem { action: Cura.Actions.quit } } diff --git a/resources/qml/Menus/OpenFilesMenu.qml b/resources/qml/Menus/OpenFilesMenu.qml index 25f474c1d6..0b6019c18d 100644 --- a/resources/qml/Menus/OpenFilesMenu.qml +++ b/resources/qml/Menus/OpenFilesMenu.qml @@ -1,25 +1,24 @@ -// Copyright (c) 2020 Ultimaker B.V. +// Copyright (c) 2022 Ultimaker B.V. // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.2 -import QtQuick.Controls 1.1 +import QtQuick.Controls 2.1 import UM 1.6 as UM import Cura 1.0 as Cura import "../Dialogs" -Menu +UM.Menu { id: openFilesMenu title: catalog.i18nc("@title:menu menubar:file", "Open File(s)...") - iconName: "document-open-recent"; Instantiator { id: fileProviders model: CuraApplication.getFileProviderModel() - MenuItem + UM.MenuItem { text: { @@ -39,6 +38,7 @@ Menu // Unassign the shortcuts when the submenu is invisible (i.e. when there is only one file provider) to avoid ambiguous shortcuts. // When there is a single file provider, the openAction is assigned with the Ctrl+O shortcut instead. shortcut: openFilesMenu.visible ? model.shortcut : "" + visible: openFilesMenu.visible } onObjectAdded: openFilesMenu.insertItem(index, object) onObjectRemoved: openFilesMenu.removeItem(object) diff --git a/resources/qml/Menus/RecentFilesMenu.qml b/resources/qml/Menus/RecentFilesMenu.qml index de6d2e3817..24874c4365 100644 --- a/resources/qml/Menus/RecentFilesMenu.qml +++ b/resources/qml/Menus/RecentFilesMenu.qml @@ -1,8 +1,8 @@ -// Copyright (c) 2021 Ultimaker B.V. +// Copyright (c) 2022 Ultimaker B.V. // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.2 -import QtQuick.Controls 1.1 +import QtQuick.Controls 2.1 import UM 1.3 as UM import Cura 1.0 as Cura @@ -13,7 +13,7 @@ Menu { id: menu title: catalog.i18nc("@title:menu menubar:file", "Open &Recent") - iconName: "document-open-recent"; + //iconName: "document-open-recent"; enabled: CuraApplication.recentFiles.length > 0; diff --git a/resources/qml/Menus/SaveProjectMenu.qml b/resources/qml/Menus/SaveProjectMenu.qml index afc6008717..3b7c3b9c01 100644 --- a/resources/qml/Menus/SaveProjectMenu.qml +++ b/resources/qml/Menus/SaveProjectMenu.qml @@ -1,15 +1,15 @@ -// Copyright (c) 2021 Ultimaker B.V. +// Copyright (c) 2022 Ultimaker B.V. // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.2 -import QtQuick.Controls 1.1 +import QtQuick.Controls 2.1 import UM 1.6 as UM import Cura 1.1 as Cura import "../Dialogs" -Menu +UM.Menu { id: saveProjectMenu title: catalog.i18nc("@title:menu menubar:file", "Save Project...") @@ -18,7 +18,7 @@ Menu Instantiator { id: projectOutputDevices - MenuItem + UM.MenuItem { text: model.name onTriggered: diff --git a/resources/qml/Menus/ViewMenu.qml b/resources/qml/Menus/ViewMenu.qml index c46e9a9f08..f382958c1f 100644 --- a/resources/qml/Menus/ViewMenu.qml +++ b/resources/qml/Menus/ViewMenu.qml @@ -2,33 +2,34 @@ // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.2 -import QtQuick.Controls 1.1 +import QtQuick.Controls 2.1 -import UM 1.2 as UM +import UM 1.5 as UM import Cura 1.0 as Cura Menu { - title: catalog.i18nc("@title:menu menubar:toplevel", "&View") id: base - - property var multiBuildPlateModel: CuraApplication.getMultiBuildPlateModel() + title: catalog.i18nc("@title:menu menubar:toplevel", "&View") Menu { - title: catalog.i18nc("@action:inmenu menubar:view","&Camera position"); - MenuItem { action: Cura.Actions.view3DCamera; } - MenuItem { action: Cura.Actions.viewFrontCamera; } - MenuItem { action: Cura.Actions.viewTopCamera; } - MenuItem { action: Cura.Actions.viewBottomCamera; } - MenuItem { action: Cura.Actions.viewLeftSideCamera; } - MenuItem { action: Cura.Actions.viewRightSideCamera; } + title: catalog.i18nc("@action:inmenu menubar:view", "&Camera position") + UM.MenuItem { action: Cura.Actions.view3DCamera } + UM.MenuItem { action: Cura.Actions.viewFrontCamera } + UM.MenuItem { action: Cura.Actions.viewTopCamera } + UM.MenuItem { action: Cura.Actions.viewBottomCamera } + UM.MenuItem { action: Cura.Actions.viewLeftSideCamera } + UM.MenuItem { action: Cura.Actions.viewRightSideCamera } } Menu { id: cameraViewMenu + + title: catalog.i18nc("@action:inmenu menubar:view","Camera view") property string cameraMode: UM.Preferences.getValue("general/camera_perspective_mode") + Connections { target: UM.Preferences @@ -42,7 +43,6 @@ Menu } } - title: catalog.i18nc("@action:inmenu menubar:view","Camera view") MenuItem { text: catalog.i18nc("@action:inmenu menubar:view", "Perspective") @@ -52,8 +52,9 @@ Menu { UM.Preferences.setValue("general/camera_perspective_mode", "perspective") } - exclusiveGroup: group + //exclusiveGroup: group } + MenuItem { text: catalog.i18nc("@action:inmenu menubar:view", "Orthographic") @@ -63,45 +64,14 @@ Menu { UM.Preferences.setValue("general/camera_perspective_mode", "orthographic") } - exclusiveGroup: group - } - ExclusiveGroup { id: group } - } - - MenuSeparator - { - visible: UM.Preferences.getValue("cura/use_multi_build_plate") - } - - Menu - { - id: buildPlateMenu; - title: catalog.i18nc("@action:inmenu menubar:view","&Build plate") - visible: UM.Preferences.getValue("cura/use_multi_build_plate") - Instantiator - { - model: base.multiBuildPlateModel - MenuItem - { - text: base.multiBuildPlateModel.getItem(index).name; - onTriggered: Cura.SceneController.setActiveBuildPlate(base.multiBuildPlateModel.getItem(index).buildPlateNumber) - checkable: true - checked: base.multiBuildPlateModel.getItem(index).buildPlateNumber == base.multiBuildPlateModel.activeBuildPlate - exclusiveGroup: buildPlateGroup - visible: UM.Preferences.getValue("cura/use_multi_build_plate") - } - onObjectAdded: buildPlateMenu.insertItem(index, object) - onObjectRemoved: buildPlateMenu.removeItem(object) - } - ExclusiveGroup - { - id: buildPlateGroup + //exclusiveGroup: group } + //ExclusiveGroup { id: group } } MenuSeparator {} - MenuItem + UM.MenuItem { action: Cura.Actions.toggleFullScreen } From 770f6f94c93a5742c7fa9a08ea2140b5bb75c837 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 10 Jan 2022 17:00:26 +0100 Subject: [PATCH 02/16] Remove exclusive group comments CURA-8683 --- resources/qml/Menus/ViewMenu.qml | 3 --- 1 file changed, 3 deletions(-) diff --git a/resources/qml/Menus/ViewMenu.qml b/resources/qml/Menus/ViewMenu.qml index f382958c1f..0b6489bf9a 100644 --- a/resources/qml/Menus/ViewMenu.qml +++ b/resources/qml/Menus/ViewMenu.qml @@ -52,7 +52,6 @@ Menu { UM.Preferences.setValue("general/camera_perspective_mode", "perspective") } - //exclusiveGroup: group } MenuItem @@ -64,9 +63,7 @@ Menu { UM.Preferences.setValue("general/camera_perspective_mode", "orthographic") } - //exclusiveGroup: group } - //ExclusiveGroup { id: group } } MenuSeparator {} From 2bad5c5cd32f400ab017f55d6b9c114505eabf59 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 11 Jan 2022 10:31:39 +0100 Subject: [PATCH 03/16] Update the settings menu to controls 2 CURA-8683 --- resources/qml/MainWindow/ApplicationMenu.qml | 13 +++ resources/qml/Menus/LocalPrinterMenu.qml | 25 ------ resources/qml/Menus/MaterialMenu.qml | 46 +++++------ resources/qml/Menus/NetworkPrinterMenu.qml | 32 -------- resources/qml/Menus/NozzleMenu.qml | 31 ++++--- resources/qml/Menus/PrinterMenu.qml | 85 +++++++++++++------- resources/qml/Menus/SettingsMenu.qml | 28 ++++--- resources/qml/Widgets/MenuItem.qml | 1 + 8 files changed, 121 insertions(+), 140 deletions(-) delete mode 100644 resources/qml/Menus/LocalPrinterMenu.qml delete mode 100644 resources/qml/Menus/NetworkPrinterMenu.qml diff --git a/resources/qml/MainWindow/ApplicationMenu.qml b/resources/qml/MainWindow/ApplicationMenu.qml index cb84e8be37..3689c0c457 100644 --- a/resources/qml/MainWindow/ApplicationMenu.qml +++ b/resources/qml/MainWindow/ApplicationMenu.qml @@ -51,6 +51,19 @@ Item EditMenu {} ViewMenu {} + + SettingsMenu + { + //On MacOS, don't translate the "Settings" word. + //Qt moves the "settings" entry to a different place, and if it got renamed can't find it again when it + //attempts to delete the item upon closing the application, causing a crash. + //In the new location, these items are translated automatically according to the system's language. + //For more information, see: + //- https://doc.qt.io/qt-5/macos-issues.html#menu-bar + //- https://doc.qt.io/qt-5/qmenubar.html#qmenubar-as-a-global-menu-bar + title: (Qt.platform.os == "osx") ? "&Settings" : catalog.i18nc("@title:menu menubar:toplevel", "&Settings") + } + } /*UM.ApplicationMenu diff --git a/resources/qml/Menus/LocalPrinterMenu.qml b/resources/qml/Menus/LocalPrinterMenu.qml deleted file mode 100644 index bd6c57d744..0000000000 --- a/resources/qml/Menus/LocalPrinterMenu.qml +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2018 Ultimaker B.V. -// Cura is released under the terms of the LGPLv3 or higher. - -import QtQuick 2.2 -import QtQuick.Controls 1.4 - -import UM 1.2 as UM -import Cura 1.0 as Cura - -Instantiator -{ - model: Cura.GlobalStacksModel {} - - MenuItem - { - text: model.name - checkable: true - checked: Cura.MachineManager.activeMachine !== null ? Cura.MachineManager.activeMachine.id == model.id: false - exclusiveGroup: group - visible: !model.hasRemoteConnection - onTriggered: Cura.MachineManager.setActiveMachine(model.id) - } - onObjectAdded: menu.insertItem(index, object) - onObjectRemoved: menu.removeItem(object) -} diff --git a/resources/qml/Menus/MaterialMenu.qml b/resources/qml/Menus/MaterialMenu.qml index b4f15fad00..b21cbbdafd 100644 --- a/resources/qml/Menus/MaterialMenu.qml +++ b/resources/qml/Menus/MaterialMenu.qml @@ -1,13 +1,13 @@ -//Copyright (c) 2020 Ultimaker B.V. +//Copyright (c) 2022 Ultimaker B.V. //Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.7 -import QtQuick.Controls 1.4 +import QtQuick.Controls 2.4 -import UM 1.2 as UM +import UM 1.6 as UM import Cura 1.0 as Cura -Menu +UM.Menu { id: menu title: catalog.i18nc("@label:category menu label", "Material") @@ -49,23 +49,24 @@ Menu enabled: updateModels } - MenuItem + UM.MenuItem { text: catalog.i18nc("@label:category menu label", "Favorites") enabled: false visible: favoriteMaterialsModel.items.length > 0 + height: visible ? implicitHeight: 0 } + Instantiator { model: favoriteMaterialsModel - delegate: MenuItem + delegate: UM.MenuItem { text: model.brand + " " + model.name checkable: true enabled: isActiveExtruderEnabled checked: model.root_material_id === menu.currentRootMaterialId onTriggered: Cura.MachineManager.setMaterial(extruderIndex, model.container_node) - exclusiveGroup: favoriteGroup // One favorite and one item from the others can be active at the same time. } onObjectAdded: menu.insertItem(index, object) onObjectRemoved: menu.removeItem(index) @@ -81,13 +82,12 @@ Menu Instantiator { model: genericMaterialsModel - delegate: MenuItem + delegate: UM.MenuItem { text: model.name checkable: true enabled: isActiveExtruderEnabled checked: model.root_material_id === menu.currentRootMaterialId - exclusiveGroup: group onTriggered: Cura.MachineManager.setMaterial(extruderIndex, model.container_node) } onObjectAdded: genericMenu.insertItem(index, object) @@ -100,7 +100,7 @@ Menu Instantiator { model: brandModel - Menu + UM.Menu { id: brandMenu title: brandName @@ -120,47 +120,37 @@ Menu Instantiator { model: brandMaterialColors - delegate: MenuItem + delegate: UM.MenuItem { text: model.name checkable: true enabled: isActiveExtruderEnabled checked: model.id === menu.activeMaterialId - exclusiveGroup: group + onTriggered: Cura.MachineManager.setMaterial(extruderIndex, model.container_node) } onObjectAdded: brandMaterialsMenu.insertItem(index, object) onObjectRemoved: brandMaterialsMenu.removeItem(object) } } - onObjectAdded: brandMenu.insertItem(index, object) - onObjectRemoved: brandMenu.removeItem(object) + onObjectAdded: brandMenu.insertMenu(index, object) + onObjectRemoved: brandMenu.removeMenu(object) } } - onObjectAdded: menu.insertItem(index, object) - onObjectRemoved: menu.removeItem(object) - } - - ExclusiveGroup - { - id: group - } - - ExclusiveGroup - { - id: favoriteGroup + onObjectAdded: menu.insertMenu(index, object) + onObjectRemoved: menu.removeMenu(object) } MenuSeparator {} - MenuItem + UM.MenuItem { action: Cura.Actions.manageMaterials } MenuSeparator {} - MenuItem + UM.MenuItem { action: Cura.Actions.marketplaceMaterials } diff --git a/resources/qml/Menus/NetworkPrinterMenu.qml b/resources/qml/Menus/NetworkPrinterMenu.qml deleted file mode 100644 index 845159f3b2..0000000000 --- a/resources/qml/Menus/NetworkPrinterMenu.qml +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2018 Ultimaker B.V. -// Cura is released under the terms of the LGPLv3 or higher. - -import QtQuick 2.2 -import QtQuick.Controls 1.4 - -import UM 1.2 as UM -import Cura 1.0 as Cura - -Instantiator -{ - model: Cura.GlobalStacksModel {} - MenuItem - { - property string connectGroupName: - { - if("group_name" in model.metadata) - { - return model.metadata["group_name"] - } - return "" - } - text: connectGroupName - checkable: true - visible: model.hasRemoteConnection - checked: Cura.MachineManager.activeMachineNetworkGroupName == connectGroupName - exclusiveGroup: group - onTriggered: Cura.MachineManager.setActiveMachine(model.id) - } - onObjectAdded: menu.insertItem(index, object) - onObjectRemoved: menu.removeItem(object) -} diff --git a/resources/qml/Menus/NozzleMenu.qml b/resources/qml/Menus/NozzleMenu.qml index 3ec48ab302..e2c5199211 100644 --- a/resources/qml/Menus/NozzleMenu.qml +++ b/resources/qml/Menus/NozzleMenu.qml @@ -1,15 +1,15 @@ -// Copyright (c) 2017 Ultimaker B.V. +// Copyright (c) 2022 Ultimaker B.V. // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.10 -import QtQuick.Controls 1.4 +import QtQuick.Controls 2.4 -import UM 1.2 as UM +import UM 1.5 as UM import Cura 1.0 as Cura -Menu +UM.Menu { - id: menu + id: nozzleMenu title: "Nozzle" property int extruderIndex: 0 @@ -23,12 +23,13 @@ Menu { model: nozzleModel - MenuItem + UM.MenuItem { text: model.hotend_name checkable: true - checked: { - var activeMachine = Cura.MachineManager.activeMachine + property var activeMachine: Cura.MachineManager.activeMachine + checked: + { if (activeMachine === null) { return false @@ -36,10 +37,8 @@ Menu var extruder = Cura.MachineManager.activeMachine.extruderList[extruderIndex] return (extruder === undefined) ? false : (extruder.variant.name == model.hotend_name) } - exclusiveGroup: group enabled: { - var activeMachine = Cura.MachineManager.activeMachine if (activeMachine === null) { return false @@ -47,14 +46,14 @@ Menu var extruder = Cura.MachineManager.activeMachine.extruderList[extruderIndex] return (extruder === undefined) ? false : extruder.isEnabled } - onTriggered: { - Cura.MachineManager.setVariant(menu.extruderIndex, model.container_node); - } + onTriggered:Cura.MachineManager.setVariant(nozzleMenu.extruderIndex, model.container_node) } - onObjectAdded: menu.insertItem(index, object); - onObjectRemoved: menu.removeItem(object); + onObjectAdded: + { + nozzleMenu.insertItem(index, object) + } + onObjectRemoved: nozzleMenu.removeItem(object) } - ExclusiveGroup { id: group } } diff --git a/resources/qml/Menus/PrinterMenu.qml b/resources/qml/Menus/PrinterMenu.qml index 98f72c128d..58c15201a2 100644 --- a/resources/qml/Menus/PrinterMenu.qml +++ b/resources/qml/Menus/PrinterMenu.qml @@ -1,60 +1,89 @@ -// Copyright (c) 2018 Ultimaker B.V. +// Copyright (c) 2022 Ultimaker B.V. // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.2 -import QtQuick.Controls 1.4 +import QtQuick.Controls 2.4 -import UM 1.2 as UM +import UM 1.6 as UM import Cura 1.0 as Cura Menu { id: menu -// TODO Enable custom style to the menu -// style: MenuStyle -// { -// frame: Rectangle -// { -// color: "white" -// } -// } - MenuItem + UM.MenuItem { + id: networkEnabledPrinterItem text: catalog.i18nc("@label:category menu label", "Network enabled printers") enabled: false - visible: networkPrinterMenu.count > 0 + visible: networKPrinterInstantiator.count > 0 } - NetworkPrinterMenu + Instantiator { - id: networkPrinterMenu + id: networKPrinterInstantiator + model: Cura.GlobalStacksModel {filterOnlineOnly: true} + UM.MenuItem + { + property string connectGroupName: + { + if("group_name" in model.metadata) + { + return model.metadata["group_name"] + } + return "" + } + text: connectGroupName + checkable: true + checked: Cura.MachineManager.activeMachineNetworkGroupName == connectGroupName + onTriggered: + { + print(typeof(model.id)) + Cura.MachineManager.someFunction("YAY") + Cura.MachineManager.setActiveMachine(model.id) + } + } + onObjectAdded: menu.insertItem(2, object) + onObjectRemoved: menu.removeItem(object) } MenuSeparator { - visible: networkPrinterMenu.count > 0 + visible: networKPrinterInstantiator.count > 0 } - MenuItem - { - text: catalog.i18nc("@label:category menu label", "Local printers") - enabled: false - visible: localPrinterMenu.count > 0 - } - - LocalPrinterMenu + UM.MenuItem { id: localPrinterMenu + text: catalog.i18nc("@label:category menu label", "Local printers") + enabled: false + visible: localPrinterInstantiator.count > 0 } - ExclusiveGroup { id: group; } + Instantiator + { + id: localPrinterInstantiator + model: Cura.GlobalStacksModel {} + + UM.MenuItem + { + text: model.name + checkable: true + checked: Cura.MachineManager.activeMachine !== null ? Cura.MachineManager.activeMachine.id == model.id: false + visible: !model.hasRemoteConnection + height: visible ? implicitHeight: 0 + onTriggered: Cura.MachineManager.setActiveMachine(model.id) + } + // A bit hackish, but we have 2 items at the end, put them before that + onObjectAdded: menu.insertItem(menu.count - 2, object) + onObjectRemoved: menu.removeItem(object) + } MenuSeparator { - visible: localPrinterMenu.count > 0 + visible: localPrinterInstantiator.count > 0 } - MenuItem { action: Cura.Actions.addMachine; } - MenuItem { action: Cura.Actions.configureMachines; } + UM.MenuItem { action: Cura.Actions.addMachine } + UM.MenuItem { action: Cura.Actions.configureMachines } } diff --git a/resources/qml/Menus/SettingsMenu.qml b/resources/qml/Menus/SettingsMenu.qml index 939ade5847..e25686f601 100644 --- a/resources/qml/Menus/SettingsMenu.qml +++ b/resources/qml/Menus/SettingsMenu.qml @@ -2,9 +2,9 @@ //Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.2 -import QtQuick.Controls 1.4 +import QtQuick.Controls 2.4 -import UM 1.2 as UM +import UM 1.5 as UM import Cura 1.0 as Cura Menu @@ -23,11 +23,16 @@ Menu { title: modelData.name property var extruder: (base.activeMachine === null) ? null : activeMachine.extruderList[model.index] - NozzleMenu { title: Cura.MachineManager.activeDefinitionVariantsName; visible: Cura.MachineManager.activeMachine.hasVariants; extruderIndex: index } + NozzleMenu + { + title: Cura.MachineManager.activeDefinitionVariantsName + shouldBeVisible: activeMachine.hasVariants + extruderIndex: index + } MaterialMenu { title: catalog.i18nc("@title:menu", "&Material") - visible: Cura.MachineManager.activeMachine.hasMaterials + shouldBeVisible: activeMachine.hasMaterials extruderIndex: index updateModels: false onAboutToShow: updateModels = true @@ -39,33 +44,34 @@ Menu visible: Cura.MachineManager.activeMachine.hasVariants || Cura.MachineManager.activeMachine.hasMaterials } - MenuItem + UM.MenuItem { text: catalog.i18nc("@action:inmenu", "Set as Active Extruder") onTriggered: Cura.ExtruderManager.setActiveExtruderIndex(model.index) } - MenuItem + UM.MenuItem { text: catalog.i18nc("@action:inmenu", "Enable Extruder") onTriggered: Cura.MachineManager.setExtruderEnabled(model.index, true) visible: (extruder === null || extruder === undefined) ? false : !extruder.isEnabled + height: visible ? implicitHeight: 0 } - MenuItem + UM.MenuItem { text: catalog.i18nc("@action:inmenu", "Disable Extruder") onTriggered: Cura.MachineManager.setExtruderEnabled(index, false) visible: (extruder === null || extruder === undefined) ? false : extruder.isEnabled enabled: Cura.MachineManager.numberExtrudersEnabled > 1 + height: visible ? implicitHeight: 0 } - } - onObjectAdded: base.insertItem(index, object) - onObjectRemoved: base.removeItem(object) + onObjectAdded: base.insertMenu(index, object) + onObjectRemoved: base.removeMenu(object) } MenuSeparator { } - MenuItem { action: Cura.Actions.configureSettingVisibility } + UM.MenuItem { action: Cura.Actions.configureSettingVisibility } } \ No newline at end of file diff --git a/resources/qml/Widgets/MenuItem.qml b/resources/qml/Widgets/MenuItem.qml index f0824b4d98..8861da1eac 100644 --- a/resources/qml/Widgets/MenuItem.qml +++ b/resources/qml/Widgets/MenuItem.qml @@ -15,6 +15,7 @@ MenuItem implicitHeight: UM.Theme.getSize("setting_control").height + UM.Theme.getSize("narrow_margin").height opacity: enabled ? 1.0 : 0.5 + height: visible ? implicitHeight: 0 arrow: UM.RecolorImage { From d1461c5d7f49889f1e13c60b6c41fe8579cd7bad Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 11 Jan 2022 11:07:12 +0100 Subject: [PATCH 04/16] Add extension menu to application menu CURA-8683 --- resources/qml/MainWindow/ApplicationMenu.qml | 2 + resources/qml/Menus/ExtensionMenu.qml | 64 ++++++++++++++++++++ resources/qml/Menus/MaterialMenu.qml | 6 +- 3 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 resources/qml/Menus/ExtensionMenu.qml diff --git a/resources/qml/MainWindow/ApplicationMenu.qml b/resources/qml/MainWindow/ApplicationMenu.qml index 3689c0c457..aa6fb803c3 100644 --- a/resources/qml/MainWindow/ApplicationMenu.qml +++ b/resources/qml/MainWindow/ApplicationMenu.qml @@ -64,6 +64,8 @@ Item title: (Qt.platform.os == "osx") ? "&Settings" : catalog.i18nc("@title:menu menubar:toplevel", "&Settings") } + ExtensionMenu {} + } /*UM.ApplicationMenu diff --git a/resources/qml/Menus/ExtensionMenu.qml b/resources/qml/Menus/ExtensionMenu.qml new file mode 100644 index 0000000000..0d4bc7c6e7 --- /dev/null +++ b/resources/qml/Menus/ExtensionMenu.qml @@ -0,0 +1,64 @@ +// Copyright (c) 2022 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.7 +import QtQuick.Controls 2.4 + +import UM 1.5 as UM +import Cura 1.0 as Cura + +UM.Menu +{ + id: extensionMenu + title: catalog.i18nc("@title:menu menubar:toplevel", "E&xtensions") + + Component + { + id: extensionsMenuItem + + UM.MenuItem + { + text: modelText + onTriggered: extensionsModel.subMenuTriggered(extensionName, modelText) + } + } + + Component + { + id: extensionsMenuSeparator + + MenuSeparator {} + } + + Instantiator + { + id: extensions + model: UM.ExtensionModel { } + + UM.Menu + { + id: sub_menu + title: model.name + shouldBeVisible: actions !== undefined + enabled: actions != null + Instantiator + { + model: actions + Loader + { + property var extensionsModel: extensions.model + property var modelText: model.text + property var extensionName: name + + sourceComponent: modelText.trim() == "" ? extensionsMenuSeparator : extensionsMenuItem + } + + onObjectAdded: sub_menu.insertItem(index, object.item) + onObjectRemoved: sub_menu.removeItem(object.item) + } + } + + onObjectAdded: extensionMenu.insertMenu(index, object) + onObjectRemoved: extensionMenu.removeMenu(object) + } +} \ No newline at end of file diff --git a/resources/qml/Menus/MaterialMenu.qml b/resources/qml/Menus/MaterialMenu.qml index b21cbbdafd..9a0c8e2c77 100644 --- a/resources/qml/Menus/MaterialMenu.qml +++ b/resources/qml/Menus/MaterialMenu.qml @@ -1,10 +1,10 @@ -//Copyright (c) 2022 Ultimaker B.V. -//Cura is released under the terms of the LGPLv3 or higher. +// Copyright (c) 2022 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.7 import QtQuick.Controls 2.4 -import UM 1.6 as UM +import UM 1.5 as UM import Cura 1.0 as Cura UM.Menu From 6cde2d028b796c203e58eb7c12d71ae33e7dd075 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 11 Jan 2022 11:10:12 +0100 Subject: [PATCH 05/16] Convert preferences & help menu to controls 2 CURA-8683 --- resources/qml/MainWindow/ApplicationMenu.qml | 133 +------------------ resources/qml/Menus/HelpMenu.qml | 23 ++++ resources/qml/Menus/PreferencesMenu.qml | 25 ++++ 3 files changed, 53 insertions(+), 128 deletions(-) create mode 100644 resources/qml/Menus/HelpMenu.qml create mode 100644 resources/qml/Menus/PreferencesMenu.qml diff --git a/resources/qml/MainWindow/ApplicationMenu.qml b/resources/qml/MainWindow/ApplicationMenu.qml index aa6fb803c3..7d52a1c588 100644 --- a/resources/qml/MainWindow/ApplicationMenu.qml +++ b/resources/qml/MainWindow/ApplicationMenu.qml @@ -66,142 +66,19 @@ Item ExtensionMenu {} + PreferencesMenu {} + + HelpMenu {} + } - /*UM.ApplicationMenu - { - id: applicationMenu - - //FileMenu { title: catalog.i18nc("@title:menu menubar:toplevel", "&File") } - - Menu - { - title: catalog.i18nc("@title:menu menubar:toplevel", "&Edit") - - MenuItem { action: Cura.Actions.undo } - MenuItem { action: Cura.Actions.redo } - MenuSeparator { } - MenuItem { action: Cura.Actions.selectAll } - MenuItem { action: Cura.Actions.arrangeAll } - MenuItem { action: Cura.Actions.multiplySelection } - MenuItem { action: Cura.Actions.deleteSelection } - MenuItem { action: Cura.Actions.deleteAll } - MenuItem { action: Cura.Actions.resetAllTranslation } - MenuItem { action: Cura.Actions.resetAll } - MenuSeparator { } - MenuItem { action: Cura.Actions.groupObjects } - MenuItem { action: Cura.Actions.mergeObjects } - MenuItem { action: Cura.Actions.unGroupObjects } - } - - ViewMenu { title: catalog.i18nc("@title:menu menubar:toplevel", "&View") } - - SettingsMenu - { - //On MacOS, don't translate the "Settings" word. - //Qt moves the "settings" entry to a different place, and if it got renamed can't find it again when it - //attempts to delete the item upon closing the application, causing a crash. - //In the new location, these items are translated automatically according to the system's language. - //For more information, see: - //- https://doc.qt.io/qt-5/macos-issues.html#menu-bar - //- https://doc.qt.io/qt-5/qmenubar.html#qmenubar-as-a-global-menu-bar - title: (Qt.platform.os == "osx") ? "&Settings" : catalog.i18nc("@title:menu menubar:toplevel", "&Settings") - } - - Menu - { - id: extensionMenu - title: catalog.i18nc("@title:menu menubar:toplevel", "E&xtensions") - - Instantiator - { - id: extensions - model: UM.ExtensionModel { } - - Menu - { - id: sub_menu - title: model.name; - visible: actions != null - enabled: actions != null - Instantiator - { - model: actions - Loader - { - property var extensionsModel: extensions.model - property var modelText: model.text - property var extensionName: name - - sourceComponent: modelText.trim() == "" ? extensionsMenuSeparator : extensionsMenuItem - } - - onObjectAdded: sub_menu.insertItem(index, object.item) - onObjectRemoved: sub_menu.removeItem(object.item) - } - } - - onObjectAdded: extensionMenu.insertItem(index, object) - onObjectRemoved: extensionMenu.removeItem(object) - } - } - - Menu - { - id: preferencesMenu - - //On MacOS, don't translate the "Preferences" word. - //Qt moves the "preferences" entry to a different place, and if it got renamed can't find it again when it - //attempts to delete the item upon closing the application, causing a crash. - //In the new location, these items are translated automatically according to the system's language. - //For more information, see: - //- https://doc.qt.io/qt-5/macos-issues.html#menu-bar - //- https://doc.qt.io/qt-5/qmenubar.html#qmenubar-as-a-global-menu-bar - title: (Qt.platform.os == "osx") ? "&Preferences" : catalog.i18nc("@title:menu menubar:toplevel", "P&references") - - MenuItem { action: Cura.Actions.preferences } - } - - Menu - { - id: helpMenu - title: catalog.i18nc("@title:menu menubar:toplevel", "&Help") - - MenuItem { action: Cura.Actions.showProfileFolder } - MenuItem { action: Cura.Actions.showTroubleshooting} - MenuItem { action: Cura.Actions.documentation } - MenuItem { action: Cura.Actions.reportBug } - MenuSeparator { } - MenuItem { action: Cura.Actions.whatsNew } - MenuItem { action: Cura.Actions.about } - } - }*/ - - - /*Component - { - id: extensionsMenuItem - - MenuItem - { - text: modelText - onTriggered: extensionsModel.subMenuTriggered(extensionName, modelText) - } - } - - Component - { - id: extensionsMenuSeparator - - MenuSeparator {} - } // ############################################################################################### // Definition of other components that are linked to the menus // ############################################################################################### - WorkspaceSummaryDialog + /*WorkspaceSummaryDialog { id: saveWorkspaceDialog property var args diff --git a/resources/qml/Menus/HelpMenu.qml b/resources/qml/Menus/HelpMenu.qml new file mode 100644 index 0000000000..d90fec57bc --- /dev/null +++ b/resources/qml/Menus/HelpMenu.qml @@ -0,0 +1,23 @@ +// Copyright (c) 2022 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.7 +import QtQuick.Controls 2.4 + +import UM 1.5 as UM +import Cura 1.0 as Cura + + +Menu +{ + id: helpMenu + title: catalog.i18nc("@title:menu menubar:toplevel", "&Help") + + UM.MenuItem { action: Cura.Actions.showProfileFolder } + UM.MenuItem { action: Cura.Actions.showTroubleshooting} + UM.MenuItem { action: Cura.Actions.documentation } + UM.MenuItem { action: Cura.Actions.reportBug } + MenuSeparator { } + UM.MenuItem { action: Cura.Actions.whatsNew } + UM.MenuItem { action: Cura.Actions.about } +} \ No newline at end of file diff --git a/resources/qml/Menus/PreferencesMenu.qml b/resources/qml/Menus/PreferencesMenu.qml new file mode 100644 index 0000000000..8b5e8fbcd5 --- /dev/null +++ b/resources/qml/Menus/PreferencesMenu.qml @@ -0,0 +1,25 @@ +// Copyright (c) 2022 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.7 +import QtQuick.Controls 2.4 + +import UM 1.5 as UM +import Cura 1.0 as Cura + +Menu +{ + id: preferencesMenu + + //On MacOS, don't translate the "Preferences" word. + //Qt moves the "preferences" entry to a different place, and if it got renamed can't find it again when it + //attempts to delete the item upon closing the application, causing a crash. + //In the new location, these items are translated automatically according to the system's language. + //For more information, see: + //- https://doc.qt.io/qt-5/macos-issues.html#menu-bar + //- https://doc.qt.io/qt-5/qmenubar.html#qmenubar-as-a-global-menu-bar + title: (Qt.platform.os == "osx") ? "&Preferences" : catalog.i18nc("@title:menu menubar:toplevel", "P&references") + + UM.MenuItem { action: Cura.Actions.preferences } +} + From 29c9322fc8068d0cf09a0fd00bc42b15f119f00e Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 11 Jan 2022 11:16:40 +0100 Subject: [PATCH 06/16] Add background to application menu CURA-8683 --- resources/qml/MainWindow/ApplicationMenu.qml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/resources/qml/MainWindow/ApplicationMenu.qml b/resources/qml/MainWindow/ApplicationMenu.qml index 7d52a1c588..20a7e774f9 100644 --- a/resources/qml/MainWindow/ApplicationMenu.qml +++ b/resources/qml/MainWindow/ApplicationMenu.qml @@ -14,7 +14,7 @@ import "../Dialogs" Item { id: menu - width: applicationMenu.width + width: parent.width height: applicationMenu.height Component @@ -46,12 +46,15 @@ Item MenuBar { id: applicationMenu + width: parent.width delegate: menuBarComponent FileMenu {} EditMenu {} ViewMenu {} + background: Rectangle {} + SettingsMenu { //On MacOS, don't translate the "Settings" word. @@ -78,7 +81,7 @@ Item // Definition of other components that are linked to the menus // ############################################################################################### - /*WorkspaceSummaryDialog + WorkspaceSummaryDialog { id: saveWorkspaceDialog property var args @@ -101,11 +104,6 @@ Item } } - UM.ExtensionModel - { - id: curaExtensions - } - // ############################################################################################### // Definition of all the connections // ############################################################################################### @@ -141,5 +139,5 @@ Item curaExtensions.callExtensionMethod("Toolbox", "launch") curaExtensions.callExtensionMethod("Toolbox", "setViewCategoryToMaterials") } - }*/ + } } \ No newline at end of file From 0bd0f094375fb115d6b6894a7513e0019a393483 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 11 Jan 2022 11:26:05 +0100 Subject: [PATCH 07/16] Remove unused component CURA-8683 --- resources/qml/MainWindow/ApplicationMenu.qml | 27 -------------------- 1 file changed, 27 deletions(-) diff --git a/resources/qml/MainWindow/ApplicationMenu.qml b/resources/qml/MainWindow/ApplicationMenu.qml index 20a7e774f9..06fbc7a47a 100644 --- a/resources/qml/MainWindow/ApplicationMenu.qml +++ b/resources/qml/MainWindow/ApplicationMenu.qml @@ -17,37 +17,10 @@ Item width: parent.width height: applicationMenu.height - Component - { - id: menuBarComponent - MenuBarItem - { - id: menuBarItem - - function replaceText(txt) - { - var index = txt.indexOf("&") - if(index >= 0) - { - txt = txt.replace(txt.substr(index, 2), ("" + txt.substr(index + 1, 1) +"")) - } - return txt - } - - contentItem: Label { - text: replaceText(menuBarItem.text) - color: "white" - verticalAlignment: Text.AlignVCenter - textFormat: Text.RichText - } - } - } - MenuBar { id: applicationMenu width: parent.width - delegate: menuBarComponent FileMenu {} EditMenu {} From 70209aa7286d19a75acbe3594c1ccf48e9feff8c Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 11 Jan 2022 11:26:26 +0100 Subject: [PATCH 08/16] Use the regular menu for extensions It seems that the extra logic doesn't play well with a menu bar. Since we don't need to make this menu invisible ever, there is no need for the extra logic to hide it. As such we can just use the regular menu CURA-8683 --- resources/qml/Menus/ExtensionMenu.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/Menus/ExtensionMenu.qml b/resources/qml/Menus/ExtensionMenu.qml index 0d4bc7c6e7..2504c7a9e1 100644 --- a/resources/qml/Menus/ExtensionMenu.qml +++ b/resources/qml/Menus/ExtensionMenu.qml @@ -7,7 +7,7 @@ import QtQuick.Controls 2.4 import UM 1.5 as UM import Cura 1.0 as Cura -UM.Menu +Menu { id: extensionMenu title: catalog.i18nc("@title:menu menubar:toplevel", "E&xtensions") From b30ad58f916cb57113a93f01810d812821813b98 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 11 Jan 2022 11:36:34 +0100 Subject: [PATCH 09/16] Update context menu to controls 2 CURA-8683 --- resources/qml/Menus/ContextMenu.qml | 103 ++++++++-------------------- 1 file changed, 30 insertions(+), 73 deletions(-) diff --git a/resources/qml/Menus/ContextMenu.qml b/resources/qml/Menus/ContextMenu.qml index 1709d70ab5..41dfafbe2f 100644 --- a/resources/qml/Menus/ContextMenu.qml +++ b/resources/qml/Menus/ContextMenu.qml @@ -2,11 +2,11 @@ // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.2 -import QtQuick.Controls 1.1 +import QtQuick.Controls 2.1 import QtQuick.Dialogs 1.2 import QtQuick.Window 2.1 -import UM 1.2 as UM +import UM 1.5 as UM import Cura 1.0 as Cura Menu @@ -18,79 +18,58 @@ Menu property var multiBuildPlateModel: CuraApplication.getMultiBuildPlateModel() // Selection-related actions. - MenuItem { action: Cura.Actions.centerSelection; } - MenuItem { action: Cura.Actions.deleteSelection; } - MenuItem { action: Cura.Actions.multiplySelection; } + UM.MenuItem { action: Cura.Actions.centerSelection; } + UM.MenuItem { action: Cura.Actions.deleteSelection; } + UM.MenuItem { action: Cura.Actions.multiplySelection; } // Extruder selection - only visible if there is more than 1 extruder MenuSeparator { visible: base.shouldShowExtruders } - MenuItem { id: extruderHeader; text: catalog.i18ncp("@label", "Print Selected Model With:", "Print Selected Models With:", UM.Selection.selectionCount); enabled: false; visible: base.shouldShowExtruders } + UM.MenuItem + { + id: extruderHeader + text: catalog.i18ncp("@label", "Print Selected Model With:", "Print Selected Models With:", UM.Selection.selectionCount) + enabled: false + visible: base.shouldShowExtruders + height: visible ? implicitHeight: 0 + } + Instantiator { model: CuraApplication.getExtrudersModel() - MenuItem { + UM.MenuItem + { text: "%1: %2 - %3".arg(model.name).arg(model.material).arg(model.variant) visible: base.shouldShowExtruders + height: visible ? implicitHeight: 0 enabled: UM.Selection.hasSelection && model.enabled checkable: true checked: Cura.ExtruderManager.selectedObjectExtruders.indexOf(model.id) != -1 onTriggered: CuraActions.setExtruderForSelection(model.id) shortcut: "Ctrl+" + (model.index + 1) } - onObjectAdded: base.insertItem(index, object) + onObjectAdded: base.insertItem(index + 5, object) onObjectRemoved: base.removeItem(object) } - MenuSeparator { - visible: UM.Preferences.getValue("cura/use_multi_build_plate") - } - - Instantiator - { - model: base.multiBuildPlateModel - MenuItem { - enabled: UM.Selection.hasSelection - text: base.multiBuildPlateModel.getItem(index).name; - onTriggered: CuraActions.setBuildPlateForSelection(base.multiBuildPlateModel.getItem(index).buildPlateNumber); - checkable: true - checked: base.multiBuildPlateModel.selectionBuildPlates.indexOf(base.multiBuildPlateModel.getItem(index).buildPlateNumber) != -1; - visible: UM.Preferences.getValue("cura/use_multi_build_plate") - } - onObjectAdded: base.insertItem(index, object); - onObjectRemoved: base.removeItem(object); - } - - MenuItem { - enabled: UM.Selection.hasSelection - text: "New build plate"; - onTriggered: { - CuraActions.setBuildPlateForSelection(base.multiBuildPlateModel.maxBuildPlate + 1); - checked = false; - } - checkable: true - checked: false - visible: UM.Preferences.getValue("cura/use_multi_build_plate") - } - // Global actions MenuSeparator {} - MenuItem { action: Cura.Actions.selectAll; } - MenuItem { action: Cura.Actions.arrangeAll; } - MenuItem { action: Cura.Actions.deleteAll; } - MenuItem { action: Cura.Actions.reloadAll; } - MenuItem { action: Cura.Actions.resetAllTranslation; } - MenuItem { action: Cura.Actions.resetAll; } + UM.MenuItem { action: Cura.Actions.selectAll } + UM.MenuItem { action: Cura.Actions.arrangeAll } + UM.MenuItem { action: Cura.Actions.deleteAll } + UM.MenuItem { action: Cura.Actions.reloadAll } + UM.MenuItem { action: Cura.Actions.resetAllTranslation } + UM.MenuItem { action: Cura.Actions.resetAll } // Group actions MenuSeparator {} - MenuItem { action: Cura.Actions.groupObjects; } - MenuItem { action: Cura.Actions.mergeObjects; } - MenuItem { action: Cura.Actions.unGroupObjects; } + UM.MenuItem { action: Cura.Actions.groupObjects } + UM.MenuItem { action: Cura.Actions.mergeObjects } + UM.MenuItem { action: Cura.Actions.unGroupObjects } Connections { target: UM.Controller - function onContextMenuRequested() { base.popup(); } + function onContextMenuRequested() { base.popup() } } Connections @@ -146,31 +125,9 @@ Menu { id: copiesField focus: true - minimumValue: 1 - maximumValue: 99 + from: 1 + to: 99 } } } - - // Find the index of an item in the list of child items of this menu. - // - // This is primarily intended as a helper function so we do not have to - // hard-code the position of the extruder selection actions. - // - // \param item The item to find the index of. - // - // \return The index of the item or -1 if it was not found. - function findItemIndex(item) - { - for(var i in base.items) - { - if(base.items[i] == item) - { - return i; - } - } - return -1; - } - - UM.I18nCatalog { id: catalog; name: "cura" } } From f8906597e596f81e1dfcd0dbe03203f799fca8e9 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 11 Jan 2022 11:43:01 +0100 Subject: [PATCH 10/16] Update menu for PrinterType button CURA-8683 --- .../Menus/ConfigurationMenu/CustomConfiguration.qml | 11 ++++++----- resources/qml/Menus/PrinterTypeMenu.qml | 9 +++------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml b/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml index 10bd5624d7..bacee0bc24 100644 --- a/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml +++ b/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml @@ -35,7 +35,7 @@ Item } } - //Printer type selector. + // Printer type selector. Item { id: printerTypeSelectorRow @@ -64,17 +64,18 @@ Item anchors.left: parent.left } - OldControls.ToolButton + Button { id: printerTypeSelector text: Cura.MachineManager.activeMachine !== null ? Cura.MachineManager.activeMachine.definition.name: "" - tooltip: text + height: UM.Theme.getSize("print_setup_big_item").height width: Math.round(parent.width * 0.7) + UM.Theme.getSize("default_margin").width anchors.right: parent.right - style: UM.Theme.styles.print_setup_header_button + onClicked: menu.open() + //style: UM.Theme.styles.print_setup_header_button - menu: Cura.PrinterTypeMenu { } + Cura.PrinterTypeMenu { id: menu} } } diff --git a/resources/qml/Menus/PrinterTypeMenu.qml b/resources/qml/Menus/PrinterTypeMenu.qml index c2a09e0efd..9a6c066b4d 100644 --- a/resources/qml/Menus/PrinterTypeMenu.qml +++ b/resources/qml/Menus/PrinterTypeMenu.qml @@ -2,9 +2,9 @@ // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.7 -import QtQuick.Controls 1.4 +import QtQuick.Controls 2.4 -import UM 1.3 as UM +import UM 1.5 as UM import Cura 1.0 as Cura Menu @@ -18,12 +18,11 @@ Menu id: printerTypeInstantiator model: outputDevice != null ? outputDevice.connectedPrintersTypeCount : [] - MenuItem + UM.MenuItem { text: modelData.machine_type checkable: true checked: Cura.MachineManager.activeMachine.definition.name == modelData.machine_type - exclusiveGroup: group onTriggered: { Cura.MachineManager.switchPrinterType(modelData.machine_type) @@ -32,6 +31,4 @@ Menu onObjectAdded: menu.insertItem(index, object) onObjectRemoved: menu.removeItem(object) } - - ExclusiveGroup { id: group } } From 3d0e71fe7e8abe4e345381a838109c8289379dea Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 11 Jan 2022 11:44:59 +0100 Subject: [PATCH 11/16] Remove unused import --- resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml index 0d4d5e9aed..69d938d977 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml @@ -3,7 +3,6 @@ import QtQuick 2.10 import QtQuick.Controls 2.3 -import QtQuick.Controls.Styles 1.4 import QtQuick.Layouts 1.3 import UM 1.5 as UM From 6644bff2be3ea05e9912fffc11d8f9570fe198fb Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 11 Jan 2022 11:52:43 +0100 Subject: [PATCH 12/16] Fix some QML warnings on closing Cura CURA-8683 --- .../ConfigurationMenu/ConfigurationMenu.qml | 16 ++++++++-------- resources/qml/Menus/NozzleMenu.qml | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml index 69d938d977..9860a522e5 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml @@ -18,7 +18,7 @@ Cura.ExpandablePopup id: base property var extrudersModel: CuraApplication.getExtrudersModel() - + property var activeMachine: Cura.MachineManager.activeMachine UM.I18nCatalog { id: catalog @@ -32,7 +32,7 @@ Cura.ExpandablePopup } contentPadding: UM.Theme.getSize("default_lining").width - enabled: Cura.MachineManager.activeMachine ? Cura.MachineManager.activeMachine.hasMaterials || Cura.MachineManager.activeMachine.hasVariants || Cura.MachineManager.activeMachine.hasVariantBuildplates : false; //Only let it drop down if there is any configuration that you could change. + enabled: activeMachine ? activeMachine.hasMaterials || activeMachine.hasVariants || activeMachine.hasVariantBuildplates : false; //Only let it drop down if there is any configuration that you could change. headerItem: Item { @@ -43,7 +43,7 @@ Cura.ExpandablePopup anchors.bottom: parent.bottom anchors.left: parent.left width: parent.width - UM.Theme.getSize("standard_arrow").width - visible: Cura.MachineManager.activeMachine ? Cura.MachineManager.activeMachine.hasMaterials : false + visible: activeMachine ? activeMachine.hasMaterials : false Repeater { model: extrudersModel @@ -55,9 +55,9 @@ Cura.ExpandablePopup Layout.maximumWidth: Math.round(parent.width / extrudersModel.count) Layout.fillHeight: true - property var extruderStack: Cura.MachineManager.activeMachine.extruders[model.index] + property var extruderStack: activeMachine ? activeMachine.extruders[model.index]: null property bool valueWarning: !Cura.ExtruderManager.getExtruderHasQualityForMaterial(extruderStack) - property bool valueError: Cura.ContainerManager.getContainerMetaDataEntry(extruderStack.material.id, "compatible", "") != "True" + property bool valueError: activeMachine ? Cura.ContainerManager.getContainerMetaDataEntry(extruderStack.material.id, "compatible", "") != "True" : false // Extruder icon. Shows extruder index and has the same color as the active material. Cura.ExtruderIcon @@ -223,7 +223,7 @@ Cura.ExpandablePopup { id: variantLabel - visible: Cura.MachineManager.activeMachine ? Cura.MachineManager.activeMachine.hasVariants : false + visible: activeMachine ? activeMachine.hasVariants : false text: model.variant elide: Text.ElideRight @@ -242,7 +242,7 @@ Cura.ExpandablePopup elide: Text.ElideRight font: UM.Theme.getFont("medium") - visible: Cura.MachineManager.activeMachine ? !Cura.MachineManager.activeMachine.hasMaterials && (Cura.MachineManager.activeMachine.hasVariants || Cura.MachineManager.activeMachine.hasVariantBuildplates) : false + visible: activeMachine ? !activeMachine.hasMaterials && (activeMachine.hasVariants || activeMachine.hasVariantBuildplates) : false anchors { @@ -267,7 +267,7 @@ Cura.ExpandablePopup onVisibleChanged: { - is_connected = Cura.MachineManager.activeMachine.hasRemoteConnection && Cura.MachineManager.printerConnected && Cura.MachineManager.printerOutputDevices[0].uniqueConfigurations.length > 0 //Re-evaluate. + is_connected = activeMachine.hasRemoteConnection && Cura.MachineManager.printerConnected && Cura.MachineManager.printerOutputDevices[0].uniqueConfigurations.length > 0 //Re-evaluate. // If the printer is not connected or does not have configurations, we switch always to the custom mode. If is connected instead, the auto mode // or the previous state is selected diff --git a/resources/qml/Menus/NozzleMenu.qml b/resources/qml/Menus/NozzleMenu.qml index e2c5199211..973cf1fb09 100644 --- a/resources/qml/Menus/NozzleMenu.qml +++ b/resources/qml/Menus/NozzleMenu.qml @@ -34,7 +34,7 @@ UM.Menu { return false } - var extruder = Cura.MachineManager.activeMachine.extruderList[extruderIndex] + var extruder = activeMachine.extruderList[extruderIndex] return (extruder === undefined) ? false : (extruder.variant.name == model.hotend_name) } enabled: @@ -43,7 +43,7 @@ UM.Menu { return false } - var extruder = Cura.MachineManager.activeMachine.extruderList[extruderIndex] + var extruder = activeMachine.extruderList[extruderIndex] return (extruder === undefined) ? false : extruder.isEnabled } onTriggered:Cura.MachineManager.setVariant(nozzleMenu.extruderIndex, model.container_node) From 59479ee223b28e97c2dc47fcbb8f2a0e18bb457f Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 11 Jan 2022 12:09:24 +0100 Subject: [PATCH 13/16] Fix checked property for materials menu CURA-8683 --- resources/qml/Menus/MaterialMenu.qml | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/resources/qml/Menus/MaterialMenu.qml b/resources/qml/Menus/MaterialMenu.qml index 9a0c8e2c77..5d02a2dd90 100644 --- a/resources/qml/Menus/MaterialMenu.qml +++ b/resources/qml/Menus/MaterialMenu.qml @@ -9,7 +9,7 @@ import Cura 1.0 as Cura UM.Menu { - id: menu + id: materialMenu title: catalog.i18nc("@label:category menu label", "Material") property int extruderIndex: 0 @@ -25,27 +25,26 @@ UM.Menu } property bool isActiveExtruderEnabled: (activeExtruder === null || activeExtruder === undefined) ? false : activeExtruder.isEnabled - property string activeMaterialId: (activeExtruder === null || activeExtruder === undefined) ? false : activeExtruder.material.id - + property string activeMaterialId: (activeExtruder === null || activeExtruder === undefined) ? "" : activeExtruder.material.id property bool updateModels: true Cura.FavoriteMaterialsModel { id: favoriteMaterialsModel - extruderPosition: menu.extruderIndex + extruderPosition: materialMenu.extruderIndex enabled: updateModels } Cura.GenericMaterialsModel { id: genericMaterialsModel - extruderPosition: menu.extruderIndex + extruderPosition: materialMenu.extruderIndex enabled: updateModels } Cura.MaterialBrandsModel { id: brandModel - extruderPosition: menu.extruderIndex + extruderPosition: materialMenu.extruderIndex enabled: updateModels } @@ -65,11 +64,11 @@ UM.Menu text: model.brand + " " + model.name checkable: true enabled: isActiveExtruderEnabled - checked: model.root_material_id === menu.currentRootMaterialId + checked: model.root_material_id === materialMenu.currentRootMaterialId onTriggered: Cura.MachineManager.setMaterial(extruderIndex, model.container_node) } - onObjectAdded: menu.insertItem(index, object) - onObjectRemoved: menu.removeItem(index) + onObjectAdded: materialMenu.insertItem(index, object) + onObjectRemoved: materialMenu.removeItem(index) } MenuSeparator {} @@ -87,7 +86,7 @@ UM.Menu text: model.name checkable: true enabled: isActiveExtruderEnabled - checked: model.root_material_id === menu.currentRootMaterialId + checked: model.root_material_id === materialMenu.currentRootMaterialId onTriggered: Cura.MachineManager.setMaterial(extruderIndex, model.container_node) } onObjectAdded: genericMenu.insertItem(index, object) @@ -125,7 +124,7 @@ UM.Menu text: model.name checkable: true enabled: isActiveExtruderEnabled - checked: model.id === menu.activeMaterialId + checked: model.id === materialMenu.activeMaterialId onTriggered: Cura.MachineManager.setMaterial(extruderIndex, model.container_node) } @@ -137,8 +136,8 @@ UM.Menu onObjectRemoved: brandMenu.removeMenu(object) } } - onObjectAdded: menu.insertMenu(index, object) - onObjectRemoved: menu.removeMenu(object) + onObjectAdded: materialMenu.insertMenu(index, object) + onObjectRemoved: materialMenu.removeMenu(object) } MenuSeparator {} From f44d4d341f50b0c96e3a3ccf57d360c9c6908a6e Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 12 Jan 2022 15:57:20 +0100 Subject: [PATCH 14/16] Apply suggestions from code review Minor codestyle issues CURA-8683 Co-authored-by: Casper Lamboo --- resources/qml/Menus/NozzleMenu.qml | 7 ++----- resources/qml/Menus/ViewMenu.qml | 2 +- resources/qml/Widgets/MenuItem.qml | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/resources/qml/Menus/NozzleMenu.qml b/resources/qml/Menus/NozzleMenu.qml index 973cf1fb09..7afe2b48bc 100644 --- a/resources/qml/Menus/NozzleMenu.qml +++ b/resources/qml/Menus/NozzleMenu.qml @@ -46,13 +46,10 @@ UM.Menu var extruder = activeMachine.extruderList[extruderIndex] return (extruder === undefined) ? false : extruder.isEnabled } - onTriggered:Cura.MachineManager.setVariant(nozzleMenu.extruderIndex, model.container_node) + onTriggered: Cura.MachineManager.setVariant(nozzleMenu.extruderIndex, model.container_node) } - onObjectAdded: - { - nozzleMenu.insertItem(index, object) - } + onObjectAdded: nozzleMenu.insertItem(index, object) onObjectRemoved: nozzleMenu.removeItem(object) } diff --git a/resources/qml/Menus/ViewMenu.qml b/resources/qml/Menus/ViewMenu.qml index 0b6489bf9a..d38bf536b0 100644 --- a/resources/qml/Menus/ViewMenu.qml +++ b/resources/qml/Menus/ViewMenu.qml @@ -27,7 +27,7 @@ Menu { id: cameraViewMenu - title: catalog.i18nc("@action:inmenu menubar:view","Camera view") + title: catalog.i18nc("@action:inmenu menubar:view", "Camera view") property string cameraMode: UM.Preferences.getValue("general/camera_perspective_mode") Connections diff --git a/resources/qml/Widgets/MenuItem.qml b/resources/qml/Widgets/MenuItem.qml index 8861da1eac..dd3f40b49a 100644 --- a/resources/qml/Widgets/MenuItem.qml +++ b/resources/qml/Widgets/MenuItem.qml @@ -15,7 +15,7 @@ MenuItem implicitHeight: UM.Theme.getSize("setting_control").height + UM.Theme.getSize("narrow_margin").height opacity: enabled ? 1.0 : 0.5 - height: visible ? implicitHeight: 0 + height: visible ? implicitHeight : 0 arrow: UM.RecolorImage { From 94c71704dbfe308f3704e7c1856a11e07b9f720f Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 12 Jan 2022 16:00:32 +0100 Subject: [PATCH 15/16] Add clarifying comment about why something is added at index 5> CURA-8683 --- resources/qml/Menus/ContextMenu.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/qml/Menus/ContextMenu.qml b/resources/qml/Menus/ContextMenu.qml index 41dfafbe2f..02ad5b6516 100644 --- a/resources/qml/Menus/ContextMenu.qml +++ b/resources/qml/Menus/ContextMenu.qml @@ -47,6 +47,7 @@ Menu onTriggered: CuraActions.setExtruderForSelection(model.id) shortcut: "Ctrl+" + (model.index + 1) } + // Add it to the fifth position (and above) as we want it to be added after the extruder header. onObjectAdded: base.insertItem(index + 5, object) onObjectRemoved: base.removeItem(object) } From 94c006009b8aa05a9ad52e8352752ab22f59af7f Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 13 Jan 2022 09:06:22 +0100 Subject: [PATCH 16/16] Remove debug code CURA-8683 --- resources/qml/Menus/PrinterMenu.qml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/resources/qml/Menus/PrinterMenu.qml b/resources/qml/Menus/PrinterMenu.qml index 58c15201a2..dcc9605bd7 100644 --- a/resources/qml/Menus/PrinterMenu.qml +++ b/resources/qml/Menus/PrinterMenu.qml @@ -36,12 +36,7 @@ Menu text: connectGroupName checkable: true checked: Cura.MachineManager.activeMachineNetworkGroupName == connectGroupName - onTriggered: - { - print(typeof(model.id)) - Cura.MachineManager.someFunction("YAY") - Cura.MachineManager.setActiveMachine(model.id) - } + onTriggered: Cura.MachineManager.setActiveMachine(model.id) } onObjectAdded: menu.insertItem(2, object) onObjectRemoved: menu.removeItem(object)