mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 08:57:47 +00:00
LibGUI+Userland: Port Labels to String
This commit is contained in:
parent
3d53dc8228
commit
91bafc2653
92 changed files with 240 additions and 242 deletions
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 };
|
||||
|
|
|
@ -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({});
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue