Fri, 04 Mar 2016 20:15:34 +0100
Continued porting the web browser.
- fixed the security page
- added the web browser appearance page
--- a/.hgignore Fri Mar 04 19:20:29 2016 +0100 +++ b/.hgignore Fri Mar 04 20:15:34 2016 +0100 @@ -16,3 +16,4 @@ glob:__pycache__ glob:**.DS_Store glob:**.coverage +glob:GPUCache
--- a/Preferences/ConfigurationDialog.py Fri Mar 04 19:20:29 2016 +0100 +++ b/Preferences/ConfigurationDialog.py Fri Mar 04 20:15:34 2016 +0100 @@ -392,7 +392,6 @@ pass elif displayMode == ConfigurationWidget.WebBrowserMode: - # TODO: Check config pages for QWebKit and add QWebEngine self.configItems = { # key : [display string, pixmap name, dialog module name or # page creation function, parent key, @@ -400,6 +399,9 @@ # The dialog module must have the module function 'create' to # create the configuration page. This must have the method # 'save' to save the settings. + "interfacePage": + [self.tr("Interface"), "preferences-interface.png", + "HelpInterfacePage", None, None], "networkPage": [self.tr("Network"), "preferences-network.png", "NetworkPage", None, None], @@ -410,6 +412,15 @@ [self.tr("Security"), "preferences-security.png", "SecurityPage", None, None], + # TODO: QtHelp +## "helpDocumentationPage": +## [self.tr("Help Documentation"), +## "preferences-helpdocumentation.png", +## "HelpDocumentationPage", None, None], + + "webBrowserAppearancePage": + [self.tr("Appearance"), "preferences-styles.png", + "WebBrowserAppearancePage", None, None], "helpFlashCookieManagerPage": [self.tr("Flash Cookie Manager"), "flashCookie16.png",
--- a/Preferences/ConfigurationPages/SecurityPage.py Fri Mar 04 19:20:29 2016 +0100 +++ b/Preferences/ConfigurationPages/SecurityPage.py Fri Mar 04 20:15:34 2016 +0100 @@ -11,10 +11,6 @@ from PyQt5.QtCore import pyqtSlot from PyQt5.QtWidgets import QDialog -try: - from PyQt5.QtWebKit import QWebSettings -except ImportError: - QWebSettings = None from .ConfigurationPageBase import ConfigurationPageBase from .Ui_SecurityPage import Ui_SecurityPage @@ -38,6 +34,7 @@ self.setObjectName("SecurityPage") self.__configDlg = configDialog + self.__displayMode = None # set initial values self.savePasswordsCheckBox.setChecked( @@ -46,15 +43,41 @@ Preferences.getUser("UseMasterPassword")) self.masterPasswordButton.setEnabled( Preferences.getUser("UseMasterPassword")) - if QWebSettings and hasattr(QWebSettings, "DnsPrefetchEnabled"): - self.dnsPrefetchCheckBox.setChecked( - Preferences.getHelp("DnsPrefetchEnabled")) - else: - self.dnsPrefetchCheckBox.setEnabled(False) self.__newPassword = "" self.__oldUseMasterPassword = Preferences.getUser("UseMasterPassword") + def setMode(self, displayMode): + """ + Public method to perform mode dependent setups. + + @param displayMode mode of the configuration dialog + (ConfigurationWidget.DefaultMode, + ConfigurationWidget.HelpBrowserMode, + ConfigurationWidget.WebBrowserMode) + """ + from ..ConfigurationDialog import ConfigurationWidget + assert displayMode in ( + ConfigurationWidget.DefaultMode, + ConfigurationWidget.HelpBrowserMode, + ConfigurationWidget.WebBrowserMode + ) + + self.__displayMode = displayMode + if self.__displayMode == ConfigurationWidget.HelpBrowserMode: + try: + from PyQt5.QtWebKit import QWebSettings + if QWebSettings and \ + hasattr(QWebSettings, "DnsPrefetchEnabled"): + self.dnsPrefetchCheckBox.setChecked( + Preferences.getHelp("DnsPrefetchEnabled")) + except ImportError: + self.dnsPrefetchCheckBox.setEnabled(False) + # TODO: add config for default Mode + else: + self.dnsPrefetchCheckBox.setEnabled(False) + self.dnsGroup.hide() + def save(self): """ Public slot to save the Help Viewers configuration.
--- a/Preferences/ConfigurationPages/SecurityPage.ui Fri Mar 04 19:20:29 2016 +0100 +++ b/Preferences/ConfigurationPages/SecurityPage.ui Fri Mar 04 20:15:34 2016 +0100 @@ -91,7 +91,7 @@ </widget> </item> <item> - <widget class="QGroupBox" name="groupBox_3"> + <widget class="QGroupBox" name="dnsGroup"> <property name="title"> <string>DNS</string> </property>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Preferences/ConfigurationPages/WebBrowserAppearancePage.py Fri Mar 04 20:15:34 2016 +0100 @@ -0,0 +1,146 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2006 - 2016 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Module implementing the Web Browser configuration page. +""" + +from __future__ import unicode_literals + +from PyQt5.QtCore import pyqtSlot +from PyQt5.QtWidgets import QFontDialog + +from E5Gui.E5PathPicker import E5PathPickerModes + +from .ConfigurationPageBase import ConfigurationPageBase +from .Ui_WebBrowserAppearancePage import Ui_WebBrowserAppearancePage + +import Preferences + +try: + MonospacedFontsOption = QFontDialog.MonospacedFonts +except AttributeError: + MonospacedFontsOption = QFontDialog.FontDialogOptions(0x10) + + +class WebBrowserAppearancePage(ConfigurationPageBase, + Ui_WebBrowserAppearancePage): + """ + Class implementing the Web Browser Appearance page. + """ + def __init__(self): + """ + Constructor + """ + super(WebBrowserAppearancePage, self).__init__() + self.setupUi(self) + self.setObjectName("WebBrowserAppearancePage") + + self.styleSheetPicker.setMode(E5PathPickerModes.OpenFileMode) + self.styleSheetPicker.setFilters(self.tr( + "Cascading Style Sheets (*.css);;All files (*)")) + + self.__displayMode = None + + # set initial values + self.standardFont = Preferences.getWebBrowser("StandardFont") + self.standardFontSample.setFont(self.standardFont) + self.standardFontSample.setText( + "{0} {1}".format(self.standardFont.family(), + self.standardFont.pointSize())) + + self.fixedFont = Preferences.getWebBrowser("FixedFont") + self.fixedFontSample.setFont(self.fixedFont) + self.fixedFontSample.setText( + "{0} {1}".format(self.fixedFont.family(), + self.fixedFont.pointSize())) + + self.initColour("SaveUrlColor", self.secureURLsColourButton, + Preferences.getWebBrowser) + + self.autoLoadImagesCheckBox.setChecked( + Preferences.getWebBrowser("AutoLoadImages")) + + self.styleSheetPicker.setText( + Preferences.getWebBrowser("UserStyleSheet")) + + self.tabsCloseButtonCheckBox.setChecked( + Preferences.getUI("SingleCloseButton")) + self.warnOnMultipleCloseCheckBox.setChecked( + Preferences.getWebBrowser("WarnOnMultipleClose")) + + def setMode(self, displayMode): + """ + Public method to perform mode dependent setups. + + @param displayMode mode of the configuration dialog + (ConfigurationWidget.DefaultMode, + ConfigurationWidget.HelpBrowserMode, + ConfigurationWidget.TrayStarterMode) + """ + from ..ConfigurationDialog import ConfigurationWidget + assert displayMode in ( + ConfigurationWidget.DefaultMode, + ConfigurationWidget.WebBrowserMode, + ) + + self.__displayMode = displayMode + if self.__displayMode != ConfigurationWidget.WebBrowserMode: + self.tabsGroupBox.hide() + + def save(self): + """ + Public slot to save the Help Viewers configuration. + """ + Preferences.setWebBrowser("StandardFont", self.standardFont) + Preferences.setWebBrowser("FixedFont", self.fixedFont) + + Preferences.setWebBrowser( + "AutoLoadImages", + self.autoLoadImagesCheckBox.isChecked()) + + Preferences.setWebBrowser( + "UserStyleSheet", + self.styleSheetPicker.text()) + + self.saveColours(Preferences.setWebBrowser) + + from ..ConfigurationDialog import ConfigurationWidget + if self.__displayMode == ConfigurationWidget.WebBrowserMode: + Preferences.setUI( + "SingleCloseButton", + self.tabsCloseButtonCheckBox.isChecked()) + + Preferences.setWebBrowser( + "WarnOnMultipleClose", + self.warnOnMultipleCloseCheckBox.isChecked()) + + @pyqtSlot() + def on_standardFontButton_clicked(self): + """ + Private method used to select the standard font. + """ + self.standardFont = \ + self.selectFont(self.standardFontSample, self.standardFont, True) + + @pyqtSlot() + def on_fixedFontButton_clicked(self): + """ + Private method used to select the fixed-width font. + """ + self.fixedFont = self.selectFont( + self.fixedFontSample, self.fixedFont, True, + options=MonospacedFontsOption) + + +def create(dlg): + """ + Module function to create the configuration page. + + @param dlg reference to the configuration dialog + @return reference to the instantiated page (ConfigurationPageBase) + """ + page = WebBrowserAppearancePage() + return page
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Preferences/ConfigurationPages/WebBrowserAppearancePage.ui Fri Mar 04 20:15:34 2016 +0100 @@ -0,0 +1,251 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>WebBrowserAppearancePage</class> + <widget class="QWidget" name="WebBrowserAppearancePage"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>499</width> + <height>547</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <widget class="QLabel" name="headerLabel"> + <property name="text"> + <string><b>Configure Web Browser appearance</b></string> + </property> + </widget> + </item> + <item> + <widget class="Line" name="line17"> + <property name="frameShape"> + <enum>QFrame::HLine</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Sunken</enum> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_5"> + <property name="title"> + <string>Fonts</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QPushButton" name="standardFontButton"> + <property name="toolTip"> + <string>Press to select the standard font</string> + </property> + <property name="text"> + <string>Standard Font</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="standardFontSample"> + <property name="focusPolicy"> + <enum>Qt::NoFocus</enum> + </property> + <property name="text"> + <string>Times 16</string> + </property> + <property name="alignment"> + <set>Qt::AlignHCenter</set> + </property> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QPushButton" name="fixedFontButton"> + <property name="toolTip"> + <string>Press to select the fixed-width font</string> + </property> + <property name="text"> + <string>Fixed-Width Font</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="fixedFontSample"> + <property name="focusPolicy"> + <enum>Qt::NoFocus</enum> + </property> + <property name="text"> + <string>Courier 13</string> + </property> + <property name="alignment"> + <set>Qt::AlignHCenter</set> + </property> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_3"> + <property name="title"> + <string>Colours</string> + </property> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="0" column="0"> + <widget class="QLabel" name="textLabel1_3"> + <property name="text"> + <string>Background colour of secure URLs:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QPushButton" name="secureURLsColourButton"> + <property name="minimumSize"> + <size> + <width>100</width> + <height>0</height> + </size> + </property> + <property name="toolTip"> + <string>Select the background colour for secure URLs.</string> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item row="0" column="2"> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>141</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>Images</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QCheckBox" name="autoLoadImagesCheckBox"> + <property name="toolTip"> + <string>Select to load images</string> + </property> + <property name="text"> + <string>Load images</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_2"> + <property name="title"> + <string>Style Sheet</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>User Style Sheet:</string> + </property> + </widget> + </item> + <item> + <widget class="E5PathPicker" name="styleSheetPicker" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="focusPolicy"> + <enum>Qt::StrongFocus</enum> + </property> + <property name="toolTip"> + <string>Enter the file name of a user style sheet</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="tabsGroupBox"> + <property name="title"> + <string>Tabs</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QCheckBox" name="tabsCloseButtonCheckBox"> + <property name="text"> + <string>Show only one close button instead of one for each tab</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="warnOnMultipleCloseCheckBox"> + <property name="toolTip"> + <string>Select to issue a warning, if multiple tabs are about to be closed</string> + </property> + <property name="text"> + <string>Warn, if multiple tabs are about to be closed</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <spacer> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>479</width> + <height>121</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>E5PathPicker</class> + <extends>QWidget</extends> + <header>E5Gui/E5PathPicker.h</header> + <container>1</container> + </customwidget> + </customwidgets> + <tabstops> + <tabstop>standardFontButton</tabstop> + <tabstop>fixedFontButton</tabstop> + <tabstop>secureURLsColourButton</tabstop> + <tabstop>autoLoadImagesCheckBox</tabstop> + <tabstop>styleSheetPicker</tabstop> + <tabstop>tabsCloseButtonCheckBox</tabstop> + <tabstop>warnOnMultipleCloseCheckBox</tabstop> + </tabstops> + <resources/> + <connections/> +</ui>
--- a/Preferences/__init__.py Fri Mar 04 19:20:29 2016 +0100 +++ b/Preferences/__init__.py Fri Mar 04 20:15:34 2016 +0100 @@ -2774,7 +2774,7 @@ return int(prefClass.settings.value( "WebBrowser/" + key, prefClass.webBrowserDefaults[key])) ## elif key in ["DiskCacheEnabled", "FilterTrackingCookies", -## "PrintBackgrounds", "AdBlockEnabled", "AutoLoadImages", +## "PrintBackgrounds", "AdBlockEnabled" ## "JavaEnabled", ## "JavaScriptCanCloseWindows", ## "PluginsEnabled", "DnsPrefetchEnabled",
--- a/eric6.e4p Fri Mar 04 19:20:29 2016 +0100 +++ b/eric6.e4p Fri Mar 04 20:15:34 2016 +0100 @@ -822,6 +822,7 @@ <Source>Preferences/ConfigurationPages/TrayStarterPage.py</Source> <Source>Preferences/ConfigurationPages/VcsPage.py</Source> <Source>Preferences/ConfigurationPages/ViewmanagerPage.py</Source> + <Source>Preferences/ConfigurationPages/WebBrowserAppearancePage.py</Source> <Source>Preferences/ConfigurationPages/__init__.py</Source> <Source>Preferences/MouseClickDialog.py</Source> <Source>Preferences/PreferencesLexer.py</Source> @@ -1751,6 +1752,7 @@ <Form>Preferences/ConfigurationPages/TrayStarterPage.ui</Form> <Form>Preferences/ConfigurationPages/VcsPage.ui</Form> <Form>Preferences/ConfigurationPages/ViewmanagerPage.ui</Form> + <Form>Preferences/ConfigurationPages/WebBrowserAppearancePage.ui</Form> <Form>Preferences/MouseClickDialog.ui</Form> <Form>Preferences/ProgramsDialog.ui</Form> <Form>Preferences/ShortcutDialog.ui</Form>