mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
LibGUI+Userland: Port StatusBar::text() and set_text functions to String
This commit is contained in:
parent
2064f544c6
commit
2029750519
Notes:
sideshowbarker
2024-07-16 22:17:03 +09:00
Author: https://github.com/krkk Commit: https://github.com/SerenityOS/serenity/commit/2029750519 Pull-request: https://github.com/SerenityOS/serenity/pull/19257 Reviewed-by: https://github.com/AtkinsSJ ✅
@ -91,7 +91,7 @@ void Tab::view_source(const URL& url, DeprecatedString const& source)
|
||||
window->show();
|
||||
}
|
||||
|
||||
void Tab::update_status(Optional<DeprecatedString> text_override, i32 count_waiting)
|
||||
void Tab::update_status(Optional<String> text_override, i32 count_waiting)
|
||||
{
|
||||
if (text_override.has_value()) {
|
||||
m_statusbar->set_text(*text_override);
|
||||
@ -99,7 +99,7 @@ void Tab::update_status(Optional<DeprecatedString> text_override, i32 count_wait
|
||||
}
|
||||
|
||||
if (m_loaded) {
|
||||
m_statusbar->set_text("");
|
||||
m_statusbar->set_text({});
|
||||
return;
|
||||
}
|
||||
|
||||
@ -107,10 +107,10 @@ void Tab::update_status(Optional<DeprecatedString> text_override, i32 count_wait
|
||||
|
||||
if (count_waiting == 0) {
|
||||
// ex: "Loading google.com"
|
||||
m_statusbar->set_text(DeprecatedString::formatted("Loading {}", m_navigating_url->host()));
|
||||
m_statusbar->set_text(String::formatted("Loading {}", m_navigating_url->host()).release_value_but_fixme_should_propagate_errors());
|
||||
} else {
|
||||
// ex: "google.com is waiting on 5 resources"
|
||||
m_statusbar->set_text(DeprecatedString::formatted("{} is waiting on {} resource{}", m_navigating_url->host(), count_waiting, count_waiting == 1 ? ""sv : "s"sv));
|
||||
m_statusbar->set_text(String::formatted("{} is waiting on {} resource{}", m_navigating_url->host(), count_waiting, count_waiting == 1 ? ""sv : "s"sv).release_value_but_fixme_should_propagate_errors());
|
||||
}
|
||||
}
|
||||
|
||||
@ -509,7 +509,7 @@ Tab::Tab(BrowserWindow& window)
|
||||
m_statusbar = *find_descendant_of_type_named<GUI::Statusbar>("statusbar");
|
||||
|
||||
view().on_link_hover = [this](auto& url) {
|
||||
update_status(url.to_deprecated_string());
|
||||
update_status(String::from_deprecated_string(url.to_deprecated_string()).release_value_but_fixme_should_propagate_errors());
|
||||
};
|
||||
|
||||
view().on_link_unhover = [this]() {
|
||||
@ -704,7 +704,7 @@ void Tab::did_become_active()
|
||||
};
|
||||
|
||||
BookmarksBarWidget::the().on_bookmark_hover = [this](auto&, auto& url) {
|
||||
m_statusbar->set_text(url);
|
||||
m_statusbar->set_text(String::from_deprecated_string(url).release_value_but_fixme_should_propagate_errors());
|
||||
};
|
||||
|
||||
BookmarksBarWidget::the().on_bookmark_change = [this]() {
|
||||
|
@ -111,7 +111,7 @@ private:
|
||||
void update_bookmark_button(StringView url);
|
||||
void start_download(const URL& url);
|
||||
void view_source(const URL& url, DeprecatedString const& source);
|
||||
void update_status(Optional<DeprecatedString> text_override = {}, i32 count_waiting = 0);
|
||||
void update_status(Optional<String> text_override = {}, i32 count_waiting = 0);
|
||||
void close_sub_widgets();
|
||||
|
||||
enum class MayAppendTLD {
|
||||
|
@ -179,5 +179,5 @@ void CharacterMapWidget::update_statusbar()
|
||||
builder.appendff("U+{:04X}", code_point);
|
||||
if (auto display_name = Unicode::code_point_display_name(code_point); display_name.has_value())
|
||||
builder.appendff(" - {}", display_name.value());
|
||||
m_statusbar->set_text(builder.to_deprecated_string());
|
||||
m_statusbar->set_text(builder.to_string().release_value_but_fixme_should_propagate_errors());
|
||||
}
|
||||
|
@ -1135,7 +1135,7 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
|
||||
};
|
||||
|
||||
directory_view->on_status_message = [&](StringView message) {
|
||||
statusbar.set_text(message);
|
||||
statusbar.set_text(String::from_utf8(message).release_value_but_fixme_should_propagate_errors());
|
||||
};
|
||||
|
||||
directory_view->on_thumbnail_progress = [&](int done, int total) {
|
||||
|
@ -963,7 +963,7 @@ void MainWidget::update_statusbar()
|
||||
else if (Gfx::Emoji::emoji_for_code_point(glyph))
|
||||
TRY(builder.try_appendff(" [emoji]"));
|
||||
|
||||
m_statusbar->set_text(0, builder.to_deprecated_string());
|
||||
m_statusbar->set_text(0, TRY(builder.to_string()));
|
||||
|
||||
builder.clear();
|
||||
|
||||
@ -972,7 +972,7 @@ void MainWidget::update_statusbar()
|
||||
TRY(builder.try_appendff("{} glyphs selected", selection.size()));
|
||||
else
|
||||
TRY(builder.try_appendff("U+{:04X}-U+{:04X}", m_range.first, m_range.last));
|
||||
m_statusbar->set_text(1, builder.to_deprecated_string());
|
||||
m_statusbar->set_text(1, TRY(builder.to_string()));
|
||||
|
||||
return {};
|
||||
}();
|
||||
|
@ -134,7 +134,7 @@ MainWidget::MainWidget()
|
||||
};
|
||||
m_web_view->on_link_hover = [this](URL const& url) {
|
||||
if (url.is_valid())
|
||||
m_statusbar->set_text(url.to_deprecated_string());
|
||||
m_statusbar->set_text(String::from_deprecated_string(url.to_deprecated_string()).release_value_but_fixme_should_propagate_errors());
|
||||
else
|
||||
m_statusbar->set_text({});
|
||||
};
|
||||
|
@ -84,8 +84,8 @@ int GoToOffsetDialog::calculate_new_offset(int input_offset)
|
||||
void GoToOffsetDialog::update_statusbar()
|
||||
{
|
||||
auto new_offset = calculate_new_offset(process_input());
|
||||
m_statusbar->set_text(0, DeprecatedString::formatted("HEX: {:#08X}", new_offset));
|
||||
m_statusbar->set_text(1, DeprecatedString::formatted("DEC: {}", new_offset));
|
||||
m_statusbar->set_text(0, String::formatted("HEX: {:#08X}", new_offset).release_value_but_fixme_should_propagate_errors());
|
||||
m_statusbar->set_text(1, String::formatted("DEC: {}", new_offset).release_value_but_fixme_should_propagate_errors());
|
||||
}
|
||||
|
||||
GoToOffsetDialog::GoToOffsetDialog()
|
||||
|
@ -61,11 +61,11 @@ HexEditorWidget::HexEditorWidget()
|
||||
};
|
||||
|
||||
m_editor->on_status_change = [this](int position, HexEditor::EditMode edit_mode, int selection_start, int selection_end) {
|
||||
m_statusbar->set_text(0, DeprecatedString::formatted("Offset: {:#08X}", position));
|
||||
m_statusbar->set_text(1, DeprecatedString::formatted("Edit Mode: {}", edit_mode == HexEditor::EditMode::Hex ? "Hex" : "Text"));
|
||||
m_statusbar->set_text(2, DeprecatedString::formatted("Selection Start: {}", selection_start));
|
||||
m_statusbar->set_text(3, DeprecatedString::formatted("Selection End: {}", selection_end));
|
||||
m_statusbar->set_text(4, DeprecatedString::formatted("Selected Bytes: {}", m_editor->selection_size()));
|
||||
m_statusbar->set_text(0, String::formatted("Offset: {:#08X}", position).release_value_but_fixme_should_propagate_errors());
|
||||
m_statusbar->set_text(1, String::formatted("Edit Mode: {}", edit_mode == HexEditor::EditMode::Hex ? "Hex" : "Text").release_value_but_fixme_should_propagate_errors());
|
||||
m_statusbar->set_text(2, String::formatted("Selection Start: {}", selection_start).release_value_but_fixme_should_propagate_errors());
|
||||
m_statusbar->set_text(3, String::formatted("Selection End: {}", selection_end).release_value_but_fixme_should_propagate_errors());
|
||||
m_statusbar->set_text(4, String::formatted("Selected Bytes: {}", m_editor->selection_size()).release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
bool has_selection = m_editor->has_selection();
|
||||
m_copy_hex_action->set_enabled(has_selection);
|
||||
|
@ -55,9 +55,9 @@ MailWidget::MailWidget()
|
||||
|
||||
m_web_view->on_link_hover = [this](auto& url) {
|
||||
if (url.is_valid())
|
||||
m_statusbar->set_text(url.to_deprecated_string());
|
||||
m_statusbar->set_text(String::from_deprecated_string(url.to_deprecated_string()).release_value_but_fixme_should_propagate_errors());
|
||||
else
|
||||
m_statusbar->set_text("");
|
||||
m_statusbar->set_text({});
|
||||
};
|
||||
|
||||
m_link_context_menu = GUI::Menu::construct();
|
||||
|
@ -133,7 +133,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
}
|
||||
|
||||
auto& app = *(NonnullRefPtr<Desktop::AppFile>*)index.internal_data();
|
||||
statusbar->set_text(app->description());
|
||||
statusbar->set_text(String::from_deprecated_string(app->description()).release_value_but_fixme_should_propagate_errors());
|
||||
};
|
||||
|
||||
window->set_icon(app_icon.bitmap_for_size(16));
|
||||
|
@ -394,7 +394,7 @@ static ErrorOr<void> fill_mounts(Vector<MountInfo>& output)
|
||||
|
||||
ErrorOr<void> TreeMapWidget::analyze(GUI::Statusbar& statusbar)
|
||||
{
|
||||
statusbar.set_text("");
|
||||
statusbar.set_text({});
|
||||
auto progress_window = TRY(ProgressWindow::try_create("Space Analyzer"sv));
|
||||
progress_window->show();
|
||||
|
||||
@ -431,9 +431,9 @@ ErrorOr<void> TreeMapWidget::analyze(GUI::Statusbar& statusbar)
|
||||
builder.append(')');
|
||||
first = false;
|
||||
}
|
||||
statusbar.set_text(builder.to_deprecated_string());
|
||||
statusbar.set_text(TRY(builder.to_string()));
|
||||
} else {
|
||||
statusbar.set_text("No errors");
|
||||
statusbar.set_text(TRY("No errors"_string));
|
||||
}
|
||||
|
||||
m_tree = move(tree);
|
||||
|
@ -291,8 +291,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
|
||||
auto process_model = ProcessModel::create();
|
||||
process_model->on_state_update = [&](int process_count, int thread_count) {
|
||||
statusbar->set_text(0, DeprecatedString::formatted("Processes: {}", process_count));
|
||||
statusbar->set_text(1, DeprecatedString::formatted("Threads: {}", thread_count));
|
||||
statusbar->set_text(0, String::formatted("Processes: {}", process_count).release_value_but_fixme_should_propagate_errors());
|
||||
statusbar->set_text(1, String::formatted("Threads: {}", thread_count).release_value_but_fixme_should_propagate_errors());
|
||||
};
|
||||
|
||||
auto& performance_widget = *tabwidget.find_descendant_of_type_named<GUI::Widget>("performance");
|
||||
@ -605,7 +605,7 @@ ErrorOr<void> build_performance_tab(GUI::Widget& graphs_container)
|
||||
sum_cpu += cpus[i]->total_cpu_percent;
|
||||
}
|
||||
float cpu_usage = sum_cpu / (float)cpus.size();
|
||||
statusbar->set_text(2, DeprecatedString::formatted("CPU usage: {}%", (int)roundf(cpu_usage)));
|
||||
statusbar->set_text(2, String::formatted("CPU usage: {}%", (int)roundf(cpu_usage)).release_value_but_fixme_should_propagate_errors());
|
||||
};
|
||||
|
||||
auto& memory_graph = *graphs_container.find_descendant_of_type_named<SystemMonitor::GraphWidget>("memory_graph");
|
||||
|
@ -350,7 +350,7 @@ WebView::OutOfProcessWebView& MainWidget::ensure_web_view()
|
||||
m_page_view = web_view_container.add<WebView::OutOfProcessWebView>();
|
||||
m_page_view->on_link_hover = [this](auto& url) {
|
||||
if (url.is_valid())
|
||||
m_statusbar->set_text(url.to_deprecated_string());
|
||||
m_statusbar->set_text(String::from_deprecated_string(url.to_deprecated_string()).release_value_but_fixme_should_propagate_errors());
|
||||
else
|
||||
update_statusbar();
|
||||
};
|
||||
@ -600,12 +600,12 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
|
||||
auto syntax_menu = TRY(view_menu->try_add_submenu("&Syntax"_short_string));
|
||||
m_plain_text_highlight = GUI::Action::create_checkable("&Plain Text", [&](auto&) {
|
||||
m_statusbar->set_text(1, "Plain Text");
|
||||
m_statusbar->set_text(1, "Plain Text"_string.release_value_but_fixme_should_propagate_errors());
|
||||
m_editor->set_syntax_highlighter({});
|
||||
m_editor->update();
|
||||
});
|
||||
m_plain_text_highlight->set_checked(true);
|
||||
m_statusbar->set_text(1, "Plain Text");
|
||||
m_statusbar->set_text(1, TRY("Plain Text"_string));
|
||||
syntax_actions.add_action(*m_plain_text_highlight);
|
||||
TRY(syntax_menu->try_add_action(*m_plain_text_highlight));
|
||||
|
||||
@ -940,13 +940,13 @@ void MainWidget::update_statusbar()
|
||||
auto word_count = m_editor->number_of_words();
|
||||
builder.appendff("{:'d} {} ({:'d} {})", text.length(), text.length() == 1 ? "character" : "characters", word_count, word_count != 1 ? "words" : "word");
|
||||
}
|
||||
m_statusbar->set_text(0, builder.to_deprecated_string());
|
||||
m_statusbar->set_text(0, builder.to_string().release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
if (m_editor && m_editor->syntax_highlighter()) {
|
||||
auto language = m_editor->syntax_highlighter()->language();
|
||||
m_statusbar->set_text(1, Syntax::language_to_string(language));
|
||||
m_statusbar->set_text(1, String::from_utf8(Syntax::language_to_string(language)).release_value_but_fixme_should_propagate_errors());
|
||||
}
|
||||
m_statusbar->set_text(2, DeprecatedString::formatted("Ln {:'d} Col {:'d}", m_editor->cursor().line() + 1, m_editor->cursor().column()));
|
||||
m_statusbar->set_text(2, String::formatted("Ln {:'d} Col {:'d}", m_editor->cursor().line() + 1, m_editor->cursor().column()).release_value_but_fixme_should_propagate_errors());
|
||||
}
|
||||
|
||||
void MainWidget::find_text(GUI::TextEditor::SearchDirection direction, ShowMessageIfNoResults show_message)
|
||||
|
@ -33,10 +33,10 @@ ErrorOr<void> GalleryWidget::load_basic_model_tab()
|
||||
|
||||
m_basic_model->on_invalidate = [&] {
|
||||
m_invalidation_count++;
|
||||
m_statusbar->set_text(DeprecatedString::formatted("Times invalidated: {}", m_invalidation_count));
|
||||
m_statusbar->set_text(String::formatted("Times invalidated: {}", m_invalidation_count).release_value_but_fixme_should_propagate_errors());
|
||||
};
|
||||
|
||||
m_statusbar->set_text(DeprecatedString::formatted("Times invalidated: {}", m_invalidation_count));
|
||||
m_statusbar->set_text(TRY(String::formatted("Times invalidated: {}", m_invalidation_count)));
|
||||
|
||||
m_basic_model->add_item("Well...");
|
||||
m_basic_model->add_item("...hello...");
|
||||
|
@ -1615,9 +1615,9 @@ void HackStudioWidget::update_statusbar()
|
||||
builder.appendff("Selected: {:'d} {} ({:'d} {})", selected_text.length(), selected_text.length() == 1 ? "character" : "characters", word_count, word_count != 1 ? "words" : "word");
|
||||
}
|
||||
|
||||
m_statusbar->set_text(0, builder.to_deprecated_string());
|
||||
m_statusbar->set_text(1, Syntax::language_to_string(current_editor_wrapper().editor().code_document().language().value_or(Syntax::Language::PlainText)));
|
||||
m_statusbar->set_text(2, DeprecatedString::formatted("Ln {:'d} Col {:'d}", current_editor().cursor().line() + 1, current_editor().cursor().column()));
|
||||
m_statusbar->set_text(0, builder.to_string().release_value_but_fixme_should_propagate_errors());
|
||||
m_statusbar->set_text(1, String::from_utf8(Syntax::language_to_string(current_editor_wrapper().editor().code_document().language().value_or(Syntax::Language::PlainText))).release_value_but_fixme_should_propagate_errors());
|
||||
m_statusbar->set_text(2, String::formatted("Ln {:'d} Col {:'d}", current_editor().cursor().line() + 1, current_editor().cursor().column()).release_value_but_fixme_should_propagate_errors());
|
||||
}
|
||||
|
||||
void HackStudioWidget::handle_external_file_deletion(DeprecatedString const& filepath)
|
||||
|
@ -251,7 +251,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
builder.appendff(", Duration: {} ms", end - start);
|
||||
}
|
||||
}
|
||||
statusbar->set_text(builder.to_deprecated_string());
|
||||
statusbar->set_text(builder.to_string().release_value_but_fixme_should_propagate_errors());
|
||||
};
|
||||
timeline_view->on_selection_change = [&] { statusbar_update(); };
|
||||
flamegraph_view->on_hover_change = [&] { statusbar_update(); };
|
||||
|
@ -164,7 +164,7 @@ ErrorOr<void> MainWidget::setup()
|
||||
return;
|
||||
|
||||
m_run_script_action->set_enabled(false);
|
||||
m_statusbar->set_text(1, "Disconnected"sv);
|
||||
m_statusbar->set_text(1, "Disconnected"_string.release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
if (m_connection_id.has_value()) {
|
||||
m_sql_client->disconnect(*m_connection_id);
|
||||
@ -172,7 +172,7 @@ ErrorOr<void> MainWidget::setup()
|
||||
}
|
||||
|
||||
if (auto connection_id = m_sql_client->connect(database_name); connection_id.has_value()) {
|
||||
m_statusbar->set_text(1, DeprecatedString::formatted("Connected to: {}", database_name));
|
||||
m_statusbar->set_text(1, String::formatted("Connected to: {}", database_name).release_value_but_fixme_should_propagate_errors());
|
||||
m_connection_id = *connection_id;
|
||||
m_run_script_action->set_enabled(true);
|
||||
} else {
|
||||
@ -245,7 +245,7 @@ ErrorOr<void> MainWidget::setup()
|
||||
|
||||
m_statusbar = find_descendant_of_type_named<GUI::Statusbar>("statusbar"sv);
|
||||
m_statusbar->segment(1).set_mode(GUI::Statusbar::Segment::Mode::Auto);
|
||||
m_statusbar->set_text(1, "Disconnected"sv);
|
||||
m_statusbar->set_text(1, TRY("Disconnected"_string));
|
||||
m_statusbar->segment(2).set_mode(GUI::Statusbar::Segment::Mode::Fixed);
|
||||
m_statusbar->segment(2).set_fixed_width(font().width("Ln 0,000 Col 000"sv) + font().max_glyph_width());
|
||||
|
||||
@ -425,8 +425,8 @@ void MainWidget::on_editor_change()
|
||||
void MainWidget::update_statusbar(ScriptEditor* editor)
|
||||
{
|
||||
if (!editor) {
|
||||
m_statusbar->set_text(0, "");
|
||||
m_statusbar->set_text(2, "");
|
||||
m_statusbar->set_text(0, {});
|
||||
m_statusbar->set_text(2, {});
|
||||
return;
|
||||
}
|
||||
|
||||
@ -437,8 +437,8 @@ void MainWidget::update_statusbar(ScriptEditor* editor)
|
||||
builder.appendff("Selected: {:'d} {} ({:'d} {})", character_count, character_count == 1 ? "character" : "characters", word_count, word_count != 1 ? "words" : "word");
|
||||
}
|
||||
|
||||
m_statusbar->set_text(0, builder.to_deprecated_string());
|
||||
m_statusbar->set_text(2, DeprecatedString::formatted("Ln {:'d} Col {:'d}", editor->cursor().line() + 1, editor->cursor().column()));
|
||||
m_statusbar->set_text(0, builder.to_string().release_value_but_fixme_should_propagate_errors());
|
||||
m_statusbar->set_text(2, String::formatted("Ln {:'d} Col {:'d}", editor->cursor().line() + 1, editor->cursor().column()).release_value_but_fixme_should_propagate_errors());
|
||||
}
|
||||
|
||||
void MainWidget::update_editor_actions(ScriptEditor* editor)
|
||||
|
@ -89,7 +89,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
auto update = [&]() {
|
||||
board_view->set_board(&game.board());
|
||||
board_view->update();
|
||||
statusbar->set_text(DeprecatedString::formatted("Score: {}", game.score()));
|
||||
statusbar->set_text(String::formatted("Score: {}", game.score()).release_value_but_fixme_should_propagate_errors());
|
||||
};
|
||||
|
||||
update();
|
||||
|
@ -105,7 +105,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
|
||||
auto update = [&]() {
|
||||
board_widget->update();
|
||||
statusbar->set_text(DeprecatedString::formatted("Moves remaining: {}", ai_moves - moves_made));
|
||||
statusbar->set_text(String::formatted("Moves remaining: {}", ai_moves - moves_made).release_value_but_fixme_should_propagate_errors());
|
||||
};
|
||||
|
||||
update();
|
||||
|
@ -24,8 +24,6 @@
|
||||
#include <LibGUI/Window.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
||||
char const* click_tip = "Tip: click the board to toggle individual cells, or click+drag to toggle multiple cells";
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
TRY(Core::System::pledge("stdio rpath recvfd sendfd unix"));
|
||||
@ -41,6 +39,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
TRY(Core::System::unveil("/res", "r"));
|
||||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
||||
auto click_tip = TRY("Tip: click the board to toggle individual cells, or click+drag to toggle multiple cells"_string);
|
||||
|
||||
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-gameoflife"sv));
|
||||
|
||||
auto window = TRY(GUI::Window::try_create());
|
||||
@ -147,7 +147,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
|
||||
board_widget->on_running_state_change = [&]() {
|
||||
if (board_widget->is_running()) {
|
||||
statusbar.set_text("Running...");
|
||||
statusbar.set_text("Running..."_string.release_value_but_fixme_should_propagate_errors());
|
||||
toggle_running_toolbar_button->set_icon(*paused_icon);
|
||||
main_widget->set_override_cursor(Gfx::StandardCursor::None);
|
||||
} else {
|
||||
@ -171,7 +171,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
|
||||
board_widget->on_stall = [&] {
|
||||
toggle_running_action->activate();
|
||||
statusbar.set_text("Stalled...");
|
||||
statusbar.set_text("Stalled..."_string.release_value_but_fixme_should_propagate_errors());
|
||||
};
|
||||
|
||||
board_widget->on_cell_toggled = [&](auto, auto, auto) {
|
||||
|
@ -57,7 +57,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
game.set_focus(true);
|
||||
|
||||
auto& statusbar = *widget->find_descendant_of_type_named<GUI::Statusbar>("statusbar");
|
||||
statusbar.set_text(0, "Score: 0");
|
||||
statusbar.set_text(0, TRY("Score: 0"_string));
|
||||
|
||||
DeprecatedString player_name = Config::read_string("Hearts"sv, ""sv, "player_name"sv, "Gunnar"sv);
|
||||
|
||||
|
@ -130,9 +130,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
|
||||
game.on_message = [&](auto message) {
|
||||
if (!message.has_value())
|
||||
statusbar.set_text("");
|
||||
statusbar.set_text({});
|
||||
else
|
||||
statusbar.set_text(*message);
|
||||
statusbar.set_text(String::from_utf8(*message).release_value_but_fixme_should_propagate_errors());
|
||||
};
|
||||
|
||||
window->show();
|
||||
|
@ -62,15 +62,15 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
auto snake_skin_name = Config::read_string("Snake"sv, "Snake"sv, "SnakeSkin"sv, "Classic"sv);
|
||||
|
||||
auto& statusbar = *widget->find_descendant_of_type_named<GUI::Statusbar>("statusbar"sv);
|
||||
statusbar.set_text(0, "Score: 0"sv);
|
||||
statusbar.set_text(1, DeprecatedString::formatted("High Score: {}", high_score));
|
||||
statusbar.set_text(0, TRY("Score: 0"_string));
|
||||
statusbar.set_text(1, TRY(String::formatted("High Score: {}", high_score)));
|
||||
|
||||
game.on_score_update = [&](auto score) {
|
||||
statusbar.set_text(0, DeprecatedString::formatted("Score: {}", score));
|
||||
statusbar.set_text(0, String::formatted("Score: {}", score).release_value_but_fixme_should_propagate_errors());
|
||||
if (score <= high_score)
|
||||
return false;
|
||||
|
||||
statusbar.set_text(1, DeprecatedString::formatted("High Score: {}", score));
|
||||
statusbar.set_text(1, String::formatted("High Score: {}", score).release_value_but_fixme_should_propagate_errors());
|
||||
Config::write_u32("Snake"sv, "Snake"sv, "HighScore"sv, score);
|
||||
|
||||
high_score = score;
|
||||
|
@ -90,9 +90,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
game.set_focus(true);
|
||||
|
||||
auto& statusbar = *widget->find_descendant_of_type_named<GUI::Statusbar>("statusbar");
|
||||
statusbar.set_text(0, "Score: 0");
|
||||
statusbar.set_text(1, DeprecatedString::formatted("High Score: {}", high_score()));
|
||||
statusbar.set_text(2, "Time: 00:00:00");
|
||||
statusbar.set_text(0, TRY("Score: 0"_string));
|
||||
statusbar.set_text(1, TRY(String::formatted("High Score: {}", high_score())));
|
||||
statusbar.set_text(2, TRY("Time: 00:00:00"_string));
|
||||
|
||||
app->on_action_enter = [&](GUI::Action& action) {
|
||||
auto text = action.status_tip();
|
||||
@ -106,7 +106,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
};
|
||||
|
||||
game.on_score_update = [&](uint32_t score) {
|
||||
statusbar.set_text(0, DeprecatedString::formatted("Score: {}", score));
|
||||
statusbar.set_text(0, String::formatted("Score: {}", score).release_value_but_fixme_should_propagate_errors());
|
||||
};
|
||||
|
||||
uint64_t seconds_elapsed = 0;
|
||||
@ -118,13 +118,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
uint64_t minutes = (seconds_elapsed / 60) % 60;
|
||||
uint64_t seconds = seconds_elapsed % 60;
|
||||
|
||||
statusbar.set_text(2, DeprecatedString::formatted("Time: {:02}:{:02}:{:02}", hours, minutes, seconds));
|
||||
statusbar.set_text(2, String::formatted("Time: {:02}:{:02}:{:02}", hours, minutes, seconds).release_value_but_fixme_should_propagate_errors());
|
||||
}));
|
||||
|
||||
game.on_game_start = [&]() {
|
||||
seconds_elapsed = 0;
|
||||
timer->start();
|
||||
statusbar.set_text(2, "Time: 00:00:00");
|
||||
statusbar.set_text(2, "Time: 00:00:00"_string.release_value_but_fixme_should_propagate_errors());
|
||||
};
|
||||
game.on_game_end = [&](Solitaire::GameOverReason reason, uint32_t score) {
|
||||
if (timer->is_active())
|
||||
@ -133,16 +133,16 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
if (reason == Solitaire::GameOverReason::Victory) {
|
||||
if (seconds_elapsed >= 30) {
|
||||
uint32_t bonus = (20'000 / seconds_elapsed) * 35;
|
||||
statusbar.set_text(0, DeprecatedString::formatted("Score: {} (Bonus: {})", score, bonus));
|
||||
statusbar.set_text(0, String::formatted("Score: {} (Bonus: {})", score, bonus).release_value_but_fixme_should_propagate_errors());
|
||||
score += bonus;
|
||||
}
|
||||
|
||||
if (score > high_score()) {
|
||||
update_high_score(score);
|
||||
statusbar.set_text(1, DeprecatedString::formatted("High Score: {}", score));
|
||||
statusbar.set_text(1, String::formatted("High Score: {}", score).release_value_but_fixme_should_propagate_errors());
|
||||
}
|
||||
}
|
||||
statusbar.set_text(2, "Timer starts after your first move");
|
||||
statusbar.set_text(2, "Timer starts after your first move"_string.release_value_but_fixme_should_propagate_errors());
|
||||
};
|
||||
|
||||
auto confirm_end_current_game = [&]() {
|
||||
@ -175,7 +175,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
if (!confirm_end_current_game())
|
||||
return;
|
||||
|
||||
statusbar.set_text(1, DeprecatedString::formatted("High Score: {}", high_score()));
|
||||
statusbar.set_text(1, String::formatted("High Score: {}", high_score()).release_value_but_fixme_should_propagate_errors());
|
||||
game.setup(mode);
|
||||
});
|
||||
single_card_draw_action->set_checked(mode == Solitaire::Mode::SingleCardDraw);
|
||||
@ -188,7 +188,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
if (!confirm_end_current_game())
|
||||
return;
|
||||
|
||||
statusbar.set_text(1, DeprecatedString::formatted("High Score: {}", high_score()));
|
||||
statusbar.set_text(1, String::formatted("High Score: {}", high_score()).release_value_but_fixme_should_propagate_errors());
|
||||
game.setup(mode);
|
||||
});
|
||||
three_card_draw_action->set_checked(mode == Solitaire::Mode::ThreeCardDraw);
|
||||
|
@ -127,19 +127,19 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
auto reset_statistic_status = [&]() {
|
||||
switch (statistic_display) {
|
||||
case StatisticDisplay::HighScore:
|
||||
statusbar.set_text(1, DeprecatedString::formatted("High Score: {}", high_score()));
|
||||
statusbar.set_text(1, String::formatted("High Score: {}", high_score()).release_value_but_fixme_should_propagate_errors());
|
||||
break;
|
||||
case StatisticDisplay::BestTime:
|
||||
statusbar.set_text(1, DeprecatedString::formatted("Best Time: {}", format_seconds(best_time())));
|
||||
statusbar.set_text(1, String::formatted("Best Time: {}", format_seconds(best_time())).release_value_but_fixme_should_propagate_errors());
|
||||
break;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
};
|
||||
|
||||
statusbar.set_text(0, "Score: 0");
|
||||
statusbar.set_text(0, TRY("Score: 0"_string));
|
||||
reset_statistic_status();
|
||||
statusbar.set_text(2, "Time: 00:00:00");
|
||||
statusbar.set_text(2, TRY("Time: 00:00:00"_string));
|
||||
|
||||
app->on_action_enter = [&](GUI::Action& action) {
|
||||
auto text = action.status_tip();
|
||||
@ -153,7 +153,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
};
|
||||
|
||||
game.on_score_update = [&](uint32_t score) {
|
||||
statusbar.set_text(0, DeprecatedString::formatted("Score: {}", score));
|
||||
statusbar.set_text(0, String::formatted("Score: {}", score).release_value_but_fixme_should_propagate_errors());
|
||||
};
|
||||
|
||||
uint64_t seconds_elapsed = 0;
|
||||
@ -161,13 +161,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
auto timer = TRY(Core::Timer::create_repeating(1000, [&]() {
|
||||
++seconds_elapsed;
|
||||
|
||||
statusbar.set_text(2, DeprecatedString::formatted("Time: {}", format_seconds(seconds_elapsed)));
|
||||
statusbar.set_text(2, String::formatted("Time: {}", format_seconds(seconds_elapsed)).release_value_but_fixme_should_propagate_errors());
|
||||
}));
|
||||
|
||||
game.on_game_start = [&]() {
|
||||
seconds_elapsed = 0;
|
||||
timer->start();
|
||||
statusbar.set_text(2, "Time: 00:00:00");
|
||||
statusbar.set_text(2, "Time: 00:00:00"_string.release_value_but_fixme_should_propagate_errors());
|
||||
};
|
||||
game.on_game_end = [&](Spider::GameOverReason reason, uint32_t score) {
|
||||
auto game_was_in_progress = timer->is_active();
|
||||
@ -192,7 +192,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
|
||||
reset_statistic_status();
|
||||
}
|
||||
statusbar.set_text(2, "Timer starts after your first move");
|
||||
statusbar.set_text(2, "Timer starts after your first move"_string.release_value_but_fixme_should_propagate_errors());
|
||||
};
|
||||
|
||||
auto confirm_end_current_game = [&]() {
|
||||
|
@ -25,7 +25,7 @@ Statusbar::Statusbar(int count)
|
||||
m_corner = add<ResizeCorner>();
|
||||
set_segment_count(count);
|
||||
|
||||
REGISTER_DEPRECATED_STRING_PROPERTY("text", text, set_text);
|
||||
REGISTER_STRING_PROPERTY("text", text, set_text);
|
||||
REGISTER_INT_PROPERTY("segment_count", segment_count, set_segment_count);
|
||||
}
|
||||
|
||||
@ -100,19 +100,19 @@ void Statusbar::update_segment(size_t index)
|
||||
}
|
||||
}
|
||||
|
||||
DeprecatedString Statusbar::text(size_t index) const
|
||||
String Statusbar::text(size_t index) const
|
||||
{
|
||||
return m_segments[index]->text().to_deprecated_string();
|
||||
return m_segments[index]->text();
|
||||
}
|
||||
|
||||
void Statusbar::set_text(DeprecatedString text)
|
||||
void Statusbar::set_text(String text)
|
||||
{
|
||||
set_text(0, move(text));
|
||||
}
|
||||
|
||||
void Statusbar::set_text(size_t index, DeprecatedString text)
|
||||
void Statusbar::set_text(size_t index, String text)
|
||||
{
|
||||
m_segments[index]->m_restored_text = String::from_deprecated_string(text).release_value_but_fixme_should_propagate_errors();
|
||||
m_segments[index]->m_restored_text = move(text);
|
||||
update_segment(index);
|
||||
}
|
||||
|
||||
|
@ -19,9 +19,9 @@ class Statusbar : public Widget {
|
||||
public:
|
||||
virtual ~Statusbar() override = default;
|
||||
|
||||
DeprecatedString text(size_t index = 0) const;
|
||||
void set_text(DeprecatedString);
|
||||
void set_text(size_t index, DeprecatedString);
|
||||
String text(size_t index = 0) const;
|
||||
void set_text(String);
|
||||
void set_text(size_t index, String);
|
||||
void set_override_text(DeprecatedString);
|
||||
|
||||
class Segment final : public Button {
|
||||
|
Loading…
Reference in New Issue
Block a user