Cura.qml 28 KB

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