UI/UserInterface.py

changeset 3020
542e97d4ecb3
parent 3012
d177226027e2
child 3030
4a0a82ddd9d2
equal deleted inserted replaced
3019:7912530a33e2 3020:542e97d4ecb3
2878 if Preferences.getUser("UseSystemEmailClient"): 2878 if Preferences.getUser("UseSystemEmailClient"):
2879 self.__showSystemEmailClient(mode, attachFile, deleteAttachFile) 2879 self.__showSystemEmailClient(mode, attachFile, deleteAttachFile)
2880 else: 2880 else:
2881 if Preferences.getUser("Email") == "" or \ 2881 if Preferences.getUser("Email") == "" or \
2882 Preferences.getUser("MailServer") == "": 2882 Preferences.getUser("MailServer") == "":
2883 E5MessageBox.critical(self, 2883 E5MessageBox.critical(
2884 self,
2884 self.trUtf8("Report Bug"), 2885 self.trUtf8("Report Bug"),
2885 self.trUtf8( 2886 self.trUtf8(
2886 """Email address or mail server address is empty.""" 2887 """Email address or mail server address is empty."""
2887 """ Please configure your Email settings in the""" 2888 """ Please configure your Email settings in the"""
2888 """ Preferences Dialog.""")) 2889 """ Preferences Dialog."""))
3896 if os.path.exists(tfn): 3897 if os.path.exists(tfn):
3897 prog = tfn 3898 prog = tfn
3898 else: 3899 else:
3899 prog = fn 3900 prog = fn
3900 else: 3901 else:
3901 E5MessageBox.critical(self, 3902 E5MessageBox.critical(
3903 self,
3902 self.trUtf8("Unittest Project"), 3904 self.trUtf8("Unittest Project"),
3903 self.trUtf8("There is no main script defined for the" 3905 self.trUtf8("There is no main script defined for the"
3904 " current project. Aborting")) 3906 " current project. Aborting"))
3905 return 3907 return
3906 3908
3957 version = 3 3959 version = 3
3958 except IOError: 3960 except IOError:
3959 pass 3961 pass
3960 3962
3961 if version == 3: 3963 if version == 3:
3962 E5MessageBox.information(self, 3964 E5MessageBox.information(
3965 self,
3963 self.trUtf8("Qt 3 support"), 3966 self.trUtf8("Qt 3 support"),
3964 self.trUtf8("""Qt v.3 is not supported by eric5.""")) 3967 self.trUtf8("""Qt v.3 is not supported by eric5."""))
3965 return 3968 return
3966 3969
3967 args = [] 3970 args = []
3968 if fn is not None: 3971 if fn is not None:
3969 try: 3972 try:
3970 if os.path.isfile(fn) and os.path.getsize(fn): 3973 if os.path.isfile(fn) and os.path.getsize(fn):
3971 args.append(fn) 3974 args.append(fn)
3972 else: 3975 else:
3973 E5MessageBox.critical(self, 3976 E5MessageBox.critical(
3977 self,
3974 self.trUtf8('Problem'), 3978 self.trUtf8('Problem'),
3975 self.trUtf8('<p>The file <b>{0}</b> does not exist or' 3979 self.trUtf8('<p>The file <b>{0}</b> does not exist or'
3976 ' is zero length.</p>') 3980 ' is zero length.</p>')
3977 .format(fn)) 3981 .format(fn))
3978 return 3982 return
3979 except EnvironmentError: 3983 except EnvironmentError:
3980 E5MessageBox.critical(self, 3984 E5MessageBox.critical(
3985 self,
3981 self.trUtf8('Problem'), 3986 self.trUtf8('Problem'),
3982 self.trUtf8('<p>The file <b>{0}</b> does not exist or' 3987 self.trUtf8('<p>The file <b>{0}</b> does not exist or'
3983 ' is zero length.</p>') 3988 ' is zero length.</p>')
3984 .format(fn)) 3989 .format(fn))
3985 return 3990 return
3995 if Utilities.isWindowsPlatform(): 4000 if Utilities.isWindowsPlatform():
3996 designer += '.exe' 4001 designer += '.exe'
3997 4002
3998 proc = QProcess() 4003 proc = QProcess()
3999 if not proc.startDetached(designer, args): 4004 if not proc.startDetached(designer, args):
4000 E5MessageBox.critical(self, 4005 E5MessageBox.critical(
4006 self,
4001 self.trUtf8('Process Generation Error'), 4007 self.trUtf8('Process Generation Error'),
4002 self.trUtf8( 4008 self.trUtf8(
4003 '<p>Could not start Qt-Designer.<br>' 4009 '<p>Could not start Qt-Designer.<br>'
4004 'Ensure that it is available as <b>{0}</b>.</p>' 4010 'Ensure that it is available as <b>{0}</b>.</p>'
4005 ).format(designer)) 4011 ).format(designer))
4016 4022
4017 @param fn filename of the translation file to be opened 4023 @param fn filename of the translation file to be opened
4018 @param version indication for the requested version (Qt 4) (integer) 4024 @param version indication for the requested version (Qt 4) (integer)
4019 """ 4025 """
4020 if version < 4: 4026 if version < 4:
4021 E5MessageBox.information(self, 4027 E5MessageBox.information(
4028 self,
4022 self.trUtf8("Qt 3 support"), 4029 self.trUtf8("Qt 3 support"),
4023 self.trUtf8("""Qt v.3 is not supported by eric5.""")) 4030 self.trUtf8("""Qt v.3 is not supported by eric5."""))
4024 return 4031 return
4025 4032
4026 args = [] 4033 args = []
4029 try: 4036 try:
4030 if os.path.isfile(fn) and os.path.getsize(fn) and \ 4037 if os.path.isfile(fn) and os.path.getsize(fn) and \
4031 fn not in args: 4038 fn not in args:
4032 args.append(fn) 4039 args.append(fn)
4033 else: 4040 else:
4034 E5MessageBox.critical(self, 4041 E5MessageBox.critical(
4042 self,
4035 self.trUtf8('Problem'), 4043 self.trUtf8('Problem'),
4036 self.trUtf8('<p>The file <b>{0}</b> does not exist or' 4044 self.trUtf8('<p>The file <b>{0}</b> does not exist or'
4037 ' is zero length.</p>') 4045 ' is zero length.</p>')
4038 .format(fn)) 4046 .format(fn))
4039 return 4047 return
4040 except EnvironmentError: 4048 except EnvironmentError:
4041 E5MessageBox.critical(self, 4049 E5MessageBox.critical(
4050 self,
4042 self.trUtf8('Problem'), 4051 self.trUtf8('Problem'),
4043 self.trUtf8('<p>The file <b>{0}</b> does not exist or' 4052 self.trUtf8('<p>The file <b>{0}</b> does not exist or'
4044 ' is zero length.</p>') 4053 ' is zero length.</p>')
4045 .format(fn)) 4054 .format(fn))
4046 return 4055 return
4056 if Utilities.isWindowsPlatform(): 4065 if Utilities.isWindowsPlatform():
4057 linguist += '.exe' 4066 linguist += '.exe'
4058 4067
4059 proc = QProcess() 4068 proc = QProcess()
4060 if not proc.startDetached(linguist, args): 4069 if not proc.startDetached(linguist, args):
4061 E5MessageBox.critical(self, 4070 E5MessageBox.critical(
4071 self,
4062 self.trUtf8('Process Generation Error'), 4072 self.trUtf8('Process Generation Error'),
4063 self.trUtf8( 4073 self.trUtf8(
4064 '<p>Could not start Qt-Linguist.<br>' 4074 '<p>Could not start Qt-Linguist.<br>'
4065 'Ensure that it is available as <b>{0}</b>.</p>' 4075 'Ensure that it is available as <b>{0}</b>.</p>'
4066 ).format(linguist)) 4076 ).format(linguist))
4079 4089
4080 @param home full pathname of a file to display (string) 4090 @param home full pathname of a file to display (string)
4081 @param version indication for the requested version (Qt 4) (integer) 4091 @param version indication for the requested version (Qt 4) (integer)
4082 """ 4092 """
4083 if version < 4: 4093 if version < 4:
4084 E5MessageBox.information(self, 4094 E5MessageBox.information(
4095 self,
4085 self.trUtf8("Qt 3 support"), 4096 self.trUtf8("Qt 3 support"),
4086 self.trUtf8("""Qt v.3 is not supported by eric5.""")) 4097 self.trUtf8("""Qt v.3 is not supported by eric5."""))
4087 return 4098 return
4088 4099
4089 args = [] 4100 args = []
4103 if Utilities.isWindowsPlatform(): 4114 if Utilities.isWindowsPlatform():
4104 assistant += '.exe' 4115 assistant += '.exe'
4105 4116
4106 proc = QProcess() 4117 proc = QProcess()
4107 if not proc.startDetached(assistant, args): 4118 if not proc.startDetached(assistant, args):
4108 E5MessageBox.critical(self, 4119 E5MessageBox.critical(
4120 self,
4109 self.trUtf8('Process Generation Error'), 4121 self.trUtf8('Process Generation Error'),
4110 self.trUtf8( 4122 self.trUtf8(
4111 '<p>Could not start Qt-Assistant.<br>' 4123 '<p>Could not start Qt-Assistant.<br>'
4112 'Ensure that it is available as <b>{0}</b>.</p>' 4124 'Ensure that it is available as <b>{0}</b>.</p>'
4113 ).format(assistant)) 4125 ).format(assistant))
4130 4142
4131 @param home full pathname of a file to display (string) 4143 @param home full pathname of a file to display (string)
4132 """ 4144 """
4133 customViewer = Preferences.getHelp("CustomViewer") 4145 customViewer = Preferences.getHelp("CustomViewer")
4134 if not customViewer: 4146 if not customViewer:
4135 E5MessageBox.information(self, 4147 E5MessageBox.information(
4148 self,
4136 self.trUtf8("Help"), 4149 self.trUtf8("Help"),
4137 self.trUtf8( 4150 self.trUtf8(
4138 """Currently no custom viewer is selected.""" 4151 """Currently no custom viewer is selected."""
4139 """ Please use the preferences dialog to specify one.""")) 4152 """ Please use the preferences dialog to specify one."""))
4140 return 4153 return
4143 args = [] 4156 args = []
4144 if home: 4157 if home:
4145 args.append(home) 4158 args.append(home)
4146 4159
4147 if not proc.startDetached(customViewer, args): 4160 if not proc.startDetached(customViewer, args):
4148 E5MessageBox.critical(self, 4161 E5MessageBox.critical(
4162 self,
4149 self.trUtf8('Process Generation Error'), 4163 self.trUtf8('Process Generation Error'),
4150 self.trUtf8( 4164 self.trUtf8(
4151 '<p>Could not start custom viewer.<br>' 4165 '<p>Could not start custom viewer.<br>'
4152 'Ensure that it is available as <b>{0}</b>.</p>' 4166 'Ensure that it is available as <b>{0}</b>.</p>'
4153 ).format(customViewer)) 4167 ).format(customViewer))
4162 proc = QProcess() 4176 proc = QProcess()
4163 args = [] 4177 args = []
4164 args.append(home) 4178 args.append(home)
4165 4179
4166 if not proc.startDetached("hh", args): 4180 if not proc.startDetached("hh", args):
4167 E5MessageBox.critical(self, 4181 E5MessageBox.critical(
4182 self,
4168 self.trUtf8('Process Generation Error'), 4183 self.trUtf8('Process Generation Error'),
4169 self.trUtf8( 4184 self.trUtf8(
4170 '<p>Could not start the help viewer.<br>' 4185 '<p>Could not start the help viewer.<br>'
4171 'Ensure that it is available as <b>hh</b>.</p>' 4186 'Ensure that it is available as <b>hh</b>.</p>'
4172 )) 4187 ))
4187 if fn is not None: 4202 if fn is not None:
4188 try: 4203 try:
4189 if os.path.isfile(fn) and os.path.getsize(fn): 4204 if os.path.isfile(fn) and os.path.getsize(fn):
4190 args.append(fn) 4205 args.append(fn)
4191 else: 4206 else:
4192 E5MessageBox.critical(self, 4207 E5MessageBox.critical(
4208 self,
4193 self.trUtf8('Problem'), 4209 self.trUtf8('Problem'),
4194 self.trUtf8('<p>The file <b>{0}</b> does not exist or' 4210 self.trUtf8('<p>The file <b>{0}</b> does not exist or'
4195 ' is zero length.</p>') 4211 ' is zero length.</p>')
4196 .format(fn)) 4212 .format(fn))
4197 return 4213 return
4198 except EnvironmentError: 4214 except EnvironmentError:
4199 E5MessageBox.critical(self, 4215 E5MessageBox.critical(
4216 self,
4200 self.trUtf8('Problem'), 4217 self.trUtf8('Problem'),
4201 self.trUtf8('<p>The file <b>{0}</b> does not exist or' 4218 self.trUtf8('<p>The file <b>{0}</b> does not exist or'
4202 ' is zero length.</p>') 4219 ' is zero length.</p>')
4203 .format(fn)) 4220 .format(fn))
4204 return 4221 return
4234 try: 4251 try:
4235 if os.path.isfile(fn) and os.path.getsize(fn): 4252 if os.path.isfile(fn) and os.path.getsize(fn):
4236 args.append(fn) 4253 args.append(fn)
4237 else: 4254 else:
4238 if not ignore: 4255 if not ignore:
4239 E5MessageBox.critical(self, 4256 E5MessageBox.critical(
4257 self,
4240 self.trUtf8('Problem'), 4258 self.trUtf8('Problem'),
4241 self.trUtf8( 4259 self.trUtf8(
4242 '<p>The file <b>{0}</b> does not exist or' 4260 '<p>The file <b>{0}</b> does not exist or'
4243 ' is zero length.</p>') 4261 ' is zero length.</p>')
4244 .format(fn)) 4262 .format(fn))
4245 return 4263 return
4246 except EnvironmentError: 4264 except EnvironmentError:
4247 if not ignore: 4265 if not ignore:
4248 E5MessageBox.critical(self, 4266 E5MessageBox.critical(
4267 self,
4249 self.trUtf8('Problem'), 4268 self.trUtf8('Problem'),
4250 self.trUtf8( 4269 self.trUtf8(
4251 '<p>The file <b>{0}</b> does not exist or' 4270 '<p>The file <b>{0}</b> does not exist or'
4252 ' is zero length.</p>') 4271 ' is zero length.</p>')
4253 .format(fn)) 4272 .format(fn))
4411 if aw is not None: 4430 if aw is not None:
4412 aw.beginUndoAction() 4431 aw.beginUndoAction()
4413 4432
4414 proc.start(program, args) 4433 proc.start(program, args)
4415 if not proc.waitForStarted(): 4434 if not proc.waitForStarted():
4416 E5MessageBox.critical(self, 4435 E5MessageBox.critical(
4436 self,
4417 self.trUtf8('Process Generation Error'), 4437 self.trUtf8('Process Generation Error'),
4418 self.trUtf8( 4438 self.trUtf8(
4419 '<p>Could not start the tool entry <b>{0}</b>.<br>' 4439 '<p>Could not start the tool entry <b>{0}</b>.<br>'
4420 'Ensure that it is available as <b>{1}</b>.</p>')\ 4440 'Ensure that it is available as <b>{1}</b>.</p>')\
4421 .format(tool['menutext'], tool['executable'])) 4441 .format(tool['menutext'], tool['executable']))
4518 pythonDocDir, "python{0}.chm".format(vers)) 4538 pythonDocDir, "python{0}.chm".format(vers))
4519 else: 4539 else:
4520 home = pythonDocDir 4540 home = pythonDocDir
4521 4541
4522 if not os.path.exists(home): 4542 if not os.path.exists(home):
4523 E5MessageBox.warning(self, 4543 E5MessageBox.warning(
4544 self,
4524 self.trUtf8("Documentation Missing"), 4545 self.trUtf8("Documentation Missing"),
4525 self.trUtf8("""<p>The documentation starting point""" 4546 self.trUtf8("""<p>The documentation starting point"""
4526 """ "<b>{0}</b>" could not be found.</p>""")\ 4547 """ "<b>{0}</b>" could not be found.</p>""")\
4527 .format(home)) 4548 .format(home))
4528 return 4549 return
4573 home = Utilities.normjoinpath(pythonDocDir, 'index.html') 4594 home = Utilities.normjoinpath(pythonDocDir, 'index.html')
4574 else: 4595 else:
4575 home = pythonDocDir 4596 home = pythonDocDir
4576 4597
4577 if not os.path.exists(home): 4598 if not os.path.exists(home):
4578 E5MessageBox.warning(self, 4599 E5MessageBox.warning(
4600 self,
4579 self.trUtf8("Documentation Missing"), 4601 self.trUtf8("Documentation Missing"),
4580 self.trUtf8("""<p>The documentation starting point""" 4602 self.trUtf8("""<p>The documentation starting point"""
4581 """ "<b>{0}</b>" could not be found.</p>""")\ 4603 """ "<b>{0}</b>" could not be found.</p>""")\
4582 .format(home)) 4604 .format(home))
4583 return 4605 return
4641 home = Utilities.normjoinpath(qtDocDir, 'index.html') 4663 home = Utilities.normjoinpath(qtDocDir, 'index.html')
4642 else: 4664 else:
4643 home = qtDocDir 4665 home = qtDocDir
4644 4666
4645 if not os.path.exists(home): 4667 if not os.path.exists(home):
4646 E5MessageBox.warning(self, 4668 E5MessageBox.warning(
4669 self,
4647 self.trUtf8("Documentation Missing"), 4670 self.trUtf8("Documentation Missing"),
4648 self.trUtf8("""<p>The documentation starting point""" 4671 self.trUtf8("""<p>The documentation starting point"""
4649 """ "<b>{0}</b>" could not be found.</p>""")\ 4672 """ "<b>{0}</b>" could not be found.</p>""")\
4650 .format(home)) 4673 .format(home))
4651 return 4674 return
4672 pyqt4DocDir = Preferences.getHelp("PyQt4DocDir") 4695 pyqt4DocDir = Preferences.getHelp("PyQt4DocDir")
4673 if not pyqt4DocDir: 4696 if not pyqt4DocDir:
4674 pyqt4DocDir = Utilities.getEnvironmentEntry("PYQT4DOCDIR", None) 4697 pyqt4DocDir = Utilities.getEnvironmentEntry("PYQT4DOCDIR", None)
4675 4698
4676 if not pyqt4DocDir: 4699 if not pyqt4DocDir:
4677 E5MessageBox.warning(self, 4700 E5MessageBox.warning(
4701 self,
4678 self.trUtf8("Documentation"), 4702 self.trUtf8("Documentation"),
4679 self.trUtf8("""<p>The PyQt4 documentation starting point""" 4703 self.trUtf8("""<p>The PyQt4 documentation starting point"""
4680 """ has not been configured.</p>""")) 4704 """ has not been configured.</p>"""))
4681 return 4705 return
4682 4706
4697 break 4721 break
4698 else: 4722 else:
4699 home = pyqt4DocDir 4723 home = pyqt4DocDir
4700 4724
4701 if not home or not os.path.exists(home): 4725 if not home or not os.path.exists(home):
4702 E5MessageBox.warning(self, 4726 E5MessageBox.warning(
4727 self,
4703 self.trUtf8("Documentation Missing"), 4728 self.trUtf8("Documentation Missing"),
4704 self.trUtf8("""<p>The documentation starting point""" 4729 self.trUtf8("""<p>The documentation starting point"""
4705 """ "<b>{0}</b>" could not be found.</p>""")\ 4730 """ "<b>{0}</b>" could not be found.</p>""")\
4706 .format(home)) 4731 .format(home))
4707 return 4732 return
4730 pyqt5DocDir = Preferences.getHelp("PyQt5DocDir") 4755 pyqt5DocDir = Preferences.getHelp("PyQt5DocDir")
4731 if not pyqt5DocDir: 4756 if not pyqt5DocDir:
4732 pyqt5DocDir = Utilities.getEnvironmentEntry("PYQT5DOCDIR", None) 4757 pyqt5DocDir = Utilities.getEnvironmentEntry("PYQT5DOCDIR", None)
4733 4758
4734 if not pyqt5DocDir: 4759 if not pyqt5DocDir:
4735 E5MessageBox.warning(self, 4760 E5MessageBox.warning(
4761 self,
4736 self.trUtf8("Documentation"), 4762 self.trUtf8("Documentation"),
4737 self.trUtf8("""<p>The PyQt5 documentation starting point""" 4763 self.trUtf8("""<p>The PyQt5 documentation starting point"""
4738 """ has not been configured.</p>""")) 4764 """ has not been configured.</p>"""))
4739 return 4765 return
4740 4766
4757 break 4783 break
4758 else: 4784 else:
4759 home = pyqt5DocDir 4785 home = pyqt5DocDir
4760 4786
4761 if not home or not os.path.exists(home): 4787 if not home or not os.path.exists(home):
4762 E5MessageBox.warning(self, 4788 E5MessageBox.warning(
4789 self,
4763 self.trUtf8("Documentation Missing"), 4790 self.trUtf8("Documentation Missing"),
4764 self.trUtf8("""<p>The documentation starting point""" 4791 self.trUtf8("""<p>The documentation starting point"""
4765 """ "<b>{0}</b>" could not be found.</p>""")\ 4792 """ "<b>{0}</b>" could not be found.</p>""")\
4766 .format(home)) 4793 .format(home))
4767 return 4794 return
4792 4819
4793 if not home.startswith("http://") and \ 4820 if not home.startswith("http://") and \
4794 not home.startswith("https://") and \ 4821 not home.startswith("https://") and \
4795 not home.startswith("qthelp://"): 4822 not home.startswith("qthelp://"):
4796 if not os.path.exists(home): 4823 if not os.path.exists(home):
4797 E5MessageBox.warning(self, 4824 E5MessageBox.warning(
4825 self,
4798 self.trUtf8("Documentation Missing"), 4826 self.trUtf8("Documentation Missing"),
4799 self.trUtf8("""<p>The documentation starting point""" 4827 self.trUtf8("""<p>The documentation starting point"""
4800 """ "<b>{0}</b>" could not be found.</p>""")\ 4828 """ "<b>{0}</b>" could not be found.</p>""")\
4801 .format(home)) 4829 .format(home))
4802 return 4830 return
4823 pysideDocDir = Preferences.getHelp("PySideDocDir") 4851 pysideDocDir = Preferences.getHelp("PySideDocDir")
4824 if not pysideDocDir: 4852 if not pysideDocDir:
4825 pysideDocDir = Utilities.getEnvironmentEntry("PYSIDEDOCDIR", None) 4853 pysideDocDir = Utilities.getEnvironmentEntry("PYSIDEDOCDIR", None)
4826 4854
4827 if not pysideDocDir: 4855 if not pysideDocDir:
4828 E5MessageBox.warning(self, 4856 E5MessageBox.warning(
4857 self,
4829 self.trUtf8("Documentation"), 4858 self.trUtf8("Documentation"),
4830 self.trUtf8("""<p>The PySide documentation starting point""" 4859 self.trUtf8("""<p>The PySide documentation starting point"""
4831 """ has not been configured.</p>""")) 4860 """ has not been configured.</p>"""))
4832 return 4861 return
4833 4862
4838 if not os.path.splitext(pysideDocDir)[1]: 4867 if not os.path.splitext(pysideDocDir)[1]:
4839 home = Utilities.normjoinpath(pysideDocDir, 'index.html') 4868 home = Utilities.normjoinpath(pysideDocDir, 'index.html')
4840 else: 4869 else:
4841 home = pysideDocDir 4870 home = pysideDocDir
4842 if not os.path.exists(home): 4871 if not os.path.exists(home):
4843 E5MessageBox.warning(self, 4872 E5MessageBox.warning(
4873 self,
4844 self.trUtf8("Documentation Missing"), 4874 self.trUtf8("Documentation Missing"),
4845 self.trUtf8("""<p>The documentation starting point""" 4875 self.trUtf8("""<p>The documentation starting point"""
4846 """ "<b>{0}</b>" could not be found.</p>""")\ 4876 """ "<b>{0}</b>" could not be found.</p>""")\
4847 .format(home)) 4877 .format(home))
4848 return 4878 return
4930 4960
4931 @param home full pathname of a file to display (string) 4961 @param home full pathname of a file to display (string)
4932 """ 4962 """
4933 started = QDesktopServices.openUrl(QUrl(home)) 4963 started = QDesktopServices.openUrl(QUrl(home))
4934 if not started: 4964 if not started:
4935 E5MessageBox.critical(self, 4965 E5MessageBox.critical(
4966 self,
4936 self.trUtf8('Open Browser'), 4967 self.trUtf8('Open Browser'),
4937 self.trUtf8('Could not start a web browser')) 4968 self.trUtf8('Could not start a web browser'))
4938 4969
4939 def getHelpViewer(self, preview=False): 4970 def getHelpViewer(self, preview=False):
4940 """ 4971 """
5262 """ 5293 """
5263 fn = os.path.join(Utilities.getConfigDir(), "eric5tasks.e4t") 5294 fn = os.path.join(Utilities.getConfigDir(), "eric5tasks.e4t")
5264 f = QFile(fn) 5295 f = QFile(fn)
5265 ok = f.open(QIODevice.WriteOnly) 5296 ok = f.open(QIODevice.WriteOnly)
5266 if not ok: 5297 if not ok:
5267 E5MessageBox.critical(self, 5298 E5MessageBox.critical(
5299 self,
5268 self.trUtf8("Save tasks"), 5300 self.trUtf8("Save tasks"),
5269 self.trUtf8( 5301 self.trUtf8(
5270 "<p>The tasks file <b>{0}</b> could not be written.</p>") 5302 "<p>The tasks file <b>{0}</b> could not be written.</p>")
5271 .format(fn)) 5303 .format(fn))
5272 return 5304 return
5287 from E5XML.TasksReader import TasksReader 5319 from E5XML.TasksReader import TasksReader
5288 reader = TasksReader(f, viewer=self.taskViewer) 5320 reader = TasksReader(f, viewer=self.taskViewer)
5289 reader.readXML() 5321 reader.readXML()
5290 f.close() 5322 f.close()
5291 else: 5323 else:
5292 E5MessageBox.critical(self, 5324 E5MessageBox.critical(
5325 self,
5293 self.trUtf8("Read tasks"), 5326 self.trUtf8("Read tasks"),
5294 self.trUtf8( 5327 self.trUtf8(
5295 "<p>The tasks file <b>{0}</b> could not be read.</p>") 5328 "<p>The tasks file <b>{0}</b> could not be read.</p>")
5296 .format(fn)) 5329 .format(fn))
5297 5330
5304 if f.open(QIODevice.WriteOnly): 5337 if f.open(QIODevice.WriteOnly):
5305 from E5XML.SessionWriter import SessionWriter 5338 from E5XML.SessionWriter import SessionWriter
5306 SessionWriter(f, None).writeXML() 5339 SessionWriter(f, None).writeXML()
5307 f.close() 5340 f.close()
5308 else: 5341 else:
5309 E5MessageBox.critical(self, 5342 E5MessageBox.critical(
5343 self,
5310 self.trUtf8("Save session"), 5344 self.trUtf8("Save session"),
5311 self.trUtf8( 5345 self.trUtf8(
5312 "<p>The session file <b>{0}</b> could not be written.</p>") 5346 "<p>The session file <b>{0}</b> could not be written.</p>")
5313 .format(fn)) 5347 .format(fn))
5314 5348
5316 """ 5350 """
5317 Private slot to read in the session file (.e4s). 5351 Private slot to read in the session file (.e4s).
5318 """ 5352 """
5319 fn = os.path.join(Utilities.getConfigDir(), "eric5session.e4s") 5353 fn = os.path.join(Utilities.getConfigDir(), "eric5session.e4s")
5320 if not os.path.exists(fn): 5354 if not os.path.exists(fn):
5321 E5MessageBox.critical(self, 5355 E5MessageBox.critical(
5356 self,
5322 self.trUtf8("Read session"), 5357 self.trUtf8("Read session"),
5323 self.trUtf8( 5358 self.trUtf8(
5324 "<p>The session file <b>{0}</b> could not be read.</p>")\ 5359 "<p>The session file <b>{0}</b> could not be read.</p>")\
5325 .format(fn)) 5360 .format(fn))
5326 return 5361 return
5330 from E5XML.SessionReader import SessionReader 5365 from E5XML.SessionReader import SessionReader
5331 reader = SessionReader(f, True) 5366 reader = SessionReader(f, True)
5332 reader.readXML() 5367 reader.readXML()
5333 f.close() 5368 f.close()
5334 else: 5369 else:
5335 E5MessageBox.critical(self, 5370 E5MessageBox.critical(
5371 self,
5336 self.trUtf8("Read session"), 5372 self.trUtf8("Read session"),
5337 self.trUtf8( 5373 self.trUtf8(
5338 "<p>The session file <b>{0}</b> could not be read.</p>")\ 5374 "<p>The session file <b>{0}</b> could not be read.</p>")\
5339 .format(fn)) 5375 .format(fn))
5340 5376
5512 fname = url.toLocalFile() 5548 fname = url.toLocalFile()
5513 if fname: 5549 if fname:
5514 if QFileInfo(fname).isFile(): 5550 if QFileInfo(fname).isFile():
5515 self.viewmanager.openSourceFile(fname) 5551 self.viewmanager.openSourceFile(fname)
5516 else: 5552 else:
5517 E5MessageBox.information(self, 5553 E5MessageBox.information(
5554 self,
5518 self.trUtf8("Drop Error"), 5555 self.trUtf8("Drop Error"),
5519 self.trUtf8("""<p><b>{0}</b> is not a file.</p>""") 5556 self.trUtf8("""<p><b>{0}</b> is not a file.</p>""")
5520 .format(fname)) 5557 .format(fname))
5521 5558
5522 self.inDragDrop = False 5559 self.inDragDrop = False
5702 "Updates/FirstFailedCheckDate", QDate.currentDate()) 5739 "Updates/FirstFailedCheckDate", QDate.currentDate())
5703 failedDuration = firstFailure.daysTo(QDate.currentDate()) 5740 failedDuration = firstFailure.daysTo(QDate.currentDate())
5704 Preferences.Prefs.settings.setValue( 5741 Preferences.Prefs.settings.setValue(
5705 "Updates/FirstFailedCheckDate", firstFailure) 5742 "Updates/FirstFailedCheckDate", firstFailure)
5706 if self.manualUpdatesCheck: 5743 if self.manualUpdatesCheck:
5707 E5MessageBox.warning(self, 5744 E5MessageBox.warning(
5745 self,
5708 self.trUtf8("Error getting versions information"), 5746 self.trUtf8("Error getting versions information"),
5709 self.trUtf8("""The versions information could not be""" 5747 self.trUtf8("""The versions information could not be"""
5710 """ downloaded.""" 5748 """ downloaded."""
5711 """ Please go online and try again.""")) 5749 """ Please go online and try again."""))
5712 elif failedDuration > 7: 5750 elif failedDuration > 7:
5713 E5MessageBox.warning(self, 5751 E5MessageBox.warning(
5752 self,
5714 self.trUtf8("Error getting versions information"), 5753 self.trUtf8("Error getting versions information"),
5715 self.trUtf8("""The versions information could not be""" 5754 self.trUtf8("""The versions information could not be"""
5716 """ downloaded for the last 7 days.""" 5755 """ downloaded for the last 7 days."""
5717 """ Please go online and try again.""")) 5756 """ Please go online and try again."""))
5718 return 5757 return
5813 self.trUtf8("Eric5 is up to date"), 5852 self.trUtf8("Eric5 is up to date"),
5814 self.trUtf8( 5853 self.trUtf8(
5815 """You are using the latest version of""" 5854 """You are using the latest version of"""
5816 """ eric5""")) 5855 """ eric5"""))
5817 except IndexError: 5856 except IndexError:
5818 E5MessageBox.warning(self, 5857 E5MessageBox.warning(
5858 self,
5819 self.trUtf8("Error during updates check"), 5859 self.trUtf8("Error during updates check"),
5820 self.trUtf8("""Could not perform updates check.""")) 5860 self.trUtf8("""Could not perform updates check."""))
5821 5861
5822 if url: 5862 if url:
5823 QDesktopServices.openUrl(QUrl(url)) 5863 QDesktopServices.openUrl(QUrl(url))
5876 the configuration dialog is shown. 5916 the configuration dialog is shown.
5877 """ 5917 """
5878 if not Preferences.isConfigured(): 5918 if not Preferences.isConfigured():
5879 self.__initDebugToolbarsLayout() 5919 self.__initDebugToolbarsLayout()
5880 5920
5881 E5MessageBox.information(self, 5921 E5MessageBox.information(
5922 self,
5882 self.trUtf8("First time usage"), 5923 self.trUtf8("First time usage"),
5883 self.trUtf8("""eric5 has not been configured yet. """ 5924 self.trUtf8("""eric5 has not been configured yet. """
5884 """The configuration dialog will be started.""")) 5925 """The configuration dialog will be started."""))
5885 self.showPreferences() 5926 self.showPreferences()
5886 5927

eric ide

mercurial