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