1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063 |
- // Copyright (c) 2017 Ultimaker B.V.
- // Cura is released under the terms of the LGPLv3 or higher.
- import QtQuick 2.7
- import QtQuick.Controls 1.4
- import QtQuick.Controls.Styles 1.4
- import QtQuick.Layouts 1.1
- import QtQuick.Dialogs 1.2
- import UM 1.3 as UM
- import Cura 1.0 as Cura
- import "Menus"
- UM.MainWindow
- {
- id: base
- //: Cura application window title
- title: catalog.i18nc("@title:window","Ultimaker Cura");
- viewportRect: Qt.rect(0, 0, (base.width - sidebar.width) / base.width, 1.0)
- property bool showPrintMonitor: false
- backgroundColor: UM.Theme.getColor("viewport_background")
- // This connection is here to support legacy printer output devices that use the showPrintMonitor signal on Application to switch to the monitor stage
- // It should be phased out in newer plugin versions.
- Connections
- {
- target: CuraApplication
- onShowPrintMonitor: {
- if (show) {
- UM.Controller.setActiveStage("MonitorStage")
- } else {
- UM.Controller.setActiveStage("PrepareStage")
- }
- }
- }
- onWidthChanged:
- {
- // If slidebar is collapsed then it should be invisible
- // otherwise after the main_window resize the sidebar will be fully re-drawn
- if (sidebar.collapsed){
- if (sidebar.visible == true){
- sidebar.visible = false
- sidebar.initialWidth = 0
- }
- }
- else{
- if (sidebar.visible == false){
- sidebar.visible = true
- sidebar.initialWidth = UM.Theme.getSize("sidebar").width
- }
- }
- }
- Component.onCompleted:
- {
- CuraApplication.setMinimumWindowSize(UM.Theme.getSize("window_minimum_size"))
- // Workaround silly issues with QML Action's shortcut property.
- //
- // Currently, there is no way to define shortcuts as "Application Shortcut".
- // This means that all Actions are "Window Shortcuts". The code for this
- // implements a rather naive check that just checks if any of the action's parents
- // are a window. Since the "Actions" object is a singleton it has no parent by
- // default. If we set its parent to something contained in this window, the
- // shortcut will activate properly because one of its parents is a window.
- //
- // This has been fixed for QtQuick Controls 2 since the Shortcut item has a context property.
- Cura.Actions.parent = backgroundItem
- CuraApplication.purgeWindows()
- }
- Item
- {
- id: backgroundItem;
- anchors.fill: parent;
- UM.I18nCatalog{id: catalog; name:"cura"}
- signal hasMesh(string name) //this signal sends the filebase name so it can be used for the JobSpecs.qml
- function getMeshName(path){
- //takes the path the complete path of the meshname and returns only the filebase
- var fileName = path.slice(path.lastIndexOf("/") + 1)
- var fileBase = fileName.slice(0, fileName.indexOf("."))
- return fileBase
- }
- //DeleteSelection on the keypress backspace event
- Keys.onPressed: {
- if (event.key == Qt.Key_Backspace)
- {
- Cura.Actions.deleteSelection.trigger()
- }
- }
- UM.ApplicationMenu
- {
- id: menu
- window: base
- Menu
- {
- id: fileMenu
- title: catalog.i18nc("@title:menu menubar:toplevel","&File");
- MenuItem
- {
- action: Cura.Actions.newProject;
- }
- MenuItem
- {
- action: Cura.Actions.open;
- }
- RecentFilesMenu { }
- MenuItem
- {
- id: saveWorkspaceMenu
- text: catalog.i18nc("@title:menu menubar:file","&Save...")
- onTriggered:
- {
- var args = { "filter_by_machine": false, "file_type": "workspace", "preferred_mimetypes": "application/vnd.ms-package.3dmanufacturing-3dmodel+xml" };
- if(UM.Preferences.getValue("cura/dialog_on_project_save"))
- {
- saveWorkspaceDialog.args = args;
- saveWorkspaceDialog.open()
- }
- else
- {
- UM.OutputDeviceManager.requestWriteToDevice("local_file", PrintInformation.jobName, args)
- }
- }
- }
- MenuSeparator { }
- MenuItem
- {
- id: saveAsMenu
- text: catalog.i18nc("@title:menu menubar:file", "&Export...")
- onTriggered:
- {
- var localDeviceId = "local_file";
- UM.OutputDeviceManager.requestWriteToDevice(localDeviceId, PrintInformation.jobName, { "filter_by_machine": false, "preferred_mimetypes": "application/vnd.ms-package.3dmanufacturing-3dmodel+xml"});
- }
- }
- MenuItem
- {
- text: catalog.i18nc("@action:inmenu menubar:file", "Export Selection...");
- enabled: UM.Selection.hasSelection;
- iconName: "document-save-as";
- onTriggered: UM.OutputDeviceManager.requestWriteSelectionToDevice("local_file", PrintInformation.jobName, { "filter_by_machine": false, "preferred_mimetypes": "application/vnd.ms-package.3dmanufacturing-3dmodel+xml"});
- }
- MenuSeparator { }
- MenuItem { action: Cura.Actions.reloadAll; }
- MenuSeparator { }
- MenuItem { action: Cura.Actions.quit; }
- }
- Menu
- {
- title: catalog.i18nc("@title:menu menubar:toplevel","&Edit");
- MenuItem { action: Cura.Actions.undo; }
- MenuItem { action: Cura.Actions.redo; }
- MenuSeparator { }
- MenuItem { action: Cura.Actions.selectAll; }
- MenuItem { action: Cura.Actions.arrangeAll; }
- MenuItem { action: Cura.Actions.deleteSelection; }
- MenuItem { action: Cura.Actions.deleteAll; }
- MenuItem { action: Cura.Actions.resetAllTranslation; }
- MenuItem { action: Cura.Actions.resetAll; }
- MenuSeparator { }
- MenuItem { action: Cura.Actions.groupObjects;}
- MenuItem { action: Cura.Actions.mergeObjects;}
- MenuItem { action: Cura.Actions.unGroupObjects;}
- }
- ViewMenu { title: catalog.i18nc("@title:menu", "&View") }
- Menu
- {
- id: settingsMenu
- title: catalog.i18nc("@title:menu", "&Settings")
- PrinterMenu { title: catalog.i18nc("@title:menu menubar:settings", "&Printer") }
- Instantiator
- {
- model: Cura.ExtrudersModel { simpleNames: true }
- Menu {
- title: model.name
- NozzleMenu { title: Cura.MachineManager.activeDefinitionVariantsName; visible: Cura.MachineManager.hasVariants; extruderIndex: index }
- MaterialMenu { title: catalog.i18nc("@title:menu", "&Material"); visible: Cura.MachineManager.hasMaterials; extruderIndex: index }
- MenuSeparator
- {
- visible: Cura.MachineManager.hasVariants || Cura.MachineManager.hasMaterials
- }
- MenuItem
- {
- text: catalog.i18nc("@action:inmenu", "Set as Active Extruder")
- onTriggered: Cura.MachineManager.setExtruderIndex(model.index)
- }
- MenuItem
- {
- text: catalog.i18nc("@action:inmenu", "Enable Extruder")
- onTriggered: Cura.MachineManager.setExtruderEnabled(model.index, true)
- visible: !Cura.MachineManager.getExtruder(model.index).isEnabled
- }
- MenuItem
- {
- text: catalog.i18nc("@action:inmenu", "Disable Extruder")
- onTriggered: Cura.MachineManager.setExtruderEnabled(model.index, false)
- visible: Cura.MachineManager.getExtruder(model.index).isEnabled
- enabled: Cura.MachineManager.numberExtrudersEnabled > 1
- }
- }
- onObjectAdded: settingsMenu.insertItem(index, object)
- onObjectRemoved: settingsMenu.removeItem(object)
- }
- // TODO Only show in dev mode. Remove check when feature ready
- BuildplateMenu { title: catalog.i18nc("@title:menu", "&Build plate"); visible: CuraSDKVersion == "dev" ? Cura.MachineManager.hasVariantBuildplates : false }
- ProfileMenu { title: catalog.i18nc("@title:settings", "&Profile"); }
- MenuSeparator { }
- MenuItem { action: Cura.Actions.configureSettingVisibility }
- }
- Menu
- {
- id: extension_menu
- title: catalog.i18nc("@title:menu menubar:toplevel","E&xtensions");
- Instantiator
- {
- id: extensions
- model: UM.ExtensionModel { }
- Menu
- {
- id: sub_menu
- title: model.name;
- visible: actions != null
- enabled: actions != null
- Instantiator
- {
- model: actions
- MenuItem
- {
- text: model.text
- onTriggered: extensions.model.subMenuTriggered(name, model.text)
- }
- onObjectAdded: sub_menu.insertItem(index, object)
- onObjectRemoved: sub_menu.removeItem(object)
- }
- }
- onObjectAdded: extension_menu.insertItem(index, object)
- onObjectRemoved: extension_menu.removeItem(object)
- }
- }
- Menu
- {
- id: plugin_menu
- title: catalog.i18nc("@title:menu menubar:toplevel", "&Toolbox")
- MenuItem { action: Cura.Actions.browsePackages }
- }
- Menu
- {
- title: catalog.i18nc("@title:menu menubar:toplevel","P&references");
- MenuItem { action: Cura.Actions.preferences; }
- }
- Menu
- {
- //: Help menu
- title: catalog.i18nc("@title:menu menubar:toplevel","&Help");
- MenuItem { action: Cura.Actions.showProfileFolder; }
- MenuItem { action: Cura.Actions.documentation; }
- MenuItem { action: Cura.Actions.reportBug; }
- MenuSeparator { }
- MenuItem { action: Cura.Actions.about; }
- }
- }
- UM.SettingPropertyProvider
- {
- id: machineExtruderCount
- containerStack: Cura.MachineManager.activeMachine
- key: "machine_extruder_count"
- watchedProperties: [ "value" ]
- storeIndex: 0
- }
- Item
- {
- id: contentItem;
- y: menu.height
- width: parent.width;
- height: parent.height - menu.height;
- Keys.forwardTo: menu
- DropArea
- {
- anchors.fill: parent;
- onDropped:
- {
- if (drop.urls.length > 0)
- {
- var nonPackages = [];
- for (var i = 0; i < drop.urls.length; i++)
- {
- var filename = drop.urls[i];
- if (filename.endsWith(".curapackage"))
- {
- // Try to install plugin & close.
- CuraApplication.getPackageManager().installPackageViaDragAndDrop(filename);
- packageInstallDialog.text = catalog.i18nc("@label", "This package will be installed after restarting.");
- packageInstallDialog.icon = StandardIcon.Information;
- packageInstallDialog.open();
- }
- else
- {
- nonPackages.push(filename);
- }
- }
- openDialog.handleOpenFileUrls(nonPackages);
- }
- }
- }
- JobSpecs
- {
- id: jobSpecs
- anchors
- {
- bottom: parent.bottom;
- right: sidebar.left;
- bottomMargin: UM.Theme.getSize("default_margin").height;
- rightMargin: UM.Theme.getSize("default_margin").width;
- }
- }
- Button
- {
- id: openFileButton;
- text: catalog.i18nc("@action:button","Open File");
- iconSource: UM.Theme.getIcon("load")
- style: UM.Theme.styles.tool_button
- tooltip: ""
- anchors
- {
- top: topbar.bottom;
- topMargin: UM.Theme.getSize("default_margin").height;
- left: parent.left;
- }
- action: Cura.Actions.open;
- }
- Toolbar
- {
- id: toolbar;
- property int mouseX: base.mouseX
- property int mouseY: base.mouseY
- anchors {
- top: openFileButton.bottom;
- topMargin: UM.Theme.getSize("window_margin").height;
- left: parent.left;
- }
- }
- ObjectsList
- {
- id: objectsList;
- visible: UM.Preferences.getValue("cura/use_multi_build_plate");
- anchors
- {
- bottom: parent.bottom;
- left: parent.left;
- }
- }
- Topbar
- {
- id: topbar
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.top: parent.top
- }
- Loader
- {
- id: main
- anchors
- {
- top: topbar.bottom
- bottom: parent.bottom
- left: parent.left
- right: sidebar.left
- }
- MouseArea
- {
- visible: UM.Controller.activeStage.mainComponent != ""
- anchors.fill: parent
- acceptedButtons: Qt.AllButtons
- onWheel: wheel.accepted = true
- }
- source: UM.Controller.activeStage.mainComponent
- }
- Loader
- {
- id: sidebar
- property bool collapsed: false;
- property var initialWidth: UM.Theme.getSize("sidebar").width;
- function callExpandOrCollapse() {
- if (collapsed) {
- sidebar.visible = true;
- sidebar.initialWidth = UM.Theme.getSize("sidebar").width;
- viewportRect = Qt.rect(0, 0, (base.width - sidebar.width) / base.width, 1.0);
- expandSidebarAnimation.start();
- } else {
- viewportRect = Qt.rect(0, 0, 1, 1.0);
- collapseSidebarAnimation.start();
- }
- collapsed = !collapsed;
- UM.Preferences.setValue("cura/sidebar_collapsed", collapsed);
- }
- anchors
- {
- top: topbar.top
- bottom: parent.bottom
- }
- width: initialWidth
- x: base.width - sidebar.width
- source: UM.Controller.activeStage.sidebarComponent
- NumberAnimation {
- id: collapseSidebarAnimation
- target: sidebar
- properties: "x"
- to: base.width
- duration: 100
- }
- NumberAnimation {
- id: expandSidebarAnimation
- target: sidebar
- properties: "x"
- to: base.width - sidebar.width
- duration: 100
- }
- Component.onCompleted:
- {
- var sidebar_collapsed = UM.Preferences.getValue("cura/sidebar_collapsed");
- if (sidebar_collapsed)
- {
- sidebar.collapsed = true;
- viewportRect = Qt.rect(0, 0, 1, 1.0)
- collapseSidebarAnimation.start();
- }
- }
- MouseArea
- {
- visible: UM.Controller.activeStage.sidebarComponent != ""
- anchors.fill: parent
- acceptedButtons: Qt.AllButtons
- onWheel: wheel.accepted = true
- }
- }
- UM.MessageStack
- {
- anchors
- {
- horizontalCenter: parent.horizontalCenter
- horizontalCenterOffset: -(Math.round(UM.Theme.getSize("sidebar").width / 2))
- top: parent.verticalCenter;
- bottom: parent.bottom;
- bottomMargin: UM.Theme.getSize("default_margin").height
- }
- }
- }
- }
- // Expand or collapse sidebar
- Connections
- {
- target: Cura.Actions.expandSidebar
- onTriggered: sidebar.callExpandOrCollapse()
- }
- UM.PreferencesDialog
- {
- id: preferences
- Component.onCompleted:
- {
- //; Remove & re-add the general page as we want to use our own instead of uranium standard.
- removePage(0);
- insertPage(0, catalog.i18nc("@title:tab","General"), Qt.resolvedUrl("Preferences/GeneralPage.qml"));
- removePage(1);
- insertPage(1, catalog.i18nc("@title:tab","Settings"), Qt.resolvedUrl("Preferences/SettingVisibilityPage.qml"));
- insertPage(2, catalog.i18nc("@title:tab", "Printers"), Qt.resolvedUrl("Preferences/MachinesPage.qml"));
- insertPage(3, catalog.i18nc("@title:tab", "Materials"), Qt.resolvedUrl("Preferences/Materials/MaterialsPage.qml"));
- insertPage(4, catalog.i18nc("@title:tab", "Profiles"), Qt.resolvedUrl("Preferences/ProfilesPage.qml"));
- // Remove plug-ins page because we will use the shiny new plugin browser:
- removePage(5);
- //Force refresh
- setPage(0);
- }
- onVisibleChanged:
- {
- // When the dialog closes, switch to the General page.
- // This prevents us from having a heavy page like Setting Visiblity active in the background.
- setPage(0);
- }
- }
- WorkspaceSummaryDialog
- {
- id: saveWorkspaceDialog
- property var args
- onYes: UM.OutputDeviceManager.requestWriteToDevice("local_file", PrintInformation.jobName, args)
- }
- Connections
- {
- target: Cura.Actions.preferences
- onTriggered: preferences.visible = true
- }
- Connections
- {
- target: CuraApplication
- onShowPreferencesWindow: preferences.visible = true
- }
- MessageDialog
- {
- id: newProjectDialog
- modality: Qt.ApplicationModal
- title: catalog.i18nc("@title:window", "New project")
- text: catalog.i18nc("@info:question", "Are you sure you want to start a new project? This will clear the build plate and any unsaved settings.")
- standardButtons: StandardButton.Yes | StandardButton.No
- icon: StandardIcon.Question
- onYes:
- {
- CuraApplication.deleteAll();
- Cura.Actions.resetProfile.trigger();
- }
- }
- Connections
- {
- target: Cura.Actions.newProject
- onTriggered:
- {
- if(Printer.platformActivity || Cura.MachineManager.hasUserSettings)
- {
- newProjectDialog.visible = true
- }
- }
- }
- Connections
- {
- target: Cura.Actions.addProfile
- onTriggered:
- {
- preferences.show();
- preferences.setPage(4);
- // Create a new profile after a very short delay so the preference page has time to initiate
- createProfileTimer.start();
- }
- }
- Connections
- {
- target: Cura.Actions.configureMachines
- onTriggered:
- {
- preferences.visible = true;
- preferences.setPage(2);
- }
- }
- Connections
- {
- target: Cura.Actions.manageProfiles
- onTriggered:
- {
- preferences.visible = true;
- preferences.setPage(4);
- }
- }
- Connections
- {
- target: Cura.Actions.manageMaterials
- onTriggered:
- {
- preferences.visible = true;
- preferences.setPage(3)
- }
- }
- Connections
- {
- target: Cura.Actions.configureSettingVisibility
- onTriggered:
- {
- preferences.visible = true;
- preferences.setPage(1);
- if(source && source.key)
- {
- preferences.getCurrentItem().scrollToSection(source.key);
- }
- }
- }
- UM.ExtensionModel {
- id: curaExtensions
- }
- // show the plugin browser dialog
- Connections
- {
- target: Cura.Actions.browsePackages
- onTriggered: {
- curaExtensions.callExtensionMethod("Toolbox", "browsePackages")
- }
- }
- Timer
- {
- id: createProfileTimer
- repeat: false
- interval: 1
- onTriggered: preferences.getCurrentItem().createProfile()
- }
- // BlurSettings is a way to force the focus away from any of the setting items.
- // We need to do this in order to keep the bindings intact.
- Connections
- {
- target: Cura.MachineManager
- onBlurSettings:
- {
- contentItem.forceActiveFocus()
- }
- }
- ContextMenu {
- id: contextMenu
- }
- onPreClosing:
- {
- close.accepted = CuraApplication.getIsAllChecksPassed();
- if (!close.accepted)
- {
- CuraApplication.checkAndExitApplication();
- }
- }
- MessageDialog
- {
- id: exitConfirmationDialog
- title: catalog.i18nc("@title:window", "Closing Cura")
- text: catalog.i18nc("@label", "Are you sure you want to exit Cura?")
- icon: StandardIcon.Question
- modality: Qt.ApplicationModal
- standardButtons: StandardButton.Yes | StandardButton.No
- onYes: CuraApplication.callConfirmExitDialogCallback(true)
- onNo: CuraApplication.callConfirmExitDialogCallback(false)
- onRejected: CuraApplication.callConfirmExitDialogCallback(false)
- onVisibilityChanged:
- {
- if (!visible)
- {
- // reset the text to default because other modules may change the message text.
- text = catalog.i18nc("@label", "Are you sure you want to exit Cura?");
- }
- }
- }
- Connections
- {
- target: CuraApplication
- onShowConfirmExitDialog:
- {
- exitConfirmationDialog.text = message;
- exitConfirmationDialog.open();
- }
- }
- Connections
- {
- target: Cura.Actions.quit
- onTriggered: CuraApplication.checkAndExitApplication();
- }
- Connections
- {
- target: Cura.Actions.toggleFullScreen
- onTriggered: base.toggleFullscreen();
- }
- FileDialog
- {
- id: openDialog;
- //: File open dialog title
- title: catalog.i18nc("@title:window","Open file(s)")
- modality: UM.Application.platform == "linux" ? Qt.NonModal : Qt.WindowModal;
- selectMultiple: true
- nameFilters: UM.MeshFileHandler.supportedReadFileTypes;
- folder: CuraApplication.getDefaultPath("dialog_load_path")
- onAccepted:
- {
- // Because several implementations of the file dialog only update the folder
- // when it is explicitly set.
- var f = folder;
- folder = f;
- CuraApplication.setDefaultPath("dialog_load_path", folder);
- handleOpenFileUrls(fileUrls);
- }
- // Yeah... I know... it is a mess to put all those things here.
- // There are lots of user interactions in this part of the logic, such as showing a warning dialog here and there,
- // etc. This means it will come back and forth from time to time between QML and Python. So, separating the logic
- // and view here may require more effort but make things more difficult to understand.
- function handleOpenFileUrls(fileUrlList)
- {
- // look for valid project files
- var projectFileUrlList = [];
- var hasGcode = false;
- var nonGcodeFileList = [];
- for (var i in fileUrlList)
- {
- var endsWithG = /\.g$/;
- var endsWithGcode = /\.gcode$/;
- if (endsWithG.test(fileUrlList[i]) || endsWithGcode.test(fileUrlList[i]))
- {
- continue;
- }
- else if (CuraApplication.checkIsValidProjectFile(fileUrlList[i]))
- {
- projectFileUrlList.push(fileUrlList[i]);
- }
- nonGcodeFileList.push(fileUrlList[i]);
- }
- hasGcode = nonGcodeFileList.length < fileUrlList.length;
- // show a warning if selected multiple files together with Gcode
- var hasProjectFile = projectFileUrlList.length > 0;
- var selectedMultipleFiles = fileUrlList.length > 1;
- if (selectedMultipleFiles && hasGcode)
- {
- infoMultipleFilesWithGcodeDialog.selectedMultipleFiles = selectedMultipleFiles;
- infoMultipleFilesWithGcodeDialog.hasProjectFile = hasProjectFile;
- infoMultipleFilesWithGcodeDialog.fileUrls = nonGcodeFileList.slice();
- infoMultipleFilesWithGcodeDialog.projectFileUrlList = projectFileUrlList.slice();
- infoMultipleFilesWithGcodeDialog.open();
- }
- else
- {
- handleOpenFiles(selectedMultipleFiles, hasProjectFile, fileUrlList, projectFileUrlList);
- }
- }
- function handleOpenFiles(selectedMultipleFiles, hasProjectFile, fileUrlList, projectFileUrlList)
- {
- // we only allow opening one project file
- if (selectedMultipleFiles && hasProjectFile)
- {
- openFilesIncludingProjectsDialog.fileUrls = fileUrlList.slice();
- openFilesIncludingProjectsDialog.show();
- return;
- }
- if (hasProjectFile)
- {
- var projectFile = projectFileUrlList[0];
- // check preference
- var choice = UM.Preferences.getValue("cura/choice_on_open_project");
- if (choice == "open_as_project")
- {
- openFilesIncludingProjectsDialog.loadProjectFile(projectFile);
- }
- else if (choice == "open_as_model")
- {
- openFilesIncludingProjectsDialog.loadModelFiles([projectFile].slice());
- }
- else // always ask
- {
- // ask whether to open as project or as models
- askOpenAsProjectOrModelsDialog.fileUrl = projectFile;
- askOpenAsProjectOrModelsDialog.show();
- }
- }
- else
- {
- openFilesIncludingProjectsDialog.loadModelFiles(fileUrlList.slice());
- }
- }
- }
- MessageDialog
- {
- id: packageInstallDialog
- title: catalog.i18nc("@window:title", "Install Package");
- standardButtons: StandardButton.Ok
- modality: Qt.ApplicationModal
- }
- MessageDialog {
- id: infoMultipleFilesWithGcodeDialog
- title: catalog.i18nc("@title:window", "Open File(s)")
- icon: StandardIcon.Information
- standardButtons: StandardButton.Ok
- 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.")
- property var selectedMultipleFiles
- property var hasProjectFile
- property var fileUrls
- property var projectFileUrlList
- onAccepted:
- {
- openDialog.handleOpenFiles(selectedMultipleFiles, hasProjectFile, fileUrls, projectFileUrlList);
- }
- }
- Connections
- {
- target: Cura.Actions.open
- onTriggered: openDialog.open()
- }
- OpenFilesIncludingProjectsDialog
- {
- id: openFilesIncludingProjectsDialog
- }
- AskOpenAsProjectOrModelsDialog
- {
- id: askOpenAsProjectOrModelsDialog
- }
- Connections
- {
- target: CuraApplication
- onOpenProjectFile:
- {
- askOpenAsProjectOrModelsDialog.fileUrl = project_file;
- askOpenAsProjectOrModelsDialog.show();
- }
- }
- EngineLog
- {
- id: engineLog;
- }
- Connections
- {
- target: Cura.Actions.showProfileFolder
- onTriggered:
- {
- var path = UM.Resources.getPath(UM.Resources.Preferences, "");
- if(Qt.platform.os == "windows") {
- path = path.replace(/\\/g,"/");
- }
- Qt.openUrlExternally(path);
- if(Qt.platform.os == "linux") {
- Qt.openUrlExternally(UM.Resources.getPath(UM.Resources.Resources, ""));
- }
- }
- }
- AddMachineDialog
- {
- id: addMachineDialog
- onMachineAdded:
- {
- machineActionsWizard.firstRun = addMachineDialog.firstRun
- machineActionsWizard.start(id)
- }
- }
- // Dialog to handle first run machine actions
- UM.Wizard
- {
- id: machineActionsWizard;
- title: catalog.i18nc("@title:window", "Add Printer")
- property var machine;
- function start(id)
- {
- var actions = Cura.MachineActionManager.getFirstStartActions(id)
- resetPages() // Remove previous pages
- for (var i = 0; i < actions.length; i++)
- {
- actions[i].displayItem.reset()
- machineActionsWizard.appendPage(actions[i].displayItem, catalog.i18nc("@title", actions[i].label));
- }
- //Only start if there are actions to perform.
- if (actions.length > 0)
- {
- machineActionsWizard.currentPage = 0;
- show()
- }
- }
- }
- MessageDialog
- {
- id: messageDialog
- modality: Qt.ApplicationModal
- onAccepted: CuraApplication.messageBoxClosed(clickedButton)
- onApply: CuraApplication.messageBoxClosed(clickedButton)
- onDiscard: CuraApplication.messageBoxClosed(clickedButton)
- onHelp: CuraApplication.messageBoxClosed(clickedButton)
- onNo: CuraApplication.messageBoxClosed(clickedButton)
- onRejected: CuraApplication.messageBoxClosed(clickedButton)
- onReset: CuraApplication.messageBoxClosed(clickedButton)
- onYes: CuraApplication.messageBoxClosed(clickedButton)
- }
- Connections
- {
- target: CuraApplication
- onShowMessageBox:
- {
- messageDialog.title = title
- messageDialog.text = text
- messageDialog.informativeText = informativeText
- messageDialog.detailedText = detailedText
- messageDialog.standardButtons = buttons
- messageDialog.icon = icon
- messageDialog.visible = true
- }
- }
- DiscardOrKeepProfileChangesDialog
- {
- id: discardOrKeepProfileChangesDialog
- }
- Connections
- {
- target: CuraApplication
- onShowDiscardOrKeepProfileChanges:
- {
- discardOrKeepProfileChangesDialog.show()
- }
- }
- Connections
- {
- target: Cura.Actions.addMachine
- onTriggered: addMachineDialog.visible = true;
- }
- AboutDialog
- {
- id: aboutDialog
- }
- Connections
- {
- target: Cura.Actions.about
- onTriggered: aboutDialog.visible = true;
- }
- Connections
- {
- target: CuraApplication
- onRequestAddPrinter:
- {
- addMachineDialog.visible = true
- addMachineDialog.firstRun = false
- }
- }
- Timer
- {
- id: startupTimer;
- interval: 100;
- repeat: false;
- running: true;
- onTriggered:
- {
- if(!base.visible)
- {
- base.visible = true;
- }
- // check later if the user agreement dialog has been closed
- if (CuraApplication.needToShowUserAgreement)
- {
- restart();
- }
- else if(Cura.MachineManager.activeMachine == null)
- {
- addMachineDialog.open();
- }
- }
- }
- }
|