Truly independent web browser
UI/Qt: Use Ladybird-branded colors more consistently
Timothy Flynn788494f01a7a
diff --git a/UI/Qt/ApplicationIcon.mm b/UI/Qt/ApplicationIcon.mmindex e1714fae830..74a6588cd57 100644--- a/UI/Qt/ApplicationIcon.mm+++ b/UI/Qt/ApplicationIcon.mm@@ -5,6 +5,7 @@*/#include <LibWebView/Profile.h>+#include <UI/Qt/BrandColors.h>#import <Cocoa/Cocoa.h>#import <UI/Qt/ApplicationIcon.h>@@ -27,31 +28,19 @@ void set_profile_application_icon(WebView::Profile const& profile)if (!application_icon)return;+ auto ns_color = [](QRgb color) {+ return [NSColor colorWithSRGBRed:qRed(color) / 255.0+ green:qGreen(color) / 255.0+ blue:qBlue(color) / 255.0+ alpha:1];+ };NSArray<NSColor*>* badge_colors = @[- [NSColor colorWithSRGBRed:0.38- green:0.52- blue:0.96- alpha:1],- [NSColor colorWithSRGBRed:0.49- green:0.43- blue:0.91- alpha:1],- [NSColor colorWithSRGBRed:0.63- green:0.39- blue:0.88- alpha:1],- [NSColor colorWithSRGBRed:0.82- green:0.36- blue:0.65- alpha:1],- [NSColor colorWithSRGBRed:0.16- green:0.57- blue:0.65- alpha:1],- [NSColor colorWithSRGBRed:0.30- green:0.36- blue:0.72- alpha:1],+ ns_color(BrandColors::SlateBlue500),+ ns_color(BrandColors::Indigo30),+ ns_color(BrandColors::Violet100),+ ns_color(BrandColors::Violet900),+ ns_color(BrandColors::SlateBlue900),+ ns_color(BrandColors::Indigo60),];auto* badge_color = badge_colors[profile.paths().identity.hash() % [badge_colors count]];diff --git a/UI/Qt/BrandColors.h b/UI/Qt/BrandColors.hnew file mode 100644index 00000000000..57781cc6b23--- /dev/null+++ b/UI/Qt/BrandColors.h@@ -0,0 +1,49 @@+/*+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++#pragma once++#include <QColor>++namespace Ladybird::BrandColors {++constexpr inline auto Indigo10 = qRgb(0xa5, 0xa6, 0xf2);+constexpr inline auto Indigo20 = qRgb(0x8a, 0x88, 0xeb);+constexpr inline auto Indigo30 = qRgb(0x68, 0x51, 0xd6);+constexpr inline auto Indigo40 = qRgb(0x55, 0x3f, 0xc4);+constexpr inline auto Indigo50 = qRgb(0x4d, 0x37, 0xb8);+constexpr inline auto Indigo60 = qRgb(0x3c, 0x28, 0xa1);+constexpr inline auto Indigo80 = qRgb(0x30, 0x1f, 0x82);+constexpr inline auto Indigo100 = qRgb(0x2a, 0x13, 0x73);+constexpr inline auto Indigo300 = qRgb(0x26, 0x0f, 0x73);+constexpr inline auto Indigo500 = qRgb(0x1d, 0x0c, 0x59);+constexpr inline auto Indigo900 = qRgb(0x19, 0x0c, 0x4a);++constexpr inline auto Violet10 = qRgb(0xe0, 0xd4, 0xff);+constexpr inline auto Violet20 = qRgb(0xca, 0xb5, 0xff);+constexpr inline auto Violet30 = qRgb(0xc3, 0xab, 0xff);+constexpr inline auto Violet40 = qRgb(0xb4, 0x96, 0xff);+constexpr inline auto Violet50 = qRgb(0xab, 0x8e, 0xf5);+constexpr inline auto Violet60 = qRgb(0x9d, 0x7c, 0xf2);+constexpr inline auto Violet80 = qRgb(0x93, 0x6f, 0xed);+constexpr inline auto Violet100 = qRgb(0x8a, 0x64, 0xe5);+constexpr inline auto Violet300 = qRgb(0x82, 0x57, 0xe6);+constexpr inline auto Violet500 = qRgb(0x7a, 0x4c, 0xe6);+constexpr inline auto Violet900 = qRgb(0x6a, 0x39, 0xdb);++constexpr inline auto SlateBlue10 = qRgb(0xcb, 0xe0, 0xf7);+constexpr inline auto SlateBlue20 = qRgb(0xc1, 0xd9, 0xf5);+constexpr inline auto SlateBlue30 = qRgb(0xb6, 0xd2, 0xf2);+constexpr inline auto SlateBlue40 = qRgb(0xa8, 0xc8, 0xed);+constexpr inline auto SlateBlue50 = qRgb(0x97, 0xbc, 0xe6);+constexpr inline auto SlateBlue60 = qRgb(0x86, 0xad, 0xd9);+constexpr inline auto SlateBlue80 = qRgb(0x77, 0xa1, 0xd1);+constexpr inline auto SlateBlue100 = qRgb(0x6d, 0x98, 0xcc);+constexpr inline auto SlateBlue300 = qRgb(0x5c, 0x8e, 0xcc);+constexpr inline auto SlateBlue500 = qRgb(0x54, 0x84, 0xbf);+constexpr inline auto SlateBlue900 = qRgb(0x48, 0x72, 0xa3);++}diff --git a/UI/Qt/CMakeLists.txt b/UI/Qt/CMakeLists.txtindex a68541b0f99..defbe55004d 100644--- a/UI/Qt/CMakeLists.txt+++ b/UI/Qt/CMakeLists.txt@@ -202,6 +202,7 @@ if (BUILD_TESTING)add_executable(TestPerformanceMonitorWidget${LADYBIRD_SOURCE_DIR}/Tests/LibWebView/TestPerformanceMonitorWidget.cpp+ ChromeStyle.cppPerformanceMonitorWidget.cppStringUtils.cpp)diff --git a/UI/Qt/ChromeStyle.cpp b/UI/Qt/ChromeStyle.cppindex a181d4f02fa..12c601e6d69 100644--- a/UI/Qt/ChromeStyle.cpp+++ b/UI/Qt/ChromeStyle.cpp@@ -5,6 +5,7 @@*/#include <AK/Platform.h>+#include <UI/Qt/BrandColors.h>#include <UI/Qt/ChromeStyle.h>#include <UI/Qt/StringUtils.h>@@ -213,9 +214,14 @@ QColor chrome_window_outline(QPalette const& palette)return mix(chrome_background(palette), material_color_anchors(false).border, 0.5);}-QColor chrome_accent(QPalette const& palette)+QColor chrome_accent(){- return palette.color(QPalette::Highlight);+ return BrandColors::Violet100;+}++static QColor chrome_text_highlight()+{+ return BrandColors::SlateBlue900;}QColor chrome_text(QPalette const& palette)@@ -346,8 +352,8 @@ QString toolbar_container_style_sheet(QPalette const& palette)auto disabled_text = style_sheet_color(chrome_muted_text(palette));auto close_hover = style_sheet_color(chrome_destructive_hover());auto close_text = style_sheet_color(chrome_destructive_text());- auto badge_surface_color = dark ? QColor(0x19, 0x0c, 0x4a) : QColor(0xe0, 0xd4, 0xff);- auto badge_border_color = dark ? QColor(0x9c, 0x90, 0xc8) : QColor(0x6c, 0x5f, 0x93);+ auto badge_surface_color = QColor(dark ? BrandColors::Indigo900 : BrandColors::Violet10);+ auto badge_border_color = QColor(dark ? BrandColors::Violet50 : BrandColors::Indigo60);auto badge_surface = style_sheet_color(badge_surface_color);auto badge_border = style_sheet_color(badge_border_color);auto badge_surface_hover = style_sheet_color(mix(badge_surface_color, badge_border_color, dark ? 0.28 : 0.22));@@ -591,7 +597,7 @@ QString location_edit_style_sheet(QPalette const& palette)auto border_color = dark ? mix(chrome_background(palette), chrome_border(palette), 0.36) : chrome_border(palette);auto hover_border_color = border_color;- auto focus_border_color = mix(chrome_border(palette), chrome_accent(palette), dark ? 0.50 : 0.54);+ auto focus_border_color = mix(chrome_border(palette), chrome_accent(), dark ? 0.50 : 0.54);auto surface = style_sheet_color(surface_color);auto hover = style_sheet_color(hover_color);@@ -601,8 +607,8 @@ QString location_edit_style_sheet(QPalette const& palette)auto focus_border = style_sheet_color(focus_border_color);auto text = style_sheet_color(dark ? mix(chrome_text(palette), QColor(255, 255, 255), 0.08) : chrome_text(palette));auto placeholder = style_sheet_color(mix(chrome_muted_text(palette), surface_color, dark ? 0.20 : 0.34));- auto selection = style_sheet_color(chrome_accent(palette));- auto selection_text = style_sheet_color(palette.color(QPalette::HighlightedText));+ auto selection = style_sheet_color(chrome_text_highlight());+ auto selection_text = style_sheet_color(Qt::white);auto not_secure_text = style_sheet_color(dark ? QColor(224, 142, 136) : QColor(144, 62, 56));auto not_secure_background = style_sheet_color(dark ? mix(surface_color, QColor(102, 52, 48), 0.28) : QColor(246, 235, 233));auto not_secure_hover = style_sheet_color(dark ? mix(surface_color, QColor(104, 55, 51), 0.34) : QColor(242, 226, 223));@@ -739,7 +745,9 @@ QString find_in_page_style_sheet(QPalette const& palette)auto border = style_sheet_color(chrome_border(palette));auto control_border_color = chrome_control_border(palette);auto control_border = style_sheet_color(control_border_color);- auto accent = style_sheet_color(chrome_accent(palette));+ auto accent = style_sheet_color(chrome_accent());+ auto selection = style_sheet_color(chrome_text_highlight());+ auto selection_text = style_sheet_color(Qt::white);auto text = style_sheet_color(chrome_text(palette));auto muted = style_sheet_color(chrome_muted_text(palette));auto no_results_background = style_sheet_color(mix(surface_color, chrome_destructive_hover(), is_dark(palette) ? 0.34 : 0.18));@@ -758,7 +766,8 @@ QWidget#LadybirdFindInPageBar QLineEdit {{border-radius: 8px;min-height: 26px;padding: 2px 9px;- selection-background-color: {6};+ selection-background-color: {11};+ selection-color: {12};}}QWidget#LadybirdFindInPageBar QLineEdit:focus {{@@ -793,7 +802,7 @@ QWidget#LadybirdFindInPageBar QLabel {{color: {8};}})",- background, surface, hover, pressed, border, control_border, accent, text, muted, no_results_background, no_results_border);+ background, surface, hover, pressed, border, control_border, accent, text, muted, no_results_background, no_results_border, selection, selection_text);}QString javascript_dialog_style_sheet(QPalette const& palette)@@ -803,7 +812,9 @@ QString javascript_dialog_style_sheet(QPalette const& palette)auto hover = style_sheet_color(chrome_control_surface_hover(palette));auto pressed = style_sheet_color(chrome_control_surface_pressed(palette));auto control_border = style_sheet_color(chrome_control_border(palette));- auto accent = style_sheet_color(chrome_accent(palette));+ auto accent = style_sheet_color(chrome_accent());+ auto selection = style_sheet_color(chrome_text_highlight());+ auto selection_text = style_sheet_color(Qt::white);auto text = style_sheet_color(chrome_text(palette));auto muted = style_sheet_color(chrome_muted_text(palette));auto scrim = is_dark(palette) ? QColor(0, 0, 0, 150) : QColor(20, 22, 25, 120);@@ -844,7 +855,8 @@ QFrame#LadybirdJavaScriptDialogPanel QLineEdit {{border-radius: 8px;min-height: 26px;padding: 2px 9px;- selection-background-color: {6};+ selection-background-color: {9};+ selection-color: {10};}}QFrame#LadybirdJavaScriptDialogPanel QLineEdit:focus {{@@ -905,7 +917,7 @@ QFrame#LadybirdJavaScriptDialogPanel QScrollBar::sub-page:vertical {{background: transparent;}})",- scrim_color, surface, recessed, hover, pressed, control_border, accent, text, muted);+ scrim_color, surface, recessed, hover, pressed, control_border, accent, text, muted, selection, selection_text);}QString bookmark_dialog_style_sheet(QPalette const& palette)@@ -915,7 +927,9 @@ QString bookmark_dialog_style_sheet(QPalette const& palette)auto hover = style_sheet_color(chrome_control_surface_hover(palette));auto pressed = style_sheet_color(chrome_control_surface_pressed(palette));auto control_border = style_sheet_color(chrome_control_border(palette));- auto accent = style_sheet_color(chrome_accent(palette));+ auto accent = style_sheet_color(chrome_accent());+ auto selection = style_sheet_color(chrome_text_highlight());+ auto selection_text = style_sheet_color(Qt::white);auto text = style_sheet_color(chrome_text(palette));return qformatted(R"(@@ -938,7 +952,8 @@ QDialog#LadybirdBookmarkDialog QComboBox {{border-radius: 8px;min-height: 26px;padding: 2px 9px;- selection-background-color: {5};+ selection-background-color: {7};+ selection-color: {8};}}QDialog#LadybirdBookmarkDialog QLineEdit:focus,@@ -1008,14 +1023,16 @@ QDialog#LadybirdBookmarkDialog QPushButton:focus {{border-color: {5};}})",- surface, recessed, hover, pressed, control_border, accent, text);+ surface, recessed, hover, pressed, control_border, accent, text, selection, selection_text);}QString crash_report_review_style_sheet(QPalette const& palette){auto recessed = style_sheet_color(chrome_surface_recessed(palette));auto control_border = style_sheet_color(chrome_control_border(palette));- auto accent = style_sheet_color(chrome_accent(palette));+ auto accent = style_sheet_color(chrome_accent());+ auto selection = style_sheet_color(chrome_text_highlight());+ auto selection_text = style_sheet_color(Qt::white);auto text = style_sheet_color(chrome_text(palette));auto muted = style_sheet_color(chrome_muted_text(palette));@@ -1026,7 +1043,8 @@ QWidget#LadybirdCrashReportReview QPlainTextEdit {{background: {0};border: 1px solid {1};border-radius: 8px;- selection-background-color: {2};+ selection-background-color: {5};+ selection-color: {6};}}QWidget#LadybirdCrashReportReview QLineEdit {{@@ -1053,7 +1071,7 @@ QWidget#LadybirdCrashReportReview QFrame#CrashReportDetails {{border-radius: 8px;}})",- recessed, control_border, accent, text, muted);+ recessed, control_border, accent, text, muted, selection, selection_text);}// Placeholders hint at what to write, so they stay readable rather than taking the platform's faintest text color.@@ -1300,7 +1318,7 @@ QString downloads_popover_style_sheet(QPalette const& palette)auto border = ChromeStyle::style_sheet_color(ChromeStyle::chrome_border(palette));auto text = ChromeStyle::style_sheet_color(ChromeStyle::chrome_text(palette));auto muted_text = ChromeStyle::style_sheet_color(ChromeStyle::chrome_muted_text(palette));- auto accent = ChromeStyle::style_sheet_color(ChromeStyle::chrome_accent(palette));+ auto accent = ChromeStyle::style_sheet_color(ChromeStyle::chrome_accent());return qformatted(R"(QFrame#LadybirdDownloadsPopover {{@@ -1363,10 +1381,10 @@ QString message_popover_style_sheet(QPalette const& palette)auto hover_surface = ChromeStyle::style_sheet_color(ChromeStyle::chrome_surface_hover(palette));auto pressed_surface = ChromeStyle::style_sheet_color(ChromeStyle::chrome_surface_pressed(palette));- auto accent = ChromeStyle::chrome_accent(palette);+ auto accent = ChromeStyle::chrome_accent();auto accent_color = ChromeStyle::style_sheet_color(accent);- auto accent_hover = ChromeStyle::style_sheet_color(ChromeStyle::mix(accent, QColor(Qt::black), 0.12));- auto accent_pressed = ChromeStyle::style_sheet_color(ChromeStyle::mix(accent, QColor(Qt::black), 0.22));+ auto accent_hover = style_sheet_color(BrandColors::Violet500);+ auto accent_pressed = style_sheet_color(BrandColors::Violet900);return qformatted(R"(QFrame#LadybirdMessagePopover {{diff --git a/UI/Qt/ChromeStyle.h b/UI/Qt/ChromeStyle.hindex 64a87966422..313c4bd3f6e 100644--- a/UI/Qt/ChromeStyle.h+++ b/UI/Qt/ChromeStyle.h@@ -30,7 +30,7 @@ QColor chrome_active_tab_surface_bottom(QPalette const&);QColor chrome_border(QPalette const&);QColor chrome_separator(QPalette const&);QColor chrome_window_outline(QPalette const&);-QColor chrome_accent(QPalette const&);+QColor chrome_accent();QColor chrome_muted_text(QPalette const&);QString style_sheet_color(QColor const&);diff --git a/UI/Qt/ContentBlockingButton.cpp b/UI/Qt/ContentBlockingButton.cppindex af0967c5f20..5f1837cd2d2 100644--- a/UI/Qt/ContentBlockingButton.cpp+++ b/UI/Qt/ContentBlockingButton.cpp@@ -80,7 +80,7 @@ void ContentBlockingButton::paintEvent(QPaintEvent*)auto badge_rect = QRect(width() - badge_width - 1, 1, badge_width, badge_height);painter.setPen(Qt::NoPen);- painter.setBrush(QColor(88, 117, 153));+ painter.setBrush(ChromeStyle::chrome_accent());painter.drawRoundedRect(badge_rect, 5, 5);painter.setPen(Qt::white);diff --git a/UI/Qt/ContentBlockingPopover.cpp b/UI/Qt/ContentBlockingPopover.cppindex a609d0f48ec..df6b2f6c810 100644--- a/UI/Qt/ContentBlockingPopover.cpp+++ b/UI/Qt/ContentBlockingPopover.cpp@@ -45,20 +45,22 @@ private:{QStylePainter painter(this);painter.setRenderHint(QPainter::Antialiasing);- if (!isEnabled())- painter.setOpacity(0.45);-auto track = QStyle::visualRect(layoutDirection(), rect(), QRect(width() - 43, (height() - 22) / 2, 40, 22));- auto track_color = isChecked() ? palette().color(QPalette::Active, QPalette::Highlight) : ChromeStyle::chrome_control_border(palette());- if (underMouse() && isEnabled())- track_color = ChromeStyle::mix(track_color, Qt::white, 0.12);+ // Match the switch colors in Base/res/ladybird/ladybird.css, including disabled states.+ auto dark = ChromeStyle::is_dark(palette());+ auto track_color = isChecked() ? ChromeStyle::chrome_accent() : QColor(dark ? 0x6b6b6b : 0x8f8f8f);+ auto thumb_color = QColor(Qt::white);+ if (!isEnabled()) {+ track_color = QColor(dark ? 0x353535 : 0xe0e0e0);+ thumb_color = QColor(dark ? 0x7a7a7a : 0xfafafa);+ }painter.setPen(Qt::NoPen);painter.setBrush(track_color);painter.drawRoundedRect(track, 11, 11);auto thumb_offset = isChecked() != (layoutDirection() == Qt::RightToLeft) ? 21 : 3;- painter.setBrush(palette().color(QPalette::Active, QPalette::HighlightedText));+ painter.setBrush(thumb_color);painter.drawEllipse(QRect(track.x() + thumb_offset, track.y() + 3, 16, 16));auto text_rect = QStyle::visualRect(layoutDirection(), rect(), QRect(0, 0, width() - 56, height()));@@ -66,7 +68,7 @@ private:if (hasFocus()) {painter.setBrush(Qt::NoBrush);- painter.setPen(QPen(palette().color(QPalette::Active, QPalette::Highlight), 2));+ painter.setPen(QPen(ChromeStyle::chrome_accent(), 2));painter.drawRoundedRect(QRectF(track).adjusted(-2, -2, 2, 2), 13, 13);}}diff --git a/UI/Qt/Icon.cpp b/UI/Qt/Icon.cppindex 7b5c8ec7377..3c3dcaa33cf 100644--- a/UI/Qt/Icon.cpp+++ b/UI/Qt/Icon.cpp@@ -364,7 +364,7 @@ QIcon create_chrome_icon(ChromeIcon icon, QPalette const& palette)auto normal = ChromeStyle::chrome_button_text(palette);auto normal_alpha = 216;if (icon == ChromeIcon::DownloadActive) {- normal = ChromeStyle::chrome_accent(palette);+ normal = ChromeStyle::chrome_accent();normal_alpha = 244;} else if (icon == ChromeIcon::Close || icon == ChromeIcon::TabClose)normal_alpha = 172;diff --git a/UI/Qt/LocationEdit.cpp b/UI/Qt/LocationEdit.cppindex d378247349d..edab7effecb 100644--- a/UI/Qt/LocationEdit.cpp+++ b/UI/Qt/LocationEdit.cpp@@ -77,9 +77,9 @@ private:}};-static QColor location_focus_glow_color(QPalette const& palette, int alpha)+static QColor location_focus_glow_color(int alpha){- auto color = ChromeStyle::chrome_accent(palette);+ auto color = ChromeStyle::chrome_accent();color.setAlpha(alpha);return color;}@@ -406,7 +406,7 @@ void LocationEdit::update_focus_glow(int alpha){m_focus_glow_alpha = alpha;if (m_focus_glow_effect)- m_focus_glow_effect->setColor(location_focus_glow_color(palette(), alpha));+ m_focus_glow_effect->setColor(location_focus_glow_color(alpha));}void LocationEdit::animate_focus_glow(int target_alpha)diff --git a/UI/Qt/PerformanceMonitorWidget.cpp b/UI/Qt/PerformanceMonitorWidget.cppindex d1b69cc9181..c7c77dec7c2 100644--- a/UI/Qt/PerformanceMonitorWidget.cpp+++ b/UI/Qt/PerformanceMonitorWidget.cpp@@ -8,6 +8,8 @@#include <LibWebView/TabPerformanceStats.h>#include <QPainter>#include <QPainterPath>+#include <UI/Qt/BrandColors.h>+#include <UI/Qt/ChromeStyle.h>#include <UI/Qt/PerformanceMonitorWidget.h>#include <UI/Qt/StringUtils.h>@@ -65,7 +67,8 @@ void PerformanceMonitorWidget::paintEvent(QPaintEvent*)auto x = text_start;QString accessible_text;auto segments = text_segments();- Array<QColor, 5> colors { neutral, neutral, QColor(40, 135, 220), QColor(210, 130, 35), neutral };+ auto dark = ChromeStyle::is_dark(palette());+ Array<QColor, 5> colors { neutral, neutral, QColor(dark ? BrandColors::SlateBlue100 : BrandColors::SlateBlue900), QColor(dark ? BrandColors::Violet50 : BrandColors::Violet900), neutral };for (size_t i = 0; i < s_labels.size(); ++i) {QString label = s_labels[i];auto label_width = fontMetrics().horizontalAdvance(label);diff --git a/UI/Qt/TabBar.cpp b/UI/Qt/TabBar.cppindex 02b607b65d0..4b73dc4baea 100644--- a/UI/Qt/TabBar.cpp+++ b/UI/Qt/TabBar.cpp@@ -796,7 +796,7 @@ void TabBar::paintEvent(QPaintEvent*)}if (m_drop_indicator_index >= 0 && count() > 0) {- auto indicator_color = ChromeStyle::chrome_accent(palette());+ auto indicator_color = ChromeStyle::chrome_accent();indicator_color.setAlpha(220);painter.setPen(QPen(indicator_color, 3, Qt::SolidLine, Qt::RoundCap));