ApplicationMenu.qml 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. // Copyright (c) 2021 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.2
  5. import QtQuick.Controls.Styles 2.2
  6. import QtQuick.Layouts 1.1
  7. import QtQuick.Dialogs 1.2
  8. import UM 1.3 as UM
  9. import Cura 1.1 as Cura
  10. import "../Menus"
  11. import "../Dialogs"
  12. Item
  13. {
  14. id: menu
  15. width: applicationMenu.width
  16. height: applicationMenu.height
  17. property alias window: applicationMenu.window
  18. UM.ApplicationMenu
  19. {
  20. id: applicationMenu
  21. FileMenu { title: catalog.i18nc("@title:menu menubar:toplevel", "&File") }
  22. Menu
  23. {
  24. title: catalog.i18nc("@title:menu menubar:toplevel", "&Edit")
  25. MenuItem { action: Cura.Actions.undo }
  26. MenuItem { action: Cura.Actions.redo }
  27. MenuSeparator { }
  28. MenuItem { action: Cura.Actions.selectAll }
  29. MenuItem { action: Cura.Actions.arrangeAll }
  30. MenuItem { action: Cura.Actions.multiplySelection }
  31. MenuItem { action: Cura.Actions.deleteSelection }
  32. MenuItem { action: Cura.Actions.deleteAll }
  33. MenuItem { action: Cura.Actions.resetAllTranslation }
  34. MenuItem { action: Cura.Actions.resetAll }
  35. MenuSeparator { }
  36. MenuItem { action: Cura.Actions.groupObjects }
  37. MenuItem { action: Cura.Actions.mergeObjects }
  38. MenuItem { action: Cura.Actions.unGroupObjects }
  39. }
  40. ViewMenu { title: catalog.i18nc("@title:menu menubar:toplevel", "&View") }
  41. SettingsMenu
  42. {
  43. //On MacOS, don't translate the "Settings" word.
  44. //Qt moves the "settings" entry to a different place, and if it got renamed can't find it again when it
  45. //attempts to delete the item upon closing the application, causing a crash.
  46. //In the new location, these items are translated automatically according to the system's language.
  47. //For more information, see:
  48. //- https://doc.qt.io/qt-5/macos-issues.html#menu-bar
  49. //- https://doc.qt.io/qt-5/qmenubar.html#qmenubar-as-a-global-menu-bar
  50. title: (Qt.platform.os == "osx") ? "&Settings" : catalog.i18nc("@title:menu menubar:toplevel", "&Settings")
  51. }
  52. Menu
  53. {
  54. id: extensionMenu
  55. title: catalog.i18nc("@title:menu menubar:toplevel", "E&xtensions")
  56. Instantiator
  57. {
  58. id: extensions
  59. model: UM.ExtensionModel { }
  60. Menu
  61. {
  62. id: sub_menu
  63. title: model.name;
  64. visible: actions != null
  65. enabled: actions != null
  66. Instantiator
  67. {
  68. model: actions
  69. Loader
  70. {
  71. property var extensionsModel: extensions.model
  72. property var modelText: model.text
  73. property var extensionName: name
  74. sourceComponent: modelText.trim() == "" ? extensionsMenuSeparator : extensionsMenuItem
  75. }
  76. onObjectAdded: sub_menu.insertItem(index, object.item)
  77. onObjectRemoved: sub_menu.removeItem(object.item)
  78. }
  79. }
  80. onObjectAdded: extensionMenu.insertItem(index, object)
  81. onObjectRemoved: extensionMenu.removeItem(object)
  82. }
  83. }
  84. Menu
  85. {
  86. id: preferencesMenu
  87. //On MacOS, don't translate the "Preferences" word.
  88. //Qt moves the "preferences" entry to a different place, and if it got renamed can't find it again when it
  89. //attempts to delete the item upon closing the application, causing a crash.
  90. //In the new location, these items are translated automatically according to the system's language.
  91. //For more information, see:
  92. //- https://doc.qt.io/qt-5/macos-issues.html#menu-bar
  93. //- https://doc.qt.io/qt-5/qmenubar.html#qmenubar-as-a-global-menu-bar
  94. title: (Qt.platform.os == "osx") ? "&Preferences" : catalog.i18nc("@title:menu menubar:toplevel", "P&references")
  95. MenuItem { action: Cura.Actions.preferences }
  96. }
  97. Menu
  98. {
  99. id: helpMenu
  100. title: catalog.i18nc("@title:menu menubar:toplevel", "&Help")
  101. MenuItem { action: Cura.Actions.showProfileFolder }
  102. MenuItem { action: Cura.Actions.showTroubleshooting}
  103. MenuItem { action: Cura.Actions.documentation }
  104. MenuItem { action: Cura.Actions.reportBug }
  105. MenuSeparator { }
  106. MenuItem { action: Cura.Actions.whatsNew }
  107. MenuItem { action: Cura.Actions.about }
  108. }
  109. }
  110. Component
  111. {
  112. id: extensionsMenuItem
  113. MenuItem
  114. {
  115. text: modelText
  116. onTriggered: extensionsModel.subMenuTriggered(extensionName, modelText)
  117. }
  118. }
  119. Component
  120. {
  121. id: extensionsMenuSeparator
  122. MenuSeparator {}
  123. }
  124. // ###############################################################################################
  125. // Definition of other components that are linked to the menus
  126. // ###############################################################################################
  127. WorkspaceSummaryDialog
  128. {
  129. id: saveWorkspaceDialog
  130. property var args
  131. onYes: UM.OutputDeviceManager.requestWriteToDevice("local_file", PrintInformation.jobName, args)
  132. }
  133. MessageDialog
  134. {
  135. id: newProjectDialog
  136. modality: Qt.ApplicationModal
  137. title: catalog.i18nc("@title:window", "New project")
  138. 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.")
  139. standardButtons: StandardButton.Yes | StandardButton.No
  140. icon: StandardIcon.Question
  141. onYes:
  142. {
  143. CuraApplication.resetWorkspace()
  144. Cura.Actions.resetProfile.trigger()
  145. UM.Controller.setActiveStage("PrepareStage")
  146. }
  147. }
  148. UM.ExtensionModel
  149. {
  150. id: curaExtensions
  151. }
  152. // ###############################################################################################
  153. // Definition of all the connections
  154. // ###############################################################################################
  155. Connections
  156. {
  157. target: Cura.Actions.newProject
  158. function onTriggered()
  159. {
  160. if(Printer.platformActivity || Cura.MachineManager.hasUserSettings)
  161. {
  162. newProjectDialog.visible = true
  163. }
  164. }
  165. }
  166. // show the Toolbox
  167. Connections
  168. {
  169. target: Cura.Actions.browsePackages
  170. function onTriggered()
  171. {
  172. curaExtensions.callExtensionMethod("Toolbox", "launch")
  173. }
  174. }
  175. // Show the Marketplace dialog at the materials tab
  176. Connections
  177. {
  178. target: Cura.Actions.marketplaceMaterials
  179. function onTriggered()
  180. {
  181. curaExtensions.callExtensionMethod("Toolbox", "launch")
  182. curaExtensions.callExtensionMethod("Toolbox", "setViewCategoryToMaterials")
  183. }
  184. }
  185. }