ApplicationMenu.qml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. height: UM.Theme.getSize("context_menu").height
  19. background: Rectangle {
  20. color: UM.Theme.getColor("background_1")
  21. }
  22. delegate: MenuBarItem
  23. {
  24. id: menuBarItem
  25. contentItem: UM.Label
  26. {
  27. text: menuBarItem.text.replace(new RegExp("&([A-Za-z])"), function (match, character)
  28. {
  29. return `<u>${character}</u>`
  30. })
  31. horizontalAlignment: Text.AlignLeft
  32. verticalAlignment: Text.AlignVCenter
  33. }
  34. leftPadding: UM.Theme.getSize("default_margin").width
  35. rightPadding: UM.Theme.getSize("default_margin").width
  36. background: Rectangle
  37. {
  38. color: menuBarItem.highlighted ? UM.Theme.getColor("background_2") : "transparent"
  39. }
  40. }
  41. FileMenu {}
  42. EditMenu {}
  43. ViewMenu {}
  44. SettingsMenu
  45. {
  46. //On MacOS, don't translate the "Settings" word.
  47. //Qt moves the "settings" entry to a different place, and if it got renamed can't find it again when it
  48. //attempts to delete the item upon closing the application, causing a crash.
  49. //In the new location, these items are translated automatically according to the system's language.
  50. //For more information, see:
  51. //- https://doc.qt.io/qt-5/macos-issues.html#menu-bar
  52. //- https://doc.qt.io/qt-5/qmenubar.html#qmenubar-as-a-global-menu-bar
  53. title: (Qt.platform.os == "osx") ? "&Settings" : catalog.i18nc("@title:menu menubar:toplevel", "&Settings")
  54. }
  55. ExtensionMenu { id: extensionMenu }
  56. PreferencesMenu {}
  57. HelpMenu {}
  58. }
  59. // ###############################################################################################
  60. // Definition of other components that are linked to the menus
  61. // ###############################################################################################
  62. WorkspaceSummaryDialog
  63. {
  64. id: saveWorkspaceDialog
  65. property var args
  66. onAccepted: UM.OutputDeviceManager.requestWriteToDevice("local_file", PrintInformation.jobName, args)
  67. }
  68. Cura.MessageDialog
  69. {
  70. id: newProjectDialog
  71. title: catalog.i18nc("@title:window", "New project")
  72. 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.")
  73. standardButtons: Dialog.Yes | Dialog.No
  74. onAccepted:
  75. {
  76. CuraApplication.resetWorkspace()
  77. Cura.Actions.resetProfile.trigger()
  78. UM.Controller.setActiveStage("PrepareStage")
  79. }
  80. }
  81. // ###############################################################################################
  82. // Definition of all the connections
  83. // ###############################################################################################
  84. Connections
  85. {
  86. target: Cura.Actions.newProject
  87. function onTriggered()
  88. {
  89. if(Printer.platformActivity || Cura.MachineManager.hasUserSettings)
  90. {
  91. newProjectDialog.visible = true
  92. }
  93. }
  94. }
  95. // show the Toolbox
  96. Connections
  97. {
  98. target: Cura.Actions.browsePackages
  99. function onTriggered()
  100. {
  101. extensionMenu.extensionModel.callExtensionMethod("Marketplace", "show")
  102. }
  103. }
  104. // Show the Marketplace dialog at the materials tab
  105. Connections
  106. {
  107. target: Cura.Actions.marketplaceMaterials
  108. function onTriggered()
  109. {
  110. extensionMenu.extensionModel.callExtensionMethod("Marketplace", "show")
  111. extensionMenu.extensionModel.callExtensionMethod("Marketplace", "setVisibleTabToMaterials")
  112. }
  113. }
  114. }