ApplicationMenu.qml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.7
  4. import QtQuick.Controls 1.4
  5. import QtQuick.Controls.Styles 1.4
  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 { title: catalog.i18nc("@title:menu menubar:toplevel", "&Settings") }
  42. Menu
  43. {
  44. id: extensionMenu
  45. title: catalog.i18nc("@title:menu menubar:toplevel", "E&xtensions")
  46. Instantiator
  47. {
  48. id: extensions
  49. model: UM.ExtensionModel { }
  50. Menu
  51. {
  52. id: sub_menu
  53. title: model.name;
  54. visible: actions != null
  55. enabled: actions != null
  56. Instantiator
  57. {
  58. model: actions
  59. Loader
  60. {
  61. property var extensionsModel: extensions.model
  62. property var modelText: model.text
  63. property var extensionName: name
  64. sourceComponent: modelText.trim() == "" ? extensionsMenuSeparator : extensionsMenuItem
  65. }
  66. onObjectAdded: sub_menu.insertItem(index, object.item)
  67. onObjectRemoved: sub_menu.removeItem(object.item)
  68. }
  69. }
  70. onObjectAdded: extensionMenu.insertItem(index, object)
  71. onObjectRemoved: extensionMenu.removeItem(object)
  72. }
  73. }
  74. Menu
  75. {
  76. id: preferencesMenu
  77. title: catalog.i18nc("@title:menu menubar:toplevel", "P&references")
  78. MenuItem { action: Cura.Actions.preferences }
  79. }
  80. Menu
  81. {
  82. id: helpMenu
  83. title: catalog.i18nc("@title:menu menubar:toplevel", "&Help")
  84. MenuItem { action: Cura.Actions.showProfileFolder }
  85. MenuItem { action: Cura.Actions.showTroubleshooting}
  86. MenuItem { action: Cura.Actions.documentation }
  87. MenuItem { action: Cura.Actions.reportBug }
  88. MenuSeparator { }
  89. MenuItem { action: Cura.Actions.whatsNew }
  90. MenuItem { action: Cura.Actions.about }
  91. }
  92. }
  93. Component
  94. {
  95. id: extensionsMenuItem
  96. MenuItem
  97. {
  98. text: modelText
  99. onTriggered: extensionsModel.subMenuTriggered(extensionName, modelText)
  100. }
  101. }
  102. Component
  103. {
  104. id: extensionsMenuSeparator
  105. MenuSeparator {}
  106. }
  107. // ###############################################################################################
  108. // Definition of other components that are linked to the menus
  109. // ###############################################################################################
  110. WorkspaceSummaryDialog
  111. {
  112. id: saveWorkspaceDialog
  113. property var args
  114. onYes: UM.OutputDeviceManager.requestWriteToDevice("local_file", PrintInformation.jobName, args)
  115. }
  116. MessageDialog
  117. {
  118. id: newProjectDialog
  119. modality: Qt.ApplicationModal
  120. title: catalog.i18nc("@title:window", "New project")
  121. 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.")
  122. standardButtons: StandardButton.Yes | StandardButton.No
  123. icon: StandardIcon.Question
  124. onYes:
  125. {
  126. CuraApplication.resetWorkspace()
  127. Cura.Actions.resetProfile.trigger()
  128. UM.Controller.setActiveStage("PrepareStage")
  129. }
  130. }
  131. UM.ExtensionModel
  132. {
  133. id: curaExtensions
  134. }
  135. // ###############################################################################################
  136. // Definition of all the connections
  137. // ###############################################################################################
  138. Connections
  139. {
  140. target: Cura.Actions.newProject
  141. onTriggered:
  142. {
  143. if(Printer.platformActivity || Cura.MachineManager.hasUserSettings)
  144. {
  145. newProjectDialog.visible = true
  146. }
  147. }
  148. }
  149. // show the Toolbox
  150. Connections
  151. {
  152. target: Cura.Actions.browsePackages
  153. onTriggered:
  154. {
  155. curaExtensions.callExtensionMethod("Toolbox", "launch")
  156. }
  157. }
  158. // Show the Marketplace dialog at the materials tab
  159. Connections
  160. {
  161. target: Cura.Actions.marketplaceMaterials
  162. onTriggered:
  163. {
  164. curaExtensions.callExtensionMethod("Toolbox", "launch")
  165. curaExtensions.callExtensionMethod("Toolbox", "setViewCategoryToMaterials")
  166. }
  167. }
  168. }