Userland: Use nondeprecated set_tooltip for static and formatted strings

This commit is contained in:
Karol Kosek 2023-08-23 20:14:42 +02:00 committed by Andreas Kling
parent 46a97844c7
commit ed3e729d4e
Notes: sideshowbarker 2024-07-17 07:20:57 +09:00
18 changed files with 45 additions and 45 deletions

View file

@ -87,7 +87,7 @@ private:
m_root_container->set_frame_style(Gfx::FrameStyle::Window);
m_percent_box = m_root_container->add<GUI::CheckBox>("\xE2\x84\xB9"_string);
m_percent_box->set_tooltip_deprecated(show_percent() ? "Hide percent" : "Show percent");
m_percent_box->set_tooltip(show_percent() ? "Hide percent"_string : "Show percent"_string);
m_percent_box->set_checked(show_percent());
m_percent_box->on_checked = [&](bool show_percent) {
set_show_percent(show_percent);
@ -111,9 +111,9 @@ private:
m_mute_box = m_root_container->add<GUI::CheckBox>("\xE2\x9D\x8C"_string);
m_mute_box->set_checked(m_audio_muted);
m_mute_box->set_tooltip_deprecated(m_audio_muted ? "Unmute" : "Mute");
m_mute_box->set_tooltip(m_audio_muted ? "Unmute"_string : "Mute"_string);
m_mute_box->on_checked = [&](bool is_muted) {
m_mute_box->set_tooltip_deprecated(is_muted ? "Unmute" : "Mute");
m_mute_box->set_tooltip(is_muted ? "Unmute"_string : "Mute"_string);
m_audio_client->set_main_mix_muted(is_muted);
GUI::Application::the()->hide_tooltip();
};
@ -129,7 +129,7 @@ public:
{
m_show_percent = show_percent;
m_percent_box->set_checked(show_percent);
m_percent_box->set_tooltip_deprecated(show_percent ? "Hide percent" : "Show percent");
m_percent_box->set_tooltip(show_percent ? "Hide percent"_string : "Show percent"_string);
if (show_percent)
window()->resize(44, 16);
else

View file

@ -101,7 +101,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
applet_window->set_window_type(GUI::WindowType::Applet);
applet_window->set_has_alpha_channel(true);
auto icon_widget = applet_window->set_main_widget<GUI::ImageWidget>();
icon_widget->set_tooltip_deprecated("Clipboard History");
icon_widget->set_tooltip("Clipboard History"_string);
icon_widget->load_from_file("/res/icons/16x16/edit-copy.png"sv);
icon_widget->on_click = [&main_window = *main_window] {
main_window.show();

View file

@ -53,10 +53,10 @@ private:
m_last_idle = idle;
float cpu = total_diff > 0 ? (float)(total_diff - idle_diff) / (float)total_diff : 0;
m_history.enqueue(cpu);
m_tooltip = DeprecatedString::formatted("CPU usage: {:.1}%", 100 * cpu);
m_tooltip = MUST(String::formatted("CPU usage: {:.1}%", 100 * cpu));
} else {
m_history.enqueue(-1);
m_tooltip = "Unable to determine CPU usage"sv;
m_tooltip = "Unable to determine CPU usage"_string;
}
break;
}
@ -66,10 +66,10 @@ private:
double total_memory = allocated + available;
double memory = (double)allocated / total_memory;
m_history.enqueue(memory);
m_tooltip = DeprecatedString::formatted("Memory: {} MiB of {:.1} MiB in use", allocated / MiB, total_memory / MiB);
m_tooltip = MUST(String::formatted("Memory: {} MiB of {:.1} MiB in use", allocated / MiB, total_memory / MiB));
} else {
m_history.enqueue(-1);
m_tooltip = "Unable to determine memory usage"sv;
m_tooltip = "Unable to determine memory usage"_string;
}
break;
}
@ -97,17 +97,17 @@ private:
}
}
m_history.enqueue(static_cast<float>(recent_tx) / static_cast<float>(m_current_scale));
m_tooltip = DeprecatedString::formatted("Network: TX {} / RX {} ({:.1} kbit/s)", tx, rx, static_cast<double>(recent_tx) * 8.0 / 1000.0);
m_tooltip = MUST(String::formatted("Network: TX {} / RX {} ({:.1} kbit/s)", tx, rx, static_cast<double>(recent_tx) * 8.0 / 1000.0));
} else {
m_history.enqueue(-1);
m_tooltip = "Unable to determine network usage"sv;
m_tooltip = "Unable to determine network usage"_string;
}
break;
}
default:
VERIFY_NOT_REACHED();
}
set_tooltip_deprecated(m_tooltip);
set_tooltip(m_tooltip);
update();
}
@ -229,7 +229,7 @@ private:
u64 m_last_total { 0 };
static constexpr u64 const scale_unit = 8000;
u64 m_current_scale { scale_unit };
DeprecatedString m_tooltip;
String m_tooltip;
OwnPtr<Core::File> m_proc_stat;
OwnPtr<Core::File> m_proc_mem;
OwnPtr<Core::File> m_proc_net;

View file

@ -117,7 +117,7 @@ BookmarksBarWidget::BookmarksBarWidget(DeprecatedString const& bookmarks_file, b
set_visible(false);
m_additional = GUI::Button::construct();
m_additional->set_tooltip_deprecated("Show hidden bookmarks");
m_additional->set_tooltip("Show hidden bookmarks"_string);
m_additional->set_menu(m_additional_menu);
auto bitmap_or_error = Gfx::Bitmap::load_from_file("/res/icons/16x16/overflow-menu.png"sv);
if (!bitmap_or_error.is_error())

View file

@ -56,7 +56,7 @@ ConsoleWidget::ConsoleWidget(WebView::OutOfProcessWebView& content_view)
auto& clear_button = bottom_container.add<GUI::Button>();
clear_button.set_fixed_size(22, 22);
clear_button.set_icon(g_icon_bag.delete_icon);
clear_button.set_tooltip_deprecated("Clear the console output");
clear_button.set_tooltip("Clear the console output"_string);
clear_button.on_click = [this](auto) {
m_console_client->clear();
};

View file

@ -205,7 +205,7 @@ Tab::Tab(BrowserWindow& window)
this);
m_reset_zoom_button = toolbar.add<GUI::Button>();
m_reset_zoom_button->set_tooltip_deprecated("Reset zoom level");
m_reset_zoom_button->set_tooltip("Reset zoom level"_string);
m_reset_zoom_button->on_click = [&](auto) {
view().reset_zoom();
update_reset_zoom_button();
@ -801,10 +801,10 @@ void Tab::update_bookmark_button(StringView url)
{
if (BookmarksBarWidget::the().contains_bookmark(url)) {
m_bookmark_button->set_icon(g_icon_bag.bookmark_filled);
m_bookmark_button->set_tooltip_deprecated("Remove Bookmark");
m_bookmark_button->set_tooltip("Remove Bookmark"_string);
} else {
m_bookmark_button->set_icon(g_icon_bag.bookmark_contour);
m_bookmark_button->set_tooltip_deprecated("Add Bookmark");
m_bookmark_button->set_tooltip("Add Bookmark"_string);
}
}

View file

@ -69,7 +69,7 @@ ErrorOr<void> MainWidget::initialize()
// FIXME: Implement vertical flipping in GUI::Slider, not here.
m_octave_knob = m_octave_container->add<GUI::VerticalSlider>();
m_octave_knob->set_preferred_width(GUI::SpecialDimension::Fit);
m_octave_knob->set_tooltip_deprecated("Z: octave down, X: octave up");
m_octave_knob->set_tooltip("Z: octave down, X: octave up"_string);
m_octave_knob->set_range(octave_min - 1, octave_max - 1);
m_octave_knob->set_value((octave_max - 1) - (m_track_manager.keyboard()->virtual_keyboard_octave() - 1));
m_octave_knob->set_step(1);

View file

@ -62,7 +62,7 @@ ErrorOr<void> PlayerWidget::initialize()
m_add_track_button = add<GUI::Button>();
m_add_track_button->set_icon(*m_add_track_icon);
m_add_track_button->set_fixed_width(30);
m_add_track_button->set_tooltip_deprecated("Add Track");
m_add_track_button->set_tooltip("Add Track"_string);
m_add_track_button->set_focus_policy(GUI::FocusPolicy::NoFocus);
m_add_track_button->on_click = [this](unsigned) {
add_track();
@ -71,7 +71,7 @@ ErrorOr<void> PlayerWidget::initialize()
m_next_track_button = add<GUI::Button>();
m_next_track_button->set_icon(*m_next_track_icon);
m_next_track_button->set_fixed_width(30);
m_next_track_button->set_tooltip_deprecated("Next Track");
m_next_track_button->set_tooltip("Next Track"_string);
m_next_track_button->set_focus_policy(GUI::FocusPolicy::NoFocus);
m_next_track_button->on_click = [this](unsigned) {
next_track();
@ -80,7 +80,7 @@ ErrorOr<void> PlayerWidget::initialize()
m_play_button = add<GUI::Button>();
m_play_button->set_icon(*m_pause_icon);
m_play_button->set_fixed_width(30);
m_play_button->set_tooltip_deprecated("Play/Pause playback");
m_play_button->set_tooltip("Play/Pause playback"_string);
m_play_button->set_focus_policy(GUI::FocusPolicy::NoFocus);
m_play_button->on_click = [this](unsigned) {
m_audio_loop.toggle_paused();
@ -95,7 +95,7 @@ ErrorOr<void> PlayerWidget::initialize()
m_back_button = add<GUI::Button>();
m_back_button->set_icon(*m_back_icon);
m_back_button->set_fixed_width(30);
m_back_button->set_tooltip_deprecated("Previous Note");
m_back_button->set_tooltip("Previous Note"_string);
m_back_button->set_focus_policy(GUI::FocusPolicy::NoFocus);
m_back_button->on_click = [this](unsigned) {
m_track_manager.time_forward(-(sample_rate / (beats_per_minute / 60) / notes_per_beat));
@ -104,7 +104,7 @@ ErrorOr<void> PlayerWidget::initialize()
m_next_button = add<GUI::Button>();
m_next_button->set_icon(*m_next_icon);
m_next_button->set_fixed_width(30);
m_next_button->set_tooltip_deprecated("Next Note");
m_next_button->set_tooltip("Next Note"_string);
m_next_button->set_focus_policy(GUI::FocusPolicy::NoFocus);
m_next_button->on_click = [this](unsigned) {
m_track_manager.time_forward((sample_rate / (beats_per_minute / 60) / notes_per_beat));

View file

@ -180,7 +180,7 @@ ErrorOr<RefPtr<GUI::Widget>> FastBoxBlur::get_settings_widget()
m_gaussian_checkbox = gaussian_container.add<GUI::CheckBox>("Approximate Gaussian Blur"_string);
m_gaussian_checkbox->set_checked(m_approximate_gauss);
m_gaussian_checkbox->set_tooltip_deprecated("A real gaussian blur can be approximated by running the box blur multiple times with different weights.");
m_gaussian_checkbox->set_tooltip("A real gaussian blur can be approximated by running the box blur multiple times with different weights."_string);
m_gaussian_checkbox->on_checked = [this](bool checked) {
m_approximate_gauss = checked;
update_preview();

View file

@ -189,7 +189,7 @@ NonnullRefPtr<GUI::Widget> GuideTool::get_properties_widget()
auto& snapping_label = snapping_container.add<GUI::Label>("Snap offset:"_string);
snapping_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
snapping_label.set_fixed_size(80, 20);
snapping_label.set_tooltip_deprecated("Press Shift to snap");
snapping_label.set_tooltip("Press Shift to snap"_string);
auto& snapping_slider = snapping_container.add<GUI::ValueSlider>(Orientation::Horizontal, "px"_string);
snapping_slider.set_range(0, 50);

View file

@ -280,7 +280,7 @@ void TreeMapWidget::mousemove_event(GUI::MouseEvent& event)
{
auto* node = path_node(m_viewpoint);
if (!node) {
set_tooltip_deprecated({});
set_tooltip({});
return;
}
@ -291,7 +291,7 @@ void TreeMapWidget::mousemove_event(GUI::MouseEvent& event)
}
});
set_tooltip_deprecated(DeprecatedString::formatted("{}\n{}", hovered_node->name(), human_readable_size(hovered_node->area())));
set_tooltip(MUST(String::formatted("{}\n{}", hovered_node->name(), human_readable_size(hovered_node->area()))));
}
void TreeMapWidget::mousedown_event(GUI::MouseEvent& event)

View file

@ -46,7 +46,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, Vector<NonnullR
auto& help_button = top_bar.add<GUI::Button>();
help_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-help.png"sv).release_value_but_fixme_should_propagate_errors());
help_button.set_tooltip_deprecated("Functions Help");
help_button.set_tooltip("Functions Help"_string);
help_button.set_fixed_size(20, 20);
help_button.on_click = [&](auto) {
if (!current_view()) {

View file

@ -32,7 +32,7 @@ GitWidget::GitWidget()
auto& refresh_button = unstaged_header.add<GUI::Button>();
refresh_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"sv).release_value_but_fixme_should_propagate_errors());
refresh_button.set_fixed_size(16, 16);
refresh_button.set_tooltip_deprecated("refresh");
refresh_button.set_tooltip("refresh"_string);
refresh_button.on_click = [this](int) { refresh(); };
auto& unstaged_label = unstaged_header.add<GUI::Label>();
@ -62,7 +62,7 @@ GitWidget::GitWidget()
auto& commit_button = staged_header.add<GUI::Button>();
commit_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/commit.png"sv).release_value_but_fixme_should_propagate_errors());
commit_button.set_fixed_size(16, 16);
commit_button.set_tooltip_deprecated("commit");
commit_button.set_tooltip("commit"_string);
commit_button.on_click = [this](int) { commit(); };
auto& staged_label = staged_header.add<GUI::Label>();

View file

@ -144,7 +144,7 @@ auto EmojiInputDialog::supported_emoji() -> Vector<Emoji>
};
if (!emoji->name.is_empty())
button->set_tooltip_deprecated(emoji->name);
button->set_tooltip(MUST(String::from_utf8(emoji->name)));
emojis.empend(move(button), emoji.release_value(), move(text));
}

View file

@ -49,7 +49,7 @@ private:
if (action.group() && action.group()->is_exclusive())
set_exclusive(true);
set_action(action);
set_tooltip_deprecated(tooltip(action));
set_tooltip(tooltip(action));
set_focus_policy(FocusPolicy::NoFocus);
if (action.icon())
set_icon(action.icon());
@ -63,12 +63,12 @@ private:
auto const* action = this->action();
VERIFY(action);
set_tooltip_deprecated(tooltip(*action));
set_tooltip(tooltip(*action));
if (!action->icon())
Button::set_text(move(text));
}
DeprecatedString tooltip(Action const& action) const
String tooltip(Action const& action) const
{
StringBuilder builder;
builder.append(action.tooltip());
@ -77,7 +77,7 @@ private:
builder.append(action.shortcut().to_deprecated_string());
builder.append(')');
}
return builder.to_deprecated_string();
return MUST(builder.to_string());
}
virtual void enter_event(Core::Event& event) override

View file

@ -878,18 +878,18 @@ void TerminalWidget::mousemove_event(GUI::MouseEvent& event)
auto file_name = LexicalPath::basename(path);
if (path == handlers[0]) {
set_tooltip_deprecated(DeprecatedString::formatted("Execute {}", app_name));
set_tooltip(MUST(String::formatted("Execute {}", app_name)));
} else {
set_tooltip_deprecated(DeprecatedString::formatted("Open {} with {}", file_name, app_name));
set_tooltip(MUST(String::formatted("Open {} with {}", file_name, app_name)));
}
} else {
set_tooltip_deprecated(DeprecatedString::formatted("Open {} with {}", attribute.href, app_name));
set_tooltip(MUST(String::formatted("Open {} with {}", attribute.href, app_name)));
}
}
} else {
m_hovered_href_id = {};
m_hovered_href = {};
set_tooltip_deprecated({});
set_tooltip({});
}
show_or_hide_tooltip();
if (!m_hovered_href.is_empty())
@ -957,7 +957,7 @@ void TerminalWidget::leave_event(Core::Event&)
bool should_update = !m_hovered_href.is_empty();
m_hovered_href = {};
m_hovered_href_id = {};
set_tooltip_deprecated(m_hovered_href);
set_tooltip({});
set_override_cursor(Gfx::StandardCursor::IBeam);
if (should_update)
update();

View file

@ -30,7 +30,7 @@ ClockWidget::ClockWidget()
if (now != last_update_time) {
tick_clock();
last_update_time = now;
set_tooltip_deprecated(Core::DateTime::now().to_deprecated_string("%Y-%m-%d"sv));
set_tooltip(MUST(Core::DateTime::now().to_string("%Y-%m-%d"sv)));
}
});
m_timer->start();
@ -107,7 +107,7 @@ ClockWidget::ClockWidget()
m_jump_to_button->set_button_style(Gfx::ButtonStyle::Coolbar);
m_jump_to_button->set_fixed_size(24, 24);
m_jump_to_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/calendar-date.png"sv).release_value_but_fixme_should_propagate_errors());
m_jump_to_button->set_tooltip_deprecated("Jump to today");
m_jump_to_button->set_tooltip("Jump to today"_string);
m_jump_to_button->on_click = [this](auto) {
jump_to_current_date();
};
@ -116,7 +116,7 @@ ClockWidget::ClockWidget()
m_calendar_launcher->set_button_style(Gfx::ButtonStyle::Coolbar);
m_calendar_launcher->set_fixed_size(24, 24);
m_calendar_launcher->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-calendar.png"sv).release_value_but_fixme_should_propagate_errors());
m_calendar_launcher->set_tooltip_deprecated("Calendar");
m_calendar_launcher->set_tooltip("Calendar"_string);
m_calendar_launcher->on_click = [this](auto) {
GUI::Process::spawn_or_show_error(window(), "/bin/Calendar"sv);
};

View file

@ -89,7 +89,7 @@ ErrorOr<void> TaskbarWindow::populate_taskbar()
m_clock_widget = main_widget->add<Taskbar::ClockWidget>();
m_show_desktop_button = main_widget->add<GUI::Button>();
m_show_desktop_button->set_tooltip_deprecated("Show Desktop");
m_show_desktop_button->set_tooltip("Show Desktop"_string);
m_show_desktop_button->set_icon(TRY(GUI::Icon::try_create_default_icon("desktop"sv)).bitmap_for_size(16));
m_show_desktop_button->set_button_style(Gfx::ButtonStyle::Coolbar);
m_show_desktop_button->set_fixed_size(24, 24);