Truly independent web browser
UI/Qt: Give the dark chrome a cool tint and pill tabs
Andreas Kling41be77d33c3d
diff --git a/UI/Qt/ChromeStyle.cpp b/UI/Qt/ChromeStyle.cppindex 487d042c547..f023cac31e6 100644--- a/UI/Qt/ChromeStyle.cpp+++ b/UI/Qt/ChromeStyle.cpp@@ -120,7 +120,9 @@ QColor chrome_background(QPalette const& palette){auto window = chrome_window(palette);auto dark = is_dark(palette);- return mix(window, material_color_anchors(dark).background, dark ? 0.34 : 0.68);+ if (dark)+ return mix(window, QColor(17, 20, 25), 0.70);+ return mix(window, material_color_anchors(dark).background, 0.68);}QColor chrome_surface(QPalette const& palette)@@ -172,24 +174,16 @@ QColor chrome_control_border(QPalette const& palette)return mix(chrome_border(palette), material_color_anchors(dark).border, 0.18);}-QColor chrome_active_tab_surface_top(QPalette const& palette)-{- auto dark = is_dark(palette);- if (!dark)- return QColor(255, 255, 255);+// The active tab is lifted toward a cool slate rather than plain white, to match the tint of the dark chrome.+static constexpr QColor active_tab_tint { 150, 165, 180 };- auto background = chrome_background(palette);- return mix(background, QColor(255, 255, 255), 0.22);-}--QColor chrome_active_tab_surface_bottom(QPalette const& palette)+QColor chrome_active_tab_surface(QPalette const& palette){auto dark = is_dark(palette);if (!dark)- return QColor(251, 251, 251);+ return QColor(255, 255, 255);- auto background = chrome_background(palette);- return mix(background, QColor(255, 255, 255), 0.20);+ return mix(chrome_background(palette), active_tab_tint, 0.24);}QColor chrome_border(QPalette const& palette)@@ -343,10 +337,12 @@ QString toolbar_container_style_sheet(QPalette const& palette){auto dark = is_dark(palette);- auto background = style_sheet_color(chrome_background(palette));+ auto background_color = chrome_background(palette);+ auto background = style_sheet_color(background_color);auto surface_hover = style_sheet_color(chrome_control_surface_hover(palette));auto surface_pressed = style_sheet_color(chrome_control_surface_pressed(palette));- auto separator = style_sheet_color(chrome_border(palette));+ // In dark mode, the line under the toolbar is as soft as the one under the tab strip.+ auto separator = style_sheet_color(dark ? mix(background_color, chrome_border(palette), 0.44) : chrome_border(palette));auto window_controls_separator = style_sheet_color(mix(chrome_background(palette), chrome_border(palette), dark ? 0.36 : 0.46));auto text = style_sheet_color(chrome_button_text(palette));auto disabled_text = style_sheet_color(chrome_muted_text(palette));@@ -1553,7 +1549,7 @@ void paint_circular_control_frame(QPainter& painter, QAbstractButton const& buttauto const& palette = button.window()->palette();auto background = frame_style == CircularControlFrameStyle::ActiveTabOverlay- ? chrome_active_tab_surface_top(palette)+ ? chrome_active_tab_surface(palette): chrome_control_surface_hover(palette);auto border = frame_style == CircularControlFrameStyle::ActiveTabOverlay? chrome_control_surface_hover(palette)diff --git a/UI/Qt/ChromeStyle.h b/UI/Qt/ChromeStyle.hindex 45e1cd2296d..9e55af3f985 100644--- a/UI/Qt/ChromeStyle.h+++ b/UI/Qt/ChromeStyle.h@@ -27,8 +27,7 @@ QColor chrome_surface_recessed(QPalette const&);QColor chrome_surface_hover(QPalette const&);QColor chrome_surface_pressed(QPalette const&);QColor chrome_control_border(QPalette const&);-QColor chrome_active_tab_surface_top(QPalette const&);-QColor chrome_active_tab_surface_bottom(QPalette const&);+QColor chrome_active_tab_surface(QPalette const&);QColor chrome_border(QPalette const&);QColor chrome_separator(QPalette const&);QColor chrome_window_outline(QPalette const&);diff --git a/UI/Qt/TabBar.cpp b/UI/Qt/TabBar.cppindex 4b73dc4baea..7d87a77fdeb 100644--- a/UI/Qt/TabBar.cpp+++ b/UI/Qt/TabBar.cpp@@ -135,25 +135,6 @@ static bool target_can_accept_tab_drop(QWidget& target, QDropEvent& event)return source_window->is_private() == target_window->is_private();}-static QPainterPath tab_shape_path(QRectF const& rect, qreal top_radius, qreal bottom_radius)-{- top_radius = min(top_radius, rect.height() / 2.0);- bottom_radius = min(bottom_radius, rect.height() / 2.0);-- QPainterPath path;- path.moveTo(rect.left() + top_radius, rect.top());- path.lineTo(rect.right() - top_radius, rect.top());- path.quadTo(rect.right(), rect.top(), rect.right(), rect.top() + top_radius);- path.lineTo(rect.right(), rect.bottom() - bottom_radius);- path.quadTo(rect.right(), rect.bottom(), rect.right() - bottom_radius, rect.bottom());- path.lineTo(rect.left() + bottom_radius, rect.bottom());- path.quadTo(rect.left(), rect.bottom(), rect.left(), rect.bottom() - bottom_radius);- path.lineTo(rect.left(), rect.top() + top_radius);- path.quadTo(rect.left(), rect.top(), rect.left() + top_radius, rect.top());- path.closeSubpath();- return path;-}-static void clear_layout(QLayout& layout){while (auto* item = layout.takeAt(0))@@ -232,6 +213,15 @@ static QColor selected_tab_border(QPalette const& palette, bool collapsed)return color;}+static QColor selected_tab_top_edge_highlight(QPalette const& palette, QColor border)+{+ if (!ChromeStyle::is_dark(palette))+ return border;+ auto highlight = QColor(255, 255, 255);+ highlight.setAlpha(border.alpha() + 26);+ return highlight;+}+static QColor selected_tab_shadow(QPalette const& palette, int layer){auto dark = ChromeStyle::is_dark(palette);@@ -295,7 +285,9 @@ private:: (is_horizontal_new_tab_button? horizontal_new_tab_button_shape_rect(QRectF(rect())): QRectF(rect()).adjusted(4.0, 3.0, -4.0, -3.0));- auto tab_path = tab_shape_path(shape_rect, 9.0, 9.0);+ // NB: The horizontal new tab button's shape is square, so this pill is a circle.+ QPainterPath tab_path;+ tab_path.addRoundedRect(shape_rect, shape_rect.height() / 2.0, shape_rect.height() / 2.0);auto hovered = underMouse();if (isDown()) {@@ -686,7 +678,6 @@ void TabBar::paintEvent(QPaintEvent*)QPainter painter(this);painter.setRenderHint(QPainter::Antialiasing, true);- auto border = ChromeStyle::chrome_border(palette());auto dark = ChromeStyle::is_dark(palette());auto text_color = ChromeStyle::chrome_text(palette());auto is_vertical = tab_layout() != TabLayout::Horizontal;@@ -712,7 +703,8 @@ void TabBar::paintEvent(QPaintEvent*)shape_rect = horizontal_tab_card_shape_rect(QRectF(tab_rect));elseshape_rect = tab_card_shape_rect(QRectF(tab_rect));- auto tab_path = tab_shape_path(shape_rect, 9.0, 9.0);+ QPainterPath tab_path;+ tab_path.addRoundedRect(shape_rect, shape_rect.height() / 2.0, shape_rect.height() / 2.0);if (is_selected) {painter.setPen(Qt::NoPen);@@ -721,11 +713,13 @@ void TabBar::paintEvent(QPaintEvent*)painter.setBrush(selected_tab_shadow(palette(), 0));painter.drawPath(tab_path.translated(0, 1));- auto selected_gradient = QLinearGradient(shape_rect.topLeft(), shape_rect.bottomLeft());- selected_gradient.setColorAt(0.0, ChromeStyle::chrome_active_tab_surface_top(palette()));- selected_gradient.setColorAt(1.0, ChromeStyle::chrome_active_tab_surface_bottom(palette()));- painter.setBrush(selected_gradient);- painter.setPen(QPen(selected_tab_border(palette(), is_collapsed_vertical), 1));+ // The fill is flat; only the border brightens toward the top edge, for a little depth.+ auto border_color = selected_tab_border(palette(), is_collapsed_vertical);+ auto border_gradient = QLinearGradient(shape_rect.topLeft(), shape_rect.bottomLeft());+ border_gradient.setColorAt(0.0, selected_tab_top_edge_highlight(palette(), border_color));+ border_gradient.setColorAt(0.45, border_color);+ painter.setBrush(ChromeStyle::chrome_active_tab_surface(palette()));+ painter.setPen(QPen(QBrush(border_gradient), 1));painter.drawPath(tab_path);} else if (is_hovered) {painter.setBrush(tab_hover_surface(palette(), hover_progress));@@ -733,16 +727,6 @@ void TabBar::paintEvent(QPaintEvent*)painter.drawPath(tab_path);}- if (!is_selected && !is_hovered && index > 0 && index != currentIndex() + 1 && !is_collapsed_vertical) {- auto separator = border;- separator.setAlpha(dark ? 24 : 20);- painter.setPen(separator);- if (is_vertical)- painter.drawLine(QPoint(tab_rect.left() + 16, tab_rect.top()), QPoint(tab_rect.right() - 16, tab_rect.top()));- else- painter.drawLine(QPoint(tab_rect.left(), 15), QPoint(tab_rect.left(), height() - 15));- }-auto icon = tabIcon(index);if (icon.isNull())icon = m_fallback_tab_icon;