14 from PyQt4.QtCore import * |
14 from PyQt4.QtCore import * |
15 from PyQt4.QtGui import * |
15 from PyQt4.QtGui import * |
16 |
16 |
17 from E4Gui.E4Application import e4App |
17 from E4Gui.E4Application import e4App |
18 |
18 |
19 from ProjectBrowserModel import ProjectBrowserFileItem, \ |
19 from .ProjectBrowserModel import ProjectBrowserFileItem, \ |
20 ProjectBrowserSimpleDirectoryItem, ProjectBrowserDirectoryItem, \ |
20 ProjectBrowserSimpleDirectoryItem, ProjectBrowserDirectoryItem, \ |
21 ProjectBrowserFormType |
21 ProjectBrowserFormType |
22 from ProjectBaseBrowser import ProjectBaseBrowser |
22 from .ProjectBaseBrowser import ProjectBaseBrowser |
23 |
23 |
24 from UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog |
24 from UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog |
25 import UI.PixmapCache |
25 import UI.PixmapCache |
26 |
26 |
27 import Preferences |
27 import Preferences |
308 self._selectSingleItem(index) |
308 self._selectSingleItem(index) |
309 categories = self.getSelectedItemsCountCategorized(\ |
309 categories = self.getSelectedItemsCountCategorized(\ |
310 [ProjectBrowserFileItem, ProjectBrowserSimpleDirectoryItem]) |
310 [ProjectBrowserFileItem, ProjectBrowserSimpleDirectoryItem]) |
311 cnt = categories["sum"] |
311 cnt = categories["sum"] |
312 |
312 |
313 bfcnt = categories[unicode(ProjectBrowserFileItem)] |
313 bfcnt = categories[str(ProjectBrowserFileItem)] |
314 sdcnt = categories[unicode(ProjectBrowserSimpleDirectoryItem)] |
314 sdcnt = categories[str(ProjectBrowserSimpleDirectoryItem)] |
315 if cnt > 1 and cnt == bfcnt: |
315 if cnt > 1 and cnt == bfcnt: |
316 self.multiMenu.popup(self.mapToGlobal(coord)) |
316 self.multiMenu.popup(self.mapToGlobal(coord)) |
317 elif cnt > 1 and cnt == sdcnt: |
317 elif cnt > 1 and cnt == sdcnt: |
318 self.dirMultiMenu.popup(self.mapToGlobal(coord)) |
318 self.dirMultiMenu.popup(self.mapToGlobal(coord)) |
319 else: |
319 else: |
451 Private slot to handle the Preview translations action. |
451 Private slot to handle the Preview translations action. |
452 """ |
452 """ |
453 fileNames = [] |
453 fileNames = [] |
454 for itm in self.getSelectedItems(): |
454 for itm in self.getSelectedItems(): |
455 fileNames.append(itm.fileName()) |
455 fileNames.append(itm.fileName()) |
456 trfiles = self.project.pdata["TRANSLATIONS"][:] |
456 trfiles = sorted(self.project.pdata["TRANSLATIONS"][:]) |
457 trfiles.sort() |
|
458 fileNames.extend([os.path.join(self.project.ppath, trfile) \ |
457 fileNames.extend([os.path.join(self.project.ppath, trfile) \ |
459 for trfile in trfiles \ |
458 for trfile in trfiles \ |
460 if trfile.endswith('.qm')]) |
459 if trfile.endswith('.qm')]) |
461 self.emit(SIGNAL('trpreview'), fileNames) |
460 self.emit(SIGNAL('trpreview'), fileNames) |
462 |
461 |
529 # user selected to not overwrite |
528 # user selected to not overwrite |
530 return |
529 return |
531 |
530 |
532 try: |
531 try: |
533 shutil.copy(templateFile, fname) |
532 shutil.copy(templateFile, fname) |
534 except IOError, e: |
533 except IOError as e: |
535 QMessageBox.critical(self, |
534 QMessageBox.critical(self, |
536 self.trUtf8("New Form"), |
535 self.trUtf8("New Form"), |
537 self.trUtf8("<p>The new form file <b>{0}</b> could not be created.<br>" |
536 self.trUtf8("<p>The new form file <b>{0}</b> could not be created.<br>" |
538 "Problem: {1}</p>").format(fname, unicode(e))) |
537 "Problem: {1}</p>").format(fname, str(e))) |
539 return |
538 return |
540 |
539 |
541 self.project.appendFile(fname) |
540 self.project.appendFile(fname) |
542 self.emit(SIGNAL('designerFile'), fname) |
541 self.emit(SIGNAL('designerFile'), fname) |
543 |
542 |
577 if self.compileProc is None: |
576 if self.compileProc is None: |
578 return |
577 return |
579 self.compileProc.setReadChannel(QProcess.StandardOutput) |
578 self.compileProc.setReadChannel(QProcess.StandardOutput) |
580 |
579 |
581 while self.compileProc and self.compileProc.canReadLine(): |
580 while self.compileProc and self.compileProc.canReadLine(): |
582 self.buf += unicode(self.compileProc.readLine()) |
581 self.buf += str(self.compileProc.readLine(), |
|
582 Preferences.getSystem("IOEncoding"), |
|
583 'replace') |
583 |
584 |
584 def __readStderr(self): |
585 def __readStderr(self): |
585 """ |
586 """ |
586 Private slot to handle the readyReadStandardError signal of the |
587 Private slot to handle the readyReadStandardError signal of the |
587 pyuic/rbuic process. |
588 pyuic/rbuic process. |
588 """ |
589 """ |
589 if self.compileProc is None: |
590 if self.compileProc is None: |
590 return |
591 return |
591 |
592 |
592 ioEncoding = str(Preferences.getSystem("IOEncoding")) |
593 ioEncoding = Preferences.getSystem("IOEncoding") |
593 |
594 |
594 self.compileProc.setReadChannel(QProcess.StandardError) |
595 self.compileProc.setReadChannel(QProcess.StandardError) |
595 while self.compileProc and self.compileProc.canReadLine(): |
596 while self.compileProc and self.compileProc.canReadLine(): |
596 s = self.uicompiler + ': ' |
597 s = self.uicompiler + ': ' |
597 error = unicode(self.compileProc.readLine(), |
598 error = str(self.compileProc.readLine(), |
598 ioEncoding, 'replace') |
599 ioEncoding, 'replace') |
599 s += error |
600 s += error |
600 self.emit(SIGNAL('appendStderr'), s) |
601 self.emit(SIGNAL('appendStderr'), s) |
601 |
602 |
602 def __compileUIDone(self, exitCode, exitStatus): |
603 def __compileUIDone(self, exitCode, exitStatus): |
609 self.compileRunning = False |
610 self.compileRunning = False |
610 e4App().getObject("ViewManager").enableEditorsCheckFocusIn(True) |
611 e4App().getObject("ViewManager").enableEditorsCheckFocusIn(True) |
611 if exitStatus == QProcess.NormalExit and exitCode == 0 and self.buf: |
612 if exitStatus == QProcess.NormalExit and exitCode == 0 and self.buf: |
612 ofn = os.path.join(self.project.ppath, self.compiledFile) |
613 ofn = os.path.join(self.project.ppath, self.compiledFile) |
613 try: |
614 try: |
614 f = open(ofn, "wb") |
615 f = open(ofn, "w") |
615 for line in self.buf.splitlines(): |
616 for line in self.buf.splitlines(): |
616 f.write(line.encode("utf8") + os.linesep) |
617 f.write(line + os.linesep) |
617 f.close() |
618 f.close() |
618 if self.compiledFile not in self.project.pdata["SOURCES"]: |
619 if self.compiledFile not in self.project.pdata["SOURCES"]: |
619 self.project.appendFile(ofn) |
620 self.project.appendFile(ofn) |
620 if not self.noDialog: |
621 if not self.noDialog: |
621 QMessageBox.information(None, |
622 QMessageBox.information(None, |
622 self.trUtf8("Form Compilation"), |
623 self.trUtf8("Form Compilation"), |
623 self.trUtf8("The compilation of the form file" |
624 self.trUtf8("The compilation of the form file" |
624 " was successful.")) |
625 " was successful.")) |
625 except IOError, msg: |
626 except IOError as msg: |
626 if not self.noDialog: |
627 if not self.noDialog: |
627 QMessageBox.information(None, |
628 QMessageBox.information(None, |
628 self.trUtf8("Form Compilation"), |
629 self.trUtf8("Form Compilation"), |
629 self.trUtf8("<p>The compilation of the form file failed.</p>" |
630 self.trUtf8("<p>The compilation of the form file failed.</p>" |
630 "<p>Reason: {0}</p>").format(unicode(msg))) |
631 "<p>Reason: {0}</p>").format(str(msg))) |
631 else: |
632 else: |
632 if not self.noDialog: |
633 if not self.noDialog: |
633 QMessageBox.information(None, |
634 QMessageBox.information(None, |
634 self.trUtf8("Form Compilation"), |
635 self.trUtf8("Form Compilation"), |
635 self.trUtf8("The compilation of the form file failed.")) |
636 self.trUtf8("The compilation of the form file failed.")) |
721 fn = itm.fileName() |
722 fn = itm.fileName() |
722 |
723 |
723 if self.hooks["generateDialogCode"] is not None: |
724 if self.hooks["generateDialogCode"] is not None: |
724 self.hooks["generateDialogCode"](filename) |
725 self.hooks["generateDialogCode"](filename) |
725 else: |
726 else: |
726 from CreateDialogCodeDialog import CreateDialogCodeDialog |
727 from .CreateDialogCodeDialog import CreateDialogCodeDialog |
727 |
728 |
728 # change environment |
729 # change environment |
729 sys.path.insert(0, self.project.getProjectPath()) |
730 sys.path.insert(0, self.project.getProjectPath()) |
730 cwd = os.getcwd() |
731 cwd = os.getcwd() |
731 os.chdir(os.path.dirname(os.path.abspath(fn))) |
732 os.chdir(os.path.dirname(os.path.abspath(fn))) |