From 5dd74d39fde21a4058464bb38d7d80dcfb05eddc Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 20 Apr 2014 19:24:22 +0200 Subject: [PATCH] Make hinting configurable --- qutebrowser/browser/hints.py | 27 ++++++++++++++++++--------- qutebrowser/config/configdata.py | 23 +++++++++++++++++++++++ 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index 3da5d037f..1ea5887e7 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -17,6 +17,10 @@ """A HintManager to draw hints over links.""" +import logging + +import qutebrowser.config.config as config + class HintManager: @@ -44,14 +48,11 @@ class HintManager: } HINT_CSS = """ - background: -webkit-gradient(linear, left top, left bottom, - color-stop(0%,#FFF785), color-stop(100%,#FFC542)); - border: 1px solid #E3BE23; - opacity: 0.7; - color: black; - font-weight: bold; - font-family: monospace; - font-size: 12px; + color: {config[colors][hints.fg]}; + background: {config[colors][hints.bg]}; + font: {config[fonts][hints]}; + border: {config[hints][border]}; + opacity: {config[hints][opacity]}; z-index: 100000; position: absolute; left: {left}px; @@ -71,7 +72,15 @@ class HintManager: def _draw_label(self, elem): """Draw a hint label over an element.""" rect = elem.geometry() - css = HintManager.HINT_CSS.format(left=rect.x(), top=rect.y()) + if rect.x() == 0 and rect.y() == 0: + logging.warn("Element is at 0/0...") + return + logging.debug("rect: {}/{}".format(rect.x(), rect.y())) + css = HintManager.HINT_CSS.format( + left=rect.x(), + top=rect.y(), + config=config.instance) + logging.debug("css: {}".format(css)) doc = self._frame.documentElement() doc.appendInside('foo'.format( css)) diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 21d6c9638..2f70617e6 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -56,6 +56,7 @@ SECTION_DESC = { 'general': 'General/misc. options', 'tabbar': 'Configuration of the tab bar.', 'webkit': 'Webkit settings.', + 'hints': 'Hinting settings.', 'searchengines': ( 'Definitions of search engines which can be used via the address ' 'bar.\n' @@ -303,6 +304,15 @@ DATA = OrderedDict([ "This setting enables WebKit's workaround for broken sites."), )), + ('hints', sect.KeyValue( + ('border', + SettingValue(types.String, "1px solid #E3BE23"), + "CSS border value for hints."), + ('opacity', + SettingValue(types.Float, "0.7"), + "Opacity for hints."), + )), + ('searchengines', sect.ValueList( types.SearchEngineName, types.SearchEngineUrl, ('DEFAULT', '${duckduckgo}'), @@ -460,6 +470,16 @@ DATA = OrderedDict([ ('tab.seperator', SettingValue(types.Color, "white"), "Color for the tab seperator."), + + ('hints.fg', + SettingValue(types.CssColor, "black"), + "Font color for hints."), + + ('hints.bg', + SettingValue(types.CssColor, "-webkit-gradient(linear, left top, " + "left bottom, color-stop(0%,#FFF785), " + "color-stop(100%,#FFC542))"), + "Background color for hints."), )), ('fonts', sect.KeyValue( @@ -475,5 +495,8 @@ DATA = OrderedDict([ SettingValue(types.Font, "8pt Monospace"), "Font used in the statusbar."), + ('hints', + SettingValue(types.Font, "bold 12px Monospace"), + "Font used for the hints."), )), ])