1224 @param icon icon to be used |
1224 @param icon icon to be used |
1225 @type QIcon |
1225 @type QIcon |
1226 @param label label text to be shown |
1226 @param label label text to be shown |
1227 @type str |
1227 @type str |
1228 """ |
1228 """ |
1229 assert side in [UserInterface.LeftSide, UserInterface.BottomSide, |
1229 if side in [UserInterface.LeftSide, UserInterface.BottomSide, |
1230 UserInterface.RightSide] |
1230 UserInterface.RightSide]: |
1231 |
1231 if self.__layoutType == "Toolboxes": |
1232 if self.__layoutType == "Toolboxes": |
1232 if side == UserInterface.LeftSide: |
1233 if side == UserInterface.LeftSide: |
1233 self.lToolbox.addItem(widget, icon, label) |
1234 self.lToolbox.addItem(widget, icon, label) |
1234 elif side == UserInterface.BottomSide: |
1235 elif side == UserInterface.BottomSide: |
1235 self.hToolbox.addItem(widget, icon, label) |
1236 self.hToolbox.addItem(widget, icon, label) |
1236 elif side == UserInterface.RightSide: |
1237 elif side == UserInterface.RightSide: |
1237 self.rToolbox.addItem(widget, icon, label) |
1238 self.rToolbox.addItem(widget, icon, label) |
1238 elif self.__layoutType == "Sidebars": |
1239 elif self.__layoutType == "Sidebars": |
1239 if side == UserInterface.LeftSide: |
1240 if side == UserInterface.LeftSide: |
1240 self.leftSidebar.addTab(widget, icon, label) |
1241 self.leftSidebar.addTab(widget, icon, label) |
1241 elif side == UserInterface.BottomSide: |
1242 elif side == UserInterface.BottomSide: |
1242 self.bottomSidebar.addTab(widget, icon, label) |
1243 self.bottomSidebar.addTab(widget, icon, label) |
1243 elif side == UserInterface.RightSide: |
1244 elif side == UserInterface.RightSide: |
1244 self.rightSidebar.addTab(widget, icon, label) |
1245 self.rightSidebar.addTab(widget, icon, label) |
|
1246 |
1245 |
1247 def removeSideWidget(self, widget): |
1246 def removeSideWidget(self, widget): |
1248 """ |
1247 """ |
1249 Public method to remove a widget added using addSideWidget(). |
1248 Public method to remove a widget added using addSideWidget(). |
1250 |
1249 |
2196 )) |
2195 )) |
2197 self.utProjectAct.triggered.connect(self.__unittestProject) |
2196 self.utProjectAct.triggered.connect(self.__unittestProject) |
2198 self.utProjectAct.setEnabled(False) |
2197 self.utProjectAct.setEnabled(False) |
2199 self.actions.append(self.utProjectAct) |
2198 self.actions.append(self.utProjectAct) |
2200 |
2199 |
2201 # check for Qt4/Qt5 designer and linguist |
2200 # check for Qt5 designer and linguist |
2202 if Utilities.isWindowsPlatform(): |
2201 if Utilities.isWindowsPlatform(): |
2203 designerExe = os.path.join( |
2202 designerExe = os.path.join( |
2204 Utilities.getQtBinariesPath(), |
2203 Utilities.getQtBinariesPath(), |
2205 "{0}.exe".format(Utilities.generateQtToolName("designer"))) |
2204 "{0}.exe".format(Utilities.generateQtToolName("designer"))) |
2206 elif Utilities.isMacPlatform(): |
2205 elif Utilities.isMacPlatform(): |
2730 |
2729 |
2731 def __initQtDocActions(self): |
2730 def __initQtDocActions(self): |
2732 """ |
2731 """ |
2733 Private slot to initialize the action to show the Qt documentation. |
2732 Private slot to initialize the action to show the Qt documentation. |
2734 """ |
2733 """ |
2735 self.qt4DocAct = E5Action( |
|
2736 self.tr('Qt4 Documentation'), |
|
2737 self.tr('Qt&4 Documentation'), |
|
2738 0, 0, self, 'qt4_documentation') |
|
2739 self.qt4DocAct.setStatusTip(self.tr('Open Qt4 Documentation')) |
|
2740 self.qt4DocAct.setWhatsThis(self.tr( |
|
2741 """<b>Qt4 Documentation</b>""" |
|
2742 """<p>Display the Qt4 Documentation. Dependent upon your""" |
|
2743 """ settings, this will either show the help in Eric's internal""" |
|
2744 """ help viewer/web browser, or execute a web browser or Qt""" |
|
2745 """ Assistant. </p>""" |
|
2746 )) |
|
2747 self.qt4DocAct.triggered.connect(self.__showQt4Doc) |
|
2748 self.actions.append(self.qt4DocAct) |
|
2749 |
|
2750 self.qt5DocAct = E5Action( |
2734 self.qt5DocAct = E5Action( |
2751 self.tr('Qt5 Documentation'), |
2735 self.tr('Qt5 Documentation'), |
2752 self.tr('Qt&5 Documentation'), |
2736 self.tr('Qt&5 Documentation'), |
2753 0, 0, self, 'qt5_documentation') |
2737 0, 0, self, 'qt5_documentation') |
2754 self.qt5DocAct.setStatusTip(self.tr('Open Qt5 Documentation')) |
2738 self.qt5DocAct.setStatusTip(self.tr('Open Qt5 Documentation')) |
2760 """ Assistant. </p>""" |
2744 """ Assistant. </p>""" |
2761 )) |
2745 )) |
2762 self.qt5DocAct.triggered.connect(self.__showQt5Doc) |
2746 self.qt5DocAct.triggered.connect(self.__showQt5Doc) |
2763 self.actions.append(self.qt5DocAct) |
2747 self.actions.append(self.qt5DocAct) |
2764 |
2748 |
2765 try: |
|
2766 import PyQt4 # __IGNORE_WARNING__ |
|
2767 self.pyqt4DocAct = E5Action( |
|
2768 self.tr('PyQt4 Documentation'), |
|
2769 self.tr('PyQt&4 Documentation'), |
|
2770 0, 0, self, 'pyqt4_documentation') |
|
2771 self.pyqt4DocAct.setStatusTip(self.tr('Open PyQt4 Documentation')) |
|
2772 self.pyqt4DocAct.setWhatsThis(self.tr( |
|
2773 """<b>PyQt4 Documentation</b>""" |
|
2774 """<p>Display the PyQt4 Documentation. Dependent upon your""" |
|
2775 """ settings, this will either show the help in Eric's""" |
|
2776 """ internal help viewer/web browser, or execute a web""" |
|
2777 """ browser or Qt Assistant. </p>""" |
|
2778 )) |
|
2779 self.pyqt4DocAct.triggered.connect(self.__showPyQt4Doc) |
|
2780 self.actions.append(self.pyqt4DocAct) |
|
2781 except ImportError: |
|
2782 self.pyqt4DocAct = None |
|
2783 |
|
2784 self.pyqt5DocAct = E5Action( |
2749 self.pyqt5DocAct = E5Action( |
2785 self.tr('PyQt5 Documentation'), |
2750 self.tr('PyQt5 Documentation'), |
2786 self.tr('PyQt&5 Documentation'), |
2751 self.tr('PyQt&5 Documentation'), |
2787 0, 0, self, 'pyqt5_documentation') |
2752 0, 0, self, 'pyqt5_documentation') |
2788 self.pyqt5DocAct.setStatusTip(self.tr( |
2753 self.pyqt5DocAct.setStatusTip(self.tr( |
2817 """ <i>/usr/share/doc/packages/python/html</i> on Unix. Set""" |
2782 """ <i>/usr/share/doc/packages/python/html</i> on Unix. Set""" |
2818 """ PYTHON3DOCDIR in your environment to override this.</p>""" |
2783 """ PYTHON3DOCDIR in your environment to override this.</p>""" |
2819 )) |
2784 )) |
2820 self.pythonDocAct.triggered.connect(self.__showPythonDoc) |
2785 self.pythonDocAct.triggered.connect(self.__showPythonDoc) |
2821 self.actions.append(self.pythonDocAct) |
2786 self.actions.append(self.pythonDocAct) |
2822 |
2787 |
2823 self.python2DocAct = E5Action( |
|
2824 self.tr('Python 2 Documentation'), |
|
2825 self.tr('Python &2 Documentation'), |
|
2826 0, 0, self, 'python2_documentation') |
|
2827 self.python2DocAct.setStatusTip(self.tr( |
|
2828 'Open Python 2 Documentation')) |
|
2829 self.python2DocAct.setWhatsThis(self.tr( |
|
2830 """<b>Python 2 Documentation</b>""" |
|
2831 """<p>Display the Python 2 documentation. If no documentation""" |
|
2832 """ directory is configured, the location of the Python 2""" |
|
2833 """ documentation is assumed to be the doc directory underneath""" |
|
2834 """ the location of the configured Python 2 executable on""" |
|
2835 """ Windows and""" |
|
2836 """ <i>/usr/share/doc/packages/python/html/python-docs-html</i>""" |
|
2837 """ on Unix. Set PYTHON2DOCDIR in your environment to override""" |
|
2838 """ this. </p>""" |
|
2839 )) |
|
2840 self.python2DocAct.triggered.connect(self.__showPython2Doc) |
|
2841 self.actions.append(self.python2DocAct) |
|
2842 |
|
2843 def __initEricDocAction(self): |
2788 def __initEricDocAction(self): |
2844 """ |
2789 """ |
2845 Private slot to initialize the action to show the eric6 documentation. |
2790 Private slot to initialize the action to show the eric6 documentation. |
2846 """ |
2791 """ |
2847 self.ericDocAct = E5Action( |
2792 self.ericDocAct = E5Action( |
2862 def __initPySideDocActions(self): |
2807 def __initPySideDocActions(self): |
2863 """ |
2808 """ |
2864 Private slot to initialize the actions to show the PySide |
2809 Private slot to initialize the actions to show the PySide |
2865 documentation. |
2810 documentation. |
2866 """ |
2811 """ |
2867 pyside_py2, pyside_py3 = Utilities.checkPyside("1") |
2812 if Utilities.checkPyside(): |
2868 if pyside_py2 or pyside_py3: |
|
2869 self.pysideDocAct = E5Action( |
|
2870 self.tr('PySide Documentation'), |
|
2871 self.tr('Py&Side Documentation'), |
|
2872 0, 0, self, 'pyside_documentation') |
|
2873 self.pysideDocAct.setStatusTip(self.tr( |
|
2874 'Open PySide Documentation')) |
|
2875 self.pysideDocAct.setWhatsThis(self.tr( |
|
2876 """<b>PySide Documentation</b>""" |
|
2877 """<p>Display the PySide Documentation. Dependent upon your""" |
|
2878 """ settings, this will either show the help in Eric's""" |
|
2879 """ internal help viewer/web browser, or execute a web""" |
|
2880 """ browser or Qt Assistant. </p>""" |
|
2881 )) |
|
2882 self.pysideDocAct.triggered.connect( |
|
2883 lambda: self.__showPySideDoc("1")) |
|
2884 self.actions.append(self.pysideDocAct) |
|
2885 else: |
|
2886 self.pysideDocAct = None |
|
2887 |
|
2888 pyside2_py2, pyside2_py3 = Utilities.checkPyside("2") |
|
2889 if pyside2_py2 or pyside2_py3: |
|
2890 self.pyside2DocAct = E5Action( |
2813 self.pyside2DocAct = E5Action( |
2891 self.tr('PySide2 Documentation'), |
2814 self.tr('PySide2 Documentation'), |
2892 self.tr('PySide&2 Documentation'), |
2815 self.tr('PySide&2 Documentation'), |
2893 0, 0, self, 'pyside2_documentation') |
2816 0, 0, self, 'pyside2_documentation') |
2894 self.pyside2DocAct.setStatusTip(self.tr( |
2817 self.pyside2DocAct.setStatusTip(self.tr( |
3190 if self.helpviewerAct: |
3113 if self.helpviewerAct: |
3191 self.__menus["help"].addAction(self.helpviewerAct) |
3114 self.__menus["help"].addAction(self.helpviewerAct) |
3192 self.__menus["help"].addSeparator() |
3115 self.__menus["help"].addSeparator() |
3193 self.__menus["help"].addAction(self.ericDocAct) |
3116 self.__menus["help"].addAction(self.ericDocAct) |
3194 self.__menus["help"].addAction(self.pythonDocAct) |
3117 self.__menus["help"].addAction(self.pythonDocAct) |
3195 self.__menus["help"].addAction(self.python2DocAct) |
|
3196 self.__menus["help"].addAction(self.qt4DocAct) |
|
3197 self.__menus["help"].addAction(self.qt5DocAct) |
3118 self.__menus["help"].addAction(self.qt5DocAct) |
3198 if self.pyqt4DocAct is not None: |
|
3199 self.__menus["help"].addAction(self.pyqt4DocAct) |
|
3200 if self.pyqt5DocAct is not None: |
3119 if self.pyqt5DocAct is not None: |
3201 self.__menus["help"].addAction(self.pyqt5DocAct) |
3120 self.__menus["help"].addAction(self.pyqt5DocAct) |
3202 if self.pysideDocAct is not None: |
|
3203 self.__menus["help"].addAction(self.pysideDocAct) |
|
3204 if self.pyside2DocAct is not None: |
3121 if self.pyside2DocAct is not None: |
3205 self.__menus["help"].addAction(self.pyside2DocAct) |
3122 self.__menus["help"].addAction(self.pyside2DocAct) |
3206 self.__menus["help"].addSeparator() |
3123 self.__menus["help"].addSeparator() |
3207 self.__menus["help"].addAction(self.versionAct) |
3124 self.__menus["help"].addAction(self.versionAct) |
3208 self.__menus["help"].addSeparator() |
3125 self.__menus["help"].addSeparator() |
5550 elif hvType == 3: |
5467 elif hvType == 3: |
5551 self.__webBrowser(home) |
5468 self.__webBrowser(home) |
5552 else: |
5469 else: |
5553 self.__customViewer(home) |
5470 self.__customViewer(home) |
5554 |
5471 |
5555 def __showPython2Doc(self): |
|
5556 """ |
|
5557 Private slot to show the Python 2 documentation. |
|
5558 """ |
|
5559 pythonDocDir = Preferences.getHelp("Python2DocDir") |
|
5560 if not pythonDocDir: |
|
5561 if Utilities.isWindowsPlatform(): |
|
5562 venvName = Preferences.getDebugger("Python2VirtualEnv") |
|
5563 interpreter = ( |
|
5564 e5App().getObject("VirtualEnvManager") |
|
5565 .getVirtualenvInterpreter(venvName) |
|
5566 ) |
|
5567 if interpreter: |
|
5568 default = os.path.join(os.path.dirname(interpreter), "doc") |
|
5569 else: |
|
5570 default = "" |
|
5571 pythonDocDir = Utilities.getEnvironmentEntry( |
|
5572 "PYTHON2DOCDIR", default) |
|
5573 else: |
|
5574 pythonDocDir = Utilities.getEnvironmentEntry( |
|
5575 "PYTHON2DOCDIR", |
|
5576 '/usr/share/doc/packages/python/html') |
|
5577 if not pythonDocDir.startswith(("http://", "https://", "qthelp://")): |
|
5578 if pythonDocDir.startswith("file://"): |
|
5579 pythonDocDir = pythonDocDir[7:] |
|
5580 if not os.path.splitext(pythonDocDir)[1]: |
|
5581 home = Utilities.normjoinpath(pythonDocDir, 'index.html') |
|
5582 else: |
|
5583 home = pythonDocDir |
|
5584 |
|
5585 if not os.path.exists(home): |
|
5586 E5MessageBox.warning( |
|
5587 self, |
|
5588 self.tr("Documentation Missing"), |
|
5589 self.tr("""<p>The documentation starting point""" |
|
5590 """ "<b>{0}</b>" could not be found.</p>""") |
|
5591 .format(home)) |
|
5592 return |
|
5593 |
|
5594 if not home.endswith(".chm"): |
|
5595 if Utilities.isWindowsPlatform(): |
|
5596 home = "file:///" + Utilities.fromNativeSeparators(home) |
|
5597 else: |
|
5598 home = "file://" + home |
|
5599 else: |
|
5600 home = pythonDocDir |
|
5601 |
|
5602 if home.endswith(".chm"): |
|
5603 self.__chmViewer(home) |
|
5604 else: |
|
5605 hvType = Preferences.getWebBrowser("HelpViewerType") |
|
5606 if hvType == 1: |
|
5607 self.launchHelpViewer(home) |
|
5608 elif hvType == 2: |
|
5609 if home.startswith("qthelp://"): |
|
5610 self.__assistant(home) |
|
5611 else: |
|
5612 self.__webBrowser(home) |
|
5613 elif hvType == 3: |
|
5614 self.__webBrowser(home) |
|
5615 else: |
|
5616 self.__customViewer(home) |
|
5617 |
|
5618 def __showQt4Doc(self): |
|
5619 """ |
|
5620 Private slot to show the Qt4 documentation. |
|
5621 """ |
|
5622 self.__showQtDoc(4) |
|
5623 |
|
5624 def __showQt5Doc(self): |
5472 def __showQt5Doc(self): |
5625 """ |
5473 """ |
5626 Private slot to show the Qt5 documentation. |
5474 Private slot to show the Qt5 documentation. |
5627 """ |
5475 """ |
5628 self.__showQtDoc(5) |
5476 self.__showQtDoc(5) |
5631 """ |
5479 """ |
5632 Private method to show the Qt documentation. |
5480 Private method to show the Qt documentation. |
5633 |
5481 |
5634 @param version Qt version to show documentation for (integer) |
5482 @param version Qt version to show documentation for (integer) |
5635 """ |
5483 """ |
5636 assert version in [4, 5] |
5484 if version == 5: |
5637 if version == 4: |
|
5638 qtDocDir = Preferences.getQt4DocDir() |
|
5639 elif version == 5: |
|
5640 qtDocDir = Preferences.getQt5DocDir() |
5485 qtDocDir = Preferences.getQt5DocDir() |
5641 |
5486 |
5642 if qtDocDir.startswith("qthelp://"): |
5487 if qtDocDir.startswith("qthelp://"): |
5643 if not os.path.splitext(qtDocDir)[1]: |
5488 if not os.path.splitext(qtDocDir)[1]: |
5644 home = qtDocDir + "/index.html" |
5489 home = qtDocDir + "/index.html" |
5665 |
5510 |
5666 if Utilities.isWindowsPlatform(): |
5511 if Utilities.isWindowsPlatform(): |
5667 home = "file:///" + Utilities.fromNativeSeparators(home) |
5512 home = "file:///" + Utilities.fromNativeSeparators(home) |
5668 else: |
5513 else: |
5669 home = "file://" + home |
5514 home = "file://" + home |
5670 |
|
5671 hvType = Preferences.getWebBrowser("HelpViewerType") |
|
5672 if hvType == 1: |
|
5673 self.launchHelpViewer(home) |
|
5674 elif hvType == 2: |
|
5675 if home.startswith("qthelp://"): |
|
5676 self.__assistant(home) |
|
5677 else: |
|
5678 self.__webBrowser(home) |
|
5679 elif hvType == 3: |
|
5680 self.__webBrowser(home) |
|
5681 else: |
|
5682 self.__customViewer(home) |
|
5683 |
|
5684 def __showPyQt4Doc(self): |
|
5685 """ |
|
5686 Private slot to show the PyQt4 documentation. |
|
5687 """ |
|
5688 pyqt4DocDir = Preferences.getHelp("PyQt4DocDir") |
|
5689 if not pyqt4DocDir: |
|
5690 pyqt4DocDir = Utilities.getEnvironmentEntry("PYQT4DOCDIR", None) |
|
5691 |
|
5692 if not pyqt4DocDir: |
|
5693 E5MessageBox.warning( |
|
5694 self, |
|
5695 self.tr("Documentation"), |
|
5696 self.tr("""<p>The PyQt4 documentation starting point""" |
|
5697 """ has not been configured.</p>""")) |
|
5698 return |
|
5699 |
|
5700 if not pyqt4DocDir.startswith(("http://", "https://", "qthelp://")): |
|
5701 home = "" |
|
5702 if pyqt4DocDir: |
|
5703 if pyqt4DocDir.startswith("file://"): |
|
5704 pyqt4DocDir = pyqt4DocDir[7:] |
|
5705 if not os.path.splitext(pyqt4DocDir)[1]: |
|
5706 possibleHomes = [ |
|
5707 Utilities.normjoinpath(pyqt4DocDir, 'index.html'), |
|
5708 Utilities.normjoinpath(pyqt4DocDir, 'classes.html'), |
|
5709 ] |
|
5710 for possibleHome in possibleHomes: |
|
5711 if os.path.exists(possibleHome): |
|
5712 home = possibleHome |
|
5713 break |
|
5714 else: |
|
5715 home = pyqt4DocDir |
|
5716 |
|
5717 if not home or not os.path.exists(home): |
|
5718 E5MessageBox.warning( |
|
5719 self, |
|
5720 self.tr("Documentation Missing"), |
|
5721 self.tr("""<p>The documentation starting point""" |
|
5722 """ "<b>{0}</b>" could not be found.</p>""") |
|
5723 .format(home)) |
|
5724 return |
|
5725 |
|
5726 if Utilities.isWindowsPlatform(): |
|
5727 home = "file:///" + Utilities.fromNativeSeparators(home) |
|
5728 else: |
|
5729 home = "file://" + home |
|
5730 else: |
|
5731 home = pyqt4DocDir |
|
5732 |
5515 |
5733 hvType = Preferences.getWebBrowser("HelpViewerType") |
5516 hvType = Preferences.getWebBrowser("HelpViewerType") |
5734 if hvType == 1: |
5517 if hvType == 1: |
5735 self.launchHelpViewer(home) |
5518 self.launchHelpViewer(home) |
5736 elif hvType == 2: |
5519 elif hvType == 2: |
5841 self.__webBrowser(home) |
5624 self.__webBrowser(home) |
5842 elif hvType == 3: |
5625 elif hvType == 3: |
5843 self.__webBrowser(home) |
5626 self.__webBrowser(home) |
5844 else: |
5627 else: |
5845 self.__customViewer(home) |
5628 self.__customViewer(home) |
5846 |
5629 |
5847 def __showPySideDoc(self, variant): |
5630 def __showPySideDoc(self, variant="2"): |
5848 """ |
5631 """ |
5849 Private slot to show the PySide/PySide2 documentation. |
5632 Private slot to show the PySide2 documentation. |
5850 |
5633 |
5851 @param variant PySide variant (1 or 2) |
5634 @param variant PySide variant (2) |
5852 @type str |
5635 @type str |
5853 """ |
5636 """ |
5854 assert variant in ("1", "2") |
5637 pysideDocDir = Preferences.getHelp("PySide2DocDir") |
5855 |
5638 if not pysideDocDir: |
5856 if variant == "1": |
5639 pysideDocDir = Utilities.getEnvironmentEntry( |
5857 pysideDocDir = Preferences.getHelp("PySideDocDir") |
5640 "PYSIDE2DOCDIR", None) |
5858 if not pysideDocDir: |
|
5859 pysideDocDir = Utilities.getEnvironmentEntry( |
|
5860 "PYSIDEDOCDIR", None) |
|
5861 else: |
|
5862 pysideDocDir = Preferences.getHelp("PySide2DocDir") |
|
5863 if not pysideDocDir: |
|
5864 pysideDocDir = Utilities.getEnvironmentEntry( |
|
5865 "PYSIDE2DOCDIR", None) |
|
5866 |
5641 |
5867 if not pysideDocDir: |
5642 if not pysideDocDir: |
5868 E5MessageBox.warning( |
5643 E5MessageBox.warning( |
5869 self, |
5644 self, |
5870 self.tr("Documentation"), |
5645 self.tr("Documentation"), |
5871 self.tr("""<p>The PySide{0} documentation starting point""" |
5646 self.tr("""<p>The PySide{0} documentation starting point""" |
5872 """ has not been configured.</p>""").format( |
5647 """ has not been configured.</p>""").format( |
5873 "" if variant == "1" else variant) |
5648 variant) |
5874 ) |
5649 ) |
5875 return |
5650 return |
5876 |
5651 |
5877 if not pysideDocDir.startswith(("http://", "https://", "qthelp://")): |
5652 if not pysideDocDir.startswith(("http://", "https://", "qthelp://")): |
5878 if pysideDocDir.startswith("file://"): |
5653 if pysideDocDir.startswith("file://"): |