diff options
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibGUI/Action.cpp | 10 | ||||
-rw-r--r-- | Libraries/LibGUI/Action.h | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/Libraries/LibGUI/Action.cpp b/Libraries/LibGUI/Action.cpp index f71354fc5d..5a9743df7e 100644 --- a/Libraries/LibGUI/Action.cpp +++ b/Libraries/LibGUI/Action.cpp @@ -24,10 +24,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <LibGUI/AboutDialog.h> #include <LibGUI/Action.h> #include <LibGUI/ActionGroup.h> #include <LibGUI/Application.h> #include <LibGUI/Button.h> +#include <LibGUI/Icon.h> #include <LibGUI/MenuItem.h> #include <LibGUI/Window.h> @@ -35,6 +37,14 @@ namespace GUI { namespace CommonActions { +NonnullRefPtr<Action> make_about_action(const String& app_name, const Icon& app_icon, Window* parent) +{ + WeakPtr<Window> weak_parent = parent ? parent->make_weak_ptr<Window>() : nullptr; + return Action::create(String::formatted("About {}", app_name), app_icon.bitmap_for_size(16), [=](auto&) { + AboutDialog::show(app_name, app_icon.bitmap_for_size(32), weak_parent.ptr()); + }); +} + NonnullRefPtr<Action> make_open_action(Function<void(Action&)> callback, Core::Object* parent) { return Action::create("Open...", { Mod_Ctrl, Key_O }, Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"), move(callback), parent); diff --git a/Libraries/LibGUI/Action.h b/Libraries/LibGUI/Action.h index 486aa6b999..9b006031bb 100644 --- a/Libraries/LibGUI/Action.h +++ b/Libraries/LibGUI/Action.h @@ -42,6 +42,7 @@ namespace GUI { namespace CommonActions { +NonnullRefPtr<Action> make_about_action(const String& app_name, const Icon& app_icon, Window* parent = nullptr); NonnullRefPtr<Action> make_open_action(Function<void(Action&)>, Core::Object* parent = nullptr); NonnullRefPtr<Action> make_save_action(Function<void(Action&)>, Core::Object* parent = nullptr); NonnullRefPtr<Action> make_save_as_action(Function<void(Action&)>, Core::Object* parent = nullptr); |