mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
Ladybird: Add indentation to options in optgroup in select dropdown
This commit is contained in:
parent
1475c1810f
commit
820f966b33
Notes:
sideshowbarker
2024-07-17 01:10:58 +09:00
Author: https://github.com/bplaat Commit: https://github.com/SerenityOS/serenity/commit/820f966b33 Pull-request: https://github.com/SerenityOS/serenity/pull/23511 Reviewed-by: https://github.com/trflynn89
3 changed files with 12 additions and 12 deletions
|
@ -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]];
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue