1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 19:17:44 +00:00

Everywhere: Use _{short_,}string to create Strings from literals

This commit is contained in:
Linus Groh 2023-02-25 16:40:37 +01:00
parent 85414d9338
commit 09d40bfbb2
92 changed files with 334 additions and 310 deletions

View file

@ -228,14 +228,14 @@ void ColorPicker::build_ui()
button_container.add_spacer().release_value_but_fixme_should_propagate_errors();
auto& ok_button = button_container.add<DialogButton>();
ok_button.set_text(String::from_utf8_short_string("OK"sv));
ok_button.set_text("OK"_short_string);
ok_button.on_click = [this](auto) {
done(ExecResult::OK);
};
ok_button.set_default(true);
auto& cancel_button = button_container.add<DialogButton>();
cancel_button.set_text(String::from_utf8_short_string("Cancel"sv));
cancel_button.set_text("Cancel"_short_string);
cancel_button.on_click = [this](auto) {
done(ExecResult::Cancel);
};
@ -407,7 +407,7 @@ void ColorPicker::build_ui_custom(Widget& root_container)
make_spinbox(Blue, m_color.blue());
make_spinbox(Alpha, m_color.alpha());
m_selector_button = vertical_container.add<GUI::Button>(String::from_utf8("Select on screen"sv).release_value_but_fixme_should_propagate_errors());
m_selector_button = vertical_container.add<GUI::Button>("Select on screen"_string.release_value_but_fixme_should_propagate_errors());
m_selector_button->on_click = [this](auto) {
auto selector = ColorSelectOverlay::construct();
auto original_color = m_color;

View file

@ -224,7 +224,7 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, StringView filename, St
ok_button.set_enabled(m_mode == Mode::OpenFolder || !m_filename_textbox->text().is_empty());
auto& cancel_button = *widget->find_descendant_of_type_named<GUI::Button>("cancel_button");
cancel_button.set_text(String::from_utf8_short_string("Cancel"sv));
cancel_button.set_text("Cancel"_short_string);
cancel_button.on_click = [this](auto) {
done(ExecResult::Cancel);
};

View file

@ -54,11 +54,11 @@ private:
case Mode::Open:
case Mode::OpenMultiple:
case Mode::OpenFolder:
return String::from_utf8_short_string("Open"sv);
return "Open"_short_string;
case Mode::Save:
return String::from_utf8_short_string("Save"sv);
return "Save"_short_string;
default:
return String::from_utf8_short_string("OK"sv);
return "OK"_short_string;
}
}

View file

@ -37,7 +37,7 @@ IncrementalSearchBanner::IncrementalSearchBanner(TextEditor& editor)
};
m_close_button = find_descendant_of_type_named<Button>("incremental_search_banner_close_button");
m_close_button->set_text(String::from_utf8_short_string("\xE2\x9D\x8C"sv));
m_close_button->set_text("\xE2\x9D\x8C"_short_string);
m_close_button->on_click = [this](auto) {
hide();
};

View file

@ -103,7 +103,7 @@ void InputBox::build()
button_container_inner.add_spacer().release_value_but_fixme_should_propagate_errors();
m_ok_button = button_container_inner.add<DialogButton>();
m_ok_button->set_text(String::from_utf8_short_string("OK"sv));
m_ok_button->set_text("OK"_short_string);
m_ok_button->on_click = [this](auto) {
dbgln("GUI::InputBox: OK button clicked");
done(ExecResult::OK);
@ -111,7 +111,7 @@ void InputBox::build()
m_ok_button->set_default(true);
m_cancel_button = button_container_inner.add<DialogButton>();
m_cancel_button->set_text(String::from_utf8_short_string("Cancel"sv));
m_cancel_button->set_text("Cancel"_short_string);
m_cancel_button->on_click = [this](auto) {
dbgln("GUI::InputBox: Cancel button clicked");
done(ExecResult::Cancel);

View file

@ -50,11 +50,11 @@ Dialog::ExecResult MessageBox::ask_about_unsaved_changes(Window* parent_window,
box->set_icon(parent_window->icon());
if (path.is_empty())
box->m_yes_button->set_text(String::from_utf8("Save As..."sv).release_value_but_fixme_should_propagate_errors());
box->m_yes_button->set_text("Save As..."_string.release_value_but_fixme_should_propagate_errors());
else
box->m_yes_button->set_text(String::from_utf8_short_string("Save"sv));
box->m_no_button->set_text(String::from_utf8_short_string("Discard"sv));
box->m_cancel_button->set_text(String::from_utf8_short_string("Cancel"sv));
box->m_yes_button->set_text("Save"_short_string);
box->m_no_button->set_text("Discard"_short_string);
box->m_cancel_button->set_text("Cancel"_short_string);
return box->exec();
}
@ -162,13 +162,13 @@ void MessageBox::build()
button_container.add_spacer().release_value_but_fixme_should_propagate_errors();
if (should_include_ok_button())
m_ok_button = add_button(String::from_utf8_short_string("OK"sv), ExecResult::OK);
m_ok_button = add_button("OK"_short_string, ExecResult::OK);
if (should_include_yes_button())
m_yes_button = add_button(String::from_utf8_short_string("Yes"sv), ExecResult::Yes);
m_yes_button = add_button("Yes"_short_string, ExecResult::Yes);
if (should_include_no_button())
m_no_button = add_button(String::from_utf8_short_string("No"sv), ExecResult::No);
m_no_button = add_button("No"_short_string, ExecResult::No);
if (should_include_cancel_button())
m_cancel_button = add_button(String::from_utf8_short_string("Cancel"sv), ExecResult::Cancel);
m_cancel_button = add_button("Cancel"_short_string, ExecResult::Cancel);
button_container.add_spacer().release_value_but_fixme_should_propagate_errors();
int width = (button_count * button_width) + ((button_count - 1) * button_container.layout()->spacing()) + 32;

View file

@ -61,7 +61,7 @@ ProcessChooser::ProcessChooser(StringView window_title, String button_label, Gfx
auto index = m_table_view->selection().first();
set_pid_from_index_and_close(index);
};
auto& cancel_button = button_container.add<GUI::Button>(String::from_utf8_short_string("Cancel"sv));
auto& cancel_button = button_container.add<GUI::Button>("Cancel"_short_string);
cancel_button.set_fixed_width(80);
cancel_button.on_click = [this](auto) {
done(ExecResult::Cancel);

View file

@ -23,7 +23,7 @@ public:
pid_t pid() const { return m_pid; }
private:
ProcessChooser(StringView window_title = "Process Chooser"sv, String button_label = String::from_utf8_short_string("Select"sv), Gfx::Bitmap const* window_icon = nullptr, GUI::Window* parent_window = nullptr);
ProcessChooser(StringView window_title = "Process Chooser"sv, String button_label = "Select"_short_string, Gfx::Bitmap const* window_icon = nullptr, GUI::Window* parent_window = nullptr);
void set_pid_from_index_and_close(ModelIndex const&);

View file

@ -43,7 +43,7 @@ ErrorOr<NonnullRefPtr<SettingsWindow>> SettingsWindow::create(DeprecatedString t
TRY(button_container->try_set_layout<GUI::HorizontalBoxLayout>(GUI::Margins {}, 6));
if (show_defaults_button == ShowDefaultsButton::Yes) {
window->m_reset_button = TRY(button_container->try_add<GUI::DialogButton>(TRY(String::from_utf8("Defaults"sv))));
window->m_reset_button = TRY(button_container->try_add<GUI::DialogButton>(TRY("Defaults"_string)));
window->m_reset_button->on_click = [window = window->make_weak_ptr<SettingsWindow>()](auto) {
window->reset_default_values();
};
@ -51,19 +51,19 @@ ErrorOr<NonnullRefPtr<SettingsWindow>> SettingsWindow::create(DeprecatedString t
TRY(button_container->add_spacer());
window->m_ok_button = TRY(button_container->try_add<GUI::DialogButton>(String::from_utf8_short_string("OK"sv)));
window->m_ok_button = TRY(button_container->try_add<GUI::DialogButton>("OK"_short_string));
window->m_ok_button->on_click = [window = window->make_weak_ptr<SettingsWindow>()](auto) {
window->apply_settings();
GUI::Application::the()->quit();
};
window->m_cancel_button = TRY(button_container->try_add<GUI::DialogButton>(String::from_utf8_short_string("Cancel"sv)));
window->m_cancel_button = TRY(button_container->try_add<GUI::DialogButton>("Cancel"_short_string));
window->m_cancel_button->on_click = [window = window->make_weak_ptr<SettingsWindow>()](auto) {
window->cancel_settings();
GUI::Application::the()->quit();
};
window->m_apply_button = TRY(button_container->try_add<GUI::DialogButton>(String::from_utf8_short_string("Apply"sv)));
window->m_apply_button = TRY(button_container->try_add<GUI::DialogButton>("Apply"_short_string));
window->m_apply_button->set_enabled(false);
window->m_apply_button->on_click = [window = window->make_weak_ptr<SettingsWindow>()](auto) {
window->apply_settings();

View file

@ -43,12 +43,12 @@ WizardDialog::WizardDialog(Window* parent_window)
nav_container_widget.set_fixed_height(42);
nav_container_widget.add_spacer().release_value_but_fixme_should_propagate_errors();
m_back_button = nav_container_widget.add<DialogButton>(String::from_utf8_short_string("< Back"sv));
m_back_button = nav_container_widget.add<DialogButton>("< Back"_short_string);
m_back_button->on_click = [&](auto) {
pop_page();
};
m_next_button = nav_container_widget.add<DialogButton>(String::from_utf8_short_string("Next >"sv));
m_next_button = nav_container_widget.add<DialogButton>("Next >"_short_string);
m_next_button->on_click = [&](auto) {
VERIFY(has_pages());
@ -65,7 +65,7 @@ WizardDialog::WizardDialog(Window* parent_window)
auto& button_spacer = nav_container_widget.add<Widget>();
button_spacer.set_fixed_width(10);
m_cancel_button = nav_container_widget.add<DialogButton>(String::from_utf8_short_string("Cancel"sv));
m_cancel_button = nav_container_widget.add<DialogButton>("Cancel"_short_string);
m_cancel_button->on_click = [&](auto) {
handle_cancel();
};
@ -120,11 +120,11 @@ void WizardDialog::update_navigation()
if (has_pages()) {
m_next_button->set_enabled(current_page().is_final_page() || current_page().can_go_next());
if (current_page().is_final_page())
m_next_button->set_text(String::from_utf8_short_string("Finish"sv));
m_next_button->set_text("Finish"_short_string);
else
m_next_button->set_text(String::from_utf8_short_string("Next >"sv));
m_next_button->set_text("Next >"_short_string);
} else {
m_next_button->set_text(String::from_utf8_short_string("Next >"sv));
m_next_button->set_text("Next >"_short_string);
m_next_button->set_enabled(false);
}
}