Add webkit settings to config
This commit is contained in:
parent
91e6f4c37d
commit
4c751d8081
@ -137,6 +137,7 @@ class QuteBrowser(QApplication):
|
|||||||
self.mainwindow.completion.on_config_changed)
|
self.mainwindow.completion.on_config_changed)
|
||||||
self.config.changed.connect(self.mainwindow.on_config_changed)
|
self.config.changed.connect(self.mainwindow.on_config_changed)
|
||||||
self.config.changed.connect(config.cmd_history.on_config_changed)
|
self.config.changed.connect(config.cmd_history.on_config_changed)
|
||||||
|
self.config.changed.connect(config.qwebsetting_on_config_changed)
|
||||||
|
|
||||||
self.mainwindow.show()
|
self.mainwindow.show()
|
||||||
self._python_hacks()
|
self._python_hacks()
|
||||||
|
@ -31,6 +31,7 @@ from configparser import ConfigParser, ExtendedInterpolation
|
|||||||
from collections.abc import MutableMapping
|
from collections.abc import MutableMapping
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject
|
from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject
|
||||||
|
from PyQt5.QtWebKit import QWebSettings
|
||||||
|
|
||||||
#from qutebrowser.utils.misc import read_file
|
#from qutebrowser.utils.misc import read_file
|
||||||
import qutebrowser.config.configdata as configdata
|
import qutebrowser.config.configdata as configdata
|
||||||
@ -43,6 +44,40 @@ state = None
|
|||||||
cmd_history = None
|
cmd_history = None
|
||||||
|
|
||||||
|
|
||||||
|
WEBSETTINGS_MAPPING = {
|
||||||
|
'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':
|
||||||
|
QWebSettings.OfflineStorageDatabaseEnabled,
|
||||||
|
'offline_web_application_storage_enabled':
|
||||||
|
QWebSettings.OfflineWebApplicationCacheEnabled,
|
||||||
|
'local_storage_enabled': QWebSettings.LocalStorageEnabled,
|
||||||
|
'local_content_can_access_remote_urls':
|
||||||
|
QWebSettings.LocalContentCanAccessRemoteUrls,
|
||||||
|
'local_content_can_access_file_urls':
|
||||||
|
QWebSettings.LocalContentCanAccessFileUrls,
|
||||||
|
'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,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class NoSectionError(configparser.NoSectionError):
|
class NoSectionError(configparser.NoSectionError):
|
||||||
|
|
||||||
"""Exception raised when a section was not found."""
|
"""Exception raised when a section was not found."""
|
||||||
@ -71,6 +106,21 @@ def init(configdir):
|
|||||||
state = ReadWriteConfigParser(configdir, 'state')
|
state = ReadWriteConfigParser(configdir, 'state')
|
||||||
cmd_history = LineConfigParser(configdir, 'cmd_history',
|
cmd_history = LineConfigParser(configdir, 'cmd_history',
|
||||||
('general', 'cmd_histlen'))
|
('general', 'cmd_histlen'))
|
||||||
|
init_qwebsettings()
|
||||||
|
|
||||||
|
def init_qwebsettings():
|
||||||
|
"""Initialize the global QWebSettings."""
|
||||||
|
settings = QWebSettings.globalSettings()
|
||||||
|
for name, item in WEBSETTINGS_MAPPING.items():
|
||||||
|
settings.setAttribute(item, config.get('webkit', name))
|
||||||
|
|
||||||
|
|
||||||
|
@pyqtSlot(str, str, object)
|
||||||
|
def qwebsetting_on_config_changed(section, option, value):
|
||||||
|
"""Update global settings when qwebsettings changed."""
|
||||||
|
if section == 'webkit':
|
||||||
|
settings = QWebSettings.globalSettings()
|
||||||
|
settings.setAttribute(WEBSETTINGS_MAPPING[option], value)
|
||||||
|
|
||||||
|
|
||||||
class Config(QObject):
|
class Config(QObject):
|
||||||
|
@ -48,6 +48,7 @@ FIRST_COMMENT = """
|
|||||||
SECTION_DESC = {
|
SECTION_DESC = {
|
||||||
'general': 'General/misc. options',
|
'general': 'General/misc. options',
|
||||||
'tabbar': 'Configuration of the tab bar.',
|
'tabbar': 'Configuration of the tab bar.',
|
||||||
|
'webkit': 'Webkit settings.',
|
||||||
'searchengines': (
|
'searchengines': (
|
||||||
'Definitions of search engines which can be used via the address '
|
'Definitions of search engines which can be used via the address '
|
||||||
'bar.\n'
|
'bar.\n'
|
||||||
@ -172,6 +173,135 @@ def configdata():
|
|||||||
"Behaviour when the last tab is closed."),
|
"Behaviour when the last tab is closed."),
|
||||||
)),
|
)),
|
||||||
|
|
||||||
|
('webkit', sect.KeyValue(
|
||||||
|
('auto_load_images',
|
||||||
|
SettingValue(types.Bool, "true"),
|
||||||
|
"Specifies whether images are automatically loaded in web "
|
||||||
|
"pages."),
|
||||||
|
|
||||||
|
('dns_prefetch_enabled',
|
||||||
|
SettingValue(types.Bool, "false"),
|
||||||
|
"Specifies whether QtWebkit will try to pre-fetch DNS entries to "
|
||||||
|
"speed up browsing."),
|
||||||
|
|
||||||
|
('javascript_enabled',
|
||||||
|
SettingValue(types.Bool, "true"),
|
||||||
|
"Enables or disables the running of JavaScript programs."),
|
||||||
|
|
||||||
|
#('java_enabled',
|
||||||
|
# SettingValue(types.Bool, "true"),
|
||||||
|
# "Enables or disables Java applets. Currently Java applets are "
|
||||||
|
# "not supported"),
|
||||||
|
|
||||||
|
('plugins_enabled',
|
||||||
|
SettingValue(types.Bool, "false"),
|
||||||
|
"Enables or disables plugins in Web pages"),
|
||||||
|
|
||||||
|
('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',
|
||||||
|
SettingValue(types.Bool, "false"),
|
||||||
|
"Specifies whether JavaScript programs can open new windows."),
|
||||||
|
|
||||||
|
('javascript_can_close_windows',
|
||||||
|
SettingValue(types.Bool, "false"),
|
||||||
|
"Specifies whether JavaScript programs can close windows."),
|
||||||
|
|
||||||
|
('javascript_can_access_clipboard',
|
||||||
|
SettingValue(types.Bool, "false"),
|
||||||
|
"Specifies whether JavaScript programs can read or write to the "
|
||||||
|
"clipboard."),
|
||||||
|
|
||||||
|
('developer_extras_enabled',
|
||||||
|
SettingValue(types.Bool, "false"),
|
||||||
|
"Enables extra tools for Web developers (e.g. webinspector)"),
|
||||||
|
|
||||||
|
('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',
|
||||||
|
SettingValue(types.Bool, "true"),
|
||||||
|
"Specifies whether hyperlinks should be included in the keyboard "
|
||||||
|
"focus chain."),
|
||||||
|
|
||||||
|
('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',
|
||||||
|
SettingValue(types.Bool, "true"),
|
||||||
|
"Specifies whether the background color and images are also "
|
||||||
|
"drawn when the page is printed. "),
|
||||||
|
|
||||||
|
('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',
|
||||||
|
SettingValue(types.Bool, "false"),
|
||||||
|
"Specifies whether support for the HTML 5 web application cache "
|
||||||
|
"feature is enabled or not. "),
|
||||||
|
|
||||||
|
('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',
|
||||||
|
SettingValue(types.Bool, "false"),
|
||||||
|
"Specifies whether locally loaded documents are allowed to "
|
||||||
|
"access remote 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',
|
||||||
|
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',
|
||||||
|
# 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',
|
||||||
|
# SettingValue(types.Bool, "false"),
|
||||||
|
# "This setting enables the tiled backing store feature for a "
|
||||||
|
# "QGraphicsWebView. With the tiled backing store enabled, the web "
|
||||||
|
# "page contents in and around the current visible area is "
|
||||||
|
# "speculatively cached to bitmap tiles. The tiles are "
|
||||||
|
# "automatically kept in sync with the web page as it changes. "
|
||||||
|
# "Enabling tiling can significantly speed up painting heavy "
|
||||||
|
# "operations like scrolling. Enabling the feature increases "
|
||||||
|
# "memory consumption. "),
|
||||||
|
|
||||||
|
('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',
|
||||||
|
SettingValue(types.Bool, "true"),
|
||||||
|
"This setting enables WebKit's workaround for broken sites."),
|
||||||
|
)),
|
||||||
|
|
||||||
('searchengines', sect.ValueList(
|
('searchengines', sect.ValueList(
|
||||||
types.SearchEngineName, types.SearchEngineUrl,
|
types.SearchEngineName, types.SearchEngineUrl,
|
||||||
('DEFAULT', '${duckduckgo}'),
|
('DEFAULT', '${duckduckgo}'),
|
||||||
|
Loading…
Reference in New Issue
Block a user