mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 16:27:35 +00:00
LibGUI: Add CommonActions::make_about_action()
This creates an "About" menu action given the app name and icon. It takes care of showing the about dialog for you.
This commit is contained in:
parent
6bfcb9c2b0
commit
da536c8d22
2 changed files with 11 additions and 0 deletions
|
@ -24,10 +24,12 @@
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibGUI/AboutDialog.h>
|
||||||
#include <LibGUI/Action.h>
|
#include <LibGUI/Action.h>
|
||||||
#include <LibGUI/ActionGroup.h>
|
#include <LibGUI/ActionGroup.h>
|
||||||
#include <LibGUI/Application.h>
|
#include <LibGUI/Application.h>
|
||||||
#include <LibGUI/Button.h>
|
#include <LibGUI/Button.h>
|
||||||
|
#include <LibGUI/Icon.h>
|
||||||
#include <LibGUI/MenuItem.h>
|
#include <LibGUI/MenuItem.h>
|
||||||
#include <LibGUI/Window.h>
|
#include <LibGUI/Window.h>
|
||||||
|
|
||||||
|
@ -35,6 +37,14 @@ namespace GUI {
|
||||||
|
|
||||||
namespace CommonActions {
|
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)
|
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);
|
return Action::create("Open...", { Mod_Ctrl, Key_O }, Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"), move(callback), parent);
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
namespace CommonActions {
|
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_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_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||||
NonnullRefPtr<Action> make_save_as_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
NonnullRefPtr<Action> make_save_as_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue