From 820f966b3309fd066b3b668a4e7a8b4bf029c1ba Mon Sep 17 00:00:00 2001 From: Bastiaan van der Plaat Date: Wed, 3 Apr 2024 19:26:41 +0200 Subject: [PATCH] Ladybird: Add indentation to options in optgroup in select dropdown --- Ladybird/AppKit/UI/LadybirdWebView.mm | 8 ++++---- Ladybird/Qt/Tab.cpp | 8 ++++---- Userland/Applications/Browser/Tab.cpp | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Ladybird/AppKit/UI/LadybirdWebView.mm b/Ladybird/AppKit/UI/LadybirdWebView.mm index cbd7119635b..b5da9bad774 100644 --- a/Ladybird/AppKit/UI/LadybirdWebView.mm +++ b/Ladybird/AppKit/UI/LadybirdWebView.mm @@ -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()) - add_menu_item(item.get()); + add_menu_item(item.get(), false); if (item.has()) [self.select_dropdown addItem:[NSMenuItem separatorItem]]; diff --git a/Ladybird/Qt/Tab.cpp b/Ladybird/Qt/Tab.cpp index 350f8e88d23..9a4b2ab2f3c 100644 --- a/Ladybird/Qt/Tab.cpp +++ b/Ladybird/Qt/Tab.cpp @@ -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()) - add_menu_item(item.get()); + add_menu_item(item.get(), false); if (item.has()) m_select_dropdown->addSeparator(); diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp index 840a3830694..9b111fe0a13 100644 --- a/Userland/Applications/Browser/Tab.cpp +++ b/Userland/Applications/Browser/Tab.cpp @@ -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()) - add_menu_item(item.get()); + add_menu_item(item.get(), false); if (item.has()) m_select_dropdown->add_separator();