Cura.qml 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934
  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. property bool tallerThanParent: height > parent.height
  274. anchors
  275. {
  276. verticalCenter: tallerThanParent ? undefined : parent.verticalCenter
  277. left: parent.left
  278. }
  279. visible: CuraApplication.platformActivity && !PrintInformation.preSliced
  280. }
  281. // A hint for the loaded content view. Overlay items / controls can safely be placed in this area
  282. Item {
  283. id: mainSafeArea
  284. anchors.left: viewOrientationControls.right
  285. anchors.right: main.right
  286. anchors.top: main.top
  287. anchors.bottom: main.bottom
  288. }
  289. Loader
  290. {
  291. // A stage can control this area. If nothing is set, it will therefore show the 3D view.
  292. id: main
  293. anchors
  294. {
  295. // Align to the top of the stageMenu since the stageMenu may not exist
  296. top: stageMenu.source ? stageMenu.verticalCenter : parent.top
  297. left: parent.left
  298. right: parent.right
  299. bottom: parent.bottom
  300. }
  301. source: UM.Controller.activeStage != null ? UM.Controller.activeStage.mainComponent : ""
  302. onLoaded: {
  303. if (main.item.safeArea !== undefined){
  304. main.item.safeArea = Qt.binding(function() { return mainSafeArea });
  305. }
  306. }
  307. }
  308. Loader
  309. {
  310. // The stage menu is, as the name implies, a menu that is defined by the active stage.
  311. // Note that this menu does not need to be set at all! It's perfectly acceptable to have a stage
  312. // without this menu!
  313. id: stageMenu
  314. anchors
  315. {
  316. left: parent.left
  317. right: parent.right
  318. top: parent.top
  319. }
  320. height: UM.Theme.getSize("stage_menu").height
  321. source: UM.Controller.activeStage != null ? UM.Controller.activeStage.stageMenuComponent : ""
  322. // HACK: This is to ensure that the parent never gets set to null, as this wreaks havoc on the focus.
  323. function onParentDestroyed()
  324. {
  325. printSetupSelector.parent = stageMenu
  326. printSetupSelector.visible = false
  327. }
  328. property Item oldParent: null
  329. // The printSetupSelector is defined here so that the setting list doesn't need to get re-instantiated
  330. // Every time the stage is changed.
  331. property var printSetupSelector: Cura.PrintSetupSelector
  332. {
  333. width: UM.Theme.getSize("print_setup_widget").width
  334. height: UM.Theme.getSize("stage_menu").height
  335. headerCornerSide: RoundedRectangle.Direction.Right
  336. onParentChanged:
  337. {
  338. if(stageMenu.oldParent !=null)
  339. {
  340. stageMenu.oldParent.Component.destruction.disconnect(stageMenu.onParentDestroyed)
  341. }
  342. stageMenu.oldParent = parent
  343. visible = parent != stageMenu
  344. parent.Component.destruction.connect(stageMenu.onParentDestroyed)
  345. }
  346. }
  347. }
  348. UM.MessageStack
  349. {
  350. anchors
  351. {
  352. horizontalCenter: parent.horizontalCenter
  353. top: parent.verticalCenter
  354. bottom: parent.bottom
  355. bottomMargin: UM.Theme.getSize("default_margin").height
  356. }
  357. primaryButton: Component
  358. {
  359. Cura.PrimaryButton
  360. {
  361. text: model.name
  362. iconSource: UM.Theme.getIcon(model.icon)
  363. height: UM.Theme.getSize("message_action_button").height
  364. }
  365. }
  366. secondaryButton: Component
  367. {
  368. Cura.SecondaryButton
  369. {
  370. text: model.name
  371. iconSource: UM.Theme.getIcon(model.icon)
  372. height: UM.Theme.getSize("message_action_button").height
  373. }
  374. }
  375. link: Component
  376. {
  377. Cura.TertiaryButton
  378. {
  379. text: model.name
  380. iconSource:
  381. {
  382. if (model.icon == null || model.icon == "")
  383. {
  384. return UM.Theme.getIcon("LinkExternal")
  385. }
  386. return UM.Theme.getIcon(model.icon)
  387. }
  388. height: UM.Theme.getSize("message_action_button").height
  389. }
  390. }
  391. }
  392. }
  393. PrintSetupTooltip
  394. {
  395. id: tooltip
  396. sourceWidth: UM.Theme.getSize("print_setup_widget").width
  397. }
  398. }
  399. UM.PreferencesDialog
  400. {
  401. id: preferences
  402. Component.onCompleted:
  403. {
  404. //; Remove & re-add the general page as we want to use our own instead of uranium standard.
  405. removePage(0);
  406. insertPage(0, catalog.i18nc("@title:tab","General"), Qt.resolvedUrl("Preferences/GeneralPage.qml"));
  407. removePage(1);
  408. insertPage(1, catalog.i18nc("@title:tab","Settings"), Qt.resolvedUrl("Preferences/SettingVisibilityPage.qml"));
  409. insertPage(2, catalog.i18nc("@title:tab", "Printers"), Qt.resolvedUrl("Preferences/MachinesPage.qml"));
  410. insertPage(3, catalog.i18nc("@title:tab", "Materials"), Qt.resolvedUrl("Preferences/Materials/MaterialsPage.qml"));
  411. insertPage(4, catalog.i18nc("@title:tab", "Profiles"), Qt.resolvedUrl("Preferences/ProfilesPage.qml"));
  412. currentPage = 0;
  413. }
  414. onVisibleChanged:
  415. {
  416. // When the dialog closes, switch to the General page.
  417. // This prevents us from having a heavy page like Setting Visibility active in the background.
  418. setPage(0);
  419. }
  420. }
  421. Connections
  422. {
  423. target: Cura.Actions.preferences
  424. function onTriggered() { preferences.visible = true }
  425. }
  426. Connections
  427. {
  428. target: CuraApplication
  429. function onShowPreferencesWindow() { preferences.visible = true }
  430. }
  431. Connections
  432. {
  433. target: Cura.Actions.addProfile
  434. function onTriggered() { createNewQualityDialog.visible = true; }
  435. }
  436. Connections
  437. {
  438. target: Cura.Actions.configureMachines
  439. function onTriggered()
  440. {
  441. preferences.visible = true;
  442. preferences.setPage(2);
  443. }
  444. }
  445. Connections
  446. {
  447. target: Cura.Actions.manageProfiles
  448. function onTriggered()
  449. {
  450. preferences.visible = true;
  451. preferences.setPage(4);
  452. }
  453. }
  454. Connections
  455. {
  456. target: Cura.Actions.manageMaterials
  457. function onTriggered()
  458. {
  459. preferences.visible = true;
  460. preferences.setPage(3)
  461. }
  462. }
  463. Connections
  464. {
  465. target: Cura.Actions.configureSettingVisibility
  466. function onTriggered(source)
  467. {
  468. preferences.visible = true;
  469. preferences.setPage(1);
  470. if(source && source.key)
  471. {
  472. preferences.getCurrentItem().scrollToSection(source.key);
  473. }
  474. }
  475. }
  476. // BlurSettings is a way to force the focus away from any of the setting items.
  477. // We need to do this in order to keep the bindings intact.
  478. Connections
  479. {
  480. target: Cura.MachineManager
  481. function onBlurSettings()
  482. {
  483. contentItem.forceActiveFocus()
  484. }
  485. }
  486. ContextMenu
  487. {
  488. id: contextMenu
  489. }
  490. onPreClosing: (close) =>
  491. {
  492. close.accepted = CuraApplication.getIsAllChecksPassed();
  493. if (!close.accepted)
  494. {
  495. CuraApplication.checkAndExitApplication();
  496. }
  497. }
  498. Cura.MessageDialog
  499. {
  500. id: exitConfirmationDialog
  501. title: catalog.i18nc("@title:window %1 is the application name", "Closing %1").arg(CuraApplication.applicationDisplayName)
  502. text: catalog.i18nc("@label %1 is the application name", "Are you sure you want to exit %1?").arg(CuraApplication.applicationDisplayName)
  503. standardButtons: Dialog.Yes | Dialog.No
  504. onAccepted: CuraApplication.callConfirmExitDialogCallback(true)
  505. onRejected: CuraApplication.callConfirmExitDialogCallback(false)
  506. onClosed:
  507. {
  508. if (!visible)
  509. {
  510. // reset the text to default because other modules may change the message text.
  511. text = catalog.i18nc("@label %1 is the application name", "Are you sure you want to exit %1?").arg(CuraApplication.applicationDisplayName);
  512. }
  513. }
  514. }
  515. Connections
  516. {
  517. target: CuraApplication
  518. function onShowConfirmExitDialog(message)
  519. {
  520. exitConfirmationDialog.text = message;
  521. exitConfirmationDialog.open();
  522. }
  523. }
  524. Connections
  525. {
  526. target: Cura.Actions.quit
  527. function onTriggered() { CuraApplication.checkAndExitApplication(); }
  528. }
  529. Connections
  530. {
  531. target: Cura.Actions.toggleFullScreen
  532. function onTriggered() { base.toggleFullscreen() }
  533. }
  534. Connections
  535. {
  536. target: Cura.Actions.exitFullScreen
  537. function onTriggered() { base.exitFullscreen() }
  538. }
  539. FileDialog
  540. {
  541. id: openDialog;
  542. //: File open dialog title
  543. title: catalog.i18nc("@title:window","Open file(s)")
  544. modality: Qt.WindowModal
  545. fileMode: FileDialog.OpenFiles
  546. nameFilters: UM.MeshFileHandler.supportedReadFileTypes;
  547. currentFolder: CuraApplication.getDefaultPath("dialog_load_path")
  548. onAccepted:
  549. {
  550. // Because several implementations of the file dialog only update the folder
  551. // when it is explicitly set.
  552. var f = currentFolder;
  553. currentFolder = f;
  554. CuraApplication.setDefaultPath("dialog_load_path", currentFolder);
  555. handleOpenFileUrls(selectedFiles);
  556. }
  557. // Yeah... I know... it is a mess to put all those things here.
  558. // There are lots of user interactions in this part of the logic, such as showing a warning dialog here and there,
  559. // etc. This means it will come back and forth from time to time between QML and Python. So, separating the logic
  560. // and view here may require more effort but make things more difficult to understand.
  561. function handleOpenFileUrls(fileUrlList)
  562. {
  563. // look for valid project files
  564. var projectFileUrlList = [];
  565. var hasGcode = false;
  566. var nonGcodeFileList = [];
  567. for (var i in fileUrlList)
  568. {
  569. var endsWithG = /\.g$/;
  570. var endsWithGcode = /\.gcode$/;
  571. if (endsWithG.test(fileUrlList[i]) || endsWithGcode.test(fileUrlList[i]))
  572. {
  573. continue;
  574. }
  575. else if (CuraApplication.checkIsValidProjectFile(fileUrlList[i]))
  576. {
  577. projectFileUrlList.push(fileUrlList[i]);
  578. }
  579. nonGcodeFileList.push(fileUrlList[i]);
  580. }
  581. hasGcode = nonGcodeFileList.length < fileUrlList.length;
  582. // show a warning if selected multiple files together with Gcode
  583. var hasProjectFile = projectFileUrlList.length > 0;
  584. var selectedMultipleFiles = fileUrlList.length > 1;
  585. if (selectedMultipleFiles && hasGcode)
  586. {
  587. infoMultipleFilesWithGcodeDialog.selectedMultipleFiles = selectedMultipleFiles;
  588. infoMultipleFilesWithGcodeDialog.hasProjectFile = hasProjectFile;
  589. infoMultipleFilesWithGcodeDialog.fileUrls = nonGcodeFileList.slice();
  590. infoMultipleFilesWithGcodeDialog.projectFileUrlList = projectFileUrlList.slice();
  591. infoMultipleFilesWithGcodeDialog.open();
  592. }
  593. else
  594. {
  595. handleOpenFiles(selectedMultipleFiles, hasProjectFile, fileUrlList, projectFileUrlList);
  596. }
  597. }
  598. function handleOpenFiles(selectedMultipleFiles, hasProjectFile, fileUrlList, projectFileUrlList)
  599. {
  600. // Make sure the files opened through the openFilesIncludingProjectDialog are added to the recent files list
  601. openFilesIncludingProjectsDialog.addToRecent = true;
  602. // we only allow opening one project file
  603. if (selectedMultipleFiles && hasProjectFile)
  604. {
  605. openFilesIncludingProjectsDialog.fileUrls = fileUrlList.slice();
  606. openFilesIncludingProjectsDialog.show();
  607. return;
  608. }
  609. if (hasProjectFile)
  610. {
  611. var projectFile = projectFileUrlList[0];
  612. // check preference
  613. var choice = UM.Preferences.getValue("cura/choice_on_open_project");
  614. if (choice == "open_as_project")
  615. {
  616. openFilesIncludingProjectsDialog.loadProjectFile(projectFile);
  617. }
  618. else if (choice == "open_as_model")
  619. {
  620. openFilesIncludingProjectsDialog.loadModelFiles([projectFile].slice());
  621. }
  622. else // always ask
  623. {
  624. // ask whether to open as project or as models
  625. askOpenAsProjectOrModelsDialog.fileUrl = projectFile;
  626. askOpenAsProjectOrModelsDialog.addToRecent = true;
  627. askOpenAsProjectOrModelsDialog.show();
  628. }
  629. }
  630. else
  631. {
  632. openFilesIncludingProjectsDialog.loadModelFiles(fileUrlList.slice());
  633. }
  634. }
  635. }
  636. Cura.MessageDialog
  637. {
  638. id: packageInstallDialog
  639. title: catalog.i18nc("@window:title", "Install Package")
  640. standardButtons: Dialog.Ok
  641. }
  642. Cura.MessageDialog
  643. {
  644. id: infoMultipleFilesWithGcodeDialog
  645. title: catalog.i18nc("@title:window", "Open File(s)")
  646. standardButtons: Dialog.Ok
  647. 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.")
  648. property var selectedMultipleFiles
  649. property var hasProjectFile
  650. property var fileUrls
  651. property var projectFileUrlList
  652. onAccepted:
  653. {
  654. openDialog.handleOpenFiles(selectedMultipleFiles, hasProjectFile, fileUrls, projectFileUrlList);
  655. }
  656. }
  657. Connections
  658. {
  659. target: Cura.Actions.open
  660. function onTriggered() { openDialog.open() }
  661. }
  662. OpenFilesIncludingProjectsDialog
  663. {
  664. id: openFilesIncludingProjectsDialog
  665. }
  666. AskOpenAsProjectOrModelsDialog
  667. {
  668. id: askOpenAsProjectOrModelsDialog
  669. }
  670. Connections
  671. {
  672. target: CuraApplication
  673. function onOpenProjectFile(project_file, add_to_recent_files)
  674. {
  675. askOpenAsProjectOrModelsDialog.fileUrl = project_file;
  676. askOpenAsProjectOrModelsDialog.addToRecent = add_to_recent_files;
  677. askOpenAsProjectOrModelsDialog.show();
  678. }
  679. }
  680. Connections
  681. {
  682. target: Cura.Actions.showProfileFolder
  683. function onTriggered()
  684. {
  685. var path = UM.Resources.getPath(UM.Resources.Preferences, "");
  686. if(Qt.platform.os == "windows")
  687. {
  688. path = path.replace(/\\/g,"/");
  689. }
  690. Qt.openUrlExternally(path);
  691. if(Qt.platform.os == "linux")
  692. {
  693. Qt.openUrlExternally(UM.Resources.getPath(UM.Resources.Resources, ""));
  694. }
  695. }
  696. }
  697. Component
  698. {
  699. id: discardOrKeepProfileChangesDialogComponent
  700. DiscardOrKeepProfileChangesDialog { }
  701. }
  702. Loader
  703. {
  704. id: discardOrKeepProfileChangesDialogLoader
  705. }
  706. Connections
  707. {
  708. target: CuraApplication
  709. function onShowCompareAndSaveProfileChanges(profileState)
  710. {
  711. discardOrKeepProfileChangesDialogLoader.sourceComponent = discardOrKeepProfileChangesDialogComponent
  712. discardOrKeepProfileChangesDialogLoader.item.state = profileState
  713. discardOrKeepProfileChangesDialogLoader.item.show()
  714. }
  715. function onShowDiscardOrKeepProfileChanges() { onShowCompareAndSaveProfileChanges("") }
  716. }
  717. Cura.WizardDialog
  718. {
  719. id: addMachineDialog
  720. title: catalog.i18nc("@title:window", "Add Printer")
  721. model: CuraApplication.getAddPrinterPagesModel()
  722. progressBarVisible: false
  723. }
  724. Cura.WizardDialog
  725. {
  726. id: whatsNewDialog
  727. title: catalog.i18nc("@title:window", "What's New")
  728. minimumWidth: UM.Theme.getSize("welcome_wizard_window").width
  729. minimumHeight: UM.Theme.getSize("welcome_wizard_window").height
  730. model: CuraApplication.getWhatsNewPagesModel()
  731. progressBarVisible: false
  732. visible: false
  733. }
  734. Connections
  735. {
  736. target: Cura.Actions.whatsNew
  737. function onTriggered() { whatsNewDialog.show() }
  738. }
  739. Connections
  740. {
  741. target: Cura.Actions.addMachine
  742. function onTriggered()
  743. {
  744. // Make sure to show from the first page when the dialog shows up.
  745. addMachineDialog.resetModelState()
  746. addMachineDialog.show()
  747. }
  748. }
  749. AboutDialog
  750. {
  751. id: aboutDialog
  752. }
  753. Connections
  754. {
  755. target: Cura.Actions.about
  756. function onTriggered() { aboutDialog.visible = true; }
  757. }
  758. Timer
  759. {
  760. id: startupTimer
  761. interval: 100
  762. repeat: false
  763. running: true
  764. onTriggered:
  765. {
  766. if (!base.visible)
  767. {
  768. base.visible = true
  769. }
  770. }
  771. }
  772. Cura.RenameDialog
  773. {
  774. id: createNewQualityDialog
  775. title: catalog.i18nc("@title:window", "Save Custom Profile")
  776. objectPlaceholder: catalog.i18nc("@textfield:placeholder", "New Custom Profile")
  777. explanation: catalog.i18nc("@info", "Custom profile name:")
  778. extraInfo:
  779. [
  780. UM.ColorImage
  781. {
  782. width: UM.Theme.getSize("message_type_icon").width
  783. height: UM.Theme.getSize("message_type_icon").height
  784. source: UM.Theme.getIcon("Information")
  785. color: UM.Theme.getColor("text")
  786. },
  787. Column
  788. {
  789. UM.Label
  790. {
  791. text: catalog.i18nc
  792. (
  793. "@label %i will be replaced with a profile name",
  794. "<b>Only user changed settings will be saved in the custom profile.</b><br/>" +
  795. "For materials that support it, the new custom profile will inherit properties from <b>%1</b>."
  796. ).arg(Cura.MachineManager.activeQualityOrQualityChangesName)
  797. wrapMode: Text.WordWrap
  798. width: parent.parent.width - 2 * UM.Theme.getSize("message_type_icon").width
  799. }
  800. Cura.TertiaryButton
  801. {
  802. text: "Learn more about Cura print profiles"
  803. iconSource: UM.Theme.getIcon("LinkExternal")
  804. isIconOnRightSide: true
  805. leftPadding: 0
  806. rightPadding: 0
  807. onClicked: Qt.openUrlExternally("https://support.ultimaker.com/s/article/1667337576882")
  808. }
  809. }
  810. ]
  811. okButtonText: catalog.i18nc("@button", "Save new profile")
  812. onAccepted: CuraApplication.getQualityManagementModel().createQualityChanges(newName, true);
  813. }
  814. /**
  815. * Function to check whether a QML object has a certain type.
  816. * Taken from StackOverflow: https://stackoverflow.com/a/28384228 and
  817. * adapted to our code style.
  818. * Licensed under CC BY-SA 3.0.
  819. * \param obj The QtObject to get the name of.
  820. * \param class_name (str) The name of the class to check against. Has to be
  821. * the QtObject class name, not the QML entity name.
  822. */
  823. function qmlTypeOf(obj, class_name)
  824. {
  825. //className plus "(" is the class instance without modification.
  826. //className plus "_QML" is the class instance with user-defined properties.
  827. var str = obj.toString();
  828. return str.indexOf(class_name + "(") == 0 || str.indexOf(class_name + "_QML") == 0;
  829. }
  830. }