mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +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:
parent
d04613d252
commit
62cbfc68b9
Notes:
sideshowbarker
2024-07-17 11:06:06 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/62cbfc68b9 Pull-request: https://github.com/SerenityOS/serenity/pull/16118
|
@ -275,9 +275,6 @@ void Action::set_text(String text)
|
|||
if (m_text == text)
|
||||
return;
|
||||
m_text = move(text);
|
||||
for_each_toolbar_button([&](auto& button) {
|
||||
button.set_text_from_action();
|
||||
});
|
||||
for_each_menu_item([&](auto& menu_item) {
|
||||
menu_item.update_from_action({});
|
||||
});
|
||||
|
|
|
@ -169,25 +169,6 @@ void Button::set_action(Action& action)
|
|||
set_checkable(action.is_checkable());
|
||||
if (action.is_checkable())
|
||||
set_checked(action.is_checked());
|
||||
set_text_from_action();
|
||||
}
|
||||
|
||||
static String create_tooltip_for_action(Action const& action)
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
void Button::set_text_from_action()
|
||||
{
|
||||
set_text(action()->text());
|
||||
set_tooltip(create_tooltip_for_action(*action()));
|
||||
}
|
||||
|
||||
void Button::set_icon(RefPtr<Gfx::Bitmap> icon)
|
||||
|
|
|
@ -50,7 +50,6 @@ public:
|
|||
Action* action() { return m_action; }
|
||||
Action const* action() const { return m_action; }
|
||||
void set_action(Action&);
|
||||
void set_text_from_action();
|
||||
|
||||
virtual bool is_uncheckable() const override;
|
||||
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue