mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:57:34 +00:00
HackStudio: Allow opening a Locator suggestion by double-clicking it
This commit is contained in:
parent
29ac3e1477
commit
990ca1a7a5
2 changed files with 17 additions and 4 deletions
|
@ -106,14 +106,12 @@ Locator::Locator(GWidget* parent)
|
||||||
m_suggestion_view->scroll_into_view(new_index, Orientation::Vertical);
|
m_suggestion_view->scroll_into_view(new_index, Orientation::Vertical);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
m_textbox->on_return_pressed = [this] {
|
m_textbox->on_return_pressed = [this] {
|
||||||
auto selected_index = m_suggestion_view->selection().first();
|
auto selected_index = m_suggestion_view->selection().first();
|
||||||
if (!selected_index.is_valid())
|
if (!selected_index.is_valid())
|
||||||
return;
|
return;
|
||||||
auto filename_index = m_suggestion_view->model()->index(selected_index.row(), LocatorSuggestionModel::Column::Name);
|
open_suggestion(selected_index);
|
||||||
auto filename = m_suggestion_view->model()->data(filename_index, GModel::Role::Display).to_string();
|
|
||||||
open_file(filename);
|
|
||||||
close();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
m_popup_window = GWindow::construct();
|
m_popup_window = GWindow::construct();
|
||||||
|
@ -125,12 +123,25 @@ Locator::Locator(GWidget* parent)
|
||||||
m_suggestion_view->set_size_columns_to_fit_content(true);
|
m_suggestion_view->set_size_columns_to_fit_content(true);
|
||||||
m_suggestion_view->set_headers_visible(false);
|
m_suggestion_view->set_headers_visible(false);
|
||||||
m_popup_window->set_main_widget(m_suggestion_view);
|
m_popup_window->set_main_widget(m_suggestion_view);
|
||||||
|
|
||||||
|
|
||||||
|
m_suggestion_view->on_activation = [this](auto& index) {
|
||||||
|
open_suggestion(index);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Locator::~Locator()
|
Locator::~Locator()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Locator::open_suggestion(const GModelIndex& index)
|
||||||
|
{
|
||||||
|
auto filename_index = m_suggestion_view->model()->index(index.row(), LocatorSuggestionModel::Column::Name);
|
||||||
|
auto filename = m_suggestion_view->model()->data(filename_index, GModel::Role::Display).to_string();
|
||||||
|
open_file(filename);
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
void Locator::open()
|
void Locator::open()
|
||||||
{
|
{
|
||||||
m_textbox->set_focus(true);
|
m_textbox->set_focus(true);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <LibGUI/GWidget.h>
|
#include <LibGUI/GWidget.h>
|
||||||
|
|
||||||
class LocatorTextBox;
|
class LocatorTextBox;
|
||||||
|
class GModelIndex;
|
||||||
class GTableView;
|
class GTableView;
|
||||||
|
|
||||||
class Locator final : public GWidget {
|
class Locator final : public GWidget {
|
||||||
|
@ -17,6 +18,7 @@ private:
|
||||||
virtual void keydown_event(GKeyEvent&) override;
|
virtual void keydown_event(GKeyEvent&) override;
|
||||||
|
|
||||||
void update_suggestions();
|
void update_suggestions();
|
||||||
|
void open_suggestion(const GModelIndex&);
|
||||||
|
|
||||||
explicit Locator(GWidget* parent);
|
explicit Locator(GWidget* parent);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue