1
0
mirror of https://github.com/SerenityOS/serenity synced 2024-07-09 05:20:45 +00:00

Ladybird: Add indentation to options in optgroup in select dropdown

This commit is contained in:
Bastiaan van der Plaat 2024-04-03 19:26:41 +02:00 committed by Tim Flynn
parent 1475c1810f
commit 820f966b33
3 changed files with 12 additions and 12 deletions

View File

@ -711,9 +711,9 @@ static void copy_data_to_clipboard(StringView data, NSPasteboardType pasteboard_
[self.select_dropdown removeAllItems];
self.select_dropdown.minimumWidth = minimum_width;
auto add_menu_item = [self](Web::HTML::SelectItemOption const& item_option) {
auto add_menu_item = [self](Web::HTML::SelectItemOption const& item_option, bool in_option_group) {
NSMenuItem* menuItem = [[NSMenuItem alloc]
initWithTitle:Ladybird::string_to_ns_string(item_option.label)
initWithTitle:Ladybird::string_to_ns_string(in_option_group ? MUST(String::formatted(" {}", item_option.label)) : item_option.label)
action:item_option.disabled ? nil : @selector(selectDropdownAction:)
keyEquivalent:@""];
menuItem.representedObject = [NSNumber numberWithUnsignedInt:item_option.id];
@ -731,11 +731,11 @@ static void copy_data_to_clipboard(StringView data, NSPasteboardType pasteboard_
[self.select_dropdown addItem:subtitle];
for (auto const& item_option : item_option_group.items)
add_menu_item(item_option);
add_menu_item(item_option, true);
}
if (item.has<Web::HTML::SelectItemOption>())
add_menu_item(item.get<Web::HTML::SelectItemOption>());
add_menu_item(item.get<Web::HTML::SelectItemOption>(), false);
if (item.has<Web::HTML::SelectItemSeparator>())
[self.select_dropdown addItem:[NSMenuItem separatorItem]];

View File

@ -332,8 +332,8 @@ Tab::Tab(BrowserWindow* window, WebContentOptions const& web_content_options, St
m_select_dropdown->clear();
m_select_dropdown->setMinimumWidth(minimum_width / view().device_pixel_ratio());
auto add_menu_item = [this](Web::HTML::SelectItemOption const& item_option) {
QAction* action = new QAction(qstring_from_ak_string(item_option.label), this);
auto add_menu_item = [this](Web::HTML::SelectItemOption const& item_option, bool in_option_group) {
QAction* action = new QAction(qstring_from_ak_string(in_option_group ? MUST(String::formatted(" {}", item_option.label)) : item_option.label), this);
action->setCheckable(true);
action->setChecked(item_option.selected);
action->setDisabled(item_option.disabled);
@ -350,11 +350,11 @@ Tab::Tab(BrowserWindow* window, WebContentOptions const& web_content_options, St
m_select_dropdown->addAction(subtitle);
for (auto const& item_option : item_option_group.items)
add_menu_item(item_option);
add_menu_item(item_option, true);
}
if (item.has<Web::HTML::SelectItemOption>())
add_menu_item(item.get<Web::HTML::SelectItemOption>());
add_menu_item(item.get<Web::HTML::SelectItemOption>(), false);
if (item.has<Web::HTML::SelectItemSeparator>())
m_select_dropdown->addSeparator();

View File

@ -654,8 +654,8 @@ Tab::Tab(BrowserWindow& window)
m_select_dropdown->remove_all_actions();
m_select_dropdown->set_minimum_width(minimum_width);
auto add_menu_item = [this](Web::HTML::SelectItemOption const& item_option) {
auto action = GUI::Action::create(item_option.label.to_byte_string(), [this, item_option](GUI::Action&) {
auto add_menu_item = [this](Web::HTML::SelectItemOption const& item_option, bool in_option_group) {
auto action = GUI::Action::create(in_option_group ? ByteString::formatted(" {}", item_option.label) : item_option.label.to_byte_string(), [this, item_option](GUI::Action&) {
m_select_dropdown_closed_by_action = true;
view().select_dropdown_closed(item_option.id);
});
@ -673,11 +673,11 @@ Tab::Tab(BrowserWindow& window)
m_select_dropdown->add_action(subtitle);
for (auto const& item_option : item_option_group.items)
add_menu_item(item_option);
add_menu_item(item_option, true);
}
if (item.has<Web::HTML::SelectItemOption>())
add_menu_item(item.get<Web::HTML::SelectItemOption>());
add_menu_item(item.get<Web::HTML::SelectItemOption>(), false);
if (item.has<Web::HTML::SelectItemSeparator>())
m_select_dropdown->add_separator();