Helpviewer/HelpWindow.py

changeset 2101
5bac7dee9e1a
parent 2100
fb16f4650860
child 2149
bd0bbb3043df
--- a/Helpviewer/HelpWindow.py	Wed Oct 03 20:07:50 2012 +0200
+++ b/Helpviewer/HelpWindow.py	Thu Oct 04 19:28:49 2012 +0200
@@ -11,10 +11,10 @@
 
 from PyQt4.QtCore import pyqtSlot, pyqtSignal, Qt, QByteArray, QSize, QTimer, QUrl, \
     QThread, QTextCodec
-from PyQt4.QtGui import QMainWindow, QWidget, QVBoxLayout, QSizePolicy, QDockWidget, \
+from PyQt4.QtGui import QWidget, QVBoxLayout, QSizePolicy, QDockWidget, \
     QDesktopServices, QKeySequence, QComboBox, QFont, QFontMetrics, QLabel, \
     QSplitter, QMenu, QToolButton, QLineEdit, QApplication, QWhatsThis, QDialog, \
-    QHBoxLayout, QProgressBar, QAction, QIcon, QStyleFactory
+    QHBoxLayout, QProgressBar, QAction, QIcon
 from PyQt4.QtNetwork import QNetworkAccessManager, QNetworkRequest
 from PyQt4.QtWebKit import QWebSettings, QWebDatabase, QWebSecurityOrigin, QWebPage
 from PyQt4.QtHelp import QHelpEngine, QHelpEngineCore, QHelpSearchQuery
@@ -65,7 +65,7 @@
 
 from E5Gui.E5Action import E5Action
 from E5Gui import E5MessageBox, E5FileDialog
-from E5Gui.E5Application import e5App
+from E5Gui.E5MainWindow import E5MainWindow
 
 from E5Network.E5NetworkMonitor import E5NetworkMonitor
 
@@ -80,7 +80,7 @@
 from UI.Info import Version
 
 
-class HelpWindow(QMainWindow):
+class HelpWindow(E5MainWindow):
     """
     Class implementing the web browser main window.
     
@@ -143,7 +143,7 @@
             self.__initActions()
         else:
             if not self.fromEric:
-                self.__setStyle()
+                self.setStyle(Preferences.getUI("Style"), Preferences.getUI("StyleSheet"))
             
             self.__helpEngine = \
                 QHelpEngine(os.path.join(Utilities.getConfigDir(),
@@ -2190,7 +2190,7 @@
         Public slot to handle a change of preferences.
         """
         if not self.fromEric:
-            self.__setStyle()
+            self.setStyle(Preferences.getUI("Style"), Preferences.getUI("StyleSheet"))
         
         self.__initWebSettings()
         
@@ -3279,36 +3279,3 @@
         dataString = "data:text/css;charset=utf-8;base64,{0}".format(encodedStyle)
         
         return QUrl(dataString)
-    
-    def __setStyle(self):
-        """
-        Private slot to set the style of the interface.
-        """
-        # step 1: set the style
-        style = None
-        styleName = Preferences.getUI("Style")
-        if styleName != "System" and styleName in QStyleFactory.keys():
-            style = QStyleFactory.create(styleName)
-        if style is None:
-            style = QStyleFactory.create(self.defaultStyleName)
-        if style is not None:
-            QApplication.setStyle(style)
-        
-        # step 2: set a style sheet
-        styleSheetFile = Preferences.getUI("StyleSheet")
-        if styleSheetFile:
-            try:
-                f = open(styleSheetFile, "r", encoding="utf-8")
-                styleSheet = f.read()
-                f.close()
-            except IOError as msg:
-                E5MessageBox.warning(self,
-                    self.trUtf8("Loading Style Sheet"),
-                    self.trUtf8("""<p>The Qt Style Sheet file <b>{0}</b> could"""
-                                """ not be read.<br>Reason: {1}</p>""")
-                        .format(styleSheetFile, str(msg)))
-                return
-        else:
-            styleSheet = ""
-        
-        e5App().setStyleSheet(styleSheet)

eric ide

mercurial