mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 02:37:42 +00:00
PixelPaint: Propagate errors from making tool property widgets
This commit is contained in:
parent
b409a40377
commit
be717edd33
41 changed files with 499 additions and 468 deletions
|
@ -9,6 +9,7 @@
|
|||
#include "Tools/Tool.h"
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/GroupBox.h>
|
||||
#include <LibGUI/Label.h>
|
||||
|
||||
REGISTER_WIDGET(PixelPaint, ToolPropertiesWidget);
|
||||
|
||||
|
@ -23,6 +24,8 @@ ToolPropertiesWidget::ToolPropertiesWidget()
|
|||
layout.set_margins({ 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);
|
||||
}
|
||||
|
||||
void ToolPropertiesWidget::set_active_tool(Tool* tool)
|
||||
|
@ -31,8 +34,14 @@ void ToolPropertiesWidget::set_active_tool(Tool* tool)
|
|||
return;
|
||||
|
||||
m_active_tool = tool;
|
||||
m_active_tool_widget = tool->get_properties_widget();
|
||||
|
||||
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(DeprecatedString::formatted("Error creating tool properties: {}", active_tool_widget_or_error.release_error()));
|
||||
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue