Make the Infill buttons and support checkboxes in Simple mode functional

CURA-182 #done
This commit is contained in:
Arjen Hiemstra 2015-09-29 16:57:38 +02:00
parent d2ed9bc74f
commit ca60ed0aad
2 changed files with 57 additions and 47 deletions

View File

@ -41,7 +41,7 @@ Item
Label{ Label{
id: infillCaption id: infillCaption
width: infillCellLeft.width - UM.Theme.sizes.default_margin.width width: infillCellLeft.width - UM.Theme.sizes.default_margin.width
text: infillModel.get(infillListView.activeIndex).text text: infillModel.count > 0 && infillListView.activeIndex != -1 ? infillModel.get(infillListView.activeIndex).text : ""
font: UM.Theme.fonts.caption font: UM.Theme.fonts.caption
wrapMode: Text.Wrap wrapMode: Text.Wrap
color: UM.Theme.colors.text color: UM.Theme.colors.text
@ -51,65 +51,80 @@ Item
} }
} }
Rectangle{ Flow {
id: infillCellRight id: infillCellRight
height: 100
height: childrenRect.height;
width: base.width / 100 * 45 width: base.width / 100 * 45
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: UM.Theme.sizes.default_margin.width - (UM.Theme.sizes.default_margin.width/4) anchors.rightMargin: UM.Theme.sizes.default_margin.width - (UM.Theme.sizes.default_margin.width/4)
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: UM.Theme.sizes.default_margin.height anchors.topMargin: UM.Theme.sizes.default_margin.height
Component{
id: infillDelegate Repeater {
id: infillListView
property int activeIndex: {
if(!UM.ActiveProfile.valid)
{
return -1;
}
var density = parseInt(UM.ActiveProfile.settingValues.infill_sparse_density);
for(var i = 0; i < infillModel.count; ++i)
{
if(infillModel.get(i).percentage == density)
{
return i;
}
}
return -1;
}
model: infillModel;
Item { Item {
width: infillCellRight.width/3 width: childrenRect.width;
x: index * (infillCellRight.width/3) height: childrenRect.height;
anchors.top: parent.top
Rectangle{ Rectangle{
id: infillIconLining id: infillIconLining
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter width: infillCellRight.width / 3 - UM.Theme.sizes.default_margin.width;
width: parent.width - (UM.Theme.sizes.default_margin.width/2) height: width
height: parent.width - (UM.Theme.sizes.default_margin.width/2)
border.color: infillListView.activeIndex == index ? UM.Theme.colors.setting_control_text : UM.Theme.colors.setting_control_border border.color: infillListView.activeIndex == index ? UM.Theme.colors.setting_control_text : UM.Theme.colors.setting_control_border
border.width: infillListView.activeIndex == index ? 2 : 1 border.width: infillListView.activeIndex == index ? 2 : 1
color: infillListView.activeIndex == index ? UM.Theme.colors.setting_category_active : "transparent" color: infillListView.activeIndex == index ? UM.Theme.colors.setting_category_active : "transparent"
UM.RecolorImage {
Image {
id: infillIcon id: infillIcon
z: parent.z + 1 anchors.fill: parent;
anchors.verticalCenter: parent.verticalCenter anchors.margins: UM.Theme.sizes.default_margin.width / 2
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width - UM.Theme.sizes.default_margin.width
height: parent.width - UM.Theme.sizes.default_margin.width
sourceSize.width: width sourceSize.width: width
sourceSize.height: width sourceSize.height: width
color: UM.Theme.colors.setting_control_text
source: UM.Theme.icons[model.icon]; source: UM.Theme.icons[model.icon];
} }
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
infillListView.activeIndex = index infillListView.activeIndex = index
UM.MachineManager.setSettingValue("infill_sparse_density", model.percentage)
} }
} }
} }
Label{ Label{
id: infillLabel id: infillLabel
anchors.top: infillIconLining.bottom anchors.top: infillIconLining.bottom
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: infillIconLining.horizontalCenter
color: infillListView.activeIndex == index ? UM.Theme.colors.setting_control_text : UM.Theme.colors.setting_control_border color: infillListView.activeIndex == index ? UM.Theme.colors.setting_control_text : UM.Theme.colors.setting_control_border
text: name text: name
//font.bold: infillListView.activeIndex == index ? true : false
} }
} }
} }
ListView{
id: infillListView
property int activeIndex: 0
model: infillModel
delegate: infillDelegate
anchors.fill: parent
}
ListModel { ListModel {
id: infillModel id: infillModel
@ -139,11 +154,12 @@ Item
Rectangle { Rectangle {
id: helpersCellLeft id: helpersCellLeft
anchors.top: infillCellLeft.bottom anchors.top: infillCellRight.bottom
anchors.topMargin: UM.Theme.sizes.default_margin.height anchors.topMargin: UM.Theme.sizes.default_margin.height
anchors.left: parent.left anchors.left: parent.left
width: parent.width/100*45 - UM.Theme.sizes.default_margin.width width: parent.width/100*45 - UM.Theme.sizes.default_margin.width
height: childrenRect.height height: childrenRect.height
Label{ Label{
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: UM.Theme.sizes.default_margin.width anchors.leftMargin: UM.Theme.sizes.default_margin.width
@ -155,7 +171,6 @@ Item
Rectangle { Rectangle {
id: helpersCellRight id: helpersCellRight
anchors.top: helpersCellLeft.top anchors.top: helpersCellLeft.top
anchors.topMargin: UM.Theme.sizes.default_margin.height
anchors.left: helpersCellLeft.right anchors.left: helpersCellLeft.right
width: parent.width/100*55 - UM.Theme.sizes.default_margin.width width: parent.width/100*55 - UM.Theme.sizes.default_margin.width
height: childrenRect.height height: childrenRect.height
@ -164,37 +179,31 @@ Item
id: skirtCheckBox id: skirtCheckBox
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
Layout.preferredHeight: UM.Theme.sizes.section.height;
//: Setting enable skirt adhesion checkbox //: Setting enable skirt adhesion checkbox
text: catalog.i18nc("@option:check","Enable Skirt Adhesion"); text: catalog.i18nc("@option:check","Enable Skirt Adhesion");
style: UM.Theme.styles.checkbox; style: UM.Theme.styles.checkbox;
checked: Printer.getSettingValue("skirt_line_count") == null ? false: Printer.getSettingValue("skirt_line_count");
onCheckedChanged: checked: UM.ActiveProfile.valid ? UM.ActiveProfile.settingValues.adhesion_type == "brim" : false;
onClicked:
{ {
if(checked != Printer.getSettingValue("skirt_line_count")) UM.MachineManager.setSettingValue("adhesion_type", "brim")
{
Printer.setSettingValue("skirt_line_count", checked)
}
} }
} }
CheckBox{ CheckBox{
anchors.top: skirtCheckBox.bottom anchors.top: skirtCheckBox.bottom
anchors.topMargin: UM.Theme.sizes.default_lining.height anchors.topMargin: UM.Theme.sizes.default_lining.height
anchors.left: parent.left anchors.left: parent.left
Layout.preferredHeight: UM.Theme.sizes.section.height;
//: Setting enable support checkbox //: Setting enable support checkbox
text: catalog.i18nc("@option:check","Enable Support"); text: catalog.i18nc("@option:check","Enable Support");
style: UM.Theme.styles.checkbox; style: UM.Theme.styles.checkbox;
checked: Printer.getSettingValue("support_enable") == null? false: Printer.getSettingValue("support_enable"); checked: UM.ActiveProfile.valid ? UM.ActiveProfile.settingValues.support_enable : false;
onCheckedChanged: onClicked:
{ {
if(checked != Printer.getSettingValue("support_enable")) UM.MachineManager.setSettingValue("support_enable", checked)
{
Printer.setSettingValue("support_enable", checked)
}
} }
} }
} }

View File

@ -152,6 +152,7 @@
"sidebar_specs_bar": [0.0, 2.2], "sidebar_specs_bar": [0.0, 2.2],
"sidebar_inputFields": [0.0, 1.9], "sidebar_inputFields": [0.0, 1.9],
"simple_mode_infill_caption": [0.0, 5.0], "simple_mode_infill_caption": [0.0, 5.0],
"simple_mode_infill_height": [0.0, 8.0],
"section": [0.0, 2.0], "section": [0.0, 2.0],
"section_icon": [1.6, 1.6], "section_icon": [1.6, 1.6],