ApplicationMenu.qml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. // Copyright (c) 2022 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.7
  4. import QtQuick.Controls 2.4
  5. import UM 1.5 as UM
  6. import Cura 1.1 as Cura
  7. import "../Menus"
  8. import "../Dialogs"
  9. Item
  10. {
  11. id: menu
  12. width: parent.width
  13. height: applicationMenu.height
  14. MenuBar
  15. {
  16. id: applicationMenu
  17. width: parent.width
  18. FileMenu {}
  19. EditMenu {}
  20. ViewMenu {}
  21. background: Rectangle {}
  22. SettingsMenu
  23. {
  24. //On MacOS, don't translate the "Settings" word.
  25. //Qt moves the "settings" entry to a different place, and if it got renamed can't find it again when it
  26. //attempts to delete the item upon closing the application, causing a crash.
  27. //In the new location, these items are translated automatically according to the system's language.
  28. //For more information, see:
  29. //- https://doc.qt.io/qt-5/macos-issues.html#menu-bar
  30. //- https://doc.qt.io/qt-5/qmenubar.html#qmenubar-as-a-global-menu-bar
  31. title: (Qt.platform.os == "osx") ? "&Settings" : catalog.i18nc("@title:menu menubar:toplevel", "&Settings")
  32. }
  33. ExtensionMenu { id: extensionMenu }
  34. PreferencesMenu {}
  35. HelpMenu {}
  36. }
  37. // ###############################################################################################
  38. // Definition of other components that are linked to the menus
  39. // ###############################################################################################
  40. WorkspaceSummaryDialog
  41. {
  42. id: saveWorkspaceDialog
  43. property var args
  44. onAccepted: UM.OutputDeviceManager.requestWriteToDevice("local_file", PrintInformation.jobName, args)
  45. }
  46. UM.MessageDialog
  47. {
  48. id: newProjectDialog
  49. title: catalog.i18nc("@title:window", "New project")
  50. text: catalog.i18nc("@info:question", "Are you sure you want to start a new project? This will clear the build plate and any unsaved settings.")
  51. standardButtons: Dialog.Yes | Dialog.No
  52. onAccepted:
  53. {
  54. CuraApplication.resetWorkspace()
  55. Cura.Actions.resetProfile.trigger()
  56. UM.Controller.setActiveStage("PrepareStage")
  57. }
  58. }
  59. // ###############################################################################################
  60. // Definition of all the connections
  61. // ###############################################################################################
  62. Connections
  63. {
  64. target: Cura.Actions.newProject
  65. function onTriggered()
  66. {
  67. if(Printer.platformActivity || Cura.MachineManager.hasUserSettings)
  68. {
  69. newProjectDialog.visible = true
  70. }
  71. }
  72. }
  73. // show the Toolbox
  74. Connections
  75. {
  76. target: Cura.Actions.browsePackages
  77. function onTriggered()
  78. {
  79. print("beepboop")
  80. extensionMenu.extensionModel.callExtensionMethod("Marketplace", "show")
  81. }
  82. }
  83. // Show the Marketplace dialog at the materials tab
  84. Connections
  85. {
  86. target: Cura.Actions.marketplaceMaterials
  87. function onTriggered()
  88. {
  89. extensionMenu.extensionModel.callExtensionMethod("Marketplace", "show")
  90. extensionMenu.extensionModel.callExtensionMethod("Marketplace", "setVisibleTabToMaterials")
  91. }
  92. }
  93. }