123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717 |
- // Copyright (c) 2015 Ultimaker B.V.
- // Cura is released under the terms of the AGPLv3 or higher.
- import QtQuick 2.2
- import QtQuick.Controls 1.1
- import QtQuick.Controls.Styles 1.1
- import QtQuick.Layouts 1.1
- import QtQuick.Dialogs 1.1
- import UM 1.1 as UM
- UM.MainWindow
- {
- id: base
- //: Cura application window title
- title: catalog.i18nc("@title:window","Cura");
- viewportRect: Qt.rect(0, 0, (base.width - sidebar.width) / base.width, 1.0)
- 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.lastIndexOf("."))
- return fileBase
- }
- //DeleteSelection on the keypress backspace event
- Keys.onPressed: {
- if (event.key == Qt.Key_Backspace)
- {
- if(objectContextMenu.objectId != 0)
- {
- Printer.deleteObject(objectContextMenu.objectId);
- }
- }
- }
- UM.ApplicationMenu
- {
- id: menu
- window: base
- Menu
- {
- id: fileMenu
- //: File menu
- title: catalog.i18nc("@title:menu menubar:toplevel","&File");
- MenuItem {
- action: actions.open;
- }
- Menu
- {
- id: recentFilesMenu;
- title: catalog.i18nc("@title:menu menubar:file", "Open &Recent")
- iconName: "document-open-recent";
- enabled: Printer.recentFiles.length > 0;
- Instantiator
- {
- model: Printer.recentFiles
- MenuItem
- {
- text:
- {
- var path = modelData.toString()
- return (index + 1) + ". " + path.slice(path.lastIndexOf("/") + 1);
- }
- onTriggered: {
- UM.MeshFileHandler.readLocalFile(modelData);
- var meshName = backgroundItem.getMeshName(modelData.toString())
- backgroundItem.hasMesh(meshName)
- }
- }
- onObjectAdded: recentFilesMenu.insertItem(index, object)
- onObjectRemoved: recentFilesMenu.removeItem(object)
- }
- }
- MenuSeparator { }
- MenuItem
- {
- text: catalog.i18nc("@action:inmenu menubar:file", "&Save Selection to File");
- enabled: UM.Selection.hasSelection;
- iconName: "document-save-as";
- onTriggered: UM.OutputDeviceManager.requestWriteSelectionToDevice("local_file", Printer.jobName, false);
- }
- Menu
- {
- id: saveAllMenu
- title: catalog.i18nc("@title:menu menubar:file","Save &All")
- iconName: "document-save-all";
- enabled: devicesModel.rowCount() > 0 && UM.Backend.progress > 0.99;
- Instantiator
- {
- model: UM.OutputDevicesModel { id: devicesModel; }
- MenuItem
- {
- text: model.description;
- onTriggered: UM.OutputDeviceManager.requestWriteToDevice(model.id, Printer.jobName, false);
- }
- onObjectAdded: saveAllMenu.insertItem(index, object)
- onObjectRemoved: saveAllMenu.removeItem(object)
- }
- }
- MenuItem { action: actions.reloadAll; }
- MenuSeparator { }
- MenuItem { action: actions.quit; }
- }
- Menu
- {
- //: Edit menu
- title: catalog.i18nc("@title:menu menubar:toplevel","&Edit");
- MenuItem { action: actions.undo; }
- MenuItem { action: actions.redo; }
- MenuSeparator { }
- MenuItem { action: actions.deleteSelection; }
- MenuItem { action: actions.deleteAll; }
- MenuItem { action: actions.resetAllTranslation; }
- MenuItem { action: actions.resetAll; }
- MenuSeparator { }
- MenuItem { action: actions.groupObjects;}
- MenuItem { action: actions.mergeObjects;}
- MenuItem { action: actions.unGroupObjects;}
- }
- Menu
- {
- title: catalog.i18nc("@title:menu menubar:toplevel","&View");
- id: top_view_menu
- Instantiator
- {
- model: UM.ViewModel { }
- MenuItem
- {
- text: model.name;
- checkable: true;
- checked: model.active;
- exclusiveGroup: view_menu_top_group;
- onTriggered: UM.Controller.setActiveView(model.id);
- }
- onObjectAdded: top_view_menu.insertItem(index, object)
- onObjectRemoved: top_view_menu.removeItem(object)
- }
- ExclusiveGroup { id: view_menu_top_group; }
- }
- Menu
- {
- id: machineMenu;
- //: Machine menu
- title: catalog.i18nc("@title:menu menubar:toplevel","&Printer");
- Instantiator
- {
- model: UM.MachineInstancesModel { }
- MenuItem
- {
- text: model.name;
- checkable: true;
- checked: model.active;
- exclusiveGroup: machineMenuGroup;
- onTriggered: UM.MachineManager.setActiveMachineInstance(model.name)
- }
- onObjectAdded: machineMenu.insertItem(index, object)
- onObjectRemoved: machineMenu.removeItem(object)
- }
- ExclusiveGroup { id: machineMenuGroup; }
- MenuSeparator { }
- Instantiator
- {
- model: UM.MachineVariantsModel { }
- MenuItem {
- text: model.name;
- checkable: true;
- checked: model.active;
- exclusiveGroup: machineVariantsGroup;
- onTriggered: UM.MachineManager.setActiveMachineVariant(model.name)
- }
- onObjectAdded: machineMenu.insertItem(index, object)
- onObjectRemoved: machineMenu.removeItem(object)
- }
- ExclusiveGroup { id: machineVariantsGroup; }
- MenuSeparator { visible: UM.MachineManager.hasVariants; }
- MenuItem { action: actions.addMachine; }
- MenuItem { action: actions.configureMachines; }
- }
- Menu
- {
- id: profileMenu
- title: catalog.i18nc("@title:menu menubar:toplevel", "P&rofile")
- Instantiator
- {
- model: UM.ProfilesModel { }
- MenuItem {
- text: model.name;
- checkable: true;
- checked: model.active;
- exclusiveGroup: profileMenuGroup;
- onTriggered: UM.MachineManager.setActiveProfile(model.name)
- }
- onObjectAdded: profileMenu.insertItem(index, object)
- onObjectRemoved: profileMenu.removeItem(object)
- }
- ExclusiveGroup { id: profileMenuGroup; }
- MenuSeparator { }
- MenuItem { action: actions.addProfile; }
- MenuItem { action: actions.manageProfiles; }
- }
- Menu
- {
- id: extension_menu
- //: Extensions menu
- title: catalog.i18nc("@title:menu menubar:toplevel","E&xtensions");
- Instantiator
- {
- model: UM.Models.extensionModel
- Menu
- {
- id: sub_menu
- title: model.name;
- visible: actions != null
- enabled:actions != null
- Instantiator
- {
- model: actions
- MenuItem
- {
- text: model.text
- onTriggered: UM.Models.extensionModel.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
- {
- //: Settings menu
- title: catalog.i18nc("@title:menu menubar:toplevel","&Settings");
- MenuItem { action: actions.preferences; }
- }
- Menu
- {
- //: Help menu
- title: catalog.i18nc("@title:menu menubar:toplevel","&Help");
- MenuItem { action: actions.showEngineLog; }
- MenuItem { action: actions.documentation; }
- MenuItem { action: actions.reportBug; }
- MenuSeparator { }
- MenuItem { action: actions.about; }
- }
- }
- 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)
- {
- for(var i in drop.urls)
- {
- UM.MeshFileHandler.readLocalFile(drop.urls[i]);
- if (i == drop.urls.length - 1)
- {
- var meshName = backgroundItem.getMeshName(drop.urls[i].toString())
- backgroundItem.hasMesh(meshName)
- }
- }
- }
- }
- }
- JobSpecs
- {
- id: jobSpecs
- anchors
- {
- bottom: parent.bottom;
- right: sidebar.left;
- bottomMargin: UM.Theme.sizes.default_margin.height;
- rightMargin: UM.Theme.sizes.default_margin.width;
- }
- }
- UM.MessageStack
- {
- anchors
- {
- horizontalCenter: parent.horizontalCenter
- horizontalCenterOffset: -(UM.Theme.sizes.sidebar.width/ 2)
- top: parent.verticalCenter;
- bottom: parent.bottom;
- }
- }
- Loader
- {
- id: view_panel
- //anchors.left: parent.left;
- //anchors.right: parent.right;
- //anchors.bottom: parent.bottom
- anchors.top: viewModeButton.bottom
- anchors.topMargin: UM.Theme.sizes.default_margin.height;
- anchors.left: viewModeButton.left;
- //anchors.bottom: buttons.top;
- //anchors.bottomMargin: UM.Theme.sizes.default_margin.height;
- height: childrenRect.height;
- source: UM.ActiveView.valid ? UM.ActiveView.activeViewPanel : "";
- }
- Button
- {
- id: openFileButton;
- //style: UM.Backend.progress < 0 ? UM.Theme.styles.open_file_button : UM.Theme.styles.tool_button;
- text: catalog.i18nc("@action:button","Open File");
- iconSource: UM.Theme.icons.load
- style: UM.Theme.styles.tool_button
- tooltip: '';
- anchors
- {
- top: parent.top;
- //topMargin: UM.Theme.sizes.loadfile_margin.height
- left: parent.left;
- //leftMargin: UM.Theme.sizes.loadfile_margin.width
- }
- action: actions.open;
- }
- Image
- {
- id: logo
- anchors
- {
- left: parent.left
- leftMargin: UM.Theme.sizes.default_margin.width;
- bottom: parent.bottom
- bottomMargin: UM.Theme.sizes.default_margin.height;
- }
- source: UM.Theme.images.logo;
- width: UM.Theme.sizes.logo.width;
- height: UM.Theme.sizes.logo.height;
- z: -1;
- sourceSize.width: width;
- sourceSize.height: height;
- }
- Button
- {
- id: viewModeButton
- anchors
- {
- top: toolbar.bottom;
- topMargin: UM.Theme.sizes.window_margin.height;
- left: parent.left;
- }
- text: catalog.i18nc("@action:button","View Mode");
- iconSource: UM.Theme.icons.viewmode;
- style: UM.Theme.styles.tool_button;
- tooltip: '';
- menu: Menu
- {
- id: viewMenu;
- Instantiator
- {
- id: viewMenuInstantiator
- model: UM.ViewModel { }
- MenuItem
- {
- text: model.name
- checkable: true;
- checked: model.active
- exclusiveGroup: viewMenuGroup;
- onTriggered: UM.Controller.setActiveView(model.id);
- }
- onObjectAdded: viewMenu.insertItem(index, object)
- onObjectRemoved: viewMenu.removeItem(object)
- }
- ExclusiveGroup { id: viewMenuGroup; }
- }
- }
- Toolbar
- {
- id: toolbar;
- anchors {
- top: openFileButton.bottom;
- topMargin: UM.Theme.sizes.window_margin.height;
- left: parent.left;
- }
- }
- Sidebar
- {
- id: sidebar;
- anchors
- {
- top: parent.top;
- bottom: parent.bottom;
- right: parent.right;
- }
- width: UM.Theme.sizes.sidebar.width;
- addMachineAction: actions.addMachine;
- configureMachinesAction: actions.configureMachines;
- addProfileAction: actions.addProfile;
- manageProfilesAction: actions.manageProfiles;
- }
- Rectangle
- {
- x: base.mouseX + UM.Theme.sizes.default_margin.width;
- y: base.mouseY + UM.Theme.sizes.default_margin.height;
- width: childrenRect.width;
- height: childrenRect.height;
- Label
- {
- text: UM.ActiveTool.properties.getValue("Rotation") != undefined ? "%1°".arg(UM.ActiveTool.properties.getValue("Rotation")) : "";
- }
- visible: UM.ActiveTool.valid && UM.ActiveTool.properties.Rotation != undefined;
- }
- }
- }
- 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"), generalPage);
- //: View preferences page title
- insertPage(1, catalog.i18nc("@title:tab","View"), viewPage);
- //Force refresh
- setPage(0)
- }
- Item {
- visible: false
- GeneralPage
- {
- id: generalPage
- }
- ViewPage
- {
- id: viewPage
- }
- }
- }
- Actions
- {
- id: actions;
- open.onTriggered: openDialog.open();
- quit.onTriggered: base.visible = false;
- undo.onTriggered: UM.OperationStack.undo();
- undo.enabled: UM.OperationStack.canUndo;
- redo.onTriggered: UM.OperationStack.redo();
- redo.enabled: UM.OperationStack.canRedo;
- deleteSelection.onTriggered:
- {
- Printer.deleteSelection()
- }
- deleteObject.onTriggered:
- {
- if(objectContextMenu.objectId != 0)
- {
- Printer.deleteObject(objectContextMenu.objectId);
- objectContextMenu.objectId = 0;
- }
- }
- multiplyObject.onTriggered:
- {
- if(objectContextMenu.objectId != 0)
- {
- Printer.multiplyObject(objectContextMenu.objectId, 1);
- objectContextMenu.objectId = 0;
- }
- }
- centerObject.onTriggered:
- {
- if(objectContextMenu.objectId != 0)
- {
- Printer.centerObject(objectContextMenu.objectId);
- objectContextMenu.objectId = 0;
- }
- }
-
- groupObjects.onTriggered:
- {
- Printer.groupSelected()
- }
-
- unGroupObjects.onTriggered:
- {
- Printer.ungroupSelected()
- }
-
- mergeObjects.onTriggered:
- {
- Printer.mergeSelected()
- }
- deleteAll.onTriggered: Printer.deleteAll()
- resetAllTranslation.onTriggered: Printer.resetAllTranslation()
- resetAll.onTriggered: Printer.resetAll()
- reloadAll.onTriggered: Printer.reloadAll()
- addMachine.onTriggered: addMachineWizard.visible = true;
- addProfile.onTriggered: { UM.MachineManager.createProfile(); preferences.visible = true; preferences.setPage(4); }
- preferences.onTriggered: { preferences.visible = true; preferences.setPage(0); }
- configureMachines.onTriggered: { preferences.visible = true; preferences.setPage(3); }
- manageProfiles.onTriggered: { preferences.visible = true; preferences.setPage(4); }
- documentation.onTriggered: CuraActions.openDocumentation();
- reportBug.onTriggered: CuraActions.openBugReportPage();
- showEngineLog.onTriggered: engineLog.visible = true;
- about.onTriggered: aboutDialog.visible = true;
- toggleFullScreen.onTriggered: base.toggleFullscreen()
- }
- Menu
- {
- id: objectContextMenu;
- property variant objectId: -1;
- MenuItem { action: actions.centerObject; }
- MenuItem { action: actions.deleteObject; }
- MenuItem { action: actions.multiplyObject; }
- MenuSeparator { }
- MenuItem { action: actions.deleteAll; }
- MenuItem { action: actions.reloadAll; }
- MenuItem { action: actions.resetAllTranslation; }
- MenuItem { action: actions.resetAll; }
- MenuItem { action: actions.groupObjects;}
- MenuItem { action: actions.mergeObjects;}
- MenuItem { action: actions.unGroupObjects;}
- }
- Menu
- {
- id: contextMenu;
- MenuItem { action: actions.deleteAll; }
- MenuItem { action: actions.reloadAll; }
- MenuItem { action: actions.resetAllTranslation; }
- MenuItem { action: actions.resetAll; }
- MenuItem { action: actions.groupObjects;}
- MenuItem { action: actions.mergeObjects;}
- MenuItem { action: actions.unGroupObjects;}
- }
- Connections
- {
- target: UM.Controller
- onContextMenuRequested:
- {
- if(objectId == 0)
- {
- contextMenu.popup();
- } else
- {
- objectContextMenu.objectId = objectId;
- objectContextMenu.popup();
- }
- }
- }
- FileDialog
- {
- id: openDialog;
- //: File open dialog title
- title: catalog.i18nc("@title:window","Open file")
- modality: UM.Application.platform == "linux" ? Qt.NonModal : Qt.WindowModal;
- //TODO: Support multiple file selection, workaround bug in KDE file dialog
- //selectMultiple: true
- nameFilters: UM.MeshFileHandler.supportedReadFileTypes;
- onAccepted:
- {
- //Because several implementations of the file dialog only update the folder
- //when it is explicitly set.
- var f = folder;
- folder = f;
- UM.MeshFileHandler.readLocalFile(fileUrl)
- var meshName = backgroundItem.getMeshName(fileUrl.toString())
- backgroundItem.hasMesh(meshName)
- }
- }
- EngineLog
- {
- id: engineLog;
- }
- AddMachineWizard
- {
- id: addMachineWizard
- }
- AboutDialog
- {
- id: aboutDialog
- }
- Connections
- {
- target: Printer
- onRequestAddPrinter:
- {
- addMachineWizard.visible = true
- addMachineWizard.firstRun = false
- }
- }
- Component.onCompleted:
- {
- UM.Theme.load(UM.Resources.getPath(UM.Resources.Themes, "cura"))
- }
- Timer
- {
- id: startupTimer;
- interval: 100;
- repeat: false;
- running: true;
- onTriggered:
- {
- if(!base.visible)
- {
- base.visible = true;
- restart();
- }
- else if(UM.MachineManager.activeMachineInstance == "")
- {
- addMachineWizard.firstRun = true;
- addMachineWizard.open();
- }
- }
- }
- }
|