From e7263a7e75aeeea64cd63fe9f5d4214ab29c5967 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 17 Apr 2021 18:18:59 +0200 Subject: [PATCH] LibGUI: Add a "long text" string to GUI::Action Actions can now have a longer text description, in addition to its regular UI string. The longer text will soon be used to display a more detailed description of hovered actions in statusbars. --- Userland/Libraries/LibGUI/Action.cpp | 12 +++++++++--- Userland/Libraries/LibGUI/Action.h | 7 ++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibGUI/Action.cpp b/Userland/Libraries/LibGUI/Action.cpp index 51f29ea324..46c9fd8616 100644 --- a/Userland/Libraries/LibGUI/Action.cpp +++ b/Userland/Libraries/LibGUI/Action.cpp @@ -48,17 +48,23 @@ NonnullRefPtr make_about_action(const String& app_name, const Icon& app_ NonnullRefPtr make_open_action(Function 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); + auto action = Action::create("&Open...", { Mod_Ctrl, Key_O }, Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"), move(callback), parent); + action->set_long_text("Open an existing file"); + return action; } NonnullRefPtr make_save_action(Function callback, Core::Object* parent) { - return Action::create("&Save", { Mod_Ctrl, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png"), move(callback), parent); + auto action = Action::create("&Save", { Mod_Ctrl, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png"), move(callback), parent); + action->set_long_text("Save the current file"); + return action; } NonnullRefPtr make_save_as_action(Function callback, Core::Object* parent) { - return Action::create("Save &As...", { Mod_Ctrl | Mod_Shift, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png"), move(callback), parent); + auto action = Action::create("Save &As...", { Mod_Ctrl | Mod_Shift, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png"), move(callback), parent); + action->set_long_text("Save the current file with a new name"); + return action; } NonnullRefPtr make_move_to_front_action(Function callback, Core::Object* parent) diff --git a/Userland/Libraries/LibGUI/Action.h b/Userland/Libraries/LibGUI/Action.h index 66beb068f5..b00d80c656 100644 --- a/Userland/Libraries/LibGUI/Action.h +++ b/Userland/Libraries/LibGUI/Action.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2021, Andreas Kling * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -87,6 +87,10 @@ public: String text() const { return m_text; } void set_text(String text) { m_text = move(text); } + + String const& long_text() const { return m_long_text; } + void set_long_text(String long_text) { m_long_text = move(long_text); } + Shortcut shortcut() const { return m_shortcut; } const Gfx::Bitmap* icon() const { return m_icon.ptr(); } void set_icon(const Gfx::Bitmap*); @@ -134,6 +138,7 @@ private: void for_each_menu_item(Callback); String m_text; + String m_long_text; RefPtr m_icon; Shortcut m_shortcut; bool m_enabled { true };