diff --git a/Userland/Applications/PixelPaint/MainWidget.cpp b/Userland/Applications/PixelPaint/MainWidget.cpp index c4a3055cd6..cc17da94eb 100644 --- a/Userland/Applications/PixelPaint/MainWidget.cpp +++ b/Userland/Applications/PixelPaint/MainWidget.cpp @@ -1433,7 +1433,7 @@ void MainWidget::update_status_bar(DeprecatedString appended_text) builder.append(" "sv); builder.append(appended_text); } - m_statusbar->set_override_text(builder.to_deprecated_string()); + m_statusbar->set_override_text(builder.to_string().release_value_but_fixme_should_propagate_errors()); } } diff --git a/Userland/Games/Hearts/Game.cpp b/Userland/Games/Hearts/Game.cpp index f84646d62b..2da8c16a16 100644 --- a/Userland/Games/Hearts/Game.cpp +++ b/Userland/Games/Hearts/Game.cpp @@ -405,9 +405,9 @@ void Game::let_player_play_card() auto& player = current_player(); if (&player == &m_players[0]) - on_status_change("Select a card to play."); + on_status_change("Select a card to play."_string.release_value_but_fixme_should_propagate_errors()); else - on_status_change(DeprecatedString::formatted("Waiting for {} to play a card...", player)); + on_status_change(String::formatted("Waiting for {} to play a card...", player).release_value_but_fixme_should_propagate_errors()); if (player.is_human) { m_human_can_play = true; @@ -455,7 +455,7 @@ void Game::advance_game() if (m_state == State::Play && game_ended()) { m_state = State::GameEnded; - on_status_change("Game ended."); + on_status_change("Game ended."_string.release_value_but_fixme_should_propagate_errors()); advance_game(); return; } @@ -699,7 +699,7 @@ void Game::card_clicked_during_play(size_t card_index, Card& card) card.set_inverted(true); update(card.rect()); m_inverted_card = card; - on_status_change(DeprecatedString::formatted("You can't play this card: {}", explanation)); + on_status_change(String::formatted("You can't play this card: {}", explanation).release_value_but_fixme_should_propagate_errors()); continue_game_after_delay(); return; } diff --git a/Userland/Games/Hearts/Game.h b/Userland/Games/Hearts/Game.h index 0f05766981..8512296919 100644 --- a/Userland/Games/Hearts/Game.h +++ b/Userland/Games/Hearts/Game.h @@ -28,7 +28,7 @@ public: void setup(DeprecatedString player_name, int hand_number = 0); - Function on_status_change; + Function on_status_change; private: Game(); diff --git a/Userland/Games/Hearts/main.cpp b/Userland/Games/Hearts/main.cpp index 468f976ee9..66c8af186d 100644 --- a/Userland/Games/Hearts/main.cpp +++ b/Userland/Games/Hearts/main.cpp @@ -61,7 +61,7 @@ ErrorOr serenity_main(Main::Arguments arguments) DeprecatedString player_name = Config::read_string("Hearts"sv, ""sv, "player_name"sv, "Gunnar"sv); - game.on_status_change = [&](const AK::StringView& status) { + game.on_status_change = [&](String const& status) { statusbar.set_override_text(status); }; diff --git a/Userland/Libraries/LibGUI/Action.cpp b/Userland/Libraries/LibGUI/Action.cpp index 79a1d7df0d..ba818e4e82 100644 --- a/Userland/Libraries/LibGUI/Action.cpp +++ b/Userland/Libraries/LibGUI/Action.cpp @@ -315,12 +315,15 @@ void Action::set_tooltip(DeprecatedString tooltip) }); } -DeprecatedString Action::status_tip() const +Optional Action::status_tip() const { if (!m_status_tip.is_empty()) - return m_status_tip.to_deprecated_string(); + return m_status_tip; - return Gfx::parse_ampersand_string(m_text); + auto maybe_parsed_action_text = String::from_deprecated_string(Gfx::parse_ampersand_string(m_text)); + if (maybe_parsed_action_text.is_error()) + return {}; + return maybe_parsed_action_text.release_value(); } } diff --git a/Userland/Libraries/LibGUI/Action.h b/Userland/Libraries/LibGUI/Action.h index 8a03cb976e..e1a322b2d6 100644 --- a/Userland/Libraries/LibGUI/Action.h +++ b/Userland/Libraries/LibGUI/Action.h @@ -89,7 +89,7 @@ public: DeprecatedString tooltip() const { return m_tooltip.value_or(m_text); } void set_tooltip(DeprecatedString); - DeprecatedString status_tip() const; + Optional status_tip() const; void set_status_tip(String status_tip) { m_status_tip = move(status_tip); } Shortcut const& shortcut() const { return m_shortcut; } diff --git a/Userland/Libraries/LibGUI/Statusbar.cpp b/Userland/Libraries/LibGUI/Statusbar.cpp index f3f7eeb095..13b4dbcf27 100644 --- a/Userland/Libraries/LibGUI/Statusbar.cpp +++ b/Userland/Libraries/LibGUI/Statusbar.cpp @@ -116,12 +116,9 @@ void Statusbar::set_text(size_t index, String text) update_segment(index); } -void Statusbar::set_override_text(DeprecatedString override_text) +void Statusbar::set_override_text(Optional override_text) { - if (override_text.is_null()) - m_segments[0]->m_override_text = {}; - else - m_segments[0]->m_override_text = String::from_deprecated_string(override_text).release_value_but_fixme_should_propagate_errors(); + m_segments[0]->m_override_text = move(override_text); update_segment(0); } diff --git a/Userland/Libraries/LibGUI/Statusbar.h b/Userland/Libraries/LibGUI/Statusbar.h index 143134eb7f..fa3a8d3f99 100644 --- a/Userland/Libraries/LibGUI/Statusbar.h +++ b/Userland/Libraries/LibGUI/Statusbar.h @@ -22,7 +22,7 @@ public: String text(size_t index = 0) const; void set_text(String); void set_text(size_t index, String); - void set_override_text(DeprecatedString); + void set_override_text(Optional); class Segment final : public Button { C_OBJECT(Segment)