Truly independent web browser
UI/Qt: Round bookmark bar items into pills
Andreas Klingca3fe9d539bd
diff --git a/UI/Qt/BookmarksBar.cpp b/UI/Qt/BookmarksBar.cppindex bc88ed7a9a8..1874883219d 100644--- a/UI/Qt/BookmarksBar.cpp+++ b/UI/Qt/BookmarksBar.cpp@@ -38,6 +38,11 @@ static constexpr int BOOKMARK_BUTTON_TEXT_ELISION_PADDING = 2;static constexpr char const* BOOKMARK_ITEM_PROPERTY = "bookmark_item";static constexpr char const* BOOKMARK_CONTEXT_MENU_OPEN_PROPERTY = "bookmark_context_menu_open";+static int bookmark_button_height(QFontMetrics const& font_metrics, int icon_height)+{+ return max(BOOKMARK_BUTTON_MIN_HEIGHT, max(font_metrics.height(), icon_height) + BOOKMARK_BUTTON_VERTICAL_PADDING);+}+static QStyleOptionToolButton bookmark_button_style_option(QToolButton const& button){QStyleOptionToolButton option;@@ -200,7 +205,9 @@ void BookmarksBar::update_chrome_style()return;m_is_updating_chrome_style = true;- setStyleSheet(ChromeStyle::bookmarks_bar_style_sheet(palette()));+ // Bookmark items are pills, like the tabs.+ auto corner_radius = bookmark_button_height(fontMetrics(), iconSize().height()) / 2;+ setStyleSheet(ChromeStyle::bookmarks_bar_style_sheet(palette(), corner_radius));m_is_updating_chrome_style = false;}@@ -220,8 +227,8 @@ void BookmarksBar::rebuild()auto option = bookmark_button_style_option(*button);- auto bookmark_button_height = max(BOOKMARK_BUTTON_MIN_HEIGHT, max(button->fontMetrics().height(), button->iconSize().height()) + BOOKMARK_BUTTON_VERTICAL_PADDING);- auto max_size_rect = QRect { 0, 0, BOOKMARK_BUTTON_MAX_WIDTH, bookmark_button_height };+ auto height = bookmark_button_height(button->fontMetrics(), button->iconSize().height());+ auto max_size_rect = QRect { 0, 0, BOOKMARK_BUTTON_MAX_WIDTH, height };auto layout = bookmark_button_layout(*button, option, title, max_size_rect);@@ -233,7 +240,7 @@ void BookmarksBar::rebuild()button->setFixedWidth(layout.preferred_width);button->setMaximumWidth(BOOKMARK_BUTTON_MAX_WIDTH);- button->setFixedHeight(bookmark_button_height);+ button->setFixedHeight(height);button->installEventFilter(this);};diff --git a/UI/Qt/ChromeStyle.cpp b/UI/Qt/ChromeStyle.cppindex 1cc9d896ca4..3b34b67d3f3 100644--- a/UI/Qt/ChromeStyle.cpp+++ b/UI/Qt/ChromeStyle.cpp@@ -727,7 +727,7 @@ static QColor chrome_control_soft_hover(QPalette const& palette)return is_dark(palette) ? QColor(255, 255, 255, 24) : QColor(0, 0, 0, 16);}-QString bookmarks_bar_style_sheet(QPalette const& palette)+QString bookmarks_bar_style_sheet(QPalette const& palette, int corner_radius){auto hover = style_sheet_color_with_alpha(chrome_control_soft_hover(palette));auto pressed = style_sheet_color(chrome_control_surface_pressed(palette));@@ -746,7 +746,7 @@ QToolBar#LadybirdBookmarksBar QToolButton {{color: {2};background: transparent;border: 1px solid transparent;- border-radius: 7px;+ border-radius: {4}px;}}QToolBar#LadybirdBookmarksBar QToolButton:hover {{@@ -760,7 +760,7 @@ QToolBar#LadybirdBookmarksBar QToolButton:checked {{border-color: {3};}})",- hover, pressed, text, control_border);+ hover, pressed, text, control_border, corner_radius);}QString find_in_page_style_sheet(QPalette const& palette)diff --git a/UI/Qt/ChromeStyle.h b/UI/Qt/ChromeStyle.hindex 9e55af3f985..38c2ffd307b 100644--- a/UI/Qt/ChromeStyle.h+++ b/UI/Qt/ChromeStyle.h@@ -40,7 +40,7 @@ QString toolbar_container_style_sheet(QPalette const&);QString menu_bar_style_sheet(QPalette const&);QString hamburger_style_sheet(QPalette const&);QString location_edit_style_sheet(QPalette const&);-QString bookmarks_bar_style_sheet(QPalette const&);+QString bookmarks_bar_style_sheet(QPalette const&, int corner_radius);QString find_in_page_style_sheet(QPalette const&);QString javascript_dialog_style_sheet(QPalette const&);QString bookmark_dialog_style_sheet(QPalette const&);