mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
Applications: Make creation of tabs non-fallible
This commit is contained in:
parent
3c9dee5d5a
commit
ffda0785c0
|
@ -236,39 +236,39 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto& progressbar = *widget->find_descendant_of_type_named<GUI::Progressbar>("progressbar");
|
||||
auto& tab_widget = *widget->find_descendant_of_type_named<GUI::TabWidget>("tab_widget");
|
||||
|
||||
auto backtrace_tab = TRY(tab_widget.try_add_tab<GUI::Widget>("Backtrace"_string));
|
||||
backtrace_tab->set_layout<GUI::VerticalBoxLayout>(4);
|
||||
auto& backtrace_tab = tab_widget.add_tab<GUI::Widget>("Backtrace"_string);
|
||||
backtrace_tab.set_layout<GUI::VerticalBoxLayout>(4);
|
||||
|
||||
auto backtrace_label = TRY(backtrace_tab->try_add<GUI::Label>("A backtrace for each thread alive during the crash is listed below:"_string));
|
||||
auto backtrace_label = TRY(backtrace_tab.try_add<GUI::Label>("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<GUI::TabWidget>());
|
||||
auto backtrace_tab_widget = TRY(backtrace_tab.try_add<GUI::TabWidget>());
|
||||
backtrace_tab_widget->set_tab_position(GUI::TabWidget::TabPosition::Bottom);
|
||||
|
||||
auto cpu_registers_tab = TRY(tab_widget.try_add_tab<GUI::Widget>("CPU Registers"_string));
|
||||
cpu_registers_tab->set_layout<GUI::VerticalBoxLayout>(4);
|
||||
auto& cpu_registers_tab = tab_widget.add_tab<GUI::Widget>("CPU Registers"_string);
|
||||
cpu_registers_tab.set_layout<GUI::VerticalBoxLayout>(4);
|
||||
|
||||
auto cpu_registers_label = TRY(cpu_registers_tab->try_add<GUI::Label>("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<GUI::Label>("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<GUI::TabWidget>());
|
||||
auto cpu_registers_tab_widget = TRY(cpu_registers_tab.try_add<GUI::TabWidget>());
|
||||
cpu_registers_tab_widget->set_tab_position(GUI::TabWidget::TabPosition::Bottom);
|
||||
|
||||
auto environment_tab = TRY(tab_widget.try_add_tab<GUI::Widget>("Environment"_string));
|
||||
environment_tab->set_layout<GUI::VerticalBoxLayout>(4);
|
||||
auto& environment_tab = tab_widget.add_tab<GUI::Widget>("Environment"_string);
|
||||
environment_tab.set_layout<GUI::VerticalBoxLayout>(4);
|
||||
|
||||
auto environment_text_editor = TRY(environment_tab->try_add<GUI::TextEditor>());
|
||||
auto environment_text_editor = TRY(environment_tab.try_add<GUI::TextEditor>());
|
||||
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<GUI::Widget>("Memory Regions"_string));
|
||||
memory_regions_tab->set_layout<GUI::VerticalBoxLayout>(4);
|
||||
auto& memory_regions_tab = tab_widget.add_tab<GUI::Widget>("Memory Regions"_string);
|
||||
memory_regions_tab.set_layout<GUI::VerticalBoxLayout>(4);
|
||||
|
||||
auto memory_regions_text_editor = TRY(memory_regions_tab->try_add<GUI::TextEditor>());
|
||||
auto memory_regions_text_editor = TRY(memory_regions_tab.try_add<GUI::TextEditor>());
|
||||
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<int> serenity_main(Main::Arguments arguments)
|
|||
},
|
||||
[&](auto results) -> ErrorOr<void> {
|
||||
for (auto& backtrace : results.thread_backtraces) {
|
||||
auto container = TRY(backtrace_tab_widget->try_add_tab<GUI::Widget>(TRY(String::from_deprecated_string(backtrace.title))));
|
||||
container->template set_layout<GUI::VerticalBoxLayout>(4);
|
||||
auto backtrace_text_editor = TRY(container->template try_add<GUI::TextEditor>());
|
||||
auto& container = backtrace_tab_widget->add_tab<GUI::Widget>(TRY(String::from_deprecated_string(backtrace.title)));
|
||||
container.template set_layout<GUI::VerticalBoxLayout>(4);
|
||||
auto backtrace_text_editor = TRY(container.template try_add<GUI::TextEditor>());
|
||||
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<int> serenity_main(Main::Arguments arguments)
|
|||
}
|
||||
|
||||
for (auto& cpu_registers : results.thread_cpu_registers) {
|
||||
auto container = TRY(cpu_registers_tab_widget->try_add_tab<GUI::Widget>(TRY(String::from_deprecated_string(cpu_registers.title))));
|
||||
container->template set_layout<GUI::VerticalBoxLayout>(4);
|
||||
auto cpu_registers_text_editor = TRY(container->template try_add<GUI::TextEditor>());
|
||||
auto& container = cpu_registers_tab_widget->add_tab<GUI::Widget>(TRY(String::from_deprecated_string(cpu_registers.title)));
|
||||
container.template set_layout<GUI::VerticalBoxLayout>(4);
|
||||
auto cpu_registers_text_editor = TRY(container.template try_add<GUI::TextEditor>());
|
||||
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);
|
||||
|
|
|
@ -120,12 +120,12 @@ ErrorOr<void> PropertiesWindow::create_widgets(bool disable_rename)
|
|||
|
||||
ErrorOr<void> PropertiesWindow::create_general_tab(GUI::TabWidget& tab_widget, bool disable_rename)
|
||||
{
|
||||
auto general_tab = TRY(tab_widget.try_add_tab<GUI::Widget>("General"_string));
|
||||
TRY(general_tab->load_from_gml(properties_window_general_tab_gml));
|
||||
auto& general_tab = tab_widget.add_tab<GUI::Widget>("General"_string);
|
||||
TRY(general_tab.load_from_gml(properties_window_general_tab_gml));
|
||||
|
||||
m_icon = general_tab->find_descendant_of_type_named<GUI::ImageWidget>("icon");
|
||||
m_icon = general_tab.find_descendant_of_type_named<GUI::ImageWidget>("icon");
|
||||
|
||||
m_name_box = general_tab->find_descendant_of_type_named<GUI::TextBox>("name");
|
||||
m_name_box = general_tab.find_descendant_of_type_named<GUI::TextBox>("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<void> 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<GUI::LinkLabel>("location");
|
||||
auto* location = general_tab.find_descendant_of_type_named<GUI::LinkLabel>("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<void> 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<GUI::Label>("type");
|
||||
auto* type = general_tab.find_descendant_of_type_named<GUI::Label>("type");
|
||||
type->set_text(TRY(String::from_utf8(get_description(m_mode))));
|
||||
|
||||
if (S_ISLNK(m_mode)) {
|
||||
|
@ -168,7 +168,7 @@ ErrorOr<void> 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<GUI::LinkLabel>("link_location");
|
||||
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.to_deprecated_string());
|
||||
|
@ -176,40 +176,40 @@ ErrorOr<void> PropertiesWindow::create_general_tab(GUI::TabWidget& tab_widget, b
|
|||
};
|
||||
}
|
||||
} else {
|
||||
auto* link_location_widget = general_tab->find_descendant_of_type_named<GUI::Widget>("link_location_widget");
|
||||
general_tab->remove_child(*link_location_widget);
|
||||
auto* link_location_widget = general_tab.find_descendant_of_type_named<GUI::Widget>("link_location_widget");
|
||||
general_tab.remove_child(*link_location_widget);
|
||||
}
|
||||
|
||||
m_size_label = general_tab->find_descendant_of_type_named<GUI::Label>("size");
|
||||
m_size_label = general_tab.find_descendant_of_type_named<GUI::Label>("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<GUI::Label>("owner");
|
||||
auto* owner = general_tab.find_descendant_of_type_named<GUI::Label>("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<GUI::Label>("group");
|
||||
auto* group = general_tab.find_descendant_of_type_named<GUI::Label>("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<GUI::Label>("created_at");
|
||||
auto* created_at = general_tab.find_descendant_of_type_named<GUI::Label>("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<GUI::Label>("last_modified");
|
||||
auto* last_modified = general_tab.find_descendant_of_type_named<GUI::Label>("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<GUI::CheckBox>("owner_read");
|
||||
auto* owner_write = general_tab->find_descendant_of_type_named<GUI::CheckBox>("owner_write");
|
||||
auto* owner_execute = general_tab->find_descendant_of_type_named<GUI::CheckBox>("owner_execute");
|
||||
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");
|
||||
auto* owner_execute = general_tab.find_descendant_of_type_named<GUI::CheckBox>("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<GUI::CheckBox>("group_read");
|
||||
auto* group_write = general_tab->find_descendant_of_type_named<GUI::CheckBox>("group_write");
|
||||
auto* group_execute = general_tab->find_descendant_of_type_named<GUI::CheckBox>("group_execute");
|
||||
auto* group_read = general_tab.find_descendant_of_type_named<GUI::CheckBox>("group_read");
|
||||
auto* group_write = general_tab.find_descendant_of_type_named<GUI::CheckBox>("group_write");
|
||||
auto* group_execute = general_tab.find_descendant_of_type_named<GUI::CheckBox>("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<GUI::CheckBox>("others_read");
|
||||
auto* others_write = general_tab->find_descendant_of_type_named<GUI::CheckBox>("others_write");
|
||||
auto* others_execute = general_tab->find_descendant_of_type_named<GUI::CheckBox>("others_execute");
|
||||
auto* others_read = general_tab.find_descendant_of_type_named<GUI::CheckBox>("others_read");
|
||||
auto* others_write = general_tab.find_descendant_of_type_named<GUI::CheckBox>("others_write");
|
||||
auto* others_execute = general_tab.find_descendant_of_type_named<GUI::CheckBox>("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<void> PropertiesWindow::create_archive_tab(GUI::TabWidget& tab_widget, N
|
|||
}
|
||||
auto zip = maybe_zip.release_value();
|
||||
|
||||
auto tab = TRY(tab_widget.try_add_tab<GUI::Widget>("Archive"_string));
|
||||
TRY(tab->load_from_gml(properties_window_archive_tab_gml));
|
||||
auto& tab = tab_widget.add_tab<GUI::Widget>("Archive"_string);
|
||||
TRY(tab.load_from_gml(properties_window_archive_tab_gml));
|
||||
|
||||
auto statistics = TRY(zip.calculate_statistics());
|
||||
|
||||
tab->find_descendant_of_type_named<GUI::Label>("archive_format")->set_text("ZIP"_string);
|
||||
tab->find_descendant_of_type_named<GUI::Label>("archive_file_count")->set_text(TRY(String::number(statistics.file_count())));
|
||||
tab->find_descendant_of_type_named<GUI::Label>("archive_directory_count")->set_text(TRY(String::number(statistics.directory_count())));
|
||||
tab->find_descendant_of_type_named<GUI::Label>("archive_uncompressed_size")->set_text(TRY(String::from_deprecated_string(AK::human_readable_size(statistics.total_uncompressed_bytes()))));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("archive_file_count")->set_text(TRY(String::number(statistics.file_count())));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("archive_format")->set_text("ZIP"_string);
|
||||
tab.find_descendant_of_type_named<GUI::Label>("archive_directory_count")->set_text(TRY(String::number(statistics.directory_count())));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("archive_uncompressed_size")->set_text(TRY(String::from_deprecated_string(AK::human_readable_size(statistics.total_uncompressed_bytes()))));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -277,14 +277,14 @@ ErrorOr<void> PropertiesWindow::create_audio_tab(GUI::TabWidget& tab_widget, Non
|
|||
}
|
||||
auto loader = loader_or_error.release_value();
|
||||
|
||||
auto tab = TRY(tab_widget.try_add_tab<GUI::Widget>("Audio"_string));
|
||||
TRY(tab->load_from_gml(properties_window_audio_tab_gml));
|
||||
auto& tab = tab_widget.add_tab<GUI::Widget>("Audio"_string);
|
||||
TRY(tab.load_from_gml(properties_window_audio_tab_gml));
|
||||
|
||||
tab->find_descendant_of_type_named<GUI::Label>("audio_type")->set_text(TRY(String::from_deprecated_string(loader->format_name())));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("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<GUI::Label>("audio_duration")->set_text(TRY(String::from_deprecated_string(human_readable_digital_time(duration_seconds))));
|
||||
tab->find_descendant_of_type_named<GUI::Label>("audio_sample_rate")->set_text(TRY(String::formatted("{} Hz", loader->sample_rate())));
|
||||
tab->find_descendant_of_type_named<GUI::Label>("audio_format")->set_text(TRY(String::formatted("{}-bit", loader->bits_per_sample())));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("audio_duration")->set_text(TRY(String::from_deprecated_string(human_readable_digital_time(duration_seconds))));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("audio_sample_rate")->set_text(TRY(String::formatted("{} Hz", loader->sample_rate())));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("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<void> PropertiesWindow::create_audio_tab(GUI::TabWidget& tab_widget, Non
|
|||
} else {
|
||||
channels_string = TRY(String::number(channel_count));
|
||||
}
|
||||
tab->find_descendant_of_type_named<GUI::Label>("audio_channels")->set_text(channels_string);
|
||||
tab.find_descendant_of_type_named<GUI::Label>("audio_channels")->set_text(channels_string);
|
||||
|
||||
tab->find_descendant_of_type_named<GUI::Label>("audio_title")->set_text(loader->metadata().title.value_or({}));
|
||||
tab->find_descendant_of_type_named<GUI::Label>("audio_artists")->set_text(TRY(loader->metadata().all_artists()).value_or({}));
|
||||
tab->find_descendant_of_type_named<GUI::Label>("audio_album")->set_text(loader->metadata().album.value_or({}));
|
||||
tab->find_descendant_of_type_named<GUI::Label>("audio_track_number")
|
||||
tab.find_descendant_of_type_named<GUI::Label>("audio_title")->set_text(loader->metadata().title.value_or({}));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("audio_artists")->set_text(TRY(loader->metadata().all_artists()).value_or({}));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("audio_album")->set_text(loader->metadata().album.value_or({}));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("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<GUI::Label>("audio_genre")->set_text(loader->metadata().genre.value_or({}));
|
||||
tab->find_descendant_of_type_named<GUI::Label>("audio_comment")->set_text(loader->metadata().comment.value_or({}));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("audio_genre")->set_text(loader->metadata().genre.value_or({}));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("audio_comment")->set_text(loader->metadata().comment.value_or({}));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -359,8 +359,8 @@ ErrorOr<void> 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<GUI::Widget>("Font"_string));
|
||||
TRY(tab->load_from_gml(properties_window_font_tab_gml));
|
||||
auto& tab = tab_widget.add_tab<GUI::Widget>("Font"_string);
|
||||
TRY(tab.load_from_gml(properties_window_font_tab_gml));
|
||||
|
||||
String format_name;
|
||||
switch (font_info.format) {
|
||||
|
@ -380,10 +380,10 @@ ErrorOr<void> PropertiesWindow::create_font_tab(GUI::TabWidget& tab_widget, Nonn
|
|||
format_name = "WOFF2"_string;
|
||||
break;
|
||||
}
|
||||
tab->find_descendant_of_type_named<GUI::Label>("font_format")->set_text(format_name);
|
||||
tab->find_descendant_of_type_named<GUI::Label>("font_family")->set_text(typeface->family().to_string());
|
||||
tab->find_descendant_of_type_named<GUI::Label>("font_fixed_width")->set_text(typeface->is_fixed_width() ? "Yes"_string : "No"_string);
|
||||
tab->find_descendant_of_type_named<GUI::Label>("font_width")->set_text(TRY(String::from_utf8(Gfx::width_to_name(static_cast<Gfx::FontWidth>(typeface->width())))));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("font_family")->set_text(typeface->family().to_string());
|
||||
tab.find_descendant_of_type_named<GUI::Label>("font_fixed_width")->set_text(typeface->is_fixed_width() ? "Yes"_string : "No"_string);
|
||||
tab.find_descendant_of_type_named<GUI::Label>("font_format")->set_text(format_name);
|
||||
tab.find_descendant_of_type_named<GUI::Label>("font_width")->set_text(TRY(String::from_utf8(Gfx::width_to_name(static_cast<Gfx::FontWidth>(typeface->width())))));
|
||||
|
||||
auto nearest_weight_class_name = [](unsigned weight) {
|
||||
if (weight > 925)
|
||||
|
@ -392,8 +392,8 @@ ErrorOr<void> 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<GUI::Label>("font_weight")->set_text(TRY(String::formatted("{} ({})", weight, nearest_weight_class_name(weight))));
|
||||
tab->find_descendant_of_type_named<GUI::Label>("font_slope")->set_text(TRY(String::from_utf8(Gfx::slope_to_name(typeface->slope()))));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("font_weight")->set_text(TRY(String::formatted("{} ({})", weight, nearest_weight_class_name(weight))));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("font_slope")->set_text(TRY(String::from_utf8(Gfx::slope_to_name(typeface->slope()))));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -404,11 +404,11 @@ ErrorOr<void> PropertiesWindow::create_image_tab(GUI::TabWidget& tab_widget, Non
|
|||
if (!image_decoder)
|
||||
return {};
|
||||
|
||||
auto tab = TRY(tab_widget.try_add_tab<GUI::Widget>("Image"_string));
|
||||
TRY(tab->load_from_gml(properties_window_image_tab_gml));
|
||||
auto& tab = tab_widget.add_tab<GUI::Widget>("Image"_string);
|
||||
TRY(tab.load_from_gml(properties_window_image_tab_gml));
|
||||
|
||||
tab->find_descendant_of_type_named<GUI::Label>("image_type")->set_text(TRY(String::from_utf8(mime_type)));
|
||||
tab->find_descendant_of_type_named<GUI::Label>("image_size")->set_text(TRY(String::formatted("{} x {}", image_decoder->width(), image_decoder->height())));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("image_type")->set_text(TRY(String::from_utf8(mime_type)));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("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<void> PropertiesWindow::create_image_tab(GUI::TabWidget& tab_widget, Non
|
|||
} else {
|
||||
animation_text = "None"_string;
|
||||
}
|
||||
tab->find_descendant_of_type_named<GUI::Label>("image_animation")->set_text(move(animation_text));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("image_animation")->set_text(move(animation_text));
|
||||
|
||||
auto hide_icc_group = [&tab](String profile_text) {
|
||||
tab->find_descendant_of_type_named<GUI::Label>("image_has_icc_profile")->set_text(profile_text);
|
||||
tab->find_descendant_of_type_named<GUI::Widget>("image_icc_group")->set_visible(false);
|
||||
tab.find_descendant_of_type_named<GUI::Label>("image_has_icc_profile")->set_text(profile_text);
|
||||
tab.find_descendant_of_type_named<GUI::Widget>("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<void> 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<GUI::Label>("image_has_icc_profile")->set_text("See below"_string);
|
||||
tab->find_descendant_of_type_named<GUI::Label>("image_icc_profile")->set_text(icc_profile->tag_string_data(Gfx::ICC::profileDescriptionTag).value_or({}));
|
||||
tab->find_descendant_of_type_named<GUI::Label>("image_icc_copyright")->set_text(icc_profile->tag_string_data(Gfx::ICC::copyrightTag).value_or({}));
|
||||
tab->find_descendant_of_type_named<GUI::Label>("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<GUI::Label>("image_icc_device_class")->set_text(TRY(String::from_utf8((device_class_name(icc_profile->device_class())))));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("image_has_icc_profile")->set_text("See below"_string);
|
||||
tab.find_descendant_of_type_named<GUI::Label>("image_icc_profile")->set_text(icc_profile->tag_string_data(Gfx::ICC::profileDescriptionTag).value_or({}));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("image_icc_copyright")->set_text(icc_profile->tag_string_data(Gfx::ICC::copyrightTag).value_or({}));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("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<GUI::Label>("image_icc_device_class")->set_text(TRY(String::from_utf8((device_class_name(icc_profile->device_class())))));
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -467,8 +467,8 @@ ErrorOr<void> 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<GUI::Label>("PDF"_string));
|
||||
tab->set_text("PDF is password-protected."_string);
|
||||
auto& tab = tab_widget.add_tab<GUI::Label>("PDF"_string);
|
||||
tab.set_text("PDF is password-protected."_string);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -477,11 +477,11 @@ ErrorOr<void> PropertiesWindow::create_pdf_tab(GUI::TabWidget& tab_widget, Nonnu
|
|||
return {};
|
||||
}
|
||||
|
||||
auto tab = TRY(tab_widget.try_add_tab<GUI::Widget>("PDF"_string));
|
||||
TRY(tab->load_from_gml(properties_window_pdf_tab_gml));
|
||||
auto& tab = tab_widget.add_tab<GUI::Widget>("PDF"_string);
|
||||
TRY(tab.load_from_gml(properties_window_pdf_tab_gml));
|
||||
|
||||
tab->find_descendant_of_type_named<GUI::Label>("pdf_version")->set_text(TRY(String::formatted("{}.{}", document->version().major, document->version().minor)));
|
||||
tab->find_descendant_of_type_named<GUI::Label>("pdf_page_count")->set_text(TRY(String::number(document->get_page_count())));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("pdf_version")->set_text(TRY(String::formatted("{}.{}", document->version().major, document->version().minor)));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("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<void> 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<GUI::Label>("pdf_title")->set_text(TRY(get_info_string(info_dict.title())));
|
||||
tab->find_descendant_of_type_named<GUI::Label>("pdf_author")->set_text(TRY(get_info_string(info_dict.author())));
|
||||
tab->find_descendant_of_type_named<GUI::Label>("pdf_subject")->set_text(TRY(get_info_string(info_dict.subject())));
|
||||
tab->find_descendant_of_type_named<GUI::Label>("pdf_keywords")->set_text(TRY(get_info_string(info_dict.keywords())));
|
||||
tab->find_descendant_of_type_named<GUI::Label>("pdf_creator")->set_text(TRY(get_info_string(info_dict.creator())));
|
||||
tab->find_descendant_of_type_named<GUI::Label>("pdf_producer")->set_text(TRY(get_info_string(info_dict.producer())));
|
||||
tab->find_descendant_of_type_named<GUI::Label>("pdf_creation_date")->set_text(TRY(get_info_string(info_dict.creation_date())));
|
||||
tab->find_descendant_of_type_named<GUI::Label>("pdf_modification_date")->set_text(TRY(get_info_string(info_dict.modification_date())));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("pdf_title")->set_text(TRY(get_info_string(info_dict.title())));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("pdf_author")->set_text(TRY(get_info_string(info_dict.author())));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("pdf_subject")->set_text(TRY(get_info_string(info_dict.subject())));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("pdf_keywords")->set_text(TRY(get_info_string(info_dict.keywords())));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("pdf_creator")->set_text(TRY(get_info_string(info_dict.creator())));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("pdf_producer")->set_text(TRY(get_info_string(info_dict.producer())));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("pdf_creation_date")->set_text(TRY(get_info_string(info_dict.creation_date())));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("pdf_modification_date")->set_text(TRY(get_info_string(info_dict.modification_date())));
|
||||
}
|
||||
|
||||
return {};
|
||||
|
|
|
@ -44,11 +44,11 @@ ErrorOr<void> MainWidget::initialize()
|
|||
TRY(m_wave_widget->set_sample_size(sample_count));
|
||||
|
||||
m_tab_widget = TRY(try_add<GUI::TabWidget>());
|
||||
m_roll_widget = TRY(m_tab_widget->try_add_tab<RollWidget>("Piano Roll"_string, m_track_manager));
|
||||
m_roll_widget = m_tab_widget->add_tab<RollWidget>("Piano Roll"_string, m_track_manager);
|
||||
|
||||
m_roll_widget->set_fixed_height(300);
|
||||
|
||||
(void)TRY(m_tab_widget->try_add_tab<SamplerWidget>("Sampler"_string, m_track_manager));
|
||||
m_tab_widget->add_tab<SamplerWidget>("Sampler"_string, m_track_manager);
|
||||
m_player_widget = TRY(try_add<PlayerWidget>(m_track_manager, *this, m_audio_loop));
|
||||
|
||||
m_keys_and_knobs_container = TRY(try_add<GUI::Widget>());
|
||||
|
|
|
@ -461,11 +461,11 @@ void MainWidget::build_override_controls()
|
|||
|
||||
ErrorOr<void> MainWidget::add_property_tab(PropertyTab const& property_tab)
|
||||
{
|
||||
auto scrollable_container = TRY(m_property_tabs->try_add_tab<GUI::ScrollableContainerWidget>(TRY(String::from_utf8(property_tab.title))));
|
||||
scrollable_container->set_should_hide_unnecessary_scrollbars(true);
|
||||
auto& scrollable_container = m_property_tabs->add_tab<GUI::ScrollableContainerWidget>(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::VerticalBoxLayout>(GUI::Margins { 8 }, 12);
|
||||
|
||||
for (auto const& group : property_tab.property_groups) {
|
||||
|
|
|
@ -24,11 +24,11 @@ GalleryWidget::GalleryWidget()
|
|||
|
||||
ErrorOr<void> GalleryWidget::load_basic_model_tab()
|
||||
{
|
||||
auto tab = TRY(m_tab_widget->try_add_tab<GUI::Widget>("Basic Model"_string));
|
||||
TRY(tab->load_from_gml(basic_model_tab_gml));
|
||||
auto& tab = m_tab_widget->add_tab<GUI::Widget>("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<GUI::TableView>("model_table");
|
||||
m_basic_model_table = *tab.find_descendant_of_type_named<GUI::TableView>("model_table");
|
||||
m_basic_model_table->set_model(m_basic_model);
|
||||
|
||||
m_basic_model->on_invalidate = [&] {
|
||||
|
@ -42,9 +42,9 @@ ErrorOr<void> 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<GUI::TextBox>("new_item_name");
|
||||
m_add_new_item = *tab->find_descendant_of_type_named<GUI::Button>("add_new_item");
|
||||
m_remove_selected_item = *tab->find_descendant_of_type_named<GUI::Button>("remove_selected_item");
|
||||
m_new_item_name = *tab.find_descendant_of_type_named<GUI::TextBox>("new_item_name");
|
||||
m_add_new_item = *tab.find_descendant_of_type_named<GUI::Button>("add_new_item");
|
||||
m_remove_selected_item = *tab.find_descendant_of_type_named<GUI::Button>("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());
|
||||
|
|
|
@ -36,11 +36,11 @@ GalleryWidget::GalleryWidget()
|
|||
|
||||
auto& tab_widget = *find_descendant_of_type_named<GUI::TabWidget>("tab_widget");
|
||||
|
||||
auto basics_tab = tab_widget.try_add_tab<GUI::Widget>("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<GUI::Widget>("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<GUI::Label>("enabled_label");
|
||||
m_label_frame = basics_tab->find_descendant_of_type_named<GUI::Frame>("label_frame");
|
||||
m_enabled_label = basics_tab.find_descendant_of_type_named<GUI::Label>("enabled_label");
|
||||
m_label_frame = basics_tab.find_descendant_of_type_named<GUI::Frame>("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<GUI::ComboBox>("frame_style_combobox");
|
||||
m_frame_shape_combobox = basics_tab.find_descendant_of_type_named<GUI::ComboBox>("frame_style_combobox");
|
||||
m_frame_shape_combobox->set_model(*GUI::ItemListModel<DeprecatedString>::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<GUI::Button>("icon_button");
|
||||
m_icon_button = basics_tab.find_descendant_of_type_named<GUI::Button>("icon_button");
|
||||
m_icon_button->set_icon(*m_button_icons[2]);
|
||||
|
||||
m_disabled_icon_button = basics_tab->find_descendant_of_type_named<GUI::Button>("disabled_icon_button");
|
||||
m_disabled_icon_button = basics_tab.find_descendant_of_type_named<GUI::Button>("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<GUI::TextEditor>("text_editor");
|
||||
m_text_editor = basics_tab.find_descendant_of_type_named<GUI::TextEditor>("text_editor");
|
||||
|
||||
m_font_button = basics_tab->find_descendant_of_type_named<GUI::Button>("font_button");
|
||||
m_font_button = basics_tab.find_descendant_of_type_named<GUI::Button>("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<GUI::Button>("file_button");
|
||||
m_file_button = basics_tab.find_descendant_of_type_named<GUI::Button>("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<GUI::Button>("input_button");
|
||||
m_input_button = basics_tab.find_descendant_of_type_named<GUI::Button>("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<GUI::ColorInput>("font_colorinput");
|
||||
m_font_colorinput = basics_tab.find_descendant_of_type_named<GUI::ColorInput>("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<GUI::Button>("msgbox_button");
|
||||
m_msgbox_button = basics_tab.find_descendant_of_type_named<GUI::Button>("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<GUI::ComboBox>("msgbox_icon_combobox");
|
||||
m_msgbox_icon_combobox = basics_tab.find_descendant_of_type_named<GUI::ComboBox>("msgbox_icon_combobox");
|
||||
m_msgbox_icon_combobox->set_model(*GUI::ItemListModel<DeprecatedString>::create(m_msgbox_icons));
|
||||
m_msgbox_icon_combobox->set_selected_index(0);
|
||||
|
||||
|
@ -148,7 +148,7 @@ GalleryWidget::GalleryWidget()
|
|||
m_msgbox_type = static_cast<GUI::MessageBox::Type>(index.row());
|
||||
};
|
||||
|
||||
m_msgbox_buttons_combobox = basics_tab->find_descendant_of_type_named<GUI::ComboBox>("msgbox_buttons_combobox");
|
||||
m_msgbox_buttons_combobox = basics_tab.find_descendant_of_type_named<GUI::ComboBox>("msgbox_buttons_combobox");
|
||||
m_msgbox_buttons_combobox->set_model(*GUI::ItemListModel<DeprecatedString>::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<GUI::Widget>("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<GUI::Widget>("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<GUI::VerticalProgressbar>("vertical_progressbar_left");
|
||||
m_vertical_progressbar_left = sliders_tab.find_descendant_of_type_named<GUI::VerticalProgressbar>("vertical_progressbar_left");
|
||||
m_vertical_progressbar_left->set_value(0);
|
||||
|
||||
m_vertical_progressbar_right = sliders_tab->find_descendant_of_type_named<GUI::VerticalProgressbar>("vertical_progressbar_right");
|
||||
m_vertical_progressbar_right = sliders_tab.find_descendant_of_type_named<GUI::VerticalProgressbar>("vertical_progressbar_right");
|
||||
m_vertical_progressbar_right->set_value(100);
|
||||
|
||||
m_vertical_slider_left = sliders_tab->find_descendant_of_type_named<GUI::VerticalSlider>("vertical_slider_left");
|
||||
m_vertical_slider_right = sliders_tab->find_descendant_of_type_named<GUI::VerticalSlider>("vertical_slider_right");
|
||||
m_vertical_slider_left = sliders_tab.find_descendant_of_type_named<GUI::VerticalSlider>("vertical_slider_left");
|
||||
m_vertical_slider_right = sliders_tab.find_descendant_of_type_named<GUI::VerticalSlider>("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<GUI::HorizontalProgressbar>("horizontal_progressbar");
|
||||
m_horizontal_progressbar = sliders_tab.find_descendant_of_type_named<GUI::HorizontalProgressbar>("horizontal_progressbar");
|
||||
m_horizontal_progressbar->set_value(0);
|
||||
|
||||
m_horizontal_slider_left = sliders_tab->find_descendant_of_type_named<GUI::HorizontalSlider>("horizontal_slider_left");
|
||||
m_horizontal_slider_right = sliders_tab->find_descendant_of_type_named<GUI::HorizontalSlider>("horizontal_slider_right");
|
||||
m_horizontal_slider_left = sliders_tab.find_descendant_of_type_named<GUI::HorizontalSlider>("horizontal_slider_left");
|
||||
m_horizontal_slider_right = sliders_tab.find_descendant_of_type_named<GUI::HorizontalSlider>("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<GUI::Scrollbar>("enabled_scrollbar");
|
||||
m_enabled_scrollbar = sliders_tab.find_descendant_of_type_named<GUI::Scrollbar>("enabled_scrollbar");
|
||||
m_enabled_scrollbar->set_orientation(Orientation::Horizontal);
|
||||
|
||||
m_disabled_scrollbar = sliders_tab->find_descendant_of_type_named<GUI::Scrollbar>("disabled_scrollbar");
|
||||
m_disabled_scrollbar = sliders_tab.find_descendant_of_type_named<GUI::Scrollbar>("disabled_scrollbar");
|
||||
m_disabled_scrollbar->set_orientation(Orientation::Horizontal);
|
||||
|
||||
m_opacity_imagewidget = sliders_tab->find_descendant_of_type_named<GUI::ImageWidget>("opacity_imagewidget");
|
||||
m_opacity_imagewidget = sliders_tab.find_descendant_of_type_named<GUI::ImageWidget>("opacity_imagewidget");
|
||||
m_opacity_imagewidget->load_from_file("/res/graphics/brand-banner.png"sv);
|
||||
|
||||
m_opacity_slider = sliders_tab->find_descendant_of_type_named<GUI::HorizontalOpacitySlider>("opacity_slider");
|
||||
m_opacity_slider = sliders_tab.find_descendant_of_type_named<GUI::HorizontalOpacitySlider>("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<GUI::ValueSlider>("opacity_value_slider");
|
||||
m_opacity_value_slider = sliders_tab.find_descendant_of_type_named<GUI::ValueSlider>("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<GUI::Widget>("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<GUI::Widget>("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<GUI::Button>("wizard_button");
|
||||
m_wizard_output = wizards_tab->find_descendant_of_type_named<GUI::TextEditor>("wizard_output");
|
||||
m_wizard_button = wizards_tab.find_descendant_of_type_named<GUI::Button>("wizard_button");
|
||||
m_wizard_output = wizards_tab.find_descendant_of_type_named<GUI::TextEditor>("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<GUI::Widget>("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<GUI::Widget>("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<GUI::TableView>("cursors_tableview");
|
||||
m_cursors_tableview = cursors_tab.find_descendant_of_type_named<GUI::TableView>("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<Gfx::Bitmap const>(icon_index.data().as_bitmap()));
|
||||
};
|
||||
|
||||
auto icons_tab = tab_widget.try_add_tab<GUI::Widget>("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<GUI::Widget>("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<GUI::TableView>("icons_tableview");
|
||||
m_icons_tableview = icons_tab.find_descendant_of_type_named<GUI::TableView>("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);
|
||||
|
|
|
@ -132,9 +132,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
auto tab_widget = TRY(main_splitter->try_add<GUI::TabWidget>());
|
||||
|
||||
auto tree_tab = TRY(tab_widget->try_add_tab<GUI::Widget>("Call Tree"_string));
|
||||
tree_tab->set_layout<GUI::VerticalBoxLayout>(4);
|
||||
auto bottom_splitter = TRY(tree_tab->try_add<GUI::VerticalSplitter>());
|
||||
auto& tree_tab = tab_widget->add_tab<GUI::Widget>("Call Tree"_string);
|
||||
tree_tab.set_layout<GUI::VerticalBoxLayout>(4);
|
||||
auto bottom_splitter = TRY(tree_tab.try_add<GUI::VerticalSplitter>());
|
||||
|
||||
auto tree_view = TRY(bottom_splitter->try_add<GUI::TreeView>());
|
||||
tree_view->set_should_fill_selected_rows(true);
|
||||
|
@ -181,10 +181,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
update_source_model();
|
||||
});
|
||||
|
||||
auto samples_tab = TRY(tab_widget->try_add_tab<GUI::Widget>("Samples"_string));
|
||||
samples_tab->set_layout<GUI::VerticalBoxLayout>(4);
|
||||
auto& samples_tab = tab_widget->add_tab<GUI::Widget>("Samples"_string);
|
||||
samples_tab.set_layout<GUI::VerticalBoxLayout>(4);
|
||||
|
||||
auto samples_splitter = TRY(samples_tab->try_add<GUI::HorizontalSplitter>());
|
||||
auto samples_splitter = TRY(samples_tab.try_add<GUI::HorizontalSplitter>());
|
||||
auto samples_table_view = TRY(samples_splitter->try_add<GUI::TableView>());
|
||||
samples_table_view->set_model(profile->samples_model());
|
||||
|
||||
|
@ -195,10 +195,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
individual_sample_view->set_model(move(model));
|
||||
};
|
||||
|
||||
auto signposts_tab = TRY(tab_widget->try_add_tab<GUI::Widget>("Signposts"_string));
|
||||
signposts_tab->set_layout<GUI::VerticalBoxLayout>(4);
|
||||
auto& signposts_tab = tab_widget->add_tab<GUI::Widget>("Signposts"_string);
|
||||
signposts_tab.set_layout<GUI::VerticalBoxLayout>(4);
|
||||
|
||||
auto signposts_splitter = TRY(signposts_tab->try_add<GUI::HorizontalSplitter>());
|
||||
auto signposts_splitter = TRY(signposts_tab.try_add<GUI::HorizontalSplitter>());
|
||||
auto signposts_table_view = TRY(signposts_splitter->try_add<GUI::TableView>());
|
||||
signposts_table_view->set_model(profile->signposts_model());
|
||||
|
||||
|
@ -209,10 +209,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
individual_signpost_view->set_model(move(model));
|
||||
};
|
||||
|
||||
auto flamegraph_tab = TRY(tab_widget->try_add_tab<GUI::Widget>("Flame Graph"_string));
|
||||
flamegraph_tab->set_layout<GUI::VerticalBoxLayout>(GUI::Margins { 4, 4, 4, 4 });
|
||||
auto& flamegraph_tab = tab_widget->add_tab<GUI::Widget>("Flame Graph"_string);
|
||||
flamegraph_tab.set_layout<GUI::VerticalBoxLayout>(GUI::Margins { 4, 4, 4, 4 });
|
||||
|
||||
auto flamegraph_view = TRY(flamegraph_tab->try_add<FlameGraphView>(profile->model(), ProfileModel::Column::StackFrame, ProfileModel::Column::SampleCount));
|
||||
auto flamegraph_view = TRY(flamegraph_tab.try_add<FlameGraphView>(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<int> 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<GUI::Widget>("Filesystem events"_string));
|
||||
filesystem_events_tab->set_layout<GUI::VerticalBoxLayout>(4);
|
||||
auto& filesystem_events_tab = tab_widget->add_tab<GUI::Widget>("Filesystem events"_string);
|
||||
filesystem_events_tab.set_layout<GUI::VerticalBoxLayout>(4);
|
||||
|
||||
auto filesystem_events_tree_view = TRY(filesystem_events_tab->try_add<GUI::TreeView>());
|
||||
auto filesystem_events_tree_view = TRY(filesystem_events_tab.try_add<GUI::TreeView>());
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue