mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:47:35 +00:00
PixelPaint: Make tool properties widget construction non-fallible
`Tool::get_properties_widget()` now also returns a NNRP to a widget rather than a raw pointer.
This commit is contained in:
parent
5df88dab07
commit
f34b1c7a7e
41 changed files with 72 additions and 85 deletions
|
@ -22,7 +22,6 @@ ToolPropertiesWidget::ToolPropertiesWidget()
|
|||
m_group_box = add<GUI::GroupBox>("Tool properties"sv);
|
||||
m_group_box->set_layout<GUI::VerticalBoxLayout>(8);
|
||||
m_tool_widget_stack = m_group_box->add<GUI::StackWidget>();
|
||||
m_blank_widget = m_tool_widget_stack->add<GUI::Widget>();
|
||||
m_error_label = m_tool_widget_stack->add<GUI::Label>();
|
||||
m_error_label->set_enabled(false);
|
||||
}
|
||||
|
@ -33,18 +32,7 @@ void ToolPropertiesWidget::set_active_tool(Tool* tool)
|
|||
return;
|
||||
|
||||
m_active_tool = tool;
|
||||
auto active_tool_widget_or_error = tool->get_properties_widget();
|
||||
if (active_tool_widget_or_error.is_error()) {
|
||||
m_active_tool_widget = nullptr;
|
||||
m_error_label->set_text(String::formatted("Error creating tool properties: {}", active_tool_widget_or_error.release_error()).release_value_but_fixme_should_propagate_errors());
|
||||
m_tool_widget_stack->set_active_widget(m_error_label);
|
||||
return;
|
||||
}
|
||||
m_active_tool_widget = active_tool_widget_or_error.release_value();
|
||||
if (m_active_tool_widget == nullptr) {
|
||||
m_tool_widget_stack->set_active_widget(m_blank_widget);
|
||||
return;
|
||||
}
|
||||
m_active_tool_widget = tool->get_properties_widget();
|
||||
|
||||
if (!m_tool_widget_stack->is_ancestor_of(*m_active_tool_widget))
|
||||
m_tool_widget_stack->add_child(*m_active_tool_widget);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue