View/edit browser config in a special browser page
Add the ability to view/edit the browser's config settings via a special browser page. It's very simplistic for now, but a good starting point. Future possibilities: * Matching config types to html input types * colors = html colorpicker * options with valid_values = select/multi-select * plain text fallbacks where appropriate * multi-line text edits for long options (i.e. host-block-lists) * Javascript option verification * switch from submitting changes onblur to onchange if an option passes basic verification, etc.
This commit is contained in:
parent
6973050ccc
commit
bf37d16896
@ -520,6 +520,13 @@ class ConfigManager(QObject):
|
|||||||
if self._initialized:
|
if self._initialized:
|
||||||
self._after_set(sectname, optname)
|
self._after_set(sectname, optname)
|
||||||
|
|
||||||
|
@pyqtSlot(str, str, str)
|
||||||
|
def set_javascript(self, sectname, optname, value):
|
||||||
|
try:
|
||||||
|
self.set('conf', sectname, optname, value)
|
||||||
|
except configtypes.ValidationError as e:
|
||||||
|
message.error(e)
|
||||||
|
|
||||||
@cmdutils.register(instance='config')
|
@cmdutils.register(instance='config')
|
||||||
def save(self):
|
def save(self):
|
||||||
"""Save the config file."""
|
"""Save the config file."""
|
||||||
|
37
qutebrowser/html/settings.html
Normal file
37
qutebrowser/html/settings.html
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block script %}
|
||||||
|
var cset = function(section, option, el) {
|
||||||
|
value = el.value;
|
||||||
|
window.qutesettings.set_javascript(section, option, value);
|
||||||
|
}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block style %}
|
||||||
|
table { border: 1px solid grey; border-collapse: collapse; }
|
||||||
|
pre { margin: 2px; }
|
||||||
|
th, td { border: 1px solid grey; padding: 0px 5px; }
|
||||||
|
th { background: lightgrey; }
|
||||||
|
th pre { color: grey; text-align: left; }
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<header><h1>{{ title }}</h1></header>
|
||||||
|
<table>
|
||||||
|
{% 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() %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ d }} (Current: {{ e.value()|truncate(100) }})</td>
|
||||||
|
<td>
|
||||||
|
<input type="input"
|
||||||
|
onblur="cset('{{ section }}', '{{ d }}', this)"
|
||||||
|
value="{{ e.value() }}">
|
||||||
|
</input>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
|
||||||
|
{% endblock %}
|
@ -31,7 +31,8 @@ from PyQt5.QtNetwork import QNetworkReply
|
|||||||
|
|
||||||
import qutebrowser
|
import qutebrowser
|
||||||
from qutebrowser.network import schemehandler, networkreply
|
from qutebrowser.network import schemehandler, networkreply
|
||||||
from qutebrowser.utils import version, utils, jinja, log, message, docutils
|
from qutebrowser.utils import (version, utils, jinja, log, message, docutils,
|
||||||
|
objreg)
|
||||||
|
|
||||||
|
|
||||||
pyeval_output = ":pyeval was never called"
|
pyeval_output = ":pyeval was never called"
|
||||||
@ -146,6 +147,19 @@ def qute_help(win_id, request):
|
|||||||
return utils.read_file(path).encode('UTF-8', errors='xmlcharrefreplace')
|
return utils.read_file(path).encode('UTF-8', errors='xmlcharrefreplace')
|
||||||
|
|
||||||
|
|
||||||
|
def qute_settings(win_id, request):
|
||||||
|
"""Handler for qute:settings. View/change qute configuration"""
|
||||||
|
from qutebrowser.config import configdata
|
||||||
|
|
||||||
|
cfg = objreg.get('config')
|
||||||
|
frame = objreg.get('webview', scope='tab').page().mainFrame()
|
||||||
|
frame.addToJavaScriptWindowObject("qutesettings", cfg)
|
||||||
|
|
||||||
|
html = jinja.env.get_template('settings.html').render(
|
||||||
|
title='settings', config=configdata, cfg=cfg)
|
||||||
|
return html.encode('UTF-8', errors='xmlcharrefreplace')
|
||||||
|
|
||||||
|
|
||||||
HANDLERS = {
|
HANDLERS = {
|
||||||
'pyeval': qute_pyeval,
|
'pyeval': qute_pyeval,
|
||||||
'version': qute_version,
|
'version': qute_version,
|
||||||
@ -153,4 +167,5 @@ HANDLERS = {
|
|||||||
'log': qute_log,
|
'log': qute_log,
|
||||||
'gpl': qute_gpl,
|
'gpl': qute_gpl,
|
||||||
'help': qute_help,
|
'help': qute_help,
|
||||||
|
'settings': qute_settings,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user