UI/UserInterface.py

branch
Py2 comp.
changeset 2791
a9577f248f04
parent 2677
3d4277929fb3
parent 2770
fd5ee85f0450
child 2847
1843ef6e2656
equal deleted inserted replaced
2790:6686a3326df8 2791:a9577f248f04
30 from . import Config 30 from . import Config
31 31
32 from E5Gui.E5SingleApplication import E5SingleApplicationServer 32 from E5Gui.E5SingleApplication import E5SingleApplicationServer
33 from E5Gui.E5Action import E5Action, createActionGroup 33 from E5Gui.E5Action import E5Action, createActionGroup
34 from E5Gui.E5ToolBarManager import E5ToolBarManager 34 from E5Gui.E5ToolBarManager import E5ToolBarManager
35 from E5Gui import E5MessageBox, E5FileDialog 35 from E5Gui import E5MessageBox, E5FileDialog, E5ErrorMessage
36 from E5Gui.E5Application import e5App 36 from E5Gui.E5Application import e5App
37 from E5Gui.E5MainWindow import E5MainWindow 37 from E5Gui.E5MainWindow import E5MainWindow
38 from E5Gui.E5ZoomWidget import E5ZoomWidget 38 from E5Gui.E5ZoomWidget import E5ZoomWidget
39 39
40 import Preferences 40 import Preferences
387 self.viewmanager.lastEditorClosed.connect(self.__lastEditorClosed) 387 self.viewmanager.lastEditorClosed.connect(self.__lastEditorClosed)
388 self.viewmanager.editorOpened.connect(self.__editorOpened) 388 self.viewmanager.editorOpened.connect(self.__editorOpened)
389 self.viewmanager.changeCaption.connect(self.__setWindowCaption) 389 self.viewmanager.changeCaption.connect(self.__setWindowCaption)
390 self.viewmanager.checkActions.connect(self.__checkActions) 390 self.viewmanager.checkActions.connect(self.__checkActions)
391 self.viewmanager.editorChanged.connect(self.projectBrowser.handleEditorChanged) 391 self.viewmanager.editorChanged.connect(self.projectBrowser.handleEditorChanged)
392 self.viewmanager.editorLineChanged.connect(
393 self.projectBrowser.handleEditorLineChanged)
392 self.viewmanager.checkActions.connect(self.cooperation.checkEditorActions) 394 self.viewmanager.checkActions.connect(self.cooperation.checkEditorActions)
393 395
394 self.shell.zoomValueChanged.connect(self.viewmanager.zoomValueChanged) 396 self.shell.zoomValueChanged.connect(self.viewmanager.zoomValueChanged)
395 397
396 self.cooperation.shareEditor.connect(self.viewmanager.shareEditor) 398 self.cooperation.shareEditor.connect(self.viewmanager.shareEditor)
1886 """<p>Opens a dialog to manage the saved SSL certificates.</p>""" 1888 """<p>Opens a dialog to manage the saved SSL certificates.</p>"""
1887 )) 1889 ))
1888 self.certificatesAct.triggered[()].connect(self.__showCertificatesDialog) 1890 self.certificatesAct.triggered[()].connect(self.__showCertificatesDialog)
1889 self.actions.append(self.certificatesAct) 1891 self.actions.append(self.certificatesAct)
1890 1892
1893 self.editMessageFilterAct = E5Action(self.trUtf8('Edit Message Filters'),
1894 UI.PixmapCache.getIcon("warning.png"),
1895 self.trUtf8('Edit Message Filters...'), 0, 0, self,
1896 'manage_message_filters')
1897 self.editMessageFilterAct.setStatusTip(self.trUtf8(
1898 'Edit the message filters used to suppress unwanted messages'))
1899 self.editMessageFilterAct.setWhatsThis(self.trUtf8(
1900 """<b>Edit Message Filters</b>"""
1901 """<p>Opens a dialog to edit the message filters used to suppress"""
1902 """ unwanted messages been shown in an error window.</p>"""
1903 ))
1904 self.editMessageFilterAct.triggered[()].connect(E5ErrorMessage.editMessageFilters)
1905 self.actions.append(self.editMessageFilterAct)
1906
1891 self.viewmanagerActivateAct = E5Action(self.trUtf8('Activate current editor'), 1907 self.viewmanagerActivateAct = E5Action(self.trUtf8('Activate current editor'),
1892 self.trUtf8('Activate current editor'), 1908 self.trUtf8('Activate current editor'),
1893 QKeySequence(self.trUtf8("Alt+Shift+E")), 1909 QKeySequence(self.trUtf8("Alt+Shift+E")),
1894 0, self, 1910 0, self,
1895 'viewmanager_activate', 1) 1911 'viewmanager_activate', 1)
2007 )) 2023 ))
2008 self.qt5DocAct.triggered[()].connect(self.__showQt5Doc) 2024 self.qt5DocAct.triggered[()].connect(self.__showQt5Doc)
2009 self.actions.append(self.qt5DocAct) 2025 self.actions.append(self.qt5DocAct)
2010 2026
2011 self.pyqt4DocAct = E5Action(self.trUtf8('PyQt4 Documentation'), 2027 self.pyqt4DocAct = E5Action(self.trUtf8('PyQt4 Documentation'),
2012 self.trUtf8('P&yQt4 Documentation'), 0, 0, self, 'pyqt4_documentation') 2028 self.trUtf8('PyQt&4 Documentation'), 0, 0, self, 'pyqt4_documentation')
2013 self.pyqt4DocAct.setStatusTip(self.trUtf8('Open PyQt4 Documentation')) 2029 self.pyqt4DocAct.setStatusTip(self.trUtf8('Open PyQt4 Documentation'))
2014 self.pyqt4DocAct.setWhatsThis(self.trUtf8( 2030 self.pyqt4DocAct.setWhatsThis(self.trUtf8(
2015 """<b>PyQt4 Documentation</b>""" 2031 """<b>PyQt4 Documentation</b>"""
2016 """<p>Display the PyQt4 Documentation. Dependant upon your settings, this""" 2032 """<p>Display the PyQt4 Documentation. Dependant upon your settings, this"""
2017 """ will either show the help in Eric's internal help viewer, or execute""" 2033 """ will either show the help in Eric's internal help viewer, or execute"""
2018 """ a web browser or Qt Assistant. </p>""" 2034 """ a web browser or Qt Assistant. </p>"""
2019 )) 2035 ))
2020 self.pyqt4DocAct.triggered[()].connect(self.__showPyQt4Doc) 2036 self.pyqt4DocAct.triggered[()].connect(self.__showPyQt4Doc)
2021 self.actions.append(self.pyqt4DocAct) 2037 self.actions.append(self.pyqt4DocAct)
2038
2039 try:
2040 import PyQt5 # __IGNORE_WARNING__
2041 self.pyqt5DocAct = E5Action(self.trUtf8('PyQt5 Documentation'),
2042 self.trUtf8('PyQt&5 Documentation'), 0, 0, self, 'pyqt5_documentation')
2043 self.pyqt5DocAct.setStatusTip(self.trUtf8('Open PyQt5 Documentation'))
2044 self.pyqt5DocAct.setWhatsThis(self.trUtf8(
2045 """<b>PyQt5 Documentation</b>"""
2046 """<p>Display the PyQt5 Documentation. Dependant upon your settings,"""
2047 """ this will either show the help in Eric's internal help viewer,"""
2048 """ or execute a web browser or Qt Assistant. </p>"""
2049 ))
2050 self.pyqt5DocAct.triggered[()].connect(self.__showPyQt5Doc)
2051 self.actions.append(self.pyqt5DocAct)
2052 except ImportError:
2053 self.pyqt5DocAct = None
2022 2054
2023 def __initPythonDocActions(self): 2055 def __initPythonDocActions(self):
2024 """ 2056 """
2025 Private slot to initialize the actions to show the Python documentation. 2057 Private slot to initialize the actions to show the Python documentation.
2026 """ 2058 """
2174 self.__menus["settings"].addSeparator() 2206 self.__menus["settings"].addSeparator()
2175 self.__menus["settings"].addAction(self.showExternalToolsAct) 2207 self.__menus["settings"].addAction(self.showExternalToolsAct)
2176 if SSL_AVAILABLE: 2208 if SSL_AVAILABLE:
2177 self.__menus["settings"].addSeparator() 2209 self.__menus["settings"].addSeparator()
2178 self.__menus["settings"].addAction(self.certificatesAct) 2210 self.__menus["settings"].addAction(self.certificatesAct)
2211 self.__menus["settings"].addSeparator()
2212 self.__menus["settings"].addAction(self.editMessageFilterAct)
2179 2213
2180 self.__menus["window"] = QMenu(self.trUtf8('&Window'), self) 2214 self.__menus["window"] = QMenu(self.trUtf8('&Window'), self)
2181 mb.addMenu(self.__menus["window"]) 2215 mb.addMenu(self.__menus["window"])
2182 self.__menus["window"].setTearOffEnabled(True) 2216 self.__menus["window"].setTearOffEnabled(True)
2183 self.__menus["window"].aboutToShow.connect(self.__showWindowMenu) 2217 self.__menus["window"].aboutToShow.connect(self.__showWindowMenu)
2235 self.__menus["help"].addAction(self.pythonDocAct) 2269 self.__menus["help"].addAction(self.pythonDocAct)
2236 self.__menus["help"].addAction(self.python2DocAct) 2270 self.__menus["help"].addAction(self.python2DocAct)
2237 self.__menus["help"].addAction(self.qt4DocAct) 2271 self.__menus["help"].addAction(self.qt4DocAct)
2238 self.__menus["help"].addAction(self.qt5DocAct) 2272 self.__menus["help"].addAction(self.qt5DocAct)
2239 self.__menus["help"].addAction(self.pyqt4DocAct) 2273 self.__menus["help"].addAction(self.pyqt4DocAct)
2274 if self.pyqt5DocAct is not None:
2275 self.__menus["help"].addAction(self.pyqt5DocAct)
2240 if self.pysideDocAct is not None: 2276 if self.pysideDocAct is not None:
2241 self.__menus["help"].addAction(self.pysideDocAct) 2277 self.__menus["help"].addAction(self.pysideDocAct)
2242 self.__menus["help"].addSeparator() 2278 self.__menus["help"].addSeparator()
2243 self.__menus["help"].addAction(self.versionAct) 2279 self.__menus["help"].addAction(self.versionAct)
2244 self.__menus["help"].addSeparator() 2280 self.__menus["help"].addSeparator()
2580 """ 2616 """
2581 self.checkUpdateAct.setEnabled(not self.__inVersionCheck) 2617 self.checkUpdateAct.setEnabled(not self.__inVersionCheck)
2582 self.showVersionsAct.setEnabled(not self.__inVersionCheck) 2618 self.showVersionsAct.setEnabled(not self.__inVersionCheck)
2583 2619
2584 self.showMenu.emit("Help", self.__menus["help"]) 2620 self.showMenu.emit("Help", self.__menus["help"])
2621
2622 def __showSettingsMenu(self):
2623 """
2624 Private slot to show the Settings menu.
2625 """
2626 self.editMessageFilterAct.setEnabled(E5ErrorMessage.messageHandlerInstalled())
2627
2628 self.showMenu.emit("Settings", self.__menus["settings"])
2585 2629
2586 def __showNext(self): 2630 def __showNext(self):
2587 """ 2631 """
2588 Private slot used to show the next tab or file. 2632 Private slot used to show the next tab or file.
2589 """ 2633 """
4436 if pyqt4DocDir.startswith("file://"): 4480 if pyqt4DocDir.startswith("file://"):
4437 pyqt4DocDir = pyqt4DocDir[7:] 4481 pyqt4DocDir = pyqt4DocDir[7:]
4438 if not os.path.splitext(pyqt4DocDir)[1]: 4482 if not os.path.splitext(pyqt4DocDir)[1]:
4439 possibleHomes = [\ 4483 possibleHomes = [\
4440 Utilities.normjoinpath(pyqt4DocDir, 'index.html'), 4484 Utilities.normjoinpath(pyqt4DocDir, 'index.html'),
4441 Utilities.normjoinpath(pyqt4DocDir, 'pyqt4ref.html'),
4442 Utilities.normjoinpath(pyqt4DocDir, 'classes.html'), 4485 Utilities.normjoinpath(pyqt4DocDir, 'classes.html'),
4443 ] 4486 ]
4444 for possibleHome in possibleHomes: 4487 for possibleHome in possibleHomes:
4445 if os.path.exists(possibleHome): 4488 if os.path.exists(possibleHome):
4446 home = possibleHome 4489 home = possibleHome
4460 home = "file:///" + Utilities.fromNativeSeparators(home) 4503 home = "file:///" + Utilities.fromNativeSeparators(home)
4461 else: 4504 else:
4462 home = "file://" + home 4505 home = "file://" + home
4463 else: 4506 else:
4464 home = pyqt4DocDir 4507 home = pyqt4DocDir
4508
4509 hvType = Preferences.getHelp("HelpViewerType")
4510 if hvType == 1:
4511 self.launchHelpViewer(home)
4512 elif hvType == 2:
4513 self.__assistant(home, version=4)
4514 elif hvType == 3:
4515 self.__webBrowser(home)
4516 else:
4517 self.__customViewer(home)
4518
4519 def __showPyQt5Doc(self):
4520 """
4521 Private slot to show the PyQt5 documentation.
4522 """
4523 pyqt5DocDir = Preferences.getHelp("PyQt5DocDir")
4524 if not pyqt5DocDir:
4525 pyqt5DocDir = Utilities.getEnvironmentEntry("PYQT5DOCDIR", None)
4526
4527 if not pyqt5DocDir:
4528 E5MessageBox.warning(self,
4529 self.trUtf8("Documentation"),
4530 self.trUtf8("""<p>The PyQt5 documentation starting point"""
4531 """ has not been configured.</p>"""))
4532 return
4533
4534 if not pyqt5DocDir.startswith("http://") and \
4535 not pyqt5DocDir.startswith("https://"):
4536 home = ""
4537 if pyqt5DocDir:
4538 if pyqt5DocDir.startswith("file://"):
4539 pyqt5DocDir = pyqt5DocDir[7:]
4540 if not os.path.splitext(pyqt5DocDir)[1]:
4541 possibleHomes = [\
4542 Utilities.normjoinpath(pyqt5DocDir, 'index.html'),
4543 Utilities.normjoinpath(pyqt5DocDir, 'class_reference.html'),
4544 ]
4545 for possibleHome in possibleHomes:
4546 if os.path.exists(possibleHome):
4547 home = possibleHome
4548 break
4549 else:
4550 home = pyqt5DocDir
4551
4552 if not home or not os.path.exists(home):
4553 E5MessageBox.warning(self,
4554 self.trUtf8("Documentation Missing"),
4555 self.trUtf8("""<p>The documentation starting point"""
4556 """ "<b>{0}</b>" could not be found.</p>""")\
4557 .format(home))
4558 return
4559
4560 if Utilities.isWindowsPlatform():
4561 home = "file:///" + Utilities.fromNativeSeparators(home)
4562 else:
4563 home = "file://" + home
4564 else:
4565 home = pyqt5DocDir
4465 4566
4466 hvType = Preferences.getHelp("HelpViewerType") 4567 hvType = Preferences.getHelp("HelpViewerType")
4467 if hvType == 1: 4568 if hvType == 1:
4468 self.launchHelpViewer(home) 4569 self.launchHelpViewer(home)
4469 elif hvType == 2: 4570 elif hvType == 2:
5583 def __getFloatingGeometry(self, w): 5684 def __getFloatingGeometry(self, w):
5584 """ 5685 """
5585 Private method to get the geometry of a floating windows. 5686 Private method to get the geometry of a floating windows.
5586 5687
5587 @param w reference to the widget to be saved (QWidget) 5688 @param w reference to the widget to be saved (QWidget)
5588 @return list giving the widget's geometry and it's visibility 5689 @return list giving the widget's geometry and its visibility
5589 """ 5690 """
5590 s = w.size() 5691 s = w.size()
5591 p = w.pos() 5692 p = w.pos()
5592 return [p.x(), p.y(), s.width(), s.height(), not w.isHidden()] 5693 return [p.x(), p.y(), s.width(), s.height(), not w.isHidden()]
5593 5694

eric ide

mercurial