diff --git a/Userland/Libraries/LibGUI/Action.cpp b/Userland/Libraries/LibGUI/Action.cpp index 5408c02ac0..4b55731e25 100644 --- a/Userland/Libraries/LibGUI/Action.cpp +++ b/Userland/Libraries/LibGUI/Action.cpp @@ -63,6 +63,11 @@ NonnullRefPtr Action::create_checkable(String text, Shortcut const& shor return adopt_ref(*new Action(move(text), shortcut, Shortcut {}, move(icon), move(callback), parent, true)); } +ErrorOr> Action::try_create_checkable(String text, Shortcut const& shortcut, Function callback, Core::Object* parent) +{ + return adopt_nonnull_ref_or_enomem(new (nothrow) Action(move(text), shortcut, Shortcut {}, move(callback), parent, true)); +} + RefPtr Action::find_action_for_shortcut(Core::Object& object, Shortcut const& shortcut) { RefPtr found_action = nullptr; diff --git a/Userland/Libraries/LibGUI/Action.h b/Userland/Libraries/LibGUI/Action.h index efe0f1c5fe..1aa517fa09 100644 --- a/Userland/Libraries/LibGUI/Action.h +++ b/Userland/Libraries/LibGUI/Action.h @@ -76,6 +76,8 @@ public: static NonnullRefPtr create_checkable(String text, Shortcut const& shortcut, Function callback, Core::Object* parent = nullptr); static NonnullRefPtr create_checkable(String text, Shortcut const& shortcut, RefPtr icon, Function callback, Core::Object* parent = nullptr); + static ErrorOr> try_create_checkable(String text, Shortcut const& shortcut, Function callback, Core::Object* parent = nullptr); + static RefPtr find_action_for_shortcut(Core::Object& object, Shortcut const& shortcut); virtual ~Action() override;