diff --git a/Userland/Applications/CrashReporter/main.cpp b/Userland/Applications/CrashReporter/main.cpp index 18cdca57ee..9074561248 100644 --- a/Userland/Applications/CrashReporter/main.cpp +++ b/Userland/Applications/CrashReporter/main.cpp @@ -236,39 +236,39 @@ ErrorOr serenity_main(Main::Arguments arguments) auto& progressbar = *widget->find_descendant_of_type_named("progressbar"); auto& tab_widget = *widget->find_descendant_of_type_named("tab_widget"); - auto backtrace_tab = TRY(tab_widget.try_add_tab("Backtrace"_string)); - backtrace_tab->set_layout(4); + auto& backtrace_tab = tab_widget.add_tab("Backtrace"_string); + backtrace_tab.set_layout(4); - auto backtrace_label = TRY(backtrace_tab->try_add("A backtrace for each thread alive during the crash is listed below:"_string)); + auto backtrace_label = TRY(backtrace_tab.try_add("A backtrace for each thread alive during the crash is listed below:"_string)); backtrace_label->set_text_alignment(Gfx::TextAlignment::CenterLeft); backtrace_label->set_fixed_height(16); - auto backtrace_tab_widget = TRY(backtrace_tab->try_add()); + auto backtrace_tab_widget = TRY(backtrace_tab.try_add()); backtrace_tab_widget->set_tab_position(GUI::TabWidget::TabPosition::Bottom); - auto cpu_registers_tab = TRY(tab_widget.try_add_tab("CPU Registers"_string)); - cpu_registers_tab->set_layout(4); + auto& cpu_registers_tab = tab_widget.add_tab("CPU Registers"_string); + cpu_registers_tab.set_layout(4); - auto cpu_registers_label = TRY(cpu_registers_tab->try_add("The CPU register state for each thread alive during the crash is listed below:"_string)); + auto cpu_registers_label = TRY(cpu_registers_tab.try_add("The CPU register state for each thread alive during the crash is listed below:"_string)); cpu_registers_label->set_text_alignment(Gfx::TextAlignment::CenterLeft); cpu_registers_label->set_fixed_height(16); - auto cpu_registers_tab_widget = TRY(cpu_registers_tab->try_add()); + auto cpu_registers_tab_widget = TRY(cpu_registers_tab.try_add()); cpu_registers_tab_widget->set_tab_position(GUI::TabWidget::TabPosition::Bottom); - auto environment_tab = TRY(tab_widget.try_add_tab("Environment"_string)); - environment_tab->set_layout(4); + auto& environment_tab = tab_widget.add_tab("Environment"_string); + environment_tab.set_layout(4); - auto environment_text_editor = TRY(environment_tab->try_add()); + auto environment_text_editor = TRY(environment_tab.try_add()); environment_text_editor->set_text(DeprecatedString::join('\n', environment)); environment_text_editor->set_mode(GUI::TextEditor::Mode::ReadOnly); environment_text_editor->set_wrapping_mode(GUI::TextEditor::WrappingMode::NoWrap); environment_text_editor->set_should_hide_unnecessary_scrollbars(true); - auto memory_regions_tab = TRY(tab_widget.try_add_tab("Memory Regions"_string)); - memory_regions_tab->set_layout(4); + auto& memory_regions_tab = tab_widget.add_tab("Memory Regions"_string); + memory_regions_tab.set_layout(4); - auto memory_regions_text_editor = TRY(memory_regions_tab->try_add()); + auto memory_regions_text_editor = TRY(memory_regions_tab.try_add()); memory_regions_text_editor->set_text(DeprecatedString::join('\n', memory_regions)); memory_regions_text_editor->set_mode(GUI::TextEditor::Mode::ReadOnly); memory_regions_text_editor->set_wrapping_mode(GUI::TextEditor::WrappingMode::NoWrap); @@ -330,9 +330,9 @@ ErrorOr serenity_main(Main::Arguments arguments) }, [&](auto results) -> ErrorOr { for (auto& backtrace : results.thread_backtraces) { - auto container = TRY(backtrace_tab_widget->try_add_tab(TRY(String::from_deprecated_string(backtrace.title)))); - container->template set_layout(4); - auto backtrace_text_editor = TRY(container->template try_add()); + auto& container = backtrace_tab_widget->add_tab(TRY(String::from_deprecated_string(backtrace.title))); + container.template set_layout(4); + auto backtrace_text_editor = TRY(container.template try_add()); backtrace_text_editor->set_text(backtrace.text); backtrace_text_editor->set_mode(GUI::TextEditor::Mode::ReadOnly); backtrace_text_editor->set_wrapping_mode(GUI::TextEditor::WrappingMode::NoWrap); @@ -341,9 +341,9 @@ ErrorOr serenity_main(Main::Arguments arguments) } for (auto& cpu_registers : results.thread_cpu_registers) { - auto container = TRY(cpu_registers_tab_widget->try_add_tab(TRY(String::from_deprecated_string(cpu_registers.title)))); - container->template set_layout(4); - auto cpu_registers_text_editor = TRY(container->template try_add()); + auto& container = cpu_registers_tab_widget->add_tab(TRY(String::from_deprecated_string(cpu_registers.title))); + container.template set_layout(4); + auto cpu_registers_text_editor = TRY(container.template try_add()); cpu_registers_text_editor->set_text(cpu_registers.text); cpu_registers_text_editor->set_mode(GUI::TextEditor::Mode::ReadOnly); cpu_registers_text_editor->set_wrapping_mode(GUI::TextEditor::WrappingMode::NoWrap); diff --git a/Userland/Applications/FileManager/PropertiesWindow.cpp b/Userland/Applications/FileManager/PropertiesWindow.cpp index fa99ab1e82..b0e235ba98 100644 --- a/Userland/Applications/FileManager/PropertiesWindow.cpp +++ b/Userland/Applications/FileManager/PropertiesWindow.cpp @@ -120,12 +120,12 @@ ErrorOr PropertiesWindow::create_widgets(bool disable_rename) ErrorOr PropertiesWindow::create_general_tab(GUI::TabWidget& tab_widget, bool disable_rename) { - auto general_tab = TRY(tab_widget.try_add_tab("General"_string)); - TRY(general_tab->load_from_gml(properties_window_general_tab_gml)); + auto& general_tab = tab_widget.add_tab("General"_string); + TRY(general_tab.load_from_gml(properties_window_general_tab_gml)); - m_icon = general_tab->find_descendant_of_type_named("icon"); + m_icon = general_tab.find_descendant_of_type_named("icon"); - m_name_box = general_tab->find_descendant_of_type_named("name"); + m_name_box = general_tab.find_descendant_of_type_named("name"); m_name_box->set_text(m_name); m_name_box->set_mode(disable_rename ? GUI::TextBox::Mode::DisplayOnly : GUI::TextBox::Mode::Editable); m_name_box->on_change = [&]() { @@ -133,7 +133,7 @@ ErrorOr PropertiesWindow::create_general_tab(GUI::TabWidget& tab_widget, b m_apply_button->set_enabled(m_name_dirty || m_permissions_dirty); }; - auto* location = general_tab->find_descendant_of_type_named("location"); + auto* location = general_tab.find_descendant_of_type_named("location"); 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)); @@ -159,7 +159,7 @@ ErrorOr PropertiesWindow::create_general_tab(GUI::TabWidget& tab_widget, b m_mode = st.st_mode; m_old_mode = st.st_mode; - auto* type = general_tab->find_descendant_of_type_named("type"); + auto* type = general_tab.find_descendant_of_type_named("type"); type->set_text(TRY(String::from_utf8(get_description(m_mode)))); if (S_ISLNK(m_mode)) { @@ -168,7 +168,7 @@ ErrorOr PropertiesWindow::create_general_tab(GUI::TabWidget& tab_widget, b perror("readlink"); } else { auto link_destination = link_destination_or_error.release_value(); - auto* link_location = general_tab->find_descendant_of_type_named("link_location"); + auto* link_location = general_tab.find_descendant_of_type_named("link_location"); link_location->set_text(link_destination); link_location->on_click = [link_destination] { auto link_directory = LexicalPath(link_destination.to_deprecated_string()); @@ -176,40 +176,40 @@ ErrorOr PropertiesWindow::create_general_tab(GUI::TabWidget& tab_widget, b }; } } else { - auto* link_location_widget = general_tab->find_descendant_of_type_named("link_location_widget"); - general_tab->remove_child(*link_location_widget); + auto* link_location_widget = general_tab.find_descendant_of_type_named("link_location_widget"); + general_tab.remove_child(*link_location_widget); } - m_size_label = general_tab->find_descendant_of_type_named("size"); + m_size_label = general_tab.find_descendant_of_type_named("size"); m_size_label->set_text(S_ISDIR(st.st_mode) ? "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("owner"); + auto* owner = general_tab.find_descendant_of_type_named("owner"); 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("group"); + auto* group = general_tab.find_descendant_of_type_named("group"); 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("created_at"); + auto* created_at = general_tab.find_descendant_of_type_named("created_at"); 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("last_modified"); + auto* last_modified = general_tab.find_descendant_of_type_named("last_modified"); 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("owner_read"); - auto* owner_write = general_tab->find_descendant_of_type_named("owner_write"); - auto* owner_execute = general_tab->find_descendant_of_type_named("owner_execute"); + auto* owner_read = general_tab.find_descendant_of_type_named("owner_read"); + auto* owner_write = general_tab.find_descendant_of_type_named("owner_write"); + auto* owner_execute = general_tab.find_descendant_of_type_named("owner_execute"); TRY(setup_permission_checkboxes(*owner_read, *owner_write, *owner_execute, { S_IRUSR, S_IWUSR, S_IXUSR }, m_mode)); - auto* group_read = general_tab->find_descendant_of_type_named("group_read"); - auto* group_write = general_tab->find_descendant_of_type_named("group_write"); - auto* group_execute = general_tab->find_descendant_of_type_named("group_execute"); + auto* group_read = general_tab.find_descendant_of_type_named("group_read"); + auto* group_write = general_tab.find_descendant_of_type_named("group_write"); + auto* group_execute = general_tab.find_descendant_of_type_named("group_execute"); TRY(setup_permission_checkboxes(*group_read, *group_write, *group_execute, { S_IRGRP, S_IWGRP, S_IXGRP }, m_mode)); - auto* others_read = general_tab->find_descendant_of_type_named("others_read"); - auto* others_write = general_tab->find_descendant_of_type_named("others_write"); - auto* others_execute = general_tab->find_descendant_of_type_named("others_execute"); + auto* others_read = general_tab.find_descendant_of_type_named("others_read"); + auto* others_write = general_tab.find_descendant_of_type_named("others_write"); + auto* others_execute = general_tab.find_descendant_of_type_named("others_execute"); TRY(setup_permission_checkboxes(*others_read, *others_write, *others_execute, { S_IROTH, S_IWOTH, S_IXOTH }, m_mode)); return {}; @@ -255,15 +255,15 @@ ErrorOr PropertiesWindow::create_archive_tab(GUI::TabWidget& tab_widget, N } auto zip = maybe_zip.release_value(); - auto tab = TRY(tab_widget.try_add_tab("Archive"_string)); - TRY(tab->load_from_gml(properties_window_archive_tab_gml)); + auto& tab = tab_widget.add_tab("Archive"_string); + TRY(tab.load_from_gml(properties_window_archive_tab_gml)); auto statistics = TRY(zip.calculate_statistics()); - tab->find_descendant_of_type_named("archive_format")->set_text("ZIP"_string); - tab->find_descendant_of_type_named("archive_file_count")->set_text(TRY(String::number(statistics.file_count()))); - tab->find_descendant_of_type_named("archive_directory_count")->set_text(TRY(String::number(statistics.directory_count()))); - tab->find_descendant_of_type_named("archive_uncompressed_size")->set_text(TRY(String::from_deprecated_string(AK::human_readable_size(statistics.total_uncompressed_bytes())))); + tab.find_descendant_of_type_named("archive_file_count")->set_text(TRY(String::number(statistics.file_count()))); + tab.find_descendant_of_type_named("archive_format")->set_text("ZIP"_string); + tab.find_descendant_of_type_named("archive_directory_count")->set_text(TRY(String::number(statistics.directory_count()))); + tab.find_descendant_of_type_named("archive_uncompressed_size")->set_text(TRY(String::from_deprecated_string(AK::human_readable_size(statistics.total_uncompressed_bytes())))); return {}; } @@ -277,14 +277,14 @@ ErrorOr PropertiesWindow::create_audio_tab(GUI::TabWidget& tab_widget, Non } auto loader = loader_or_error.release_value(); - auto tab = TRY(tab_widget.try_add_tab("Audio"_string)); - TRY(tab->load_from_gml(properties_window_audio_tab_gml)); + auto& tab = tab_widget.add_tab("Audio"_string); + TRY(tab.load_from_gml(properties_window_audio_tab_gml)); - tab->find_descendant_of_type_named("audio_type")->set_text(TRY(String::from_deprecated_string(loader->format_name()))); + tab.find_descendant_of_type_named("audio_type")->set_text(TRY(String::from_deprecated_string(loader->format_name()))); auto duration_seconds = loader->total_samples() / loader->sample_rate(); - tab->find_descendant_of_type_named("audio_duration")->set_text(TRY(String::from_deprecated_string(human_readable_digital_time(duration_seconds)))); - tab->find_descendant_of_type_named("audio_sample_rate")->set_text(TRY(String::formatted("{} Hz", loader->sample_rate()))); - tab->find_descendant_of_type_named("audio_format")->set_text(TRY(String::formatted("{}-bit", loader->bits_per_sample()))); + tab.find_descendant_of_type_named("audio_duration")->set_text(TRY(String::from_deprecated_string(human_readable_digital_time(duration_seconds)))); + tab.find_descendant_of_type_named("audio_sample_rate")->set_text(TRY(String::formatted("{} Hz", loader->sample_rate()))); + tab.find_descendant_of_type_named("audio_format")->set_text(TRY(String::formatted("{}-bit", loader->bits_per_sample()))); auto channel_count = loader->num_channels(); String channels_string; @@ -293,15 +293,15 @@ ErrorOr PropertiesWindow::create_audio_tab(GUI::TabWidget& tab_widget, Non } else { channels_string = TRY(String::number(channel_count)); } - tab->find_descendant_of_type_named("audio_channels")->set_text(channels_string); + tab.find_descendant_of_type_named("audio_channels")->set_text(channels_string); - tab->find_descendant_of_type_named("audio_title")->set_text(loader->metadata().title.value_or({})); - tab->find_descendant_of_type_named("audio_artists")->set_text(TRY(loader->metadata().all_artists()).value_or({})); - tab->find_descendant_of_type_named("audio_album")->set_text(loader->metadata().album.value_or({})); - tab->find_descendant_of_type_named("audio_track_number") + tab.find_descendant_of_type_named("audio_title")->set_text(loader->metadata().title.value_or({})); + tab.find_descendant_of_type_named("audio_artists")->set_text(TRY(loader->metadata().all_artists()).value_or({})); + tab.find_descendant_of_type_named("audio_album")->set_text(loader->metadata().album.value_or({})); + tab.find_descendant_of_type_named("audio_track_number") ->set_text(TRY(loader->metadata().track_number.map([](auto number) { return String::number(number); })).value_or({})); - tab->find_descendant_of_type_named("audio_genre")->set_text(loader->metadata().genre.value_or({})); - tab->find_descendant_of_type_named("audio_comment")->set_text(loader->metadata().comment.value_or({})); + tab.find_descendant_of_type_named("audio_genre")->set_text(loader->metadata().genre.value_or({})); + tab.find_descendant_of_type_named("audio_comment")->set_text(loader->metadata().comment.value_or({})); return {}; } @@ -359,8 +359,8 @@ ErrorOr PropertiesWindow::create_font_tab(GUI::TabWidget& tab_widget, Nonn auto font_info = font_info_or_error.release_value(); auto& typeface = font_info.typeface; - auto tab = TRY(tab_widget.try_add_tab("Font"_string)); - TRY(tab->load_from_gml(properties_window_font_tab_gml)); + auto& tab = tab_widget.add_tab("Font"_string); + TRY(tab.load_from_gml(properties_window_font_tab_gml)); String format_name; switch (font_info.format) { @@ -380,10 +380,10 @@ ErrorOr PropertiesWindow::create_font_tab(GUI::TabWidget& tab_widget, Nonn format_name = "WOFF2"_string; break; } - tab->find_descendant_of_type_named("font_format")->set_text(format_name); - tab->find_descendant_of_type_named("font_family")->set_text(typeface->family().to_string()); - tab->find_descendant_of_type_named("font_fixed_width")->set_text(typeface->is_fixed_width() ? "Yes"_string : "No"_string); - tab->find_descendant_of_type_named("font_width")->set_text(TRY(String::from_utf8(Gfx::width_to_name(static_cast(typeface->width()))))); + tab.find_descendant_of_type_named("font_family")->set_text(typeface->family().to_string()); + tab.find_descendant_of_type_named("font_fixed_width")->set_text(typeface->is_fixed_width() ? "Yes"_string : "No"_string); + tab.find_descendant_of_type_named("font_format")->set_text(format_name); + tab.find_descendant_of_type_named("font_width")->set_text(TRY(String::from_utf8(Gfx::width_to_name(static_cast(typeface->width()))))); auto nearest_weight_class_name = [](unsigned weight) { if (weight > 925) @@ -392,8 +392,8 @@ ErrorOr PropertiesWindow::create_font_tab(GUI::TabWidget& tab_widget, Nonn return Gfx::weight_to_name(weight_class); }; auto weight = typeface->weight(); - tab->find_descendant_of_type_named("font_weight")->set_text(TRY(String::formatted("{} ({})", weight, nearest_weight_class_name(weight)))); - tab->find_descendant_of_type_named("font_slope")->set_text(TRY(String::from_utf8(Gfx::slope_to_name(typeface->slope())))); + tab.find_descendant_of_type_named("font_weight")->set_text(TRY(String::formatted("{} ({})", weight, nearest_weight_class_name(weight)))); + tab.find_descendant_of_type_named("font_slope")->set_text(TRY(String::from_utf8(Gfx::slope_to_name(typeface->slope())))); return {}; } @@ -404,11 +404,11 @@ ErrorOr PropertiesWindow::create_image_tab(GUI::TabWidget& tab_widget, Non if (!image_decoder) return {}; - auto tab = TRY(tab_widget.try_add_tab("Image"_string)); - TRY(tab->load_from_gml(properties_window_image_tab_gml)); + auto& tab = tab_widget.add_tab("Image"_string); + TRY(tab.load_from_gml(properties_window_image_tab_gml)); - tab->find_descendant_of_type_named("image_type")->set_text(TRY(String::from_utf8(mime_type))); - tab->find_descendant_of_type_named("image_size")->set_text(TRY(String::formatted("{} x {}", image_decoder->width(), image_decoder->height()))); + tab.find_descendant_of_type_named("image_type")->set_text(TRY(String::from_utf8(mime_type))); + tab.find_descendant_of_type_named("image_size")->set_text(TRY(String::formatted("{} x {}", image_decoder->width(), image_decoder->height()))); String animation_text; if (image_decoder->is_animated()) { @@ -428,11 +428,11 @@ ErrorOr PropertiesWindow::create_image_tab(GUI::TabWidget& tab_widget, Non } else { animation_text = "None"_string; } - tab->find_descendant_of_type_named("image_animation")->set_text(move(animation_text)); + tab.find_descendant_of_type_named("image_animation")->set_text(move(animation_text)); auto hide_icc_group = [&tab](String profile_text) { - tab->find_descendant_of_type_named("image_has_icc_profile")->set_text(profile_text); - tab->find_descendant_of_type_named("image_icc_group")->set_visible(false); + tab.find_descendant_of_type_named("image_has_icc_profile")->set_text(profile_text); + tab.find_descendant_of_type_named("image_icc_group")->set_visible(false); }; if (auto embedded_icc_bytes = TRY(image_decoder->icc_data()); embedded_icc_bytes.has_value()) { @@ -442,11 +442,11 @@ ErrorOr PropertiesWindow::create_image_tab(GUI::TabWidget& tab_widget, Non } else { auto icc_profile = icc_profile_or_error.release_value(); - tab->find_descendant_of_type_named("image_has_icc_profile")->set_text("See below"_string); - tab->find_descendant_of_type_named("image_icc_profile")->set_text(icc_profile->tag_string_data(Gfx::ICC::profileDescriptionTag).value_or({})); - tab->find_descendant_of_type_named("image_icc_copyright")->set_text(icc_profile->tag_string_data(Gfx::ICC::copyrightTag).value_or({})); - tab->find_descendant_of_type_named("image_icc_color_space")->set_text(TRY(String::from_utf8(data_color_space_name(icc_profile->data_color_space())))); - tab->find_descendant_of_type_named("image_icc_device_class")->set_text(TRY(String::from_utf8((device_class_name(icc_profile->device_class()))))); + tab.find_descendant_of_type_named("image_has_icc_profile")->set_text("See below"_string); + tab.find_descendant_of_type_named("image_icc_profile")->set_text(icc_profile->tag_string_data(Gfx::ICC::profileDescriptionTag).value_or({})); + tab.find_descendant_of_type_named("image_icc_copyright")->set_text(icc_profile->tag_string_data(Gfx::ICC::copyrightTag).value_or({})); + tab.find_descendant_of_type_named("image_icc_color_space")->set_text(TRY(String::from_utf8(data_color_space_name(icc_profile->data_color_space())))); + tab.find_descendant_of_type_named("image_icc_device_class")->set_text(TRY(String::from_utf8((device_class_name(icc_profile->device_class()))))); } } else { @@ -467,8 +467,8 @@ ErrorOr PropertiesWindow::create_pdf_tab(GUI::TabWidget& tab_widget, Nonnu if (auto handler = document->security_handler(); handler && !handler->has_user_password()) { // FIXME: Show a password dialog, once we've switched to lazy-loading - auto tab = TRY(tab_widget.try_add_tab("PDF"_string)); - tab->set_text("PDF is password-protected."_string); + auto& tab = tab_widget.add_tab("PDF"_string); + tab.set_text("PDF is password-protected."_string); return {}; } @@ -477,11 +477,11 @@ ErrorOr PropertiesWindow::create_pdf_tab(GUI::TabWidget& tab_widget, Nonnu return {}; } - auto tab = TRY(tab_widget.try_add_tab("PDF"_string)); - TRY(tab->load_from_gml(properties_window_pdf_tab_gml)); + auto& tab = tab_widget.add_tab("PDF"_string); + TRY(tab.load_from_gml(properties_window_pdf_tab_gml)); - tab->find_descendant_of_type_named("pdf_version")->set_text(TRY(String::formatted("{}.{}", document->version().major, document->version().minor))); - tab->find_descendant_of_type_named("pdf_page_count")->set_text(TRY(String::number(document->get_page_count()))); + tab.find_descendant_of_type_named("pdf_version")->set_text(TRY(String::formatted("{}.{}", document->version().major, document->version().minor))); + tab.find_descendant_of_type_named("pdf_page_count")->set_text(TRY(String::number(document->get_page_count()))); auto maybe_info_dict = document->info_dict(); if (maybe_info_dict.is_error()) { @@ -496,14 +496,14 @@ ErrorOr PropertiesWindow::create_pdf_tab(GUI::TabWidget& tab_widget, Nonnu }; auto info_dict = maybe_info_dict.release_value().release_value(); - tab->find_descendant_of_type_named("pdf_title")->set_text(TRY(get_info_string(info_dict.title()))); - tab->find_descendant_of_type_named("pdf_author")->set_text(TRY(get_info_string(info_dict.author()))); - tab->find_descendant_of_type_named("pdf_subject")->set_text(TRY(get_info_string(info_dict.subject()))); - tab->find_descendant_of_type_named("pdf_keywords")->set_text(TRY(get_info_string(info_dict.keywords()))); - tab->find_descendant_of_type_named("pdf_creator")->set_text(TRY(get_info_string(info_dict.creator()))); - tab->find_descendant_of_type_named("pdf_producer")->set_text(TRY(get_info_string(info_dict.producer()))); - tab->find_descendant_of_type_named("pdf_creation_date")->set_text(TRY(get_info_string(info_dict.creation_date()))); - tab->find_descendant_of_type_named("pdf_modification_date")->set_text(TRY(get_info_string(info_dict.modification_date()))); + tab.find_descendant_of_type_named("pdf_title")->set_text(TRY(get_info_string(info_dict.title()))); + tab.find_descendant_of_type_named("pdf_author")->set_text(TRY(get_info_string(info_dict.author()))); + tab.find_descendant_of_type_named("pdf_subject")->set_text(TRY(get_info_string(info_dict.subject()))); + tab.find_descendant_of_type_named("pdf_keywords")->set_text(TRY(get_info_string(info_dict.keywords()))); + tab.find_descendant_of_type_named("pdf_creator")->set_text(TRY(get_info_string(info_dict.creator()))); + tab.find_descendant_of_type_named("pdf_producer")->set_text(TRY(get_info_string(info_dict.producer()))); + tab.find_descendant_of_type_named("pdf_creation_date")->set_text(TRY(get_info_string(info_dict.creation_date()))); + tab.find_descendant_of_type_named("pdf_modification_date")->set_text(TRY(get_info_string(info_dict.modification_date()))); } return {}; diff --git a/Userland/Applications/Piano/MainWidget.cpp b/Userland/Applications/Piano/MainWidget.cpp index b36dcfb1f6..0e3f8664ec 100644 --- a/Userland/Applications/Piano/MainWidget.cpp +++ b/Userland/Applications/Piano/MainWidget.cpp @@ -44,11 +44,11 @@ ErrorOr MainWidget::initialize() TRY(m_wave_widget->set_sample_size(sample_count)); m_tab_widget = TRY(try_add()); - m_roll_widget = TRY(m_tab_widget->try_add_tab("Piano Roll"_string, m_track_manager)); + m_roll_widget = m_tab_widget->add_tab("Piano Roll"_string, m_track_manager); m_roll_widget->set_fixed_height(300); - (void)TRY(m_tab_widget->try_add_tab("Sampler"_string, m_track_manager)); + m_tab_widget->add_tab("Sampler"_string, m_track_manager); m_player_widget = TRY(try_add(m_track_manager, *this, m_audio_loop)); m_keys_and_knobs_container = TRY(try_add()); diff --git a/Userland/Applications/ThemeEditor/MainWidget.cpp b/Userland/Applications/ThemeEditor/MainWidget.cpp index fd5aad2281..6548c6ba80 100644 --- a/Userland/Applications/ThemeEditor/MainWidget.cpp +++ b/Userland/Applications/ThemeEditor/MainWidget.cpp @@ -461,11 +461,11 @@ void MainWidget::build_override_controls() ErrorOr MainWidget::add_property_tab(PropertyTab const& property_tab) { - auto scrollable_container = TRY(m_property_tabs->try_add_tab(TRY(String::from_utf8(property_tab.title)))); - scrollable_container->set_should_hide_unnecessary_scrollbars(true); + auto& scrollable_container = m_property_tabs->add_tab(TRY(String::from_utf8(property_tab.title))); + scrollable_container.set_should_hide_unnecessary_scrollbars(true); auto properties_list = TRY(GUI::Widget::try_create()); - scrollable_container->set_widget(properties_list); + scrollable_container.set_widget(properties_list); properties_list->set_layout(GUI::Margins { 8 }, 12); for (auto const& group : property_tab.property_groups) { diff --git a/Userland/Demos/ModelGallery/GalleryWidget.cpp b/Userland/Demos/ModelGallery/GalleryWidget.cpp index ae5b792588..1aff265d66 100644 --- a/Userland/Demos/ModelGallery/GalleryWidget.cpp +++ b/Userland/Demos/ModelGallery/GalleryWidget.cpp @@ -24,11 +24,11 @@ GalleryWidget::GalleryWidget() ErrorOr GalleryWidget::load_basic_model_tab() { - auto tab = TRY(m_tab_widget->try_add_tab("Basic Model"_string)); - TRY(tab->load_from_gml(basic_model_tab_gml)); + auto& tab = m_tab_widget->add_tab("Basic Model"_string); + TRY(tab.load_from_gml(basic_model_tab_gml)); m_basic_model = BasicModel::create(); - m_basic_model_table = *tab->find_descendant_of_type_named("model_table"); + m_basic_model_table = *tab.find_descendant_of_type_named("model_table"); m_basic_model_table->set_model(m_basic_model); m_basic_model->on_invalidate = [&] { @@ -42,9 +42,9 @@ ErrorOr GalleryWidget::load_basic_model_tab() m_basic_model->add_item("...hello..."); m_basic_model->add_item("...friends! :^)"); - m_new_item_name = *tab->find_descendant_of_type_named("new_item_name"); - m_add_new_item = *tab->find_descendant_of_type_named("add_new_item"); - m_remove_selected_item = *tab->find_descendant_of_type_named("remove_selected_item"); + m_new_item_name = *tab.find_descendant_of_type_named("new_item_name"); + m_add_new_item = *tab.find_descendant_of_type_named("add_new_item"); + m_remove_selected_item = *tab.find_descendant_of_type_named("remove_selected_item"); m_add_new_item->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/plus.png"sv).release_value_but_fixme_should_propagate_errors()); m_remove_selected_item->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/minus.png"sv).release_value_but_fixme_should_propagate_errors()); diff --git a/Userland/Demos/WidgetGallery/GalleryWidget.cpp b/Userland/Demos/WidgetGallery/GalleryWidget.cpp index 86aeb53c7f..4acf3fea41 100644 --- a/Userland/Demos/WidgetGallery/GalleryWidget.cpp +++ b/Userland/Demos/WidgetGallery/GalleryWidget.cpp @@ -36,11 +36,11 @@ GalleryWidget::GalleryWidget() auto& tab_widget = *find_descendant_of_type_named("tab_widget"); - auto basics_tab = tab_widget.try_add_tab("Basics"_string).release_value_but_fixme_should_propagate_errors(); - basics_tab->load_from_gml(basics_tab_gml).release_value_but_fixme_should_propagate_errors(); + auto& basics_tab = tab_widget.add_tab("Basics"_string); + basics_tab.load_from_gml(basics_tab_gml).release_value_but_fixme_should_propagate_errors(); - m_enabled_label = basics_tab->find_descendant_of_type_named("enabled_label"); - m_label_frame = basics_tab->find_descendant_of_type_named("label_frame"); + m_enabled_label = basics_tab.find_descendant_of_type_named("enabled_label"); + m_label_frame = basics_tab.find_descendant_of_type_named("label_frame"); m_frame_shapes.append("No Frame"); m_frame_shapes.append("Window"); @@ -52,7 +52,7 @@ GalleryWidget::GalleryWidget() m_frame_shapes.append("Raised Panel"); m_frame_shapes.append("Sunken Panel"); - m_frame_shape_combobox = basics_tab->find_descendant_of_type_named("frame_style_combobox"); + m_frame_shape_combobox = basics_tab.find_descendant_of_type_named("frame_style_combobox"); m_frame_shape_combobox->set_model(*GUI::ItemListModel::create(m_frame_shapes)); m_frame_shape_combobox->on_change = [&](auto&, auto const& index) { @@ -68,10 +68,10 @@ GalleryWidget::GalleryWidget() m_button_icons.append(Gfx::Bitmap::load_from_file("/res/icons/16x16/inspector-object.png"sv).release_value_but_fixme_should_propagate_errors()); m_button_icons.append(Gfx::Bitmap::load_from_file("/res/icons/16x16/ladybug.png"sv).release_value_but_fixme_should_propagate_errors()); - m_icon_button = basics_tab->find_descendant_of_type_named("icon_button"); + m_icon_button = basics_tab.find_descendant_of_type_named("icon_button"); m_icon_button->set_icon(*m_button_icons[2]); - m_disabled_icon_button = basics_tab->find_descendant_of_type_named("disabled_icon_button"); + m_disabled_icon_button = basics_tab.find_descendant_of_type_named("disabled_icon_button"); m_disabled_icon_button->set_icon(*m_button_icons[2]); m_icon_button->on_click = [&](auto) { @@ -83,9 +83,9 @@ GalleryWidget::GalleryWidget() i++; }; - m_text_editor = basics_tab->find_descendant_of_type_named("text_editor"); + m_text_editor = basics_tab.find_descendant_of_type_named("text_editor"); - m_font_button = basics_tab->find_descendant_of_type_named("font_button"); + m_font_button = basics_tab.find_descendant_of_type_named("font_button"); m_font_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-font-editor.png"sv).release_value_but_fixme_should_propagate_errors()); m_font_button->on_click = [&](auto) { @@ -95,7 +95,7 @@ GalleryWidget::GalleryWidget() } }; - m_file_button = basics_tab->find_descendant_of_type_named("file_button"); + m_file_button = basics_tab.find_descendant_of_type_named("file_button"); m_file_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"sv).release_value_but_fixme_should_propagate_errors()); m_file_button->on_click = [&](auto) { @@ -105,7 +105,7 @@ GalleryWidget::GalleryWidget() m_text_editor->set_text(response.release_value().filename()); }; - m_input_button = basics_tab->find_descendant_of_type_named("input_button"); + m_input_button = basics_tab.find_descendant_of_type_named("input_button"); m_input_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/properties.png"sv).release_value_but_fixme_should_propagate_errors()); m_input_button->on_click = [&](auto) { @@ -114,7 +114,7 @@ GalleryWidget::GalleryWidget() m_text_editor->set_text(value); }; - m_font_colorinput = basics_tab->find_descendant_of_type_named("font_colorinput"); + m_font_colorinput = basics_tab.find_descendant_of_type_named("font_colorinput"); m_font_colorinput->on_change = [&]() { auto palette = m_text_editor->palette(); @@ -123,7 +123,7 @@ GalleryWidget::GalleryWidget() m_text_editor->update(); }; - m_msgbox_button = basics_tab->find_descendant_of_type_named("msgbox_button"); + m_msgbox_button = basics_tab.find_descendant_of_type_named("msgbox_button"); m_msgbox_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-browser.png"sv).release_value_but_fixme_should_propagate_errors()); m_msgbox_type = GUI::MessageBox::Type::None; @@ -140,7 +140,7 @@ GalleryWidget::GalleryWidget() m_msgbox_buttons.append("Yes No"); m_msgbox_buttons.append("Yes No Cancel"); - m_msgbox_icon_combobox = basics_tab->find_descendant_of_type_named("msgbox_icon_combobox"); + m_msgbox_icon_combobox = basics_tab.find_descendant_of_type_named("msgbox_icon_combobox"); m_msgbox_icon_combobox->set_model(*GUI::ItemListModel::create(m_msgbox_icons)); m_msgbox_icon_combobox->set_selected_index(0); @@ -148,7 +148,7 @@ GalleryWidget::GalleryWidget() m_msgbox_type = static_cast(index.row()); }; - m_msgbox_buttons_combobox = basics_tab->find_descendant_of_type_named("msgbox_buttons_combobox"); + m_msgbox_buttons_combobox = basics_tab.find_descendant_of_type_named("msgbox_buttons_combobox"); m_msgbox_buttons_combobox->set_model(*GUI::ItemListModel::create(m_msgbox_buttons)); m_msgbox_buttons_combobox->set_selected_index(0); @@ -160,17 +160,17 @@ GalleryWidget::GalleryWidget() GUI::MessageBox::show(window(), m_text_editor->text(), "Message"sv, m_msgbox_type, m_msgbox_input_type); }; - auto sliders_tab = tab_widget.try_add_tab("Sliders"_string).release_value_but_fixme_should_propagate_errors(); - sliders_tab->load_from_gml(sliders_tab_gml).release_value_but_fixme_should_propagate_errors(); + auto& sliders_tab = tab_widget.add_tab("Sliders"_string); + sliders_tab.load_from_gml(sliders_tab_gml).release_value_but_fixme_should_propagate_errors(); - m_vertical_progressbar_left = sliders_tab->find_descendant_of_type_named("vertical_progressbar_left"); + m_vertical_progressbar_left = sliders_tab.find_descendant_of_type_named("vertical_progressbar_left"); m_vertical_progressbar_left->set_value(0); - m_vertical_progressbar_right = sliders_tab->find_descendant_of_type_named("vertical_progressbar_right"); + m_vertical_progressbar_right = sliders_tab.find_descendant_of_type_named("vertical_progressbar_right"); m_vertical_progressbar_right->set_value(100); - m_vertical_slider_left = sliders_tab->find_descendant_of_type_named("vertical_slider_left"); - m_vertical_slider_right = sliders_tab->find_descendant_of_type_named("vertical_slider_right"); + m_vertical_slider_left = sliders_tab.find_descendant_of_type_named("vertical_slider_left"); + m_vertical_slider_right = sliders_tab.find_descendant_of_type_named("vertical_slider_right"); m_vertical_slider_left->on_change = [&](auto value) { m_vertical_progressbar_left->set_value(m_vertical_slider_left->max() - value); @@ -180,11 +180,11 @@ GalleryWidget::GalleryWidget() m_vertical_progressbar_right->set_value((100 / m_vertical_slider_right->max()) * (m_vertical_slider_right->max() - value)); }; - m_horizontal_progressbar = sliders_tab->find_descendant_of_type_named("horizontal_progressbar"); + m_horizontal_progressbar = sliders_tab.find_descendant_of_type_named("horizontal_progressbar"); m_horizontal_progressbar->set_value(0); - m_horizontal_slider_left = sliders_tab->find_descendant_of_type_named("horizontal_slider_left"); - m_horizontal_slider_right = sliders_tab->find_descendant_of_type_named("horizontal_slider_right"); + m_horizontal_slider_left = sliders_tab.find_descendant_of_type_named("horizontal_slider_left"); + m_horizontal_slider_right = sliders_tab.find_descendant_of_type_named("horizontal_slider_right"); m_horizontal_slider_left->on_change = [&](auto value) { m_horizontal_progressbar->set_value(value); @@ -197,23 +197,23 @@ GalleryWidget::GalleryWidget() m_horizontal_slider_left->set_value((value * 100) / m_horizontal_slider_right->max()); }; - m_enabled_scrollbar = sliders_tab->find_descendant_of_type_named("enabled_scrollbar"); + m_enabled_scrollbar = sliders_tab.find_descendant_of_type_named("enabled_scrollbar"); m_enabled_scrollbar->set_orientation(Orientation::Horizontal); - m_disabled_scrollbar = sliders_tab->find_descendant_of_type_named("disabled_scrollbar"); + m_disabled_scrollbar = sliders_tab.find_descendant_of_type_named("disabled_scrollbar"); m_disabled_scrollbar->set_orientation(Orientation::Horizontal); - m_opacity_imagewidget = sliders_tab->find_descendant_of_type_named("opacity_imagewidget"); + m_opacity_imagewidget = sliders_tab.find_descendant_of_type_named("opacity_imagewidget"); m_opacity_imagewidget->load_from_file("/res/graphics/brand-banner.png"sv); - m_opacity_slider = sliders_tab->find_descendant_of_type_named("opacity_slider"); + m_opacity_slider = sliders_tab.find_descendant_of_type_named("opacity_slider"); m_opacity_slider->on_change = [&](auto percent) { m_opacity_imagewidget->set_opacity_percent(percent); m_opacity_value_slider->set_value(percent); }; - m_opacity_value_slider = sliders_tab->find_descendant_of_type_named("opacity_value_slider"); + m_opacity_value_slider = sliders_tab.find_descendant_of_type_named("opacity_value_slider"); m_opacity_value_slider->set_range(0, 100); m_opacity_value_slider->on_change = [&](auto percent) { @@ -221,11 +221,11 @@ GalleryWidget::GalleryWidget() m_opacity_slider->set_value(percent); }; - auto wizards_tab = tab_widget.try_add_tab("Wizards"_string).release_value_but_fixme_should_propagate_errors(); - wizards_tab->load_from_gml(wizards_tab_gml).release_value_but_fixme_should_propagate_errors(); + auto& wizards_tab = tab_widget.add_tab("Wizards"_string); + wizards_tab.load_from_gml(wizards_tab_gml).release_value_but_fixme_should_propagate_errors(); - m_wizard_button = wizards_tab->find_descendant_of_type_named("wizard_button"); - m_wizard_output = wizards_tab->find_descendant_of_type_named("wizard_output"); + m_wizard_button = wizards_tab.find_descendant_of_type_named("wizard_button"); + m_wizard_output = wizards_tab.find_descendant_of_type_named("wizard_output"); m_wizard_output->set_should_hide_unnecessary_scrollbars(true); char const* serenityos_ascii = { @@ -277,10 +277,10 @@ GalleryWidget::GalleryWidget() m_wizard_output->set_text(sb.string_view()); }; - auto cursors_tab = tab_widget.try_add_tab("Cursors"_string).release_value_but_fixme_should_propagate_errors(); - cursors_tab->load_from_gml(cursors_tab_gml).release_value_but_fixme_should_propagate_errors(); + auto& cursors_tab = tab_widget.add_tab("Cursors"_string); + cursors_tab.load_from_gml(cursors_tab_gml).release_value_but_fixme_should_propagate_errors(); - m_cursors_tableview = cursors_tab->find_descendant_of_type_named("cursors_tableview"); + m_cursors_tableview = cursors_tab.find_descendant_of_type_named("cursors_tableview"); m_cursors_tableview->set_highlight_selected_rows(true); m_cursors_tableview->set_alternating_row_colors(false); m_cursors_tableview->set_vertical_padding(16); @@ -300,10 +300,10 @@ GalleryWidget::GalleryWidget() m_cursors_tableview->set_override_cursor(NonnullRefPtr(icon_index.data().as_bitmap())); }; - auto icons_tab = tab_widget.try_add_tab("Icons"_string).release_value_but_fixme_should_propagate_errors(); - icons_tab->load_from_gml(icons_tab_gml).release_value_but_fixme_should_propagate_errors(); + auto& icons_tab = tab_widget.add_tab("Icons"_string); + icons_tab.load_from_gml(icons_tab_gml).release_value_but_fixme_should_propagate_errors(); - m_icons_tableview = icons_tab->find_descendant_of_type_named("icons_tableview"); + m_icons_tableview = icons_tab.find_descendant_of_type_named("icons_tableview"); m_icons_tableview->set_highlight_selected_rows(true); m_icons_tableview->set_alternating_row_colors(false); m_icons_tableview->set_vertical_padding(24); diff --git a/Userland/DevTools/Profiler/main.cpp b/Userland/DevTools/Profiler/main.cpp index 23617ee806..b94d5c1e00 100644 --- a/Userland/DevTools/Profiler/main.cpp +++ b/Userland/DevTools/Profiler/main.cpp @@ -132,9 +132,9 @@ ErrorOr serenity_main(Main::Arguments arguments) auto tab_widget = TRY(main_splitter->try_add()); - auto tree_tab = TRY(tab_widget->try_add_tab("Call Tree"_string)); - tree_tab->set_layout(4); - auto bottom_splitter = TRY(tree_tab->try_add()); + auto& tree_tab = tab_widget->add_tab("Call Tree"_string); + tree_tab.set_layout(4); + auto bottom_splitter = TRY(tree_tab.try_add()); auto tree_view = TRY(bottom_splitter->try_add()); tree_view->set_should_fill_selected_rows(true); @@ -181,10 +181,10 @@ ErrorOr serenity_main(Main::Arguments arguments) update_source_model(); }); - auto samples_tab = TRY(tab_widget->try_add_tab("Samples"_string)); - samples_tab->set_layout(4); + auto& samples_tab = tab_widget->add_tab("Samples"_string); + samples_tab.set_layout(4); - auto samples_splitter = TRY(samples_tab->try_add()); + auto samples_splitter = TRY(samples_tab.try_add()); auto samples_table_view = TRY(samples_splitter->try_add()); samples_table_view->set_model(profile->samples_model()); @@ -195,10 +195,10 @@ ErrorOr serenity_main(Main::Arguments arguments) individual_sample_view->set_model(move(model)); }; - auto signposts_tab = TRY(tab_widget->try_add_tab("Signposts"_string)); - signposts_tab->set_layout(4); + auto& signposts_tab = tab_widget->add_tab("Signposts"_string); + signposts_tab.set_layout(4); - auto signposts_splitter = TRY(signposts_tab->try_add()); + auto signposts_splitter = TRY(signposts_tab.try_add()); auto signposts_table_view = TRY(signposts_splitter->try_add()); signposts_table_view->set_model(profile->signposts_model()); @@ -209,10 +209,10 @@ ErrorOr serenity_main(Main::Arguments arguments) individual_signpost_view->set_model(move(model)); }; - auto flamegraph_tab = TRY(tab_widget->try_add_tab("Flame Graph"_string)); - flamegraph_tab->set_layout(GUI::Margins { 4, 4, 4, 4 }); + auto& flamegraph_tab = tab_widget->add_tab("Flame Graph"_string); + flamegraph_tab.set_layout(GUI::Margins { 4, 4, 4, 4 }); - auto flamegraph_view = TRY(flamegraph_tab->try_add(profile->model(), ProfileModel::Column::StackFrame, ProfileModel::Column::SampleCount)); + auto flamegraph_view = TRY(flamegraph_tab.try_add(profile->model(), ProfileModel::Column::StackFrame, ProfileModel::Column::SampleCount)); u64 const start_of_trace = profile->first_timestamp(); u64 const end_of_trace = start_of_trace + profile->length_in_ms(); @@ -257,10 +257,10 @@ ErrorOr serenity_main(Main::Arguments arguments) timeline_view->on_selection_change = [&] { statusbar_update(); }; flamegraph_view->on_hover_change = [&] { statusbar_update(); }; - auto filesystem_events_tab = TRY(tab_widget->try_add_tab("Filesystem events"_string)); - filesystem_events_tab->set_layout(4); + auto& filesystem_events_tab = tab_widget->add_tab("Filesystem events"_string); + filesystem_events_tab.set_layout(4); - auto filesystem_events_tree_view = TRY(filesystem_events_tab->try_add()); + auto filesystem_events_tree_view = TRY(filesystem_events_tab.try_add()); filesystem_events_tree_view->set_should_fill_selected_rows(true); filesystem_events_tree_view->set_column_headers_visible(true); filesystem_events_tree_view->set_selection_behavior(GUI::TreeView::SelectionBehavior::SelectRows);