27 |
27 |
28 class ProgramsDialog(QDialog, Ui_ProgramsDialog): |
28 class ProgramsDialog(QDialog, Ui_ProgramsDialog): |
29 """ |
29 """ |
30 Class implementing the Programs page. |
30 Class implementing the Programs page. |
31 """ |
31 """ |
32 ToolAvailableRole = Qt.UserRole + 1 |
32 ToolAvailableRole = Qt.ItemDataRole.UserRole + 1 |
33 |
33 |
34 def __init__(self, parent=None): |
34 def __init__(self, parent=None): |
35 """ |
35 """ |
36 Constructor |
36 Constructor |
37 |
37 |
38 @param parent The parent widget of this dialog. (QWidget) |
38 @param parent The parent widget of this dialog. (QWidget) |
39 """ |
39 """ |
40 super(ProgramsDialog, self).__init__(parent) |
40 super(ProgramsDialog, self).__init__(parent) |
41 self.setupUi(self) |
41 self.setupUi(self) |
42 self.setObjectName("ProgramsDialog") |
42 self.setObjectName("ProgramsDialog") |
43 self.setWindowFlags(Qt.Window) |
43 self.setWindowFlags(Qt.WindowType.Window) |
44 |
44 |
45 self.__hasSearched = False |
45 self.__hasSearched = False |
46 |
46 |
47 self.programsList.headerItem().setText( |
47 self.programsList.headerItem().setText( |
48 self.programsList.columnCount(), "") |
48 self.programsList.columnCount(), "") |
49 |
49 |
50 self.searchButton = self.buttonBox.addButton( |
50 self.searchButton = self.buttonBox.addButton( |
51 self.tr("Search"), QDialogButtonBox.ActionRole) |
51 self.tr("Search"), QDialogButtonBox.ButtonRole.ActionRole) |
52 self.searchButton.setToolTip( |
52 self.searchButton.setToolTip( |
53 self.tr("Press to search for programs")) |
53 self.tr("Press to search for programs")) |
54 |
54 |
55 self.showComboBox.addItems([ |
55 self.showComboBox.addItems([ |
56 self.tr("All Supported Tools"), |
56 self.tr("All Supported Tools"), |
80 """ |
80 """ |
81 Private slot to search for all supported/required programs. |
81 Private slot to search for all supported/required programs. |
82 """ |
82 """ |
83 self.programsList.clear() |
83 self.programsList.clear() |
84 header = self.programsList.header() |
84 header = self.programsList.header() |
85 header.setSortIndicator(0, Qt.AscendingOrder) |
85 header.setSortIndicator(0, Qt.SortOrder.AscendingOrder) |
86 header.setSortIndicatorShown(False) |
86 header.setSortIndicatorShown(False) |
87 |
87 |
88 with E5OverrideCursor(): |
88 with E5OverrideCursor(): |
89 # 1. do the Qt programs |
89 # 1. do the Qt programs |
90 # 1a. Translation Converter |
90 # 1a. Translation Converter |
354 with the program given in exe (e.g. to execute a Python module) |
354 with the program given in exe (e.g. to execute a Python module) |
355 (list of str) |
355 (list of str) |
356 @return version string of detected or given version (string) |
356 @return version string of detected or given version (string) |
357 """ |
357 """ |
358 itmList = self.programsList.findItems( |
358 itmList = self.programsList.findItems( |
359 description, Qt.MatchCaseSensitive) |
359 description, Qt.MatchFlag.MatchCaseSensitive) |
360 if itmList: |
360 if itmList: |
361 itm = itmList[0] |
361 itm = itmList[0] |
362 else: |
362 else: |
363 itm = QTreeWidgetItem(self.programsList, [description]) |
363 itm = QTreeWidgetItem(self.programsList, [description]) |
364 font = itm.font(0) |
364 font = itm.font(0) |
375 exe = Utilities.getExecutablePath(exe) |
375 exe = Utilities.getExecutablePath(exe) |
376 if exe: |
376 if exe: |
377 available = True |
377 available = True |
378 if versionCommand and versionPosition is not None: |
378 if versionCommand and versionPosition is not None: |
379 proc = QProcess() |
379 proc = QProcess() |
380 proc.setProcessChannelMode(QProcess.MergedChannels) |
380 proc.setProcessChannelMode( |
|
381 QProcess.ProcessChannelMode.MergedChannels) |
381 if exeModule: |
382 if exeModule: |
382 args = exeModule[:] + [versionCommand] |
383 args = exeModule[:] + [versionCommand] |
383 else: |
384 else: |
384 args = [versionCommand] |
385 args = [versionCommand] |
385 proc.start(exe, args) |
386 proc.start(exe, args) |
450 citm = QTreeWidgetItem( |
451 citm = QTreeWidgetItem( |
451 itm, [rememberedExe, self.tr("(not found)")]) |
452 itm, [rememberedExe, self.tr("(not found)")]) |
452 citm.setData(0, self.ToolAvailableRole, False) |
453 citm.setData(0, self.ToolAvailableRole, False) |
453 itm.setExpanded(True) |
454 itm.setExpanded(True) |
454 QApplication.processEvents() |
455 QApplication.processEvents() |
455 self.programsList.header().resizeSections(QHeaderView.ResizeToContents) |
456 self.programsList.header().resizeSections( |
|
457 QHeaderView.ResizeMode.ResizeToContents) |
456 self.programsList.header().setStretchLastSection(True) |
458 self.programsList.header().setStretchLastSection(True) |
457 return version |
459 return version |
458 |
460 |
459 def __createEntry(self, description, entryText, entryVersion): |
461 def __createEntry(self, description, entryText, entryVersion): |
460 """ |
462 """ |
476 not entryVersion.startswith("(")) |
478 not entryVersion.startswith("(")) |
477 # assume version starting with '(' is an unavailability |
479 # assume version starting with '(' is an unavailability |
478 else: |
480 else: |
479 itm.setText(1, self.tr("(not found)")) |
481 itm.setText(1, self.tr("(not found)")) |
480 QApplication.processEvents() |
482 QApplication.processEvents() |
481 self.programsList.header().resizeSections(QHeaderView.ResizeToContents) |
483 self.programsList.header().resizeSections( |
|
484 QHeaderView.ResizeMode.ResizeToContents) |
482 self.programsList.header().setStretchLastSection(True) |
485 self.programsList.header().setStretchLastSection(True) |
483 |
486 |
484 @pyqtSlot(int) |
487 @pyqtSlot(int) |
485 def on_showComboBox_currentIndexChanged(self, index): |
488 def on_showComboBox_currentIndexChanged(self, index): |
486 """ |
489 """ |