243 self.__menu.addAction(UI.PixmapCache.getIcon("fileSaveAs.png"), |
243 self.__menu.addAction(UI.PixmapCache.getIcon("fileSaveAs.png"), |
244 self.trUtf8('Save As...'), self.__contextMenuSaveAs) |
244 self.trUtf8('Save As...'), self.__contextMenuSaveAs) |
245 self.__menu.addAction(UI.PixmapCache.getIcon("fileSaveAll.png"), |
245 self.__menu.addAction(UI.PixmapCache.getIcon("fileSaveAll.png"), |
246 self.trUtf8('Save All'), self.__contextMenuSaveAll) |
246 self.trUtf8('Save All'), self.__contextMenuSaveAll) |
247 self.__menu.addSeparator() |
247 self.__menu.addSeparator() |
|
248 self.openRejectionsMenuAct = \ |
|
249 self.__menu.addAction(self.trUtf8("Open 'rejection' file"), |
|
250 self.__contextMenuOpenRejections) |
|
251 self.__menu.addSeparator() |
248 self.__menu.addAction(UI.PixmapCache.getIcon("print.png"), |
252 self.__menu.addAction(UI.PixmapCache.getIcon("print.png"), |
249 self.trUtf8('Print'), self.__contextMenuPrintFile) |
253 self.trUtf8('Print'), self.__contextMenuPrintFile) |
250 self.__menu.addSeparator() |
254 self.__menu.addSeparator() |
251 self.copyPathAct = self.__menu.addAction(self.trUtf8("Copy Path to Clipboard"), |
255 self.copyPathAct = self.__menu.addAction(self.trUtf8("Copy Path to Clipboard"), |
252 self.__contextMenuCopyPathToClipboard) |
256 self.__contextMenuCopyPathToClipboard) |
260 """ |
264 """ |
261 if self.editors: |
265 if self.editors: |
262 self.contextMenuEditor = self.widget(index) |
266 self.contextMenuEditor = self.widget(index) |
263 if self.contextMenuEditor: |
267 if self.contextMenuEditor: |
264 self.saveMenuAct.setEnabled(self.contextMenuEditor.isModified()) |
268 self.saveMenuAct.setEnabled(self.contextMenuEditor.isModified()) |
265 self.copyPathAct.setEnabled(bool(self.contextMenuEditor.getFileName())) |
269 fileName = self.contextMenuEditor.getFileName() |
|
270 self.copyPathAct.setEnabled(bool(fileName)) |
|
271 if fileName: |
|
272 rej = "{0}.rej".format(fileName) |
|
273 self.openRejectionsMenuAct.setEnabled(os.path.exists(rej)) |
|
274 else: |
|
275 self.openRejectionsMenuAct.setEnabled(False) |
266 |
276 |
267 self.contextMenuIndex = index |
277 self.contextMenuIndex = index |
268 self.leftMenuAct.setEnabled(index > 0) |
278 self.leftMenuAct.setEnabled(index > 0) |
269 self.rightMenuAct.setEnabled(index < self.count() - 1) |
279 self.rightMenuAct.setEnabled(index < self.count() - 1) |
270 self.firstMenuAct.setEnabled(index > 0) |
280 self.firstMenuAct.setEnabled(index > 0) |
504 def __contextMenuCloseOthers(self): |
514 def __contextMenuCloseOthers(self): |
505 """ |
515 """ |
506 Private method to close the other tabs. |
516 Private method to close the other tabs. |
507 """ |
517 """ |
508 index = self.contextMenuIndex |
518 index = self.contextMenuIndex |
509 for i in list(range(self.count() - 1, index, -1)) + list(range(index - 1, -1, -1)): |
519 for i in list(range(self.count() - 1, index, -1)) + \ |
|
520 list(range(index - 1, -1, -1)): |
510 editor = self.widget(i) |
521 editor = self.widget(i) |
511 self.vm.closeEditorWindow(editor) |
522 self.vm.closeEditorWindow(editor) |
512 |
523 |
513 def __contextMenuCloseAll(self): |
524 def __contextMenuCloseAll(self): |
514 """ |
525 """ |
535 def __contextMenuSaveAll(self): |
546 def __contextMenuSaveAll(self): |
536 """ |
547 """ |
537 Private method to save all tabs. |
548 Private method to save all tabs. |
538 """ |
549 """ |
539 self.vm.saveEditorsList(self.editors) |
550 self.vm.saveEditorsList(self.editors) |
|
551 |
|
552 def __contextMenuOpenRejections(self): |
|
553 """ |
|
554 Private slot to open a rejections file associated with the selected tab. |
|
555 """ |
|
556 if self.contextMenuEditor: |
|
557 fileName = self.contextMenuEditor.getFileName() |
|
558 if fileName: |
|
559 rej = "{0}.rej".format(fileName) |
|
560 if os.path.exists(rej): |
|
561 self.vm.openSourceFile(rej) |
540 |
562 |
541 def __contextMenuPrintFile(self): |
563 def __contextMenuPrintFile(self): |
542 """ |
564 """ |
543 Private method to print the selected tab. |
565 Private method to print the selected tab. |
544 """ |
566 """ |
545 if self.contextMenuEditor: |
567 if self.contextMenuEditor: |
546 self.vm.printEditor(self.contextMenuEditor) |
568 self.vm.printEditor(self.contextMenuEditor) |
547 |
569 |
548 def __contextMenuCopyPathToClipboard(self): |
570 def __contextMenuCopyPathToClipboard(self): |
549 """ |
571 """ |
550 Private method to copy the file name of the editor to the clipboard. |
572 Private method to copy the file name of the selected tab to the clipboard. |
551 """ |
573 """ |
552 if self.contextMenuEditor: |
574 if self.contextMenuEditor: |
553 fn = self.contextMenuEditor.getFileName() |
575 fn = self.contextMenuEditor.getFileName() |
554 if fn: |
576 if fn: |
555 cb = QApplication.clipboard() |
577 cb = QApplication.clipboard() |