summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarol Kosek <krkk@serenityos.org>2023-02-12 11:40:58 +0100
committerLinus Groh <mail@linusgroh.de>2023-02-13 00:45:09 +0000
commitd32d4029d34e3181635e52ef88fbf934b3a0f5ae (patch)
tree71d9d418b03a9080687ea4b27a7cd05249a9a137
parentfca29eae0988a46c3297a1dc515a8ca5ade40c6e (diff)
downloadserenity-d32d4029d34e3181635e52ef88fbf934b3a0f5ae.zip
Userland: Replace usages of AbstractButton::text_deprecated with text()
-rw-r--r--Userland/Applications/Assistant/main.cpp4
-rw-r--r--Userland/Applications/Browser/BookmarksBarWidget.cpp2
-rw-r--r--Userland/Applications/KeyboardMapper/KeyButton.cpp6
-rw-r--r--Userland/Libraries/LibGUI/AbstractButton.cpp8
-rw-r--r--Userland/Libraries/LibGUI/Button.cpp14
-rw-r--r--Userland/Libraries/LibGUI/CheckBox.cpp4
-rw-r--r--Userland/Libraries/LibGUI/RadioButton.cpp4
-rw-r--r--Userland/Libraries/LibGUI/Statusbar.cpp6
-rw-r--r--Userland/Services/Taskbar/TaskbarWindow.cpp2
9 files changed, 25 insertions, 25 deletions
diff --git a/Userland/Applications/Assistant/main.cpp b/Userland/Applications/Assistant/main.cpp
index 9a672c40a2..55e04052da 100644
--- a/Userland/Applications/Assistant/main.cpp
+++ b/Userland/Applications/Assistant/main.cpp
@@ -57,7 +57,7 @@ class ResultRow final : public GUI::Button {
if (!m_context_menu) {
m_context_menu = GUI::Menu::construct();
- if (LexicalPath path { text_deprecated() }; path.is_absolute()) {
+ if (LexicalPath path { text().to_deprecated_string() }; path.is_absolute()) {
m_context_menu->add_action(GUI::Action::create("&Show in File Manager", MUST(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-file-manager.png"sv)), [=](auto&) {
Desktop::Launcher::open(URL::create_with_file_scheme(path.dirname(), path.basename()));
}));
@@ -65,7 +65,7 @@ class ResultRow final : public GUI::Button {
}
m_context_menu->add_action(GUI::Action::create("&Copy as Text", MUST(Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-copy.png"sv)), [&](auto&) {
- GUI::Clipboard::the().set_plain_text(text_deprecated());
+ GUI::Clipboard::the().set_plain_text(text());
}));
}
m_context_menu->popup(event.screen_position());
diff --git a/Userland/Applications/Browser/BookmarksBarWidget.cpp b/Userland/Applications/Browser/BookmarksBarWidget.cpp
index 48207ee1e0..069de668fc 100644
--- a/Userland/Applications/Browser/BookmarksBarWidget.cpp
+++ b/Userland/Applications/Browser/BookmarksBarWidget.cpp
@@ -264,7 +264,7 @@ void BookmarksBarWidget::update_content_size()
for (size_t i = m_last_visible_index; i < m_bookmarks.size(); ++i) {
auto& bookmark = m_bookmarks.at(i);
bookmark.set_visible(false);
- m_additional_menu->add_action(GUI::Action::create(bookmark.text_deprecated(), g_icon_bag.filetype_html, [&](auto&) { bookmark.on_click(0); }));
+ m_additional_menu->add_action(GUI::Action::create(bookmark.text().to_deprecated_string(), g_icon_bag.filetype_html, [&](auto&) { bookmark.on_click(0); }));
}
}
}
diff --git a/Userland/Applications/KeyboardMapper/KeyButton.cpp b/Userland/Applications/KeyboardMapper/KeyButton.cpp
index c444a3df6b..5c5b7abca6 100644
--- a/Userland/Applications/KeyboardMapper/KeyButton.cpp
+++ b/Userland/Applications/KeyboardMapper/KeyButton.cpp
@@ -38,13 +38,13 @@ void KeyButton::paint_event(GUI::PaintEvent& event)
painter.draw_rect(key_cap_face_border_rect, Color::from_rgb(0x8C7272), false);
painter.fill_rect(key_cap_face_rect, face_color);
- if (text_deprecated().is_empty() || text_deprecated().starts_with('\0'))
+ if (text().is_empty() || text().bytes_as_string_view().starts_with('\0'))
return;
- Gfx::IntRect text_rect { 0, 0, static_cast<int>(ceilf(font.width(text_deprecated()))), font.glyph_height() };
+ Gfx::IntRect text_rect { 0, 0, static_cast<int>(ceilf(font.width(text()))), font.glyph_height() };
text_rect.align_within(key_cap_face_rect, Gfx::TextAlignment::Center);
- painter.draw_text(text_rect, text_deprecated(), font, Gfx::TextAlignment::Center, Color::Black, Gfx::TextElision::Right);
+ painter.draw_text(text_rect, text(), font, Gfx::TextAlignment::Center, Color::Black, Gfx::TextElision::Right);
if (is_focused())
painter.draw_rect(text_rect.inflated(6, 4), palette().focus_outline());
}
diff --git a/Userland/Libraries/LibGUI/AbstractButton.cpp b/Userland/Libraries/LibGUI/AbstractButton.cpp
index e8efed323c..9de91b683f 100644
--- a/Userland/Libraries/LibGUI/AbstractButton.cpp
+++ b/Userland/Libraries/LibGUI/AbstractButton.cpp
@@ -243,14 +243,14 @@ void AbstractButton::paint_text(Painter& painter, Gfx::IntRect const& rect, Gfx:
auto clipped_rect = rect.intersected(this->rect());
if (!is_enabled()) {
- painter.draw_text(clipped_rect.translated(1, 1), text_deprecated(), font, text_alignment, palette().disabled_text_back(), Gfx::TextElision::Right, text_wrapping);
- painter.draw_text(clipped_rect, text_deprecated(), font, text_alignment, palette().disabled_text_front(), Gfx::TextElision::Right, text_wrapping);
+ painter.draw_text(clipped_rect.translated(1, 1), text(), font, text_alignment, palette().disabled_text_back(), Gfx::TextElision::Right, text_wrapping);
+ painter.draw_text(clipped_rect, text(), font, text_alignment, palette().disabled_text_front(), Gfx::TextElision::Right, text_wrapping);
return;
}
- if (text_deprecated().is_empty())
+ if (text().is_empty())
return;
- painter.draw_text(clipped_rect, text_deprecated(), font, text_alignment, palette().color(foreground_role()), Gfx::TextElision::Right, text_wrapping);
+ painter.draw_text(clipped_rect, text(), font, text_alignment, palette().color(foreground_role()), Gfx::TextElision::Right, text_wrapping);
}
void AbstractButton::change_event(Event& event)
diff --git a/Userland/Libraries/LibGUI/Button.cpp b/Userland/Libraries/LibGUI/Button.cpp
index 6f24d17786..9536d27037 100644
--- a/Userland/Libraries/LibGUI/Button.cpp
+++ b/Userland/Libraries/LibGUI/Button.cpp
@@ -66,12 +66,12 @@ void Button::paint_event(PaintEvent& event)
Gfx::StylePainter::paint_button(painter, rect(), palette(), m_button_style, paint_pressed, is_hovered(), is_checked(), is_enabled(), is_focused(), is_default() && !another_button_has_focus());
- if (text_deprecated().is_empty() && !m_icon)
+ if (text().is_empty() && !m_icon)
return;
auto content_rect = rect().shrunken(8, 2);
auto icon_location = m_icon ? content_rect.center().translated(-(m_icon->width() / 2), -(m_icon->height() / 2)) : Gfx::IntPoint();
- if (m_icon && !text_deprecated().is_empty())
+ if (m_icon && !text().is_empty())
icon_location.set_x(content_rect.x());
if (paint_pressed || is_checked()) {
@@ -108,12 +108,12 @@ void Button::paint_event(PaintEvent& event)
m_icon->invert();
}
auto& font = is_checked() ? this->font().bold_variant() : this->font();
- if (m_icon && !text_deprecated().is_empty()) {
+ if (m_icon && !text().is_empty()) {
content_rect.translate_by(m_icon->width() + icon_spacing(), 0);
content_rect.set_width(content_rect.width() - m_icon->width() - icon_spacing());
}
- Gfx::IntRect text_rect { 0, 0, static_cast<int>(ceilf(font.width(text_deprecated()))), font.glyph_height() };
+ Gfx::IntRect text_rect { 0, 0, static_cast<int>(ceilf(font.width(text()))), font.glyph_height() };
if (text_rect.width() > content_rect.width())
text_rect.set_width(content_rect.width());
text_rect.align_within(content_rect, text_alignment());
@@ -121,7 +121,7 @@ void Button::paint_event(PaintEvent& event)
if (is_focused()) {
Gfx::IntRect focus_rect;
- if (m_icon && !text_deprecated().is_empty())
+ if (m_icon && !text().is_empty())
focus_rect = text_rect.inflated(4, 4);
else
focus_rect = rect().shrunken(8, 8);
@@ -279,9 +279,9 @@ Optional<UISize> Button::calculated_min_size() const
{
int horizontal = 0, vertical = 0;
- if (!text_deprecated().is_empty()) {
+ if (!text().is_empty()) {
auto& font = this->font();
- horizontal = font.width(text_deprecated()) + 2;
+ horizontal = font.width(text()) + 2;
vertical = font.glyph_height() + 4; // FIXME: Use actual maximum total height
}
diff --git a/Userland/Libraries/LibGUI/CheckBox.cpp b/Userland/Libraries/LibGUI/CheckBox.cpp
index 8fdf0ab05b..3da479ce83 100644
--- a/Userland/Libraries/LibGUI/CheckBox.cpp
+++ b/Userland/Libraries/LibGUI/CheckBox.cpp
@@ -47,7 +47,7 @@ void CheckBox::paint_event(PaintEvent& event)
auto text_rect = rect();
if (m_checkbox_position == CheckBoxPosition::Left)
text_rect.set_left(s_box_width + s_horizontal_padding);
- text_rect.set_width(font().width(text_deprecated()));
+ text_rect.set_width(font().width(text()));
text_rect.set_top(height() / 2 - font().glyph_height() / 2);
text_rect.set_height(font().glyph_height());
@@ -90,7 +90,7 @@ void CheckBox::set_autosize(bool autosize)
void CheckBox::size_to_fit()
{
- set_fixed_width(s_box_width + font().width(text_deprecated()) + s_horizontal_padding * 2);
+ set_fixed_width(s_box_width + font().width(text()) + s_horizontal_padding * 2);
}
}
diff --git a/Userland/Libraries/LibGUI/RadioButton.cpp b/Userland/Libraries/LibGUI/RadioButton.cpp
index f0c387ad87..73fe040497 100644
--- a/Userland/Libraries/LibGUI/RadioButton.cpp
+++ b/Userland/Libraries/LibGUI/RadioButton.cpp
@@ -51,7 +51,7 @@ void RadioButton::paint_event(PaintEvent& event)
Gfx::StylePainter::paint_radio_button(painter, circle_rect, palette(), is_checked(), is_being_pressed());
- Gfx::IntRect text_rect { circle_rect.right() + 7, 0, static_cast<int>(ceilf(font().width(text_deprecated()))), font().glyph_height() };
+ Gfx::IntRect text_rect { circle_rect.right() + 7, 0, static_cast<int>(ceilf(font().width(text()))), font().glyph_height() };
text_rect.center_vertically_within(rect());
paint_text(painter, text_rect, font(), Gfx::TextAlignment::TopLeft);
@@ -71,7 +71,7 @@ Optional<UISize> RadioButton::calculated_min_size() const
int horizontal = 2 + 7, vertical = 0;
auto& font = this->font();
vertical = max(font.glyph_height(), circle_size().height());
- horizontal += font.width(text_deprecated());
+ horizontal += font.width(text());
return UISize(horizontal, vertical);
}
diff --git a/Userland/Libraries/LibGUI/Statusbar.cpp b/Userland/Libraries/LibGUI/Statusbar.cpp
index 73c2d0450a..ab6cd6e697 100644
--- a/Userland/Libraries/LibGUI/Statusbar.cpp
+++ b/Userland/Libraries/LibGUI/Statusbar.cpp
@@ -104,7 +104,7 @@ void Statusbar::update_segment(size_t index)
DeprecatedString Statusbar::text(size_t index) const
{
- return m_segments.at(index).text_deprecated();
+ return m_segments.at(index).text().to_deprecated_string();
}
void Statusbar::set_text(DeprecatedString text)
@@ -157,8 +157,8 @@ void Statusbar::Segment::paint_event(PaintEvent& event)
if (is_clickable())
Button::paint_event(event);
- else if (!text_deprecated().is_empty())
- painter.draw_text(rect().shrunken(font().max_glyph_width(), 0), text_deprecated(), text_alignment(), palette().color(foreground_role()), Gfx::TextElision::Right, Gfx::TextWrapping::DontWrap);
+ else if (!text().is_empty())
+ painter.draw_text(rect().shrunken(font().max_glyph_width(), 0), text(), text_alignment(), palette().color(foreground_role()), Gfx::TextElision::Right, Gfx::TextWrapping::DontWrap);
}
void Statusbar::Segment::mousedown_event(MouseEvent& event)
diff --git a/Userland/Services/Taskbar/TaskbarWindow.cpp b/Userland/Services/Taskbar/TaskbarWindow.cpp
index a94fc07d67..648fe65d97 100644
--- a/Userland/Services/Taskbar/TaskbarWindow.cpp
+++ b/Userland/Services/Taskbar/TaskbarWindow.cpp
@@ -393,5 +393,5 @@ void TaskbarWindow::workspace_change_event(unsigned current_row, unsigned curren
void TaskbarWindow::set_start_button_font(Gfx::Font const& font)
{
m_start_button->set_font(font);
- m_start_button->set_fixed_size(font.width(m_start_button->text_deprecated()) + 30, 21);
+ m_start_button->set_fixed_size(font.width(m_start_button->text()) + 30, 21);
}