mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05: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
2 changed files with 14 additions and 14 deletions
|
@ -20,39 +20,39 @@ IncrementalSearchBanner::IncrementalSearchBanner(TextEditor& editor)
|
|||
: m_editor(editor)
|
||||
{
|
||||
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 = is_checked
|
||||
? TextDocument::SearchShouldWrap::Yes
|
||||
: 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 = is_checked;
|
||||
m_editor->reset_search_results();
|
||||
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->on_click = [this](auto) {
|
||||
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) {
|
||||
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) {
|
||||
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_editor->reset_search_results();
|
||||
search(TextEditor::SearchDirection::Forward);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
|
||||
@GUI::TextBox {
|
||||
name: "search_textbox"
|
||||
name: "incremental_search_banner_search_textbox"
|
||||
max_width: 250
|
||||
preferred_width: "grow"
|
||||
placeholder: "Find"
|
||||
|
@ -19,7 +19,7 @@
|
|||
}
|
||||
|
||||
@GUI::Button {
|
||||
name: "previous_button"
|
||||
name: "incremental_search_banner_previous_button"
|
||||
icon: "/res/icons/16x16/go-up.png"
|
||||
fixed_width: 18
|
||||
button_style: "Coolbar"
|
||||
|
@ -27,7 +27,7 @@
|
|||
}
|
||||
|
||||
@GUI::Button {
|
||||
name: "next_button"
|
||||
name: "incremental_search_banner_next_button"
|
||||
icon: "/res/icons/16x16/go-down.png"
|
||||
fixed_width: 18
|
||||
button_style: "Coolbar"
|
||||
|
@ -36,7 +36,7 @@
|
|||
}
|
||||
|
||||
@GUI::Label {
|
||||
name: "index_label"
|
||||
name: "incremental_search_banner_index_label"
|
||||
text_alignment: "CenterLeft"
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@
|
|||
}
|
||||
|
||||
@GUI::Button {
|
||||
name: "wrap_search_button"
|
||||
name: "incremental_search_banner_wrap_search_button"
|
||||
fixed_width: 24
|
||||
icon: "/res/icons/16x16/reload.png"
|
||||
tooltip: "Wrap Search"
|
||||
|
@ -60,7 +60,7 @@
|
|||
}
|
||||
|
||||
@GUI::Button {
|
||||
name: "match_case_button"
|
||||
name: "incremental_search_banner_match_case_button"
|
||||
fixed_width: 24
|
||||
icon: "/res/icons/16x16/app-font-editor.png"
|
||||
tooltip: "Match Case"
|
||||
|
@ -73,7 +73,7 @@
|
|||
@GUI::VerticalSeparator {}
|
||||
|
||||
@GUI::Button {
|
||||
name: "close_button"
|
||||
name: "incremental_search_banner_close_button"
|
||||
fixed_size: [15, 16]
|
||||
button_style: "Coolbar"
|
||||
focus_policy: "NoFocus"
|
||||
|
|
Loading…
Add table
Reference in a new issue