143 itm.setData(Qt.UserRole, counter) |
143 itm.setData(Qt.UserRole, counter) |
144 counter += 1 |
144 counter += 1 |
145 |
145 |
146 if counter == 0: |
146 if counter == 0: |
147 itm = QListWidgetItem(self.databasesList) |
147 itm = QListWidgetItem(self.databasesList) |
148 itm.setText(self.trUtf8("No databases are used by this page.")) |
148 itm.setText(self.tr("No databases are used by this page.")) |
149 itm.setFlags(itm.flags() & Qt.ItemIsSelectable) |
149 itm.setFlags(itm.flags() & Qt.ItemIsSelectable) |
150 |
150 |
151 @pyqtSlot() |
151 @pyqtSlot() |
152 def on_securityDetailsButton_clicked(self): |
152 def on_securityDetailsButton_clicked(self): |
153 """ |
153 """ |
186 else: |
186 else: |
187 pixmap.loadFromData(cacheData.readAll()) |
187 pixmap.loadFromData(cacheData.readAll()) |
188 if pixmap.isNull(): |
188 if pixmap.isNull(): |
189 invalidPixmap = True |
189 invalidPixmap = True |
190 if invalidPixmap: |
190 if invalidPixmap: |
191 scene.addText(self.trUtf8("Preview not available.")) |
191 scene.addText(self.tr("Preview not available.")) |
192 else: |
192 else: |
193 scene.addPixmap(pixmap) |
193 scene.addPixmap(pixmap) |
194 self.imagePreview.setScene(scene) |
194 self.imagePreview.setScene(scene) |
195 |
195 |
196 def __imagesTreeContextMenuRequested(self, pos): |
196 def __imagesTreeContextMenuRequested(self, pos): |
203 if itm is None: |
203 if itm is None: |
204 return |
204 return |
205 |
205 |
206 menu = QMenu() |
206 menu = QMenu() |
207 act = menu.addAction( |
207 act = menu.addAction( |
208 self.trUtf8("Copy Image Location to Clipboard"), |
208 self.tr("Copy Image Location to Clipboard"), |
209 self.__copyAction) |
209 self.__copyAction) |
210 act.setData(itm.text(1)) |
210 act.setData(itm.text(1)) |
211 act = menu.addAction( |
211 act = menu.addAction( |
212 self.trUtf8("Copy Image Name to Clipboard"), |
212 self.tr("Copy Image Name to Clipboard"), |
213 self.__copyAction) |
213 self.__copyAction) |
214 act.setData(itm.text(0)) |
214 act.setData(itm.text(0)) |
215 menu.addSeparator() |
215 menu.addSeparator() |
216 act = menu.addAction(self.trUtf8("Save Image"), self.__saveImage) |
216 act = menu.addAction(self.tr("Save Image"), self.__saveImage) |
217 act.setData(self.imagesTree.indexOfTopLevelItem(itm)) |
217 act.setData(self.imagesTree.indexOfTopLevelItem(itm)) |
218 menu.exec_(QCursor.pos()) |
218 menu.exec_(QCursor.pos()) |
219 |
219 |
220 def __copyAction(self): |
220 def __copyAction(self): |
221 """ |
221 """ |
246 else: |
246 else: |
247 cacheData = None |
247 cacheData = None |
248 if not cacheData: |
248 if not cacheData: |
249 E5MessageBox.critical( |
249 E5MessageBox.critical( |
250 self, |
250 self, |
251 self.trUtf8("Save Image"), |
251 self.tr("Save Image"), |
252 self.trUtf8("""This image is not available.""")) |
252 self.tr("""This image is not available.""")) |
253 return |
253 return |
254 |
254 |
255 downloadDirectory = Helpviewer.HelpWindow.HelpWindow\ |
255 downloadDirectory = Helpviewer.HelpWindow.HelpWindow\ |
256 .downloadManager().downloadDirectory() |
256 .downloadManager().downloadDirectory() |
257 fn = os.path.join(downloadDirectory, os.path.basename(itm.text(1))) |
257 fn = os.path.join(downloadDirectory, os.path.basename(itm.text(1))) |
258 filename = E5FileDialog.getSaveFileName( |
258 filename = E5FileDialog.getSaveFileName( |
259 self, |
259 self, |
260 self.trUtf8("Save Image"), |
260 self.tr("Save Image"), |
261 fn, |
261 fn, |
262 self.trUtf8("All Files (*)"), |
262 self.tr("All Files (*)"), |
263 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) |
263 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) |
264 |
264 |
265 if not filename: |
265 if not filename: |
266 return |
266 return |
267 |
267 |
268 f = QFile(filename) |
268 f = QFile(filename) |
269 if not f.open(QFile.WriteOnly): |
269 if not f.open(QFile.WriteOnly): |
270 E5MessageBox.critical( |
270 E5MessageBox.critical( |
271 self, |
271 self, |
272 self.trUtf8("Save Image"), |
272 self.tr("Save Image"), |
273 self.trUtf8( |
273 self.tr( |
274 """<p>Cannot write to file <b>{0}</b>.</p>""") |
274 """<p>Cannot write to file <b>{0}</b>.</p>""") |
275 .format(filename)) |
275 .format(filename)) |
276 return |
276 return |
277 f.write(cacheData.readAll()) |
277 f.write(cacheData.readAll()) |
278 f.close() |
278 f.close() |