eric6/UI/UserInterface.py

changeset 7264
bedbe458d792
parent 7229
53054eb5b15a
child 7286
7eb04391adf7
child 7300
7622b6330e62
equal deleted inserted replaced
7263:c1af2e327675 7264:bedbe458d792
10 10
11 import os 11 import os
12 import sys 12 import sys
13 import logging 13 import logging
14 14
15 from PyQt5.QtCore import pyqtSlot, QTimer, QFile, QFileInfo, pyqtSignal, \ 15 from PyQt5.QtCore import (
16 PYQT_VERSION_STR, QDate, QIODevice, qVersion, QProcess, QSize, QUrl, \ 16 pyqtSlot, QTimer, QFile, QFileInfo, pyqtSignal, PYQT_VERSION_STR, QDate,
17 QObject, Qt, QUuid, QThread, QUrlQuery 17 QIODevice, qVersion, QProcess, QSize, QUrl, QObject, Qt, QUuid, QThread,
18 QUrlQuery
19 )
18 from PyQt5.QtGui import QKeySequence, QDesktopServices 20 from PyQt5.QtGui import QKeySequence, QDesktopServices
19 from PyQt5.QtWidgets import QSizePolicy, QWidget, QWhatsThis, QToolBar, \ 21 from PyQt5.QtWidgets import (
20 QDialog, QSplitter, QApplication, QMenu, QVBoxLayout, QDockWidget, \ 22 QSizePolicy, QWidget, QWhatsThis, QToolBar, QDialog, QSplitter,
21 QAction, QLabel 23 QApplication, QMenu, QVBoxLayout, QDockWidget, QAction, QLabel
24 )
22 from PyQt5.Qsci import QSCINTILLA_VERSION_STR 25 from PyQt5.Qsci import QSCINTILLA_VERSION_STR
23 from PyQt5.QtNetwork import QNetworkProxyFactory, QNetworkAccessManager, \ 26 from PyQt5.QtNetwork import (
24 QNetworkRequest, QNetworkReply 27 QNetworkProxyFactory, QNetworkAccessManager, QNetworkRequest, QNetworkReply
28 )
25 29
26 from .Info import Version, VersionOnly, BugAddress, Program, FeatureAddress 30 from .Info import Version, VersionOnly, BugAddress, Program, FeatureAddress
27 from . import Config 31 from . import Config
28 32
29 from E5Gui.E5SingleApplication import E5SingleApplicationServer 33 from E5Gui.E5SingleApplication import E5SingleApplicationServer
40 import Utilities 44 import Utilities
41 45
42 import UI.PixmapCache 46 import UI.PixmapCache
43 47
44 from E5Network.E5NetworkIcon import E5NetworkIcon 48 from E5Network.E5NetworkIcon import E5NetworkIcon
45 from E5Network.E5NetworkProxyFactory import E5NetworkProxyFactory, \ 49 from E5Network.E5NetworkProxyFactory import (
46 proxyAuthenticationRequired 50 E5NetworkProxyFactory, proxyAuthenticationRequired
51 )
47 try: 52 try:
48 from E5Network.E5SslErrorHandler import E5SslErrorHandler 53 from E5Network.E5SslErrorHandler import E5SslErrorHandler
49 SSL_AVAILABLE = True 54 SSL_AVAILABLE = True
50 except ImportError: 55 except ImportError:
51 SSL_AVAILABLE = False 56 SSL_AVAILABLE = False
655 self.pluginManager.activatePlugins() 660 self.pluginManager.activatePlugins()
656 splash.showMessage(self.tr("Generating Plugins Toolbars...")) 661 splash.showMessage(self.tr("Generating Plugins Toolbars..."))
657 self.pluginManager.initPluginToolbars(self.toolbarManager) 662 self.pluginManager.initPluginToolbars(self.toolbarManager)
658 if Preferences.getPluginManager("StartupCleanup"): 663 if Preferences.getPluginManager("StartupCleanup"):
659 splash.showMessage(self.tr("Cleaning Plugins Download Area...")) 664 splash.showMessage(self.tr("Cleaning Plugins Download Area..."))
660 from PluginManager.PluginRepositoryDialog import \ 665 from PluginManager.PluginRepositoryDialog import (
661 PluginRepositoryDownloadCleanup 666 PluginRepositoryDownloadCleanup
667 )
662 PluginRepositoryDownloadCleanup(quiet=True) 668 PluginRepositoryDownloadCleanup(quiet=True)
663 669
664 # now read the keyboard shortcuts for all the actions 670 # now read the keyboard shortcuts for all the actions
665 from Preferences import Shortcuts 671 from Preferences import Shortcuts
666 Shortcuts.readShortcuts() 672 Shortcuts.readShortcuts()
738 @exception ValueError raised to indicate an invalid layout type 744 @exception ValueError raised to indicate an invalid layout type
739 """ 745 """
740 # Create the view manager depending on the configuration setting 746 # Create the view manager depending on the configuration setting
741 logging.debug("Creating Viewmanager...") 747 logging.debug("Creating Viewmanager...")
742 import ViewManager 748 import ViewManager
743 self.viewmanager = \ 749 self.viewmanager = ViewManager.factory(
744 ViewManager.factory(self, self, debugServer, self.pluginManager) 750 self, self, debugServer, self.pluginManager)
745 leftWidget = QWidget() 751 leftWidget = QWidget()
746 layout = QVBoxLayout() 752 layout = QVBoxLayout()
747 layout.setContentsMargins(1, 1, 1, 1) 753 layout.setContentsMargins(1, 1, 1, 1)
748 layout.setSpacing(1) 754 layout.setSpacing(1)
749 layout.addWidget(self.viewmanager.mainWidget()) 755 layout.addWidget(self.viewmanager.mainWidget())
971 elif self.__shellPosition == "right": 977 elif self.__shellPosition == "right":
972 self.__shellParent = self.rToolboxDock 978 self.__shellParent = self.rToolboxDock
973 else: 979 else:
974 self.__shellParent = self.hToolboxDock 980 self.__shellParent = self.hToolboxDock
975 from QScintilla.Shell import ShellAssembly 981 from QScintilla.Shell import ShellAssembly
976 self.shellAssembly = \ 982 self.shellAssembly = ShellAssembly(
977 ShellAssembly(debugServer, self.viewmanager, self.project, True) 983 debugServer, self.viewmanager, self.project, True)
978 self.shell = self.shellAssembly.shell() 984 self.shell = self.shellAssembly.shell()
979 self.__shellParent.widget().insertItem( 985 self.__shellParent.widget().insertItem(
980 0, self.shellAssembly, UI.PixmapCache.getIcon("shell.png"), 986 0, self.shellAssembly, UI.PixmapCache.getIcon("shell.png"),
981 self.tr("Shell")) 987 self.tr("Shell"))
982 988
1168 elif self.__shellPosition == "right": 1174 elif self.__shellPosition == "right":
1169 self.__shellParent = self.rightSidebar 1175 self.__shellParent = self.rightSidebar
1170 else: 1176 else:
1171 self.__shellParent = self.bottomSidebar 1177 self.__shellParent = self.bottomSidebar
1172 from QScintilla.Shell import ShellAssembly 1178 from QScintilla.Shell import ShellAssembly
1173 self.shellAssembly = \ 1179 self.shellAssembly = ShellAssembly(
1174 ShellAssembly(debugServer, self.viewmanager, self.project, True) 1180 debugServer, self.viewmanager, self.project, True)
1175 self.shell = self.shellAssembly.shell() 1181 self.shell = self.shellAssembly.shell()
1176 self.__shellParent.insertTab(0, self.shellAssembly, 1182 self.__shellParent.insertTab(0, self.shellAssembly,
1177 UI.PixmapCache.getIcon("shell.png"), 1183 UI.PixmapCache.getIcon("shell.png"),
1178 self.tr("Shell")) 1184 self.tr("Shell"))
1179 1185
1467 1473
1468 @param editor filename to be displayed (string) 1474 @param editor filename to be displayed (string)
1469 @param project project name to be displayed (string) 1475 @param project project name to be displayed (string)
1470 """ 1476 """
1471 if editor is not None and self.captionShowsFilename: 1477 if editor is not None and self.captionShowsFilename:
1472 self.capEditor = \ 1478 self.capEditor = Utilities.compactPath(editor, self.maxFilePathLen)
1473 Utilities.compactPath(editor, self.maxFilePathLen)
1474 if project is not None: 1479 if project is not None:
1475 self.capProject = project 1480 self.capProject = project
1476 1481
1477 if self.passiveMode: 1482 if self.passiveMode:
1478 if not self.capProject and not self.capEditor: 1483 if not self.capProject and not self.capEditor:
2902 """ 2907 """
2903 Private slot to create the menus. 2908 Private slot to create the menus.
2904 """ 2909 """
2905 self.__menus = {} 2910 self.__menus = {}
2906 mb = self.menuBar() 2911 mb = self.menuBar()
2907 if Utilities.isLinuxPlatform() and \ 2912 if (
2908 not Preferences.getUI("UseNativeMenuBar"): 2913 Utilities.isLinuxPlatform() and
2914 not Preferences.getUI("UseNativeMenuBar")
2915 ):
2909 mb.setNativeMenuBar(False) 2916 mb.setNativeMenuBar(False)
2910 2917
2911 ############################################################## 2918 ##############################################################
2912 ## File menu 2919 ## File menu
2913 ############################################################## 2920 ##############################################################
2963 2970
2964 ############################################################## 2971 ##############################################################
2965 ## Project menu 2972 ## Project menu
2966 ############################################################## 2973 ##############################################################
2967 2974
2968 self.__menus["project"], self.__menus["project_tools"] = \ 2975 self.__menus["project"], self.__menus["project_tools"] = (
2969 self.project.initMenus() 2976 self.project.initMenus()
2977 )
2970 mb.addMenu(self.__menus["project"]) 2978 mb.addMenu(self.__menus["project"])
2971 mb.addMenu(self.__menus["project_tools"]) 2979 mb.addMenu(self.__menus["project_tools"])
2972 2980
2973 ############################################################## 2981 ##############################################################
2974 ## Start and Debug menus 2982 ## Start and Debug menus
2975 ############################################################## 2983 ##############################################################
2976 2984
2977 self.__menus["start"], self.__menus["debug"] = \ 2985 self.__menus["start"], self.__menus["debug"] = (
2978 self.debuggerUI.initMenus() 2986 self.debuggerUI.initMenus()
2987 )
2979 mb.addMenu(self.__menus["start"]) 2988 mb.addMenu(self.__menus["start"])
2980 mb.addMenu(self.__menus["debug"]) 2989 mb.addMenu(self.__menus["debug"])
2981 2990
2982 ############################################################## 2991 ##############################################################
2983 ## Extras menu 2992 ## Extras menu
3156 3165
3157 ############################################################## 3166 ##############################################################
3158 ## Window/Toolbars menu 3167 ## Window/Toolbars menu
3159 ############################################################## 3168 ##############################################################
3160 3169
3161 self.__menus["toolbars"] = \ 3170 self.__menus["toolbars"] = QMenu(
3162 QMenu(self.tr("&Toolbars"), self.__menus["window"]) 3171 self.tr("&Toolbars"), self.__menus["window"])
3163 self.__menus["toolbars"].setTearOffEnabled(True) 3172 self.__menus["toolbars"].setTearOffEnabled(True)
3164 self.__menus["toolbars"].aboutToShow.connect(self.__showToolbarsMenu) 3173 self.__menus["toolbars"].aboutToShow.connect(self.__showToolbarsMenu)
3165 self.__menus["toolbars"].triggered.connect(self.__TBMenuTriggered) 3174 self.__menus["toolbars"].triggered.connect(self.__TBMenuTriggered)
3166 3175
3167 self.__showWindowMenu() # to initialize these actions 3176 self.__showWindowMenu() # to initialize these actions
3635 sizeStr = "32-Bit" 3644 sizeStr = "32-Bit"
3636 3645
3637 versionText = self.tr( 3646 versionText = self.tr(
3638 """<h3>Version Numbers</h3>""" 3647 """<h3>Version Numbers</h3>"""
3639 """<table>""") 3648 """<table>""")
3640 versionText += """<tr><td><b>Python</b></td><td>{0}, {1}</td></tr>"""\ 3649 versionText += (
3641 .format(sys.version.split()[0], sizeStr) 3650 """<tr><td><b>Python</b></td><td>{0}, {1}</td></tr>"""
3642 versionText += """<tr><td><b>Qt</b></td><td>{0}</td></tr>"""\ 3651 ).format(sys.version.split()[0], sizeStr)
3643 .format(qVersion()) 3652 versionText += (
3644 versionText += """<tr><td><b>PyQt</b></td><td>{0}</td></tr>"""\ 3653 """<tr><td><b>Qt</b></td><td>{0}</td></tr>"""
3645 .format(PYQT_VERSION_STR) 3654 ).format(qVersion())
3646 versionText += """<tr><td><b>sip</b></td><td>{0}</td></tr>"""\ 3655 versionText += (
3647 .format(sip_version_str) 3656 """<tr><td><b>PyQt</b></td><td>{0}</td></tr>"""
3648 versionText += """<tr><td><b>QScintilla</b></td><td>{0}</td></tr>"""\ 3657 ).format(PYQT_VERSION_STR)
3649 .format(QSCINTILLA_VERSION_STR) 3658 versionText += (
3659 """<tr><td><b>sip</b></td><td>{0}</td></tr>"""
3660 ).format(sip_version_str)
3661 versionText += (
3662 """<tr><td><b>QScintilla</b></td><td>{0}</td></tr>"""
3663 ).format(QSCINTILLA_VERSION_STR)
3650 try: 3664 try:
3651 from WebBrowser.Tools import WebBrowserTools 3665 from WebBrowser.Tools import WebBrowserTools
3652 chromeVersion = WebBrowserTools.getWebEngineVersions()[0] 3666 chromeVersion = WebBrowserTools.getWebEngineVersions()[0]
3653 versionText += \ 3667 versionText += (
3654 """<tr><td><b>WebEngine</b></td><td>{0}</td></tr>"""\ 3668 """<tr><td><b>WebEngine</b></td><td>{0}</td></tr>"""
3655 .format(chromeVersion) 3669 ).format(chromeVersion)
3656 except ImportError: 3670 except ImportError:
3657 pass 3671 pass
3658 versionText += """<tr><td><b>{0}</b></td><td>{1}</td></tr>"""\ 3672 versionText += ("""<tr><td><b>{0}</b></td><td>{1}</td></tr>"""
3659 .format(Program, Version) 3673 ).format(Program, Version)
3660 versionText += self.tr("""</table>""") 3674 versionText += self.tr("""</table>""")
3661 3675
3662 E5MessageBox.about(self, Program, versionText) 3676 E5MessageBox.about(self, Program, versionText)
3663 3677
3664 def __reportBug(self): 3678 def __reportBug(self):
4268 self.profiles[self.currentProfile][2][4] = state 4282 self.profiles[self.currentProfile][2][4] = state
4269 state = self.rightSidebar.saveState() 4283 state = self.rightSidebar.saveState()
4270 self.profiles[self.currentProfile][2][5] = state 4284 self.profiles[self.currentProfile][2][5] = state
4271 # step 2: save the visibility of the windows of the active profile 4285 # step 2: save the visibility of the windows of the active profile
4272 if self.__layoutType == "Toolboxes": 4286 if self.__layoutType == "Toolboxes":
4273 self.profiles[self.currentProfile][1][0] = \ 4287 self.profiles[self.currentProfile][1][0] = (
4274 self.lToolboxDock.isVisible() 4288 self.lToolboxDock.isVisible()
4275 self.profiles[self.currentProfile][1][1] = \ 4289 )
4290 self.profiles[self.currentProfile][1][1] = (
4276 self.hToolboxDock.isVisible() 4291 self.hToolboxDock.isVisible()
4277 self.profiles[self.currentProfile][1][2] = \ 4292 )
4293 self.profiles[self.currentProfile][1][2] = (
4278 self.rToolboxDock.isVisible() 4294 self.rToolboxDock.isVisible()
4295 )
4279 elif self.__layoutType == "Sidebars": 4296 elif self.__layoutType == "Sidebars":
4280 self.profiles[self.currentProfile][1][0] = \ 4297 self.profiles[self.currentProfile][1][0] = (
4281 self.leftSidebar.isVisible() 4298 self.leftSidebar.isVisible()
4282 self.profiles[self.currentProfile][1][1] = \ 4299 )
4300 self.profiles[self.currentProfile][1][1] = (
4283 self.bottomSidebar.isVisible() 4301 self.bottomSidebar.isVisible()
4284 self.profiles[self.currentProfile][1][2] = \ 4302 )
4303 self.profiles[self.currentProfile][1][2] = (
4285 self.rightSidebar.isVisible() 4304 self.rightSidebar.isVisible()
4305 )
4286 Preferences.setUI("ViewProfiles2", self.profiles) 4306 Preferences.setUI("ViewProfiles2", self.profiles)
4287 4307
4288 def __activateViewProfile(self, name, save=True): 4308 def __activateViewProfile(self, name, save=True):
4289 """ 4309 """
4290 Private slot to activate a view profile. 4310 Private slot to activate a view profile.
4751 4771
4752 def __toolGroupsConfiguration(self): 4772 def __toolGroupsConfiguration(self):
4753 """ 4773 """
4754 Private slot to handle the tool groups configuration menu entry. 4774 Private slot to handle the tool groups configuration menu entry.
4755 """ 4775 """
4756 from Preferences.ToolGroupConfigurationDialog import \ 4776 from Preferences.ToolGroupConfigurationDialog import (
4757 ToolGroupConfigurationDialog 4777 ToolGroupConfigurationDialog
4778 )
4758 dlg = ToolGroupConfigurationDialog( 4779 dlg = ToolGroupConfigurationDialog(
4759 self.toolGroups, self.currentToolGroup, self) 4780 self.toolGroups, self.currentToolGroup, self)
4760 if dlg.exec_() == QDialog.Accepted: 4781 if dlg.exec_() == QDialog.Accepted:
4761 self.toolGroups, self.currentToolGroup = dlg.getToolGroups() 4782 self.toolGroups, self.currentToolGroup = dlg.getToolGroups()
4762 4783
4952 4973
4953 args = [] 4974 args = []
4954 if fn is not None: 4975 if fn is not None:
4955 fn = fn.replace('.qm', '.ts') 4976 fn = fn.replace('.qm', '.ts')
4956 try: 4977 try:
4957 if os.path.isfile(fn) and os.path.getsize(fn) and \ 4978 if (
4958 fn not in args: 4979 os.path.isfile(fn) and
4980 os.path.getsize(fn) and
4981 fn not in args
4982 ):
4959 args.append(fn) 4983 args.append(fn)
4960 else: 4984 else:
4961 E5MessageBox.critical( 4985 E5MessageBox.critical(
4962 self, 4986 self,
4963 self.tr('Problem'), 4987 self.tr('Problem'),
5148 '<p>The file <b>{0}</b> does not exist or' 5172 '<p>The file <b>{0}</b> does not exist or'
5149 ' is zero length.</p>') 5173 ' is zero length.</p>')
5150 .format(fn)) 5174 .format(fn))
5151 return 5175 return
5152 5176
5153 if not os.path.isfile(viewer) or \ 5177 if (
5154 not proc.startDetached(sys.executable, args): 5178 not os.path.isfile(viewer) or
5179 not proc.startDetached(sys.executable, args)
5180 ):
5155 E5MessageBox.critical( 5181 E5MessageBox.critical(
5156 self, 5182 self,
5157 self.tr('Process Generation Error'), 5183 self.tr('Process Generation Error'),
5158 self.tr( 5184 self.tr(
5159 '<p>Could not start UI Previewer.<br>' 5185 '<p>Could not start UI Previewer.<br>'
5203 '<p>The file <b>{0}</b> does not exist or' 5229 '<p>The file <b>{0}</b> does not exist or'
5204 ' is zero length.</p>') 5230 ' is zero length.</p>')
5205 .format(fn)) 5231 .format(fn))
5206 return 5232 return
5207 5233
5208 if not os.path.isfile(viewer) or \ 5234 if (
5209 not proc.startDetached(sys.executable, args): 5235 not os.path.isfile(viewer) or
5236 not proc.startDetached(sys.executable, args)
5237 ):
5210 E5MessageBox.critical( 5238 E5MessageBox.critical(
5211 self, 5239 self,
5212 self.tr('Process Generation Error'), 5240 self.tr('Process Generation Error'),
5213 self.tr( 5241 self.tr(
5214 '<p>Could not start Translation Previewer.<br>' 5242 '<p>Could not start Translation Previewer.<br>'
5224 browser = os.path.join(getConfig("ericDir"), "eric6_sqlbrowser.py") 5252 browser = os.path.join(getConfig("ericDir"), "eric6_sqlbrowser.py")
5225 5253
5226 args = [] 5254 args = []
5227 args.append(browser) 5255 args.append(browser)
5228 5256
5229 if not os.path.isfile(browser) or \ 5257 if (
5230 not proc.startDetached(sys.executable, args): 5258 not os.path.isfile(browser) or
5259 not proc.startDetached(sys.executable, args)
5260 ):
5231 E5MessageBox.critical( 5261 E5MessageBox.critical(
5232 self, 5262 self,
5233 self.tr('Process Generation Error'), 5263 self.tr('Process Generation Error'),
5234 self.tr( 5264 self.tr(
5235 '<p>Could not start SQL Browser.<br>' 5265 '<p>Could not start SQL Browser.<br>'
5294 snap = os.path.join(getConfig("ericDir"), "eric6_snap.py") 5324 snap = os.path.join(getConfig("ericDir"), "eric6_snap.py")
5295 5325
5296 args = [] 5326 args = []
5297 args.append(snap) 5327 args.append(snap)
5298 5328
5299 if not os.path.isfile(snap) or \ 5329 if (
5300 not proc.startDetached(sys.executable, args): 5330 not os.path.isfile(snap) or
5331 not proc.startDetached(sys.executable, args)
5332 ):
5301 E5MessageBox.critical( 5333 E5MessageBox.critical(
5302 self, 5334 self,
5303 self.tr('Process Generation Error'), 5335 self.tr('Process Generation Error'),
5304 self.tr( 5336 self.tr(
5305 '<p>Could not start Snapshot tool.<br>' 5337 '<p>Could not start Snapshot tool.<br>'
5367 procData = (None,) 5399 procData = (None,)
5368 program = tool['executable'] 5400 program = tool['executable']
5369 args = [] 5401 args = []
5370 argv = Utilities.parseOptionString(tool['arguments']) 5402 argv = Utilities.parseOptionString(tool['arguments'])
5371 args.extend(argv) 5403 args.extend(argv)
5372 t = self.tr("Starting process '{0} {1}'.\n")\ 5404 t = self.tr("Starting process '{0} {1}'.\n"
5373 .format(program, tool['arguments']) 5405 ).format(program, tool['arguments'])
5374 self.appendToStdout(t) 5406 self.appendToStdout(t)
5375 5407
5376 proc.finished.connect(self.__toolFinished) 5408 proc.finished.connect(self.__toolFinished)
5377 if tool['redirect'] != 'no': 5409 if tool['redirect'] != 'no':
5378 proc.readyReadStandardOutput.connect(self.__processToolStdout) 5410 proc.readyReadStandardOutput.connect(self.__processToolStdout)
5407 5439
5408 # loop through all running tool processes 5440 # loop through all running tool processes
5409 for program, toolProc, toolProcData in self.toolProcs: 5441 for program, toolProc, toolProcData in self.toolProcs:
5410 toolProc.setReadChannel(QProcess.StandardOutput) 5442 toolProc.setReadChannel(QProcess.StandardOutput)
5411 5443
5412 if toolProcData[0] is None or \ 5444 if (
5413 toolProcData[1] not in ["insert", "replaceSelection"]: 5445 toolProcData[0] is None or
5446 toolProcData[1] not in ["insert", "replaceSelection"]
5447 ):
5414 # not connected to an editor or wrong mode 5448 # not connected to an editor or wrong mode
5415 while toolProc.canReadLine(): 5449 while toolProc.canReadLine():
5416 output = str(toolProc.readLine(), ioEncoding, 'replace') 5450 output = str(toolProc.readLine(), ioEncoding, 'replace')
5417 s = "{0} - {1}".format(program, output) 5451 s = "{0} - {1}".format(program, output)
5418 self.appendToStdout(s) 5452 self.appendToStdout(s)
5470 """ 5504 """
5471 pythonDocDir = Preferences.getHelp("PythonDocDir") 5505 pythonDocDir = Preferences.getHelp("PythonDocDir")
5472 if not pythonDocDir: 5506 if not pythonDocDir:
5473 if Utilities.isWindowsPlatform(): 5507 if Utilities.isWindowsPlatform():
5474 venvName = Preferences.getDebugger("Python3VirtualEnv") 5508 venvName = Preferences.getDebugger("Python3VirtualEnv")
5475 interpreter = e5App().getObject("VirtualEnvManager")\ 5509 interpreter = (
5510 e5App().getObject("VirtualEnvManager")
5476 .getVirtualenvInterpreter(venvName) 5511 .getVirtualenvInterpreter(venvName)
5512 )
5477 if interpreter: 5513 if interpreter:
5478 default = os.path.join(os.path.dirname(interpreter), "doc") 5514 default = os.path.join(os.path.dirname(interpreter), "doc")
5479 else: 5515 else:
5480 default = "" 5516 default = ""
5481 pythonDocDir = \ 5517 pythonDocDir = Utilities.getEnvironmentEntry(
5482 Utilities.getEnvironmentEntry("PYTHON3DOCDIR", default) 5518 "PYTHON3DOCDIR", default)
5483 else: 5519 else:
5484 pythonDocDir = Utilities.getEnvironmentEntry( 5520 pythonDocDir = Utilities.getEnvironmentEntry(
5485 "PYTHON3DOCDIR", 5521 "PYTHON3DOCDIR",
5486 '/usr/share/doc/packages/python3/html') 5522 '/usr/share/doc/packages/python3/html')
5487 if not pythonDocDir.startswith(("http://", "https://", "qthelp://")): 5523 if not pythonDocDir.startswith(("http://", "https://", "qthelp://")):
5538 """ 5574 """
5539 pythonDocDir = Preferences.getHelp("Python2DocDir") 5575 pythonDocDir = Preferences.getHelp("Python2DocDir")
5540 if not pythonDocDir: 5576 if not pythonDocDir:
5541 if Utilities.isWindowsPlatform(): 5577 if Utilities.isWindowsPlatform():
5542 venvName = Preferences.getDebugger("Python2VirtualEnv") 5578 venvName = Preferences.getDebugger("Python2VirtualEnv")
5543 interpreter = e5App().getObject("VirtualEnvManager")\ 5579 interpreter = (
5580 e5App().getObject("VirtualEnvManager")
5544 .getVirtualenvInterpreter(venvName) 5581 .getVirtualenvInterpreter(venvName)
5582 )
5545 if interpreter: 5583 if interpreter:
5546 default = os.path.join(os.path.dirname(interpreter), "doc") 5584 default = os.path.join(os.path.dirname(interpreter), "doc")
5547 else: 5585 else:
5548 default = "" 5586 default = ""
5549 pythonDocDir = \ 5587 pythonDocDir = Utilities.getEnvironmentEntry(
5550 Utilities.getEnvironmentEntry("PYTHON2DOCDIR", default) 5588 "PYTHON2DOCDIR", default)
5551 else: 5589 else:
5552 pythonDocDir = Utilities.getEnvironmentEntry( 5590 pythonDocDir = Utilities.getEnvironmentEntry(
5553 "PYTHON2DOCDIR", 5591 "PYTHON2DOCDIR",
5554 '/usr/share/doc/packages/python/html') 5592 '/usr/share/doc/packages/python/html')
5555 if not pythonDocDir.startswith(("http://", "https://", "qthelp://")): 5593 if not pythonDocDir.startswith(("http://", "https://", "qthelp://")):
5992 @type QProcess 6030 @type QProcess
5993 @return error indication (1 = connection not possible, 0 = ok, 6031 @return error indication (1 = connection not possible, 0 = ok,
5994 -1 = server exited with an error code) 6032 -1 = server exited with an error code)
5995 @rtype int 6033 @rtype int
5996 """ 6034 """
5997 from WebBrowser.WebBrowserSingleApplication import \ 6035 from WebBrowser.WebBrowserSingleApplication import (
5998 WebBrowserSingleApplicationClient 6036 WebBrowserSingleApplicationClient
6037 )
5999 6038
6000 webBrowserClient = WebBrowserSingleApplicationClient( 6039 webBrowserClient = WebBrowserSingleApplicationClient(
6001 self.__webBrowserSAName) 6040 self.__webBrowserSAName)
6002 connectCount = 30 6041 connectCount = 30
6003 while connectCount: 6042 while connectCount:
6006 break 6045 break
6007 else: 6046 else:
6008 connectCount -= 1 6047 connectCount -= 1
6009 QThread.msleep(1000) 6048 QThread.msleep(1000)
6010 QApplication.processEvents() 6049 QApplication.processEvents()
6011 if process.state() == QProcess.NotRunning and \ 6050 if (
6012 process.exitStatus() == QProcess.NormalExit and \ 6051 process.state() == QProcess.NotRunning and
6013 process.exitCode() == 100: 6052 process.exitStatus() == QProcess.NormalExit and
6053 process.exitCode() == 100
6054 ):
6014 # Process exited prematurely due to missing pre-requisites 6055 # Process exited prematurely due to missing pre-requisites
6015 return -1 6056 return -1
6016 if res <= 0: 6057 if res <= 0:
6017 E5MessageBox.warning( 6058 E5MessageBox.warning(
6018 self, 6059 self,
6096 QApplication.processEvents() 6137 QApplication.processEvents()
6097 if self.__configurationDialog.result() == QDialog.Accepted: 6138 if self.__configurationDialog.result() == QDialog.Accepted:
6098 self.__configurationDialog.setPreferences() 6139 self.__configurationDialog.setPreferences()
6099 Preferences.syncPreferences() 6140 Preferences.syncPreferences()
6100 self.__preferencesChanged() 6141 self.__preferencesChanged()
6101 self.__lastConfigurationPageName = \ 6142 self.__lastConfigurationPageName = (
6102 self.__configurationDialog.getConfigurationPageName() 6143 self.__configurationDialog.getConfigurationPageName()
6103 self.__expandedConfigurationEntries = \ 6144 )
6145 self.__expandedConfigurationEntries = (
6104 self.__configurationDialog.getExpandedEntries() 6146 self.__configurationDialog.getExpandedEntries()
6147 )
6105 6148
6106 self.__configurationDialog.deleteLater() 6149 self.__configurationDialog.deleteLater()
6107 self.__configurationDialog = None 6150 self.__configurationDialog = None
6108 6151
6109 def __exportPreferences(self): 6152 def __exportPreferences(self):
6199 6242
6200 self.masterPasswordChanged.emit(oldPassword, newPassword) 6243 self.masterPasswordChanged.emit(oldPassword, newPassword)
6201 Preferences.convertPasswords(oldPassword, newPassword) 6244 Preferences.convertPasswords(oldPassword, newPassword)
6202 variant = Globals.getWebBrowserSupport() 6245 variant = Globals.getWebBrowserSupport()
6203 if variant == "QtWebEngine": 6246 if variant == "QtWebEngine":
6204 from WebBrowser.Passwords.PasswordManager import \ 6247 from WebBrowser.Passwords.PasswordManager import (
6205 PasswordManager 6248 PasswordManager
6249 )
6206 pwManager = PasswordManager() 6250 pwManager = PasswordManager()
6207 pwManager.masterPasswordChanged(oldPassword, newPassword) 6251 pwManager.masterPasswordChanged(oldPassword, newPassword)
6208 Utilities.crypto.changeRememberedMaster(newPassword) 6252 Utilities.crypto.changeRememberedMaster(newPassword)
6209 6253
6210 def __reloadAPIs(self): 6254 def __reloadAPIs(self):
6314 from .ClearPrivateDataDialog import ClearPrivateDataDialog 6358 from .ClearPrivateDataDialog import ClearPrivateDataDialog
6315 dlg = ClearPrivateDataDialog(self) 6359 dlg = ClearPrivateDataDialog(self)
6316 if dlg.exec_() == QDialog.Accepted: 6360 if dlg.exec_() == QDialog.Accepted:
6317 # recent files, recent projects, recent multi projects, 6361 # recent files, recent projects, recent multi projects,
6318 # debug histories, shell histories 6362 # debug histories, shell histories
6319 (files, projects, multiProjects, debug, shell, vcs, plugins) = \ 6363 (files, projects, multiProjects, debug, shell, vcs, plugins) = (
6320 dlg.getData() 6364 dlg.getData()
6365 )
6321 if files: 6366 if files:
6322 # clear list of recently opened files 6367 # clear list of recently opened files
6323 self.viewmanager.clearRecent() 6368 self.viewmanager.clearRecent()
6324 if projects: 6369 if projects:
6325 # clear list of recently opened projects and other histories 6370 # clear list of recently opened projects and other histories
6352 """ 6397 """
6353 Private slot to handle the projectOpened signal. 6398 Private slot to handle the projectOpened signal.
6354 """ 6399 """
6355 from Debugger.DebugClientCapabilities import HasUnittest 6400 from Debugger.DebugClientCapabilities import HasUnittest
6356 self.__setWindowCaption(project=self.project.name) 6401 self.__setWindowCaption(project=self.project.name)
6357 cap = e5App().getObject("DebugServer")\ 6402 cap = e5App().getObject("DebugServer").getClientCapabilities(
6358 .getClientCapabilities(self.project.getProjectLanguage()) 6403 self.project.getProjectLanguage())
6359 self.utProjectAct.setEnabled(cap & HasUnittest) 6404 self.utProjectAct.setEnabled(cap & HasUnittest)
6360 self.utProjectOpen = cap & HasUnittest 6405 self.utProjectOpen = cap & HasUnittest
6361 6406
6362 def __projectClosed(self): 6407 def __projectClosed(self):
6363 """ 6408 """
6630 6675
6631 def __writeCrashSession(self): 6676 def __writeCrashSession(self):
6632 """ 6677 """
6633 Private slot to write a crash session file. 6678 Private slot to write a crash session file.
6634 """ 6679 """
6635 if not self.__readingSession and \ 6680 if (
6636 not self.__disableCrashSession and \ 6681 not self.__readingSession and
6637 Preferences.getUI("CrashSessionEnabled"): 6682 not self.__disableCrashSession and
6683 Preferences.getUI("CrashSessionEnabled")
6684 ):
6638 self.__writeSession(crashSession=True) 6685 self.__writeSession(crashSession=True)
6639 6686
6640 def __readCrashSession(self): 6687 def __readCrashSession(self):
6641 """ 6688 """
6642 Private method to check for and read a crash session. 6689 Private method to check for and read a crash session.
6643 6690
6644 @return flag indicating a crash session file was found and read 6691 @return flag indicating a crash session file was found and read
6645 @rtype bool 6692 @rtype bool
6646 """ 6693 """
6647 res = False 6694 res = False
6648 if not self.__disableCrashSession and \ 6695 if (
6649 not self.__noCrashOpenAtStartup and \ 6696 not self.__disableCrashSession and
6650 Preferences.getUI("OpenCrashSessionOnStartup"): 6697 not self.__noCrashOpenAtStartup and
6698 Preferences.getUI("OpenCrashSessionOnStartup")
6699 ):
6651 fn = os.path.join(Utilities.getConfigDir(), 6700 fn = os.path.join(Utilities.getConfigDir(),
6652 "eric6_crash_session.e5s") 6701 "eric6_crash_session.e5s")
6653 if os.path.exists(fn): 6702 if os.path.exists(fn):
6654 yes = E5MessageBox.yesNo( 6703 yes = E5MessageBox.yesNo(
6655 self, 6704 self,
6705 @keyparam searchDir directory to search in (string) 6754 @keyparam searchDir directory to search in (string)
6706 @keyparam openFiles flag indicating to operate on open files (boolean) 6755 @keyparam openFiles flag indicating to operate on open files (boolean)
6707 """ 6756 """
6708 if self.replaceFilesDialog is None: 6757 if self.replaceFilesDialog is None:
6709 from .FindFileDialog import FindFileDialog 6758 from .FindFileDialog import FindFileDialog
6710 self.replaceFilesDialog = \ 6759 self.replaceFilesDialog = FindFileDialog(
6711 FindFileDialog(self.project, replaceMode=True) 6760 self.project, replaceMode=True)
6712 self.replaceFilesDialog.sourceFile.connect( 6761 self.replaceFilesDialog.sourceFile.connect(
6713 self.viewmanager.openSourceFile) 6762 self.viewmanager.openSourceFile)
6714 self.replaceFilesDialog.designerFile.connect(self.__designer) 6763 self.replaceFilesDialog.designerFile.connect(self.__designer)
6715 if searchDir: 6764 if searchDir:
6716 self.replaceFilesDialog.setSearchDirectory(searchDir) 6765 self.replaceFilesDialog.setSearchDirectory(searchDir)
7079 self.__replies.remove(reply) 7128 self.__replies.remove(reply)
7080 if reply.error() == QNetworkReply.NoError: 7129 if reply.error() == QNetworkReply.NoError:
7081 ioEncoding = Preferences.getSystem("IOEncoding") 7130 ioEncoding = Preferences.getSystem("IOEncoding")
7082 versions = str(reply.readAll(), ioEncoding, 'replace').splitlines() 7131 versions = str(reply.readAll(), ioEncoding, 'replace').splitlines()
7083 reply.close() 7132 reply.close()
7084 if reply.error() != QNetworkReply.NoError or \ 7133 if (
7085 len(versions) == 0 or \ 7134 reply.error() != QNetworkReply.NoError or
7086 versions[0].startswith("<"): 7135 len(versions) == 0 or
7136 versions[0].startswith("<")
7137 ):
7087 # network error or an error page 7138 # network error or an error page
7088 self.httpAlternative += 1 7139 self.httpAlternative += 1
7089 if self.httpAlternative >= len(self.__httpAlternatives): 7140 if self.httpAlternative >= len(self.__httpAlternatives):
7090 self.__inVersionCheck = False 7141 self.__inVersionCheck = False
7091 if self.__versionCheckProgress is not None: 7142 if self.__versionCheckProgress is not None:
7245 line = 0 7296 line = 0
7246 while line < len(versions): 7297 while line < len(versions):
7247 if versions[line] == "---": 7298 if versions[line] == "---":
7248 break 7299 break
7249 7300
7250 versionText += """<tr><td>{0}</td><td><a href="{1}">{2}</a>""" \ 7301 versionText += (
7251 """</td></tr>""".format( 7302 """<tr><td>{0}</td><td><a href="{1}">{2}</a></td></tr>"""
7252 versions[line], versions[line + 1], 7303 ).format(
7253 'sourceforge' in versions[line + 1] and 7304 versions[line], versions[line + 1],
7254 "SourceForge" or versions[line + 1]) 7305 'sourceforge' in versions[line + 1] and
7306 "SourceForge" or versions[line + 1])
7255 line += 2 7307 line += 2
7256 versionText += self.tr("""</table>""") 7308 versionText += self.tr("""</table>""")
7257 7309
7258 self.__versionsDialog = E5MessageBox.E5MessageBox( 7310 self.__versionsDialog = E5MessageBox.E5MessageBox(
7259 E5MessageBox.NoIcon, 7311 E5MessageBox.NoIcon,

eric ide

mercurial