223 itm = self.imagesTree.itemAt(pos) |
223 itm = self.imagesTree.itemAt(pos) |
224 if itm is None: |
224 if itm is None: |
225 return |
225 return |
226 |
226 |
227 menu = QMenu() |
227 menu = QMenu() |
228 act = menu.addAction( |
228 act = menu.addAction(self.tr("Copy Image Location to Clipboard")) |
229 self.tr("Copy Image Location to Clipboard"), |
|
230 self.__copyAction) |
|
231 act.setData(itm.text(1)) |
229 act.setData(itm.text(1)) |
232 act = menu.addAction( |
230 act.triggered.connect(lambda: self.__copyAction(act)) |
233 self.tr("Copy Image Name to Clipboard"), |
231 act = menu.addAction(self.tr("Copy Image Name to Clipboard")) |
234 self.__copyAction) |
|
235 act.setData(itm.text(0)) |
232 act.setData(itm.text(0)) |
|
233 act.triggered.connect(lambda: self.__copyAction(act)) |
236 menu.addSeparator() |
234 menu.addSeparator() |
237 act = menu.addAction(self.tr("Save Image"), self.__saveImage) |
235 act = menu.addAction(self.tr("Save Image")) |
238 act.setData(self.imagesTree.indexOfTopLevelItem(itm)) |
236 act.setData(self.imagesTree.indexOfTopLevelItem(itm)) |
|
237 act.triggered.connect(lambda: self.__saveImage(act)) |
239 menu.exec_(QCursor.pos()) |
238 menu.exec_(QCursor.pos()) |
240 |
239 |
241 def __copyAction(self): |
240 def __copyAction(self, act): |
242 """ |
241 """ |
243 Private slot to copy the image URL or the image name to the clipboard. |
242 Private slot to copy the image URL or the image name to the clipboard. |
244 """ |
243 |
245 act = self.sender() |
244 @param act reference to the action that triggered |
|
245 @type QAction |
|
246 """ |
246 QApplication.clipboard().setText(act.data()) |
247 QApplication.clipboard().setText(act.data()) |
247 |
248 |
248 def __saveImage(self): |
249 def __saveImage(self, act): |
249 """ |
250 """ |
250 Private slot to save the selected image to disk. |
251 Private slot to save the selected image to disk. |
251 """ |
252 |
252 act = self.sender() |
253 @param act reference to the action that triggered |
|
254 @type QAction |
|
255 """ |
253 index = act.data() |
256 index = act.data() |
254 itm = self.imagesTree.topLevelItem(index) |
257 itm = self.imagesTree.topLevelItem(index) |
255 if itm is None: |
258 if itm is None: |
256 return |
259 return |
257 |
260 |