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

LibGUI: Add GUI::CommonActions::make_properties_action()

Many apps want a "Properties" action with the same icon and shortcut.
This commit is contained in:
Andreas Kling 2021-04-04 22:39:41 +02:00
parent 578f749791
commit eff7ea5b84
4 changed files with 45 additions and 40 deletions

View file

@ -310,9 +310,8 @@ int run_in_desktop_mode([[maybe_unused]] RefPtr<Core::ConfigFile> config)
cut_action->set_enabled(!view.selection().is_empty()); cut_action->set_enabled(!view.selection().is_empty());
}; };
auto properties_action auto properties_action = GUI::CommonActions::make_properties_action(
= GUI::Action::create( [&](auto&) {
"Properties", { Mod_Alt, Key_Return }, Gfx::Bitmap::load_from_file("/res/icons/16x16/properties.png"), [&](const GUI::Action&) {
String path = directory_view.path(); String path = directory_view.path();
Vector<String> selected = directory_view.selected_file_paths(); Vector<String> selected = directory_view.selected_file_paths();
@ -658,9 +657,8 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
}, },
window); window);
auto properties_action auto properties_action = GUI::CommonActions::make_properties_action(
= GUI::Action::create( [&](auto& action) {
"Properties", { Mod_Alt, Key_Return }, Gfx::Bitmap::load_from_file("/res/icons/16x16/properties.png"), [&](const GUI::Action& action) {
String container_dir_path; String container_dir_path;
String path; String path;
Vector<String> selected; Vector<String> selected;

View file

@ -296,7 +296,8 @@ int main(int argc, char** argv)
HashMap<pid_t, NonnullRefPtr<GUI::Window>> process_windows; HashMap<pid_t, NonnullRefPtr<GUI::Window>> process_windows;
auto process_properties_action = GUI::Action::create("Properties", { Mod_Alt, Key_Return }, [&](auto&) { auto process_properties_action = GUI::CommonActions::make_properties_action(
[&](auto&) {
auto pid = selected_id(ProcessModel::Column::PID); auto pid = selected_id(ProcessModel::Column::PID);
RefPtr<GUI::Window> process_window; RefPtr<GUI::Window> process_window;

View file

@ -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); 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) NonnullRefPtr<Action> Action::create(String text, Function<void(Action&)> callback, Core::Object* parent)

View file

@ -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_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_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_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 { class Action final : public Core::Object {