Rename and reorder config options

This commit is contained in:
Florian Bruhin 2014-04-27 21:21:14 +02:00
parent 4692414255
commit 8474bbdf6a
13 changed files with 114 additions and 107 deletions

View File

@ -461,7 +461,7 @@ class QuteBrowser(QApplication):
return
self._shutting_down = True
logging.debug("Shutting down... (do_quit={})".format(do_quit))
if config.get('general', 'autosave'):
if config.get('general', 'auto-save-config'):
try:
config.instance.save()
except AttributeError:

View File

@ -81,9 +81,9 @@ class SearchManager(QObject):
self.do_search.emit('', 0)
self._text = text
self._flags = 0
if config.get('general', 'ignorecase'):
if config.get('general', 'ignore-case'):
self._flags |= QWebPage.FindCaseSensitively
if config.get('general', 'wrapsearch'):
if config.get('general', 'wrap-search'):
self._flags |= QWebPage.FindWrapsAroundDocument
if rev:
self._flags |= QWebPage.FindBackward

View File

@ -61,7 +61,7 @@ def init(configdir):
instance = ConfigManager(configdir, 'qutebrowser.conf')
state = ReadWriteConfigParser(configdir, 'state')
cmd_history = LineConfigParser(configdir, 'cmd_history',
('general', 'cmd_histlen'))
('completion', 'history-length'))
def get(*args, **kwargs):

View File

@ -54,13 +54,15 @@ FIRST_COMMENT = """
SECTION_DESC = {
'general': "General/misc. options",
'input': "Options related to input modes.",
'completion': "Options related to completion and command history .",
'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"
"The searchengine named DEFAULT is used when general.auto_search "
"The searchengine named DEFAULT is used when general.auto-search "
"is true and something else than an URL was entered to be opened. "
"Other search engines can be used via the bang-syntax, e.g. "
"\"qutebrowser !google\". The string \"{}\" will be replaced by the "
@ -139,21 +141,11 @@ SECTION_DESC = {
DATA = OrderedDict([
('general', sect.KeyValue(
('show_completion',
SettingValue(types.Bool(), 'true'),
"Whether to show the autocompletion window or not."),
('completion_height',
SettingValue(types.PercOrInt(minperc=0, maxperc=100, minint=1),
'50%'),
"The height of the completion, in px or as percentage of the "
"window."),
('ignorecase',
('ignore-case',
SettingValue(types.Bool(), 'true'),
"Whether to do case-insensitive searching."),
('wrapsearch',
('wrap-search',
SettingValue(types.Bool(), 'true'),
"Whether to wrap search to the top when arriving at the end."),
@ -161,49 +153,64 @@ DATA = OrderedDict([
SettingValue(types.List(), 'http://www.duckduckgo.com'),
"The default page(s) to open at the start, separated with commas."),
('auto_search',
('auto-search',
SettingValue(types.AutoSearch(), 'naive'),
"Whether to start a search when something else than an URL is "
"entered."),
('zoomlevels',
('zoom-levels',
SettingValue(types.PercList(minval=0),
'25%,33%,50%,67%,75%,90%,100%,110%,125%,150%,175%,200%,'
'250%,300%,400%,500%'),
"The available zoom levels, separated by commas."),
('defaultzoom',
('default-zoom',
SettingValue(types.ZoomPerc(), '100%'),
"The default zoom level."),
('autosave',
('auto-save-config',
SettingValue(types.Bool(), 'true'),
"Whether to save the config automatically on quit."),
('cmd_histlen',
('background-tabs',
SettingValue(types.Bool(), 'false'),
"Whether to open new tabs (middleclick/ctrl+click) in background"),
)),
('completion', sect.KeyValue(
('show',
SettingValue(types.Bool(), 'true'),
"Whether to show the autocompletion window or not."),
('height',
SettingValue(types.PercOrInt(minperc=0, maxperc=100, minint=1),
'50%'),
"The height of the completion, in px or as percentage of the "
"window."),
('history-length',
SettingValue(types.Int(minval=-1), '100'),
"How many commands to save in the history. 0: no history / -1: "
"unlimited"),
('background_tabs',
SettingValue(types.Bool(), 'false'),
"Whether to open new tabs (middleclick/ctrl+click) in background"),
)),
('cmd_timeout',
('input', sect.KeyValue(
('timeout',
SettingValue(types.Int(minval=0), '500'),
"Timeout for ambiguous keybindings."),
('insert_mode_on_plugins',
('insert-mode-on-plugins',
SettingValue(types.Bool(), 'true'),
"Whether to switch to insert mode when clicking flash and other "
"plugins."),
('auto_insert_mode',
('auto-insert-mode',
SettingValue(types.Bool(), 'true'),
"Whether to automatically enter insert mode if an editable element "
"is focused after page load."),
('forward_unbound_keys',
('forward-unbound-keys',
SettingValue(types.Bool(), 'false'),
"Whether to forward unbound keys to the website in normal mode."),
)),
@ -213,11 +220,11 @@ DATA = OrderedDict([
SettingValue(types.Bool(), 'true'),
"Whether tabs should be movable."),
('closebuttons',
('close-buttons',
SettingValue(types.Bool(), 'false'),
"Whether tabs should have close-buttons."),
('scrollbuttons',
('scroll-buttons',
SettingValue(types.Bool(), 'true'),
"Whether there should be scroll buttons if there are too many tabs."),
@ -225,11 +232,11 @@ DATA = OrderedDict([
SettingValue(types.Position(), 'north'),
"The position of the tab bar."),
('select_on_remove',
('select-on-remove',
SettingValue(types.SelectOnRemove(), 'previous'),
"Which tab to select when the focused tab is removed."),
('last_close',
('last-close',
SettingValue(types.LastClose(), 'ignore'),
"Behaviour when the last tab is closed."),
@ -239,112 +246,112 @@ DATA = OrderedDict([
)),
('webkit', sect.KeyValue(
('auto_load_images',
('auto-load-images',
SettingValue(types.Bool(), 'true'),
"Specifies whether images are automatically loaded in web pages."),
('dns_prefetch_enabled',
('dns-prefetch-enabled',
SettingValue(types.Bool(), 'false'),
"Specifies whether QtWebkit will try to pre-fetch DNS entries to "
"speed up browsing."),
('javascript_enabled',
('javascript-enabled',
SettingValue(types.Bool(), 'true'),
"Enables or disables the running of JavaScript programs."),
#('java_enabled',
#('java-enabled',
# SettingValue(types.Bool(), 'true'),
# "Enables or disables Java applets. Currently Java applets are "
# "not supported"),
('plugins_enabled',
('plugins-enabled',
SettingValue(types.Bool(), 'false'),
"Enables or disables plugins in Web pages"),
('private_browsing_enabled',
('private-browsing-enabled',
SettingValue(types.Bool(), 'false'),
"Private browsing prevents WebKit from recording visited pages in "
"the history and storing web page icons."),
('javascript_can_open_windows',
('javascript-can-open-windows',
SettingValue(types.Bool(), 'false'),
"Specifies whether JavaScript programs can open new windows."),
('javascript_can_close_windows',
('javascript-can-close-windows',
SettingValue(types.Bool(), 'false'),
"Specifies whether JavaScript programs can close windows."),
('javascript_can_access_clipboard',
('javascript-can-access-clipboard',
SettingValue(types.Bool(), 'false'),
"Specifies whether JavaScript programs can read or write to the "
"clipboard."),
('developer_extras_enabled',
('developer-extras-enabled',
SettingValue(types.Bool(), 'false'),
"Enables extra tools for Web developers (e.g. webinspector)"),
('spatial_navigation_enabled',
('spatial-navigation-enabled',
SettingValue(types.Bool(), 'false'),
"Enables or disables the Spatial Navigation feature, which consists "
"in the ability to navigate between focusable elements in a Web "
"page, such as hyperlinks and form controls, by using Left, Right, "
"Up and Down arrow keys."),
('links_included_in_focus_chain',
('links-included-in-focus-chain',
SettingValue(types.Bool(), 'true'),
"Specifies whether hyperlinks should be included in the keyboard "
"focus chain."),
('zoom_text_only',
('zoom-text-only',
SettingValue(types.Bool(), 'false'),
"Specifies whether the zoom factor on a frame applies only to the "
"text or to all content."),
('print_element_backgrounds',
('print-element-backgrounds',
SettingValue(types.Bool(), 'true'),
"Specifies whether the background color and images are also drawn "
"when the page is printed. "),
('offline_storage_database_enabled',
('offline-storage-database-enabled',
SettingValue(types.Bool(), 'false'),
"Specifies whether support for the HTML 5 offline storage feature is "
"enabled or not. "),
('offline_web_application_storage_enabled',
('offline-web-application-storage-enabled',
SettingValue(types.Bool(), 'false'),
"Specifies whether support for the HTML 5 web application cache "
"feature is enabled or not. "),
('local_storage_enabled',
('local-storage-enabled',
SettingValue(types.Bool(), 'false'),
"Specifies whether support for the HTML 5 local storage feature is "
"enabled or not."),
('local_content_can_access_remote_urls',
('local-content-can-access-remote-urls',
SettingValue(types.Bool(), 'false'),
"Specifies whether locally loaded documents are allowed to access "
"remote urls."),
('local_content_can_access_file_urls',
('local-content-can-access-file-urls',
SettingValue(types.Bool(), 'true'),
"Specifies whether locally loaded documents are allowed to access "
"other local urls."),
('xss_auditing_enabled',
('xss-auditing-enabled',
SettingValue(types.Bool(), 'false'),
"Specifies whether load requests should be monitored for cross-site "
"scripting attempts. Suspicious scripts will be blocked and reported "
"in the inspector's JavaScript console. Enabling this feature might "
"have an impact on performance."),
#('accelerated_compositing_enabled',
#('accelerated-compositing-enabled',
# SettingValue(types.Bool(), 'true'),
# "This feature, when used in conjunction with QGraphicsWebView, "
# "accelerates animations of web content. CSS animations of the "
# "transform and opacity properties will be rendered by composing the "
# "cached content of the animated elements. "),
#('tiled_backing_store_enabled',
#('tiled-backing-store-enabled',
# SettingValue(types.Bool(), 'false'),
# "This setting enables the tiled backing store feature for a "
# "QGraphicsWebView. With the tiled backing store enabled, the web "
@ -354,13 +361,13 @@ DATA = OrderedDict([
# "significantly speed up painting heavy operations like scrolling. "
# "Enabling the feature increases memory consuption."),
('frame_flattening_enabled',
('frame-flattening-enabled',
SettingValue(types.Bool(), 'false'),
"With this setting each subframe is expanded to its contents. This "
"will flatten all the frames to become one scrollable "
"page."),
('site_specific_quirks_enabled',
('site-specific-quirks-enabled',
SettingValue(types.Bool(), 'true'),
"This setting enables WebKit's workaround for broken sites."),
)),

View File

@ -31,36 +31,36 @@ import qutebrowser.config.config as config
MAPPING = {
# noqa
'auto_load_images': QWebSettings.AutoLoadImages,
'dns_prefetch_enabled': QWebSettings.DnsPrefetchEnabled,
'javascript_enabled': QWebSettings.JavascriptEnabled,
#'java_enabled': #QWebSettings.JavaEnabled,
'plugins_enabled': QWebSettings.PluginsEnabled,
'private_browsing_enabled': QWebSettings.PrivateBrowsingEnabled,
'javascript_can_open_windows': QWebSettings.JavascriptCanOpenWindows,
'javascript_can_close_windows': QWebSettings.JavascriptCanCloseWindows,
'javascript_can_access_clipboard':
'auto-load-images': QWebSettings.AutoLoadImages,
'dns-prefetch-enabled': QWebSettings.DnsPrefetchEnabled,
'javascript-enabled': QWebSettings.JavascriptEnabled,
#'java-enabled': #QWebSettings.JavaEnabled,
'plugins-enabled': QWebSettings.PluginsEnabled,
'private-browsing-enabled': QWebSettings.PrivateBrowsingEnabled,
'javascript-can-open-windows': QWebSettings.JavascriptCanOpenWindows,
'javascript-can-close-windows': QWebSettings.JavascriptCanCloseWindows,
'javascript-can-access-clipboard':
QWebSettings.JavascriptCanAccessClipboard,
'developer_extras_enabled': QWebSettings.DeveloperExtrasEnabled,
'spatial_navigation_enabled': QWebSettings.SpatialNavigationEnabled,
'links_included_in_focus_chain': QWebSettings.LinksIncludedInFocusChain,
'zoom_text_only': QWebSettings.ZoomTextOnly,
'print_element_backgrounds': QWebSettings.PrintElementBackgrounds,
'offline_storage_database_enabled':
'developer-extras-enabled': QWebSettings.DeveloperExtrasEnabled,
'spatial-navigation-enabled': QWebSettings.SpatialNavigationEnabled,
'links-included-in-focus-chain': QWebSettings.LinksIncludedInFocusChain,
'zoom-text-only': QWebSettings.ZoomTextOnly,
'print-element-backgrounds': QWebSettings.PrintElementBackgrounds,
'offline-storage-database-enabled':
QWebSettings.OfflineStorageDatabaseEnabled,
'offline_web_application_storage_enabled':
'offline-web-application-storage-enabled':
QWebSettings.OfflineWebApplicationCacheEnabled,
'local_storage_enabled': QWebSettings.LocalStorageEnabled,
'local_content_can_access_remote_urls':
'local-storage-enabled': QWebSettings.LocalStorageEnabled,
'local-content-can-access-remote-urls':
QWebSettings.LocalContentCanAccessRemoteUrls,
'local_content_can_access_file_urls':
'local-content-can-access-file-urls':
QWebSettings.LocalContentCanAccessFileUrls,
'xss_auditing_enabled': QWebSettings.XSSAuditingEnabled,
#'accelerated_compositing_enabled':
'xss-auditing-enabled': QWebSettings.XSSAuditingEnabled,
#'accelerated-compositing-enabled':
# QWebSettings.AcceleratedCompositingEnabled,
#'tiled_backing_store_enabled': QWebSettings.TiledBackingStoreEnabled,
'frame_flattening_enabled': QWebSettings.FrameFlatteningEnabled,
'site_specific_quirks_enabled': QWebSettings.SiteSpecificQuirksEnabled,
#'tiled-backing-store-enabled': QWebSettings.TiledBackingStoreEnabled,
'frame-flattening-enabled': QWebSettings.FrameFlatteningEnabled,
'site-specific-quirks-enabled': QWebSettings.SiteSpecificQuirksEnabled,
}
settings = None

View File

@ -245,7 +245,7 @@ class BaseKeyParser(QObject):
count: The count to pass.
"""
logging.debug("Ambiguous match for \"{}\"".format(self._keystring))
time = config.get('general', 'cmd_timeout')
time = config.get('input', 'timeout')
if time == 0:
# execute immediately
self._keystring = ''

View File

@ -98,8 +98,8 @@ class ModeManager(QObject):
self.passthrough = []
self._mode_stack = []
self._releaseevents_to_pass = []
self._forward_unbound_keys = config.get('general',
'forward_unbound_keys')
self._forward_unbound_keys = config.get('input',
'forward-unbound-keys')
@property
def mode(self):
@ -132,7 +132,7 @@ class ModeManager(QObject):
if not filter_this:
self._releaseevents_to_pass.append(event)
logging.debug("handled: {}, forward_unbound_keys: {}, passthrough: {} "
logging.debug("handled: {}, forward-unbound-keys: {}, passthrough: {} "
"--> filter: {}".format(handled,
self._forward_unbound_keys,
self.mode in self.passthrough,
@ -220,9 +220,9 @@ class ModeManager(QObject):
@pyqtSlot(str, str)
def on_config_changed(self, section, option):
"""Update local setting when config changed."""
if (section, option) == ('general', 'forward_unbound_keys'):
self._forward_unbound_keys = config.get('general',
'forward_unbound_keys')
if (section, option) == ('input', 'forward-unbound-keys'):
self._forward_unbound_keys = config.get('input',
'forward-unbound-keys')
def eventFilter(self, obj, event):
"""Filter all events based on the currently set mode.

View File

@ -164,7 +164,7 @@ def is_url(url):
"""
urlstr = urlstring(url)
autosearch = config.get('general', 'auto_search')
autosearch = config.get('general', 'auto-search')
logging.debug("Checking if '{}' is an URL (autosearch={}).".format(
urlstr, autosearch))

View File

@ -105,7 +105,7 @@ class CompletionView(QTreeView):
def __init__(self, parent=None):
super().__init__(parent)
self._enabled = config.get('general', 'show_completion')
self._enabled = config.get('completion', 'show')
self._model = None
self._lastmodel = None
self._completion_models = {
@ -241,8 +241,8 @@ class CompletionView(QTreeView):
@pyqtSlot(str, str)
def on_config_changed(self, section, option):
"""Update self._enabled when the config changed."""
if section == 'general' and option == 'show_completion':
self._enabled = config.get('general', 'show_completion')
if section == 'completion' and option == 'show':
self._enabled = config.get('completion', 'show')
@pyqtSlot(str)
def on_cmd_text_changed(self, text):

View File

@ -188,14 +188,14 @@ class TabbedBrowser(TabWidget):
count: The tab index to close, or None
Emit:
quit: If last tab was closed and last_close in config is set to
quit: If last tab was closed and last-close in config is set to
quit.
"""
idx = self.currentIndex() if count is None else count - 1
tab = self.cntwidget(count)
if tab is None:
return
last_close = config.get('tabbar', 'last_close')
last_close = config.get('tabbar', 'last-close')
if self.count() > 1:
self._url_stack.append(tab.url())
self.removeTab(idx)

View File

@ -80,10 +80,10 @@ class TabWidget(QTabWidget):
'previous': QTabBar.SelectPreviousTab,
}
self.setMovable(config.get('tabbar', 'movable'))
self.setTabsClosable(config.get('tabbar', 'closebuttons'))
self.setUsesScrollButtons(config.get('tabbar', 'scrollbuttons'))
self.setTabsClosable(config.get('tabbar', 'close-buttons'))
self.setUsesScrollButtons(config.get('tabbar', 'scroll-buttons'))
posstr = config.get('tabbar', 'position')
selstr = config.get('tabbar', 'select_on_remove')
selstr = config.get('tabbar', 'select-on-remove')
try:
self.setTabPosition(position_conv[posstr])
self.tabBar().setSelectionBehaviorOnRemove(select_conv[selstr])

View File

@ -88,12 +88,12 @@ class MainWindow(QWidget):
@pyqtSlot(str, str)
def on_config_changed(self, section, option):
"""Resize completion if config changed."""
if section == 'general' and option == 'completion_height':
if section == 'completion' and option == 'height':
self.resize_completion()
def resize_completion(self):
"""Adjust completion according to config."""
confheight = str(config.get('general', 'completion_height'))
confheight = str(config.get('completion', 'height'))
if confheight.endswith('%'):
perc = int(confheight.rstrip('%'))
height = self.height() * perc / 100
@ -115,7 +115,7 @@ class MainWindow(QWidget):
self.inspector.hide()
self.resize_completion()
else:
if not config.get('webkit', 'developer_extras_enabled'):
if not config.get('webkit', 'developer-extras-enabled'):
self.status.disp_error("Please enable developer-extras before "
"using the webinspector!")
else:

View File

@ -93,8 +93,8 @@ class WebView(QWebView):
def _init_neighborlist(self):
"""Initialize the _zoom neighborlist."""
self._zoom = NeighborList(
config.get('general', 'zoomlevels'),
default=config.get('general', 'defaultzoom'),
config.get('general', 'zoom-levels'),
default=config.get('general', 'default-zoom'),
mode=NeighborList.BLOCK)
def _on_destroyed(self, sender):
@ -123,7 +123,7 @@ class WebView(QWebView):
if hitresult.isContentEditable():
# text fields and the like
return True
if not config.get('general', 'insert_mode_on_plugins'):
if not config.get('input', 'insert-mode-on-plugins'):
return False
elem = hitresult.element()
tag = elem.tagName().lower()
@ -236,7 +236,7 @@ class WebView(QWebView):
@pyqtSlot(str, str)
def on_config_changed(self, section, option):
"""Update tab config when config was changed."""
if section == 'general' and option in ['zoomlevels', 'defaultzoom']:
if section == 'general' and option in ['zoom-levels', 'default-zoom']:
self._init_neighborlist()
@pyqtSlot('QMouseEvent')
@ -247,8 +247,8 @@ class WebView(QWebView):
@pyqtSlot(bool)
def on_load_finished(self, _ok):
"""Handle auto_insert_mode after loading finished."""
if not config.get('general', 'auto_insert_mode'):
"""Handle auto-insert-mode after loading finished."""
if not config.get('input', 'auto-insert-mode'):
return
frame = self.page_.currentFrame()
elem = frame.findFirstElement(
@ -334,7 +334,7 @@ class WebView(QWebView):
self._open_target))
elif (e.button() == Qt.MidButton or
e.modifiers() & Qt.ControlModifier):
if config.get('general', 'background_tabs'):
if config.get('general', 'background-tabs'):
self._open_target = "bgtab"
else:
self._open_target = "tab"