20 QStandardPaths |
20 QStandardPaths |
21 ) |
21 ) |
22 from PyQt6.QtGui import QImageWriter, QPixmap, QDrag, QKeySequence, QShortcut |
22 from PyQt6.QtGui import QImageWriter, QPixmap, QDrag, QKeySequence, QShortcut |
23 from PyQt6.QtWidgets import QWidget, QApplication |
23 from PyQt6.QtWidgets import QWidget, QApplication |
24 |
24 |
25 from E5Gui import E5FileDialog, E5MessageBox |
25 from E5Gui import EricFileDialog, EricMessageBox |
26 |
26 |
27 from .Ui_SnapWidget import Ui_SnapWidget |
27 from .Ui_SnapWidget import Ui_SnapWidget |
28 |
28 |
29 import UI.PixmapCache |
29 import UI.PixmapCache |
30 import Preferences |
30 import Preferences |
198 """ |
198 """ |
199 if not self.__snapshot.isNull(): |
199 if not self.__snapshot.isNull(): |
200 while os.path.exists(self.__filename): |
200 while os.path.exists(self.__filename): |
201 self.__autoIncFilename() |
201 self.__autoIncFilename() |
202 |
202 |
203 fileName, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( |
203 fileName, selectedFilter = EricFileDialog.getSaveFileNameAndFilter( |
204 self, |
204 self, |
205 self.tr("Save Snapshot"), |
205 self.tr("Save Snapshot"), |
206 self.__filename, |
206 self.__filename, |
207 self.__outputFilter, |
207 self.__outputFilter, |
208 self.__defaultFilter, |
208 self.__defaultFilter, |
209 E5FileDialog.DontConfirmOverwrite) |
209 EricFileDialog.DontConfirmOverwrite) |
210 if not fileName: |
210 if not fileName: |
211 return |
211 return |
212 |
212 |
213 ext = QFileInfo(fileName).suffix() |
213 ext = QFileInfo(fileName).suffix() |
214 if not ext: |
214 if not ext: |
228 |
228 |
229 @param fileName name of the file to save to (string) |
229 @param fileName name of the file to save to (string) |
230 @return flag indicating success (boolean) |
230 @return flag indicating success (boolean) |
231 """ |
231 """ |
232 if QFileInfo(fileName).exists(): |
232 if QFileInfo(fileName).exists(): |
233 res = E5MessageBox.yesNo( |
233 res = EricMessageBox.yesNo( |
234 self, |
234 self, |
235 self.tr("Save Snapshot"), |
235 self.tr("Save Snapshot"), |
236 self.tr("<p>The file <b>{0}</b> already exists." |
236 self.tr("<p>The file <b>{0}</b> already exists." |
237 " Overwrite it?</p>").format(fileName), |
237 " Overwrite it?</p>").format(fileName), |
238 icon=E5MessageBox.Warning) |
238 icon=EricMessageBox.Warning) |
239 if not res: |
239 if not res: |
240 return False |
240 return False |
241 |
241 |
242 file = QFile(fileName) |
242 file = QFile(fileName) |
243 if not file.open(QFile.WriteOnly): |
243 if not file.open(QFile.WriteOnly): |
244 E5MessageBox.warning( |
244 EricMessageBox.warning( |
245 self, self.tr("Save Snapshot"), |
245 self, self.tr("Save Snapshot"), |
246 self.tr("Cannot write file '{0}:\n{1}.") |
246 self.tr("Cannot write file '{0}:\n{1}.") |
247 .format(fileName, file.errorString())) |
247 .format(fileName, file.errorString())) |
248 return False |
248 return False |
249 |
249 |
250 ok = self.__snapshot.save(file) |
250 ok = self.__snapshot.save(file) |
251 file.close() |
251 file.close() |
252 |
252 |
253 if not ok: |
253 if not ok: |
254 E5MessageBox.warning( |
254 EricMessageBox.warning( |
255 self, self.tr("Save Snapshot"), |
255 self, self.tr("Save Snapshot"), |
256 self.tr("Cannot write file '{0}:\n{1}.") |
256 self.tr("Cannot write file '{0}:\n{1}.") |
257 .format(fileName, file.errorString())) |
257 .format(fileName, file.errorString())) |
258 |
258 |
259 return ok |
259 return ok |
386 Protected method handling the close event. |
386 Protected method handling the close event. |
387 |
387 |
388 @param evt close event (QCloseEvent) |
388 @param evt close event (QCloseEvent) |
389 """ |
389 """ |
390 if self.__modified: |
390 if self.__modified: |
391 res = E5MessageBox.question( |
391 res = EricMessageBox.question( |
392 self, |
392 self, |
393 self.tr("eric Snapshot"), |
393 self.tr("eric Snapshot"), |
394 self.tr( |
394 self.tr( |
395 """The application contains an unsaved snapshot."""), |
395 """The application contains an unsaved snapshot."""), |
396 E5MessageBox.Abort | E5MessageBox.Discard | E5MessageBox.Save |
396 EricMessageBox.Abort | EricMessageBox.Discard | EricMessageBox.Save |
397 ) |
397 ) |
398 if res == E5MessageBox.Abort: |
398 if res == EricMessageBox.Abort: |
399 evt.ignore() |
399 evt.ignore() |
400 return |
400 return |
401 elif res == E5MessageBox.Save: |
401 elif res == EricMessageBox.Save: |
402 self.on_saveButton_clicked() |
402 self.on_saveButton_clicked() |
403 |
403 |
404 Preferences.Prefs.settings.setValue( |
404 Preferences.Prefs.settings.setValue( |
405 "Snapshot/Delay", self.delaySpin.value()) |
405 "Snapshot/Delay", self.delaySpin.value()) |
406 modeData = self.modeCombo.itemData(self.modeCombo.currentIndex()) |
406 modeData = self.modeCombo.itemData(self.modeCombo.currentIndex()) |