123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335 |
- // Copyright (c) 2020 Ultimaker B.V.
- // Cura is released under the terms of the LGPLv3 or higher.
- import QtQuick 2.10
- import QtQuick.Controls 2.3
- import UM 1.2 as UM
- import Cura 1.6 as Cura
- Popup
- {
- id: popup
- implicitWidth: 400
- property var dataModel: Cura.IntentCategoryModel {}
- property int defaultMargin: UM.Theme.getSize("default_margin").width
- property color backgroundColor: UM.Theme.getColor("main_background")
- property color borderColor: UM.Theme.getColor("lining")
- topPadding: UM.Theme.getSize("narrow_margin").height
- rightPadding: UM.Theme.getSize("default_lining").width
- leftPadding: UM.Theme.getSize("default_lining").width
- padding: 0
- closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
- background: Cura.RoundedRectangle
- {
- color: backgroundColor
- border.width: UM.Theme.getSize("default_lining").width
- border.color: borderColor
- cornerSide: Cura.RoundedRectangle.Direction.Down
- }
- ButtonGroup
- {
- id: buttonGroup
- exclusive: true
- onClicked: popup.visible = false
- }
- contentItem: Column
- {
- // This repeater adds the intent labels
- ScrollView
- {
- property real maximumHeight: screenScaleFactor * 400
- contentHeight: dataColumn.height
- height: Math.min(contentHeight, maximumHeight)
- clip: true
- ScrollBar.vertical.policy: height == maximumHeight ? ScrollBar.AlwaysOn: ScrollBar.AlwaysOff
- Column
- {
- id: dataColumn
- width: parent.width
- Repeater
- {
- model: dataModel
- delegate: Item
- {
- // We need to set it like that, otherwise we'd have to set the sub model with model: model.qualities
- // Which obviously won't work due to naming conflicts.
- property variant subItemModel: model.qualities
- height: childrenRect.height
- width: popup.contentWidth
- Label
- {
- id: headerLabel
- text: model.name
- color: UM.Theme.getColor("text_inactive")
- renderType: Text.NativeRendering
- width: parent.width
- height: visible ? contentHeight: 0
- visible: qualitiesList.visibleChildren.length > 0
- anchors.left: parent.left
- anchors.leftMargin: UM.Theme.getSize("default_margin").width
- MouseArea // tooltip hover area
- {
- anchors.fill: parent
- hoverEnabled: true
- enabled: model.description !== undefined
- acceptedButtons: Qt.NoButton // react to hover only, don't steal clicks
- onEntered:
- {
- base.showTooltip(
- headerLabel,
- Qt.point(- UM.Theme.getSize("default_margin").width, 0),
- model.description
- )
- }
- onExited: base.hideTooltip()
- }
- }
- Column
- {
- id: qualitiesList
- anchors.top: headerLabel.bottom
- anchors.left: parent.left
- anchors.right: parent.right
- // We set it by means of a binding, since then we can use the when condition, which we need to
- // prevent a binding loop.
- Binding
- {
- target: parent
- property: "height"
- value: parent.childrenRect.height
- when: parent.visibleChildren.length > 0
- }
- // Add the qualities that belong to the intent
- Repeater
- {
- visible: false
- model: subItemModel
- MenuButton
- {
- id: button
- onClicked: Cura.IntentManager.selectIntent(model.intent_category, model.quality_type)
- width: parent.width
- checkable: true
- visible: model.available
- text: model.name + " - " + model.layer_height + " mm"
- checked:
- {
- if (Cura.MachineManager.hasCustomQuality)
- {
- // When user created profile is active, no quality tickbox should be active.
- return false;
- }
- return Cura.MachineManager.activeQualityType == model.quality_type && Cura.MachineManager.activeIntentCategory == model.intent_category;
- }
- ButtonGroup.group: buttonGroup
- }
- }
- }
- }
- }
- //Another "intent category" for custom profiles.
- Item
- {
- height: childrenRect.height
- anchors
- {
- left: parent.left
- right: parent.right
- }
- Label
- {
- id: customProfileHeader
- text: catalog.i18nc("@label:header", "Custom profiles")
- renderType: Text.NativeRendering
- height: visible ? contentHeight: 0
- enabled: false
- visible: profilesList.visibleChildren.length > 1
- anchors.left: parent.left
- anchors.leftMargin: UM.Theme.getSize("default_margin").width
- color: UM.Theme.getColor("text_inactive")
- }
- Column
- {
- id: profilesList
- anchors
- {
- top: customProfileHeader.bottom
- left: parent.left
- right: parent.right
- }
- //We set it by means of a binding, since then we can use the
- //"when" condition, which we need to prevent a binding loop.
- Binding
- {
- target: parent
- property: "height"
- value: parent.childrenRect.height
- when: parent.visibleChildren.length > 1
- }
- //Add all the custom profiles.
- Repeater
- {
- model: Cura.CustomQualityProfilesDropDownMenuModel
- MenuButton
- {
- onClicked: Cura.MachineManager.setQualityChangesGroup(model.quality_changes_group)
- width: parent.width
- checkable: true
- visible: model.available
- text: model.name
- checked:
- {
- var active_quality_group = Cura.MachineManager.activeQualityChangesGroup
- if (active_quality_group != null)
- {
- return active_quality_group.name == model.quality_changes_group.name
- }
- return false
- }
- ButtonGroup.group: buttonGroup
- }
- }
- }
- }
- }
- }
- Rectangle
- {
- height: UM.Theme.getSize("default_lining").height
- anchors.left: parent.left
- anchors.right: parent.right
- color: borderColor
- }
- MenuButton
- {
- labelText: Cura.Actions.addProfile.text
- anchors.left: parent.left
- anchors.right: parent.right
- enabled: Cura.Actions.addProfile.enabled
- onClicked:
- {
- Cura.Actions.addProfile.trigger()
- popup.visible = false
- }
- }
- MenuButton
- {
- labelText: Cura.Actions.updateProfile.text
- anchors.left: parent.left
- anchors.right: parent.right
- enabled: Cura.Actions.updateProfile.enabled
- onClicked:
- {
- popup.visible = false
- Cura.Actions.updateProfile.trigger()
- }
- }
- MenuButton
- {
- text: catalog.i18nc("@action:button", "Discard current changes")
- anchors.left: parent.left
- anchors.right: parent.right
- enabled: Cura.MachineManager.hasUserSettings
- onClicked:
- {
- popup.visible = false
- Cura.ContainerManager.clearUserContainers()
- }
- }
- Rectangle
- {
- height: UM.Theme.getSize("default_lining").width
- anchors.left: parent.left
- anchors.right: parent.right
- color: borderColor
- }
- MenuButton
- {
- id: manageProfilesButton
- text: Cura.Actions.manageProfiles.text
- anchors
- {
- left: parent.left
- right: parent.right
- }
- height: textLabel.contentHeight + 2 * UM.Theme.getSize("narrow_margin").height
- contentItem: Item
- {
- width: parent.width
- height: childrenRect.height
- Label
- {
- id: textLabel
- text: manageProfilesButton.text
- height: contentHeight
- anchors.left: parent.left
- anchors.leftMargin: UM.Theme.getSize("default_margin").width + UM.Theme.getSize("narrow_margin").width
- verticalAlignment: Text.AlignVCenter
- renderType: Text.NativeRendering
- font: UM.Theme.getFont("default")
- color: UM.Theme.getColor("text")
- }
- Label
- {
- id: shortcutLabel
- text: Cura.Actions.manageProfiles.shortcut
- height: contentHeight
- anchors.right: parent.right
- anchors.rightMargin: UM.Theme.getSize("default_margin").width
- verticalAlignment: Text.AlignVCenter
- renderType: Text.NativeRendering
- font: UM.Theme.getFont("default")
- color: UM.Theme.getColor("text")
- }
- }
- onClicked:
- {
- popup.visible = false
- Cura.Actions.manageProfiles.trigger()
- }
- }
- // spacer
- Item
- {
- width: 2
- height: UM.Theme.getSize("default_radius").width
- }
- }
- }
|