1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:18:12 +00:00

Revert "LibGUI: Update buttons' text/tooltips in Action::set_text"

This reverts commit e20756f9f7.

Some buttons, e.g. GUI::ToolbarButton, set text to be used only as a
tooltip instead of text on the button itself. This commit forced those
buttons to have text on them when their action became set. For most
toolbars, this was an invisible side effect; the button icons covered
the whole button rect. But the toolbar for EmojiInputDialog has slightly
smaller icons, causing an ellipsis to be displayed next to the icon.
This commit is contained in:
Timothy Flynn 2022-11-19 09:08:09 -05:00 committed by Andreas Kling
parent d04613d252
commit 62cbfc68b9
4 changed files with 12 additions and 23 deletions

View file

@ -51,6 +51,7 @@ private:
if (action.group() && action.group()->is_exclusive())
set_exclusive(true);
set_action(action);
set_tooltip(tooltip(action));
set_focus_policy(FocusPolicy::NoFocus);
if (action.icon())
set_icon(action.icon());
@ -58,6 +59,17 @@ private:
set_text(action.text());
set_button_style(Gfx::ButtonStyle::Coolbar);
}
String tooltip(Action const& action) const
{
StringBuilder builder;
builder.append(action.text());
if (action.shortcut().is_valid()) {
builder.append(" ("sv);
builder.append(action.shortcut().to_string());
builder.append(')');
}
return builder.to_string();
}
virtual void enter_event(Core::Event& event) override
{