Add proper tooltips for Material properties #24434 (#25509)

This commit is contained in:
timpieces
2025-12-11 22:56:26 +08:00
committed by GitHub
parent 7a8135d863
commit de2f8a58a3
5 changed files with 139 additions and 6 deletions

View File

@@ -46,6 +46,9 @@
<property name="text">
<string>Diffuse color</string>
</property>
<property name="toolTip">
<string>Defines the base color of a surface when illuminated by light. It represents how the object scatters light evenly in all directions, independent of the viewers angle. This property will influence the material color the most.</string>
</property>
</widget>
</item>
<item row="4" column="0">
@@ -53,6 +56,9 @@
<property name="text">
<string>Shininess</string>
</property>
<property name="toolTip">
<string>Defines the size and sharpness of specular highlights on a surface. Higher values produce small, sharp highlights, while lower values create broad, soft highlights. Note that the highlight intensity is defined by specular color.</string>
</property>
</widget>
</item>
<item row="0" column="1">
@@ -70,6 +76,9 @@
<property name="text">
<string>Reset</string>
</property>
<property name="toolTip">
<string>Reverts changes done in the dialogue.</string>
</property>
</widget>
</item>
<item row="0" column="0">
@@ -77,6 +86,9 @@
<property name="text">
<string>Ambient color</string>
</property>
<property name="toolTip">
<string>Defines the color of a surface under indirect, uniform lighting, representing how it appears when illuminated only by ambient light in a scene, without directional light, shading, or highlights</string>
</property>
</widget>
</item>
<item row="4" column="1">
@@ -113,6 +125,9 @@
<property name="text">
<string>Specular color</string>
</property>
<property name="toolTip">
<string>Defines the color and intensity of the bright, mirror-like highlights that appear on shiny or reflective surfaces when light hits them directly. Set to bright colors for shiny objects.</string>
</property>
</widget>
</item>
<item row="3" column="1">
@@ -130,6 +145,9 @@
<property name="text">
<string>Default</string>
</property>
<property name="toolTip">
<string>Changes all values to default values</string>
</property>
</widget>
</item>
<item row="1" column="1">
@@ -147,6 +165,9 @@
<property name="text">
<string>Emissive color</string>
</property>
<property name="toolTip">
<string>Defines the color of a surface that appears to emit as if it were a light source, independent of external lighting, making the object look self-illuminated. Set to black to have no emissive color.</string>
</property>
</widget>
</item>
<item row="5" column="0">
@@ -154,6 +175,9 @@
<property name="text">
<string>Transparency</string>
</property>
<property name="toolTip">
<string>Defines how much light passes through an object, making it partially or fully see-through</string>
</property>
</widget>
</item>
<item row="5" column="1">

View File

@@ -650,6 +650,11 @@ void PropertyItem::setPropertyValue(const std::string& value)
}
}
void PropertyItem::setNameToolTipOverride(const QString& name)
{
nameToolTipOverride = name;
}
void PropertyItem::setPropertyValue(const QString& value)
{
setPropertyValue(value.toStdString());
@@ -676,6 +681,9 @@ QVariant PropertyItem::dataPropertyName(int role) const
}
// no properties set
if (propertyItems.empty()) {
if (role == Qt::ToolTipRole && nameToolTipOverride.size()) {
return nameToolTipOverride;
}
return {};
}
if (role == Qt::ToolTipRole) {
@@ -3557,21 +3565,41 @@ PropertyMaterialItem::PropertyMaterialItem()
diffuse = static_cast<PropertyColorItem*>(PropertyColorItem::create());
diffuse->setParent(this);
diffuse->setPropertyName(QLatin1String("DiffuseColor"));
diffuse->setNameToolTipOverride(
tr("Defines the base color of a surface when illuminated by light. It represents how the "
"object scatters light evenly in all directions, independent of the viewers angle. "
"This property will influence the material color the most.")
);
this->appendChild(diffuse);
ambient = static_cast<PropertyColorItem*>(PropertyColorItem::create());
ambient->setParent(this);
ambient->setPropertyName(QLatin1String("AmbientColor"));
ambient->setNameToolTipOverride(
tr("Defines the color of a surface under indirect, uniform lighting, representing how it "
"appears when illuminated only by ambient light in a scene, without directional light, "
"shading, or highlights")
);
this->appendChild(ambient);
specular = static_cast<PropertyColorItem*>(PropertyColorItem::create());
specular->setParent(this);
specular->setPropertyName(QLatin1String("SpecularColor"));
specular->setNameToolTipOverride(
tr("Defines the color and intensity of the bright, mirror-like highlights that appear on "
"shiny or reflective surfaces when light hits them directly. Set to bright colors for "
"shiny objects.")
);
this->appendChild(specular);
emissive = static_cast<PropertyColorItem*>(PropertyColorItem::create());
emissive->setParent(this);
emissive->setPropertyName(QLatin1String("EmissiveColor"));
emissive->setNameToolTipOverride(
tr("Defines the color of a surface that appears to emit as if it were a light source, "
"independent of external lighting, making the object look self-illuminated. Set to "
"black to have no emissive color.")
);
this->appendChild(emissive);
shininess = static_cast<PropertyIntegerConstraintItem*>(PropertyIntegerConstraintItem::create());
@@ -3579,6 +3607,11 @@ PropertyMaterialItem::PropertyMaterialItem()
shininess->setStepSize(steps);
shininess->setParent(this);
shininess->setPropertyName(QLatin1String("Shininess"));
shininess->setNameToolTipOverride(
tr("Defines the size and sharpness of specular highlights on a surface. Higher values "
"produce small, sharp highlights, while lower values create broad, soft highlights. "
"Note that the highlight intensity is defined by specular color.")
);
this->appendChild(shininess);
transparency = static_cast<PropertyIntegerConstraintItem*>(PropertyIntegerConstraintItem::create());
@@ -3586,6 +3619,10 @@ PropertyMaterialItem::PropertyMaterialItem()
transparency->setStepSize(steps);
transparency->setParent(this);
transparency->setPropertyName(QLatin1String("Transparency"));
transparency->setNameToolTipOverride(
tr("Defines how much light passes through an object, making it "
"partially or fully see-through")
);
this->appendChild(transparency);
}
@@ -3894,21 +3931,41 @@ PropertyMaterialListItem::PropertyMaterialListItem()
diffuse = static_cast<PropertyColorItem*>(PropertyColorItem::create());
diffuse->setParent(this);
diffuse->setPropertyName(QLatin1String("DiffuseColor"));
diffuse->setNameToolTipOverride(
tr("Defines the base color of a surface when illuminated by light. It represents how the "
"object scatters light evenly in all directions, independent of the viewers angle. "
"This property will influence the material color the most.")
);
this->appendChild(diffuse);
ambient = static_cast<PropertyColorItem*>(PropertyColorItem::create());
ambient->setParent(this);
ambient->setPropertyName(QLatin1String("AmbientColor"));
ambient->setNameToolTipOverride(
tr("Defines the color of a surface under indirect, uniform lighting, representing how it "
"appears when illuminated only by ambient light in a scene, without directional light, "
"shading, or highlights")
);
this->appendChild(ambient);
specular = static_cast<PropertyColorItem*>(PropertyColorItem::create());
specular->setParent(this);
specular->setPropertyName(QLatin1String("SpecularColor"));
specular->setNameToolTipOverride(
tr("Defines the color and intensity of the bright, mirror-like highlights that appear on "
"shiny or reflective surfaces when light hits them directly. Set to bright colors for "
"shiny objects.")
);
this->appendChild(specular);
emissive = static_cast<PropertyColorItem*>(PropertyColorItem::create());
emissive->setParent(this);
emissive->setPropertyName(QLatin1String("EmissiveColor"));
emissive->setNameToolTipOverride(
tr("Defines the color of a surface that appears to emit as if it were a light source, "
"independent of external lighting, making the object look self-illuminated. Set to "
"black to have no emissive color.")
);
this->appendChild(emissive);
shininess = static_cast<PropertyIntegerConstraintItem*>(PropertyIntegerConstraintItem::create());
@@ -3916,6 +3973,11 @@ PropertyMaterialListItem::PropertyMaterialListItem()
shininess->setStepSize(steps);
shininess->setParent(this);
shininess->setPropertyName(QLatin1String("Shininess"));
shininess->setNameToolTipOverride(
tr("Defines the size and sharpness of specular highlights on a surface. Higher values "
"produce small, sharp highlights, while lower values create broad, soft highlights. "
"Note that the highlight intensity is defined by specular color.")
);
this->appendChild(shininess);
transparency = static_cast<PropertyIntegerConstraintItem*>(PropertyIntegerConstraintItem::create());
@@ -3923,6 +3985,10 @@ PropertyMaterialListItem::PropertyMaterialListItem()
transparency->setStepSize(steps);
transparency->setParent(this);
transparency->setPropertyName(QLatin1String("Transparency"));
transparency->setNameToolTipOverride(
tr("Defines how much light passes through an object, making it "
"partially or fully see-through")
);
this->appendChild(transparency);
}

View File

@@ -210,6 +210,7 @@ public:
QString propertyName() const;
void setPropertyName(const QString& name, const QString& realName = QString());
void setPropertyValue(const QString&);
void setNameToolTipOverride(const QString& tooltip);
virtual QVariant data(int column, int role) const;
bool setData(const QVariant& value);
Qt::ItemFlags flags(int column) const;
@@ -252,6 +253,7 @@ protected:
int precision;
bool linked;
bool expanded;
QString nameToolTipOverride;
friend class PropertyItemAttorney;
};

View File

@@ -200,6 +200,10 @@ QWidget* DlgInspectAppearance::makeAppearanceTab(const App::Material& material)
int row = 0;
auto* labelDiffuse = new QLabel();
labelDiffuse->setText(tr("Diffuse color"));
labelDiffuse->setToolTip(
tr("Defines the base color of a surface when illuminated by light. It represents how the "
"object scatters light evenly in all directions, independent of the viewers angle. "
"This property will influence the material color the most."));
auto* colorDiffuse = new ColorWidget(material.diffuseColor);
colorDiffuse->setMaximumHeight(23);
@@ -209,6 +213,10 @@ QWidget* DlgInspectAppearance::makeAppearanceTab(const App::Material& material)
auto* labelAmbient = new QLabel();
labelAmbient->setText(tr("Ambient color"));
labelAmbient->setToolTip(
tr("Defines the color of a surface under indirect, uniform lighting, representing how it "
"appears when illuminated only by ambient light in a scene, without directional light, "
"shading, or highlights"));
auto* colorAmbient = new ColorWidget(material.ambientColor);
colorAmbient->setMaximumHeight(23);
@@ -218,6 +226,10 @@ QWidget* DlgInspectAppearance::makeAppearanceTab(const App::Material& material)
auto* labelEmissive = new QLabel();
labelEmissive->setText(tr("Emissive color"));
labelEmissive->setToolTip(
tr("Defines the color of a surface that appears to emit as if it were a light source, "
"independent of external lighting, making the object look self-illuminated. Set to "
"black to have no emissive color."));
auto* colorEmissive = new ColorWidget(material.emissiveColor);
colorEmissive->setMaximumHeight(23);
@@ -227,6 +239,10 @@ QWidget* DlgInspectAppearance::makeAppearanceTab(const App::Material& material)
auto* labelSpecular = new QLabel();
labelSpecular->setText(tr("Specular color"));
labelSpecular->setToolTip(
tr("Defines the color and intensity of the bright, mirror-like highlights that appear on "
"shiny or reflective surfaces when light hits them directly. Set to bright colors for "
"shiny objects."));
auto* colorSpecular = new ColorWidget(material.specularColor);
colorSpecular->setMaximumHeight(23);
@@ -236,6 +252,10 @@ QWidget* DlgInspectAppearance::makeAppearanceTab(const App::Material& material)
auto* labelShininess = new QLabel();
labelShininess->setText(tr("Shininess"));
labelShininess->setToolTip(
tr("Defines the size and sharpness of specular highlights on a surface. Higher values "
"produce small, sharp highlights, while lower values create broad, soft highlights. "
"Note that the highlight intensity is defined by specular color."));
auto* editShininess = new QLineEdit();
editShininess->setText(QString::number(material.shininess));
editShininess->setEnabled(false);
@@ -246,6 +266,8 @@ QWidget* DlgInspectAppearance::makeAppearanceTab(const App::Material& material)
auto* labelTransparency = new QLabel();
labelTransparency->setText(tr("Transparency"));
labelTransparency->setToolTip(tr("Defines how much light passes through an object, making it "
"partially or fully see-through"));
auto* editTransparency = new QLineEdit();
editTransparency->setText(QString::number(material.transparency));
editTransparency->setEnabled(false);

View File

@@ -34,32 +34,51 @@ AppearanceModel:
Type: 'Color'
Units: ''
URL: ''
Description: " "
Description: >
Defines the color of a surface under indirect, uniform lighting,
representing how it appears when illuminated only by ambient light in a
scene, without directional light, shading, or highlights
DiffuseColor:
DisplayName: "Diffuse Color"
Type: 'Color'
Units: ''
URL: ''
Description: " "
Description: >
Defines the base color of a surface when illuminated by light. It
represents how the object scatters light evenly in all directions,
independent of the viewers angle. This property will influence the
material color the most.
EmissiveColor:
DisplayName: "Emissive Color"
Type: 'Color'
Units: ''
URL: ''
Description: " "
Description: >
Defines the color of a surface that appears to emit as if it were a light
source, independent of external lighting, making the object look
self-illuminated. Set to black to have no emissive color.
Shininess:
Type: 'Float'
Units: ''
URL: ''
Description: " "
Description: >
Defines the size and sharpness of specular highlights on a surface.
Higher values produce small, sharp highlights, while lower values create
broad, soft highlights. Note that the highlight intensity is defined by
specular color."
SpecularColor:
DisplayName: "Specular Color"
Type: 'Color'
Units: ''
URL: ''
Description: " "
Description: >
Defines the color and intensity of the bright, mirror-like highlights
that appear on shiny or reflective surfaces when light hits them
directly. Set to bright colors for shiny objects.
Transparency:
Type: 'Float'
Units: ''
URL: ''
Description: " "
Description: >
Defines how much light passes through an object, making it partially or
fully see-through