Actions.qml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. // Copyright (c) 2023 UltiMaker
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. pragma Singleton
  4. import QtQuick 2.10
  5. import QtQuick.Controls 2.4
  6. import UM 1.1 as UM
  7. import Cura 1.5 as Cura
  8. Item
  9. {
  10. property alias newProject: newProjectAction
  11. property alias open: openAction
  12. property alias quit: quitAction
  13. property alias undo: undoAction
  14. property alias redo: redoAction
  15. property alias view3DCamera: view3DCameraAction
  16. property alias viewFrontCamera: viewFrontCameraAction
  17. property alias viewTopCamera: viewTopCameraAction
  18. property alias viewBottomCamera: viewBottomCameraAction
  19. property alias viewLeftSideCamera: viewLeftSideCameraAction
  20. property alias viewRightSideCamera: viewRightSideCameraAction
  21. property alias deleteSelection: deleteSelectionAction
  22. property alias centerSelection: centerSelectionAction
  23. property alias multiplySelection: multiplySelectionAction
  24. property alias deleteObject: deleteObjectAction
  25. property alias centerObject: centerObjectAction
  26. property alias groupObjects: groupObjectsAction
  27. property alias unGroupObjects:unGroupObjectsAction
  28. property alias mergeObjects: mergeObjectsAction
  29. //property alias unMergeObjects: unMergeObjectsAction
  30. property alias printObjectBeforePrevious: printObjectBeforePreviousAction
  31. property alias printObjectAfterNext: printObjectAfterNextAction
  32. property alias multiplyObject: multiplyObjectAction
  33. property alias dropAll: dropAllAction
  34. property alias selectAll: selectAllAction
  35. property alias deleteAll: deleteAllAction
  36. property alias reloadAll: reloadAllAction
  37. property alias arrangeAll: arrangeAllAction
  38. property alias arrangeAllGrid: arrangeAllGridAction
  39. property alias resetAllTranslation: resetAllTranslationAction
  40. property alias resetAll: resetAllAction
  41. property alias addMachine: addMachineAction
  42. property alias configureMachines: settingsAction
  43. property alias addProfile: addProfileAction
  44. property alias updateProfile: updateProfileAction
  45. property alias resetProfile: resetProfileAction
  46. property alias manageProfiles: manageProfilesAction
  47. property alias manageMaterials: manageMaterialsAction
  48. property alias marketplaceMaterials: marketplaceMaterialsAction
  49. property alias preferences: preferencesAction
  50. property alias showProfileFolder: showProfileFolderAction
  51. property alias documentation: documentationAction
  52. property alias openSponsershipPage: openSponsershipPageAction
  53. property alias reportBug: reportBugAction
  54. property alias whatsNew: whatsNewAction
  55. property alias about: aboutAction
  56. property alias toggleFullScreen: toggleFullScreenAction
  57. property alias exitFullScreen: exitFullScreenAction
  58. property alias configureSettingVisibility: configureSettingVisibilityAction
  59. property alias browsePackages: browsePackagesAction
  60. property alias paste: pasteAction
  61. property alias copy: copyAction
  62. property alias cut: cutAction
  63. property alias exportProjectForSupport: exportProjectForSupportAction
  64. readonly property bool copy_paste_enabled: {
  65. const all_enabled_packages = CuraApplication.getPackageManager().allEnabledPackages;
  66. return all_enabled_packages.includes("3MFReader") && all_enabled_packages.includes("3MFWriter");
  67. }
  68. UM.I18nCatalog{id: catalog; name: "cura"}
  69. Action
  70. {
  71. id: openSponsershipPageAction
  72. onTriggered: Qt.openUrlExternally("https://ultimaker.com/software/ultimaker-cura/sponsor/")
  73. text: catalog.i18nc("@action:inmenu", "Sponsor Cura")
  74. }
  75. Action
  76. {
  77. id: toggleFullScreenAction
  78. shortcut: StandardKey.FullScreen
  79. text: catalog.i18nc("@action:inmenu", "Toggle Full Screen")
  80. icon.name: "view-fullscreen"
  81. }
  82. Action
  83. {
  84. id: exitFullScreenAction
  85. text: catalog.i18nc("@action:inmenu", "Exit Full Screen")
  86. icon.name: "view-fullscreen"
  87. }
  88. Action
  89. {
  90. id: undoAction
  91. text: catalog.i18nc("@action:inmenu menubar:edit", "&Undo")
  92. icon.name: "edit-undo"
  93. shortcut: StandardKey.Undo
  94. onTriggered: CuraActions.undo()
  95. enabled: CuraActions.canUndo
  96. }
  97. Action
  98. {
  99. id: redoAction
  100. text: catalog.i18nc("@action:inmenu menubar:edit", "&Redo")
  101. icon.name: "edit-redo"
  102. shortcut: StandardKey.Redo
  103. onTriggered: CuraActions.redo()
  104. enabled: CuraActions.canRedo
  105. }
  106. Action
  107. {
  108. id: quitAction
  109. //On MacOS, don't translate the "Quit" word.
  110. //Qt moves the "quit" entry to a different place, and if it got renamed can't find it again when it attempts to
  111. //delete the item upon closing the application, causing a crash.
  112. //In the new location, these items are translated automatically according to the system's language.
  113. //For more information, see:
  114. //- https://doc.qt.io/qt-5/macos-issues.html#menu-bar
  115. //- https://doc.qt.io/qt-5/qmenubar.html#qmenubar-as-a-global-menu-bar
  116. text: (Qt.platform.os == "osx") ? "&Quit" : catalog.i18nc("@action:inmenu menubar:file", "&Quit")
  117. icon.name: "application-exit"
  118. shortcut: StandardKey.Quit
  119. }
  120. Action
  121. {
  122. id: view3DCameraAction
  123. text: catalog.i18nc("@action:inmenu menubar:view", "3D View")
  124. onTriggered: UM.Controller.setCameraRotation("3d", 0)
  125. }
  126. Action
  127. {
  128. id: viewFrontCameraAction
  129. text: catalog.i18nc("@action:inmenu menubar:view", "Front View")
  130. onTriggered: UM.Controller.setCameraRotation("home", 0)
  131. }
  132. Action
  133. {
  134. id: viewTopCameraAction
  135. text: catalog.i18nc("@action:inmenu menubar:view", "Top View")
  136. onTriggered: UM.Controller.setCameraRotation("y", 90)
  137. }
  138. Action
  139. {
  140. id: viewBottomCameraAction
  141. text: catalog.i18nc("@action:inmenu menubar:view", "Bottom View")
  142. onTriggered: UM.Controller.setCameraRotation("y", -90)
  143. }
  144. Action
  145. {
  146. id: viewLeftSideCameraAction
  147. text: catalog.i18nc("@action:inmenu menubar:view", "Left Side View")
  148. onTriggered: UM.Controller.setCameraRotation("x", 90)
  149. }
  150. Action
  151. {
  152. id: viewRightSideCameraAction
  153. text: catalog.i18nc("@action:inmenu menubar:view", "Right Side View")
  154. onTriggered: UM.Controller.setCameraRotation("x", -90)
  155. }
  156. Action
  157. {
  158. id: preferencesAction
  159. //On MacOS, don't translate the "Configure" word.
  160. //Qt moves the "configure" entry to a different place, and if it got renamed can't find it again when it
  161. //attempts to delete the item upon closing the application, causing a crash.
  162. //In the new location, these items are translated automatically according to the system's language.
  163. //For more information, see:
  164. //- https://doc.qt.io/qt-5/macos-issues.html#menu-bar
  165. //- https://doc.qt.io/qt-5/qmenubar.html#qmenubar-as-a-global-menu-bar
  166. text: (Qt.platform.os == "osx") ? "Configure Cura..." : catalog.i18nc("@action:inmenu", "Configure Cura...")
  167. icon.name: "configure"
  168. // on MacOS it us customary to assign the ctrl+, hotkey to open a general settings menu
  169. shortcut: (Qt.platform.os == "osx") ? "Ctrl+," : ""
  170. }
  171. Action
  172. {
  173. id: addMachineAction
  174. text: catalog.i18nc("@action:inmenu menubar:printer", "&Add Printer...")
  175. }
  176. Action
  177. {
  178. id: settingsAction
  179. text: catalog.i18nc("@action:inmenu menubar:printer", "Manage Pr&inters...")
  180. icon.name: "configure"
  181. }
  182. Action
  183. {
  184. id: manageMaterialsAction
  185. text: catalog.i18nc("@action:inmenu", "Manage Materials...")
  186. icon.name: "configure"
  187. shortcut: "Ctrl+K"
  188. }
  189. Action
  190. {
  191. id: marketplaceMaterialsAction
  192. text: catalog.i18nc("@action:inmenu Marketplace is a brand name of UltiMaker's, so don't translate.", "Add more materials from Marketplace")
  193. }
  194. Action
  195. {
  196. id: updateProfileAction
  197. enabled: !Cura.MachineManager.stacksHaveErrors && Cura.MachineManager.hasUserSettings && Cura.MachineManager.activeQualityChangesGroup != null
  198. text: catalog.i18nc("@action:inmenu menubar:profile", "&Update profile with current settings/overrides");
  199. onTriggered: Cura.ContainerManager.updateQualityChanges()
  200. }
  201. Action
  202. {
  203. id: resetProfileAction
  204. enabled: Cura.MachineManager.hasUserSettings
  205. text: catalog.i18nc("@action:inmenu menubar:profile", "&Discard current changes")
  206. onTriggered:
  207. {
  208. forceActiveFocus()
  209. Cura.ContainerManager.clearUserContainers()
  210. }
  211. }
  212. Action
  213. {
  214. id: addProfileAction
  215. enabled: !Cura.MachineManager.stacksHaveErrors && Cura.MachineManager.hasUserSettings
  216. text: catalog.i18nc("@action:inmenu menubar:profile", "&Create profile from current settings/overrides...")
  217. }
  218. Action
  219. {
  220. id: manageProfilesAction
  221. text: catalog.i18nc("@action:inmenu menubar:profile", "Manage Profiles...")
  222. icon.name: "configure"
  223. shortcut: "Ctrl+J"
  224. }
  225. Action
  226. {
  227. id: documentationAction
  228. text: catalog.i18nc("@action:inmenu menubar:help", "Show Online &Documentation")
  229. icon.name: "help-contents"
  230. shortcut: StandardKey.Help
  231. onTriggered: CuraActions.openDocumentation()
  232. }
  233. Action {
  234. id: reportBugAction
  235. text: catalog.i18nc("@action:inmenu menubar:help", "Report a &Bug")
  236. icon.name: "tools-report-bug"
  237. onTriggered: CuraActions.openBugReportPage()
  238. }
  239. Action
  240. {
  241. id: whatsNewAction
  242. text: catalog.i18nc("@action:inmenu menubar:help", "What's New")
  243. }
  244. Action
  245. {
  246. id: aboutAction
  247. //On MacOS, don't translate the "About" word.
  248. //Qt moves the "about" entry to a different place, and if it got renamed can't find it again when it
  249. //attempts to delete the item upon closing the application, causing a crash.
  250. //In the new location, these items are translated automatically according to the system's language.
  251. //For more information, see:
  252. //- https://doc.qt.io/qt-5/macos-issues.html#menu-bar
  253. //- https://doc.qt.io/qt-5/qmenubar.html#qmenubar-as-a-global-menu-bar
  254. text: (Qt.platform.os == "osx") ? "About..." : catalog.i18nc("@action:inmenu menubar:help", "About...")
  255. icon.name: "help-about"
  256. }
  257. Action
  258. {
  259. id: deleteSelectionAction
  260. text: catalog.i18nc("@action:inmenu menubar:edit", "Delete Selected")
  261. enabled: UM.Controller.toolsEnabled && UM.Selection.hasSelection
  262. icon.name: "edit-delete"
  263. shortcut: StandardKey.Delete | "Backspace"
  264. onTriggered: CuraActions.deleteSelection()
  265. }
  266. Action
  267. {
  268. id: centerSelectionAction
  269. text: catalog.i18nc("@action:inmenu menubar:edit", "Center Selected")
  270. enabled: UM.Controller.toolsEnabled && UM.Selection.hasSelection
  271. icon.name: "align-vertical-center"
  272. onTriggered: CuraActions.centerSelection()
  273. }
  274. Action
  275. {
  276. id: copyAction
  277. text: catalog.i18nc("@action:inmenu menubar:edit", "Copy to clipboard")
  278. onTriggered: CuraActions.copy()
  279. enabled: UM.Controller.toolsEnabled && UM.Selection.hasSelection && copy_paste_enabled
  280. shortcut: StandardKey.Copy
  281. }
  282. Action
  283. {
  284. id: pasteAction
  285. text: catalog.i18nc("@action:inmenu menubar:edit", "Paste from clipboard")
  286. onTriggered: CuraActions.paste()
  287. enabled: UM.Controller.toolsEnabled && copy_paste_enabled
  288. shortcut: StandardKey.Paste
  289. }
  290. Action
  291. {
  292. id: cutAction
  293. text: catalog.i18nc("@action:inmenu menubar:edit", "Cut")
  294. onTriggered: CuraActions.cut()
  295. enabled: UM.Controller.toolsEnabled && UM.Selection.hasSelection && copy_paste_enabled
  296. shortcut: StandardKey.Cut
  297. }
  298. Action
  299. {
  300. id: multiplySelectionAction
  301. text: catalog.i18nc("@action:inmenu menubar:edit", "Multiply Selected")
  302. enabled: UM.Controller.toolsEnabled && UM.Selection.hasSelection
  303. icon.name: "edit-duplicate"
  304. shortcut: "Ctrl+M"
  305. }
  306. Action
  307. {
  308. id: deleteObjectAction
  309. text: catalog.i18nc("@action:inmenu","Delete Model")
  310. enabled: UM.Controller.toolsEnabled
  311. icon.name: "edit-delete"
  312. }
  313. Action
  314. {
  315. id: centerObjectAction
  316. text: catalog.i18nc("@action:inmenu","Ce&nter Model on Platform")
  317. }
  318. Action
  319. {
  320. id: groupObjectsAction
  321. text: catalog.i18nc("@action:inmenu menubar:edit","&Group Models")
  322. enabled: UM.Selection.selectionCount > 1 ? true: false
  323. icon.name: "object-group"
  324. shortcut: "Ctrl+G"
  325. onTriggered: CuraApplication.groupSelected()
  326. }
  327. Action
  328. {
  329. id: reloadQmlAction
  330. onTriggered:
  331. {
  332. CuraApplication.reloadQML()
  333. }
  334. shortcut: "Shift+F5"
  335. }
  336. Action
  337. {
  338. id: unGroupObjectsAction
  339. text: catalog.i18nc("@action:inmenu menubar:edit","Ungroup Models")
  340. enabled: UM.Selection.isGroupSelected
  341. icon.name: "object-ungroup"
  342. shortcut: "Ctrl+Shift+G"
  343. onTriggered: CuraApplication.ungroupSelected()
  344. }
  345. Action
  346. {
  347. id: printObjectBeforePreviousAction
  348. text: catalog.i18nc("@action:inmenu menubar:edit","Print Before") + " " + PrintOrderManager.previousNodeName
  349. enabled: PrintOrderManager.shouldEnablePrintBeforeAction
  350. icon.name: "print-before"
  351. shortcut: "PgUp"
  352. onTriggered: PrintOrderManager.swapSelectedAndPreviousNodes()
  353. }
  354. Action
  355. {
  356. id: printObjectAfterNextAction
  357. text: catalog.i18nc("@action:inmenu menubar:edit","Print After") + " " + PrintOrderManager.nextNodeName
  358. enabled: PrintOrderManager.shouldEnablePrintAfterAction
  359. icon.name: "print-after"
  360. shortcut: "PgDown"
  361. onTriggered: PrintOrderManager.swapSelectedAndNextNodes()
  362. }
  363. Action
  364. {
  365. id: mergeObjectsAction
  366. text: catalog.i18nc("@action:inmenu menubar:edit","&Merge Models")
  367. enabled: UM.Selection.selectionCount > 1 ? true: false
  368. icon.name: "merge"
  369. shortcut: "Ctrl+Alt+G"
  370. onTriggered: CuraApplication.mergeSelected()
  371. }
  372. Action
  373. {
  374. id: multiplyObjectAction
  375. text: catalog.i18nc("@action:inmenu","&Multiply Model...")
  376. icon.name: "edit-duplicate"
  377. }
  378. Action
  379. {
  380. id: selectAllAction
  381. text: catalog.i18nc("@action:inmenu menubar:edit","Select All Models")
  382. enabled: UM.Controller.toolsEnabled
  383. icon.name: "edit-select-all"
  384. shortcut: "Ctrl+A"
  385. onTriggered: CuraApplication.selectAll()
  386. }
  387. Action
  388. {
  389. id: deleteAllAction
  390. text: catalog.i18nc("@action:inmenu menubar:edit","Clear Build Plate")
  391. enabled: UM.Controller.toolsEnabled
  392. icon.name: "edit-delete"
  393. shortcut: "Ctrl+D"
  394. onTriggered: CuraApplication.deleteAll()
  395. }
  396. Action
  397. {
  398. id: reloadAllAction
  399. text: catalog.i18nc("@action:inmenu menubar:file","Reload All Models")
  400. icon.name: "document-revert"
  401. shortcut: "F5"
  402. onTriggered: CuraApplication.reloadAll()
  403. }
  404. Action
  405. {
  406. id: arrangeAllAction
  407. text: catalog.i18nc("@action:inmenu menubar:edit","Arrange All Models")
  408. onTriggered: Printer.arrangeAll()
  409. shortcut: "Ctrl+R"
  410. }
  411. Action
  412. {
  413. id: arrangeAllGridAction
  414. text: catalog.i18nc("@action:inmenu menubar:edit","Arrange All Models in a grid")
  415. onTriggered: Printer.arrangeAllInGrid()
  416. shortcut: "Shift+Ctrl+R"
  417. }
  418. Action
  419. {
  420. id: dropAllAction
  421. text: catalog.i18nc("@action:inmenu menubar:edit","Drop All Models to buildplate")
  422. shortcut: "Ctrl+B"
  423. onTriggered: CuraApplication.setWorkplaceDropToBuildplate()
  424. }
  425. Action
  426. {
  427. id: resetAllTranslationAction
  428. text: catalog.i18nc("@action:inmenu menubar:edit","Reset All Model Positions")
  429. onTriggered: CuraApplication.resetAllTranslation()
  430. }
  431. Action
  432. {
  433. id: resetAllAction
  434. text: catalog.i18nc("@action:inmenu menubar:edit","Reset All Model Transformations")
  435. onTriggered: CuraApplication.resetAll()
  436. }
  437. Action
  438. {
  439. id: openAction
  440. property var fileProviderModel: CuraApplication.getFileProviderModel()
  441. text: catalog.i18nc("@action:inmenu menubar:file","&Open File(s)...")
  442. icon.name: "document-open"
  443. // Unassign the shortcut when there are more than one file providers, since then the file provider's shortcut is
  444. // enabled instead, and Ctrl+O is assigned to the local file provider
  445. shortcut: fileProviderModel.count == 1 ? StandardKey.Open : ""
  446. }
  447. Action
  448. {
  449. id: arrangeSelectionAction
  450. text: catalog.i18nc("@action:inmenu menubar:edit", "Arrange Selection")
  451. onTriggered: Printer.arrangeSelection()
  452. }
  453. Action
  454. {
  455. id: newProjectAction
  456. text: catalog.i18nc("@action:inmenu menubar:file","&New Project...")
  457. shortcut: StandardKey.New
  458. }
  459. Action
  460. {
  461. id: showProfileFolderAction
  462. text: catalog.i18nc("@action:inmenu menubar:help","Show Configuration Folder")
  463. }
  464. Action
  465. {
  466. id: configureSettingVisibilityAction
  467. text: catalog.i18nc("@action:menu", "Configure setting visibility...")
  468. icon.name: "configure"
  469. }
  470. Action
  471. {
  472. id: browsePackagesAction
  473. text: "&Marketplace"
  474. icon.name: "plugins_browse"
  475. }
  476. Action
  477. {
  478. id: exportProjectForSupportAction
  479. text: catalog.i18nc("@action:inmenu menubar:help", "Export Package For Technical Support")
  480. onTriggered:
  481. {
  482. var exportName = Qt.formatDateTime(new Date(), "'export-'yyyyMMdd-HHmmss")
  483. var args = {
  484. "filter_by_machine": false,
  485. "file_type": "workspace",
  486. "preferred_mimetypes": "application/vnd.ms-package.3dmanufacturing-3dmodel+xml",
  487. "limit_mimetypes": ["application/vnd.ms-package.3dmanufacturing-3dmodel+xml"],
  488. "silent_save": true,
  489. "writer_args": {
  490. "include_log": true
  491. }
  492. };
  493. UM.OutputDeviceManager.requestWriteToDevice("local_file", exportName, args)
  494. }
  495. }
  496. }