summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Applications/FileManager/main.cpp50
-rw-r--r--Userland/Applications/SystemMonitor/main.cpp31
-rw-r--r--Userland/Libraries/LibGUI/Action.cpp5
-rw-r--r--Userland/Libraries/LibGUI/Action.h1
4 files changed, 46 insertions, 41 deletions
diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp
index b783a97771..83e0648c1b 100644
--- a/Userland/Applications/FileManager/main.cpp
+++ b/Userland/Applications/FileManager/main.cpp
@@ -310,15 +310,14 @@ int run_in_desktop_mode([[maybe_unused]] RefPtr<Core::ConfigFile> config)
cut_action->set_enabled(!view.selection().is_empty());
};
- auto properties_action
- = GUI::Action::create(
- "Properties", { Mod_Alt, Key_Return }, Gfx::Bitmap::load_from_file("/res/icons/16x16/properties.png"), [&](const GUI::Action&) {
- String path = directory_view.path();
- Vector<String> selected = directory_view.selected_file_paths();
+ auto properties_action = GUI::CommonActions::make_properties_action(
+ [&](auto&) {
+ String path = directory_view.path();
+ Vector<String> selected = directory_view.selected_file_paths();
- show_properties(path, path, selected, directory_view.window());
- },
- window);
+ show_properties(path, path, selected, directory_view.window());
+ },
+ window);
auto paste_action = GUI::CommonActions::make_paste_action(
[&](const GUI::Action&) {
@@ -658,25 +657,24 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
},
window);
- auto properties_action
- = GUI::Action::create(
- "Properties", { Mod_Alt, Key_Return }, Gfx::Bitmap::load_from_file("/res/icons/16x16/properties.png"), [&](const GUI::Action& action) {
- String container_dir_path;
- String path;
- Vector<String> selected;
- if (action.activator() == directory_context_menu || directory_view.active_widget()->is_focused()) {
- path = directory_view.path();
- container_dir_path = path;
- selected = directory_view.selected_file_paths();
- } else {
- path = directories_model->full_path(tree_view.selection().first());
- container_dir_path = LexicalPath(path).basename();
- selected = tree_view_selected_file_paths();
- }
+ auto properties_action = GUI::CommonActions::make_properties_action(
+ [&](auto& action) {
+ String container_dir_path;
+ String path;
+ Vector<String> selected;
+ if (action.activator() == directory_context_menu || directory_view.active_widget()->is_focused()) {
+ path = directory_view.path();
+ container_dir_path = path;
+ selected = directory_view.selected_file_paths();
+ } else {
+ path = directories_model->full_path(tree_view.selection().first());
+ container_dir_path = LexicalPath(path).basename();
+ selected = tree_view_selected_file_paths();
+ }
- show_properties(container_dir_path, path, selected, directory_view.window());
- },
- window);
+ show_properties(container_dir_path, path, selected, directory_view.window());
+ },
+ window);
auto paste_action = GUI::CommonActions::make_paste_action(
[&](const GUI::Action& action) {
diff --git a/Userland/Applications/SystemMonitor/main.cpp b/Userland/Applications/SystemMonitor/main.cpp
index 8a0f3cd339..d8c13fa469 100644
--- a/Userland/Applications/SystemMonitor/main.cpp
+++ b/Userland/Applications/SystemMonitor/main.cpp
@@ -296,21 +296,22 @@ int main(int argc, char** argv)
HashMap<pid_t, NonnullRefPtr<GUI::Window>> process_windows;
- auto process_properties_action = GUI::Action::create("Properties", { Mod_Alt, Key_Return }, [&](auto&) {
- auto pid = selected_id(ProcessModel::Column::PID);
-
- RefPtr<GUI::Window> process_window;
- if (!process_windows.contains(pid)) {
- process_window = build_process_window(pid);
- process_window->on_close_request = [pid, &process_windows] {
- process_windows.remove(pid);
- return GUI::Window::CloseRequestDecision::Close;
- };
- process_windows.set(pid, *process_window);
- }
- process_window->show();
- process_window->move_to_front();
- });
+ auto process_properties_action = GUI::CommonActions::make_properties_action(
+ [&](auto&) {
+ auto pid = selected_id(ProcessModel::Column::PID);
+
+ RefPtr<GUI::Window> process_window;
+ if (!process_windows.contains(pid)) {
+ process_window = build_process_window(pid);
+ process_window->on_close_request = [pid, &process_windows] {
+ process_windows.remove(pid);
+ return GUI::Window::CloseRequestDecision::Close;
+ };
+ process_windows.set(pid, *process_window);
+ }
+ process_window->show();
+ process_window->move_to_front();
+ });
auto menubar = GUI::MenuBar::construct();
auto& app_menu = menubar->add_menu("File");
diff --git a/Userland/Libraries/LibGUI/Action.cpp b/Userland/Libraries/LibGUI/Action.cpp
index 848911849a..fba1c62eb3 100644
--- a/Userland/Libraries/LibGUI/Action.cpp
+++ b/Userland/Libraries/LibGUI/Action.cpp
@@ -141,6 +141,11 @@ NonnullRefPtr<Action> make_select_all_action(Function<void(Action&)> callback, C
return Action::create("Select all", { Mod_Ctrl, Key_A }, Gfx::Bitmap::load_from_file("/res/icons/16x16/select-all.png"), move(callback), parent);
}
+NonnullRefPtr<Action> make_properties_action(Function<void(Action&)> callback, Core::Object* parent)
+{
+ return Action::create("Properties", { Mod_Alt, Key_Return }, Gfx::Bitmap::load_from_file("/res/icons/16x16/properties.png"), move(callback), parent);
+}
+
}
NonnullRefPtr<Action> Action::create(String text, Function<void(Action&)> callback, Core::Object* parent)
diff --git a/Userland/Libraries/LibGUI/Action.h b/Userland/Libraries/LibGUI/Action.h
index 4ed68896f7..66beb068f5 100644
--- a/Userland/Libraries/LibGUI/Action.h
+++ b/Userland/Libraries/LibGUI/Action.h
@@ -62,6 +62,7 @@ NonnullRefPtr<Action> make_go_forward_action(Function<void(Action&)>, Core::Obje
NonnullRefPtr<Action> make_go_home_action(Function<void(Action&)> callback, Core::Object* parent = nullptr);
NonnullRefPtr<Action> make_reload_action(Function<void(Action&)>, Core::Object* parent = nullptr);
NonnullRefPtr<Action> make_select_all_action(Function<void(Action&)>, Core::Object* parent = nullptr);
+NonnullRefPtr<Action> make_properties_action(Function<void(Action&)>, Core::Object* parent = nullptr);
};
class Action final : public Core::Object {