12 import re |
12 import re |
13 import sys |
13 import sys |
14 |
14 |
15 from PyQt5.QtCore import pyqtSlot, Qt, QProcess |
15 from PyQt5.QtCore import pyqtSlot, Qt, QProcess |
16 from PyQt5.QtGui import QCursor |
16 from PyQt5.QtGui import QCursor |
17 from PyQt5.QtWidgets import QApplication, QTreeWidgetItem, QHeaderView, \ |
17 from PyQt5.QtWidgets import ( |
18 QDialog, QDialogButtonBox |
18 QApplication, QTreeWidgetItem, QHeaderView, QDialog, QDialogButtonBox |
|
19 ) |
19 |
20 |
20 from E5Gui.E5Application import e5App |
21 from E5Gui.E5Application import e5App |
21 |
22 |
22 from .Ui_ProgramsDialog import Ui_ProgramsDialog |
23 from .Ui_ProgramsDialog import Ui_ProgramsDialog |
23 |
24 |
80 header.setSortIndicator(0, Qt.AscendingOrder) |
81 header.setSortIndicator(0, Qt.AscendingOrder) |
81 header.setSortIndicatorShown(False) |
82 header.setSortIndicatorShown(False) |
82 |
83 |
83 # 1. do the Qt5 programs |
84 # 1. do the Qt5 programs |
84 # 1a. Translation Converter |
85 # 1a. Translation Converter |
85 exe = Utilities.isWindowsPlatform() and \ |
86 exe = ( |
86 "{0}.exe".format(Utilities.generateQtToolName("lrelease")) or \ |
87 Utilities.isWindowsPlatform() and |
|
88 "{0}.exe".format(Utilities.generateQtToolName("lrelease")) or |
87 Utilities.generateQtToolName("lrelease") |
89 Utilities.generateQtToolName("lrelease") |
|
90 ) |
88 exe = os.path.join(Utilities.getQtBinariesPath(), exe) |
91 exe = os.path.join(Utilities.getQtBinariesPath(), exe) |
89 version = self.__createProgramEntry( |
92 version = self.__createProgramEntry( |
90 self.tr("Translation Converter (Qt)"), exe, '-version', |
93 self.tr("Translation Converter (Qt)"), exe, '-version', |
91 'lrelease', -1) |
94 'lrelease', -1) |
92 # 1b. Qt Designer |
95 # 1b. Qt Designer |
361 if not Utilities.isExecutable(exe): |
364 if not Utilities.isExecutable(exe): |
362 exe = "" |
365 exe = "" |
363 else: |
366 else: |
364 exe = Utilities.getExecutablePath(exe) |
367 exe = Utilities.getExecutablePath(exe) |
365 if exe: |
368 if exe: |
366 if versionCommand and \ |
369 if ( |
367 (versionStartsWith != "" or |
370 versionCommand and |
368 (versionRe is not None and versionRe != "")) and \ |
371 (versionStartsWith != "" or |
369 versionPosition: |
372 (versionRe is not None and versionRe != "")) and |
|
373 versionPosition |
|
374 ): |
370 proc = QProcess() |
375 proc = QProcess() |
371 proc.setProcessChannelMode(QProcess.MergedChannels) |
376 proc.setProcessChannelMode(QProcess.MergedChannels) |
372 if exeModule: |
377 if exeModule: |
373 args = exeModule[:] + [versionCommand] |
378 args = exeModule[:] + [versionCommand] |
374 else: |
379 else: |
377 finished = proc.waitForFinished(10000) |
382 finished = proc.waitForFinished(10000) |
378 if finished: |
383 if finished: |
379 output = str(proc.readAllStandardOutput(), |
384 output = str(proc.readAllStandardOutput(), |
380 Preferences.getSystem("IOEncoding"), |
385 Preferences.getSystem("IOEncoding"), |
381 'replace') |
386 'replace') |
382 if exeModule and exeModule[0] == "-m" and \ |
387 if ( |
|
388 exeModule and |
|
389 exeModule[0] == "-m" and |
383 ("ImportError:" in output or |
390 ("ImportError:" in output or |
384 "ModuleNotFoundError:" in output or |
391 "ModuleNotFoundError:" in output or |
385 proc.exitCode() != 0): |
392 proc.exitCode() != 0) |
|
393 ): |
386 version = self.tr("(module not found)") |
394 version = self.tr("(module not found)") |
387 else: |
395 else: |
388 if versionRe is None: |
396 if versionRe is None: |
389 versionRe = "^{0}".format( |
397 versionRe = "^{0}".format( |
390 re.escape(versionStartsWith)) |
398 re.escape(versionStartsWith)) |