Cura.qml 26 KB

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