Addon Manager: Improve darkmode check
This commit is contained in:
@@ -268,42 +268,41 @@ def repair_git_repo(repo_url: str, clone_dir: str) -> None:
|
||||
repo.head.reset("--hard")
|
||||
|
||||
|
||||
def is_darkmode() -> bool:
|
||||
"""Heuristics to determine if we are in a darkmode stylesheet"""
|
||||
if hasattr(QtWidgets.QApplication.instance(), "styleSheet"):
|
||||
if "dark" in QtWidgets.QApplication.instance().styleSheet().lower():
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def warning_color_string() -> str:
|
||||
"""A shade of red, adapted to darkmode if possible. Targets a minimum 7:1 contrast ratio."""
|
||||
|
||||
warningColorString = "rgb(255,0,0)"
|
||||
if hasattr(QtWidgets.QApplication.instance(), "styleSheet"):
|
||||
# Qt 5.9 doesn't give a QApplication instance, so can't give the stylesheet info
|
||||
if "dark" in QtWidgets.QApplication.instance().styleSheet().lower():
|
||||
warningColorString = "rgb(255,105,97)"
|
||||
else:
|
||||
warningColorString = "rgb(215,0,21)"
|
||||
if is_darkmode():
|
||||
warningColorString = "rgb(255,105,97)"
|
||||
else:
|
||||
warningColorString = "rgb(215,0,21)"
|
||||
return warningColorString
|
||||
|
||||
|
||||
def bright_color_string() -> str:
|
||||
"""A shade of green, adapted to darkmode if possible. Targets a minimum 7:1 contrast ratio."""
|
||||
|
||||
brightColorString = "rgb(0,255,0)"
|
||||
if hasattr(QtWidgets.QApplication.instance(), "styleSheet"):
|
||||
# Qt 5.9 doesn't give a QApplication instance, so can't give the stylesheet info
|
||||
if "dark" in QtWidgets.QApplication.instance().styleSheet().lower():
|
||||
brightColorString = "rgb(48,219,91)"
|
||||
else:
|
||||
brightColorString = "rgb(36,138,61)"
|
||||
if is_darkmode():
|
||||
brightColorString = "rgb(48,219,91)"
|
||||
else:
|
||||
brightColorString = "rgb(36,138,61)"
|
||||
return brightColorString
|
||||
|
||||
|
||||
def attention_color_string() -> str:
|
||||
"""A shade of orange, adapted to darkmode if possible. Targets a minimum 7:1 contrast ratio."""
|
||||
|
||||
attentionColorString = "rgb(255,149,0)"
|
||||
if hasattr(QtWidgets.QApplication.instance(), "styleSheet"):
|
||||
# Qt 5.9 doesn't give a QApplication instance, so can't give the stylesheet info
|
||||
if "dark" in QtWidgets.QApplication.instance().styleSheet().lower():
|
||||
attentionColorString = "rgb(255,179,64)"
|
||||
else:
|
||||
attentionColorString = "rgb(255,149,0)"
|
||||
if is_darkmode():
|
||||
attentionColorString = "rgb(255,179,64)"
|
||||
else:
|
||||
attentionColorString = "rgb(255,149,0)"
|
||||
return attentionColorString
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user