41 translations previewer |
41 translations previewer |
42 @signal showMenu(string, QMenu) emitted when a menu is about to be shown. The name |
42 @signal showMenu(string, QMenu) emitted when a menu is about to be shown. The name |
43 of the menu and a reference to the menu are given. |
43 of the menu and a reference to the menu are given. |
44 """ |
44 """ |
45 sourceFile = pyqtSignal(str) |
45 sourceFile = pyqtSignal(str) |
|
46 linguistFile = pyqtSignal(str) |
|
47 appendStdout = pyqtSignal(str) |
|
48 appendStderr = pyqtSignal(str) |
|
49 closeSourceWindow = pyqtSignal(str) |
|
50 trpreview = pyqtSignal((list, ), (list, bool)) |
|
51 showMenu = pyqtSignal(str, QMenu) |
46 |
52 |
47 def __init__(self, project, parent=None): |
53 def __init__(self, project, parent=None): |
48 """ |
54 """ |
49 Constructor |
55 Constructor |
50 |
56 |
461 for act in self.qmprocMenuActions: |
467 for act in self.qmprocMenuActions: |
462 act.setEnabled(True) |
468 act.setEnabled(True) |
463 |
469 |
464 ProjectBaseBrowser._showContextMenu(self, self.menu) |
470 ProjectBaseBrowser._showContextMenu(self, self.menu) |
465 |
471 |
466 self.emit(SIGNAL("showMenu"), "Main", self.menu) |
472 self.showMenu.emit("Main", self.menu) |
467 |
473 |
468 def __showContextMenuMulti(self): |
474 def __showContextMenuMulti(self): |
469 """ |
475 """ |
470 Private slot called by the multiMenu aboutToShow signal. |
476 Private slot called by the multiMenu aboutToShow signal. |
471 """ |
477 """ |
500 for act in self.qmprocMultiMenuActions: |
506 for act in self.qmprocMultiMenuActions: |
501 act.setEnabled(True) |
507 act.setEnabled(True) |
502 |
508 |
503 ProjectBaseBrowser._showContextMenuMulti(self, self.multiMenu) |
509 ProjectBaseBrowser._showContextMenuMulti(self, self.multiMenu) |
504 |
510 |
505 self.emit(SIGNAL("showMenu"), "MainMulti", self.multiMenu) |
511 self.showMenu.emit("MainMulti", self.multiMenu) |
506 |
512 |
507 def __showContextMenuDir(self): |
513 def __showContextMenuDir(self): |
508 """ |
514 """ |
509 Private slot called by the dirMenu aboutToShow signal. |
515 Private slot called by the dirMenu aboutToShow signal. |
510 """ |
516 """ |
517 for act in self.qmprocDirMenuActions: |
523 for act in self.qmprocDirMenuActions: |
518 act.setEnabled(True) |
524 act.setEnabled(True) |
519 |
525 |
520 ProjectBaseBrowser._showContextMenuDir(self, self.dirMenu) |
526 ProjectBaseBrowser._showContextMenuDir(self, self.dirMenu) |
521 |
527 |
522 self.emit(SIGNAL("showMenu"), "MainDir", self.dirMenu) |
528 self.showMenu.emit("MainDir", self.dirMenu) |
523 |
529 |
524 def __showContextMenuBack(self): |
530 def __showContextMenuBack(self): |
525 """ |
531 """ |
526 Private slot called by the backMenu aboutToShow signal. |
532 Private slot called by the backMenu aboutToShow signal. |
527 """ |
533 """ |
532 act.setEnabled(False) |
538 act.setEnabled(False) |
533 if self.lreleaseProcRunning: |
539 if self.lreleaseProcRunning: |
534 for act in self.qmprocBackMenuActions: |
540 for act in self.qmprocBackMenuActions: |
535 act.setEnabled(True) |
541 act.setEnabled(True) |
536 |
542 |
537 self.emit(SIGNAL("showMenu"), "MainBack", self.backMenu) |
543 self.showMenu.emit("MainBack", self.backMenu) |
538 |
544 |
539 def __addTranslationFiles(self): |
545 def __addTranslationFiles(self): |
540 """ |
546 """ |
541 Private method to add translation files to the project. |
547 Private method to add translation files to the project. |
542 """ |
548 """ |
557 itmList = self.getSelectedItems() |
563 itmList = self.getSelectedItems() |
558 for itm in itmList: |
564 for itm in itmList: |
559 if isinstance(itm, ProjectBrowserFileItem): |
565 if isinstance(itm, ProjectBrowserFileItem): |
560 if itm.isLinguistFile(): |
566 if itm.isLinguistFile(): |
561 if itm.fileExt() == '.ts': |
567 if itm.fileExt() == '.ts': |
562 self.emit(SIGNAL('linguistFile'), itm.fileName()) |
568 self.linguistFile.emit(itm.fileName()) |
563 else: |
569 else: |
564 self.emit(SIGNAL('trpreview'), [itm.fileName()]) |
570 self.trpreview.emit([itm.fileName()]) |
565 else: |
571 else: |
566 self.sourceFile.emit(itm.fileName()) |
572 self.sourceFile.emit(itm.fileName()) |
567 |
573 |
568 def __openFileInEditor(self): |
574 def __openFileInEditor(self): |
569 """ |
575 """ |
579 """ |
585 """ |
580 itmList = self.getSelectedItems() |
586 itmList = self.getSelectedItems() |
581 |
587 |
582 for itm in itmList[:]: |
588 for itm in itmList[:]: |
583 fn = itm.fileName() |
589 fn = itm.fileName() |
584 self.emit(SIGNAL('closeSourceWindow'), fn) |
590 self.closeSourceWindow.emit(fn) |
585 self.project.removeLanguageFile(fn) |
591 self.project.removeLanguageFile(fn) |
586 |
592 |
587 def __deleteLanguageFile(self): |
593 def __deleteLanguageFile(self): |
588 """ |
594 """ |
589 Private method to delete a translation file from the project. |
595 Private method to delete a translation file from the project. |
598 " from the project?"), |
604 " from the project?"), |
599 translationFiles) |
605 translationFiles) |
600 |
606 |
601 if dlg.exec_() == QDialog.Accepted: |
607 if dlg.exec_() == QDialog.Accepted: |
602 for fn in translationFiles: |
608 for fn in translationFiles: |
603 self.emit(SIGNAL('closeSourceWindow'), fn) |
609 self.closeSourceWindow.emit(fn) |
604 self.project.deleteLanguageFile(fn) |
610 self.project.deleteLanguageFile(fn) |
605 |
611 |
606 def __TRPreview(self, previewAll = False): |
612 def __TRPreview(self, previewAll = False): |
607 """ |
613 """ |
608 Private slot to handle the Preview translations action. |
614 Private slot to handle the Preview translations action. |
628 else: |
634 else: |
629 trfiles = sorted(self.project.pdata["TRANSLATIONS"][:]) |
635 trfiles = sorted(self.project.pdata["TRANSLATIONS"][:]) |
630 fileNames.extend([os.path.join(self.project.ppath, trfile) \ |
636 fileNames.extend([os.path.join(self.project.ppath, trfile) \ |
631 for trfile in trfiles \ |
637 for trfile in trfiles \ |
632 if trfile.endswith('.qm')]) |
638 if trfile.endswith('.qm')]) |
633 self.emit(SIGNAL('trpreview'), fileNames, True) |
639 self.trpreview[list, bool].emit(fileNames, True) |
634 |
640 |
635 def __TRPreviewAll(self): |
641 def __TRPreviewAll(self): |
636 """ |
642 """ |
637 Private slot to handle the Preview all translations action. |
643 Private slot to handle the Preview all translations action. |
638 """ |
644 """ |
767 proc.setReadChannel(QProcess.StandardOutput) |
773 proc.setReadChannel(QProcess.StandardOutput) |
768 while proc and proc.canReadLine(): |
774 while proc and proc.canReadLine(): |
769 s = ps |
775 s = ps |
770 output = str(proc.readLine(), ioEncoding, 'replace') |
776 output = str(proc.readLine(), ioEncoding, 'replace') |
771 s += output |
777 s += output |
772 self.emit(SIGNAL('appendStdout'), s) |
778 self.appendStdout.emit(s) |
773 |
779 |
774 def __readStderrLupdate(self): |
780 def __readStderrLupdate(self): |
775 """ |
781 """ |
776 Private slot to handle the readyReadStandardError signal of the |
782 Private slot to handle the readyReadStandardError signal of the |
777 pylupdate process. |
783 pylupdate process. |
803 proc.setReadChannel(QProcess.StandardError) |
809 proc.setReadChannel(QProcess.StandardError) |
804 while proc and proc.canReadLine(): |
810 while proc and proc.canReadLine(): |
805 s = ps |
811 s = ps |
806 error = str(proc.readLine(), ioEncoding, 'replace') |
812 error = str(proc.readLine(), ioEncoding, 'replace') |
807 s += error |
813 s += error |
808 self.emit(SIGNAL('appendStderr'), s) |
814 self.appendStderr.emit(s) |
809 |
815 |
810 ############################################################################ |
816 ############################################################################ |
811 ## Methods for the generation commands |
817 ## Methods for the generation commands |
812 ############################################################################ |
818 ############################################################################ |
813 |
819 |