mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:07:35 +00:00
LibGUI: Make Action::set_text() update any associated menu items
Now you can change the text of an action and it will actually show up in the menu. :^)
This commit is contained in:
parent
161568103e
commit
bfd2ec88f4
3 changed files with 13 additions and 1 deletions
|
@ -343,4 +343,14 @@ void Action::set_icon(const Gfx::Bitmap* icon)
|
||||||
m_icon = icon;
|
m_icon = icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Action::set_text(String text)
|
||||||
|
{
|
||||||
|
if (m_text == text)
|
||||||
|
return;
|
||||||
|
m_text = move(text);
|
||||||
|
for_each_menu_item([&](auto& menu_item) {
|
||||||
|
menu_item.update_from_action({});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ public:
|
||||||
virtual ~Action() override;
|
virtual ~Action() override;
|
||||||
|
|
||||||
String text() const { return m_text; }
|
String text() const { return m_text; }
|
||||||
void set_text(String text) { m_text = move(text); }
|
void set_text(String);
|
||||||
|
|
||||||
String const& status_tip() const { return m_status_tip; }
|
String const& status_tip() const { return m_status_tip; }
|
||||||
void set_status_tip(String status_tip) { m_status_tip = move(status_tip); }
|
void set_status_tip(String status_tip) { m_status_tip = move(status_tip); }
|
||||||
|
|
|
@ -50,6 +50,8 @@ public:
|
||||||
void set_menu_id(Badge<Menu>, unsigned menu_id);
|
void set_menu_id(Badge<Menu>, unsigned menu_id);
|
||||||
void set_identifier(Badge<Menu>, unsigned identifier);
|
void set_identifier(Badge<Menu>, unsigned identifier);
|
||||||
|
|
||||||
|
void update_from_action(Badge<Action>) { update_window_server(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void update_window_server();
|
void update_window_server();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue