mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:27:45 +00:00
Help: Use new GML code generator
This commit is contained in:
parent
d1645efde9
commit
8ec9b26bba
4 changed files with 28 additions and 30 deletions
|
@ -5,17 +5,14 @@ serenity_component(
|
||||||
DEPENDS WebContent
|
DEPENDS WebContent
|
||||||
)
|
)
|
||||||
|
|
||||||
stringify_gml(HelpWindow.gml HelpWindowGML.h help_window_gml)
|
compile_gml(HelpWindow.gml HelpWindowGML.cpp)
|
||||||
|
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
History.cpp
|
History.cpp
|
||||||
main.cpp
|
main.cpp
|
||||||
MainWidget.cpp
|
MainWidget.cpp
|
||||||
ManualModel.cpp
|
ManualModel.cpp
|
||||||
)
|
HelpWindowGML.cpp
|
||||||
|
|
||||||
set(GENERATED_SOURCES
|
|
||||||
HelpWindowGML.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
serenity_app(Help ICON app-help)
|
serenity_app(Help ICON app-help)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
@GUI::Widget {
|
@Help::MainWidget {
|
||||||
fill_with_background_color: true
|
fill_with_background_color: true
|
||||||
layout: @GUI::VerticalBoxLayout {
|
layout: @GUI::VerticalBoxLayout {
|
||||||
spacing: 2
|
spacing: 2
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <AK/StringView.h>
|
#include <AK/StringView.h>
|
||||||
#include <AK/URL.h>
|
#include <AK/URL.h>
|
||||||
#include <Applications/Help/HelpWindowGML.h>
|
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <LibCore/System.h>
|
#include <LibCore/System.h>
|
||||||
#include <LibDesktop/Launcher.h>
|
#include <LibDesktop/Launcher.h>
|
||||||
|
@ -41,7 +40,29 @@ namespace Help {
|
||||||
|
|
||||||
MainWidget::MainWidget()
|
MainWidget::MainWidget()
|
||||||
{
|
{
|
||||||
load_from_gml(help_window_gml).release_value_but_fixme_should_propagate_errors();
|
}
|
||||||
|
|
||||||
|
ErrorOr<void> MainWidget::set_start_page(Vector<StringView, 2> 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<void> MainWidget::initialize_fallibles(GUI::Window& window)
|
||||||
|
{
|
||||||
m_toolbar = find_descendant_of_type_named<GUI::Toolbar>("toolbar");
|
m_toolbar = find_descendant_of_type_named<GUI::Toolbar>("toolbar");
|
||||||
m_tab_widget = find_descendant_of_type_named<GUI::TabWidget>("tab_widget");
|
m_tab_widget = find_descendant_of_type_named<GUI::TabWidget>("tab_widget");
|
||||||
m_search_container = find_descendant_of_type_named<GUI::Widget>("search_container");
|
m_search_container = find_descendant_of_type_named<GUI::Widget>("search_container");
|
||||||
|
@ -172,29 +193,7 @@ MainWidget::MainWidget()
|
||||||
GUI::Application::the()->on_action_leave = [this](GUI::Action const&) {
|
GUI::Application::the()->on_action_leave = [this](GUI::Action const&) {
|
||||||
m_statusbar->set_override_text({});
|
m_statusbar->set_override_text({});
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
ErrorOr<void> MainWidget::set_start_page(Vector<StringView, 2> 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<void> MainWidget::initialize_fallibles(GUI::Window& window)
|
|
||||||
{
|
|
||||||
static String const help_index_path = TRY(TRY(Manual::PageNode::help_index_page())->path());
|
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_go_home_action = GUI::CommonActions::make_go_home_action([this](auto&) {
|
||||||
m_history.push(help_index_path);
|
m_history.push(help_index_path);
|
||||||
|
|
|
@ -19,6 +19,8 @@ class MainWidget final : public GUI::Widget {
|
||||||
public:
|
public:
|
||||||
virtual ~MainWidget() override = default;
|
virtual ~MainWidget() override = default;
|
||||||
|
|
||||||
|
static ErrorOr<NonnullRefPtr<MainWidget>> try_create();
|
||||||
|
|
||||||
ErrorOr<void> initialize_fallibles(GUI::Window&);
|
ErrorOr<void> initialize_fallibles(GUI::Window&);
|
||||||
ErrorOr<void> set_start_page(Vector<StringView, 2> query_parameters);
|
ErrorOr<void> set_start_page(Vector<StringView, 2> query_parameters);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue