mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
Ladybird: Rely on transparent text color for location highlighting
This patch replaces the usage of QPalette::PlaceholderText with QPalette::Text with opacity reduced to roughly 50%. This fixes the non highlighted spans having an extremely low contrast compared to the background in dark mode.
This commit is contained in:
parent
b96920a9d6
commit
1a958633fa
Notes:
sideshowbarker
2024-07-17 06:40:35 +09:00
Author: https://github.com/networkException Commit: https://github.com/SerenityOS/serenity/commit/1a958633fa Pull-request: https://github.com/SerenityOS/serenity/pull/17853 Reviewed-by: https://github.com/awesomekling
@ -39,6 +39,9 @@ void LocationEdit::highlight_location()
|
||||
{
|
||||
auto url = AK::URL::create_with_url_or_path(ak_deprecated_string_from_qstring(text()));
|
||||
|
||||
auto darkened_text_color = QPalette().color(QPalette::Text);
|
||||
darkened_text_color.setAlpha(127);
|
||||
|
||||
QList<QInputMethodEvent::Attribute> attributes;
|
||||
if (url.is_valid() && !hasFocus()) {
|
||||
if (url.scheme() == "http" || url.scheme() == "https" || url.scheme() == "gemini") {
|
||||
@ -49,7 +52,7 @@ void LocationEdit::highlight_location()
|
||||
// for now just highlight the whole host
|
||||
|
||||
QTextCharFormat defaultFormat;
|
||||
defaultFormat.setForeground(QPalette().color(QPalette::PlaceholderText));
|
||||
defaultFormat.setForeground(darkened_text_color);
|
||||
attributes.append({
|
||||
QInputMethodEvent::TextFormat,
|
||||
-cursorPosition(),
|
||||
@ -67,7 +70,7 @@ void LocationEdit::highlight_location()
|
||||
});
|
||||
} else if (url.scheme() == "file") {
|
||||
QTextCharFormat schemeFormat;
|
||||
schemeFormat.setForeground(QPalette().color(QPalette::PlaceholderText));
|
||||
schemeFormat.setForeground(darkened_text_color);
|
||||
attributes.append({
|
||||
QInputMethodEvent::TextFormat,
|
||||
-cursorPosition(),
|
||||
|
Loading…
Reference in New Issue
Block a user