Make non-specialized config types String. Closes #1103

This commit is contained in:
Patric Schmitz 2015-11-09 09:12:13 +01:00 committed by Patric Schmitz
parent 75f9f2af8d
commit 2a705e2eb6
2 changed files with 101 additions and 179 deletions

View File

@ -209,18 +209,32 @@ def data(readonly=False):
"be used."),
('new-instance-open-target',
SettingValue(typ.NewInstanceOpenTarget(), 'tab'),
SettingValue(typ.String(
valid_values=typ.ValidValues(
('tab', "Open a new tab in the existing "
"window and activate the window."),
('tab-bg', "Open a new background tab in the "
"existing window and activate the "
"window."),
('tab-silent', "Open a new tab in the existing "
"window without activating "
"the window."),
('tab-bg-silent', "Open a new background tab "
"in the existing window "
"without activating the "
"window."),
('window', "Open in a new window.")
)), 'tab'),
"How to open links in an existing instance if a new one is "
"launched."),
('log-javascript-console',
SettingValue(
typ.String(
valid_values=typ.ValidValues(
('none', 'Not displayed'),
('debug', 'Display in debug mode'),
('info', 'Display always'))),
'debug'),
SettingValue(typ.String(
valid_values=typ.ValidValues(
('none', 'Not displayed'),
('debug', 'Display in debug mode'),
('info', 'Display always')
)), 'debug'),
"How to log javascript console messages."),
('save-session',
@ -351,7 +365,15 @@ def data(readonly=False):
"Value to send in the `accept-language` header."),
('referer-header',
SettingValue(typ.Referer(), 'same-domain'),
SettingValue(typ.String(
valid_values=typ.ValidValues(
('always', "Always send."),
('never', "Never send; this is not recommended,"
" as some sites may break."),
('same-domain', "Only send for the same domain."
" This will still protect your privacy, but"
" shouldn't break any sites.")
)), 'same-domain'),
"Send the Referer header"),
('user-agent',
@ -385,7 +407,12 @@ def data(readonly=False):
"Automatically open completion when typing."),
('download-path-suggestion',
SettingValue(typ.DownloadPathSuggestion(), 'path'),
SettingValue(typ.String(
valid_values=typ.ValidValues(
('path', "Show only the download path."),
('filename', "Show only download filename."),
('both', "Show download path and filename."))),
'path'),
"What to display in the download filename input."),
('timestamp-format',
@ -458,7 +485,13 @@ def data(readonly=False):
"element is focused after page load."),
('forward-unbound-keys',
SettingValue(typ.ForwardUnboundKeys(), 'auto'),
SettingValue(typ.String(
valid_values=typ.ValidValues(
('all', "Forward all unbound keys."),
('auto', "Forward unbound non-alphanumeric "
"keys."),
('none', "Don't forward any keys.")
)), 'auto'),
"Whether to forward unbound keys to the webview in normal mode."),
('spatial-navigation',
@ -508,11 +541,26 @@ def data(readonly=False):
"How new tabs opened explicitly are positioned."),
('last-close',
SettingValue(typ.LastClose(), 'ignore'),
SettingValue(typ.String(
valid_values=typ.ValidValues(
('ignore', "Don't do anything."),
('blank', "Load a blank page."),
('startpage', "Load the start page."),
('default-page', "Load the default page."),
('close', "Close the window.")
)), 'ignore'),
"Behavior when the last tab is closed."),
('show',
SettingValue(typ.TabBarShow(), 'always'),
SettingValue(typ.String(
valid_values=typ.ValidValues(
('always', "Always show the tab bar."),
('never', "Always hide the tab bar."),
('multiple', "Hide the tab bar if only one tab "
"is open."),
('switching', "Show the tab bar when switching "
"tabs.")
)), 'always'),
"When to show the tab bar"),
('show-switching-delay',
@ -529,7 +577,12 @@ def data(readonly=False):
"Whether tabs should be movable."),
('close-mouse-button',
SettingValue(typ.CloseButton(), 'middle'),
SettingValue(typ.String(
valid_values=typ.ValidValues(
('right', "Close tabs on right-click."),
('middle', "Close tabs on middle-click."),
('none', "Don't close tabs using the mouse.")
)), 'middle'),
"On which mouse button to close tabs."),
('position',
@ -737,7 +790,16 @@ def data(readonly=False):
"local urls."),
('cookies-accept',
SettingValue(typ.AcceptCookies(), 'no-3rdparty'),
SettingValue(typ.String(
valid_values=typ.ValidValues(
('all', "Accept all cookies."),
('no-3rdparty', "Accept cookies from the same"
" origin only."),
('no-unknown-3rdparty', "Accept cookies from "
"the same origin only, unless a cookie is "
"already set for the domain."),
('never', "Don't accept cookies at all.")
)), 'no-3rdparty'),
"Control which cookies to accept."),
('cookies-store',
@ -785,7 +847,12 @@ def data(readonly=False):
"Opacity for hints."),
('mode',
SettingValue(typ.HintMode(), 'letter'),
SettingValue(typ.String(
valid_values=typ.ValidValues(
('number', "Use numeric hints."),
('letter', "Use the chars in the hints -> "
"chars setting.")
)), 'letter'),
"Mode to use for hints."),
('chars',

View File

@ -652,11 +652,11 @@ class ColorSystem(MappingType):
special = True
def __init__(self):
self.valid_values = \
ValidValues(('rgb', "Interpolate in the RGB color system."),
('hsv', "Interpolate in the HSV color system."),
('hsl', "Interpolate in the HSL color system."),
('none', "Don't show a gradient."))
self.valid_values = ValidValues(
('rgb', "Interpolate in the RGB color system."),
('hsv', "Interpolate in the HSV color system."),
('hsl', "Interpolate in the HSL color system."),
('none', "Don't show a gradient."))
MAPPING = {
'rgb': QColor.Rgb,
@ -1090,19 +1090,6 @@ class ShellCommand(BaseType):
return shlex.split(value)
class HintMode(BaseType):
"""Base class for the hints -> mode setting."""
special = True
def __init__(self):
self.valid_values = \
ValidValues(('number', "Use numeric hints."),
('letter', "Use the chars in the hints -> "
"chars setting."))
class Proxy(BaseType):
"""A proxy URL or special value."""
@ -1110,9 +1097,9 @@ class Proxy(BaseType):
special = True
def __init__(self):
self.valid_values = \
ValidValues(('system', "Use the system wide proxy."),
('none', "Don't use any proxy"))
self.valid_values = ValidValues(
('system', "Use the system wide proxy."),
('none', "Don't use any proxy"))
PROXY_TYPES = {
'http': QNetworkProxy.HttpProxy,
@ -1413,38 +1400,6 @@ class SelectOnRemove(MappingType):
}
class LastClose(BaseType):
"""Behavior when the last tab is closed."""
special = True
def __init__(self):
self.valid_values = \
ValidValues(('ignore', "Don't do anything."),
('blank', "Load a blank page."),
('startpage', "Load the start page."),
('default-page', "Load the default page."),
('close', "Close the window."))
class AcceptCookies(BaseType):
"""Control which cookies to accept."""
special = True
def __init__(self):
self.valid_values = \
ValidValues(('all', "Accept all cookies."),
('no-3rdparty', "Accept cookies from the same"
" origin only."),
('no-unknown-3rdparty', "Accept cookies from "
"the same origin only, unless a cookie is "
"already set for the domain."),
('never', "Don't accept cookies at all."))
class ConfirmQuit(FlagList):
"""Whether to display a confirmation when the window is closed."""
@ -1477,33 +1432,6 @@ class ConfirmQuit(FlagList):
value, "List cannot contain always!")
class ForwardUnboundKeys(BaseType):
"""Whether to forward unbound keys."""
special = True
def __init__(self):
self.valid_values = \
ValidValues(('all', "Forward all unbound keys."),
('auto', "Forward unbound non-alphanumeric "
"keys."),
('none', "Don't forward any keys."))
class CloseButton(BaseType):
"""Mouse button used to close tabs."""
special = True
def __init__(self):
self.valid_values = \
ValidValues(('right', "Close tabs on right-click."),
('middle', "Close tabs on middle-click."),
('none', "Don't close tabs using the mouse."))
class NewTabPosition(BaseType):
"""How new tabs are positioned."""
@ -1511,11 +1439,11 @@ class NewTabPosition(BaseType):
special = True
def __init__(self):
self.valid_values = \
ValidValues(('left', "On the left of the current tab."),
('right', "On the right of the current tab."),
('first', "At the left end."),
('last', "At the right end."))
self.valid_values = ValidValues(
('left', "On the left of the current tab."),
('right', "On the right of the current tab."),
('first', "At the left end."),
('last', "At the right end."))
class IgnoreCase(Bool):
@ -1525,11 +1453,11 @@ class IgnoreCase(Bool):
special = True
def __init__(self):
self.valid_values = \
ValidValues(('true', "Search case-insensitively"),
('false', "Search case-sensitively"),
('smart', "Search case-sensitively if there "
"are capital chars"))
self.valid_values = ValidValues(
('true', "Search case-insensitively"),
('false', "Search case-sensitively"),
('smart', "Search case-sensitively if there "
"are capital chars"))
def transform(self, value):
if value.lower() == 'smart':
@ -1547,56 +1475,6 @@ class IgnoreCase(Bool):
super().validate(value)
class NewInstanceOpenTarget(BaseType):
"""How to open links in an existing instance if a new one is launched."""
special = True
def __init__(self):
self.valid_values = \
ValidValues(('tab', "Open a new tab in the existing "
"window and activate the window."),
('tab-bg', "Open a new background tab in the "
"existing window and activate the "
"window."),
('tab-silent', "Open a new tab in the existing "
"window without activating "
"the window."),
('tab-bg-silent', "Open a new background tab "
"in the existing window "
"without activating the "
"window."),
('window', "Open in a new window."))
class DownloadPathSuggestion(BaseType):
"""How to format the question when downloading."""
special = True
def __init__(self):
self.valid_values = \
ValidValues(('path', "Show only the download path."),
('filename', "Show only download filename."),
('both', "Show download path and filename."))
class Referer(BaseType):
"""Send the Referer header."""
def __init__(self):
self.valid_values = \
ValidValues(('always', "Always send."),
('never', "Never send; this is not recommended,"
" as some sites may break."),
('same-domain', "Only send for the same domain."
" This will still protect your privacy, but"
" shouldn't break any sites."))
class UserAgent(BaseType):
"""The user agent to use."""
@ -1660,29 +1538,6 @@ class UserAgent(BaseType):
return out
class TabBarShow(BaseType):
"""When to show the tab bar."""
def __init__(self):
self.valid_values = \
ValidValues(('always', "Always show the tab bar."),
('never', "Always hide the tab bar."),
('multiple', "Hide the tab bar if only one tab "
"is open."),
('switching', "Show the tab bar when switching "
"tabs."))
class URLSegmentList(FlagList):
"""A list of URL segments."""
def __init__(self, none_ok=False):
super().__init__(none_ok)
self.valid_values = ValidValues('host', 'path', 'query', 'anchor')
class TimestampTemplate(BaseType):
"""A strftime-like template for timestamps.