Add ability to change document's default background and text color

This commit is contained in:
Fierelier 2021-03-18 19:17:14 +01:00
parent 78f23db211
commit c8dd22817a
2 changed files with 15 additions and 2 deletions

View File

@ -1,3 +1,9 @@
[default]
home = https://example.com
useragent = BirdyNet/$VER ($OS)
useragent = BirdyNet/$VER ($OS)
[accessibility]
# Which background color (CSS color) should be chosen for websites? "default" for system's default. "white" is recommended for compatibility.
colorBackground = white
# Which text color (CSS color) should be chosen for websites? "default" for system's default. "black" is recommended for compatibility.
colorText = black

View File

@ -3,7 +3,14 @@ class browserDoc(QTextBrowser):
def __init__(self,*args,**kwargs):
super().__init__(*args,**kwargs)
self.setOpenLinks(False)
self.setStyleSheet("QTextBrowser { background-color: white; color: black }")
style = ""
if (config["accessibility"]["colorBackground"] != "default"):
style += "background-color: " +config["accessibility"]["colorBackground"] + ";"
if (config["accessibility"]["colorText"] != "default"):
style += "color: " +config["accessibility"]["colorText"]+ ";"
self.setStyleSheet("QTextBrowser { " +style+ " }")
self.anchorClicked.connect(self.cAnchorClicked)
def cRenderHtml(self,html):