Snapshot/SnapWidget.py

changeset 3020
542e97d4ecb3
parent 2993
4933ac9daa80
child 3030
4a0a82ddd9d2
equal deleted inserted replaced
3019:7912530a33e2 3020:542e97d4ecb3
213 213
214 @param fileName name of the file to save to (string) 214 @param fileName name of the file to save to (string)
215 @return flag indicating success (boolean) 215 @return flag indicating success (boolean)
216 """ 216 """
217 if QFileInfo(fileName).exists(): 217 if QFileInfo(fileName).exists():
218 res = E5MessageBox.yesNo(self, 218 res = E5MessageBox.yesNo(
219 self,
219 self.trUtf8("Save Snapshot"), 220 self.trUtf8("Save Snapshot"),
220 self.trUtf8("<p>The file <b>{0}</b> already exists." 221 self.trUtf8("<p>The file <b>{0}</b> already exists."
221 " Overwrite it?</p>").format(fileName), 222 " Overwrite it?</p>").format(fileName),
222 icon=E5MessageBox.Warning) 223 icon=E5MessageBox.Warning)
223 if not res: 224 if not res:
224 return False 225 return False
225 226
226 file = QFile(fileName) 227 file = QFile(fileName)
227 if not file.open(QFile.WriteOnly): 228 if not file.open(QFile.WriteOnly):
228 E5MessageBox.warning(self, self.trUtf8("Save Snapshot"), 229 E5MessageBox.warning(
229 self.trUtf8("Cannot write file '{0}:\n{1}.")\ 230 self, self.trUtf8("Save Snapshot"),
230 .format(fileName, file.errorString())) 231 self.trUtf8("Cannot write file '{0}:\n{1}.")\
232 .format(fileName, file.errorString()))
231 return False 233 return False
232 234
233 ok = self.__snapshot.save(file) 235 ok = self.__snapshot.save(file)
234 file.close() 236 file.close()
235 237
236 if not ok: 238 if not ok:
237 E5MessageBox.warning(self, self.trUtf8("Save Snapshot"), 239 E5MessageBox.warning(
238 self.trUtf8("Cannot write file '{0}:\n{1}.")\ 240 self, self.trUtf8("Save Snapshot"),
239 .format(fileName, file.errorString())) 241 self.trUtf8("Cannot write file '{0}:\n{1}.")\
242 .format(fileName, file.errorString()))
240 243
241 return ok 244 return ok
242 245
243 def __autoIncFilename(self): 246 def __autoIncFilename(self):
244 """ 247 """
471 Protected method handling the close event. 474 Protected method handling the close event.
472 475
473 @param evt close event (QCloseEvent) 476 @param evt close event (QCloseEvent)
474 """ 477 """
475 if self.__modified: 478 if self.__modified:
476 res = E5MessageBox.question(self, 479 res = E5MessageBox.question(
480 self,
477 self.trUtf8("eric5 Snapshot"), 481 self.trUtf8("eric5 Snapshot"),
478 self.trUtf8( 482 self.trUtf8(
479 """The application contains an unsaved snapshot."""), 483 """The application contains an unsaved snapshot."""),
480 E5MessageBox.StandardButtons( 484 E5MessageBox.StandardButtons(
481 E5MessageBox.Abort | \ 485 E5MessageBox.Abort | \

eric ide

mercurial