mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:07:35 +00:00
HackStudio: Propagate errors using try_set_main_widget
The documentation tooltip and parameters hint tooltip initialization functions are now fallible and now call try_set_main_widget instead of set_main_widget. They are only called by Editor's new custom try_create function.
This commit is contained in:
parent
4c0b8a70e2
commit
d4484f4de3
3 changed files with 21 additions and 10 deletions
|
@ -40,11 +40,17 @@
|
|||
|
||||
namespace HackStudio {
|
||||
|
||||
ErrorOr<NonnullRefPtr<Editor>> Editor::try_create()
|
||||
{
|
||||
NonnullRefPtr<Editor> editor = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) Editor()));
|
||||
TRY(editor->initialize_documentation_tooltip());
|
||||
TRY(editor->initialize_parameters_hint_tooltip());
|
||||
return editor;
|
||||
}
|
||||
|
||||
Editor::Editor()
|
||||
{
|
||||
set_document(CodeDocument::create());
|
||||
initialize_documentation_tooltip();
|
||||
initialize_parameters_hint_tooltip();
|
||||
m_evaluate_expression_action = GUI::Action::create("Evaluate expression", { Mod_Ctrl, Key_E }, [this](auto&) {
|
||||
VERIFY(is_program_running());
|
||||
auto dialog = EvaluateExpressionDialog::construct(window());
|
||||
|
@ -72,20 +78,22 @@ Editor::~Editor()
|
|||
{
|
||||
}
|
||||
|
||||
void Editor::initialize_documentation_tooltip()
|
||||
ErrorOr<void> Editor::initialize_documentation_tooltip()
|
||||
{
|
||||
m_documentation_tooltip_window = GUI::Window::construct();
|
||||
m_documentation_tooltip_window->set_rect(0, 0, 500, 400);
|
||||
m_documentation_tooltip_window->set_window_type(GUI::WindowType::Tooltip);
|
||||
m_documentation_page_view = m_documentation_tooltip_window->set_main_widget<Web::OutOfProcessWebView>();
|
||||
m_documentation_page_view = TRY(m_documentation_tooltip_window->try_set_main_widget<Web::OutOfProcessWebView>());
|
||||
return {};
|
||||
}
|
||||
|
||||
void Editor::initialize_parameters_hint_tooltip()
|
||||
ErrorOr<void> Editor::initialize_parameters_hint_tooltip()
|
||||
{
|
||||
m_parameters_hint_tooltip_window = GUI::Window::construct();
|
||||
m_parameters_hint_tooltip_window->set_rect(0, 0, 280, 35);
|
||||
m_parameters_hint_tooltip_window->set_window_type(GUI::WindowType::Tooltip);
|
||||
m_parameter_hint_page_view = m_parameters_hint_tooltip_window->set_main_widget<Web::OutOfProcessWebView>();
|
||||
m_parameter_hint_page_view = TRY(m_parameters_hint_tooltip_window->try_set_main_widget<Web::OutOfProcessWebView>());
|
||||
return {};
|
||||
}
|
||||
|
||||
EditorWrapper& Editor::wrapper()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue