Remove dark mode settings removed from Chromium

Closes #7929
This commit is contained in:
Florian Bruhin 2023-12-04 13:36:58 +01:00
parent 1cd6d5af63
commit 2a10461ca4
5 changed files with 18 additions and 103 deletions

View File

@ -19,6 +19,12 @@ breaking changes (such as renamed commands) can happen in minor releases.
v3.1.0 (unreleased)
-------------------
Removed
~~~~~~~
- The darkmode settings `grayscale.all`, `grayscale.images` and
`increase_text_contrast` got removed, following removals in Chromium.
Changed
~~~~~~~

View File

@ -118,9 +118,6 @@
|<<colors.webpage.darkmode.algorithm,colors.webpage.darkmode.algorithm>>|Which algorithm to use for modifying how colors are rendered with darkmode.
|<<colors.webpage.darkmode.contrast,colors.webpage.darkmode.contrast>>|Contrast for dark mode.
|<<colors.webpage.darkmode.enabled,colors.webpage.darkmode.enabled>>|Render all web contents using a dark theme.
|<<colors.webpage.darkmode.grayscale.all,colors.webpage.darkmode.grayscale.all>>|Render all colors as grayscale.
|<<colors.webpage.darkmode.grayscale.images,colors.webpage.darkmode.grayscale.images>>|Desaturation factor for images in dark mode.
|<<colors.webpage.darkmode.increase_text_contrast,colors.webpage.darkmode.increase_text_contrast>>|Increase text contrast by drawing an outline of the uninverted color.
|<<colors.webpage.darkmode.policy.images,colors.webpage.darkmode.policy.images>>|Which images to apply dark mode to.
|<<colors.webpage.darkmode.policy.page,colors.webpage.darkmode.policy.page>>|Which pages to apply dark mode to.
|<<colors.webpage.darkmode.threshold.background,colors.webpage.darkmode.threshold.background>>|Threshold for inverting background elements with dark mode.
@ -1695,46 +1692,6 @@ Type: <<types,Bool>>
Default: +pass:[false]+
[[colors.webpage.darkmode.grayscale.all]]
=== colors.webpage.darkmode.grayscale.all
Render all colors as grayscale.
This only has an effect when `colors.webpage.darkmode.algorithm` is set to `lightness-hsl` or `brightness-rgb`.
This setting requires a restart.
This setting is only available with the QtWebEngine backend.
Type: <<types,Bool>>
Default: +pass:[false]+
[[colors.webpage.darkmode.grayscale.images]]
=== colors.webpage.darkmode.grayscale.images
Desaturation factor for images in dark mode.
If set to 0, images are left as-is. If set to 1, images are completely grayscale. Values between 0 and 1 desaturate the colors accordingly.
This setting requires a restart.
This setting is only available with the QtWebEngine backend.
Type: <<types,Float>>
Default: +pass:[0.0]+
[[colors.webpage.darkmode.increase_text_contrast]]
=== colors.webpage.darkmode.increase_text_contrast
Increase text contrast by drawing an outline of the uninverted color.
This setting requires a restart.
On QtWebEngine, this setting requires Qt 6.3 or newer.
On QtWebKit, this setting is unavailable.
Type: <<types,Bool>>
Default: +pass:[false]+
[[colors.webpage.darkmode.policy.images]]
=== colors.webpage.darkmode.policy.images
Which images to apply dark mode to.

View File

@ -85,7 +85,8 @@ Qt 6.3
------
- New IncreaseTextContrast:
https://chromium-review.googlesource.com/c/chromium/src/+/2893236
https://chromium-review.googlesource.com/c/chromium/src/+/2893236
(UNSUPPORTED because dropped in 6.5)
Qt 6.4
------
@ -97,6 +98,15 @@ Qt 6.4
"Rename text_classifier to foreground_classifier"
https://chromium-review.googlesource.com/c/chromium/src/+/3226389
- Grayscale darkmode support removed:
https://chromium-review.googlesource.com/c/chromium/src/+/3238985
Qt 6.5
------
- IncreaseTextContrast removed:
https://chromium-review.googlesource.com/c/chromium/src/+/3821841
"""
import os
@ -120,7 +130,6 @@ class Variant(enum.Enum):
qt_515_2 = enum.auto()
qt_515_3 = enum.auto()
qt_63 = enum.auto()
qt_64 = enum.auto()
@ -273,12 +282,10 @@ _DEFINITIONS: MutableMapping[Variant, _Definition] = {
_Setting('policy.images', 'ImagePolicy', _IMAGE_POLICIES),
_Setting('contrast', 'Contrast'),
_Setting('grayscale.all', 'Grayscale', _BOOLS),
_Setting('policy.page', 'PagePolicy', _PAGE_POLICIES),
_Setting('threshold.foreground', 'TextBrightnessThreshold'),
_Setting('threshold.background', 'BackgroundBrightnessThreshold'),
_Setting('grayscale.images', 'ImageGrayscale'),
mandatory={'enabled', 'policy.images'},
prefix='forceDarkMode',
@ -291,21 +298,16 @@ _DEFINITIONS: MutableMapping[Variant, _Definition] = {
_Setting('policy.images', 'ImagePolicy', _IMAGE_POLICIES),
_Setting('contrast', 'ContrastPercent'),
_Setting('grayscale.all', 'IsGrayScale', _BOOLS),
_Setting('threshold.foreground', 'TextBrightnessThreshold'),
_Setting('threshold.background', 'BackgroundBrightnessThreshold'),
_Setting('grayscale.images', 'ImageGrayScalePercent'),
mandatory={'enabled', 'policy.images'},
prefix='',
switch_names={'enabled': _BLINK_SETTINGS, None: 'dark-mode-settings'},
),
}
_DEFINITIONS[Variant.qt_63] = _DEFINITIONS[Variant.qt_515_3].copy_add_setting(
_Setting('increase_text_contrast', 'IncreaseTextContrast', _INT_BOOLS),
)
_DEFINITIONS[Variant.qt_64] = _DEFINITIONS[Variant.qt_63].copy_replace_setting(
_DEFINITIONS[Variant.qt_64] = _DEFINITIONS[Variant.qt_515_3].copy_replace_setting(
'threshold.foreground', 'ForegroundBrightnessThreshold',
)
@ -328,11 +330,6 @@ _PREFERRED_COLOR_SCHEME_DEFINITIONS: Mapping[Variant, Mapping[_SettingValType, s
"light": "1",
},
Variant.qt_63: {
"dark": "0",
"light": "1",
},
Variant.qt_64: {
"dark": "0",
"light": "1",
@ -351,8 +348,6 @@ def _variant(versions: version.WebEngineVersions) -> Variant:
if versions.webengine >= utils.VersionNumber(6, 4):
return Variant.qt_64
elif versions.webengine >= utils.VersionNumber(6, 3):
return Variant.qt_63
elif (versions.webengine == utils.VersionNumber(5, 15, 2) and
versions.chromium_major == 87):
# WORKAROUND for Gentoo packaging something newer as 5.15.2...

View File

@ -3359,41 +3359,6 @@ colors.webpage.darkmode.threshold.background:
restart: true
backend: QtWebEngine
colors.webpage.darkmode.grayscale.all:
default: false
type: Bool
desc: >-
Render all colors as grayscale.
This only has an effect when `colors.webpage.darkmode.algorithm` is set to
`lightness-hsl` or `brightness-rgb`.
restart: true
backend: QtWebEngine
colors.webpage.darkmode.grayscale.images:
default: 0.0
type:
name: Float
minval: 0.0
maxval: 1.0
desc: >-
Desaturation factor for images in dark mode.
If set to 0, images are left as-is. If set to 1, images are completely
grayscale. Values between 0 and 1 desaturate the colors accordingly.
restart: true
backend: QtWebEngine
colors.webpage.darkmode.increase_text_contrast:
default: false
type: Bool
desc: >-
Increase text contrast by drawing an outline of the uninverted color.
restart: true
backend:
QtWebEngine: Qt 6.3
QtWebKit: false
# emacs: '
## fonts

View File

@ -103,7 +103,6 @@ QT_515_2_SETTINGS = {'blink-settings': [
('forceDarkModeEnabled', 'true'),
('forceDarkModeInversionAlgorithm', '2'),
('forceDarkModeImagePolicy', '2'),
('forceDarkModeGrayscale', 'true'),
('forceDarkModeTextBrightnessThreshold', '100'),
]}
@ -113,7 +112,6 @@ QT_515_3_SETTINGS = {
'dark-mode-settings': [
('InversionAlgorithm', '1'),
('ImagePolicy', '2'),
('IsGrayScale', 'true'),
('TextBrightnessThreshold', '100'),
],
}
@ -123,7 +121,6 @@ QT_64_SETTINGS = {
'dark-mode-settings': [
('InversionAlgorithm', '1'),
('ImagePolicy', '2'),
('IsGrayScale', 'true'),
('ForegroundBrightnessThreshold', '100'),
],
}
@ -138,7 +135,6 @@ def test_qt_version_differences(config_stub, qversion, expected):
settings = {
'enabled': True,
'algorithm': 'brightness-rgb',
'grayscale.all': True,
'threshold.foreground': 100,
}
for k, v in settings.items():
@ -160,10 +156,6 @@ def test_qt_version_differences(config_stub, qversion, expected):
'TextBrightnessThreshold', '100'),
('threshold.background', 100,
'BackgroundBrightnessThreshold', '100'),
('grayscale.all', True,
'Grayscale', 'true'),
('grayscale.images', 0.5,
'ImageGrayscale', '0.5'),
])
def test_customization(config_stub, setting, value, exp_key, exp_val):
config_stub.val.colors.webpage.darkmode.enabled = True