Use shallow copy to isolate browser row color adjustments (#2158)

This stops flag and card state colors from getting increasingly lighter/darker and also makes the effect exclusive to the cell rows.
This commit is contained in:
Matthias Metelka 2022-11-02 09:25:36 +01:00 committed by GitHub
parent ee9af871b7
commit d44a99885e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,6 +2,7 @@
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
from __future__ import annotations from __future__ import annotations
import copy
import time import time
from dataclasses import dataclass from dataclasses import dataclass
from typing import TYPE_CHECKING, Generator, Sequence, Union from typing import TYPE_CHECKING, Generator, Sequence, Union
@ -103,9 +104,12 @@ def backend_color_to_aqt_color(color: BrowserRow.Color.V) -> dict[str, str] | No
def adjusted_bg_color(color: dict[str, str]) -> dict[str, str]: def adjusted_bg_color(color: dict[str, str]) -> dict[str, str]:
if color: if color:
color["light"] = QColor(color["light"]).lighter(150).name() adjusted_color = copy.copy(color)
color["dark"] = QColor(color["dark"]).darker(150).name() light = QColor(color["light"]).lighter(150)
return color adjusted_color["light"] = light.name()
dark = QColor(color["dark"]).darker(150)
adjusted_color["dark"] = dark.name()
return adjusted_color
else: else:
return None return None