summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2020-08-15 13:01:58 -0400
committerAndreas Kling <kling@serenityos.org>2020-08-15 19:07:47 +0200
commit19ee853cd017eb1c0493d7007fc99b95a2ff54a2 (patch)
treeb3f777fd206b3208104c5f977e753b3523bd38ef /Libraries/LibGUI
parentcd7b4e813f195ad800624e4da20427a845a9525f (diff)
downloadserenity-19ee853cd017eb1c0493d7007fc99b95a2ff54a2.zip
LibGUI: Make ProcessChooser accept double clicks on rows as "Ok" click
Diffstat (limited to 'Libraries/LibGUI')
-rw-r--r--Libraries/LibGUI/ProcessChooser.cpp13
-rw-r--r--Libraries/LibGUI/ProcessChooser.h2
2 files changed, 12 insertions, 3 deletions
diff --git a/Libraries/LibGUI/ProcessChooser.cpp b/Libraries/LibGUI/ProcessChooser.cpp
index 92c2209dbe..3d2ab697c3 100644
--- a/Libraries/LibGUI/ProcessChooser.cpp
+++ b/Libraries/LibGUI/ProcessChooser.cpp
@@ -61,6 +61,8 @@ ProcessChooser::ProcessChooser(const StringView& window_title, const StringView&
sorting_model->set_key_column_and_sort_order(RunningProcessesModel::Column::PID, GUI::SortOrder::Descending);
m_table_view->set_model(sorting_model);
+ m_table_view->on_activation = [this](const ModelIndex& index) { set_pid_from_index_and_close(index); };
+
auto& button_container = widget.add<GUI::Widget>();
button_container.set_preferred_size(0, 30);
button_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
@@ -77,9 +79,7 @@ ProcessChooser::ProcessChooser(const StringView& window_title, const StringView&
return;
}
auto index = m_table_view->selection().first();
- auto pid_as_variant = m_table_view->model()->data(index, GUI::Model::Role::Custom);
- m_pid = pid_as_variant.as_i32();
- done(ExecOK);
+ set_pid_from_index_and_close(index);
};
auto& cancel_button = button_container.add<GUI::Button>("Cancel");
cancel_button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
@@ -119,6 +119,13 @@ ProcessChooser::ProcessChooser(const StringView& window_title, const StringView&
};
}
+void ProcessChooser::set_pid_from_index_and_close(const ModelIndex& index)
+{
+ auto pid_as_variant = m_table_view->model()->data(index, GUI::Model::Role::Custom);
+ m_pid = pid_as_variant.as_i32();
+ done(ExecOK);
+}
+
ProcessChooser::~ProcessChooser()
{
}
diff --git a/Libraries/LibGUI/ProcessChooser.h b/Libraries/LibGUI/ProcessChooser.h
index 5f09fdbe98..644fd59f00 100644
--- a/Libraries/LibGUI/ProcessChooser.h
+++ b/Libraries/LibGUI/ProcessChooser.h
@@ -42,6 +42,8 @@ public:
private:
ProcessChooser(const StringView& window_title = "Process Chooser", const StringView& button_label = "Select", const Gfx::Bitmap* window_icon = nullptr, GUI::Window* parent_window = nullptr);
+ void set_pid_from_index_and_close(const ModelIndex&);
+
pid_t m_pid { 0 };
String m_window_title;