def init(): """Initialize the global QWebSettings.""" cache_path = standarddir.cache() data_path = standarddir.data() QWebSettings.setIconDatabasePath(standarddir.cache()) QWebSettings.setOfflineWebApplicationCachePath( os.path.join(cache_path, 'application-cache')) QWebSettings.globalSettings().setLocalStoragePath( os.path.join(data_path, 'local-storage')) QWebSettings.setOfflineStoragePath( os.path.join(data_path, 'offline-storage')) settings = QWebSettings.globalSettings() _set_user_stylesheet(settings) _set_cookie_accept_policy(settings) _set_cache_maximum_pages(settings) _init_user_agent() config.instance.changed.connect(_update_settings) global global_settings global_settings = WebKitSettings(QWebSettings.globalSettings()) global_settings.init_settings()
def init(): """Initialize the global QWebSettings.""" cache_path = standarddir.cache() data_path = standarddir.data() if config.get('general', 'private-browsing') or cache_path is None: QWebSettings.setIconDatabasePath('') else: QWebSettings.setIconDatabasePath(cache_path) if cache_path is not None: QWebSettings.setOfflineWebApplicationCachePath( os.path.join(cache_path, 'application-cache')) if data_path is not None: QWebSettings.globalSettings().setLocalStoragePath( os.path.join(data_path, 'local-storage')) QWebSettings.setOfflineStoragePath( os.path.join(data_path, 'offline-storage')) for sectname, section in MAPPINGS.items(): for optname, mapping in section.items(): default = mapping.save_default() log.config.vdebug("Saved default for {} -> {}: {!r}".format( sectname, optname, default)) value = config.get(sectname, optname) log.config.vdebug("Setting {} -> {} to {!r}".format( sectname, optname, value)) mapping.set(value) objreg.get('config').changed.connect(update_settings)
def __init__(self): self.debug = 1 self.app = QApplication([]) self.desktop = QApplication.desktop() self.web = QWebView() self.icon = QIcon(ICON) QWebSettings.setIconDatabasePath(DATA_DIR)
def _shutdown(self, status, restart): """Second stage of shutdown.""" log.destroy.debug("Stage 2 of shutting down...") if qApp is None: # No QApplication exists yet, so quit hard. sys.exit(status) # Remove eventfilter try: log.destroy.debug("Removing eventfilter...") qApp.removeEventFilter(objreg.get('event-filter')) except AttributeError: pass # Close all windows QApplication.closeAllWindows() # Shut down IPC try: objreg.get('ipc-server').shutdown() except KeyError: pass # Save everything try: save_manager = objreg.get('save-manager') except KeyError: log.destroy.debug("Save manager not initialized yet, so not " "saving anything.") else: for key in save_manager.saveables: try: save_manager.save(key, is_exit=True) except OSError as e: error.handle_fatal_exc( e, self._args, "Error while saving!", pre_text="Error while saving {}".format(key)) # Disable storage so removing tempdir will work QWebSettings.setIconDatabasePath('') QWebSettings.setOfflineWebApplicationCachePath('') QWebSettings.globalSettings().setLocalStoragePath('') # Re-enable faulthandler to stdout, then remove crash log log.destroy.debug("Deactivating crash log...") objreg.get('crash-handler').destroy_crashlogfile() # Delete temp basedir if ((self._args.temp_basedir or self._args.temp_basedir_restarted) and not restart): atexit.register(shutil.rmtree, self._args.basedir, ignore_errors=True) # Delete temp download dir objreg.get('temporary-downloads').cleanup() # If we don't kill our custom handler here we might get segfaults log.destroy.debug("Deactivating message handler...") qInstallMessageHandler(None) # Now we can hopefully quit without segfaults log.destroy.debug("Deferring QApplication::exit...") objreg.get('signal-handler').deactivate() # We use a singleshot timer to exit here to minimize the likelihood of # segfaults. QTimer.singleShot(0, functools.partial(qApp.exit, status))
def _init_private_browsing(): if config.get('general', 'private-browsing'): if qtutils.is_qtwebkit_ng(qWebKitVersion()): message.warning("Private browsing is not fully implemented by " "QtWebKit-NG!") QWebSettings.setIconDatabasePath('') else: QWebSettings.setIconDatabasePath(standarddir.cache())
def update_settings(section, option): """Update global settings when qwebsettings changed.""" cache_path = standarddir.cache() if (section, option) == ('general', 'private-browsing'): if config.get('general', 'private-browsing') or cache_path is None: QWebSettings.setIconDatabasePath('') else: QWebSettings.setIconDatabasePath(cache_path) websettings.update_mappings(MAPPINGS, section, option)
def __init__(self): self.debug = 1 self.app = QApplication(sys.argv) self.desktop = QApplication.desktop() self.web = QWebView() self.icon = QIcon(ICON) QWebSettings.setIconDatabasePath(DATA_DIR) self.web.titleChanged.connect(self.title_changed) self.web.iconChanged.connect(self.icon_changed) self.web.page().windowCloseRequested.connect(self.close_window) self.web.page().geometryChangeRequested.connect(self.set_geometry)
def update_settings(section, option): """Update global settings when qwebsettings changed.""" if (section, option) == ('general', 'private-browsing'): cache_path = standarddir.cache() if config.get('general', 'private-browsing') or cache_path is None: QWebSettings.setIconDatabasePath('') else: QWebSettings.setIconDatabasePath(cache_path) elif section == 'ui' and option in ['hide-scrollbar', 'user-stylesheet']: _set_user_stylesheet() websettings.update_mappings(MAPPINGS, section, option)
def __init__(self): self.debug=1 self.app = QApplication(sys.argv) self.desktop= QApplication.desktop() self.web = QWebView() self.icon = QIcon(ICON) QWebSettings.setIconDatabasePath(DATA_DIR) self.web.setWindowIcon(self.icon) self.web.titleChanged.connect(self.title_changed) self.web.iconChanged.connect(self.icon_changed) self.web.page().windowCloseRequested.connect(self.close_window) self.web.page().geometryChangeRequested.connect(self.set_geometry)
def update_settings(section, option): """Update global settings when qwebsettings changed.""" if (section, option) == ('general', 'private-browsing'): if config.get('general', 'private-browsing'): QWebSettings.setIconDatabasePath('') else: QWebSettings.setIconDatabasePath(standarddir.cache()) else: try: mapping = MAPPINGS[section][option] except KeyError: return value = config.get(section, option) mapping.set(value)
def init(_args): """Initialize the global QWebSettings.""" cache_path = standarddir.cache() data_path = standarddir.data() QWebSettings.setIconDatabasePath(standarddir.cache()) QWebSettings.setOfflineWebApplicationCachePath( os.path.join(cache_path, 'application-cache')) QWebSettings.globalSettings().setLocalStoragePath( os.path.join(data_path, 'local-storage')) QWebSettings.setOfflineStoragePath( os.path.join(data_path, 'offline-storage')) websettings.init_mappings(MAPPINGS) _set_user_stylesheet() config.instance.changed.connect(_update_settings)
def init(): """Initialize the global QWebSettings.""" cachedir = standarddir.get(QStandardPaths.CacheLocation) QWebSettings.setIconDatabasePath(cachedir) QWebSettings.setOfflineWebApplicationCachePath( os.path.join(cachedir, 'application-cache')) datadir = standarddir.get(QStandardPaths.DataLocation) QWebSettings.globalSettings().setLocalStoragePath( os.path.join(datadir, 'local-storage')) QWebSettings.setOfflineStoragePath(os.path.join(datadir, 'offline-storage')) global settings settings = QWebSettings.globalSettings() for sectname, section in MAPPINGS.items(): for optname, (typ, arg) in section.items(): value = config.get(sectname, optname) _set_setting(typ, arg, value) objreg.get('config').changed.connect(update_settings)
def init(): """Initialize the global QWebSettings.""" cachedir = standarddir.get(QStandardPaths.CacheLocation) QWebSettings.setIconDatabasePath(cachedir) QWebSettings.setOfflineWebApplicationCachePath( os.path.join(cachedir, 'application-cache')) datadir = standarddir.get(QStandardPaths.DataLocation) QWebSettings.globalSettings().setLocalStoragePath( os.path.join(datadir, 'local-storage')) QWebSettings.setOfflineStoragePath( os.path.join(datadir, 'offline-storage')) global settings settings = QWebSettings.globalSettings() for sectname, section in MAPPINGS.items(): for optname, (typ, arg) in section.items(): value = config.get(sectname, optname) _set_setting(typ, arg, value) objreg.get('config').changed.connect(update_settings)
def init(): """Initialize the global QWebSettings.""" cache_path = standarddir.cache() data_path = standarddir.data() if config.get('general', 'private-browsing'): QWebSettings.setIconDatabasePath('') else: QWebSettings.setIconDatabasePath(cache_path) QWebSettings.setOfflineWebApplicationCachePath( os.path.join(cache_path, 'application-cache')) QWebSettings.globalSettings().setLocalStoragePath( os.path.join(data_path, 'local-storage')) QWebSettings.setOfflineStoragePath( os.path.join(data_path, 'offline-storage')) websettings.init_mappings(MAPPINGS) _set_user_stylesheet() objreg.get('config').changed.connect(update_settings)
def init(): """Initialize the global QWebSettings.""" cache_path = standarddir.cache() data_path = standarddir.data() if config.get('general', 'private-browsing') or cache_path is None: QWebSettings.setIconDatabasePath('') else: QWebSettings.setIconDatabasePath(cache_path) if cache_path is not None: QWebSettings.setOfflineWebApplicationCachePath( os.path.join(cache_path, 'application-cache')) if data_path is not None: QWebSettings.globalSettings().setLocalStoragePath( os.path.join(data_path, 'local-storage')) QWebSettings.setOfflineStoragePath( os.path.join(data_path, 'offline-storage')) websettings.init_mappings(MAPPINGS) objreg.get('config').changed.connect(update_settings)
def init(_args): """Initialize the global QWebSettings.""" cache_path = standarddir.cache() data_path = standarddir.data() QWebSettings.setIconDatabasePath(standarddir.cache()) QWebSettings.setOfflineWebApplicationCachePath( os.path.join(cache_path, 'application-cache')) QWebSettings.globalSettings().setLocalStoragePath( os.path.join(data_path, 'local-storage')) QWebSettings.setOfflineStoragePath( os.path.join(data_path, 'offline-storage')) settings = QWebSettings.globalSettings() _set_user_stylesheet(settings) _set_cookie_accept_policy(settings) _set_cache_maximum_pages(settings) config.instance.changed.connect(_update_settings) global global_settings global_settings = WebKitSettings(QWebSettings.globalSettings()) global_settings.init_settings()
def init(_args): """Initialize the global QWebSettings.""" cache_path = standarddir.cache() data_path = standarddir.data() QWebSettings.setIconDatabasePath(standarddir.cache()) QWebSettings.setOfflineWebApplicationCachePath( os.path.join(cache_path, 'application-cache')) QWebSettings.globalSettings().setLocalStoragePath( os.path.join(data_path, 'local-storage')) QWebSettings.setOfflineStoragePath( os.path.join(data_path, 'offline-storage')) if (config.get('general', 'private-browsing') and not qtutils.version_check('5.4.2')): # WORKAROUND for https://codereview.qt-project.org/#/c/108936/ # Won't work when private browsing is not enabled globally, but that's # the best we can do... QWebSettings.setIconDatabasePath('') websettings.init_mappings(MAPPINGS) _set_user_stylesheet() objreg.get('config').changed.connect(update_settings)
def shutdown(): """Disable storage so removing tmpdir will work.""" QWebSettings.setIconDatabasePath('') QWebSettings.setOfflineWebApplicationCachePath('') QWebSettings.globalSettings().setLocalStoragePath('')