Cura.qml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903
  1. // Copyright (c) 2022 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.7
  4. import QtQuick.Controls 2.15
  5. import QtQuick.Dialogs
  6. import UM 1.5 as UM
  7. import Cura 1.1 as Cura
  8. import "Dialogs"
  9. import "Menus"
  10. import "MainWindow"
  11. import "WelcomePages"
  12. UM.MainWindow
  13. {
  14. id: base
  15. // Cura application window title
  16. title:
  17. {
  18. let result = "";
  19. if(PrintInformation !== null && PrintInformation.jobName != "")
  20. {
  21. result += PrintInformation.jobName + " - ";
  22. }
  23. result += CuraApplication.applicationDisplayName;
  24. return result;
  25. }
  26. backgroundColor: UM.Theme.getColor("viewport_background")
  27. UM.I18nCatalog
  28. {
  29. id: catalog
  30. name: "cura"
  31. }
  32. function showTooltip(item, position, text)
  33. {
  34. tooltip.text = text;
  35. position = item.mapToItem(backgroundItem, position.x - UM.Theme.getSize("default_arrow").width, position.y);
  36. tooltip.show(position);
  37. }
  38. function hideTooltip()
  39. {
  40. tooltip.hide();
  41. }
  42. MouseArea
  43. {
  44. // Hack introduced when switching to qt6
  45. // We used to be able to let the main window's default handlers control this, but something seems to be changed
  46. // for qt6 in the ordering. TODO; We should find out what changed and have a less hacky fix for that.
  47. enabled: parent.visible
  48. anchors.fill: parent
  49. hoverEnabled: true
  50. acceptedButtons: Qt.AllButtons
  51. onPositionChanged: (mouse) => {base.mouseMoved(mouse);}
  52. onPressed: (mouse) => { base.mousePressed(mouse);}
  53. onReleased: (mouse) => { base.mouseReleased(mouse);}
  54. onWheel: (wheel) => {base.wheel(wheel)}
  55. }
  56. Rectangle
  57. {
  58. id: greyOutBackground
  59. anchors.fill: parent
  60. visible: welcomeDialogItem.visible
  61. color: UM.Theme.getColor("window_disabled_background")
  62. opacity: 0.7
  63. z: stageMenu.z + 1
  64. MouseArea
  65. {
  66. // Prevent all mouse events from passing through.
  67. enabled: parent.visible
  68. anchors.fill: parent
  69. hoverEnabled: true
  70. acceptedButtons: Qt.AllButtons
  71. }
  72. }
  73. WelcomeDialogItem
  74. {
  75. id: welcomeDialogItem
  76. visible: false
  77. z: greyOutBackground.z + 1
  78. }
  79. Component.onCompleted:
  80. {
  81. CuraApplication.setMinimumWindowSize(UM.Theme.getSize("window_minimum_size"))
  82. CuraApplication.purgeWindows()
  83. }
  84. Connections
  85. {
  86. // This connection is used when there is no ActiveMachine and the user is logged in
  87. target: CuraApplication
  88. function onShowAddPrintersUncancellableDialog()
  89. {
  90. Cura.Actions.parent = backgroundItem
  91. // Reuse the welcome dialog item to show "Add a printer" only.
  92. welcomeDialogItem.model = CuraApplication.getAddPrinterPagesModelWithoutCancel()
  93. welcomeDialogItem.progressBarVisible = false
  94. welcomeDialogItem.visible = true
  95. }
  96. }
  97. Connections
  98. {
  99. target: CuraApplication
  100. function onInitializationFinished()
  101. {
  102. // Workaround silly issues with QML Action's shortcut property.
  103. //
  104. // Currently, there is no way to define shortcuts as "Application Shortcut".
  105. // This means that all Actions are "Window Shortcuts". The code for this
  106. // implements a rather naive check that just checks if any of the action's parents
  107. // are a window. Since the "Actions" object is a singleton it has no parent by
  108. // default. If we set its parent to something contained in this window, the
  109. // shortcut will activate properly because one of its parents is a window.
  110. //
  111. // This has been fixed for QtQuick Controls 2 since the Shortcut item has a context property.
  112. Cura.Actions.parent = backgroundItem
  113. if (CuraApplication.shouldShowWelcomeDialog())
  114. {
  115. welcomeDialogItem.visible = true
  116. }
  117. else
  118. {
  119. welcomeDialogItem.visible = false
  120. }
  121. // Reuse the welcome dialog item to show "What's New" only.
  122. if (CuraApplication.shouldShowWhatsNewDialog())
  123. {
  124. welcomeDialogItem.model = CuraApplication.getWhatsNewPagesModel()
  125. welcomeDialogItem.progressBarVisible = false
  126. welcomeDialogItem.visible = true
  127. }
  128. // Reuse the welcome dialog item to show the "Add printers" dialog. Triggered when there is no active
  129. // machine and the user is logged in.
  130. if (!Cura.MachineManager.activeMachine && Cura.API.account.isLoggedIn)
  131. {
  132. welcomeDialogItem.model = CuraApplication.getAddPrinterPagesModelWithoutCancel()
  133. welcomeDialogItem.progressBarVisible = false
  134. welcomeDialogItem.visible = true
  135. }
  136. }
  137. }
  138. Item
  139. {
  140. id: backgroundItem
  141. anchors.fill: parent
  142. //DeleteSelection on the keypress backspace event
  143. Keys.onPressed: (event) =>
  144. {
  145. if (event.key == Qt.Key_Backspace)
  146. {
  147. Cura.Actions.deleteSelection.trigger()
  148. }
  149. }
  150. ApplicationMenu
  151. {
  152. id: applicationMenu
  153. }
  154. Item
  155. {
  156. id: headerBackground
  157. anchors
  158. {
  159. top: applicationMenu.bottom
  160. left: parent.left
  161. right: parent.right
  162. }
  163. height: stageMenu.source != "" ? Math.round(mainWindowHeader.height + stageMenu.height / 2) : mainWindowHeader.height
  164. Rectangle
  165. {
  166. anchors.fill: parent
  167. color: UM.Theme.getColor("main_window_header_background")
  168. }
  169. // This is a placeholder for adding a pattern in the header
  170. Image
  171. {
  172. id: backgroundPattern
  173. anchors.fill: parent
  174. fillMode: Image.Tile
  175. source: UM.Theme.getImage("header_pattern")
  176. horizontalAlignment: Image.AlignLeft
  177. verticalAlignment: Image.AlignTop
  178. }
  179. }
  180. MainWindowHeader
  181. {
  182. id: mainWindowHeader
  183. anchors
  184. {
  185. left: parent.left
  186. right: parent.right
  187. top: applicationMenu.bottom
  188. }
  189. }
  190. Item
  191. {
  192. id: contentItem
  193. anchors
  194. {
  195. top: mainWindowHeader.bottom
  196. bottom: parent.bottom
  197. left: parent.left
  198. right: parent.right
  199. }
  200. Keys.forwardTo: applicationMenu
  201. DropArea
  202. {
  203. // The drop area is here to handle files being dropped onto Cura.
  204. anchors.fill: parent
  205. onDropped: (drop) =>
  206. {
  207. if (drop.urls.length > 0)
  208. {
  209. var nonPackages = [];
  210. for (var i = 0; i < drop.urls.length; i++)
  211. {
  212. var filename = drop.urls[i];
  213. if (filename.toString().toLowerCase().endsWith(".curapackage"))
  214. {
  215. // Try to install plugin & close.
  216. CuraApplication.installPackageViaDragAndDrop(filename);
  217. packageInstallDialog.text = catalog.i18nc("@label", "This package will be installed after restarting.");
  218. packageInstallDialog.open();
  219. }
  220. else
  221. {
  222. nonPackages.push(filename);
  223. }
  224. }
  225. openDialog.handleOpenFileUrls(nonPackages);
  226. }
  227. }
  228. }
  229. ObjectSelector
  230. {
  231. id: objectSelector
  232. visible: CuraApplication.platformActivity
  233. anchors
  234. {
  235. bottom: jobSpecs.top
  236. left: toolbar.right
  237. leftMargin: UM.Theme.getSize("default_margin").width
  238. rightMargin: UM.Theme.getSize("default_margin").width
  239. bottomMargin: UM.Theme.getSize("narrow_margin").height
  240. }
  241. }
  242. JobSpecs
  243. {
  244. id: jobSpecs
  245. visible: CuraApplication.platformActivity
  246. anchors
  247. {
  248. left: toolbar.right
  249. bottom: viewOrientationControls.top
  250. leftMargin: UM.Theme.getSize("default_margin").width
  251. rightMargin: UM.Theme.getSize("default_margin").width
  252. bottomMargin: UM.Theme.getSize("thin_margin").width
  253. topMargin: UM.Theme.getSize("thin_margin").width
  254. }
  255. }
  256. ViewOrientationControls
  257. {
  258. id: viewOrientationControls
  259. anchors
  260. {
  261. left: toolbar.right
  262. bottom: parent.bottom
  263. margins: UM.Theme.getSize("default_margin").width
  264. }
  265. }
  266. Toolbar
  267. {
  268. // The toolbar is the left bar that is populated by all the tools
  269. // (which are dynamically populated by plugins)
  270. id: toolbar
  271. property int mouseX: base.mouseX
  272. property int mouseY: base.mouseY
  273. anchors
  274. {
  275. verticalCenter: parent.verticalCenter
  276. left: parent.left
  277. }
  278. visible: CuraApplication.platformActivity && !PrintInformation.preSliced
  279. }
  280. // A hint for the loaded content view. Overlay items / controls can safely be placed in this area
  281. Item {
  282. id: mainSafeArea
  283. anchors.left: viewOrientationControls.right
  284. anchors.right: main.right
  285. anchors.top: main.top
  286. anchors.bottom: main.bottom
  287. }
  288. Loader
  289. {
  290. // A stage can control this area. If nothing is set, it will therefore show the 3D view.
  291. id: main
  292. anchors
  293. {
  294. // Align to the top of the stageMenu since the stageMenu may not exist
  295. top: stageMenu.source ? stageMenu.verticalCenter : parent.top
  296. left: parent.left
  297. right: parent.right
  298. bottom: parent.bottom
  299. }
  300. source: UM.Controller.activeStage != null ? UM.Controller.activeStage.mainComponent : ""
  301. onLoaded: {
  302. if (main.item.safeArea !== undefined){
  303. main.item.safeArea = Qt.binding(function() { return mainSafeArea });
  304. }
  305. }
  306. }
  307. Loader
  308. {
  309. // The stage menu is, as the name implies, a menu that is defined by the active stage.
  310. // Note that this menu does not need to be set at all! It's perfectly acceptable to have a stage
  311. // without this menu!
  312. id: stageMenu
  313. anchors
  314. {
  315. left: parent.left
  316. right: parent.right
  317. top: parent.top
  318. }
  319. height: UM.Theme.getSize("stage_menu").height
  320. source: UM.Controller.activeStage != null ? UM.Controller.activeStage.stageMenuComponent : ""
  321. // HACK: This is to ensure that the parent never gets set to null, as this wreaks havoc on the focus.
  322. function onParentDestroyed()
  323. {
  324. printSetupSelector.parent = stageMenu
  325. printSetupSelector.visible = false
  326. }
  327. property Item oldParent: null
  328. // The printSetupSelector is defined here so that the setting list doesn't need to get re-instantiated
  329. // Every time the stage is changed.
  330. property var printSetupSelector: Cura.PrintSetupSelector
  331. {
  332. width: UM.Theme.getSize("print_setup_widget").width
  333. height: UM.Theme.getSize("stage_menu").height
  334. headerCornerSide: RoundedRectangle.Direction.Right
  335. onParentChanged:
  336. {
  337. if(stageMenu.oldParent !=null)
  338. {
  339. stageMenu.oldParent.Component.destruction.disconnect(stageMenu.onParentDestroyed)
  340. }
  341. stageMenu.oldParent = parent
  342. visible = parent != stageMenu
  343. parent.Component.destruction.connect(stageMenu.onParentDestroyed)
  344. }
  345. }
  346. }
  347. UM.MessageStack
  348. {
  349. anchors
  350. {
  351. horizontalCenter: parent.horizontalCenter
  352. top: parent.verticalCenter
  353. bottom: parent.bottom
  354. bottomMargin: UM.Theme.getSize("default_margin").height
  355. }
  356. primaryButton: Component
  357. {
  358. Cura.PrimaryButton
  359. {
  360. text: model.name
  361. iconSource: UM.Theme.getIcon(model.icon)
  362. height: UM.Theme.getSize("message_action_button").height
  363. }
  364. }
  365. secondaryButton: Component
  366. {
  367. Cura.SecondaryButton
  368. {
  369. text: model.name
  370. iconSource: UM.Theme.getIcon(model.icon)
  371. height: UM.Theme.getSize("message_action_button").height
  372. }
  373. }
  374. link: Component
  375. {
  376. Cura.TertiaryButton
  377. {
  378. text: model.name
  379. iconSource:
  380. {
  381. if (model.icon == null || model.icon == "")
  382. {
  383. return UM.Theme.getIcon("LinkExternal")
  384. }
  385. return UM.Theme.getIcon(model.icon)
  386. }
  387. height: UM.Theme.getSize("message_action_button").height
  388. }
  389. }
  390. }
  391. }
  392. PrintSetupTooltip
  393. {
  394. id: tooltip
  395. sourceWidth: UM.Theme.getSize("print_setup_widget").width
  396. }
  397. }
  398. UM.PreferencesDialog
  399. {
  400. id: preferences
  401. Component.onCompleted:
  402. {
  403. //; Remove & re-add the general page as we want to use our own instead of uranium standard.
  404. removePage(0);
  405. insertPage(0, catalog.i18nc("@title:tab","General"), Qt.resolvedUrl("Preferences/GeneralPage.qml"));
  406. removePage(1);
  407. insertPage(1, catalog.i18nc("@title:tab","Settings"), Qt.resolvedUrl("Preferences/SettingVisibilityPage.qml"));
  408. insertPage(2, catalog.i18nc("@title:tab", "Printers"), Qt.resolvedUrl("Preferences/MachinesPage.qml"));
  409. insertPage(3, catalog.i18nc("@title:tab", "Materials"), Qt.resolvedUrl("Preferences/Materials/MaterialsPage.qml"));
  410. insertPage(4, catalog.i18nc("@title:tab", "Profiles"), Qt.resolvedUrl("Preferences/ProfilesPage.qml"));
  411. currentPage = 0;
  412. }
  413. onVisibleChanged:
  414. {
  415. // When the dialog closes, switch to the General page.
  416. // This prevents us from having a heavy page like Setting Visibility active in the background.
  417. setPage(0);
  418. }
  419. }
  420. Connections
  421. {
  422. target: Cura.Actions.preferences
  423. function onTriggered() { preferences.visible = true }
  424. }
  425. Connections
  426. {
  427. target: CuraApplication
  428. function onShowPreferencesWindow() { preferences.visible = true }
  429. }
  430. Connections
  431. {
  432. target: Cura.Actions.addProfile
  433. function onTriggered()
  434. {
  435. preferences.show();
  436. preferences.setPage(4);
  437. // Create a new profile after a very short delay so the preference page has time to initiate
  438. createProfileTimer.start();
  439. }
  440. }
  441. Connections
  442. {
  443. target: Cura.Actions.configureMachines
  444. function onTriggered()
  445. {
  446. preferences.visible = true;
  447. preferences.setPage(2);
  448. }
  449. }
  450. Connections
  451. {
  452. target: Cura.Actions.manageProfiles
  453. function onTriggered()
  454. {
  455. preferences.visible = true;
  456. preferences.setPage(4);
  457. }
  458. }
  459. Connections
  460. {
  461. target: Cura.Actions.manageMaterials
  462. function onTriggered()
  463. {
  464. preferences.visible = true;
  465. preferences.setPage(3)
  466. }
  467. }
  468. Connections
  469. {
  470. target: Cura.Actions.configureSettingVisibility
  471. function onTriggered(source)
  472. {
  473. preferences.visible = true;
  474. preferences.setPage(1);
  475. if(source && source.key)
  476. {
  477. preferences.getCurrentItem().scrollToSection(source.key);
  478. }
  479. }
  480. }
  481. Timer
  482. {
  483. id: createProfileTimer
  484. repeat: false
  485. interval: 1
  486. onTriggered: preferences.getCurrentItem().createProfile()
  487. }
  488. // BlurSettings is a way to force the focus away from any of the setting items.
  489. // We need to do this in order to keep the bindings intact.
  490. Connections
  491. {
  492. target: Cura.MachineManager
  493. function onBlurSettings()
  494. {
  495. contentItem.forceActiveFocus()
  496. }
  497. }
  498. ContextMenu
  499. {
  500. id: contextMenu
  501. }
  502. onPreClosing: (close) =>
  503. {
  504. close.accepted = CuraApplication.getIsAllChecksPassed();
  505. if (!close.accepted)
  506. {
  507. CuraApplication.checkAndExitApplication();
  508. }
  509. }
  510. Cura.MessageDialog
  511. {
  512. id: exitConfirmationDialog
  513. title: catalog.i18nc("@title:window %1 is the application name", "Closing %1").arg(CuraApplication.applicationDisplayName)
  514. text: catalog.i18nc("@label %1 is the application name", "Are you sure you want to exit %1?").arg(CuraApplication.applicationDisplayName)
  515. standardButtons: Dialog.Yes | Dialog.No
  516. onAccepted: CuraApplication.callConfirmExitDialogCallback(true)
  517. onRejected: CuraApplication.callConfirmExitDialogCallback(false)
  518. onClosed:
  519. {
  520. if (!visible)
  521. {
  522. // reset the text to default because other modules may change the message text.
  523. text = catalog.i18nc("@label %1 is the application name", "Are you sure you want to exit %1?").arg(CuraApplication.applicationDisplayName);
  524. }
  525. }
  526. }
  527. Connections
  528. {
  529. target: CuraApplication
  530. function onShowConfirmExitDialog(message)
  531. {
  532. exitConfirmationDialog.text = message;
  533. exitConfirmationDialog.open();
  534. }
  535. }
  536. Connections
  537. {
  538. target: Cura.Actions.quit
  539. function onTriggered() { CuraApplication.checkAndExitApplication(); }
  540. }
  541. Connections
  542. {
  543. target: Cura.Actions.toggleFullScreen
  544. function onTriggered() { base.toggleFullscreen() }
  545. }
  546. Connections
  547. {
  548. target: Cura.Actions.exitFullScreen
  549. function onTriggered() { base.exitFullscreen() }
  550. }
  551. FileDialog
  552. {
  553. id: openDialog;
  554. //: File open dialog title
  555. title: catalog.i18nc("@title:window","Open file(s)")
  556. modality: Qt.WindowModal
  557. fileMode: FileDialog.OpenFiles
  558. nameFilters: UM.MeshFileHandler.supportedReadFileTypes;
  559. currentFolder: CuraApplication.getDefaultPath("dialog_load_path")
  560. onAccepted:
  561. {
  562. // Because several implementations of the file dialog only update the folder
  563. // when it is explicitly set.
  564. var f = currentFolder;
  565. currentFolder = f;
  566. CuraApplication.setDefaultPath("dialog_load_path", currentFolder);
  567. handleOpenFileUrls(selectedFiles);
  568. }
  569. // Yeah... I know... it is a mess to put all those things here.
  570. // There are lots of user interactions in this part of the logic, such as showing a warning dialog here and there,
  571. // etc. This means it will come back and forth from time to time between QML and Python. So, separating the logic
  572. // and view here may require more effort but make things more difficult to understand.
  573. function handleOpenFileUrls(fileUrlList)
  574. {
  575. // look for valid project files
  576. var projectFileUrlList = [];
  577. var hasGcode = false;
  578. var nonGcodeFileList = [];
  579. for (var i in fileUrlList)
  580. {
  581. var endsWithG = /\.g$/;
  582. var endsWithGcode = /\.gcode$/;
  583. if (endsWithG.test(fileUrlList[i]) || endsWithGcode.test(fileUrlList[i]))
  584. {
  585. continue;
  586. }
  587. else if (CuraApplication.checkIsValidProjectFile(fileUrlList[i]))
  588. {
  589. projectFileUrlList.push(fileUrlList[i]);
  590. }
  591. nonGcodeFileList.push(fileUrlList[i]);
  592. }
  593. hasGcode = nonGcodeFileList.length < fileUrlList.length;
  594. // show a warning if selected multiple files together with Gcode
  595. var hasProjectFile = projectFileUrlList.length > 0;
  596. var selectedMultipleFiles = fileUrlList.length > 1;
  597. if (selectedMultipleFiles && hasGcode)
  598. {
  599. infoMultipleFilesWithGcodeDialog.selectedMultipleFiles = selectedMultipleFiles;
  600. infoMultipleFilesWithGcodeDialog.hasProjectFile = hasProjectFile;
  601. infoMultipleFilesWithGcodeDialog.fileUrls = nonGcodeFileList.slice();
  602. infoMultipleFilesWithGcodeDialog.projectFileUrlList = projectFileUrlList.slice();
  603. infoMultipleFilesWithGcodeDialog.open();
  604. }
  605. else
  606. {
  607. handleOpenFiles(selectedMultipleFiles, hasProjectFile, fileUrlList, projectFileUrlList);
  608. }
  609. }
  610. function handleOpenFiles(selectedMultipleFiles, hasProjectFile, fileUrlList, projectFileUrlList)
  611. {
  612. // Make sure the files opened through the openFilesIncludingProjectDialog are added to the recent files list
  613. openFilesIncludingProjectsDialog.addToRecent = true;
  614. // we only allow opening one project file
  615. if (selectedMultipleFiles && hasProjectFile)
  616. {
  617. openFilesIncludingProjectsDialog.fileUrls = fileUrlList.slice();
  618. openFilesIncludingProjectsDialog.show();
  619. return;
  620. }
  621. if (hasProjectFile)
  622. {
  623. var projectFile = projectFileUrlList[0];
  624. // check preference
  625. var choice = UM.Preferences.getValue("cura/choice_on_open_project");
  626. if (choice == "open_as_project")
  627. {
  628. openFilesIncludingProjectsDialog.loadProjectFile(projectFile);
  629. }
  630. else if (choice == "open_as_model")
  631. {
  632. openFilesIncludingProjectsDialog.loadModelFiles([projectFile].slice());
  633. }
  634. else // always ask
  635. {
  636. // ask whether to open as project or as models
  637. askOpenAsProjectOrModelsDialog.fileUrl = projectFile;
  638. askOpenAsProjectOrModelsDialog.addToRecent = true;
  639. askOpenAsProjectOrModelsDialog.show();
  640. }
  641. }
  642. else
  643. {
  644. openFilesIncludingProjectsDialog.loadModelFiles(fileUrlList.slice());
  645. }
  646. }
  647. }
  648. Cura.MessageDialog
  649. {
  650. id: packageInstallDialog
  651. title: catalog.i18nc("@window:title", "Install Package")
  652. standardButtons: Dialog.Ok
  653. }
  654. Cura.MessageDialog
  655. {
  656. id: infoMultipleFilesWithGcodeDialog
  657. title: catalog.i18nc("@title:window", "Open File(s)")
  658. standardButtons: Dialog.Ok
  659. 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.")
  660. property var selectedMultipleFiles
  661. property var hasProjectFile
  662. property var fileUrls
  663. property var projectFileUrlList
  664. onAccepted:
  665. {
  666. openDialog.handleOpenFiles(selectedMultipleFiles, hasProjectFile, fileUrls, projectFileUrlList);
  667. }
  668. }
  669. Connections
  670. {
  671. target: Cura.Actions.open
  672. function onTriggered() { openDialog.open() }
  673. }
  674. OpenFilesIncludingProjectsDialog
  675. {
  676. id: openFilesIncludingProjectsDialog
  677. }
  678. AskOpenAsProjectOrModelsDialog
  679. {
  680. id: askOpenAsProjectOrModelsDialog
  681. }
  682. Connections
  683. {
  684. target: CuraApplication
  685. function onOpenProjectFile(project_file, add_to_recent_files)
  686. {
  687. askOpenAsProjectOrModelsDialog.fileUrl = project_file;
  688. askOpenAsProjectOrModelsDialog.addToRecent = add_to_recent_files;
  689. askOpenAsProjectOrModelsDialog.show();
  690. }
  691. }
  692. Connections
  693. {
  694. target: Cura.Actions.showProfileFolder
  695. function onTriggered()
  696. {
  697. var path = UM.Resources.getPath(UM.Resources.Preferences, "");
  698. if(Qt.platform.os == "windows")
  699. {
  700. path = path.replace(/\\/g,"/");
  701. }
  702. Qt.openUrlExternally(path);
  703. if(Qt.platform.os == "linux")
  704. {
  705. Qt.openUrlExternally(UM.Resources.getPath(UM.Resources.Resources, ""));
  706. }
  707. }
  708. }
  709. Component
  710. {
  711. id: discardOrKeepProfileChangesDialogComponent
  712. DiscardOrKeepProfileChangesDialog { }
  713. }
  714. Loader
  715. {
  716. id: discardOrKeepProfileChangesDialogLoader
  717. }
  718. Connections
  719. {
  720. target: CuraApplication
  721. function onShowDiscardOrKeepProfileChanges()
  722. {
  723. discardOrKeepProfileChangesDialogLoader.sourceComponent = discardOrKeepProfileChangesDialogComponent
  724. discardOrKeepProfileChangesDialogLoader.item.show()
  725. }
  726. }
  727. Cura.WizardDialog
  728. {
  729. id: addMachineDialog
  730. title: catalog.i18nc("@title:window", "Add Printer")
  731. model: CuraApplication.getAddPrinterPagesModel()
  732. progressBarVisible: false
  733. }
  734. Cura.WizardDialog
  735. {
  736. id: whatsNewDialog
  737. title: catalog.i18nc("@title:window", "What's New")
  738. minimumWidth: UM.Theme.getSize("welcome_wizard_window").width
  739. minimumHeight: UM.Theme.getSize("welcome_wizard_window").height
  740. model: CuraApplication.getWhatsNewPagesModel()
  741. progressBarVisible: false
  742. visible: false
  743. }
  744. Connections
  745. {
  746. target: Cura.Actions.whatsNew
  747. function onTriggered() { whatsNewDialog.show() }
  748. }
  749. Connections
  750. {
  751. target: Cura.Actions.addMachine
  752. function onTriggered()
  753. {
  754. // Make sure to show from the first page when the dialog shows up.
  755. addMachineDialog.resetModelState()
  756. addMachineDialog.show()
  757. }
  758. }
  759. AboutDialog
  760. {
  761. id: aboutDialog
  762. }
  763. Connections
  764. {
  765. target: Cura.Actions.about
  766. function onTriggered() { aboutDialog.visible = true; }
  767. }
  768. Timer
  769. {
  770. id: startupTimer
  771. interval: 100
  772. repeat: false
  773. running: true
  774. onTriggered:
  775. {
  776. if (!base.visible)
  777. {
  778. base.visible = true
  779. }
  780. }
  781. }
  782. /**
  783. * Function to check whether a QML object has a certain type.
  784. * Taken from StackOverflow: https://stackoverflow.com/a/28384228 and
  785. * adapted to our code style.
  786. * Licensed under CC BY-SA 3.0.
  787. * \param obj The QtObject to get the name of.
  788. * \param class_name (str) The name of the class to check against. Has to be
  789. * the QtObject class name, not the QML entity name.
  790. */
  791. function qmlTypeOf(obj, class_name)
  792. {
  793. //className plus "(" is the class instance without modification.
  794. //className plus "_QML" is the class instance with user-defined properties.
  795. var str = obj.toString();
  796. return str.indexOf(class_name + "(") == 0 || str.indexOf(class_name + "_QML") == 0;
  797. }
  798. }