Initial qute://settings upgrade
This commit is contained in:
parent
3a6bcb3dd0
commit
a7c3bb0d55
@ -29,7 +29,7 @@ from PyQt5.QtNetwork import QNetworkReply
|
||||
from qutebrowser.browser import pdfjs, qutescheme
|
||||
from qutebrowser.browser.webkit.network import schemehandler, networkreply
|
||||
from qutebrowser.utils import jinja, log, message, objreg, usertypes, qtutils
|
||||
from qutebrowser.config import configexc, configdata
|
||||
from qutebrowser.config import configexc, configdata, config
|
||||
|
||||
|
||||
class QuteSchemeHandler(schemehandler.SchemeHandler):
|
||||
@ -84,18 +84,19 @@ class JSBridge(QObject):
|
||||
"as it needs javascript support.")
|
||||
return
|
||||
# FIXME:conf
|
||||
try:
|
||||
objreg.get('config').set('conf', sectname, optname, value)
|
||||
except (configexc.Error, configparser.Error) as e:
|
||||
message.error(str(e))
|
||||
message.error("Setting doesn't work yet!")
|
||||
# try:
|
||||
# objreg.get('config').set('conf', sectname, optname, value)
|
||||
# except (configexc.Error, configparser.Error) as e:
|
||||
# message.error(str(e))
|
||||
|
||||
|
||||
@qutescheme.add_handler('settings', backend=usertypes.Backend.QtWebKit)
|
||||
def qute_settings(_url):
|
||||
"""Handler for qute://settings. View/change qute configuration."""
|
||||
config_getter = functools.partial(objreg.get('config').get, raw=True)
|
||||
html = jinja.render('settings.html', title='settings', config=configdata,
|
||||
confget=config_getter)
|
||||
config_getter = config.instance.get # FIXME to_str
|
||||
html = jinja.render('settings.html', title='settings',
|
||||
configdata=configdata, confget=config_getter)
|
||||
return 'text/html', html
|
||||
|
||||
|
||||
|
@ -523,8 +523,8 @@ CHANGED_KEY_COMMANDS = [
|
||||
]
|
||||
|
||||
|
||||
Option = collections.namedtuple('Option', ['typ', 'default', 'backends',
|
||||
'description'])
|
||||
Option = collections.namedtuple('Option', ['name', 'typ', 'default',
|
||||
'backends', 'description'])
|
||||
|
||||
|
||||
def _raise_invalid_node(name, what, node):
|
||||
@ -660,6 +660,7 @@ def _read_yaml(yaml_data):
|
||||
option.keys(), name))
|
||||
|
||||
parsed[name] = Option(
|
||||
name=name,
|
||||
typ=_parse_yaml_type(name, option['type']),
|
||||
default=option['default'],
|
||||
backends=_parse_yaml_backends(name, option.get('backend', None)),
|
||||
|
@ -22,25 +22,22 @@ th pre { color: grey; text-align: left; }
|
||||
<noscript><h1 class="noscript">View Only</h1><p class="noscript-text">Changing settings requires javascript to be enabled!</p></noscript>
|
||||
<header><h1>{{ title }}</h1></header>
|
||||
<table>
|
||||
<!-- FIXME:conf refactor -->
|
||||
{% for section in config.DATA %}
|
||||
<tr><th colspan="2"><h3>{{ section }}</h3><pre>{{ config.SECTION_DESC.get(section)|wordwrap(width=120) }}</pre></th></tr>
|
||||
{% for d, e in config.DATA.get(section).items() %}
|
||||
{% for option in configdata.DATA.values() %}
|
||||
<tr>
|
||||
<td>{{ d }} (Current: {{ confget(section, d)|truncate(100) }})
|
||||
{% if config.DATA.get(section).descriptions[d] %}
|
||||
<p class="option_description">{{ config.DATA.get(section).descriptions[d]|e }}</p>
|
||||
<!-- FIXME: convert to string properly -->
|
||||
<td>{{ option.name }} (Current: {{ confget(option.name) | string |truncate(100) }})
|
||||
{% if option.description %}
|
||||
<p class="option_description">{{ option.description|e }}</p>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<input type="text"
|
||||
onblur="cset('{{ section }}', '{{ d }}', this)"
|
||||
value="{{ confget(section, d) }}">
|
||||
onblur="cset('{{ option.name }}', this)"
|
||||
value="{{ confget(option.name) }}">
|
||||
</input>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user