diff options
author | thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> | 2023-04-29 10:41:48 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-04-30 05:48:14 +0200 |
commit | 91bafc2653bcbcc0b8d05b5589324375b92f91b5 (patch) | |
tree | 3ebc611c104c9c1c47c4b85b594e36f91c66c026 /Userland/Libraries/LibGUI | |
parent | 3d53dc82283e7eccf7a27918dbbcd391dc4988f7 (diff) | |
download | serenity-91bafc2653bcbcc0b8d05b5589324375b92f91b5.zip |
LibGUI+Userland: Port Labels to String
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r-- | Userland/Libraries/LibGUI/AboutDialog.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Application.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/AutocompleteProvider.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/ColorPicker.cpp | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/FilePicker.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/IncrementalSearchBanner.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/InputBox.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Label.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Label.h | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/LinkLabel.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/LinkLabel.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/MessageBox.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/PasswordInputDialog.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Wizards/CoverWizardPage.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Wizards/WizardPage.cpp | 8 |
15 files changed, 35 insertions, 35 deletions
diff --git a/Userland/Libraries/LibGUI/AboutDialog.cpp b/Userland/Libraries/LibGUI/AboutDialog.cpp index b15802218c..b1e3d31fee 100644 --- a/Userland/Libraries/LibGUI/AboutDialog.cpp +++ b/Userland/Libraries/LibGUI/AboutDialog.cpp @@ -36,10 +36,10 @@ ErrorOr<NonnullRefPtr<AboutDialog>> AboutDialog::try_create(String name, String icon_wrapper->set_visible(false); } - widget->find_descendant_of_type_named<GUI::Label>("name")->set_text(name.to_deprecated_string()); + widget->find_descendant_of_type_named<GUI::Label>("name")->set_text(name); // If we are displaying a dialog for an application, insert 'SerenityOS' below the application name widget->find_descendant_of_type_named<GUI::Label>("serenity_os")->set_visible(name != "SerenityOS"); - widget->find_descendant_of_type_named<GUI::Label>("version")->set_text(version.to_deprecated_string()); + widget->find_descendant_of_type_named<GUI::Label>("version")->set_text(version); auto ok_button = widget->find_descendant_of_type_named<DialogButton>("ok_button"); ok_button->on_click = [dialog](auto) { diff --git a/Userland/Libraries/LibGUI/Application.cpp b/Userland/Libraries/LibGUI/Application.cpp index bac1d76841..f5be7b95ac 100644 --- a/Userland/Libraries/LibGUI/Application.cpp +++ b/Userland/Libraries/LibGUI/Application.cpp @@ -27,7 +27,7 @@ class Application::TooltipWindow final : public Window { public: void set_tooltip(DeprecatedString const& tooltip) { - m_label->set_text(Gfx::parse_ampersand_string(tooltip)); + m_label->set_text(String::from_deprecated_string(Gfx::parse_ampersand_string(tooltip)).release_value_but_fixme_should_propagate_errors()); int tooltip_width = m_label->effective_min_size().width().as_int() + 10; int line_count = m_label->text().count("\n"sv); int font_size = m_label->font().pixel_size_rounded_up(); diff --git a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp index fd7db85142..60ac4744d1 100644 --- a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp +++ b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp @@ -109,7 +109,7 @@ AutocompleteBox::AutocompleteBox(TextEditor& editor) apply_suggestion(); }; - m_no_suggestions_view = main_widget->add<GUI::Label>("No suggestions"); + m_no_suggestions_view = main_widget->add<GUI::Label>("No suggestions"_string.release_value_but_fixme_should_propagate_errors()); } void AutocompleteBox::update_suggestions(Vector<CodeComprehension::AutocompleteResultEntry>&& suggestions) diff --git a/Userland/Libraries/LibGUI/ColorPicker.cpp b/Userland/Libraries/LibGUI/ColorPicker.cpp index 8983fe93ee..451b1679a1 100644 --- a/Userland/Libraries/LibGUI/ColorPicker.cpp +++ b/Userland/Libraries/LibGUI/ColorPicker.cpp @@ -332,7 +332,7 @@ void ColorPicker::build_ui_custom(Widget& root_container) auto& html_label = html_container.add<GUI::Label>(); html_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); html_label.set_preferred_width(48); - html_label.set_text("HTML:"); + html_label.set_text("HTML:"_short_string); m_html_text = html_container.add<GUI::TextBox>(); m_html_text->set_text(m_color_has_alpha_channel ? m_color.to_deprecated_string() : m_color.to_deprecated_string_without_alpha()); @@ -388,16 +388,16 @@ void ColorPicker::build_ui_custom(Widget& root_container) }; if (component == Red) { - rgb_label.set_text("Red:"); + rgb_label.set_text("Red:"_short_string); m_red_spinbox = spinbox; } else if (component == Green) { - rgb_label.set_text("Green:"); + rgb_label.set_text("Green:"_short_string); m_green_spinbox = spinbox; } else if (component == Blue) { - rgb_label.set_text("Blue:"); + rgb_label.set_text("Blue:"_short_string); m_blue_spinbox = spinbox; } else if (component == Alpha) { - rgb_label.set_text("Alpha:"); + rgb_label.set_text("Alpha:"_short_string); m_alpha_spinbox = spinbox; } }; diff --git a/Userland/Libraries/LibGUI/FilePicker.cpp b/Userland/Libraries/LibGUI/FilePicker.cpp index fbef90de65..59927b525d 100644 --- a/Userland/Libraries/LibGUI/FilePicker.cpp +++ b/Userland/Libraries/LibGUI/FilePicker.cpp @@ -272,7 +272,7 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, StringView filename, St }; m_model->on_directory_change_error = [&](int, char const* error_string) { - m_error_label->set_text(DeprecatedString::formatted("Could not open {}:\n{}", m_model->root_path(), error_string)); + m_error_label->set_text(String::formatted("Could not open {}:\n{}", m_model->root_path(), error_string).release_value_but_fixme_should_propagate_errors()); m_view->set_active_widget(m_error_label); m_view->view_as_icons_action().set_enabled(false); diff --git a/Userland/Libraries/LibGUI/IncrementalSearchBanner.cpp b/Userland/Libraries/LibGUI/IncrementalSearchBanner.cpp index ecba03dd3a..7437411530 100644 --- a/Userland/Libraries/LibGUI/IncrementalSearchBanner.cpp +++ b/Userland/Libraries/LibGUI/IncrementalSearchBanner.cpp @@ -93,7 +93,7 @@ void IncrementalSearchBanner::search(TextEditor::SearchDirection direction) auto needle = m_search_textbox->text(); if (needle.is_empty()) { m_editor->reset_search_results(); - m_index_label->set_text(DeprecatedString::empty()); + m_index_label->set_text({}); return; } @@ -107,9 +107,9 @@ void IncrementalSearchBanner::search(TextEditor::SearchDirection direction) auto result = m_editor->find_text(needle, direction, m_wrap_search, false, m_match_case); index = m_editor->search_result_index().value_or(0) + 1; if (result.is_valid()) - m_index_label->set_text(DeprecatedString::formatted("{} of {}", index, m_editor->search_results().size())); + m_index_label->set_text(String::formatted("{} of {}", index, m_editor->search_results().size()).release_value_but_fixme_should_propagate_errors()); else - m_index_label->set_text(DeprecatedString::empty()); + m_index_label->set_text({}); } void IncrementalSearchBanner::paint_event(PaintEvent& event) diff --git a/Userland/Libraries/LibGUI/InputBox.cpp b/Userland/Libraries/LibGUI/InputBox.cpp index 445741f53c..0f98aa23b2 100644 --- a/Userland/Libraries/LibGUI/InputBox.cpp +++ b/Userland/Libraries/LibGUI/InputBox.cpp @@ -151,7 +151,7 @@ ErrorOr<void> InputBox::build() m_prompt_label->set_autosize(true); m_prompt_label->set_text_wrapping(Gfx::TextWrapping::DontWrap); m_prompt_label->set_text_alignment(Gfx::TextAlignment::CenterLeft); - m_prompt_label->set_text(move(m_prompt).to_deprecated_string()); + m_prompt_label->set_text(move(m_prompt)); } switch (m_input_type) { diff --git a/Userland/Libraries/LibGUI/Label.cpp b/Userland/Libraries/LibGUI/Label.cpp index 8d69b7332a..7368d50976 100644 --- a/Userland/Libraries/LibGUI/Label.cpp +++ b/Userland/Libraries/LibGUI/Label.cpp @@ -16,7 +16,7 @@ REGISTER_WIDGET(GUI, Label) namespace GUI { -Label::Label(DeprecatedString text) +Label::Label(String text) : m_text(move(text)) { REGISTER_TEXT_ALIGNMENT_PROPERTY("text_alignment", text_alignment, set_text_alignment); @@ -31,7 +31,7 @@ Label::Label(DeprecatedString text) set_foreground_role(Gfx::ColorRole::WindowText); - REGISTER_DEPRECATED_STRING_PROPERTY("text", text, set_text); + REGISTER_STRING_PROPERTY("text", text, set_text); REGISTER_BOOL_PROPERTY("autosize", is_autosize, set_autosize); REGISTER_WRITE_ONLY_STRING_PROPERTY("icon", set_icon_from_path); } @@ -54,7 +54,7 @@ void Label::set_icon(Gfx::Bitmap const* icon) update(); } -void Label::set_icon_from_path(DeprecatedString const& path) +void Label::set_icon_from_path(StringView path) { auto maybe_bitmap = Gfx::Bitmap::load_from_file(path); if (maybe_bitmap.is_error()) { @@ -64,7 +64,7 @@ void Label::set_icon_from_path(DeprecatedString const& path) set_icon(maybe_bitmap.release_value()); } -void Label::set_text(DeprecatedString text) +void Label::set_text(String text) { if (text == m_text) return; diff --git a/Userland/Libraries/LibGUI/Label.h b/Userland/Libraries/LibGUI/Label.h index 65f52dc381..e6499180c6 100644 --- a/Userland/Libraries/LibGUI/Label.h +++ b/Userland/Libraries/LibGUI/Label.h @@ -19,11 +19,11 @@ class Label : public Frame { public: virtual ~Label() override = default; - DeprecatedString text() const { return m_text; } - void set_text(DeprecatedString); + String const& text() const { return m_text; } + void set_text(String); void set_icon(Gfx::Bitmap const*); - void set_icon_from_path(DeprecatedString const&); + void set_icon_from_path(StringView); Gfx::Bitmap const* icon() const { return m_icon.ptr(); } Gfx::TextAlignment text_alignment() const { return m_text_alignment; } @@ -46,7 +46,7 @@ public: Gfx::IntRect text_rect() const; protected: - explicit Label(DeprecatedString text = {}); + explicit Label(String text = {}); virtual void paint_event(PaintEvent&) override; virtual void did_change_font() override; @@ -55,7 +55,7 @@ protected: private: void size_to_fit(); - DeprecatedString m_text; + String m_text; RefPtr<Gfx::Bitmap const> m_icon; Gfx::TextAlignment m_text_alignment { Gfx::TextAlignment::Center }; Gfx::TextWrapping m_text_wrapping { Gfx::TextWrapping::Wrap }; diff --git a/Userland/Libraries/LibGUI/LinkLabel.cpp b/Userland/Libraries/LibGUI/LinkLabel.cpp index fff58244fb..829353d909 100644 --- a/Userland/Libraries/LibGUI/LinkLabel.cpp +++ b/Userland/Libraries/LibGUI/LinkLabel.cpp @@ -19,7 +19,7 @@ REGISTER_WIDGET(GUI, LinkLabel) namespace GUI { -LinkLabel::LinkLabel(DeprecatedString text) +LinkLabel::LinkLabel(String text) : Label(move(text)) { set_foreground_role(Gfx::ColorRole::Link); @@ -102,7 +102,7 @@ void LinkLabel::did_change_text() void LinkLabel::update_tooltip_if_needed() { if (width() < font().width(text())) { - set_tooltip(text()); + set_tooltip(text().to_deprecated_string()); } else { set_tooltip({}); } diff --git a/Userland/Libraries/LibGUI/LinkLabel.h b/Userland/Libraries/LibGUI/LinkLabel.h index 0701a40eea..36175936a7 100644 --- a/Userland/Libraries/LibGUI/LinkLabel.h +++ b/Userland/Libraries/LibGUI/LinkLabel.h @@ -17,7 +17,7 @@ public: Function<void()> on_click; private: - explicit LinkLabel(DeprecatedString text = {}); + explicit LinkLabel(String text = {}); virtual void mousemove_event(MouseEvent&) override; virtual void mousedown_event(MouseEvent&) override; diff --git a/Userland/Libraries/LibGUI/MessageBox.cpp b/Userland/Libraries/LibGUI/MessageBox.cpp index 9047ba65b4..a19f2753b2 100644 --- a/Userland/Libraries/LibGUI/MessageBox.cpp +++ b/Userland/Libraries/LibGUI/MessageBox.cpp @@ -87,7 +87,7 @@ ErrorOr<Dialog::ExecResult> MessageBox::try_ask_about_unsaved_changes(Window* pa void MessageBox::set_text(String text) { - m_text_label->set_text(move(text).to_deprecated_string()); + m_text_label->set_text(move(text)); } MessageBox::MessageBox(Window* parent_window, Type type, InputType input_type) diff --git a/Userland/Libraries/LibGUI/PasswordInputDialog.cpp b/Userland/Libraries/LibGUI/PasswordInputDialog.cpp index f7b4d36997..ee046d9546 100644 --- a/Userland/Libraries/LibGUI/PasswordInputDialog.cpp +++ b/Userland/Libraries/LibGUI/PasswordInputDialog.cpp @@ -30,10 +30,10 @@ PasswordInputDialog::PasswordInputDialog(Window* parent_window, DeprecatedString key_icon_label.set_icon(Gfx::Bitmap::load_from_file("/res/icons/32x32/key.png"sv).release_value_but_fixme_should_propagate_errors()); auto& server_label = *widget->find_descendant_of_type_named<GUI::Label>("server_label"); - server_label.set_text(move(server)); + server_label.set_text(String::from_deprecated_string(server).release_value_but_fixme_should_propagate_errors()); auto& username_label = *widget->find_descendant_of_type_named<GUI::Label>("username_label"); - username_label.set_text(move(username)); + username_label.set_text(String::from_deprecated_string(username).release_value_but_fixme_should_propagate_errors()); auto& password_box = *widget->find_descendant_of_type_named<GUI::PasswordBox>("password_box"); diff --git a/Userland/Libraries/LibGUI/Wizards/CoverWizardPage.cpp b/Userland/Libraries/LibGUI/Wizards/CoverWizardPage.cpp index c054f7968e..5183b4c290 100644 --- a/Userland/Libraries/LibGUI/Wizards/CoverWizardPage.cpp +++ b/Userland/Libraries/LibGUI/Wizards/CoverWizardPage.cpp @@ -37,12 +37,12 @@ CoverWizardPage::CoverWizardPage() void CoverWizardPage::set_header_text(DeprecatedString const& text) { - m_header_label->set_text(text); + m_header_label->set_text(String::from_deprecated_string(text).release_value_but_fixme_should_propagate_errors()); } void CoverWizardPage::set_body_text(DeprecatedString const& text) { - m_body_label->set_text(text); + m_body_label->set_text(String::from_deprecated_string(text).release_value_but_fixme_should_propagate_errors()); } } diff --git a/Userland/Libraries/LibGUI/Wizards/WizardPage.cpp b/Userland/Libraries/LibGUI/Wizards/WizardPage.cpp index 35b0037fe2..b1d1fd1075 100644 --- a/Userland/Libraries/LibGUI/Wizards/WizardPage.cpp +++ b/Userland/Libraries/LibGUI/Wizards/WizardPage.cpp @@ -25,11 +25,11 @@ WizardPage::WizardPage(DeprecatedString const& title_text, DeprecatedString cons header_widget.set_fixed_height(58); header_widget.set_layout<VerticalBoxLayout>(GUI::Margins { 15, 30, 0 }); - m_title_label = header_widget.add<Label>(title_text); + m_title_label = header_widget.add<Label>(String::from_deprecated_string(title_text).release_value_but_fixme_should_propagate_errors()); m_title_label->set_font(Gfx::FontDatabase::default_font().bold_variant()); m_title_label->set_fixed_height(m_title_label->font().pixel_size_rounded_up() + 2); m_title_label->set_text_alignment(Gfx::TextAlignment::TopLeft); - m_subtitle_label = header_widget.add<Label>(subtitle_text); + m_subtitle_label = header_widget.add<Label>(String::from_deprecated_string(subtitle_text).release_value_but_fixme_should_propagate_errors()); m_subtitle_label->set_text_alignment(Gfx::TextAlignment::TopLeft); m_subtitle_label->set_fixed_height(m_subtitle_label->font().pixel_size_rounded_up()); header_widget.add_spacer().release_value_but_fixme_should_propagate_errors(); @@ -43,12 +43,12 @@ WizardPage::WizardPage(DeprecatedString const& title_text, DeprecatedString cons void WizardPage::set_page_title(DeprecatedString const& text) { - m_title_label->set_text(text); + m_title_label->set_text(String::from_deprecated_string(text).release_value_but_fixme_should_propagate_errors()); } void WizardPage::set_page_subtitle(DeprecatedString const& text) { - m_subtitle_label->set_text(text); + m_subtitle_label->set_text(String::from_deprecated_string(text).release_value_but_fixme_should_propagate_errors()); } } |