Now displaying a help icon and value units

CURA-11561
This commit is contained in:
Erwan MATHIEU 2024-02-01 10:34:19 +01:00
parent fcf1e63160
commit 38b67f8015
4 changed files with 29 additions and 31 deletions

View File

@ -5,7 +5,7 @@ import QtQuick 2.10
import QtQuick.Controls 2.3
import UM 1.5 as UM
import UM 1.8 as UM
Item
@ -80,34 +80,13 @@ Item
sourceComponent: combobox
}
MouseArea
UM.HelpIcon
{
id: helpIconMouseArea
anchors.right: parent.right
anchors.verticalCenter: comboboxLabel.verticalCenter
width: childrenRect.width
height: childrenRect.height
hoverEnabled: true
UM.ColorImage
{
width: UM.Theme.getSize("section_icon").width
height: width
visible: comboboxTooltipText != ""
source: UM.Theme.getIcon("Help")
color: UM.Theme.getColor("text")
UM.ToolTip
{
text: comboboxTooltipText
visible: helpIconMouseArea.containsMouse
targetPoint: Qt.point(parent.x + Math.round(parent.width / 2), parent.y)
x: 0
y: parent.y + parent.height + UM.Theme.getSize("default_margin").height
width: UM.Theme.getSize("tooltip").width
}
}
text: comboboxTooltipText
visible: comboboxTooltipText != ""
}
}

View File

@ -6,12 +6,13 @@ from PyQt6.QtCore import QObject, pyqtProperty, pyqtSignal
class SettingExport(QObject):
def __init__(self, id, name, value):
def __init__(self, id, name, value, selectable):
super().__init__()
self.id = id
self._name = name
self._value = value
self._selected = True
self._selected = selectable
self._selectable = selectable
@pyqtProperty(str, constant=True)
def name(self):
@ -31,3 +32,7 @@ class SettingExport(QObject):
@pyqtProperty(bool, fset = setSelected, notify = selectedChanged)
def selected(self):
return self._selected
@pyqtProperty(bool, constant=True)
def selectable(self):
return self._selectable

View File

@ -6,7 +6,7 @@ import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3
import QtQuick.Window 2.2
import UM 1.5 as UM
import UM 1.8 as UM
import Cura 1.1 as Cura
RowLayout
@ -19,10 +19,20 @@ RowLayout
Layout.preferredWidth: UM.Theme.getSize("setting").width
checked: modelData.selected
onClicked: modelData.selected = checked
enabled: modelData.selectable
}
UM.Label
{
text: modelData.value
}
UM.HelpIcon
{
UM.I18nCatalog { id: catalog; name: "cura" }
text: catalog.i18nc("@tooltip",
"This setting can't be exported because it depends too much on the used printer capacities")
visible: !modelData.selectable
}
}

View File

@ -110,17 +110,21 @@ class SettingsExportModel(QObject):
settings_export = []
for setting_to_export in user_keys.intersection(SettingsExportModel.EXPORTABLE_SETTINGS):
for setting_to_export in user_keys:
label = settings_stack.getProperty(setting_to_export, "label")
value = settings_stack.getProperty(setting_to_export, "value")
unit = settings_stack.getProperty(setting_to_export, "unit")
setting_type = settings_stack.getProperty(setting_to_export, "type")
if setting_type is not None:
# This is not very good looking, but will do for now
value = SettingDefinition.settingValueToString(setting_type, value)
value = SettingDefinition.settingValueToString(setting_type, value) + " " + unit
else:
value = str(value)
settings_export.append(SettingExport(setting_to_export, label, value))
settings_export.append(SettingExport(setting_to_export,
label,
value,
setting_to_export in SettingsExportModel.EXPORTABLE_SETTINGS))
return settings_export