UI/UserInterface.py

changeset 6291
94e0e688dcad
parent 6287
9a193ff6d24a
child 6296
db9b3a419845
equal deleted inserted replaced
6290:bf4624957d2d 6291:94e0e688dcad
1774 self.helpviewerAct = None 1774 self.helpviewerAct = None
1775 1775
1776 self.__initQtDocActions() 1776 self.__initQtDocActions()
1777 self.__initPythonDocActions() 1777 self.__initPythonDocActions()
1778 self.__initEricDocAction() 1778 self.__initEricDocAction()
1779 self.__initPySideDocAction() 1779 self.__initPySideDocActions()
1780 1780
1781 self.versionAct = E5Action( 1781 self.versionAct = E5Action(
1782 self.tr('Show Versions'), 1782 self.tr('Show Versions'),
1783 self.tr('Show &Versions'), 1783 self.tr('Show &Versions'),
1784 0, 0, self, 'show_versions') 1784 0, 0, self, 'show_versions')
2437 self.qt4DocAct.setStatusTip(self.tr('Open Qt4 Documentation')) 2437 self.qt4DocAct.setStatusTip(self.tr('Open Qt4 Documentation'))
2438 self.qt4DocAct.setWhatsThis(self.tr( 2438 self.qt4DocAct.setWhatsThis(self.tr(
2439 """<b>Qt4 Documentation</b>""" 2439 """<b>Qt4 Documentation</b>"""
2440 """<p>Display the Qt4 Documentation. Dependent upon your""" 2440 """<p>Display the Qt4 Documentation. Dependent upon your"""
2441 """ settings, this will either show the help in Eric's internal""" 2441 """ settings, this will either show the help in Eric's internal"""
2442 """ help viewer, or execute a web browser or Qt Assistant. </p>""" 2442 """ help viewer/web browser, or execute a web browser or Qt"""
2443 """ Assistant. </p>"""
2443 )) 2444 ))
2444 self.qt4DocAct.triggered.connect(self.__showQt4Doc) 2445 self.qt4DocAct.triggered.connect(self.__showQt4Doc)
2445 self.actions.append(self.qt4DocAct) 2446 self.actions.append(self.qt4DocAct)
2446 2447
2447 self.qt5DocAct = E5Action( 2448 self.qt5DocAct = E5Action(
2451 self.qt5DocAct.setStatusTip(self.tr('Open Qt5 Documentation')) 2452 self.qt5DocAct.setStatusTip(self.tr('Open Qt5 Documentation'))
2452 self.qt5DocAct.setWhatsThis(self.tr( 2453 self.qt5DocAct.setWhatsThis(self.tr(
2453 """<b>Qt5 Documentation</b>""" 2454 """<b>Qt5 Documentation</b>"""
2454 """<p>Display the Qt5 Documentation. Dependent upon your""" 2455 """<p>Display the Qt5 Documentation. Dependent upon your"""
2455 """ settings, this will either show the help in Eric's internal""" 2456 """ settings, this will either show the help in Eric's internal"""
2456 """ help viewer, or execute a web browser or Qt Assistant. </p>""" 2457 """ help viewer/web browser, or execute a web browser or Qt"""
2458 """ Assistant. </p>"""
2457 )) 2459 ))
2458 self.qt5DocAct.triggered.connect(self.__showQt5Doc) 2460 self.qt5DocAct.triggered.connect(self.__showQt5Doc)
2459 self.actions.append(self.qt5DocAct) 2461 self.actions.append(self.qt5DocAct)
2460 2462
2461 try: 2463 try:
2467 self.pyqt4DocAct.setStatusTip(self.tr('Open PyQt4 Documentation')) 2469 self.pyqt4DocAct.setStatusTip(self.tr('Open PyQt4 Documentation'))
2468 self.pyqt4DocAct.setWhatsThis(self.tr( 2470 self.pyqt4DocAct.setWhatsThis(self.tr(
2469 """<b>PyQt4 Documentation</b>""" 2471 """<b>PyQt4 Documentation</b>"""
2470 """<p>Display the PyQt4 Documentation. Dependent upon your""" 2472 """<p>Display the PyQt4 Documentation. Dependent upon your"""
2471 """ settings, this will either show the help in Eric's""" 2473 """ settings, this will either show the help in Eric's"""
2472 """ internal help viewer, or execute a web browser or""" 2474 """ internal help viewer/web browser, or execute a web"""
2473 """ Qt Assistant. </p>""" 2475 """ browser or Qt Assistant. </p>"""
2474 )) 2476 ))
2475 self.pyqt4DocAct.triggered.connect(self.__showPyQt4Doc) 2477 self.pyqt4DocAct.triggered.connect(self.__showPyQt4Doc)
2476 self.actions.append(self.pyqt4DocAct) 2478 self.actions.append(self.pyqt4DocAct)
2477 except ImportError: 2479 except ImportError:
2478 self.pyqt4DocAct = None 2480 self.pyqt4DocAct = None
2487 'Open PyQt5 Documentation')) 2489 'Open PyQt5 Documentation'))
2488 self.pyqt5DocAct.setWhatsThis(self.tr( 2490 self.pyqt5DocAct.setWhatsThis(self.tr(
2489 """<b>PyQt5 Documentation</b>""" 2491 """<b>PyQt5 Documentation</b>"""
2490 """<p>Display the PyQt5 Documentation. Dependent upon your""" 2492 """<p>Display the PyQt5 Documentation. Dependent upon your"""
2491 """ settings, this will either show the help in Eric's""" 2493 """ settings, this will either show the help in Eric's"""
2492 """ internal help viewer, or execute a web browser or""" 2494 """ internal help viewer/web browser, or execute a web"""
2493 """ Qt Assistant. </p>""" 2495 """ browser or Qt Assistant. </p>"""
2494 )) 2496 ))
2495 self.pyqt5DocAct.triggered.connect(self.__showPyQt5Doc) 2497 self.pyqt5DocAct.triggered.connect(self.__showPyQt5Doc)
2496 self.actions.append(self.pyqt5DocAct) 2498 self.actions.append(self.pyqt5DocAct)
2497 except ImportError: 2499 except ImportError:
2498 self.pyqt5DocAct = None 2500 self.pyqt5DocAct = None
2557 """ the eric6 installation directory.</p>""" 2559 """ the eric6 installation directory.</p>"""
2558 )) 2560 ))
2559 self.ericDocAct.triggered.connect(self.__showEricDoc) 2561 self.ericDocAct.triggered.connect(self.__showEricDoc)
2560 self.actions.append(self.ericDocAct) 2562 self.actions.append(self.ericDocAct)
2561 2563
2562 def __initPySideDocAction(self): 2564 def __initPySideDocActions(self):
2563 """ 2565 """
2564 Private slot to initialize the action to show the PySide documentation. 2566 Private slot to initialize the actions to show the PySide
2565 """ 2567 documentation.
2566 pyside2, pyside3 = Utilities.checkPyside() 2568 """
2567 if pyside2 or pyside3: 2569 pyside_py2, pyside_py3 = Utilities.checkPyside("1")
2570 if pyside_py2 or pyside_py3:
2568 self.pysideDocAct = E5Action( 2571 self.pysideDocAct = E5Action(
2569 self.tr('PySide Documentation'), 2572 self.tr('PySide Documentation'),
2570 self.tr('Py&Side Documentation'), 2573 self.tr('Py&Side Documentation'),
2571 0, 0, self, 'pyside_documentation') 2574 0, 0, self, 'pyside_documentation')
2572 self.pysideDocAct.setStatusTip(self.tr( 2575 self.pysideDocAct.setStatusTip(self.tr(
2573 'Open PySide Documentation')) 2576 'Open PySide Documentation'))
2574 self.pysideDocAct.setWhatsThis(self.tr( 2577 self.pysideDocAct.setWhatsThis(self.tr(
2575 """<b>PySide Documentation</b>""" 2578 """<b>PySide Documentation</b>"""
2576 """<p>Display the PySide Documentation. Dependent upon your""" 2579 """<p>Display the PySide Documentation. Dependent upon your"""
2577 """ settings, this will either show the help in Eric's""" 2580 """ settings, this will either show the help in Eric's"""
2578 """ internal help viewer, or execute a web browser or""" 2581 """ internal help viewer/web browser, or execute a web"""
2579 """ Qt Assistant. </p>""" 2582 """ browser or Qt Assistant. </p>"""
2580 )) 2583 ))
2581 self.pysideDocAct.triggered.connect(self.__showPySideDoc) 2584 self.pysideDocAct.triggered.connect(
2585 lambda: self.__showPySideDoc("1"))
2582 self.actions.append(self.pysideDocAct) 2586 self.actions.append(self.pysideDocAct)
2583 else: 2587 else:
2584 self.pysideDocAct = None 2588 self.pysideDocAct = None
2585 2589
2590 pyside2_py2, pyside2_py3 = Utilities.checkPyside("2")
2591 if pyside2_py2 or pyside2_py3:
2592 self.pyside2DocAct = E5Action(
2593 self.tr('PySide2 Documentation'),
2594 self.tr('PySide&2 Documentation'),
2595 0, 0, self, 'pyside2_documentation')
2596 self.pyside2DocAct.setStatusTip(self.tr(
2597 'Open PySide2 Documentation'))
2598 self.pyside2DocAct.setWhatsThis(self.tr(
2599 """<b>PySide2 Documentation</b>"""
2600 """<p>Display the PySide2 Documentation. Dependent upon your"""
2601 """ settings, this will either show the help in Eric's"""
2602 """ internal help viewer/web browser, or execute a web"""
2603 """ browser or Qt Assistant. </p>"""
2604 ))
2605 self.pyside2DocAct.triggered.connect(
2606 lambda: self.__showPySideDoc("2"))
2607 self.actions.append(self.pyside2DocAct)
2608 else:
2609 self.pyside2DocAct = None
2610
2586 def __initMenus(self): 2611 def __initMenus(self):
2587 """ 2612 """
2588 Private slot to create the menus. 2613 Private slot to create the menus.
2589 """ 2614 """
2590 self.__menus = {} 2615 self.__menus = {}
2744 self.__menus["help"].addAction(self.pyqt4DocAct) 2769 self.__menus["help"].addAction(self.pyqt4DocAct)
2745 if self.pyqt5DocAct is not None: 2770 if self.pyqt5DocAct is not None:
2746 self.__menus["help"].addAction(self.pyqt5DocAct) 2771 self.__menus["help"].addAction(self.pyqt5DocAct)
2747 if self.pysideDocAct is not None: 2772 if self.pysideDocAct is not None:
2748 self.__menus["help"].addAction(self.pysideDocAct) 2773 self.__menus["help"].addAction(self.pysideDocAct)
2774 if self.pyside2DocAct is not None:
2775 self.__menus["help"].addAction(self.pyside2DocAct)
2749 self.__menus["help"].addSeparator() 2776 self.__menus["help"].addSeparator()
2750 self.__menus["help"].addAction(self.versionAct) 2777 self.__menus["help"].addAction(self.versionAct)
2751 self.__menus["help"].addSeparator() 2778 self.__menus["help"].addSeparator()
2752 self.__menus["help"].addAction(self.checkUpdateAct) 2779 self.__menus["help"].addAction(self.checkUpdateAct)
2753 self.__menus["help"].addAction(self.showVersionsAct) 2780 self.__menus["help"].addAction(self.showVersionsAct)
5371 elif hvType == 3: 5398 elif hvType == 3:
5372 self.__webBrowser(home) 5399 self.__webBrowser(home)
5373 else: 5400 else:
5374 self.__customViewer(home) 5401 self.__customViewer(home)
5375 5402
5376 def __showPySideDoc(self): 5403 def __showPySideDoc(self, variant):
5377 """ 5404 """
5378 Private slot to show the PySide documentation. 5405 Private slot to show the PySide/PySide2 documentation.
5379 """ 5406
5380 pysideDocDir = Preferences.getHelp("PySideDocDir") 5407 @param variant PySide variant (1 or 2)
5381 if not pysideDocDir: 5408 @type str
5382 pysideDocDir = Utilities.getEnvironmentEntry("PYSIDEDOCDIR", None) 5409 """
5410 assert variant in ("1", "2")
5411
5412 if variant == "1":
5413 pysideDocDir = Preferences.getHelp("PySideDocDir")
5414 if not pysideDocDir:
5415 pysideDocDir = Utilities.getEnvironmentEntry(
5416 "PYSIDEDOCDIR", None)
5417 else:
5418 pysideDocDir = Preferences.getHelp("PySide2DocDir")
5419 if not pysideDocDir:
5420 pysideDocDir = Utilities.getEnvironmentEntry(
5421 "PYSIDE2DOCDIR", None)
5383 5422
5384 if not pysideDocDir: 5423 if not pysideDocDir:
5385 E5MessageBox.warning( 5424 E5MessageBox.warning(
5386 self, 5425 self,
5387 self.tr("Documentation"), 5426 self.tr("Documentation"),
5388 self.tr("""<p>The PySide documentation starting point""" 5427 self.tr("""<p>The PySide{0} documentation starting point"""
5389 """ has not been configured.</p>""")) 5428 """ has not been configured.</p>""").format(
5429 "" if variant == "1" else variant)
5430 )
5390 return 5431 return
5391 5432
5392 if not pysideDocDir.startswith(("http://", "https://", "qthelp://")): 5433 if not pysideDocDir.startswith(("http://", "https://", "qthelp://")):
5393 if pysideDocDir.startswith("file://"): 5434 if pysideDocDir.startswith("file://"):
5394 pysideDocDir = pysideDocDir[7:] 5435 pysideDocDir = pysideDocDir[7:]
5425 self.__webBrowser(home) 5466 self.__webBrowser(home)
5426 elif hvType == 3: 5467 elif hvType == 3:
5427 self.__webBrowser(home) 5468 self.__webBrowser(home)
5428 else: 5469 else:
5429 self.__customViewer(home) 5470 self.__customViewer(home)
5430 5471
5431 @pyqtSlot(QUrl) 5472 @pyqtSlot(QUrl)
5432 def handleUrl(self, url): 5473 def handleUrl(self, url):
5433 """ 5474 """
5434 Public slot to handle opening a URL. 5475 Public slot to handle opening a URL.
5435 5476
5515 self.helpWindow.masterPasswordChanged) 5556 self.helpWindow.masterPasswordChanged)
5516 self.helpWindow = None 5557 self.helpWindow = None
5517 5558
5518 def __helpViewer(self): 5559 def __helpViewer(self):
5519 """ 5560 """
5520 Private slot to start an empty help viewer. 5561 Private slot to start an empty help viewer/web browser.
5521 """ 5562 """
5522 searchWord = self.viewmanager.textForFind(False) 5563 searchWord = self.viewmanager.textForFind(False)
5523 if searchWord == "": 5564 if searchWord == "":
5524 searchWord = None 5565 searchWord = None
5525 5566

eric ide

mercurial