mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 10:38:13 +00:00
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.
This commit is contained in:
parent
ba7e1ca2fb
commit
e7263a7e75
2 changed files with 15 additions and 4 deletions
|
@ -48,17 +48,23 @@ NonnullRefPtr<Action> make_about_action(const String& app_name, const Icon& app_
|
|||
|
||||
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);
|
||||
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<Action> make_save_action(Function<void(Action&)> 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<Action> make_save_as_action(Function<void(Action&)> 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<Action> make_move_to_front_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
* 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<Gfx::Bitmap> m_icon;
|
||||
Shortcut m_shortcut;
|
||||
bool m_enabled { true };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue