mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:57:43 +00:00
GVariant: Try to do color string parsing in GVariant::to_color()
If the underlying variant type is a String, try to parse out a color when to_color() is called. This makes VisualBuilder apply the saved colors when loading forms.
This commit is contained in:
parent
e43b27a3fa
commit
54c77cb714
1 changed files with 6 additions and 8 deletions
|
@ -167,17 +167,15 @@ public:
|
|||
return Color::from_rgba(m_value.as_color);
|
||||
}
|
||||
|
||||
Color to_color() const
|
||||
{
|
||||
if (is_color())
|
||||
return as_color();
|
||||
return Color();
|
||||
}
|
||||
|
||||
Color to_color(Color default_value) const
|
||||
Color to_color(Color default_value = {}) const
|
||||
{
|
||||
if (type() == Type::Color)
|
||||
return as_color();
|
||||
if (type() == Type::String) {
|
||||
auto color = Color::from_string(as_string());
|
||||
if (color.has_value())
|
||||
return color.value();
|
||||
}
|
||||
return default_value;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue