--- a/UI/UserInterface.py Tue May 01 12:04:30 2018 +0200 +++ b/UI/UserInterface.py Sat Jun 02 12:44:41 2018 +0200 @@ -280,7 +280,7 @@ self.stdout = Redirector(False) self.stderr = Redirector(True) - # set a few dialog members for dialogs created on demand + # set a few dialog members for non-modal dialogs created on demand self.programsDialog = None self.shortcutsDialog = None self.unittestDialog = None @@ -291,6 +291,7 @@ self.replaceFilesDialog = None self.__notification = None self.__readingSession = False + self.__versionsDialog = None # now setup the connections splash.showMessage(self.tr("Setting up connections...")) @@ -540,6 +541,11 @@ else: self.dummyHelpViewer = None + # redirect handling of http and https URLs to ourselves + if WEBENGINE_AVAILABLE or WEBKIT_AVAILABLE: + QDesktopServices.setUrlHandler("http", self.handleUrl) + QDesktopServices.setUrlHandler("https", self.handleUrl) + # register all relevant objects splash.showMessage(self.tr("Registering Objects...")) e5App().registerObject("UserInterface", self) @@ -630,6 +636,9 @@ self.toolbarManager.restoreState( Preferences.getUI("ToolbarManagerState")) + # finalize the initialization of the code documentation viewer + self.codeDocumentationViewer.finalizeSetup() + # now activate the initial view profile splash.showMessage(self.tr("Setting View Profile...")) self.__setEditProfile() @@ -673,9 +682,6 @@ if interval > 0: QApplication.setKeyboardInputInterval(interval) - # finalize the initialization of the code documentation viewer - self.codeDocumentationViewer.finalizeSetup() - def __createLayout(self, debugServer): """ Private method to create the layout of the various windows. @@ -1769,7 +1775,7 @@ self.__initQtDocActions() self.__initPythonDocActions() self.__initEricDocAction() - self.__initPySideDocAction() + self.__initPySideDocActions() self.versionAct = E5Action( self.tr('Show Versions'), @@ -2432,7 +2438,8 @@ """<b>Qt4 Documentation</b>""" """<p>Display the Qt4 Documentation. Dependent upon your""" """ settings, this will either show the help in Eric's internal""" - """ help viewer, or execute a web browser or Qt Assistant. </p>""" + """ help viewer/web browser, or execute a web browser or Qt""" + """ Assistant. </p>""" )) self.qt4DocAct.triggered.connect(self.__showQt4Doc) self.actions.append(self.qt4DocAct) @@ -2446,7 +2453,8 @@ """<b>Qt5 Documentation</b>""" """<p>Display the Qt5 Documentation. Dependent upon your""" """ settings, this will either show the help in Eric's internal""" - """ help viewer, or execute a web browser or Qt Assistant. </p>""" + """ help viewer/web browser, or execute a web browser or Qt""" + """ Assistant. </p>""" )) self.qt5DocAct.triggered.connect(self.__showQt5Doc) self.actions.append(self.qt5DocAct) @@ -2462,8 +2470,8 @@ """<b>PyQt4 Documentation</b>""" """<p>Display the PyQt4 Documentation. Dependent upon your""" """ settings, this will either show the help in Eric's""" - """ internal help viewer, or execute a web browser or""" - """ Qt Assistant. </p>""" + """ internal help viewer/web browser, or execute a web""" + """ browser or Qt Assistant. </p>""" )) self.pyqt4DocAct.triggered.connect(self.__showPyQt4Doc) self.actions.append(self.pyqt4DocAct) @@ -2482,8 +2490,8 @@ """<b>PyQt5 Documentation</b>""" """<p>Display the PyQt5 Documentation. Dependent upon your""" """ settings, this will either show the help in Eric's""" - """ internal help viewer, or execute a web browser or""" - """ Qt Assistant. </p>""" + """ internal help viewer/web browser, or execute a web""" + """ browser or Qt Assistant. </p>""" )) self.pyqt5DocAct.triggered.connect(self.__showPyQt5Doc) self.actions.append(self.pyqt5DocAct) @@ -2552,12 +2560,13 @@ self.ericDocAct.triggered.connect(self.__showEricDoc) self.actions.append(self.ericDocAct) - def __initPySideDocAction(self): - """ - Private slot to initialize the action to show the PySide documentation. - """ - pyside2, pyside3 = Utilities.checkPyside() - if pyside2 or pyside3: + def __initPySideDocActions(self): + """ + Private slot to initialize the actions to show the PySide + documentation. + """ + pyside_py2, pyside_py3 = Utilities.checkPyside("1") + if pyside_py2 or pyside_py3: self.pysideDocAct = E5Action( self.tr('PySide Documentation'), self.tr('Py&Side Documentation'), @@ -2568,14 +2577,36 @@ """<b>PySide Documentation</b>""" """<p>Display the PySide Documentation. Dependent upon your""" """ settings, this will either show the help in Eric's""" - """ internal help viewer, or execute a web browser or""" - """ Qt Assistant. </p>""" + """ internal help viewer/web browser, or execute a web""" + """ browser or Qt Assistant. </p>""" )) - self.pysideDocAct.triggered.connect(self.__showPySideDoc) + self.pysideDocAct.triggered.connect( + lambda: self.__showPySideDoc("1")) self.actions.append(self.pysideDocAct) else: self.pysideDocAct = None - + + pyside2_py2, pyside2_py3 = Utilities.checkPyside("2") + if pyside2_py2 or pyside2_py3: + self.pyside2DocAct = E5Action( + self.tr('PySide2 Documentation'), + self.tr('PySide&2 Documentation'), + 0, 0, self, 'pyside2_documentation') + self.pyside2DocAct.setStatusTip(self.tr( + 'Open PySide2 Documentation')) + self.pyside2DocAct.setWhatsThis(self.tr( + """<b>PySide2 Documentation</b>""" + """<p>Display the PySide2 Documentation. Dependent upon your""" + """ settings, this will either show the help in Eric's""" + """ internal help viewer/web browser, or execute a web""" + """ browser or Qt Assistant. </p>""" + )) + self.pyside2DocAct.triggered.connect( + lambda: self.__showPySideDoc("2")) + self.actions.append(self.pyside2DocAct) + else: + self.pyside2DocAct = None + def __initMenus(self): """ Private slot to create the menus. @@ -2739,6 +2770,8 @@ self.__menus["help"].addAction(self.pyqt5DocAct) if self.pysideDocAct is not None: self.__menus["help"].addAction(self.pysideDocAct) + if self.pyside2DocAct is not None: + self.__menus["help"].addAction(self.pyside2DocAct) self.__menus["help"].addSeparator() self.__menus["help"].addAction(self.versionAct) self.__menus["help"].addSeparator() @@ -5366,20 +5399,34 @@ else: self.__customViewer(home) - def __showPySideDoc(self): - """ - Private slot to show the PySide documentation. - """ - pysideDocDir = Preferences.getHelp("PySideDocDir") - if not pysideDocDir: - pysideDocDir = Utilities.getEnvironmentEntry("PYSIDEDOCDIR", None) + def __showPySideDoc(self, variant): + """ + Private slot to show the PySide/PySide2 documentation. + + @param variant PySide variant (1 or 2) + @type str + """ + assert variant in ("1", "2") + + if variant == "1": + pysideDocDir = Preferences.getHelp("PySideDocDir") + if not pysideDocDir: + pysideDocDir = Utilities.getEnvironmentEntry( + "PYSIDEDOCDIR", None) + else: + pysideDocDir = Preferences.getHelp("PySide2DocDir") + if not pysideDocDir: + pysideDocDir = Utilities.getEnvironmentEntry( + "PYSIDE2DOCDIR", None) if not pysideDocDir: E5MessageBox.warning( self, self.tr("Documentation"), - self.tr("""<p>The PySide documentation starting point""" - """ has not been configured.</p>""")) + self.tr("""<p>The PySide{0} documentation starting point""" + """ has not been configured.</p>""").format( + "" if variant == "1" else variant) + ) return if not pysideDocDir.startswith(("http://", "https://", "qthelp://")): @@ -5420,16 +5467,31 @@ self.__webBrowser(home) else: self.__customViewer(home) - + + @pyqtSlot(QUrl) + def handleUrl(self, url): + """ + Public slot to handle opening a URL. + + @param url URL to be shown + @type QUrl + """ + self.launchHelpViewer(url) + def launchHelpViewer(self, home, searchWord=None, useSingle=False): """ - Public slot to start the help viewer. - - @param home filename of file to be shown (string) - @keyparam searchWord word to search for (string) + Public slot to start the help viewer/web browser. + + @param home filename of file to be shown or URL to be opened + @type str or QUrl + @keyparam searchWord word to search for + @type str @keyparam useSingle flag indicating to use a single browser window - (boolean) - """ + @type bool + """ + if isinstance(home, QUrl): + home = home.toString(QUrl.None_) + if len(home) > 0: homeUrl = QUrl(home) if not homeUrl.scheme(): @@ -5495,7 +5557,7 @@ def __helpViewer(self): """ - Private slot to start an empty help viewer. + Private slot to start an empty help viewer/web browser. """ searchWord = self.viewmanager.textForFind(False) if searchWord == "": @@ -6691,7 +6753,17 @@ line += 2 versionText += self.tr("""</table>""") - E5MessageBox.about(self, Program, versionText) + self.__versionsDialog = E5MessageBox.E5MessageBox( + E5MessageBox.NoIcon, + Program, + versionText, + modal=False, + buttons=E5MessageBox.Ok, + parent=self + ) + self.__versionsDialog.setIconPixmap( + UI.PixmapCache.getPixmap("eric.png").scaled(64, 64)) + self.__versionsDialog.show() def __sslErrors(self, reply, errors): """