ApplicationMenu.qml 6.0 KB

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