Cura.qml 29 KB

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