Преглед изворни кода

LibGUI: Parse ampersand string for tooltips only in GUI::Action

It seems unnecessary to pass every tooltip string through
Gfx::parse_ampersand_string() when only Action tooltips need to parse a
title.
Karol Kosek пре 2 година
родитељ
комит
16defb4806

+ 5 - 0
Userland/Libraries/LibGUI/Action.cpp

@@ -297,6 +297,11 @@ void Action::set_text(DeprecatedString text)
     });
     });
 }
 }
 
 
+DeprecatedString Action::tooltip() const
+{
+    return m_tooltip.value_or_lazy_evaluated([this] { return Gfx::parse_ampersand_string(m_text); });
+}
+
 void Action::set_tooltip(DeprecatedString tooltip)
 void Action::set_tooltip(DeprecatedString tooltip)
 {
 {
     if (m_tooltip == tooltip)
     if (m_tooltip == tooltip)

+ 1 - 1
Userland/Libraries/LibGUI/Action.h

@@ -84,7 +84,7 @@ public:
     DeprecatedString text() const { return m_text; }
     DeprecatedString text() const { return m_text; }
     void set_text(DeprecatedString);
     void set_text(DeprecatedString);
 
 
-    DeprecatedString tooltip() const { return m_tooltip.value_or(m_text); }
+    DeprecatedString tooltip() const;
     void set_tooltip(DeprecatedString);
     void set_tooltip(DeprecatedString);
 
 
     Optional<String> status_tip() const;
     Optional<String> status_tip() const;

+ 1 - 1
Userland/Libraries/LibGUI/Application.cpp

@@ -27,7 +27,7 @@ class Application::TooltipWindow final : public Window {
 public:
 public:
     void set_tooltip(DeprecatedString const& tooltip)
     void set_tooltip(DeprecatedString const& tooltip)
     {
     {
-        m_label->set_text(String::from_deprecated_string(Gfx::parse_ampersand_string(tooltip)).release_value_but_fixme_should_propagate_errors());
+        m_label->set_text(String::from_deprecated_string(tooltip).release_value_but_fixme_should_propagate_errors());
         int tooltip_width = m_label->effective_min_size().width().as_int() + 10;
         int tooltip_width = m_label->effective_min_size().width().as_int() + 10;
         int line_count = m_label->text().count("\n"sv);
         int line_count = m_label->text().count("\n"sv);
         int font_size = m_label->font().pixel_size_rounded_up();
         int font_size = m_label->font().pixel_size_rounded_up();

+ 1 - 1
Userland/Libraries/LibGUI/EmojiInputDialog.cpp

@@ -67,7 +67,7 @@ EmojiInputDialog::EmojiInputDialog(Window* parent_window)
 
 
     for (auto const& category : s_emoji_groups) {
     for (auto const& category : s_emoji_groups) {
         auto name = Unicode::emoji_group_to_string(category.group);
         auto name = Unicode::emoji_group_to_string(category.group);
-        auto tooltip = name.replace("&"sv, "&&"sv, ReplaceMode::FirstOnly);
+        DeprecatedString tooltip = name;
 
 
         auto set_filter_action = Action::create_checkable(
         auto set_filter_action = Action::create_checkable(
             category.representative_emoji,
             category.representative_emoji,