mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 18:57:42 +00:00
Userland: Replace usages of AbstractButton::text_deprecated with text()
This commit is contained in:
parent
fca29eae09
commit
d32d4029d3
9 changed files with 25 additions and 25 deletions
|
@ -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());
|
||||
|
|
|
@ -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); }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue