Use NoneString config type for settings with Qt defaults.
This fixes wikipedia looking ugly because setUserStylesheet gets called with an empty string.
This commit is contained in:
parent
1a3ed11070
commit
f6c3e00d59
@ -72,7 +72,7 @@ class BrowserPage(QWebPage):
|
||||
def userAgentForUrl(self, url):
|
||||
"""Override QWebPage::userAgentForUrl to customize the user agent."""
|
||||
ua = config.get('network', 'user-agent')
|
||||
if not ua:
|
||||
if ua is None:
|
||||
return super().userAgentForUrl(url)
|
||||
else:
|
||||
return ua
|
||||
|
@ -165,6 +165,7 @@ class String(BaseType):
|
||||
self.forbidden = forbidden
|
||||
|
||||
def transform(self, value):
|
||||
# FIXME that .lower() probably isn't always a good idea...
|
||||
return value.lower()
|
||||
|
||||
def validate(self, value):
|
||||
@ -180,6 +181,16 @@ class String(BaseType):
|
||||
self.maxlen))
|
||||
|
||||
|
||||
class NoneString(String):
|
||||
|
||||
"""String which returns None if it's empty."""
|
||||
|
||||
def transform(self, value):
|
||||
if not value:
|
||||
return None
|
||||
return super().transform(value)
|
||||
|
||||
|
||||
class ShellCommand(String):
|
||||
|
||||
"""A shellcommand which is split via shlex.
|
||||
|
@ -203,11 +203,11 @@ DATA = OrderedDict([
|
||||
"Value to send in the DNT header."),
|
||||
|
||||
('accept-language',
|
||||
SettingValue(types.String(), 'en-US,en'),
|
||||
SettingValue(types.NoneString(), 'en-US,en'),
|
||||
"Value to send in the accept-language header."),
|
||||
|
||||
('user-agent',
|
||||
SettingValue(types.String(), ''),
|
||||
SettingValue(types.NoneString(), ''),
|
||||
"User agent to send. Empty to send the default."),
|
||||
|
||||
('accept-cookies',
|
||||
@ -422,51 +422,51 @@ DATA = OrderedDict([
|
||||
"User stylesheet to set."),
|
||||
|
||||
('css-media-type',
|
||||
SettingValue(types.String(), ''),
|
||||
SettingValue(types.NoneString(), ''),
|
||||
"Set the CSS media type."),
|
||||
|
||||
('default-encoding',
|
||||
SettingValue(types.String(), ''),
|
||||
SettingValue(types.NoneString(), ''),
|
||||
"Default encoding to use for websites."),
|
||||
|
||||
('font-family-standard',
|
||||
SettingValue(types.String(), ''),
|
||||
SettingValue(types.NoneString(), ''),
|
||||
"Font family for standard fonts."),
|
||||
|
||||
('font-family-fixed',
|
||||
SettingValue(types.String(), ''),
|
||||
SettingValue(types.NoneString(), ''),
|
||||
"Font family for fixed fonts."),
|
||||
|
||||
('font-family-serif',
|
||||
SettingValue(types.String(), ''),
|
||||
SettingValue(types.NoneString(), ''),
|
||||
"Font family for serif fonts."),
|
||||
|
||||
('font-family-sans-serif',
|
||||
SettingValue(types.String(), ''),
|
||||
SettingValue(types.NoneString(), ''),
|
||||
"Font family for sans-serif fonts."),
|
||||
|
||||
('font-family-cursive',
|
||||
SettingValue(types.String(), ''),
|
||||
SettingValue(types.NoneString(), ''),
|
||||
"Font family for cursive fonts."),
|
||||
|
||||
('font-family-fantasy',
|
||||
SettingValue(types.String(), ''),
|
||||
SettingValue(types.NoneString(), ''),
|
||||
"Font family for fantasy fonts."),
|
||||
|
||||
('font-size-minimum',
|
||||
SettingValue(types.String(), ''),
|
||||
SettingValue(types.NoneString(), ''),
|
||||
"The hard minimum font size."),
|
||||
|
||||
('font-size-minimum-logical',
|
||||
SettingValue(types.String(), ''),
|
||||
SettingValue(types.NoneString(), ''),
|
||||
"The minimum logical font size that is applied when zooming out."),
|
||||
|
||||
('font-size-default',
|
||||
SettingValue(types.String(), ''),
|
||||
SettingValue(types.NoneString(), ''),
|
||||
"The default font size for regular text."),
|
||||
|
||||
('font-size-default-fixed',
|
||||
SettingValue(types.String(), ''),
|
||||
SettingValue(types.NoneString(), ''),
|
||||
"The default font size for fixed-pitch text."),
|
||||
|
||||
('maximum-pages-in-cache',
|
||||
|
@ -72,8 +72,10 @@ class NetworkManager(QNetworkAccessManager):
|
||||
dnt = '0'.encode('ascii')
|
||||
req.setRawHeader('DNT'.encode('ascii'), dnt)
|
||||
req.setRawHeader('X-Do-Not-Track'.encode('ascii'), dnt)
|
||||
req.setRawHeader('Accept-Language'.encode('ascii'),
|
||||
config.get('network', 'accept-language'))
|
||||
accept_language = config.get('network', 'accept-language')
|
||||
if accept_language is not None:
|
||||
req.setRawHeader('Accept-Language'.encode('ascii'),
|
||||
accept_language.encode('ascii'))
|
||||
reply = super().createRequest(op, req, outgoing_data)
|
||||
self._requests[id(reply)] = reply
|
||||
reply.destroyed.connect(lambda obj: self._requests.pop(id(obj)))
|
||||
|
Loading…
Reference in New Issue
Block a user