Don't show the corresponding element in the general preference panel

if the related plugin is not enabled.
Contributes to CURA-5204
This commit is contained in:
Diego Prado Gesto 2018-04-20 11:56:59 +02:00
parent 4e53f219f0
commit 121d1806be

View File

@ -98,16 +98,26 @@ UM.PreferencesPage
UM.Preferences.resetPreference("cura/choice_on_open_project") UM.Preferences.resetPreference("cura/choice_on_open_project")
setDefaultOpenProjectOption(UM.Preferences.getValue("cura/choice_on_open_project")) setDefaultOpenProjectOption(UM.Preferences.getValue("cura/choice_on_open_project"))
if (plugins.find("id", "SliceInfoPlugin") > -1) { if (pluginExistsAndEnabled("SliceInfoPlugin")) {
UM.Preferences.resetPreference("info/send_slice_info") UM.Preferences.resetPreference("info/send_slice_info")
sendDataCheckbox.checked = boolCheck(UM.Preferences.getValue("info/send_slice_info")) sendDataCheckbox.checked = boolCheck(UM.Preferences.getValue("info/send_slice_info"))
} }
if (plugins.find("id", "UpdateChecker") > -1) { if (pluginExistsAndEnabled("UpdateChecker")) {
UM.Preferences.resetPreference("info/automatic_update_check") UM.Preferences.resetPreference("info/automatic_update_check")
checkUpdatesCheckbox.checked = boolCheck(UM.Preferences.getValue("info/automatic_update_check")) checkUpdatesCheckbox.checked = boolCheck(UM.Preferences.getValue("info/automatic_update_check"))
} }
} }
function pluginExistsAndEnabled(pluginName)
{
var pluginItem = plugins.find("id", pluginName)
if (pluginItem > -1)
{
return plugins.getItem(pluginItem).enabled
}
return false
}
ScrollView ScrollView
{ {
width: parent.width width: parent.width
@ -633,7 +643,7 @@ UM.PreferencesPage
} }
UM.TooltipArea { UM.TooltipArea {
visible: plugins.find("id", "UpdateChecker") > -1 visible: pluginExistsAndEnabled("UpdateChecker")
width: childrenRect.width width: childrenRect.width
height: visible ? childrenRect.height : 0 height: visible ? childrenRect.height : 0
text: catalog.i18nc("@info:tooltip","Should Cura check for updates when the program is started?") text: catalog.i18nc("@info:tooltip","Should Cura check for updates when the program is started?")
@ -642,34 +652,29 @@ UM.PreferencesPage
{ {
id: checkUpdatesCheckbox id: checkUpdatesCheckbox
text: catalog.i18nc("@option:check","Check for updates on start") text: catalog.i18nc("@option:check","Check for updates on start")
checked: boolCheck(UM.Preferences.getValue("info/automatic_update_check")) checked: parent.visible ? boolCheck(UM.Preferences.getValue("info/automatic_update_check")): false
onCheckedChanged: UM.Preferences.setValue("info/automatic_update_check", checked) onCheckedChanged: UM.Preferences.setValue("info/automatic_update_check", checked)
} }
} }
UM.TooltipArea { UM.TooltipArea {
visible: plugins.find("id", "SliceInfoPlugin") > -1 visible: pluginExistsAndEnabled("SliceInfoPlugin")
width: childrenRect.width width: childrenRect.width
height: visible ? childrenRect.height * 2 : 0 height: visible ? childrenRect.height : 0
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.") 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.")
CheckBox CheckBox
{ {
id: sendDataCheckbox id: sendDataCheckbox
text: catalog.i18nc("@option:check","Send (anonymous) print information") text: catalog.i18nc("@option:check","Send (anonymous) print information")
checked: boolCheck(UM.Preferences.getValue("info/send_slice_info")) checked: parent.visible ? boolCheck(UM.Preferences.getValue("info/send_slice_info")) : false
onCheckedChanged: UM.Preferences.setValue("info/send_slice_info", checked) onCheckedChanged: UM.Preferences.setValue("info/send_slice_info", checked)
} }
Button Button
{ {
id: showMoreInfo id: showMoreInfo
anchors anchors.top: sendDataCheckbox.bottom
{
top: sendDataCheckbox.bottom
bottom: parent.bottom
}
text: catalog.i18nc("@action:button", "More information") text: catalog.i18nc("@action:button", "More information")
onClicked: onClicked:
{ {
@ -718,8 +723,6 @@ UM.PreferencesPage
onCheckedChanged: UM.Preferences.setValue("cura/not_arrange_objects_on_load", checked) onCheckedChanged: UM.Preferences.setValue("cura/not_arrange_objects_on_load", checked)
} }
} }
} }
} }
} }