QScintilla/MiniEditor.py

changeset 3020
542e97d4ecb3
parent 3011
18292228c724
child 3030
4a0a82ddd9d2
equal deleted inserted replaced
3019:7912530a33e2 3020:542e97d4ecb3
245 245
246 def __about(self): 246 def __about(self):
247 """ 247 """
248 Private slot to show a little About message. 248 Private slot to show a little About message.
249 """ 249 """
250 E5MessageBox.about(self, self.trUtf8("About eric5 Mini Editor"), 250 E5MessageBox.about(
251 self,
252 self.trUtf8("About eric5 Mini Editor"),
251 self.trUtf8("The eric5 Mini Editor is an editor component" 253 self.trUtf8("The eric5 Mini Editor is an editor component"
252 " based on QScintilla. It may be used for simple" 254 " based on QScintilla. It may be used for simple"
253 " editing tasks, that don't need the power of" 255 " editing tasks, that don't need the power of"
254 " a full blown editor.")) 256 " a full blown editor."))
255 257
2074 Private method to ask the user to save the file, if it was modified. 2076 Private method to ask the user to save the file, if it was modified.
2075 2077
2076 @return flag indicating, if it is ok to continue (boolean) 2078 @return flag indicating, if it is ok to continue (boolean)
2077 """ 2079 """
2078 if self.__textEdit.isModified(): 2080 if self.__textEdit.isModified():
2079 ret = E5MessageBox.okToClearData(self, 2081 ret = E5MessageBox.okToClearData(
2080 self.trUtf8("eric5 Mini Editor"), 2082 self,
2081 self.trUtf8("The document has unsaved changes."), 2083 self.trUtf8("eric5 Mini Editor"),
2082 self.__save) 2084 self.trUtf8("The document has unsaved changes."),
2085 self.__save)
2083 return ret 2086 return ret
2084 return True 2087 return True
2085 2088
2086 def __loadFile(self, fileName, filetype=None): 2089 def __loadFile(self, fileName, filetype=None):
2087 """ 2090 """
2094 2097
2095 try: 2098 try:
2096 txt, self.encoding = Utilities.readEncodedFile(fileName) 2099 txt, self.encoding = Utilities.readEncodedFile(fileName)
2097 except (UnicodeDecodeError, IOError) as why: 2100 except (UnicodeDecodeError, IOError) as why:
2098 QApplication.restoreOverrideCursor() 2101 QApplication.restoreOverrideCursor()
2099 E5MessageBox.critical(self, self.trUtf8('Open File'), 2102 E5MessageBox.critical(
2103 self, self.trUtf8('Open File'),
2100 self.trUtf8('<p>The file <b>{0}</b> could not be opened.</p>' 2104 self.trUtf8('<p>The file <b>{0}</b> could not be opened.</p>'
2101 '<p>Reason: {1}</p>') 2105 '<p>Reason: {1}</p>')
2102 .format(fileName, str(why))) 2106 .format(fileName, str(why)))
2103 QApplication.restoreOverrideCursor() 2107 QApplication.restoreOverrideCursor()
2104 return 2108 return
2128 txt = self.__textEdit.text() 2132 txt = self.__textEdit.text()
2129 try: 2133 try:
2130 self.encoding = Utilities.writeEncodedFile( 2134 self.encoding = Utilities.writeEncodedFile(
2131 fileName, txt, self.encoding) 2135 fileName, txt, self.encoding)
2132 except (IOError, Utilities.CodingError, UnicodeError) as why: 2136 except (IOError, Utilities.CodingError, UnicodeError) as why:
2133 E5MessageBox.critical(self, self.trUtf8('Save File'), 2137 E5MessageBox.critical(
2138 self, self.trUtf8('Save File'),
2134 self.trUtf8('<p>The file <b>{0}</b> could not be saved.<br/>' 2139 self.trUtf8('<p>The file <b>{0}</b> could not be saved.<br/>'
2135 'Reason: {1}</p>') 2140 'Reason: {1}</p>')
2136 .format(fileName, str(why))) 2141 .format(fileName, str(why)))
2137 QApplication.restoreOverrideCursor() 2142 QApplication.restoreOverrideCursor()
2138 2143

eric ide

mercurial