diff options
author | Andreas Kling <kling@serenityos.org> | 2021-04-11 01:09:44 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-11 01:11:09 +0200 |
commit | a4992b5eceb26fb0c137ad6ba1fbef8460b173ca (patch) | |
tree | 97cbcaf1c35ed4d057c5a5a0f3f9640352a30a45 /Userland/Libraries/LibGUI | |
parent | f27352dfdc4c28a05797c1a95b6b4f841a277d4d (diff) | |
download | serenity-a4992b5eceb26fb0c137ad6ba1fbef8460b173ca.zip |
LibGUI+LibGfx: Collapse the '&' from Alt shortcuts in tooltip texts
Also resolve a FIXME about using GUI::Label auto-sizing since we're
changing this code and it simplifies what we're doing.
Fixes #6219.
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r-- | Userland/Libraries/LibGUI/Application.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Userland/Libraries/LibGUI/Application.cpp b/Userland/Libraries/LibGUI/Application.cpp index da40d8edfe..8f9b3e92ef 100644 --- a/Userland/Libraries/LibGUI/Application.cpp +++ b/Userland/Libraries/LibGUI/Application.cpp @@ -44,12 +44,10 @@ class Application::TooltipWindow final : public Window { C_OBJECT(TooltipWindow); public: - void set_tooltip(String tooltip) + void set_tooltip(const String& tooltip) { - // FIXME: Add some kind of GUI::Label auto-sizing feature. - int text_width = m_label->font().width(tooltip); - set_rect(rect().x(), rect().y(), text_width + 10, m_label->font().glyph_height() + 8); - m_label->set_text(move(tooltip)); + m_label->set_text(Gfx::parse_ampersand_string(tooltip)); + set_rect(rect().x(), rect().y(), m_label->min_width() + 10, m_label->font().glyph_height() + 8); } private: @@ -63,6 +61,7 @@ private: m_label->set_frame_thickness(1); m_label->set_frame_shape(Gfx::FrameShape::Container); m_label->set_frame_shadow(Gfx::FrameShadow::Plain); + m_label->set_autosize(true); } RefPtr<Label> m_label; |