Cura.qml 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890
  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.2 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. MenuItem
  65. {
  66. action: Cura.Actions.loadWorkspace
  67. }
  68. RecentFilesMenu { }
  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 Workspace")
  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(visible)
  369. {
  370. Cura.MachineManager.printerOutputDevices[0].startCamera()
  371. } else
  372. {
  373. Cura.MachineManager.printerOutputDevices[0].stopCamera()
  374. }
  375. }
  376. source:
  377. {
  378. if(!base.monitoringPrint)
  379. {
  380. return "";
  381. }
  382. if(Cura.MachineManager.printerOutputDevices.length > 0 && Cura.MachineManager.printerOutputDevices[0].cameraImage)
  383. {
  384. return Cura.MachineManager.printerOutputDevices[0].cameraImage;
  385. }
  386. return "";
  387. }
  388. }
  389. UM.MessageStack
  390. {
  391. anchors
  392. {
  393. horizontalCenter: parent.horizontalCenter
  394. horizontalCenterOffset: -(UM.Theme.getSize("sidebar").width/ 2)
  395. top: parent.verticalCenter;
  396. bottom: parent.bottom;
  397. }
  398. }
  399. }
  400. }
  401. UM.PreferencesDialog
  402. {
  403. id: preferences
  404. Component.onCompleted:
  405. {
  406. //; Remove & re-add the general page as we want to use our own instead of uranium standard.
  407. removePage(0);
  408. insertPage(0, catalog.i18nc("@title:tab","General"), Qt.resolvedUrl("Preferences/GeneralPage.qml"));
  409. removePage(1);
  410. insertPage(1, catalog.i18nc("@title:tab","Settings"), Qt.resolvedUrl("Preferences/SettingVisibilityPage.qml"));
  411. insertPage(2, catalog.i18nc("@title:tab", "Printers"), Qt.resolvedUrl("Preferences/MachinesPage.qml"));
  412. insertPage(3, catalog.i18nc("@title:tab", "Materials"), Qt.resolvedUrl("Preferences/MaterialsPage.qml"));
  413. insertPage(4, catalog.i18nc("@title:tab", "Profiles"), Qt.resolvedUrl("Preferences/ProfilesPage.qml"));
  414. //Force refresh
  415. setPage(0);
  416. }
  417. onVisibleChanged:
  418. {
  419. if(!visible)
  420. {
  421. // When the dialog closes, switch to the General page.
  422. // This prevents us from having a heavy page like Setting Visiblity active in the background.
  423. setPage(0);
  424. }
  425. }
  426. }
  427. Connections
  428. {
  429. target: Cura.Actions.preferences
  430. onTriggered: preferences.visible = true
  431. }
  432. Connections
  433. {
  434. target: Cura.Actions.addProfile
  435. onTriggered:
  436. {
  437. preferences.setPage(4);
  438. preferences.show();
  439. // Create a new profile after a very short delay so the preference page has time to initiate
  440. createProfileTimer.start();
  441. }
  442. }
  443. Connections
  444. {
  445. target: Cura.Actions.configureMachines
  446. onTriggered:
  447. {
  448. preferences.visible = true;
  449. preferences.setPage(2);
  450. }
  451. }
  452. Connections
  453. {
  454. target: Cura.Actions.manageProfiles
  455. onTriggered:
  456. {
  457. preferences.visible = true;
  458. preferences.setPage(4);
  459. }
  460. }
  461. Connections
  462. {
  463. target: Cura.Actions.manageMaterials
  464. onTriggered:
  465. {
  466. preferences.visible = true;
  467. preferences.setPage(3)
  468. }
  469. }
  470. Connections
  471. {
  472. target: Cura.Actions.configureSettingVisibility
  473. onTriggered:
  474. {
  475. preferences.visible = true;
  476. preferences.setPage(1);
  477. preferences.getCurrentItem().scrollToSection(source.key);
  478. }
  479. }
  480. Timer
  481. {
  482. id: createProfileTimer
  483. repeat: false
  484. interval: 1
  485. onTriggered: preferences.getCurrentItem().createProfile()
  486. }
  487. // BlurSettings is a way to force the focus away from any of the setting items.
  488. // We need to do this in order to keep the bindings intact.
  489. Connections
  490. {
  491. target: Cura.MachineManager
  492. onBlurSettings:
  493. {
  494. forceActiveFocus()
  495. }
  496. }
  497. Menu
  498. {
  499. id: objectContextMenu;
  500. property variant objectId: -1;
  501. MenuItem { action: Cura.Actions.centerObject; }
  502. MenuItem { action: Cura.Actions.deleteObject; }
  503. MenuItem { action: Cura.Actions.multiplyObject; }
  504. MenuSeparator { }
  505. MenuItem { action: Cura.Actions.selectAll; }
  506. MenuItem { action: Cura.Actions.deleteAll; }
  507. MenuItem { action: Cura.Actions.reloadAll; }
  508. MenuItem { action: Cura.Actions.resetAllTranslation; }
  509. MenuItem { action: Cura.Actions.resetAll; }
  510. MenuSeparator { }
  511. MenuItem { action: Cura.Actions.groupObjects; }
  512. MenuItem { action: Cura.Actions.mergeObjects; }
  513. MenuItem { action: Cura.Actions.unGroupObjects; }
  514. Connections
  515. {
  516. target: Cura.Actions.deleteObject
  517. onTriggered:
  518. {
  519. if(objectContextMenu.objectId != 0)
  520. {
  521. Printer.deleteObject(objectContextMenu.objectId);
  522. objectContextMenu.objectId = 0;
  523. }
  524. }
  525. }
  526. Connections
  527. {
  528. target: Cura.Actions.multiplyObject
  529. onTriggered:
  530. {
  531. if(objectContextMenu.objectId != 0)
  532. {
  533. Printer.multiplyObject(objectContextMenu.objectId, 1);
  534. objectContextMenu.objectId = 0;
  535. }
  536. }
  537. }
  538. Connections
  539. {
  540. target: Cura.Actions.centerObject
  541. onTriggered:
  542. {
  543. if(objectContextMenu.objectId != 0)
  544. {
  545. Printer.centerObject(objectContextMenu.objectId);
  546. objectContextMenu.objectId = 0;
  547. }
  548. }
  549. }
  550. }
  551. Menu
  552. {
  553. id: contextMenu;
  554. MenuItem { action: Cura.Actions.selectAll; }
  555. MenuItem { action: Cura.Actions.deleteAll; }
  556. MenuItem { action: Cura.Actions.reloadAll; }
  557. MenuItem { action: Cura.Actions.resetAllTranslation; }
  558. MenuItem { action: Cura.Actions.resetAll; }
  559. MenuSeparator { }
  560. MenuItem { action: Cura.Actions.groupObjects; }
  561. MenuItem { action: Cura.Actions.mergeObjects; }
  562. MenuItem { action: Cura.Actions.unGroupObjects; }
  563. }
  564. Connections
  565. {
  566. target: UM.Controller
  567. onContextMenuRequested:
  568. {
  569. if(objectId == 0)
  570. {
  571. contextMenu.popup();
  572. } else
  573. {
  574. objectContextMenu.objectId = objectId;
  575. objectContextMenu.popup();
  576. }
  577. }
  578. }
  579. Connections
  580. {
  581. target: Cura.Actions.quit
  582. onTriggered: base.visible = false;
  583. }
  584. Connections
  585. {
  586. target: Cura.Actions.toggleFullScreen
  587. onTriggered: base.toggleFullscreen();
  588. }
  589. FileDialog
  590. {
  591. id: openDialog;
  592. //: File open dialog title
  593. title: catalog.i18nc("@title:window","Open file")
  594. modality: UM.Application.platform == "linux" ? Qt.NonModal : Qt.WindowModal;
  595. selectMultiple: true
  596. nameFilters: UM.MeshFileHandler.supportedReadFileTypes;
  597. folder: CuraApplication.getDefaultPath("dialog_load_path")
  598. onAccepted:
  599. {
  600. //Because several implementations of the file dialog only update the folder
  601. //when it is explicitly set.
  602. var f = folder;
  603. folder = f;
  604. CuraApplication.setDefaultPath("dialog_load_path", folder);
  605. for(var i in fileUrls)
  606. {
  607. UM.MeshFileHandler.readLocalFile(fileUrls[i])
  608. if (i == fileUrls.length - 1)
  609. {
  610. var meshName = backgroundItem.getMeshName(fileUrls.toString())
  611. backgroundItem.hasMesh(decodeURIComponent(meshName))
  612. }
  613. }
  614. }
  615. }
  616. Connections
  617. {
  618. target: Cura.Actions.open
  619. onTriggered: openDialog.open()
  620. }
  621. FileDialog
  622. {
  623. id: openWorkspaceDialog;
  624. //: File open dialog title
  625. title: catalog.i18nc("@title:window","Open workspace")
  626. modality: UM.Application.platform == "linux" ? Qt.NonModal : Qt.WindowModal;
  627. selectMultiple: false
  628. nameFilters: UM.WorkspaceFileHandler.supportedReadFileTypes;
  629. folder: CuraApplication.getDefaultPath("dialog_load_path")
  630. onAccepted:
  631. {
  632. //Because several implementations of the file dialog only update the folder
  633. //when it is explicitly set.
  634. var f = folder;
  635. folder = f;
  636. CuraApplication.setDefaultPath("dialog_load_path", folder);
  637. for(var i in fileUrls)
  638. {
  639. UM.WorkspaceFileHandler.readLocalFile(fileUrls[i])
  640. }
  641. }
  642. }
  643. Connections
  644. {
  645. target: Cura.Actions.loadWorkspace
  646. onTriggered:openWorkspaceDialog.open()
  647. }
  648. EngineLog
  649. {
  650. id: engineLog;
  651. }
  652. Connections
  653. {
  654. target: Cura.Actions.showProfileFolder
  655. onTriggered:
  656. {
  657. var path = UM.Resources.getPath(UM.Resources.Preferences, "");
  658. if(Qt.platform.os == "windows") {
  659. path = path.replace(/\\/g,"/");
  660. }
  661. Qt.openUrlExternally(path);
  662. }
  663. }
  664. AddMachineDialog
  665. {
  666. id: addMachineDialog
  667. onMachineAdded:
  668. {
  669. machineActionsWizard.firstRun = addMachineDialog.firstRun
  670. machineActionsWizard.start(id)
  671. }
  672. }
  673. // Dialog to handle first run machine actions
  674. UM.Wizard
  675. {
  676. id: machineActionsWizard;
  677. title: catalog.i18nc("@title:window", "Add Printer")
  678. property var machine;
  679. function start(id)
  680. {
  681. var actions = Cura.MachineActionManager.getFirstStartActions(id)
  682. resetPages() // Remove previous pages
  683. for (var i = 0; i < actions.length; i++)
  684. {
  685. actions[i].displayItem.reset()
  686. machineActionsWizard.appendPage(actions[i].displayItem, catalog.i18nc("@title", actions[i].label));
  687. }
  688. //Only start if there are actions to perform.
  689. if (actions.length > 0)
  690. {
  691. machineActionsWizard.currentPage = 0;
  692. show()
  693. }
  694. }
  695. }
  696. MessageDialog
  697. {
  698. id: messageDialog
  699. modality: Qt.ApplicationModal
  700. onAccepted: Printer.messageBoxClosed(clickedButton)
  701. onApply: Printer.messageBoxClosed(clickedButton)
  702. onDiscard: Printer.messageBoxClosed(clickedButton)
  703. onHelp: Printer.messageBoxClosed(clickedButton)
  704. onNo: Printer.messageBoxClosed(clickedButton)
  705. onRejected: Printer.messageBoxClosed(clickedButton)
  706. onReset: Printer.messageBoxClosed(clickedButton)
  707. onYes: Printer.messageBoxClosed(clickedButton)
  708. }
  709. Connections
  710. {
  711. target: Printer
  712. onShowMessageBox:
  713. {
  714. messageDialog.title = title
  715. messageDialog.text = text
  716. messageDialog.informativeText = informativeText
  717. messageDialog.detailedText = detailedText
  718. messageDialog.standardButtons = buttons
  719. messageDialog.icon = icon
  720. messageDialog.visible = true
  721. }
  722. }
  723. Connections
  724. {
  725. target: Cura.Actions.addMachine
  726. onTriggered: addMachineDialog.visible = true;
  727. }
  728. AboutDialog
  729. {
  730. id: aboutDialog
  731. }
  732. Connections
  733. {
  734. target: Cura.Actions.about
  735. onTriggered: aboutDialog.visible = true;
  736. }
  737. Connections
  738. {
  739. target: Printer
  740. onRequestAddPrinter:
  741. {
  742. addMachineDialog.visible = true
  743. addMachineDialog.firstRun = false
  744. }
  745. }
  746. Timer
  747. {
  748. id: startupTimer;
  749. interval: 100;
  750. repeat: false;
  751. running: true;
  752. onTriggered:
  753. {
  754. if(!base.visible)
  755. {
  756. base.visible = true;
  757. restart();
  758. }
  759. else if(Cura.MachineManager.activeMachineId == null || Cura.MachineManager.activeMachineId == "")
  760. {
  761. addMachineDialog.open();
  762. }
  763. }
  764. }
  765. }