diff --git a/Userland/Libraries/LibGUI/Action.cpp b/Userland/Libraries/LibGUI/Action.cpp index a1d140544d..7d7e423b3c 100644 --- a/Userland/Libraries/LibGUI/Action.cpp +++ b/Userland/Libraries/LibGUI/Action.cpp @@ -186,9 +186,19 @@ NonnullRefPtr Action::create(String text, const Shortcut& shortcut, Func return adopt_ref(*new Action(move(text), shortcut, move(callback), parent)); } +NonnullRefPtr Action::create(String text, const Shortcut& shortcut, const Shortcut& alternate_shortcut, Function callback, Core::Object* parent) +{ + return adopt_ref(*new Action(move(text), shortcut, alternate_shortcut, move(callback), parent)); +} + NonnullRefPtr Action::create(String text, const Shortcut& shortcut, RefPtr icon, Function callback, Core::Object* parent) { - return adopt_ref(*new Action(move(text), shortcut, move(icon), move(callback), parent)); + return adopt_ref(*new Action(move(text), shortcut, Shortcut {}, move(icon), move(callback), parent)); +} + +NonnullRefPtr Action::create(String text, const Shortcut& shortcut, const Shortcut& alternate_shortcut, RefPtr icon, Function callback, Core::Object* parent) +{ + return adopt_ref(*new Action(move(text), shortcut, alternate_shortcut, move(icon), move(callback), parent)); } NonnullRefPtr Action::create_checkable(String text, Function callback, Core::Object* parent) @@ -208,30 +218,36 @@ NonnullRefPtr Action::create_checkable(String text, const Shortcut& shor NonnullRefPtr Action::create_checkable(String text, const Shortcut& shortcut, RefPtr icon, Function callback, Core::Object* parent) { - return adopt_ref(*new Action(move(text), shortcut, move(icon), move(callback), parent, true)); + return adopt_ref(*new Action(move(text), shortcut, Shortcut {}, move(icon), move(callback), parent, true)); } Action::Action(String text, Function on_activation_callback, Core::Object* parent, bool checkable) - : Action(move(text), Shortcut {}, nullptr, move(on_activation_callback), parent, checkable) + : Action(move(text), Shortcut {}, Shortcut {}, nullptr, move(on_activation_callback), parent, checkable) { } Action::Action(String text, RefPtr icon, Function on_activation_callback, Core::Object* parent, bool checkable) - : Action(move(text), Shortcut {}, move(icon), move(on_activation_callback), parent, checkable) + : Action(move(text), Shortcut {}, Shortcut {}, move(icon), move(on_activation_callback), parent, checkable) { } Action::Action(String text, const Shortcut& shortcut, Function on_activation_callback, Core::Object* parent, bool checkable) - : Action(move(text), shortcut, nullptr, move(on_activation_callback), parent, checkable) + : Action(move(text), shortcut, Shortcut {}, nullptr, move(on_activation_callback), parent, checkable) { } -Action::Action(String text, const Shortcut& shortcut, RefPtr icon, Function on_activation_callback, Core::Object* parent, bool checkable) +Action::Action(String text, const Shortcut& shortcut, const Shortcut& alternate_shortcut, Function on_activation_callback, Core::Object* parent, bool checkable) + : Action(move(text), shortcut, alternate_shortcut, nullptr, move(on_activation_callback), parent, checkable) +{ +} + +Action::Action(String text, const Shortcut& shortcut, const Shortcut& alternate_shortcut, RefPtr icon, Function on_activation_callback, Core::Object* parent, bool checkable) : Core::Object(parent) , on_activation(move(on_activation_callback)) , m_text(move(text)) , m_icon(move(icon)) , m_shortcut(shortcut) + , m_alternate_shortcut(alternate_shortcut) , m_checkable(checkable) { if (parent && is(*parent)) { diff --git a/Userland/Libraries/LibGUI/Action.h b/Userland/Libraries/LibGUI/Action.h index 7f4d3ade35..56ffed1373 100644 --- a/Userland/Libraries/LibGUI/Action.h +++ b/Userland/Libraries/LibGUI/Action.h @@ -61,7 +61,9 @@ public: static NonnullRefPtr create(String text, Function callback, Core::Object* parent = nullptr); static NonnullRefPtr create(String text, RefPtr icon, Function callback, Core::Object* parent = nullptr); static NonnullRefPtr create(String text, const Shortcut& shortcut, Function callback, Core::Object* parent = nullptr); + static NonnullRefPtr create(String text, const Shortcut& shortcut, const Shortcut& alternate_shortcut, Function callback, Core::Object* parent = nullptr); static NonnullRefPtr create(String text, const Shortcut& shortcut, RefPtr icon, Function callback, Core::Object* parent = nullptr); + static NonnullRefPtr create(String text, const Shortcut& shortcut, const Shortcut& alternate_shortcut, RefPtr icon, Function callback, Core::Object* parent = nullptr); static NonnullRefPtr create_checkable(String text, Function callback, Core::Object* parent = nullptr); static NonnullRefPtr create_checkable(String text, RefPtr icon, Function callback, Core::Object* parent = nullptr); static NonnullRefPtr create_checkable(String text, const Shortcut& shortcut, Function callback, Core::Object* parent = nullptr); @@ -76,6 +78,7 @@ public: void set_status_tip(String status_tip) { m_status_tip = move(status_tip); } Shortcut shortcut() const { return m_shortcut; } + Shortcut alternate_shortcut() const { return m_alternate_shortcut; } const Gfx::Bitmap* icon() const { return m_icon.ptr(); } void set_icon(const Gfx::Bitmap*); @@ -113,7 +116,8 @@ public: private: Action(String, Function = nullptr, Core::Object* = nullptr, bool checkable = false); Action(String, const Shortcut&, Function = nullptr, Core::Object* = nullptr, bool checkable = false); - Action(String, const Shortcut&, RefPtr icon, Function = nullptr, Core::Object* = nullptr, bool checkable = false); + Action(String, const Shortcut&, const Shortcut&, Function = nullptr, Core::Object* = nullptr, bool checkable = false); + Action(String, const Shortcut&, const Shortcut&, RefPtr icon, Function = nullptr, Core::Object* = nullptr, bool checkable = false); Action(String, RefPtr icon, Function = nullptr, Core::Object* = nullptr, bool checkable = false); template @@ -125,6 +129,7 @@ private: String m_status_tip; RefPtr m_icon; Shortcut m_shortcut; + Shortcut m_alternate_shortcut; bool m_enabled { true }; bool m_checkable { false }; bool m_checked { false };