Cura.qml 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966
  1. // Copyright (c) 2015 Ultimaker B.V.
  2. // Cura is released under the terms of the AGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 1.1
  5. import QtQuick.Controls.Styles 1.1
  6. import QtQuick.Layouts 1.1
  7. import QtQuick.Dialogs 1.1
  8. import UM 1.3 as UM
  9. import Cura 1.0 as Cura
  10. import "Menus"
  11. UM.MainWindow
  12. {
  13. id: base
  14. //: Cura application window title
  15. title: catalog.i18nc("@title:window","Cura");
  16. viewportRect: Qt.rect(0, 0, (base.width - sidebar.width) / base.width, 1.0)
  17. property bool monitoringPrint: false
  18. Component.onCompleted:
  19. {
  20. Printer.setMinimumWindowSize(UM.Theme.getSize("window_minimum_size"))
  21. // Workaround silly issues with QML Action's shortcut property.
  22. //
  23. // Currently, there is no way to define shortcuts as "Application Shortcut".
  24. // This means that all Actions are "Window Shortcuts". The code for this
  25. // implements a rather naive check that just checks if any of the action's parents
  26. // are a window. Since the "Actions" object is a singleton it has no parent by
  27. // default. If we set its parent to something contained in this window, the
  28. // shortcut will activate properly because one of its parents is a window.
  29. //
  30. // This has been fixed for QtQuick Controls 2 since the Shortcut item has a context property.
  31. Cura.Actions.parent = backgroundItem
  32. }
  33. Item
  34. {
  35. id: backgroundItem;
  36. anchors.fill: parent;
  37. UM.I18nCatalog{id: catalog; name:"cura"}
  38. signal hasMesh(string name) //this signal sends the filebase name so it can be used for the JobSpecs.qml
  39. function getMeshName(path){
  40. //takes the path the complete path of the meshname and returns only the filebase
  41. var fileName = path.slice(path.lastIndexOf("/") + 1)
  42. var fileBase = fileName.slice(0, fileName.indexOf("."))
  43. return fileBase
  44. }
  45. //DeleteSelection on the keypress backspace event
  46. Keys.onPressed: {
  47. if (event.key == Qt.Key_Backspace)
  48. {
  49. Cura.Actions.deleteSelection.trigger()
  50. }
  51. }
  52. UM.ApplicationMenu
  53. {
  54. id: menu
  55. window: base
  56. Menu
  57. {
  58. id: fileMenu
  59. title: catalog.i18nc("@title:menu menubar:toplevel","&File");
  60. MenuItem
  61. {
  62. action: Cura.Actions.newProject;
  63. }
  64. MenuItem
  65. {
  66. action: Cura.Actions.open;
  67. }
  68. RecentFilesMenu { }
  69. MenuItem
  70. {
  71. action: Cura.Actions.loadWorkspace
  72. }
  73. MenuSeparator { }
  74. MenuItem
  75. {
  76. text: catalog.i18nc("@action:inmenu menubar:file", "&Save Selection to File");
  77. enabled: UM.Selection.hasSelection;
  78. iconName: "document-save-as";
  79. onTriggered: UM.OutputDeviceManager.requestWriteSelectionToDevice("local_file", PrintInformation.jobName, { "filter_by_machine": false, "preferred_mimetype": "application/vnd.ms-package.3dmanufacturing-3dmodel+xml"});
  80. }
  81. Menu
  82. {
  83. id: saveAllMenu
  84. title: catalog.i18nc("@title:menu menubar:file","Save &All")
  85. iconName: "document-save-all";
  86. enabled: devicesModel.rowCount() > 0 && UM.Backend.progress > 0.99;
  87. Instantiator
  88. {
  89. model: UM.OutputDevicesModel { id: devicesModel; }
  90. MenuItem
  91. {
  92. text: model.description;
  93. onTriggered: UM.OutputDeviceManager.requestWriteToDevice(model.id, PrintInformation.jobName, { "filter_by_machine": false, "preferred_mimetype": "application/vnd.ms-package.3dmanufacturing-3dmodel+xml"});
  94. }
  95. onObjectAdded: saveAllMenu.insertItem(index, object)
  96. onObjectRemoved: saveAllMenu.removeItem(object)
  97. }
  98. }
  99. MenuItem
  100. {
  101. id: saveWorkspaceMenu
  102. text: catalog.i18nc("@title:menu menubar:file","Save project")
  103. onTriggered:
  104. {
  105. if(UM.Preferences.getValue("cura/dialog_on_project_save"))
  106. {
  107. saveWorkspaceDialog.open()
  108. }
  109. else
  110. {
  111. UM.OutputDeviceManager.requestWriteToDevice("local_file", PrintInformation.jobName, { "filter_by_machine": false, "file_type": "workspace" })
  112. }
  113. }
  114. }
  115. MenuItem { action: Cura.Actions.reloadAll; }
  116. MenuSeparator { }
  117. MenuItem { action: Cura.Actions.quit; }
  118. }
  119. Menu
  120. {
  121. title: catalog.i18nc("@title:menu menubar:toplevel","&Edit");
  122. MenuItem { action: Cura.Actions.undo; }
  123. MenuItem { action: Cura.Actions.redo; }
  124. MenuSeparator { }
  125. MenuItem { action: Cura.Actions.selectAll; }
  126. MenuItem { action: Cura.Actions.deleteSelection; }
  127. MenuItem { action: Cura.Actions.deleteAll; }
  128. MenuItem { action: Cura.Actions.resetAllTranslation; }
  129. MenuItem { action: Cura.Actions.resetAll; }
  130. MenuSeparator { }
  131. MenuItem { action: Cura.Actions.groupObjects;}
  132. MenuItem { action: Cura.Actions.mergeObjects;}
  133. MenuItem { action: Cura.Actions.unGroupObjects;}
  134. }
  135. ViewMenu { title: catalog.i18nc("@title:menu", "&View") }
  136. Menu
  137. {
  138. id: settingsMenu
  139. title: catalog.i18nc("@title:menu", "&Settings")
  140. PrinterMenu { title: catalog.i18nc("@title:menu menubar:toplevel", "&Printer") }
  141. Instantiator
  142. {
  143. model: Cura.ExtrudersModel { simpleNames: true }
  144. Menu {
  145. title: model.name
  146. visible: machineExtruderCount.properties.value > 1
  147. NozzleMenu { title: Cura.MachineManager.activeDefinitionVariantsName; visible: Cura.MachineManager.hasVariants; extruderIndex: index }
  148. MaterialMenu { title: catalog.i18nc("@title:menu", "&Material"); visible: Cura.MachineManager.hasMaterials; extruderIndex: index }
  149. ProfileMenu { title: catalog.i18nc("@title:menu", "&Profile"); }
  150. MenuSeparator { }
  151. MenuItem { text: catalog.i18nc("@action:inmenu", "Set as Active Extruder"); onTriggered: ExtruderManager.setActiveExtruderIndex(model.index) }
  152. }
  153. onObjectAdded: settingsMenu.insertItem(index, object)
  154. onObjectRemoved: settingsMenu.removeItem(object)
  155. }
  156. NozzleMenu { title: Cura.MachineManager.activeDefinitionVariantsName; visible: machineExtruderCount.properties.value <= 1 && Cura.MachineManager.hasVariants }
  157. MaterialMenu { title: catalog.i18nc("@title:menu", "&Material"); visible: machineExtruderCount.properties.value <= 1 && Cura.MachineManager.hasMaterials }
  158. ProfileMenu { title: catalog.i18nc("@title:menu", "&Profile"); visible: machineExtruderCount.properties.value <= 1 }
  159. MenuSeparator { }
  160. MenuItem { action: Cura.Actions.configureSettingVisibility }
  161. }
  162. Menu
  163. {
  164. id: extension_menu
  165. title: catalog.i18nc("@title:menu menubar:toplevel","E&xtensions");
  166. Instantiator
  167. {
  168. id: extensions
  169. model: UM.ExtensionModel { }
  170. Menu
  171. {
  172. id: sub_menu
  173. title: model.name;
  174. visible: actions != null
  175. enabled:actions != null
  176. Instantiator
  177. {
  178. model: actions
  179. MenuItem
  180. {
  181. text: model.text
  182. onTriggered: extensions.model.subMenuTriggered(name, model.text)
  183. }
  184. onObjectAdded: sub_menu.insertItem(index, object)
  185. onObjectRemoved: sub_menu.removeItem(object)
  186. }
  187. }
  188. onObjectAdded: extension_menu.insertItem(index, object)
  189. onObjectRemoved: extension_menu.removeItem(object)
  190. }
  191. }
  192. Menu
  193. {
  194. title: catalog.i18nc("@title:menu menubar:toplevel","P&references");
  195. MenuItem { action: Cura.Actions.preferences; }
  196. }
  197. Menu
  198. {
  199. //: Help menu
  200. title: catalog.i18nc("@title:menu menubar:toplevel","&Help");
  201. MenuItem { action: Cura.Actions.showProfileFolder; }
  202. MenuItem { action: Cura.Actions.documentation; }
  203. MenuItem { action: Cura.Actions.reportBug; }
  204. MenuSeparator { }
  205. MenuItem { action: Cura.Actions.about; }
  206. }
  207. }
  208. UM.SettingPropertyProvider
  209. {
  210. id: machineExtruderCount
  211. containerStackId: Cura.MachineManager.activeMachineId
  212. key: "machine_extruder_count"
  213. watchedProperties: [ "value" ]
  214. storeIndex: 0
  215. }
  216. Item
  217. {
  218. id: contentItem;
  219. y: menu.height
  220. width: parent.width;
  221. height: parent.height - menu.height;
  222. Keys.forwardTo: menu
  223. DropArea
  224. {
  225. anchors.fill: parent;
  226. onDropped:
  227. {
  228. if (drop.urls.length > 0)
  229. {
  230. // Import models
  231. var imported_model = -1;
  232. for (var i in drop.urls)
  233. {
  234. // There is no endsWith in this version of JS...
  235. if ((drop.urls[i].length <= 12) || (drop.urls[i].substring(drop.urls[i].length-12) !== ".curaprofile")) {
  236. // Drop an object
  237. Printer.readLocalFile(drop.urls[i]);
  238. if (imported_model == -1)
  239. {
  240. imported_model = i;
  241. }
  242. }
  243. }
  244. // Import profiles
  245. var import_result = Cura.ContainerManager.importProfiles(drop.urls);
  246. if (import_result.message !== "") {
  247. messageDialog.text = import_result.message
  248. if (import_result.status == "ok")
  249. {
  250. messageDialog.icon = StandardIcon.Information
  251. }
  252. else
  253. {
  254. messageDialog.icon = StandardIcon.Critical
  255. }
  256. messageDialog.open()
  257. }
  258. if (imported_model != -1)
  259. {
  260. var meshName = backgroundItem.getMeshName(drop.urls[imported_model].toString())
  261. backgroundItem.hasMesh(decodeURIComponent(meshName))
  262. }
  263. }
  264. }
  265. }
  266. JobSpecs
  267. {
  268. id: jobSpecs
  269. anchors
  270. {
  271. bottom: parent.bottom;
  272. right: sidebar.left;
  273. bottomMargin: UM.Theme.getSize("default_margin").height;
  274. rightMargin: UM.Theme.getSize("default_margin").width;
  275. }
  276. }
  277. Loader
  278. {
  279. id: view_panel
  280. anchors.top: viewModeButton.bottom
  281. anchors.topMargin: UM.Theme.getSize("default_margin").height;
  282. anchors.left: viewModeButton.left;
  283. height: childrenRect.height;
  284. source: UM.ActiveView.valid ? UM.ActiveView.activeViewPanel : "";
  285. }
  286. Button
  287. {
  288. id: openFileButton;
  289. text: catalog.i18nc("@action:button","Open File");
  290. iconSource: UM.Theme.getIcon("load")
  291. style: UM.Theme.styles.tool_button
  292. tooltip: '';
  293. anchors
  294. {
  295. top: parent.top;
  296. left: parent.left;
  297. }
  298. action: Cura.Actions.open;
  299. }
  300. Image
  301. {
  302. id: logo
  303. anchors
  304. {
  305. left: parent.left
  306. leftMargin: UM.Theme.getSize("default_margin").width;
  307. bottom: parent.bottom
  308. bottomMargin: UM.Theme.getSize("default_margin").height;
  309. }
  310. source: UM.Theme.getImage("logo");
  311. width: UM.Theme.getSize("logo").width;
  312. height: UM.Theme.getSize("logo").height;
  313. z: -1;
  314. sourceSize.width: width;
  315. sourceSize.height: height;
  316. }
  317. Toolbar
  318. {
  319. id: toolbar;
  320. property int mouseX: base.mouseX
  321. property int mouseY: base.mouseY
  322. anchors {
  323. top: openFileButton.bottom;
  324. topMargin: UM.Theme.getSize("window_margin").height;
  325. left: parent.left;
  326. }
  327. }
  328. Sidebar
  329. {
  330. id: sidebar;
  331. anchors
  332. {
  333. top: parent.top;
  334. bottom: parent.bottom;
  335. right: parent.right;
  336. }
  337. z: 1
  338. onMonitoringPrintChanged: base.monitoringPrint = monitoringPrint
  339. width: UM.Theme.getSize("sidebar").width;
  340. }
  341. Button
  342. {
  343. id: viewModeButton
  344. anchors
  345. {
  346. top: toolbar.bottom;
  347. topMargin: UM.Theme.getSize("window_margin").height;
  348. left: parent.left;
  349. }
  350. text: catalog.i18nc("@action:button","View Mode");
  351. iconSource: UM.Theme.getIcon("viewmode");
  352. style: UM.Theme.styles.tool_button;
  353. tooltip: "";
  354. enabled: !PrintInformation.preSliced
  355. menu: ViewMenu { }
  356. }
  357. Rectangle
  358. {
  359. id: viewportOverlay
  360. color: UM.Theme.getColor("viewport_overlay")
  361. anchors
  362. {
  363. top: parent.top
  364. bottom: parent.bottom
  365. left:parent.left
  366. right: sidebar.left
  367. }
  368. visible: opacity > 0
  369. opacity: base.monitoringPrint ? 0.75 : 0
  370. Behavior on opacity { NumberAnimation { duration: 100; } }
  371. MouseArea {
  372. anchors.fill: parent
  373. acceptedButtons: Qt.AllButtons
  374. onWheel: wheel.accepted = true
  375. }
  376. }
  377. Image
  378. {
  379. id: cameraImage
  380. width: Math.min(viewportOverlay.width, sourceSize.width)
  381. height: sourceSize.height * width / sourceSize.width
  382. anchors.horizontalCenter: parent.horizontalCenter
  383. anchors.verticalCenter: parent.verticalCenter
  384. anchors.horizontalCenterOffset: - UM.Theme.getSize("sidebar").width / 2
  385. visible: base.monitoringPrint
  386. onVisibleChanged:
  387. {
  388. if(Cura.MachineManager.printerOutputDevices.length == 0 )
  389. {
  390. return;
  391. }
  392. if(visible)
  393. {
  394. Cura.MachineManager.printerOutputDevices[0].startCamera()
  395. } else
  396. {
  397. Cura.MachineManager.printerOutputDevices[0].stopCamera()
  398. }
  399. }
  400. source:
  401. {
  402. if(!base.monitoringPrint)
  403. {
  404. return "";
  405. }
  406. if(Cura.MachineManager.printerOutputDevices.length > 0 && Cura.MachineManager.printerOutputDevices[0].cameraImage)
  407. {
  408. return Cura.MachineManager.printerOutputDevices[0].cameraImage;
  409. }
  410. return "";
  411. }
  412. }
  413. UM.MessageStack
  414. {
  415. anchors
  416. {
  417. horizontalCenter: parent.horizontalCenter
  418. horizontalCenterOffset: -(UM.Theme.getSize("sidebar").width/ 2)
  419. top: parent.verticalCenter;
  420. bottom: parent.bottom;
  421. }
  422. }
  423. }
  424. }
  425. UM.PreferencesDialog
  426. {
  427. id: preferences
  428. Component.onCompleted:
  429. {
  430. //; Remove & re-add the general page as we want to use our own instead of uranium standard.
  431. removePage(0);
  432. insertPage(0, catalog.i18nc("@title:tab","General"), Qt.resolvedUrl("Preferences/GeneralPage.qml"));
  433. removePage(1);
  434. insertPage(1, catalog.i18nc("@title:tab","Settings"), Qt.resolvedUrl("Preferences/SettingVisibilityPage.qml"));
  435. insertPage(2, catalog.i18nc("@title:tab", "Printers"), Qt.resolvedUrl("Preferences/MachinesPage.qml"));
  436. insertPage(3, catalog.i18nc("@title:tab", "Materials"), Qt.resolvedUrl("Preferences/MaterialsPage.qml"));
  437. insertPage(4, catalog.i18nc("@title:tab", "Profiles"), Qt.resolvedUrl("Preferences/ProfilesPage.qml"));
  438. //Force refresh
  439. setPage(0);
  440. }
  441. onVisibleChanged:
  442. {
  443. // When the dialog closes, switch to the General page.
  444. // This prevents us from having a heavy page like Setting Visiblity active in the background.
  445. setPage(0);
  446. }
  447. }
  448. WorkspaceSummaryDialog
  449. {
  450. id: saveWorkspaceDialog
  451. onYes: UM.OutputDeviceManager.requestWriteToDevice("local_file", PrintInformation.jobName, { "filter_by_machine": false, "file_type": "workspace" })
  452. }
  453. Connections
  454. {
  455. target: Cura.Actions.preferences
  456. onTriggered: preferences.visible = true
  457. }
  458. MessageDialog
  459. {
  460. id: newProjectDialog
  461. modality: Qt.ApplicationModal
  462. title: catalog.i18nc("@title:window", "New project")
  463. 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.")
  464. standardButtons: StandardButton.Yes | StandardButton.No
  465. icon: StandardIcon.Question
  466. onYes:
  467. {
  468. Printer.deleteAll();
  469. Cura.Actions.resetProfile.trigger();
  470. }
  471. }
  472. Connections
  473. {
  474. target: Cura.Actions.newProject
  475. onTriggered:
  476. {
  477. if(Printer.platformActivity || Cura.MachineManager.hasUserSettings)
  478. {
  479. newProjectDialog.visible = true
  480. }
  481. }
  482. }
  483. Connections
  484. {
  485. target: Cura.Actions.addProfile
  486. onTriggered:
  487. {
  488. preferences.show();
  489. preferences.setPage(4);
  490. // Create a new profile after a very short delay so the preference page has time to initiate
  491. createProfileTimer.start();
  492. }
  493. }
  494. Connections
  495. {
  496. target: Cura.Actions.configureMachines
  497. onTriggered:
  498. {
  499. preferences.visible = true;
  500. preferences.setPage(2);
  501. }
  502. }
  503. Connections
  504. {
  505. target: Cura.Actions.manageProfiles
  506. onTriggered:
  507. {
  508. preferences.visible = true;
  509. preferences.setPage(4);
  510. }
  511. }
  512. Connections
  513. {
  514. target: Cura.Actions.manageMaterials
  515. onTriggered:
  516. {
  517. preferences.visible = true;
  518. preferences.setPage(3)
  519. }
  520. }
  521. Connections
  522. {
  523. target: Cura.Actions.configureSettingVisibility
  524. onTriggered:
  525. {
  526. preferences.visible = true;
  527. preferences.setPage(1);
  528. preferences.getCurrentItem().scrollToSection(source.key);
  529. }
  530. }
  531. Timer
  532. {
  533. id: createProfileTimer
  534. repeat: false
  535. interval: 1
  536. onTriggered: preferences.getCurrentItem().createProfile()
  537. }
  538. // BlurSettings is a way to force the focus away from any of the setting items.
  539. // We need to do this in order to keep the bindings intact.
  540. Connections
  541. {
  542. target: Cura.MachineManager
  543. onBlurSettings:
  544. {
  545. contentItem.forceActiveFocus()
  546. }
  547. }
  548. Menu
  549. {
  550. id: objectContextMenu;
  551. property variant objectId: -1;
  552. MenuItem { action: Cura.Actions.centerObject; }
  553. MenuItem { action: Cura.Actions.deleteObject; }
  554. MenuItem { action: Cura.Actions.multiplyObject; }
  555. MenuSeparator { }
  556. MenuItem { action: Cura.Actions.selectAll; }
  557. MenuItem { action: Cura.Actions.deleteAll; }
  558. MenuItem { action: Cura.Actions.reloadAll; }
  559. MenuItem { action: Cura.Actions.resetAllTranslation; }
  560. MenuItem { action: Cura.Actions.resetAll; }
  561. MenuSeparator { }
  562. MenuItem { action: Cura.Actions.groupObjects; }
  563. MenuItem { action: Cura.Actions.mergeObjects; }
  564. MenuItem { action: Cura.Actions.unGroupObjects; }
  565. Connections
  566. {
  567. target: Cura.Actions.deleteObject
  568. onTriggered:
  569. {
  570. if(objectContextMenu.objectId != 0)
  571. {
  572. Printer.deleteObject(objectContextMenu.objectId);
  573. objectContextMenu.objectId = 0;
  574. }
  575. }
  576. }
  577. MultiplyObjectOptions
  578. {
  579. id: multiplyObjectOptions
  580. }
  581. Connections
  582. {
  583. target: Cura.Actions.multiplyObject
  584. onTriggered:
  585. {
  586. if(objectContextMenu.objectId != 0)
  587. {
  588. multiplyObjectOptions.objectId = objectContextMenu.objectId;
  589. multiplyObjectOptions.visible = true;
  590. multiplyObjectOptions.reset();
  591. objectContextMenu.objectId = 0;
  592. }
  593. }
  594. }
  595. Connections
  596. {
  597. target: Cura.Actions.centerObject
  598. onTriggered:
  599. {
  600. if(objectContextMenu.objectId != 0)
  601. {
  602. Printer.centerObject(objectContextMenu.objectId);
  603. objectContextMenu.objectId = 0;
  604. }
  605. }
  606. }
  607. }
  608. Menu
  609. {
  610. id: contextMenu;
  611. MenuItem { action: Cura.Actions.selectAll; }
  612. MenuItem { action: Cura.Actions.deleteAll; }
  613. MenuItem { action: Cura.Actions.reloadAll; }
  614. MenuItem { action: Cura.Actions.resetAllTranslation; }
  615. MenuItem { action: Cura.Actions.resetAll; }
  616. MenuSeparator { }
  617. MenuItem { action: Cura.Actions.groupObjects; }
  618. MenuItem { action: Cura.Actions.mergeObjects; }
  619. MenuItem { action: Cura.Actions.unGroupObjects; }
  620. }
  621. Connections
  622. {
  623. target: UM.Controller
  624. onContextMenuRequested:
  625. {
  626. if(objectId == 0)
  627. {
  628. contextMenu.popup();
  629. } else
  630. {
  631. objectContextMenu.objectId = objectId;
  632. objectContextMenu.popup();
  633. }
  634. }
  635. }
  636. Connections
  637. {
  638. target: Cura.Actions.quit
  639. onTriggered: base.visible = false;
  640. }
  641. Connections
  642. {
  643. target: Cura.Actions.toggleFullScreen
  644. onTriggered: base.toggleFullscreen();
  645. }
  646. FileDialog
  647. {
  648. id: openDialog;
  649. //: File open dialog title
  650. title: catalog.i18nc("@title:window","Open file")
  651. modality: UM.Application.platform == "linux" ? Qt.NonModal : Qt.WindowModal;
  652. selectMultiple: true
  653. nameFilters: UM.MeshFileHandler.supportedReadFileTypes;
  654. folder: CuraApplication.getDefaultPath("dialog_load_path")
  655. onAccepted:
  656. {
  657. //Because several implementations of the file dialog only update the folder
  658. //when it is explicitly set.
  659. var f = folder;
  660. folder = f;
  661. CuraApplication.setDefaultPath("dialog_load_path", folder);
  662. for(var i in fileUrls)
  663. {
  664. Printer.readLocalFile(fileUrls[i])
  665. }
  666. var meshName = backgroundItem.getMeshName(fileUrls[0].toString())
  667. backgroundItem.hasMesh(decodeURIComponent(meshName))
  668. }
  669. }
  670. Connections
  671. {
  672. target: Cura.Actions.open
  673. onTriggered: openDialog.open()
  674. }
  675. FileDialog
  676. {
  677. id: openWorkspaceDialog;
  678. //: File open dialog title
  679. title: catalog.i18nc("@title:window","Open workspace")
  680. modality: UM.Application.platform == "linux" ? Qt.NonModal : Qt.WindowModal;
  681. selectMultiple: false
  682. nameFilters: UM.WorkspaceFileHandler.supportedReadFileTypes;
  683. folder: CuraApplication.getDefaultPath("dialog_load_path")
  684. onAccepted:
  685. {
  686. //Because several implementations of the file dialog only update the folder
  687. //when it is explicitly set.
  688. var f = folder;
  689. folder = f;
  690. CuraApplication.setDefaultPath("dialog_load_path", folder);
  691. for(var i in fileUrls)
  692. {
  693. UM.WorkspaceFileHandler.readLocalFile(fileUrls[i])
  694. }
  695. var meshName = backgroundItem.getMeshName(fileUrls[0].toString())
  696. backgroundItem.hasMesh(decodeURIComponent(meshName))
  697. }
  698. }
  699. Connections
  700. {
  701. target: Cura.Actions.loadWorkspace
  702. onTriggered: openWorkspaceDialog.open()
  703. }
  704. EngineLog
  705. {
  706. id: engineLog;
  707. }
  708. Connections
  709. {
  710. target: Cura.Actions.showProfileFolder
  711. onTriggered:
  712. {
  713. var path = UM.Resources.getPath(UM.Resources.Preferences, "");
  714. if(Qt.platform.os == "windows") {
  715. path = path.replace(/\\/g,"/");
  716. }
  717. Qt.openUrlExternally(path);
  718. }
  719. }
  720. AddMachineDialog
  721. {
  722. id: addMachineDialog
  723. onMachineAdded:
  724. {
  725. machineActionsWizard.firstRun = addMachineDialog.firstRun
  726. machineActionsWizard.start(id)
  727. }
  728. }
  729. // Dialog to handle first run machine actions
  730. UM.Wizard
  731. {
  732. id: machineActionsWizard;
  733. title: catalog.i18nc("@title:window", "Add Printer")
  734. property var machine;
  735. function start(id)
  736. {
  737. var actions = Cura.MachineActionManager.getFirstStartActions(id)
  738. resetPages() // Remove previous pages
  739. for (var i = 0; i < actions.length; i++)
  740. {
  741. actions[i].displayItem.reset()
  742. machineActionsWizard.appendPage(actions[i].displayItem, catalog.i18nc("@title", actions[i].label));
  743. }
  744. //Only start if there are actions to perform.
  745. if (actions.length > 0)
  746. {
  747. machineActionsWizard.currentPage = 0;
  748. show()
  749. }
  750. }
  751. }
  752. MessageDialog
  753. {
  754. id: messageDialog
  755. modality: Qt.ApplicationModal
  756. onAccepted: Printer.messageBoxClosed(clickedButton)
  757. onApply: Printer.messageBoxClosed(clickedButton)
  758. onDiscard: Printer.messageBoxClosed(clickedButton)
  759. onHelp: Printer.messageBoxClosed(clickedButton)
  760. onNo: Printer.messageBoxClosed(clickedButton)
  761. onRejected: Printer.messageBoxClosed(clickedButton)
  762. onReset: Printer.messageBoxClosed(clickedButton)
  763. onYes: Printer.messageBoxClosed(clickedButton)
  764. }
  765. Connections
  766. {
  767. target: Printer
  768. onShowMessageBox:
  769. {
  770. messageDialog.title = title
  771. messageDialog.text = text
  772. messageDialog.informativeText = informativeText
  773. messageDialog.detailedText = detailedText
  774. messageDialog.standardButtons = buttons
  775. messageDialog.icon = icon
  776. messageDialog.visible = true
  777. }
  778. }
  779. DiscardOrKeepProfileChangesDialog
  780. {
  781. id: discardOrKeepProfileChangesDialog
  782. }
  783. Connections
  784. {
  785. target: Printer
  786. onShowDiscardOrKeepProfileChanges:
  787. {
  788. discardOrKeepProfileChangesDialog.show()
  789. }
  790. }
  791. Connections
  792. {
  793. target: Cura.Actions.addMachine
  794. onTriggered: addMachineDialog.visible = true;
  795. }
  796. AboutDialog
  797. {
  798. id: aboutDialog
  799. }
  800. Connections
  801. {
  802. target: Cura.Actions.about
  803. onTriggered: aboutDialog.visible = true;
  804. }
  805. Connections
  806. {
  807. target: Printer
  808. onRequestAddPrinter:
  809. {
  810. addMachineDialog.visible = true
  811. addMachineDialog.firstRun = false
  812. }
  813. }
  814. Timer
  815. {
  816. id: startupTimer;
  817. interval: 100;
  818. repeat: false;
  819. running: true;
  820. onTriggered:
  821. {
  822. if(!base.visible)
  823. {
  824. base.visible = true;
  825. restart();
  826. }
  827. else if(Cura.MachineManager.activeMachineId == null || Cura.MachineManager.activeMachineId == "")
  828. {
  829. addMachineDialog.open();
  830. }
  831. }
  832. }
  833. }