Skip to content

Commit

Permalink
Merge pull request #7 from Ahuge/dev
Browse files Browse the repository at this point in the history
Prepare for Release v0.1.5
  • Loading branch information
Ahuge authored Jan 18, 2021
2 parents bc2c7b7 + dd62d67 commit ac5fc27
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions sept_qt/documentation_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,26 @@ def __init__(self, parser, parent=None):
self.addTab(self._token_webview, "Tokens")
self.addTab(self._operator_webview, "Operators")

def html_prefix(self):
return (
"<head><style>body {"
"background-color: "
+ self._get_background_colour()
+ "color: "
+ self._get_foreground_colour()
+ "}</style></head>"
)

def _get_background_colour(self):
bg_colour = self.palette().color(QtGui.QPalette.Base)
r, g, b = bg_colour.red(), bg_colour.green(), bg_colour.blue()
return "rgb({r}, {g}, {b});".format(r=r, g=g, b=b)

def _get_foreground_colour(self):
fg_colour = self.palette().color(QtGui.QPalette.Text)
r, g, b = fg_colour.red(), fg_colour.green(), fg_colour.blue()
return "rgb({r}, {g}, {b});".format(r=r, g=g, b=b)

def refreshDocumentation(self):
"""
refreshDocumentation will query the parser again for any updated
Expand All @@ -40,10 +60,10 @@ def refreshDocumentation(self):
"""
token_html = self.parser.token_documentation()
self._token_webview.setHtml(token_html)
self._token_webview.setHtml(self.html_prefix() + token_html)

operator_html = self.parser.operator_documentation()
self._operator_webview.setHtml(operator_html)
self._operator_webview.setHtml(self.html_prefix() + operator_html)

def showEvent(self, event):
self.refreshDocumentation()
Expand Down

0 comments on commit ac5fc27

Please sign in to comment.