Cura.qml 26 KB

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