mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:07:34 +00:00
Userland: Set Button text using the new String class
This commit is contained in:
parent
b5cb9a9ebb
commit
e39adc4772
49 changed files with 134 additions and 127 deletions
|
@ -78,7 +78,7 @@ ShutdownDialog::ShutdownDialog()
|
|||
auto action = options[i];
|
||||
auto& radio = right_container.add<GUI::RadioButton>();
|
||||
radio.set_enabled(action.enabled);
|
||||
radio.set_text_deprecated(action.title);
|
||||
radio.set_text(String::from_deprecated_string(action.title).release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
radio.on_checked = [this, i](auto) {
|
||||
m_selected_option = i;
|
||||
|
@ -97,13 +97,13 @@ ShutdownDialog::ShutdownDialog()
|
|||
button_container.set_layout<GUI::HorizontalBoxLayout>();
|
||||
button_container.layout()->set_spacing(5);
|
||||
button_container.layout()->add_spacer();
|
||||
auto& ok_button = button_container.add<GUI::Button>("OK");
|
||||
auto& ok_button = button_container.add<GUI::Button>(String::from_utf8_short_string("OK"sv));
|
||||
ok_button.set_fixed_size(80, 23);
|
||||
ok_button.on_click = [this](auto) {
|
||||
done(ExecResult::OK);
|
||||
};
|
||||
ok_button.set_default(true);
|
||||
auto& cancel_button = button_container.add<GUI::Button>("Cancel");
|
||||
auto& cancel_button = button_container.add<GUI::Button>(String::from_utf8_short_string("Cancel"sv));
|
||||
cancel_button.set_fixed_size(80, 23);
|
||||
cancel_button.on_click = [this](auto) {
|
||||
done(ExecResult::Cancel);
|
||||
|
|
|
@ -93,20 +93,20 @@ void TaskbarButton::paint_event(GUI::PaintEvent& event)
|
|||
|
||||
Gfx::StylePainter::paint_button(painter, rect(), palette(), button_style(), is_being_pressed(), is_hovered(), is_checked(), is_enabled());
|
||||
|
||||
if (text_deprecated().is_empty())
|
||||
if (text().is_empty())
|
||||
return;
|
||||
|
||||
auto content_rect = rect().shrunken(8, 2);
|
||||
auto icon_location = content_rect.center().translated(-(icon.width() / 2), -(icon.height() / 2));
|
||||
if (!text_deprecated().is_empty())
|
||||
if (!text().is_empty())
|
||||
icon_location.set_x(content_rect.x());
|
||||
|
||||
if (!text_deprecated().is_empty()) {
|
||||
if (!text().is_empty()) {
|
||||
content_rect.translate_by(icon.width() + 4, 0);
|
||||
content_rect.set_width(content_rect.width() - icon.width() - 4);
|
||||
}
|
||||
|
||||
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());
|
||||
|
@ -123,7 +123,7 @@ void TaskbarButton::paint_event(GUI::PaintEvent& event)
|
|||
adjusted_rect.set_width(adjusted_rect.width() + 1);
|
||||
adjusted_rect.set_height(adjusted_rect.height() + 1);
|
||||
}
|
||||
paint_custom_progressbar(painter, adjusted_rect, text_rect, palette(), 0, 100, window.progress().value(), text_deprecated(), font, text_alignment());
|
||||
paint_custom_progressbar(painter, adjusted_rect, text_rect, palette(), 0, 100, window.progress().value(), text(), font, text_alignment());
|
||||
}
|
||||
|
||||
if (is_enabled()) {
|
||||
|
|
|
@ -114,7 +114,7 @@ void TaskbarWindow::add_system_menu(NonnullRefPtr<GUI::Menu> system_menu)
|
|||
{
|
||||
m_system_menu = move(system_menu);
|
||||
|
||||
m_start_button = GUI::Button::construct("Serenity");
|
||||
m_start_button = GUI::Button::construct(String::from_utf8("Serenity"sv).release_value_but_fixme_should_propagate_errors());
|
||||
set_start_button_font(Gfx::FontDatabase::default_font().bold_variant());
|
||||
m_start_button->set_icon_spacing(0);
|
||||
auto app_icon = GUI::Icon::default_icon("ladyball"sv);
|
||||
|
@ -202,7 +202,7 @@ void TaskbarWindow::update_window_button(::Window& window, bool show_as_active)
|
|||
auto* button = window.button();
|
||||
if (!button)
|
||||
return;
|
||||
button->set_text_deprecated(window.title());
|
||||
button->set_text(String::from_deprecated_string(window.title()).release_value_but_fixme_should_propagate_errors());
|
||||
button->set_tooltip(window.title());
|
||||
button->set_checked(show_as_active);
|
||||
button->set_visible(is_window_on_current_workspace(window));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue