123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405 |
- // Copyright (c) 2018 Ultimaker B.V.
- // Uranium is released under the terms of the LGPLv3 or higher.
- import QtQuick 2.8
- import QtQuick.Controls 1.4
- import QtQuick.Layouts 1.3
- import QtQuick.Dialogs 1.2
- import UM 1.2 as UM
- import Cura 1.0 as Cura
- Item
- {
- id: base
- property var resetEnabled: false // Keep PreferencesDialog happy
- property var extrudersModel: Cura.ExtrudersModel{}
- UM.I18nCatalog { id: catalog; name: "cura"; }
- Cura.QualityManagementModel {
- id: qualitiesModel
- }
- Label {
- id: titleLabel
- anchors {
- top: parent.top
- left: parent.left
- right: parent.right
- margins: 5 * screenScaleFactor
- }
- font.pointSize: 18
- text: catalog.i18nc("@title:tab", "Profiles")
- }
- property var hasCurrentItem: qualityListView.currentItem != null
- property var currentItem: {
- var current_index = qualityListView.currentIndex;
- return qualitiesModel.getItem(current_index);
- }
- property var isCurrentItemActivated: {
- if (!base.currentItem) {
- return false;
- }
- return base.currentItem.name == Cura.MachineManager.activeQualityOrQualityChangesName;
- }
- property var canCreateProfile: {
- return isCurrentItemActivated && Cura.MachineManager.hasUserSettings;
- }
- Row // Button Row
- {
- id: buttonRow
- anchors {
- left: parent.left
- right: parent.right
- top: titleLabel.bottom
- }
- height: childrenRect.height
- // Activate button
- Button
- {
- text: catalog.i18nc("@action:button", "Activate")
- iconName: "list-activate"
- enabled: !isCurrentItemActivated
- onClicked: {
- if (base.currentItem.is_read_only) {
- Cura.MachineManager.setQualityGroup(base.currentItem.quality_group);
- } else {
- Cura.MachineManager.setQualityChangesGroup(base.currentItem.quality_changes_group);
- }
- }
- }
- // Create button
- Button
- {
- text: catalog.i18nc("@label", "Create")
- iconName: "list-add"
- enabled: base.canCreateProfile && !Cura.MachineManager.stacksHaveErrors
- visible: base.canCreateProfile
- onClicked: {
- newNameDialog.object = base.currentItem != null ? Cura.ContainerManager.makeUniqueName(Cura.MachineManager.activeQualityOrQualityChangesName) : "";
- newNameDialog.open();
- newNameDialog.selectText();
- }
- }
- // Duplicate button
- Button
- {
- text: catalog.i18nc("@label", "Duplicate")
- iconName: "list-add"
- enabled: !base.canCreateProfile
- visible: !base.canCreateProfile
- onClicked: {
- // TODO
- }
- }
- // Remove button
- Button
- {
- text: catalog.i18nc("@action:button", "Remove")
- iconName: "list-remove"
- //enabled: base.currentItem != null ? !base.currentItem.readOnly && !Cura.ContainerManager.isContainerUsed(base.currentItem.id) : false;
- enabled: true // TODO
- onClicked: {
- // TODO
- }
- }
- // Rename button
- Button
- {
- text: catalog.i18nc("@action:button", "Rename")
- iconName: "edit-rename"
- //enabled: base.currentItem != null ? !base.currentItem.readOnly : false;
- enabled: true // TODO
- onClicked: {
- // TODO
- }
- }
- // Import button
- Button
- {
- text: catalog.i18nc("@action:button", "Import")
- iconName: "document-import"
- onClicked: {
- // TODO
- }
- }
- // Export button
- Button
- {
- text: catalog.i18nc("@action:button", "Export")
- iconName: "document-export"
- //enabled: currentItem != null && !base.currentItem.readOnly
- enabled: true // TODO
- onClicked: {
- // TODO
- }
- }
- }
- // Dialog to request a name when creating a new profile
- UM.RenameDialog
- {
- title: catalog.i18nc("@title:window", "Create Profile")
- id: newNameDialog;
- object: "<new name>";
- onAccepted:
- {
- var selectedContainer = Cura.ContainerManager.createQualityChanges(newName);
- objectList.currentIndex = -1 //Reset selection.
- }
- }
- Item {
- id: contentsItem
- anchors {
- top: titleLabel.bottom
- left: parent.left
- right: parent.right
- bottom: parent.bottom
- margins: 5 * screenScaleFactor
- bottomMargin: 0
- }
- clip: true
- }
- Item
- {
- anchors {
- top: buttonRow.bottom
- topMargin: UM.Theme.getSize("default_margin").height
- left: parent.left
- right: parent.right
- bottom: parent.bottom
- }
- SystemPalette { id: palette }
- Label
- {
- id: captionLabel
- anchors {
- top: parent.top
- left: parent.left
- }
- visible: text != ""
- text: {
- // OLD STUFF
- return catalog.i18nc("@label %1 is printer name", "Printer: %1").arg(Cura.MachineManager.activeMachineName);
- }
- width: profileScrollView.width
- elide: Text.ElideRight
- }
- ScrollView
- {
- id: profileScrollView
- anchors {
- top: captionLabel.visible ? captionLabel.bottom : parent.top
- topMargin: captionLabel.visible ? UM.Theme.getSize("default_margin").height : 0
- bottom: parent.bottom
- left: parent.left
- }
- Rectangle {
- parent: viewport
- anchors.fill: parent
- color: palette.light
- }
- width: true ? (parent.width * 0.4) | 0 : parent.width
- ListView
- {
- id: qualityListView
- model: qualitiesModel
- section.property: "is_read_only"
- section.delegate: Rectangle
- {
- height: childrenRect.height
- Label
- {
- anchors.left: parent.left
- anchors.leftMargin: UM.Theme.getSize("default_lining").width
- text: section == "true" ? catalog.i18nc("@label", "Protected profiles") : catalog.i18nc("@label", "Custom profiles")
- font.bold: true
- }
- }
- delegate: Rectangle
- {
- width: profileScrollView.width
- height: childrenRect.height
- color: ListView.isCurrentItem ? palette.highlight : (model.index % 2) ? palette.base : palette.alternateBase
- Row
- {
- spacing: (UM.Theme.getSize("default_margin").width / 2) | 0
- anchors.left: parent.left
- anchors.leftMargin: UM.Theme.getSize("default_margin").width
- anchors.right: parent.right
- Label
- {
- width: Math.floor((parent.width * 0.3))
- text: model.name
- elide: Text.ElideRight
- font.italic: { // TODO: make it easier
- return model.name == Cura.MachineManager.activeQualityOrQualityChangesName;
- }
- color: parent.ListView.isCurrentItem ? palette.highlightedText : palette.text;
- }
- }
- MouseArea
- {
- anchors.fill: parent
- onClicked: {
- parent.ListView.view.currentIndex = model.index;
- }
- }
- }
- onCurrentIndexChanged:
- {
- var model = qualitiesModel.getItem(currentIndex);
- // TODO
- }
- }
- }
- // details panel on the right
- Item
- {
- id: detailsPanel
- anchors {
- left: profileScrollView.right
- leftMargin: UM.Theme.getSize("default_margin").width
- top: parent.top
- bottom: parent.bottom
- right: parent.right
- }
- Item
- {
- anchors.fill: parent
- Item // Profile title Label
- {
- id: profileName
- width: parent.width
- height: childrenRect.height
- Label {
- text: base.currentItem.name // TODO
- font: UM.Theme.getFont("large")
- }
- }
- Flow {
- id: currentSettingsActions
- visible: true // TODO //currentItem && currentItem.id == Cura.MachineManager.activeQualityId
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.top: profileName.bottom
- anchors.topMargin: UM.Theme.getSize("default_margin").height
- Button
- {
- text: {
- return catalog.i18nc("@action:button", "Update profile with current settings/overrides");
- }
- enabled: Cura.MachineManager.hasUserSettings && !Cura.MachineManager.isReadOnly(Cura.MachineManager.activeQualityId)
- onClicked: Cura.ContainerManager.updateQualityChanges()
- }
- Button
- {
- text: catalog.i18nc("@action:button", "Discard current changes");
- enabled: Cura.MachineManager.hasUserSettings
- onClicked: Cura.ContainerManager.clearUserContainers();
- }
- }
- Column {
- id: profileNotices
- anchors.top: currentSettingsActions.visible ? currentSettingsActions.bottom : currentSettingsActions.anchors.top
- anchors.topMargin: UM.Theme.getSize("default_margin").height
- anchors.left: parent.left
- anchors.right: parent.right
- spacing: UM.Theme.getSize("default_margin").height
- Label {
- id: defaultsMessage
- visible: false
- text: catalog.i18nc("@action:label", "This profile uses the defaults specified by the printer, so it has no settings/overrides in the list below.")
- wrapMode: Text.WordWrap
- width: parent.width
- }
- Label {
- id: noCurrentSettingsMessage
- visible: currentItem && currentItem.id == Cura.MachineManager.activeQualityId && !Cura.MachineManager.hasUserSettings
- text: catalog.i18nc("@action:label", "Your current settings match the selected profile.")
- wrapMode: Text.WordWrap
- width: parent.width
- }
- }
- TabView
- {
- anchors.left: parent.left
- anchors.top: profileNotices.visible ? profileNotices.bottom : profileNotices.anchors.top
- anchors.topMargin: UM.Theme.getSize("default_margin").height
- anchors.right: parent.right
- anchors.bottom: parent.bottom
- currentIndex: 0
- ProfileTab
- {
- title: catalog.i18nc("@title:tab", "Global Settings");
- quality: base.currentItem;
- }
- Repeater
- {
- model: base.extrudersModel
- ProfileTab
- {
- title: model.name;
- extruderPosition: model.index;
- quality: base.currentItem;
- }
- }
- }
- }
- }
- }
- }
|