UI/UserInterface.py

changeset 2101
5bac7dee9e1a
parent 2094
88620e11c67c
child 2114
c07f0cb40b18
equal deleted inserted replaced
2100:fb16f4650860 2101:5bac7dee9e1a
12 import logging 12 import logging
13 13
14 from PyQt4.QtCore import QTimer, QFile, QFileInfo, pyqtSignal, PYQT_VERSION_STR, QDate, \ 14 from PyQt4.QtCore import QTimer, QFile, QFileInfo, pyqtSignal, PYQT_VERSION_STR, QDate, \
15 QIODevice, QByteArray, qVersion, QProcess, QSize, QUrl, QObject, Qt 15 QIODevice, QByteArray, qVersion, QProcess, QSize, QUrl, QObject, Qt
16 from PyQt4.QtGui import QSizePolicy, QWidget, QKeySequence, QDesktopServices, \ 16 from PyQt4.QtGui import QSizePolicy, QWidget, QKeySequence, QDesktopServices, \
17 QWhatsThis, QToolBar, QDialog, QSplitter, QApplication, QMenu, QStyleFactory, \ 17 QWhatsThis, QToolBar, QDialog, QSplitter, QApplication, QMenu, QProgressDialog, \
18 QMainWindow, QProgressDialog, QVBoxLayout, QDockWidget, QAction, QLabel 18 QVBoxLayout, QDockWidget, QAction, QLabel
19 from PyQt4.Qsci import QSCINTILLA_VERSION_STR 19 from PyQt4.Qsci import QSCINTILLA_VERSION_STR
20 from PyQt4.QtNetwork import QNetworkProxyFactory, QNetworkAccessManager, \ 20 from PyQt4.QtNetwork import QNetworkProxyFactory, QNetworkAccessManager, \
21 QNetworkRequest, QNetworkReply 21 QNetworkRequest, QNetworkReply
22 try: 22 try:
23 from PyQt4.QtNetwork import QSslError # __IGNORE_EXCEPTION__ __IGNORE_WARNING__ 23 from PyQt4.QtNetwork import QSslError # __IGNORE_EXCEPTION__ __IGNORE_WARNING__
85 from E5Gui.E5SqueezeLabels import E5SqueezeLabelPath 85 from E5Gui.E5SqueezeLabels import E5SqueezeLabelPath
86 from E5Gui.E5ToolBox import E5VerticalToolBox, E5HorizontalToolBox 86 from E5Gui.E5ToolBox import E5VerticalToolBox, E5HorizontalToolBox
87 from E5Gui.E5SideBar import E5SideBar 87 from E5Gui.E5SideBar import E5SideBar
88 from E5Gui import E5MessageBox, E5FileDialog 88 from E5Gui import E5MessageBox, E5FileDialog
89 from E5Gui.E5Application import e5App 89 from E5Gui.E5Application import e5App
90 from E5Gui.E5MainWindow import E5MainWindow
90 91
91 from VCS.StatusMonitorLed import StatusMonitorLed 92 from VCS.StatusMonitorLed import StatusMonitorLed
92 93
93 import Preferences 94 import Preferences
94 import ViewManager 95 import ViewManager
168 """ 169 """
169 self.buffer += str(s) 170 self.buffer += str(s)
170 self.__nWrite(self.__bufferedWrite()) 171 self.__nWrite(self.__bufferedWrite())
171 172
172 173
173 class UserInterface(QMainWindow): 174 class UserInterface(E5MainWindow):
174 """ 175 """
175 Class implementing the main user interface. 176 Class implementing the main user interface.
176 177
177 @signal appendStderr(str) emitted to write data to stderr logger 178 @signal appendStderr(str) emitted to write data to stderr logger
178 @signal appendStdout(str) emitted to write data to stdout logger 179 @signal appendStdout(str) emitted to write data to stdout logger
210 super().__init__() 211 super().__init__()
211 self.setAttribute(Qt.WA_DeleteOnClose) 212 self.setAttribute(Qt.WA_DeleteOnClose)
212 213
213 self.__restartArgs = restartArguments[:] 214 self.__restartArgs = restartArguments[:]
214 215
215 self.defaultStyleName = QApplication.style().objectName() 216 self.setStyle(Preferences.getUI("Style"), Preferences.getUI("StyleSheet"))
216 self.__setStyle()
217 217
218 self.maxEditorPathLen = Preferences.getUI("CaptionFilenameLength") 218 self.maxEditorPathLen = Preferences.getUI("CaptionFilenameLength")
219 self.locale = locale 219 self.locale = locale
220 self.__noOpenAtStartup = noOpenAtStartup 220 self.__noOpenAtStartup = noOpenAtStartup
221 221
570 SpellChecker.setDefaultLanguage( 570 SpellChecker.setDefaultLanguage(
571 Preferences.getEditor("SpellCheckingDefaultLanguage")) 571 Preferences.getEditor("SpellCheckingDefaultLanguage"))
572 572
573 # attribute for the last shown configuration page 573 # attribute for the last shown configuration page
574 self.__lastConfigurationPageName = "" 574 self.__lastConfigurationPageName = ""
575
576 def __setStyle(self):
577 """
578 Private slot to set the style of the interface.
579 """
580 # step 1: set the style
581 style = None
582 styleName = Preferences.getUI("Style")
583 if styleName != "System" and styleName in list(QStyleFactory.keys()):
584 style = QStyleFactory.create(styleName)
585 if style is None:
586 style = QStyleFactory.create(self.defaultStyleName)
587 if style is not None:
588 QApplication.setStyle(style)
589
590 # step 2: set a style sheet
591 styleSheetFile = Preferences.getUI("StyleSheet")
592 if styleSheetFile:
593 try:
594 f = open(styleSheetFile, "r", encoding="utf-8")
595 styleSheet = f.read()
596 f.close()
597 except IOError as msg:
598 E5MessageBox.warning(self,
599 self.trUtf8("Loading Style Sheet"),
600 self.trUtf8("""<p>The Qt Style Sheet file <b>{0}</b> could"""
601 """ not be read.<br>Reason: {1}</p>""")
602 .format(styleSheetFile, str(msg)))
603 return
604 else:
605 styleSheet = ""
606
607 e5App().setStyleSheet(styleSheet)
608 575
609 def __createLayout(self, debugServer): 576 def __createLayout(self, debugServer):
610 """ 577 """
611 Private method to create the layout of the various windows. 578 Private method to create the layout of the various windows.
612 579
4720 4687
4721 def __preferencesChanged(self): 4688 def __preferencesChanged(self):
4722 """ 4689 """
4723 Private slot to handle a change of the preferences. 4690 Private slot to handle a change of the preferences.
4724 """ 4691 """
4725 self.__setStyle() 4692 self.setStyle(Preferences.getUI("Style"), Preferences.getUI("StyleSheet"))
4726 4693
4727 if Preferences.getUI("SingleApplicationMode"): 4694 if Preferences.getUI("SingleApplicationMode"):
4728 if self.SAServer is None: 4695 if self.SAServer is None:
4729 self.SAServer = E5SingleApplicationServer() 4696 self.SAServer = E5SingleApplicationServer()
4730 else: 4697 else:

eric ide

mercurial