1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 19:27:45 +00:00

HackStudio: File search box stays opened after closing

Fix ##5061 by passing the parent widget down to the locator object
and having the locator object parent it's window to it.
This commit is contained in:
Tim Waterhouse 2021-04-03 20:37:09 -07:00 committed by Andreas Kling
parent 8e4e640717
commit 7648f6aa7b
2 changed files with 11 additions and 8 deletions

View file

@ -128,7 +128,7 @@ LocatorSuggestionModel::Suggestion LocatorSuggestionModel::Suggestion::create_sy
return s; return s;
} }
Locator::Locator() Locator::Locator(Core::Object* parent)
{ {
set_layout<GUI::VerticalBoxLayout>(); set_layout<GUI::VerticalBoxLayout>();
set_fixed_height(20); set_fixed_height(20);
@ -171,7 +171,7 @@ Locator::Locator()
open_suggestion(selected_index); open_suggestion(selected_index);
}; };
m_popup_window = GUI::Window::construct(); m_popup_window = GUI::Window::construct(parent);
// FIXME: This is obviously not a tooltip window, but it's the closest thing to what we want atm. // FIXME: This is obviously not a tooltip window, but it's the closest thing to what we want atm.
m_popup_window->set_window_type(GUI::WindowType::Tooltip); m_popup_window->set_window_type(GUI::WindowType::Tooltip);
m_popup_window->set_rect(0, 0, 500, 200); m_popup_window->set_rect(0, 0, 500, 200);
@ -234,12 +234,15 @@ void Locator::update_suggestions()
} }
dbgln("I have {} suggestion(s):", suggestions.size()); dbgln("I have {} suggestion(s):", suggestions.size());
// Limit the debug logging otherwise this can be very slow for large projects
if (suggestions.size() < 100) {
for (auto& s : suggestions) { for (auto& s : suggestions) {
if (s.is_filename()) if (s.is_filename())
dbgln(" {}", s.as_filename.value()); dbgln(" {}", s.as_filename.value());
if (s.is_symbol_declaration()) if (s.is_symbol_declaration())
dbgln(" {} ({})", s.as_symbol_declaration.value().name, s.as_symbol_declaration.value().position.file); dbgln(" {} ({})", s.as_symbol_declaration.value().name, s.as_symbol_declaration.value().position.file);
} }
}
bool has_suggestions = !suggestions.is_empty(); bool has_suggestions = !suggestions.is_empty();

View file

@ -45,7 +45,7 @@ private:
void update_suggestions(); void update_suggestions();
void open_suggestion(const GUI::ModelIndex&); void open_suggestion(const GUI::ModelIndex&);
Locator(); Locator(Core::Object* parent = nullptr);
RefPtr<GUI::TextBox> m_textbox; RefPtr<GUI::TextBox> m_textbox;
RefPtr<GUI::Window> m_popup_window; RefPtr<GUI::Window> m_popup_window;