1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:27:43 +00:00

LibGUI+Userland: Port Labels to String

This commit is contained in:
thankyouverycool 2023-04-29 10:41:48 -04:00 committed by Andreas Kling
parent 3d53dc8228
commit 91bafc2653
92 changed files with 240 additions and 242 deletions

View file

@ -153,7 +153,7 @@ void DirectoryView::setup_model()
{
m_model->on_directory_change_error = [this](int, char const* error_string) {
auto failed_path = m_model->root_path();
auto error_message = DeprecatedString::formatted("Could not read {}:\n{}", failed_path, error_string);
auto error_message = String::formatted("Could not read {}:\n{}", failed_path, error_string).release_value_but_fixme_should_propagate_errors();
m_error_label->set_text(error_message);
set_active_widget(m_error_label);

View file

@ -54,16 +54,16 @@ FileOperationProgressWidget::FileOperationProgressWidget(FileOperation operation
switch (m_operation) {
case FileOperation::Copy:
files_copied_label.set_text("Copying files...");
current_file_action_label.set_text("Copying: ");
files_copied_label.set_text("Copying files..."_string.release_value_but_fixme_should_propagate_errors());
current_file_action_label.set_text("Copying: "_string.release_value_but_fixme_should_propagate_errors());
break;
case FileOperation::Move:
files_copied_label.set_text("Moving files...");
current_file_action_label.set_text("Moving: ");
files_copied_label.set_text("Moving files..."_string.release_value_but_fixme_should_propagate_errors());
current_file_action_label.set_text("Moving: "_string.release_value_but_fixme_should_propagate_errors());
break;
case FileOperation::Delete:
files_copied_label.set_text("Deleting files...");
current_file_action_label.set_text("Deleting: ");
files_copied_label.set_text("Deleting files..."_string.release_value_but_fixme_should_propagate_errors());
current_file_action_label.set_text("Deleting: "_string.release_value_but_fixme_should_propagate_errors());
break;
default:
VERIFY_NOT_REACHED();
@ -179,23 +179,23 @@ void FileOperationProgressWidget::did_progress(off_t bytes_done, off_t total_byt
auto& overall_progressbar = *find_descendant_of_type_named<GUI::Progressbar>("overall_progressbar");
auto& estimated_time_label = *find_descendant_of_type_named<GUI::Label>("estimated_time_label");
current_file_label.set_text(current_filename);
current_file_label.set_text(String::from_utf8(current_filename).release_value_but_fixme_should_propagate_errors());
switch (m_operation) {
case FileOperation::Copy:
files_copied_label.set_text(DeprecatedString::formatted("Copying file {} of {}", files_done, total_file_count));
files_copied_label.set_text(String::formatted("Copying file {} of {}", files_done, total_file_count).release_value_but_fixme_should_propagate_errors());
break;
case FileOperation::Move:
files_copied_label.set_text(DeprecatedString::formatted("Moving file {} of {}", files_done, total_file_count));
files_copied_label.set_text(String::formatted("Moving file {} of {}", files_done, total_file_count).release_value_but_fixme_should_propagate_errors());
break;
case FileOperation::Delete:
files_copied_label.set_text(DeprecatedString::formatted("Deleting file {} of {}", files_done, total_file_count));
files_copied_label.set_text(String::formatted("Deleting file {} of {}", files_done, total_file_count).release_value_but_fixme_should_propagate_errors());
break;
default:
VERIFY_NOT_REACHED();
}
estimated_time_label.set_text(estimate_time(bytes_done, total_byte_count));
estimated_time_label.set_text(String::from_deprecated_string(estimate_time(bytes_done, total_byte_count)).release_value_but_fixme_should_propagate_errors());
if (total_byte_count) {
window()->set_progress(100.0f * bytes_done / total_byte_count);

View file

@ -72,7 +72,7 @@ ErrorOr<void> PropertiesWindow::create_widgets(bool disable_rename)
};
auto* location = general_tab->find_descendant_of_type_named<GUI::LinkLabel>("location");
location->set_text(m_path);
location->set_text(TRY(String::from_deprecated_string(m_path)));
location->on_click = [this] {
Desktop::Launcher::open(URL::create_with_file_scheme(m_parent_path, m_name));
};
@ -98,18 +98,18 @@ ErrorOr<void> PropertiesWindow::create_widgets(bool disable_rename)
m_old_mode = st.st_mode;
auto* type = general_tab->find_descendant_of_type_named<GUI::Label>("type");
type->set_text(get_description(m_mode));
type->set_text(TRY(String::from_deprecated_string(get_description(m_mode))));
if (S_ISLNK(m_mode)) {
auto link_destination_or_error = FileSystem::read_link(m_path);
if (link_destination_or_error.is_error()) {
perror("readlink");
} else {
auto link_destination = link_destination_or_error.release_value().to_deprecated_string();
auto link_destination = link_destination_or_error.release_value();
auto* link_location = general_tab->find_descendant_of_type_named<GUI::LinkLabel>("link_location");
link_location->set_text(link_destination);
link_location->on_click = [link_destination] {
auto link_directory = LexicalPath(link_destination);
auto link_directory = LexicalPath(link_destination.to_deprecated_string());
Desktop::Launcher::open(URL::create_with_file_scheme(link_directory.dirname(), link_directory.basename()));
};
}
@ -119,19 +119,21 @@ ErrorOr<void> PropertiesWindow::create_widgets(bool disable_rename)
}
m_size_label = general_tab->find_descendant_of_type_named<GUI::Label>("size");
m_size_label->set_text(S_ISDIR(st.st_mode) ? "Calculating..." : human_readable_size_long(st.st_size, UseThousandsSeparator::Yes));
m_size_label->set_text(S_ISDIR(st.st_mode)
? TRY("Calculating..."_string)
: TRY(String::from_deprecated_string(human_readable_size_long(st.st_size, UseThousandsSeparator::Yes))));
auto* owner = general_tab->find_descendant_of_type_named<GUI::Label>("owner");
owner->set_text(DeprecatedString::formatted("{} ({})", owner_name, st.st_uid));
owner->set_text(String::formatted("{} ({})", owner_name, st.st_uid).release_value_but_fixme_should_propagate_errors());
auto* group = general_tab->find_descendant_of_type_named<GUI::Label>("group");
group->set_text(DeprecatedString::formatted("{} ({})", group_name, st.st_gid));
group->set_text(String::formatted("{} ({})", group_name, st.st_gid).release_value_but_fixme_should_propagate_errors());
auto* created_at = general_tab->find_descendant_of_type_named<GUI::Label>("created_at");
created_at->set_text(GUI::FileSystemModel::timestamp_string(st.st_ctime));
created_at->set_text(String::from_deprecated_string(GUI::FileSystemModel::timestamp_string(st.st_ctime)).release_value_but_fixme_should_propagate_errors());
auto* last_modified = general_tab->find_descendant_of_type_named<GUI::Label>("last_modified");
last_modified->set_text(GUI::FileSystemModel::timestamp_string(st.st_mtime));
last_modified->set_text(String::from_deprecated_string(GUI::FileSystemModel::timestamp_string(st.st_mtime)).release_value_but_fixme_should_propagate_errors());
auto* owner_read = general_tab->find_descendant_of_type_named<GUI::CheckBox>("owner_read");
auto* owner_write = general_tab->find_descendant_of_type_named<GUI::CheckBox>("owner_write");
@ -173,7 +175,7 @@ ErrorOr<void> PropertiesWindow::create_widgets(bool disable_rename)
m_directory_statistics_calculator->on_update = [this, origin_event_loop = &Core::EventLoop::current()](off_t total_size_in_bytes, size_t file_count, size_t directory_count) {
origin_event_loop->deferred_invoke([=, weak_this = make_weak_ptr<PropertiesWindow>()] {
if (auto strong_this = weak_this.strong_ref())
strong_this->m_size_label->set_text(DeprecatedString::formatted("{}\n{:'d} files, {:'d} subdirectories", human_readable_size_long(total_size_in_bytes, UseThousandsSeparator::Yes), file_count, directory_count));
strong_this->m_size_label->set_text(String::formatted("{}\n{} files, {} subdirectories", human_readable_size_long(total_size_in_bytes, UseThousandsSeparator::Yes), file_count, directory_count).release_value_but_fixme_should_propagate_errors());
});
};
m_directory_statistics_calculator->start();