50 self.takeButton.setIcon(UI.PixmapCache.getIcon("cameraPhoto.png")) |
50 self.takeButton.setIcon(UI.PixmapCache.getIcon("cameraPhoto.png")) |
51 self.copyButton.setIcon(UI.PixmapCache.getIcon("editCopy.png")) |
51 self.copyButton.setIcon(UI.PixmapCache.getIcon("editCopy.png")) |
52 self.copyPreviewButton.setIcon(UI.PixmapCache.getIcon("editCopy.png")) |
52 self.copyPreviewButton.setIcon(UI.PixmapCache.getIcon("editCopy.png")) |
53 self.setWindowIcon(UI.PixmapCache.getIcon("ericSnap.png")) |
53 self.setWindowIcon(UI.PixmapCache.getIcon("ericSnap.png")) |
54 |
54 |
55 self.modeCombo.addItem(self.trUtf8("Fullscreen"), |
55 self.modeCombo.addItem(self.tr("Fullscreen"), |
56 SnapWidget.ModeFullscreen) |
56 SnapWidget.ModeFullscreen) |
57 self.modeCombo.addItem(self.trUtf8("Rectangular Selection"), |
57 self.modeCombo.addItem(self.tr("Rectangular Selection"), |
58 SnapWidget.ModeRectangle) |
58 SnapWidget.ModeRectangle) |
59 self.modeCombo.addItem(self.trUtf8("Ellipical Selection"), |
59 self.modeCombo.addItem(self.tr("Ellipical Selection"), |
60 SnapWidget.ModeEllipse) |
60 SnapWidget.ModeEllipse) |
61 self.modeCombo.addItem(self.trUtf8("Freehand Selection"), |
61 self.modeCombo.addItem(self.tr("Freehand Selection"), |
62 SnapWidget.ModeFreehand) |
62 SnapWidget.ModeFreehand) |
63 if QApplication.desktop().numScreens() > 1: |
63 if QApplication.desktop().numScreens() > 1: |
64 self.modeCombo.addItem(self.trUtf8("Current Screen"), |
64 self.modeCombo.addItem(self.tr("Current Screen"), |
65 SnapWidget.ModeScreen) |
65 SnapWidget.ModeScreen) |
66 self.__mode = int(Preferences.Prefs.settings.value("Snapshot/Mode", 0)) |
66 self.__mode = int(Preferences.Prefs.settings.value("Snapshot/Mode", 0)) |
67 index = self.modeCombo.findData(self.__mode) |
67 index = self.modeCombo.findData(self.__mode) |
68 if index == -1: |
68 if index == -1: |
69 index = 0 |
69 index = 0 |
76 self.__filename = Preferences.Prefs.settings.value( |
76 self.__filename = Preferences.Prefs.settings.value( |
77 "Snapshot/Filename", |
77 "Snapshot/Filename", |
78 os.path.join( |
78 os.path.join( |
79 QDesktopServices.storageLocation( |
79 QDesktopServices.storageLocation( |
80 QDesktopServices.PicturesLocation), |
80 QDesktopServices.PicturesLocation), |
81 self.trUtf8("snapshot") + "1.png")) |
81 self.tr("snapshot") + "1.png")) |
82 |
82 |
83 self.__grabber = None |
83 self.__grabber = None |
84 self.__snapshot = QPixmap() |
84 self.__snapshot = QPixmap() |
85 self.__savedPosition = QPoint() |
85 self.__savedPosition = QPoint() |
86 self.__modified = False |
86 self.__modified = False |
108 def __initFileFilters(self): |
108 def __initFileFilters(self): |
109 """ |
109 """ |
110 Private method to define the supported image file filters. |
110 Private method to define the supported image file filters. |
111 """ |
111 """ |
112 filters = { |
112 filters = { |
113 'bmp': self.trUtf8("Windows Bitmap File (*.bmp)"), |
113 'bmp': self.tr("Windows Bitmap File (*.bmp)"), |
114 'gif': self.trUtf8("Graphic Interchange Format File (*.gif)"), |
114 'gif': self.tr("Graphic Interchange Format File (*.gif)"), |
115 'ico': self.trUtf8("Windows Icon File (*.ico)"), |
115 'ico': self.tr("Windows Icon File (*.ico)"), |
116 'jpg': self.trUtf8("JPEG File (*.jpg)"), |
116 'jpg': self.tr("JPEG File (*.jpg)"), |
117 'mng': self.trUtf8("Multiple-Image Network Graphics File (*.mng)"), |
117 'mng': self.tr("Multiple-Image Network Graphics File (*.mng)"), |
118 'pbm': self.trUtf8("Portable Bitmap File (*.pbm)"), |
118 'pbm': self.tr("Portable Bitmap File (*.pbm)"), |
119 'pcx': self.trUtf8("Paintbrush Bitmap File (*.pcx)"), |
119 'pcx': self.tr("Paintbrush Bitmap File (*.pcx)"), |
120 'pgm': self.trUtf8("Portable Graymap File (*.pgm)"), |
120 'pgm': self.tr("Portable Graymap File (*.pgm)"), |
121 'png': self.trUtf8("Portable Network Graphics File (*.png)"), |
121 'png': self.tr("Portable Network Graphics File (*.png)"), |
122 'ppm': self.trUtf8("Portable Pixmap File (*.ppm)"), |
122 'ppm': self.tr("Portable Pixmap File (*.ppm)"), |
123 'sgi': self.trUtf8("Silicon Graphics Image File (*.sgi)"), |
123 'sgi': self.tr("Silicon Graphics Image File (*.sgi)"), |
124 'svg': self.trUtf8("Scalable Vector Graphics File (*.svg)"), |
124 'svg': self.tr("Scalable Vector Graphics File (*.svg)"), |
125 'tga': self.trUtf8("Targa Graphic File (*.tga)"), |
125 'tga': self.tr("Targa Graphic File (*.tga)"), |
126 'tif': self.trUtf8("TIFF File (*.tif)"), |
126 'tif': self.tr("TIFF File (*.tif)"), |
127 'xbm': self.trUtf8("X11 Bitmap File (*.xbm)"), |
127 'xbm': self.tr("X11 Bitmap File (*.xbm)"), |
128 'xpm': self.trUtf8("X11 Pixmap File (*.xpm)"), |
128 'xpm': self.tr("X11 Pixmap File (*.xpm)"), |
129 } |
129 } |
130 |
130 |
131 outputFormats = [] |
131 outputFormats = [] |
132 writeFormats = QImageWriter.supportedImageFormats() |
132 writeFormats = QImageWriter.supportedImageFormats() |
133 for writeFormat in writeFormats: |
133 for writeFormat in writeFormats: |
189 while os.path.exists(self.__filename): |
189 while os.path.exists(self.__filename): |
190 self.__autoIncFilename() |
190 self.__autoIncFilename() |
191 |
191 |
192 fileName, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( |
192 fileName, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( |
193 self, |
193 self, |
194 self.trUtf8("Save Snapshot"), |
194 self.tr("Save Snapshot"), |
195 self.__filename, |
195 self.__filename, |
196 self.__outputFilter, |
196 self.__outputFilter, |
197 self.__defaultFilter, |
197 self.__defaultFilter, |
198 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) |
198 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) |
199 if not fileName: |
199 if not fileName: |
219 @return flag indicating success (boolean) |
219 @return flag indicating success (boolean) |
220 """ |
220 """ |
221 if QFileInfo(fileName).exists(): |
221 if QFileInfo(fileName).exists(): |
222 res = E5MessageBox.yesNo( |
222 res = E5MessageBox.yesNo( |
223 self, |
223 self, |
224 self.trUtf8("Save Snapshot"), |
224 self.tr("Save Snapshot"), |
225 self.trUtf8("<p>The file <b>{0}</b> already exists." |
225 self.tr("<p>The file <b>{0}</b> already exists." |
226 " Overwrite it?</p>").format(fileName), |
226 " Overwrite it?</p>").format(fileName), |
227 icon=E5MessageBox.Warning) |
227 icon=E5MessageBox.Warning) |
228 if not res: |
228 if not res: |
229 return False |
229 return False |
230 |
230 |
231 file = QFile(fileName) |
231 file = QFile(fileName) |
232 if not file.open(QFile.WriteOnly): |
232 if not file.open(QFile.WriteOnly): |
233 E5MessageBox.warning( |
233 E5MessageBox.warning( |
234 self, self.trUtf8("Save Snapshot"), |
234 self, self.tr("Save Snapshot"), |
235 self.trUtf8("Cannot write file '{0}:\n{1}.") |
235 self.tr("Cannot write file '{0}:\n{1}.") |
236 .format(fileName, file.errorString())) |
236 .format(fileName, file.errorString())) |
237 return False |
237 return False |
238 |
238 |
239 ok = self.__snapshot.save(file) |
239 ok = self.__snapshot.save(file) |
240 file.close() |
240 file.close() |
241 |
241 |
242 if not ok: |
242 if not ok: |
243 E5MessageBox.warning( |
243 E5MessageBox.warning( |
244 self, self.trUtf8("Save Snapshot"), |
244 self, self.tr("Save Snapshot"), |
245 self.trUtf8("Cannot write file '{0}:\n{1}.") |
245 self.tr("Cannot write file '{0}:\n{1}.") |
246 .format(fileName, file.errorString())) |
246 .format(fileName, file.errorString())) |
247 |
247 |
248 return ok |
248 return ok |
249 |
249 |
250 def __autoIncFilename(self): |
250 def __autoIncFilename(self): |
438 |
438 |
439 def __updatePreview(self): |
439 def __updatePreview(self): |
440 """ |
440 """ |
441 Private slot to update the preview picture. |
441 Private slot to update the preview picture. |
442 """ |
442 """ |
443 self.preview.setToolTip(self.trUtf8( |
443 self.preview.setToolTip(self.tr( |
444 "Preview of the snapshot image ({0:n} x {1:n})").format( |
444 "Preview of the snapshot image ({0:n} x {1:n})").format( |
445 self.__snapshot.width(), self.__snapshot.height())) |
445 self.__snapshot.width(), self.__snapshot.height())) |
446 self.preview.setPreview(self.__snapshot) |
446 self.preview.setPreview(self.__snapshot) |
447 self.preview.adjustSize() |
447 self.preview.adjustSize() |
448 |
448 |
489 @param evt close event (QCloseEvent) |
489 @param evt close event (QCloseEvent) |
490 """ |
490 """ |
491 if self.__modified: |
491 if self.__modified: |
492 res = E5MessageBox.question( |
492 res = E5MessageBox.question( |
493 self, |
493 self, |
494 self.trUtf8("eric5 Snapshot"), |
494 self.tr("eric5 Snapshot"), |
495 self.trUtf8( |
495 self.tr( |
496 """The application contains an unsaved snapshot."""), |
496 """The application contains an unsaved snapshot."""), |
497 E5MessageBox.StandardButtons( |
497 E5MessageBox.StandardButtons( |
498 E5MessageBox.Abort | |
498 E5MessageBox.Abort | |
499 E5MessageBox.Discard | |
499 E5MessageBox.Discard | |
500 E5MessageBox.Save)) |
500 E5MessageBox.Save)) |
517 """ |
517 """ |
518 Private method to update the window caption. |
518 Private method to update the window caption. |
519 """ |
519 """ |
520 self.setWindowTitle("{0}[*] - {1}".format( |
520 self.setWindowTitle("{0}[*] - {1}".format( |
521 os.path.basename(self.__filename), |
521 os.path.basename(self.__filename), |
522 self.trUtf8("eric5 Snapshot"))) |
522 self.tr("eric5 Snapshot"))) |
523 self.setWindowModified(self.__modified) |
523 self.setWindowModified(self.__modified) |
524 self.pathNameEdit.setText(os.path.dirname(self.__filename)) |
524 self.pathNameEdit.setText(os.path.dirname(self.__filename)) |