Fix layout of General preference page

This commit is contained in:
fieldOfView 2015-12-29 18:16:42 +01:00
parent 282a0d307d
commit fba47cac0c
2 changed files with 74 additions and 133 deletions

View File

@ -11,7 +11,7 @@ import UM 1.1 as UM
UM.PreferencesPage UM.PreferencesPage
{ {
//: General configuration page title //: General configuration page title
title: catalog.i18nc("@title:tab","General"); title: catalog.i18nc("@title:tab","General")
function setDefaultLanguage(languageCode) function setDefaultLanguage(languageCode)
{ {
@ -38,74 +38,72 @@ UM.PreferencesPage
setDefaultLanguage(defaultLanguage) setDefaultLanguage(defaultLanguage)
} }
GridLayout ColumnLayout
{ {
columns: 2;
//: Language selection label //: Language selection label
UM.I18nCatalog{id: catalog; name:"cura"} UM.I18nCatalog{id: catalog; name:"cura"}
Label
{
id: languageLabel
text: catalog.i18nc("@label","Language")
}
ComboBox RowLayout
{ {
id: languageComboBox Label
model: ListModel
{ {
id: languageList id: languageLabel
text: catalog.i18nc("@label","Language:")
Component.onCompleted: {
// append({ text: catalog.i18nc("@item:inlistbox", "Bulgarian"), code: "bg" })
// append({ text: catalog.i18nc("@item:inlistbox", "Czech"), code: "cs" })
append({ text: catalog.i18nc("@item:inlistbox", "English"), code: "en" })
append({ text: catalog.i18nc("@item:inlistbox", "Finnish"), code: "fi" })
append({ text: catalog.i18nc("@item:inlistbox", "French"), code: "fr" })
append({ text: catalog.i18nc("@item:inlistbox", "German"), code: "de" })
// append({ text: catalog.i18nc("@item:inlistbox", "Italian"), code: "it" })
append({ text: catalog.i18nc("@item:inlistbox", "Polish"), code: "pl" })
// append({ text: catalog.i18nc("@item:inlistbox", "Russian"), code: "ru" })
// append({ text: catalog.i18nc("@item:inlistbox", "Spanish"), code: "es" })
}
} }
currentIndex: ComboBox
{ {
var code = UM.Preferences.getValue("general/language"); id: languageComboBox
for(var i = 0; i < languageList.count; ++i) model: ListModel
{ {
if(model.get(i).code == code) id: languageList
{
return i Component.onCompleted: {
// append({ text: catalog.i18nc("@item:inlistbox", "Bulgarian"), code: "bg" })
// append({ text: catalog.i18nc("@item:inlistbox", "Czech"), code: "cs" })
append({ text: catalog.i18nc("@item:inlistbox", "English"), code: "en" })
append({ text: catalog.i18nc("@item:inlistbox", "Finnish"), code: "fi" })
append({ text: catalog.i18nc("@item:inlistbox", "French"), code: "fr" })
append({ text: catalog.i18nc("@item:inlistbox", "German"), code: "de" })
// append({ text: catalog.i18nc("@item:inlistbox", "Italian"), code: "it" })
append({ text: catalog.i18nc("@item:inlistbox", "Polish"), code: "pl" })
// append({ text: catalog.i18nc("@item:inlistbox", "Russian"), code: "ru" })
// append({ text: catalog.i18nc("@item:inlistbox", "Spanish"), code: "es" })
} }
} }
}
onActivated: UM.Preferences.setValue("general/language", model.get(index).code)
anchors.left: languageLabel.right currentIndex:
anchors.top: languageLabel.top
anchors.leftMargin: 20
Component.onCompleted:
{
// Because ListModel is stupid and does not allow using qsTr() for values.
for(var i = 0; i < languageList.count; ++i)
{ {
languageList.setProperty(i, "text", catalog.i18n(languageList.get(i).text)); var code = UM.Preferences.getValue("general/language");
for(var i = 0; i < languageList.count; ++i)
{
if(model.get(i).code == code)
{
return i
}
}
} }
onActivated: UM.Preferences.setValue("general/language", model.get(index).code)
// Glorious hack time. ComboBox does not update the text properly after changing the Component.onCompleted:
// model. So change the indices around to force it to update. {
currentIndex += 1; // Because ListModel is stupid and does not allow using qsTr() for values.
currentIndex -= 1; for(var i = 0; i < languageList.count; ++i)
{
languageList.setProperty(i, "text", catalog.i18n(languageList.get(i).text));
}
// Glorious hack time. ComboBox does not update the text properly after changing the
// model. So change the indices around to force it to update.
currentIndex += 1;
currentIndex -= 1;
}
} }
} }
Label Label
{ {
id: languageCaption; id: languageCaption
Layout.columnSpan: 2
//: Language change warning //: Language change warning
text: catalog.i18nc("@label", "You will need to restart the application for language changes to have effect.") text: catalog.i18nc("@label", "You will need to restart the application for language changes to have effect.")
@ -113,103 +111,46 @@ UM.PreferencesPage
font.italic: true font.italic: true
} }
CheckBox UM.TooltipArea {
{ width: childrenRect.width
id: pushFreeCheckbox height: childrenRect.height
checked: boolCheck(UM.Preferences.getValue("physics/automatic_push_free")) text: catalog.i18nc("@info:tooltip", "Should objects on the platform be moved so that they no longer intersect.")
onCheckedChanged: UM.Preferences.setValue("physics/automatic_push_free", checked)
}
Button
{
id: pushFreeText //is a button so the user doesn't have te click inconvenientley precise to enable or disable the checkbox
//: Display Overhang preference checkbox CheckBox
text: catalog.i18nc("@option:check", "Ensure objects are kept apart");
onClicked: pushFreeCheckbox.checked = !pushFreeCheckbox.checked
//: Display Overhang preference tooltip
tooltip: catalog.i18nc("@info:tooltip", "Should objects on the platform be moved so that they no longer intersect.")
style: ButtonStyle
{ {
background: Rectangle id: pushFreeCheckbox
{ text: catalog.i18nc("@option:check", "Ensure objects are kept apart")
border.width: 0 checked: boolCheck(UM.Preferences.getValue("physics/automatic_push_free"))
color: "transparent" onCheckedChanged: UM.Preferences.setValue("physics/automatic_push_free", checked)
}
label: Text
{
renderType: Text.NativeRendering
horizontalAlignment: Text.AlignLeft
text: control.text
}
} }
} }
CheckBox UM.TooltipArea {
{ width: childrenRect.width
id: sendDataCheckbox height: childrenRect.height
checked: boolCheck(UM.Preferences.getValue("info/send_slice_info")) text: catalog.i18nc("@info:tooltip","Should opened files be scaled to the build volume if they are too large?")
onCheckedChanged: UM.Preferences.setValue("info/send_slice_info", checked)
}
Button
{
id: sendDataText //is a button so the user doesn't have te click inconvenientley precise to enable or disable the checkbox
//: Display Overhang preference checkbox CheckBox
text: catalog.i18nc("@option:check","Send (Anonymous) Print Information");
onClicked: sendDataCheckbox.checked = !sendDataCheckbox.checked
//: Display Overhang preference tooltip
tooltip: catalog.i18nc("@info:tooltip","Should anonymous data about your print be sent to Ultimaker? Note, no models, IP addresses or other personally identifiable information is sent or stored.")
style: ButtonStyle
{ {
background: Rectangle id: scaleToFitCheckbox
{ text: catalog.i18nc("@option:check","Scale large files")
border.width: 0 checked: boolCheck(UM.Preferences.getValue("mesh/scale_to_fit"))
color: "transparent" onCheckedChanged: UM.Preferences.setValue("mesh/scale_to_fit", checked)
}
label: Text
{
renderType: Text.NativeRendering
horizontalAlignment: Text.AlignLeft
text: control.text
}
} }
} }
CheckBox
{
id: scaleToFitCheckbox
checked: boolCheck(UM.Preferences.getValue("mesh/scale_to_fit"))
onCheckedChanged: UM.Preferences.setValue("mesh/scale_to_fit", checked)
}
Button
{
id: scaleToFitText //is a button so the user doesn't have te click inconvenientley precise to enable or disable the checkbox
//: Display Overhang preference checkbox UM.TooltipArea {
text: catalog.i18nc("@option:check","Scale Too Large Files"); width: childrenRect.width
onClicked: scaleToFitCheckbox.checked = !scaleToFitCheckbox.checked height: childrenRect.height
text: catalog.i18nc("@info:tooltip","Should anonymous data about your print be sent to Ultimaker? Note, no models, IP addresses or other personally identifiable information is sent or stored.")
//: Display Overhang preference tooltip CheckBox
tooltip: catalog.i18nc("@info:tooltip","Should opened files be scaled to the build volume when they are too large?")
style: ButtonStyle
{ {
background: Rectangle id: sendDataCheckbox
{ text: catalog.i18nc("@option:check","Send (anonymous) print information")
border.width: 0 checked: boolCheck(UM.Preferences.getValue("info/send_slice_info"))
color: "transparent" onCheckedChanged: UM.Preferences.setValue("info/send_slice_info", checked)
}
label: Text
{
renderType: Text.NativeRendering
horizontalAlignment: Text.AlignLeft
text: control.text
}
} }
} }
Item { Layout.fillHeight: true; Layout.columnSpan: 2 }
} }
} }

View File

@ -39,7 +39,7 @@ UM.PreferencesPage
checked: boolCheck(UM.Preferences.getValue("view/show_overhang")) checked: boolCheck(UM.Preferences.getValue("view/show_overhang"))
onClicked: UM.Preferences.setValue("view/show_overhang", checked) onClicked: UM.Preferences.setValue("view/show_overhang", checked)
text: catalog.i18nc("@option:check","Display Overhang"); text: catalog.i18nc("@option:check","Display overhang");
} }
} }