mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 11:47:34 +00:00
LibGUI+Userland: Port StatusBar::text() and set_text functions to String
This commit is contained in:
parent
2064f544c6
commit
2029750519
27 changed files with 88 additions and 88 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue