81 from eric7.PluginManager.PluginRepositoryDialog import PluginRepositoryDownloadCleanup |
81 from eric7.PluginManager.PluginRepositoryDialog import PluginRepositoryDownloadCleanup |
82 from eric7.Preferences import Shortcuts |
82 from eric7.Preferences import Shortcuts |
83 from eric7.Project.Project import Project |
83 from eric7.Project.Project import Project |
84 from eric7.QScintilla.SpellChecker import SpellChecker |
84 from eric7.QScintilla.SpellChecker import SpellChecker |
85 from eric7.Sessions.SessionFile import SessionFile |
85 from eric7.Sessions.SessionFile import SessionFile |
|
86 from eric7.SystemUtilities import ( |
|
87 DesktopUtilities, |
|
88 FileSystemUtilities, |
|
89 OSUtilities, |
|
90 PythonUtilities, |
|
91 QtUtilities, |
|
92 ) |
86 from eric7.Tasks.TasksFile import TasksFile |
93 from eric7.Tasks.TasksFile import TasksFile |
87 from eric7.Testing.TestingWidget import clearSavedHistories |
94 from eric7.Testing.TestingWidget import clearSavedHistories |
88 from eric7.Utilities.BackgroundService import BackgroundService |
95 from eric7.Utilities.BackgroundService import BackgroundService |
89 from eric7.VirtualEnv.VirtualenvManager import VirtualenvManager |
96 from eric7.VirtualEnv.VirtualenvManager import VirtualenvManager |
90 |
97 |
1623 # holds space delimited list of command args, if any |
1630 # holds space delimited list of command args, if any |
1624 argsStr = None |
1631 argsStr = None |
1625 # flag indicating '--' options was found |
1632 # flag indicating '--' options was found |
1626 ddseen = False |
1633 ddseen = False |
1627 |
1634 |
1628 argChars = ["-", "/"] if Utilities.isWindowsPlatform() else ["-"] |
1635 argChars = ["-", "/"] if OSUtilities.isWindowsPlatform() else ["-"] |
1629 |
1636 |
1630 for arg in args: |
1637 for arg in args: |
1631 # handle a request to start with last session |
1638 # handle a request to start with last session |
1632 if arg == "--start-file": |
1639 if arg == "--start-file": |
1633 self.__openOnStartup("File") |
1640 self.__openOnStartup("File") |
1808 |
1815 |
1809 @param editor filename to be displayed (string) |
1816 @param editor filename to be displayed (string) |
1810 @param project project name to be displayed (string) |
1817 @param project project name to be displayed (string) |
1811 """ |
1818 """ |
1812 if editor is not None and self.captionShowsFilename: |
1819 if editor is not None and self.captionShowsFilename: |
1813 self.capEditor = Utilities.compactPath(editor, self.maxFilePathLen) |
1820 self.capEditor = FileSystemUtilities.compactPath( |
|
1821 editor, self.maxFilePathLen |
|
1822 ) |
1814 if project is not None: |
1823 if project is not None: |
1815 self.capProject = project |
1824 self.capProject = project |
1816 |
1825 |
1817 if self.passiveMode: |
1826 if self.passiveMode: |
1818 if not self.capProject and not self.capEditor: |
1827 if not self.capProject and not self.capEditor: |
2882 self.testProjectAct.triggered.connect(self.__startTestProject) |
2891 self.testProjectAct.triggered.connect(self.__startTestProject) |
2883 self.testProjectAct.setEnabled(False) |
2892 self.testProjectAct.setEnabled(False) |
2884 self.actions.append(self.testProjectAct) |
2893 self.actions.append(self.testProjectAct) |
2885 |
2894 |
2886 # check for Qt5 designer and linguist |
2895 # check for Qt5 designer and linguist |
2887 if Utilities.isWindowsPlatform(): |
2896 if OSUtilities.isWindowsPlatform(): |
2888 designerExe = os.path.join( |
2897 designerExe = os.path.join( |
2889 Utilities.getQtBinariesPath(), |
2898 QtUtilities.getQtBinariesPath(), |
2890 "{0}.exe".format(Utilities.generateQtToolName("designer")), |
2899 "{0}.exe".format(QtUtilities.generateQtToolName("designer")), |
2891 ) |
2900 ) |
2892 elif Utilities.isMacPlatform(): |
2901 elif OSUtilities.isMacPlatform(): |
2893 designerExe = Utilities.getQtMacBundle("designer") |
2902 designerExe = QtUtilities.getQtMacBundle("designer") |
2894 else: |
2903 else: |
2895 designerExe = os.path.join( |
2904 designerExe = os.path.join( |
2896 Utilities.getQtBinariesPath(), Utilities.generateQtToolName("designer") |
2905 QtUtilities.getQtBinariesPath(), |
|
2906 QtUtilities.generateQtToolName("designer"), |
2897 ) |
2907 ) |
2898 if os.path.exists(designerExe): |
2908 if os.path.exists(designerExe): |
2899 self.designer4Act = EricAction( |
2909 self.designer4Act = EricAction( |
2900 self.tr("Qt-Designer"), |
2910 self.tr("Qt-Designer"), |
2901 EricPixmapCache.getIcon("designer4"), |
2911 EricPixmapCache.getIcon("designer4"), |
2912 self.designer4Act.triggered.connect(self.__designer) |
2922 self.designer4Act.triggered.connect(self.__designer) |
2913 self.actions.append(self.designer4Act) |
2923 self.actions.append(self.designer4Act) |
2914 else: |
2924 else: |
2915 self.designer4Act = None |
2925 self.designer4Act = None |
2916 |
2926 |
2917 if Utilities.isWindowsPlatform(): |
2927 if OSUtilities.isWindowsPlatform(): |
2918 linguistExe = os.path.join( |
2928 linguistExe = os.path.join( |
2919 Utilities.getQtBinariesPath(), |
2929 QtUtilities.getQtBinariesPath(), |
2920 "{0}.exe".format(Utilities.generateQtToolName("linguist")), |
2930 "{0}.exe".format(QtUtilities.generateQtToolName("linguist")), |
2921 ) |
2931 ) |
2922 elif Utilities.isMacPlatform(): |
2932 elif OSUtilities.isMacPlatform(): |
2923 linguistExe = Utilities.getQtMacBundle("linguist") |
2933 linguistExe = QtUtilities.getQtMacBundle("linguist") |
2924 else: |
2934 else: |
2925 linguistExe = os.path.join( |
2935 linguistExe = os.path.join( |
2926 Utilities.getQtBinariesPath(), Utilities.generateQtToolName("linguist") |
2936 QtUtilities.getQtBinariesPath(), |
|
2937 QtUtilities.generateQtToolName("linguist"), |
2927 ) |
2938 ) |
2928 if os.path.exists(linguistExe): |
2939 if os.path.exists(linguistExe): |
2929 self.linguist4Act = EricAction( |
2940 self.linguist4Act = EricAction( |
2930 self.tr("Qt-Linguist"), |
2941 self.tr("Qt-Linguist"), |
2931 EricPixmapCache.getIcon("linguist4"), |
2942 EricPixmapCache.getIcon("linguist4"), |
3707 def __initPySideDocActions(self): |
3718 def __initPySideDocActions(self): |
3708 """ |
3719 """ |
3709 Private slot to initialize the actions to show the PySide |
3720 Private slot to initialize the actions to show the PySide |
3710 documentation. |
3721 documentation. |
3711 """ |
3722 """ |
3712 if Utilities.checkPyside(variant=2): |
3723 if QtUtilities.checkPyside(variant=2): |
3713 self.pyside2DocAct = EricAction( |
3724 self.pyside2DocAct = EricAction( |
3714 self.tr("PySide2 Documentation"), |
3725 self.tr("PySide2 Documentation"), |
3715 self.tr("PySide2 Documentation"), |
3726 self.tr("PySide2 Documentation"), |
3716 0, |
3727 0, |
3717 0, |
3728 0, |
3733 ) |
3744 ) |
3734 self.actions.append(self.pyside2DocAct) |
3745 self.actions.append(self.pyside2DocAct) |
3735 else: |
3746 else: |
3736 self.pyside2DocAct = None |
3747 self.pyside2DocAct = None |
3737 |
3748 |
3738 if Utilities.checkPyside(variant=6): |
3749 if QtUtilities.checkPyside(variant=6): |
3739 self.pyside6DocAct = EricAction( |
3750 self.pyside6DocAct = EricAction( |
3740 self.tr("PySide6 Documentation"), |
3751 self.tr("PySide6 Documentation"), |
3741 self.tr("PySide6 Documentation"), |
3752 self.tr("PySide6 Documentation"), |
3742 0, |
3753 0, |
3743 0, |
3754 0, |
3765 """ |
3776 """ |
3766 Private slot to create the menus. |
3777 Private slot to create the menus. |
3767 """ |
3778 """ |
3768 self.__menus = {} |
3779 self.__menus = {} |
3769 mb = self.menuBar() |
3780 mb = self.menuBar() |
3770 if Utilities.isLinuxPlatform() and not Preferences.getUI("UseNativeMenuBar"): |
3781 if OSUtilities.isLinuxPlatform() and not Preferences.getUI("UseNativeMenuBar"): |
3771 mb.setNativeMenuBar(False) |
3782 mb.setNativeMenuBar(False) |
3772 |
3783 |
3773 ############################################################## |
3784 ############################################################## |
3774 ## File menu |
3785 ## File menu |
3775 ############################################################## |
3786 ############################################################## |
4574 versionText += ("""<tr><td><b>{0}</b></td><td>{1}</td></tr>""").format( |
4585 versionText += ("""<tr><td><b>{0}</b></td><td>{1}</td></tr>""").format( |
4575 Program, Version |
4586 Program, Version |
4576 ) |
4587 ) |
4577 |
4588 |
4578 # desktop and session type |
4589 # desktop and session type |
4579 desktop = Globals.desktopName() |
4590 desktop = DesktopUtilities.desktopName() |
4580 session = Globals.sessionType() |
4591 session = DesktopUtilities.sessionType() |
4581 if desktop or session: |
4592 if desktop or session: |
4582 versionText += "<tr><td></td><td></td></tr>" |
4593 versionText += "<tr><td></td><td></td></tr>" |
4583 if desktop: |
4594 if desktop: |
4584 versionText += ("<tr><td><b>{0}</b></td><td>{1}</td></tr>").format( |
4595 versionText += ("<tr><td><b>{0}</b></td><td>{1}</td></tr>").format( |
4585 self.tr("Desktop"), desktop |
4596 self.tr("Desktop"), desktop |
4677 user, what to do with it. |
4688 user, what to do with it. |
4678 """ |
4689 """ |
4679 from .ErrorLogDialog import ErrorLogDialog |
4690 from .ErrorLogDialog import ErrorLogDialog |
4680 |
4691 |
4681 if Preferences.getUI("CheckErrorLog"): |
4692 if Preferences.getUI("CheckErrorLog"): |
4682 logFile = os.path.join(Utilities.getConfigDir(), self.ErrorLogFileName) |
4693 logFile = os.path.join(Globals.getConfigDir(), self.ErrorLogFileName) |
4683 if os.path.exists(logFile): |
4694 if os.path.exists(logFile): |
4684 dlg = ErrorLogDialog(logFile, False, self) |
4695 dlg = ErrorLogDialog(logFile, False, self) |
4685 dlg.exec() |
4696 dlg.exec() |
4686 |
4697 |
4687 def __hasErrorLog(self): |
4698 def __hasErrorLog(self): |
4688 """ |
4699 """ |
4689 Private method to check, if an error log file exists. |
4700 Private method to check, if an error log file exists. |
4690 |
4701 |
4691 @return flag indicating the existence of an error log file (boolean) |
4702 @return flag indicating the existence of an error log file (boolean) |
4692 """ |
4703 """ |
4693 logFile = os.path.join(Utilities.getConfigDir(), self.ErrorLogFileName) |
4704 logFile = os.path.join(Globals.getConfigDir(), self.ErrorLogFileName) |
4694 return os.path.exists(logFile) |
4705 return os.path.exists(logFile) |
4695 |
4706 |
4696 def __showErrorLog(self): |
4707 def __showErrorLog(self): |
4697 """ |
4708 """ |
4698 Private slot to show the most recent error log message. |
4709 Private slot to show the most recent error log message. |
4699 """ |
4710 """ |
4700 from .ErrorLogDialog import ErrorLogDialog |
4711 from .ErrorLogDialog import ErrorLogDialog |
4701 |
4712 |
4702 logFile = os.path.join(Utilities.getConfigDir(), self.ErrorLogFileName) |
4713 logFile = os.path.join(Globals.getConfigDir(), self.ErrorLogFileName) |
4703 if os.path.exists(logFile): |
4714 if os.path.exists(logFile): |
4704 dlg = ErrorLogDialog(logFile, True, self) |
4715 dlg = ErrorLogDialog(logFile, True, self) |
4705 dlg.show() |
4716 dlg.show() |
4706 |
4717 |
4707 def __showInstallInfo(self): |
4718 def __showInstallInfo(self): |
4949 else True |
4960 else True |
4950 ) |
4961 ) |
4951 |
4962 |
4952 if res and self.__shutdown(): |
4963 if res and self.__shutdown(): |
4953 ericApp().closeAllWindows() |
4964 ericApp().closeAllWindows() |
4954 program = Globals.getPythonExecutable() |
4965 program = PythonUtilities.getPythonExecutable() |
4955 args = ["-m", "eric7", "--start-session"] |
4966 args = ["-m", "eric7", "--start-session"] |
4956 args.extend(self.__restartArgs) |
4967 args.extend(self.__restartArgs) |
4957 QProcess.startDetached(program, args) |
4968 QProcess.startDetached(program, args) |
4958 |
4969 |
4959 @pyqtSlot() |
4970 @pyqtSlot() |
5043 @param upgradeType upgrade operation (one of 'eric', 'ericpyqt', |
5054 @param upgradeType upgrade operation (one of 'eric', 'ericpyqt', |
5044 'pyqt') |
5055 'pyqt') |
5045 @type str |
5056 @type str |
5046 """ |
5057 """ |
5047 ericApp().closeAllWindows() |
5058 ericApp().closeAllWindows() |
5048 program = Globals.getPythonExecutable() |
5059 program = PythonUtilities.getPythonExecutable() |
5049 ericStartArgs = ["-m", "eric7", "--start-session"] |
5060 ericStartArgs = ["-m", "eric7", "--start-session"] |
5050 ericStartArgs.extend(self.__restartArgs) |
5061 ericStartArgs.extend(self.__restartArgs) |
5051 |
5062 |
5052 upgrader = os.path.join(os.path.dirname(__file__), "upgrader.py") |
5063 upgrader = os.path.join(os.path.dirname(__file__), "upgrader.py") |
5053 upgraderArgs = [ |
5064 upgraderArgs = [ |
5062 """ |
5073 """ |
5063 Private slot to start a new instance of eric. |
5074 Private slot to start a new instance of eric. |
5064 """ |
5075 """ |
5065 if not Preferences.getUI("SingleApplicationMode"): |
5076 if not Preferences.getUI("SingleApplicationMode"): |
5066 # start eric without loading anything and without crash session |
5077 # start eric without loading anything and without crash session |
5067 program = Globals.getPythonExecutable() |
5078 program = PythonUtilities.getPythonExecutable() |
5068 eric7 = os.path.join(os.path.dirname(__file__), "..", "eric7_ide.py") |
5079 eric7 = os.path.join(os.path.dirname(__file__), "..", "eric7_ide.py") |
5069 args = [eric7, "--no-open", "--disable-crash"] |
5080 args = [eric7, "--no-open", "--disable-crash"] |
5070 QProcess.startDetached(program, args) |
5081 QProcess.startDetached(program, args) |
5071 |
5082 |
5072 def __initToolsMenus(self, menu): |
5083 def __initToolsMenus(self, menu): |
5982 " is zero length.</p>" |
5993 " is zero length.</p>" |
5983 ).format(fn), |
5994 ).format(fn), |
5984 ) |
5995 ) |
5985 return |
5996 return |
5986 |
5997 |
5987 if Utilities.isMacPlatform(): |
5998 if OSUtilities.isMacPlatform(): |
5988 designer, args = Utilities.prepareQtMacBundle("designer", args) |
5999 designer, args = QtUtilities.prepareQtMacBundle("designer", args) |
5989 else: |
6000 else: |
5990 designer = os.path.join( |
6001 designer = os.path.join( |
5991 Utilities.getQtBinariesPath(), Utilities.generateQtToolName("designer") |
6002 QtUtilities.getQtBinariesPath(), |
5992 ) |
6003 QtUtilities.generateQtToolName("designer"), |
5993 if Utilities.isWindowsPlatform(): |
6004 ) |
|
6005 if OSUtilities.isWindowsPlatform(): |
5994 designer += ".exe" |
6006 designer += ".exe" |
5995 |
6007 |
5996 if designer: |
6008 if designer: |
5997 proc = QProcess() |
6009 proc = QProcess() |
5998 if not proc.startDetached(designer, args): |
6010 if not proc.startDetached(designer, args): |
6049 " is zero length.</p>" |
6061 " is zero length.</p>" |
6050 ).format(fn), |
6062 ).format(fn), |
6051 ) |
6063 ) |
6052 return |
6064 return |
6053 |
6065 |
6054 if Utilities.isMacPlatform(): |
6066 if OSUtilities.isMacPlatform(): |
6055 linguist, args = Utilities.prepareQtMacBundle("linguist", args) |
6067 linguist, args = QtUtilities.prepareQtMacBundle("linguist", args) |
6056 else: |
6068 else: |
6057 linguist = os.path.join( |
6069 linguist = os.path.join( |
6058 Utilities.getQtBinariesPath(), Utilities.generateQtToolName("linguist") |
6070 QtUtilities.getQtBinariesPath(), |
6059 ) |
6071 QtUtilities.generateQtToolName("linguist"), |
6060 if Utilities.isWindowsPlatform(): |
6072 ) |
|
6073 if OSUtilities.isWindowsPlatform(): |
6061 linguist += ".exe" |
6074 linguist += ".exe" |
6062 |
6075 |
6063 if linguist: |
6076 if linguist: |
6064 proc = QProcess() |
6077 proc = QProcess() |
6065 if not proc.startDetached(linguist, args): |
6078 if not proc.startDetached(linguist, args): |
6092 args = [] |
6105 args = [] |
6093 if home: |
6106 if home: |
6094 args.append("-showUrl") |
6107 args.append("-showUrl") |
6095 args.append(home) |
6108 args.append(home) |
6096 |
6109 |
6097 if Utilities.isMacPlatform(): |
6110 if OSUtilities.isMacPlatform(): |
6098 assistant, args = Utilities.prepareQtMacBundle("assistant", args) |
6111 assistant, args = QtUtilities.prepareQtMacBundle("assistant", args) |
6099 else: |
6112 else: |
6100 assistant = os.path.join( |
6113 assistant = os.path.join( |
6101 Utilities.getQtBinariesPath(), Utilities.generateQtToolName("assistant") |
6114 QtUtilities.getQtBinariesPath(), |
6102 ) |
6115 QtUtilities.generateQtToolName("assistant"), |
6103 if Utilities.isWindowsPlatform(): |
6116 ) |
|
6117 if OSUtilities.isWindowsPlatform(): |
6104 assistant += ".exe" |
6118 assistant += ".exe" |
6105 |
6119 |
6106 if assistant: |
6120 if assistant: |
6107 proc = QProcess() |
6121 proc = QProcess() |
6108 if not proc.startDetached(assistant, args): |
6122 if not proc.startDetached(assistant, args): |
6306 |
6320 |
6307 args = [] |
6321 args = [] |
6308 args.append(browser) |
6322 args.append(browser) |
6309 |
6323 |
6310 if not os.path.isfile(browser) or not proc.startDetached( |
6324 if not os.path.isfile(browser) or not proc.startDetached( |
6311 Globals.getPythonExecutable(), args |
6325 PythonUtilities.getPythonExecutable(), args |
6312 ): |
6326 ): |
6313 EricMessageBox.critical( |
6327 EricMessageBox.critical( |
6314 self, |
6328 self, |
6315 self.tr("Process Generation Error"), |
6329 self.tr("Process Generation Error"), |
6316 self.tr( |
6330 self.tr( |
6573 """ |
6587 """ |
6574 Private slot to show the Python 3 documentation. |
6588 Private slot to show the Python 3 documentation. |
6575 """ |
6589 """ |
6576 pythonDocDir = Preferences.getHelp("PythonDocDir") |
6590 pythonDocDir = Preferences.getHelp("PythonDocDir") |
6577 if not pythonDocDir: |
6591 if not pythonDocDir: |
6578 if Utilities.isWindowsPlatform(): |
6592 if OSUtilities.isWindowsPlatform(): |
6579 venvName = Preferences.getDebugger("Python3VirtualEnv") |
6593 venvName = Preferences.getDebugger("Python3VirtualEnv") |
6580 interpreter = ( |
6594 interpreter = ( |
6581 ericApp() |
6595 ericApp() |
6582 .getObject("VirtualEnvManager") |
6596 .getObject("VirtualEnvManager") |
6583 .getVirtualenvInterpreter(venvName) |
6597 .getVirtualenvInterpreter(venvName) |
6584 ) |
6598 ) |
6585 if interpreter: |
6599 if interpreter: |
6586 default = os.path.join(os.path.dirname(interpreter), "doc") |
6600 default = os.path.join(os.path.dirname(interpreter), "doc") |
6587 else: |
6601 else: |
6588 default = "" |
6602 default = "" |
6589 pythonDocDir = Utilities.getEnvironmentEntry("PYTHON3DOCDIR", default) |
6603 pythonDocDir = OSUtilities.getEnvironmentEntry("PYTHON3DOCDIR", default) |
6590 else: |
6604 else: |
6591 pythonDocDir = Utilities.getEnvironmentEntry( |
6605 pythonDocDir = OSUtilities.getEnvironmentEntry( |
6592 "PYTHON3DOCDIR", "/usr/share/doc/packages/python3/html" |
6606 "PYTHON3DOCDIR", "/usr/share/doc/packages/python3/html" |
6593 ) |
6607 ) |
6594 if not pythonDocDir.startswith(("http://", "https://", "qthelp://")): |
6608 if not pythonDocDir.startswith(("http://", "https://", "qthelp://")): |
6595 if pythonDocDir.startswith("file://"): |
6609 if pythonDocDir.startswith("file://"): |
6596 pythonDocDir = pythonDocDir[7:] |
6610 pythonDocDir = pythonDocDir[7:] |
6597 if not os.path.splitext(pythonDocDir)[1]: |
6611 if not os.path.splitext(pythonDocDir)[1]: |
6598 home = Utilities.normjoinpath(pythonDocDir, "index.html") |
6612 home = FileSystemUtilities.normjoinpath(pythonDocDir, "index.html") |
6599 |
6613 |
6600 if Utilities.isWindowsPlatform() and not os.path.exists(home): |
6614 if OSUtilities.isWindowsPlatform() and not os.path.exists(home): |
6601 pyversion = sys.hexversion >> 16 |
6615 pyversion = sys.hexversion >> 16 |
6602 vers = "{0:d}{1:d}".format( |
6616 vers = "{0:d}{1:d}".format( |
6603 (pyversion >> 8) & 0xFF, pyversion & 0xFF |
6617 (pyversion >> 8) & 0xFF, pyversion & 0xFF |
6604 ) |
6618 ) |
6605 home = os.path.join(pythonDocDir, "python{0}.chm".format(vers)) |
6619 home = os.path.join(pythonDocDir, "python{0}.chm".format(vers)) |
6664 home = qtDocDir |
6678 home = qtDocDir |
6665 else: |
6679 else: |
6666 if qtDocDir.startswith("file://"): |
6680 if qtDocDir.startswith("file://"): |
6667 qtDocDir = qtDocDir[7:] |
6681 qtDocDir = qtDocDir[7:] |
6668 if not os.path.splitext(qtDocDir)[1]: |
6682 if not os.path.splitext(qtDocDir)[1]: |
6669 home = Utilities.normjoinpath(qtDocDir, "index.html") |
6683 home = FileSystemUtilities.normjoinpath(qtDocDir, "index.html") |
6670 else: |
6684 else: |
6671 home = qtDocDir |
6685 home = qtDocDir |
6672 |
6686 |
6673 if not os.path.exists(home): |
6687 if not os.path.exists(home): |
6674 EricMessageBox.warning( |
6688 EricMessageBox.warning( |
6708 @param variant PyQt variant to show documentation for (5 or 6) |
6722 @param variant PyQt variant to show documentation for (5 or 6) |
6709 @type int or str |
6723 @type int or str |
6710 """ |
6724 """ |
6711 pyqtDocDir = Preferences.getHelp("PyQt{0}DocDir".format(variant)) |
6725 pyqtDocDir = Preferences.getHelp("PyQt{0}DocDir".format(variant)) |
6712 if not pyqtDocDir: |
6726 if not pyqtDocDir: |
6713 pyqtDocDir = Utilities.getEnvironmentEntry( |
6727 pyqtDocDir = OSUtilities.getEnvironmentEntry( |
6714 "PYQT{0}DOCDIR".format(variant), None |
6728 "PYQT{0}DOCDIR".format(variant), None |
6715 ) |
6729 ) |
6716 |
6730 |
6717 if not pyqtDocDir: |
6731 if not pyqtDocDir: |
6718 EricMessageBox.warning( |
6732 EricMessageBox.warning( |
6730 if pyqtDocDir: |
6744 if pyqtDocDir: |
6731 if pyqtDocDir.startswith("file://"): |
6745 if pyqtDocDir.startswith("file://"): |
6732 pyqtDocDir = pyqtDocDir[7:] |
6746 pyqtDocDir = pyqtDocDir[7:] |
6733 if not os.path.splitext(pyqtDocDir)[1]: |
6747 if not os.path.splitext(pyqtDocDir)[1]: |
6734 possibleHomes = [ |
6748 possibleHomes = [ |
6735 Utilities.normjoinpath(pyqtDocDir, "index.html"), |
6749 FileSystemUtilities.normjoinpath(pyqtDocDir, "index.html"), |
6736 Utilities.normjoinpath(pyqtDocDir, "class_reference.html"), |
6750 FileSystemUtilities.normjoinpath( |
|
6751 pyqtDocDir, "class_reference.html" |
|
6752 ), |
6737 ] |
6753 ] |
6738 for possibleHome in possibleHomes: |
6754 for possibleHome in possibleHomes: |
6739 if os.path.exists(possibleHome): |
6755 if os.path.exists(possibleHome): |
6740 home = possibleHome |
6756 home = possibleHome |
6741 break |
6757 break |
6779 """ |
6795 """ |
6780 Private slot to show the Eric documentation. |
6796 Private slot to show the Eric documentation. |
6781 """ |
6797 """ |
6782 home = Preferences.getHelp("EricDocDir") |
6798 home = Preferences.getHelp("EricDocDir") |
6783 if not home: |
6799 if not home: |
6784 home = Utilities.normjoinpath( |
6800 home = FileSystemUtilities.normjoinpath( |
6785 getConfig("ericDocDir"), "Source", "index.html" |
6801 getConfig("ericDocDir"), "Source", "index.html" |
6786 ) |
6802 ) |
6787 |
6803 |
6788 if not home.startswith(("http://", "https://", "qthelp://")): |
6804 if not home.startswith(("http://", "https://", "qthelp://")): |
6789 if not os.path.exists(home): |
6805 if not os.path.exists(home): |
6824 @param variant PySide variant (2 or 6) |
6840 @param variant PySide variant (2 or 6) |
6825 @type int or str |
6841 @type int or str |
6826 """ |
6842 """ |
6827 pysideDocDir = Preferences.getHelp("PySide{0}DocDir".format(variant)) |
6843 pysideDocDir = Preferences.getHelp("PySide{0}DocDir".format(variant)) |
6828 if not pysideDocDir: |
6844 if not pysideDocDir: |
6829 pysideDocDir = Utilities.getEnvironmentEntry( |
6845 pysideDocDir = OSUtilities.getEnvironmentEntry( |
6830 "PYSIDE{0}DOCDIR".format(variant), None |
6846 "PYSIDE{0}DOCDIR".format(variant), None |
6831 ) |
6847 ) |
6832 |
6848 |
6833 if not pysideDocDir: |
6849 if not pysideDocDir: |
6834 EricMessageBox.warning( |
6850 EricMessageBox.warning( |
6843 |
6859 |
6844 if not pysideDocDir.startswith(("http://", "https://", "qthelp://")): |
6860 if not pysideDocDir.startswith(("http://", "https://", "qthelp://")): |
6845 if pysideDocDir.startswith("file://"): |
6861 if pysideDocDir.startswith("file://"): |
6846 pysideDocDir = pysideDocDir[7:] |
6862 pysideDocDir = pysideDocDir[7:] |
6847 if not os.path.splitext(pysideDocDir)[1]: |
6863 if not os.path.splitext(pysideDocDir)[1]: |
6848 home = Utilities.normjoinpath(pysideDocDir, "index.html") |
6864 home = FileSystemUtilities.normjoinpath(pysideDocDir, "index.html") |
6849 else: |
6865 else: |
6850 home = pysideDocDir |
6866 home = pysideDocDir |
6851 if not os.path.exists(home): |
6867 if not os.path.exists(home): |
6852 EricMessageBox.warning( |
6868 EricMessageBox.warning( |
6853 self, |
6869 self, |
6943 "--qthelp", |
6959 "--qthelp", |
6944 "--single", |
6960 "--single", |
6945 "--name={0}".format(self.__webBrowserSAName), |
6961 "--name={0}".format(self.__webBrowserSAName), |
6946 home, |
6962 home, |
6947 ] |
6963 ] |
6948 process.start(Globals.getPythonExecutable(), args) |
6964 process.start(PythonUtilities.getPythonExecutable(), args) |
6949 if not process.waitForStarted(): |
6965 if not process.waitForStarted(): |
6950 EricMessageBox.warning( |
6966 EricMessageBox.warning( |
6951 self, |
6967 self, |
6952 self.tr("Start Web Browser"), |
6968 self.tr("Start Web Browser"), |
6953 self.tr("""The eric web browser could not be started."""), |
6969 self.tr("""The eric web browser could not be started."""), |
7505 |
7521 |
7506 def __writeTasks(self): |
7522 def __writeTasks(self): |
7507 """ |
7523 """ |
7508 Private slot to write the tasks data to a JSON file (.etj). |
7524 Private slot to write the tasks data to a JSON file (.etj). |
7509 """ |
7525 """ |
7510 fn = os.path.join(Utilities.getConfigDir(), "eric7tasks.etj") |
7526 fn = os.path.join(Globals.getConfigDir(), "eric7tasks.etj") |
7511 self.__tasksFile.writeFile(fn) |
7527 self.__tasksFile.writeFile(fn) |
7512 |
7528 |
7513 def __readTasks(self): |
7529 def __readTasks(self): |
7514 """ |
7530 """ |
7515 Private slot to read in the tasks file (.etj or .e6t). |
7531 Private slot to read in the tasks file (.etj or .e6t). |
7516 """ |
7532 """ |
7517 fn = os.path.join(Utilities.getConfigDir(), "eric7tasks.etj") |
7533 fn = os.path.join(Globals.getConfigDir(), "eric7tasks.etj") |
7518 if os.path.exists(fn): |
7534 if os.path.exists(fn): |
7519 # try new style JSON file first |
7535 # try new style JSON file first |
7520 self.__tasksFile.readFile(fn) |
7536 self.__tasksFile.readFile(fn) |
7521 else: |
7537 else: |
7522 # try old style XML file second |
7538 # try old style XML file second |
7523 fn = os.path.join(Utilities.getConfigDir(), "eric7tasks.e6t") |
7539 fn = os.path.join(Globals.getConfigDir(), "eric7tasks.e6t") |
7524 if os.path.exists(fn): |
7540 if os.path.exists(fn): |
7525 f = QFile(fn) |
7541 f = QFile(fn) |
7526 if f.open(QIODevice.OpenModeFlag.ReadOnly): |
7542 if f.open(QIODevice.OpenModeFlag.ReadOnly): |
7527 reader = TasksReader(f, viewer=self.taskViewer) |
7543 reader = TasksReader(f, viewer=self.taskViewer) |
7528 reader.readXML() |
7544 reader.readXML() |
7548 @rtype bool |
7564 @rtype bool |
7549 """ |
7565 """ |
7550 if filename: |
7566 if filename: |
7551 fn = filename |
7567 fn = filename |
7552 elif crashSession: |
7568 elif crashSession: |
7553 fn = os.path.join(Utilities.getConfigDir(), "eric7_crash_session.esj") |
7569 fn = os.path.join(Globals.getConfigDir(), "eric7_crash_session.esj") |
7554 else: |
7570 else: |
7555 fn = os.path.join(Utilities.getConfigDir(), "eric7session.esj") |
7571 fn = os.path.join(Globals.getConfigDir(), "eric7session.esj") |
7556 |
7572 |
7557 return self.__sessionFile.writeFile(fn) |
7573 return self.__sessionFile.writeFile(fn) |
7558 |
7574 |
7559 def __readSession(self, filename=""): |
7575 def __readSession(self, filename=""): |
7560 """ |
7576 """ |
7566 @rtype bool |
7582 @rtype bool |
7567 """ |
7583 """ |
7568 if filename: |
7584 if filename: |
7569 fn = filename |
7585 fn = filename |
7570 else: |
7586 else: |
7571 fn = os.path.join(Utilities.getConfigDir(), "eric7session.esj") |
7587 fn = os.path.join(Globals.getConfigDir(), "eric7session.esj") |
7572 if not os.path.exists(fn): |
7588 if not os.path.exists(fn): |
7573 fn = os.path.join(Utilities.getConfigDir(), "eric7session.e5s") |
7589 fn = os.path.join(Globals.getConfigDir(), "eric7session.e5s") |
7574 if not os.path.exists(fn): |
7590 if not os.path.exists(fn): |
7575 EricMessageBox.critical( |
7591 EricMessageBox.critical( |
7576 self, |
7592 self, |
7577 self.tr("Read Session"), |
7593 self.tr("Read Session"), |
7578 self.tr( |
7594 self.tr( |
7617 Private slot to save a session to disk. |
7633 Private slot to save a session to disk. |
7618 """ |
7634 """ |
7619 sessionFile, selectedFilter = EricFileDialog.getSaveFileNameAndFilter( |
7635 sessionFile, selectedFilter = EricFileDialog.getSaveFileNameAndFilter( |
7620 self, |
7636 self, |
7621 self.tr("Save Session"), |
7637 self.tr("Save Session"), |
7622 Utilities.getHomeDir(), |
7638 OSUtilities.getHomeDir(), |
7623 self.tr("eric Session Files (*.esj)"), |
7639 self.tr("eric Session Files (*.esj)"), |
7624 "", |
7640 "", |
7625 ) |
7641 ) |
7626 |
7642 |
7627 if not sessionFile: |
7643 if not sessionFile: |
7640 Private slot to load a session from disk. |
7656 Private slot to load a session from disk. |
7641 """ |
7657 """ |
7642 sessionFile = EricFileDialog.getOpenFileName( |
7658 sessionFile = EricFileDialog.getOpenFileName( |
7643 self, |
7659 self, |
7644 self.tr("Load session"), |
7660 self.tr("Load session"), |
7645 Utilities.getHomeDir(), |
7661 OSUtilities.getHomeDir(), |
7646 self.tr("eric Session Files (*.esj);;eric XML Session Files (*.e5s)"), |
7662 self.tr("eric Session Files (*.esj);;eric XML Session Files (*.e5s)"), |
7647 ) |
7663 ) |
7648 |
7664 |
7649 if not sessionFile: |
7665 if not sessionFile: |
7650 return |
7666 return |
7654 def __deleteCrashSession(self): |
7670 def __deleteCrashSession(self): |
7655 """ |
7671 """ |
7656 Private slot to delete the crash session file. |
7672 Private slot to delete the crash session file. |
7657 """ |
7673 """ |
7658 for ext in (".esj", ".e5s"): |
7674 for ext in (".esj", ".e5s"): |
7659 fn = os.path.join(Utilities.getConfigDir(), f"eric7_crash_session{ext}") |
7675 fn = os.path.join(Globals.getConfigDir(), f"eric7_crash_session{ext}") |
7660 if os.path.exists(fn): |
7676 if os.path.exists(fn): |
7661 with contextlib.suppress(OSError): |
7677 with contextlib.suppress(OSError): |
7662 os.remove(fn) |
7678 os.remove(fn) |
7663 |
7679 |
7664 def __writeCrashSession(self): |
7680 def __writeCrashSession(self): |
7683 if ( |
7699 if ( |
7684 not self.__disableCrashSession |
7700 not self.__disableCrashSession |
7685 and not self.__noCrashOpenAtStartup |
7701 and not self.__noCrashOpenAtStartup |
7686 and Preferences.getUI("OpenCrashSessionOnStartup") |
7702 and Preferences.getUI("OpenCrashSessionOnStartup") |
7687 ): |
7703 ): |
7688 fn = os.path.join(Utilities.getConfigDir(), "eric7_crash_session.esj") |
7704 fn = os.path.join(Globals.getConfigDir(), "eric7_crash_session.esj") |
7689 if os.path.exists(fn): |
7705 if os.path.exists(fn): |
7690 yes = EricMessageBox.yesNo( |
7706 yes = EricMessageBox.yesNo( |
7691 self, |
7707 self, |
7692 self.tr("Crash Session found!"), |
7708 self.tr("Crash Session found!"), |
7693 self.tr( |
7709 self.tr( |
8310 # eric hasn't been configured at all |
8326 # eric hasn't been configured at all |
8311 self.checkConfigurationStatus() |
8327 self.checkConfigurationStatus() |
8312 |
8328 |
8313 workspace = Preferences.getMultiProject("Workspace") |
8329 workspace = Preferences.getMultiProject("Workspace") |
8314 if workspace == "": |
8330 if workspace == "": |
8315 default = Utilities.getHomeDir() |
8331 default = OSUtilities.getHomeDir() |
8316 workspace = EricFileDialog.getExistingDirectory( |
8332 workspace = EricFileDialog.getExistingDirectory( |
8317 None, |
8333 None, |
8318 self.tr("Select Workspace Directory"), |
8334 self.tr("Select Workspace Directory"), |
8319 default, |
8335 default, |
8320 EricFileDialog.Option(0), |
8336 EricFileDialog.Option(0), |