72 |
72 |
73 self.__delay = int( |
73 self.__delay = int( |
74 Preferences.Prefs.settings.value("Snapshot/Delay", 0)) |
74 Preferences.Prefs.settings.value("Snapshot/Delay", 0)) |
75 self.delaySpin.setValue(self.__delay) |
75 self.delaySpin.setValue(self.__delay) |
76 |
76 |
77 self.__filename = Preferences.Prefs.settings.value("Snapshot/Filename", |
77 self.__filename = Preferences.Prefs.settings.value( |
|
78 "Snapshot/Filename", |
78 os.path.join( |
79 os.path.join( |
79 QDesktopServices.storageLocation( |
80 QDesktopServices.storageLocation( |
80 QDesktopServices.PicturesLocation), |
81 QDesktopServices.PicturesLocation), |
81 self.trUtf8("snapshot") + "1.png")) |
82 self.trUtf8("snapshot") + "1.png")) |
82 |
83 |
145 Private method to initialize the keyboard shortcuts. |
146 Private method to initialize the keyboard shortcuts. |
146 """ |
147 """ |
147 self.__quitShortcut = QShortcut( |
148 self.__quitShortcut = QShortcut( |
148 QKeySequence(QKeySequence.Quit), self, self.close) |
149 QKeySequence(QKeySequence.Quit), self, self.close) |
149 |
150 |
150 self.__copyShortcut = QShortcut(QKeySequence(QKeySequence.Copy), self, |
151 self.__copyShortcut = QShortcut( |
|
152 QKeySequence(QKeySequence.Copy), self, |
151 self.copyButton.animateClick) |
153 self.copyButton.animateClick) |
152 |
154 |
153 self.__quickSaveShortcut = QShortcut(QKeySequence(Qt.Key_Q), self, |
155 self.__quickSaveShortcut = QShortcut( |
154 self.__quickSave) |
156 QKeySequence(Qt.Key_Q), self, self.__quickSave) |
155 |
157 |
156 self.__save1Shortcut = QShortcut(QKeySequence(QKeySequence.Save), self, |
158 self.__save1Shortcut = QShortcut( |
|
159 QKeySequence(QKeySequence.Save), self, |
157 self.saveButton.animateClick) |
160 self.saveButton.animateClick) |
158 self.__save2Shortcut = QShortcut(QKeySequence(Qt.Key_S), self, |
161 self.__save2Shortcut = QShortcut( |
159 self.saveButton.animateClick) |
162 QKeySequence(Qt.Key_S), self, self.saveButton.animateClick) |
160 |
163 |
161 self.__grab1Shortcut = QShortcut(QKeySequence(QKeySequence.New), self, |
164 self.__grab1Shortcut = QShortcut( |
162 self.takeButton.animateClick) |
165 QKeySequence(QKeySequence.New), self, self.takeButton.animateClick) |
163 self.__grab2Shortcut = QShortcut(QKeySequence(Qt.Key_N), self, |
166 self.__grab2Shortcut = QShortcut( |
164 self.takeButton.animateClick) |
167 QKeySequence(Qt.Key_N), self, self.takeButton.animateClick) |
165 self.__grab3Shortcut = QShortcut(QKeySequence(Qt.Key_Space), self, |
168 self.__grab3Shortcut = QShortcut( |
166 self.takeButton.animateClick) |
169 QKeySequence(Qt.Key_Space), self, self.takeButton.animateClick) |
167 |
170 |
168 def __quickSave(self): |
171 def __quickSave(self): |
169 """ |
172 """ |
170 Private slot to save the snapshot bypassing the file selection dialog. |
173 Private slot to save the snapshot bypassing the file selection dialog. |
171 """ |
174 """ |
215 |
218 |
216 @param fileName name of the file to save to (string) |
219 @param fileName name of the file to save to (string) |
217 @return flag indicating success (boolean) |
220 @return flag indicating success (boolean) |
218 """ |
221 """ |
219 if QFileInfo(fileName).exists(): |
222 if QFileInfo(fileName).exists(): |
220 res = E5MessageBox.yesNo(self, |
223 res = E5MessageBox.yesNo( |
|
224 self, |
221 self.trUtf8("Save Snapshot"), |
225 self.trUtf8("Save Snapshot"), |
222 self.trUtf8("<p>The file <b>{0}</b> already exists." |
226 self.trUtf8("<p>The file <b>{0}</b> already exists." |
223 " Overwrite it?</p>").format(fileName), |
227 " Overwrite it?</p>").format(fileName), |
224 icon=E5MessageBox.Warning) |
228 icon=E5MessageBox.Warning) |
225 if not res: |
229 if not res: |
226 return False |
230 return False |
227 |
231 |
228 file = QFile(fileName) |
232 file = QFile(fileName) |
229 if not file.open(QFile.WriteOnly): |
233 if not file.open(QFile.WriteOnly): |
230 E5MessageBox.warning(self, self.trUtf8("Save Snapshot"), |
234 E5MessageBox.warning( |
231 self.trUtf8("Cannot write file '{0}:\n{1}.")\ |
235 self, self.trUtf8("Save Snapshot"), |
232 .format(fileName, file.errorString())) |
236 self.trUtf8("Cannot write file '{0}:\n{1}.")\ |
|
237 .format(fileName, file.errorString())) |
233 return False |
238 return False |
234 |
239 |
235 ok = self.__snapshot.save(file) |
240 ok = self.__snapshot.save(file) |
236 file.close() |
241 file.close() |
237 |
242 |
238 if not ok: |
243 if not ok: |
239 E5MessageBox.warning(self, self.trUtf8("Save Snapshot"), |
244 E5MessageBox.warning( |
240 self.trUtf8("Cannot write file '{0}:\n{1}.")\ |
245 self, self.trUtf8("Save Snapshot"), |
241 .format(fileName, file.errorString())) |
246 self.trUtf8("Cannot write file '{0}:\n{1}.")\ |
|
247 .format(fileName, file.errorString())) |
242 |
248 |
243 return ok |
249 return ok |
244 |
250 |
245 def __autoIncFilename(self): |
251 def __autoIncFilename(self): |
246 """ |
252 """ |
473 Protected method handling the close event. |
479 Protected method handling the close event. |
474 |
480 |
475 @param evt close event (QCloseEvent) |
481 @param evt close event (QCloseEvent) |
476 """ |
482 """ |
477 if self.__modified: |
483 if self.__modified: |
478 res = E5MessageBox.question(self, |
484 res = E5MessageBox.question( |
|
485 self, |
479 self.trUtf8("eric5 Snapshot"), |
486 self.trUtf8("eric5 Snapshot"), |
480 self.trUtf8( |
487 self.trUtf8( |
481 """The application contains an unsaved snapshot."""), |
488 """The application contains an unsaved snapshot."""), |
482 E5MessageBox.StandardButtons( |
489 E5MessageBox.StandardButtons( |
483 E5MessageBox.Abort | \ |
490 E5MessageBox.Abort | \ |