diff --git a/Userland/Applications/Help/CMakeLists.txt b/Userland/Applications/Help/CMakeLists.txt index ebc8057cc5..7b958012c4 100644 --- a/Userland/Applications/Help/CMakeLists.txt +++ b/Userland/Applications/Help/CMakeLists.txt @@ -5,17 +5,14 @@ serenity_component( DEPENDS WebContent ) -stringify_gml(HelpWindow.gml HelpWindowGML.h help_window_gml) +compile_gml(HelpWindow.gml HelpWindowGML.cpp) set(SOURCES History.cpp main.cpp MainWidget.cpp ManualModel.cpp -) - -set(GENERATED_SOURCES - HelpWindowGML.h + HelpWindowGML.cpp ) serenity_app(Help ICON app-help) diff --git a/Userland/Applications/Help/HelpWindow.gml b/Userland/Applications/Help/HelpWindow.gml index 24067b5fda..cb1c54a638 100644 --- a/Userland/Applications/Help/HelpWindow.gml +++ b/Userland/Applications/Help/HelpWindow.gml @@ -1,4 +1,4 @@ -@GUI::Widget { +@Help::MainWidget { fill_with_background_color: true layout: @GUI::VerticalBoxLayout { spacing: 2 diff --git a/Userland/Applications/Help/MainWidget.cpp b/Userland/Applications/Help/MainWidget.cpp index 653d20cb18..d4a2443314 100644 --- a/Userland/Applications/Help/MainWidget.cpp +++ b/Userland/Applications/Help/MainWidget.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -41,7 +40,29 @@ namespace Help { MainWidget::MainWidget() { - load_from_gml(help_window_gml).release_value_but_fixme_should_propagate_errors(); +} + +ErrorOr MainWidget::set_start_page(Vector query_parameters) +{ + auto result = Manual::Node::try_create_from_query(query_parameters); + if (result.is_error()) { + // No match, so treat the input as a search query + m_tab_widget->set_active_widget(m_search_container); + m_search_box->set_focus(true); + m_search_box->set_text(query_parameters.first_matching([](auto&) { return true; }).value_or(""sv)); + m_search_box->select_all(); + m_filter_model->set_filter_term(m_search_box->text()); + m_go_home_action->activate(); + } else { + auto const page = TRY(result.value()->path()); + m_history.push(page); + open_page(page); + } + return {}; +} + +ErrorOr MainWidget::initialize_fallibles(GUI::Window& window) +{ m_toolbar = find_descendant_of_type_named("toolbar"); m_tab_widget = find_descendant_of_type_named("tab_widget"); m_search_container = find_descendant_of_type_named("search_container"); @@ -172,29 +193,7 @@ MainWidget::MainWidget() GUI::Application::the()->on_action_leave = [this](GUI::Action const&) { m_statusbar->set_override_text({}); }; -} -ErrorOr MainWidget::set_start_page(Vector query_parameters) -{ - auto result = Manual::Node::try_create_from_query(query_parameters); - if (result.is_error()) { - // No match, so treat the input as a search query - m_tab_widget->set_active_widget(m_search_container); - m_search_box->set_focus(true); - m_search_box->set_text(query_parameters.first_matching([](auto&) { return true; }).value_or(""sv)); - m_search_box->select_all(); - m_filter_model->set_filter_term(m_search_box->text()); - m_go_home_action->activate(); - } else { - auto const page = TRY(result.value()->path()); - m_history.push(page); - open_page(page); - } - return {}; -} - -ErrorOr MainWidget::initialize_fallibles(GUI::Window& window) -{ static String const help_index_path = TRY(TRY(Manual::PageNode::help_index_page())->path()); m_go_home_action = GUI::CommonActions::make_go_home_action([this](auto&) { m_history.push(help_index_path); diff --git a/Userland/Applications/Help/MainWidget.h b/Userland/Applications/Help/MainWidget.h index 4b30e64193..f004a2d494 100644 --- a/Userland/Applications/Help/MainWidget.h +++ b/Userland/Applications/Help/MainWidget.h @@ -19,6 +19,8 @@ class MainWidget final : public GUI::Widget { public: virtual ~MainWidget() override = default; + static ErrorOr> try_create(); + ErrorOr initialize_fallibles(GUI::Window&); ErrorOr set_start_page(Vector query_parameters);