mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
LibGUI: Add a prefix to IncrementalSearchBanner
's widgets name
Widget's name are the current way to retrieve them when using GML. Presently, there is no way to differentiate two items that share the same name. `IncrementalSearchBanner` uses common names as "close_button" or "next_button", prepend them with `incremental_search_banner_` avoid collisions. This fixes a bug where the close button of `CrashReporter` was confused with the one of the search banner. However, This solution isn't perfect, down the road, we should probably find a way to warn about equal names and introduce something like namespace to avoid huge prefixes.
This commit is contained in:
parent
f14006637d
commit
741138c585
Notes:
sideshowbarker
2024-07-17 06:24:08 +09:00
Author: https://github.com/LucasChollet Commit: https://github.com/SerenityOS/serenity/commit/741138c585 Pull-request: https://github.com/SerenityOS/serenity/pull/16378 Reviewed-by: https://github.com/AtkinsSJ ✅
|
@ -20,39 +20,39 @@ IncrementalSearchBanner::IncrementalSearchBanner(TextEditor& editor)
|
||||||
: m_editor(editor)
|
: m_editor(editor)
|
||||||
{
|
{
|
||||||
load_from_gml(incremental_search_banner_gml);
|
load_from_gml(incremental_search_banner_gml);
|
||||||
m_index_label = find_descendant_of_type_named<Label>("index_label");
|
m_index_label = find_descendant_of_type_named<Label>("incremental_search_banner_index_label");
|
||||||
|
|
||||||
m_wrap_search_button = find_descendant_of_type_named<Button>("wrap_search_button");
|
m_wrap_search_button = find_descendant_of_type_named<Button>("incremental_search_banner_wrap_search_button");
|
||||||
m_wrap_search_button->on_checked = [this](auto is_checked) {
|
m_wrap_search_button->on_checked = [this](auto is_checked) {
|
||||||
m_wrap_search = is_checked
|
m_wrap_search = is_checked
|
||||||
? TextDocument::SearchShouldWrap::Yes
|
? TextDocument::SearchShouldWrap::Yes
|
||||||
: TextDocument::SearchShouldWrap::No;
|
: TextDocument::SearchShouldWrap::No;
|
||||||
};
|
};
|
||||||
|
|
||||||
m_match_case_button = find_descendant_of_type_named<Button>("match_case_button");
|
m_match_case_button = find_descendant_of_type_named<Button>("incremental_search_banner_match_case_button");
|
||||||
m_match_case_button->on_checked = [this](auto is_checked) {
|
m_match_case_button->on_checked = [this](auto is_checked) {
|
||||||
m_match_case = is_checked;
|
m_match_case = is_checked;
|
||||||
m_editor->reset_search_results();
|
m_editor->reset_search_results();
|
||||||
search(TextEditor::SearchDirection::Forward);
|
search(TextEditor::SearchDirection::Forward);
|
||||||
};
|
};
|
||||||
|
|
||||||
m_close_button = find_descendant_of_type_named<Button>("close_button");
|
m_close_button = find_descendant_of_type_named<Button>("incremental_search_banner_close_button");
|
||||||
m_close_button->set_text("\xE2\x9D\x8C");
|
m_close_button->set_text("\xE2\x9D\x8C");
|
||||||
m_close_button->on_click = [this](auto) {
|
m_close_button->on_click = [this](auto) {
|
||||||
hide();
|
hide();
|
||||||
};
|
};
|
||||||
|
|
||||||
m_next_button = find_descendant_of_type_named<Button>("next_button");
|
m_next_button = find_descendant_of_type_named<Button>("incremental_search_banner_next_button");
|
||||||
m_next_button->on_click = [this](auto) {
|
m_next_button->on_click = [this](auto) {
|
||||||
search(TextEditor::SearchDirection::Forward);
|
search(TextEditor::SearchDirection::Forward);
|
||||||
};
|
};
|
||||||
|
|
||||||
m_previous_button = find_descendant_of_type_named<Button>("previous_button");
|
m_previous_button = find_descendant_of_type_named<Button>("incremental_search_banner_previous_button");
|
||||||
m_previous_button->on_click = [this](auto) {
|
m_previous_button->on_click = [this](auto) {
|
||||||
search(TextEditor::SearchDirection::Backward);
|
search(TextEditor::SearchDirection::Backward);
|
||||||
};
|
};
|
||||||
|
|
||||||
m_search_textbox = find_descendant_of_type_named<TextBox>("search_textbox");
|
m_search_textbox = find_descendant_of_type_named<TextBox>("incremental_search_banner_search_textbox");
|
||||||
m_search_textbox->on_change = [this]() {
|
m_search_textbox->on_change = [this]() {
|
||||||
m_editor->reset_search_results();
|
m_editor->reset_search_results();
|
||||||
search(TextEditor::SearchDirection::Forward);
|
search(TextEditor::SearchDirection::Forward);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::TextBox {
|
@GUI::TextBox {
|
||||||
name: "search_textbox"
|
name: "incremental_search_banner_search_textbox"
|
||||||
max_width: 250
|
max_width: 250
|
||||||
preferred_width: "grow"
|
preferred_width: "grow"
|
||||||
placeholder: "Find"
|
placeholder: "Find"
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Button {
|
@GUI::Button {
|
||||||
name: "previous_button"
|
name: "incremental_search_banner_previous_button"
|
||||||
icon: "/res/icons/16x16/go-up.png"
|
icon: "/res/icons/16x16/go-up.png"
|
||||||
fixed_width: 18
|
fixed_width: 18
|
||||||
button_style: "Coolbar"
|
button_style: "Coolbar"
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Button {
|
@GUI::Button {
|
||||||
name: "next_button"
|
name: "incremental_search_banner_next_button"
|
||||||
icon: "/res/icons/16x16/go-down.png"
|
icon: "/res/icons/16x16/go-down.png"
|
||||||
fixed_width: 18
|
fixed_width: 18
|
||||||
button_style: "Coolbar"
|
button_style: "Coolbar"
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Label {
|
@GUI::Label {
|
||||||
name: "index_label"
|
name: "incremental_search_banner_index_label"
|
||||||
text_alignment: "CenterLeft"
|
text_alignment: "CenterLeft"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Button {
|
@GUI::Button {
|
||||||
name: "wrap_search_button"
|
name: "incremental_search_banner_wrap_search_button"
|
||||||
fixed_width: 24
|
fixed_width: 24
|
||||||
icon: "/res/icons/16x16/reload.png"
|
icon: "/res/icons/16x16/reload.png"
|
||||||
tooltip: "Wrap Search"
|
tooltip: "Wrap Search"
|
||||||
|
@ -60,7 +60,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Button {
|
@GUI::Button {
|
||||||
name: "match_case_button"
|
name: "incremental_search_banner_match_case_button"
|
||||||
fixed_width: 24
|
fixed_width: 24
|
||||||
icon: "/res/icons/16x16/app-font-editor.png"
|
icon: "/res/icons/16x16/app-font-editor.png"
|
||||||
tooltip: "Match Case"
|
tooltip: "Match Case"
|
||||||
|
@ -73,7 +73,7 @@
|
||||||
@GUI::VerticalSeparator {}
|
@GUI::VerticalSeparator {}
|
||||||
|
|
||||||
@GUI::Button {
|
@GUI::Button {
|
||||||
name: "close_button"
|
name: "incremental_search_banner_close_button"
|
||||||
fixed_size: [15, 16]
|
fixed_size: [15, 16]
|
||||||
button_style: "Coolbar"
|
button_style: "Coolbar"
|
||||||
focus_policy: "NoFocus"
|
focus_policy: "NoFocus"
|
||||||
|
|
Loading…
Reference in a new issue