From 3e34b2e3ab2b61d07fe5ebe7a441bf6620fcc144 Mon Sep 17 00:00:00 2001 From: brave-builds Date: Tue, 10 Dec 2024 23:57:45 +0000 Subject: [PATCH] Uplift of #26883 (squashed) to beta --- browser/ui/toolbar/brave_app_menu_model.cc | 31 ++++++++++++++++------ 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/browser/ui/toolbar/brave_app_menu_model.cc b/browser/ui/toolbar/brave_app_menu_model.cc index 837a01e47370..eeaffb4aa064 100644 --- a/browser/ui/toolbar/brave_app_menu_model.cc +++ b/browser/ui/toolbar/brave_app_menu_model.cc @@ -173,6 +173,21 @@ void BraveAppMenuModel::BuildBraveProductsSection() { #if defined(TOOLKIT_VIEWS) if (sidebar::CanUseSidebar(browser())) { + auto index = GetNextIndexOfBraveProductsSection(); + // Remove above separator as sidebar will add its top & bottom + // separator. + // If |need_separator| is false, there is no item after window section + // entry and separator. In this case, need to remove that separator because + // we will add different type of separators around sidebar menu entry. + if (!need_separator) { + RemoveItemAt(index - 1); + index--; + } + + // Don't need finish this section with more separator as + // we'll add another separators around sidebar menu entry below. + need_separator = false; + sidebar_show_option_model_ = std::make_unique( IDS_APP_MENU_SIDEBAR_TITLE, this); @@ -182,16 +197,16 @@ void BraveAppMenuModel::BuildBraveProductsSection() { IDC_SIDEBAR_SHOW_OPTION_MOUSEOVER, IDS_APP_MENU_SIDEBAR_HOVER); sidebar_show_option_model_->AddGroupItemWithStringId( IDC_SIDEBAR_SHOW_OPTION_NEVER, IDS_APP_MENU_SIDEBAR_OFF); - const auto index = GetNextIndexOfBraveProductsSection(); + + // Add additional spacing because LOWER|UPPER separator has more narrow + // spacing then normal separator. + InsertSeparatorAt(index++, ui::SPACING_SEPARATOR); + InsertSeparatorAt(index++, ui::LOWER_SEPARATOR); AddButtonItemAt(IDC_SIDEBAR_SHOW_OPTION_MENU, sidebar_show_option_model_.get(), - static_cast(index)); - // Insert separator to the top and bottom - InsertSeparatorAt(index, ui::LOWER_SEPARATOR); - InsertSeparatorAt(index + 2, ui::UPPER_SEPARATOR); - - // Already added separator. - need_separator = false; + static_cast(index++)); + InsertSeparatorAt(index++, ui::UPPER_SEPARATOR); + InsertSeparatorAt(index, ui::SPACING_SEPARATOR); } #endif if (need_separator) {