|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2018 - 2022 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to enter the properties for 'make'. |
|
8 """ |
|
9 |
|
10 from PyQt6.QtWidgets import QDialog, QDialogButtonBox |
|
11 |
|
12 from EricWidgets.EricPathPicker import EricPathPickerModes |
|
13 |
|
14 from .Ui_MakePropertiesDialog import Ui_MakePropertiesDialog |
|
15 |
|
16 |
|
17 class MakePropertiesDialog(QDialog, Ui_MakePropertiesDialog): |
|
18 """ |
|
19 Class implementing a dialog to enter the properties for 'make'. |
|
20 """ |
|
21 def __init__(self, project, new, parent=None): |
|
22 """ |
|
23 Constructor |
|
24 |
|
25 @param project reference to the project object |
|
26 @type Project |
|
27 @param new flag indicating the generation of a new project |
|
28 @type bool |
|
29 @param parent reference to the parent widget of this dialog |
|
30 @type QWidget |
|
31 """ |
|
32 super().__init__(parent) |
|
33 self.setupUi(self) |
|
34 |
|
35 self.__project = project |
|
36 |
|
37 self.makePicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) |
|
38 self.makePicker.setFilters(self.tr("All Files (*)")) |
|
39 |
|
40 self.makefilePicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) |
|
41 self.makefilePicker.setDefaultDirectory(self.__project.ppath) |
|
42 self.makefilePicker.setFilters(self.tr( |
|
43 "Makefiles (*makefile Makefile *.mak);;All Files (*)")) |
|
44 |
|
45 self.makeTargetEdit.textChanged.connect(self.__updateOkButton) |
|
46 |
|
47 self.initDialog() |
|
48 |
|
49 msh = self.minimumSizeHint() |
|
50 self.resize(max(self.width(), msh.width()), msh.height()) |
|
51 |
|
52 def initDialog(self): |
|
53 """ |
|
54 Public method to initialize the dialog's data. |
|
55 """ |
|
56 makeData = self.__project.pdata["MAKEPARAMS"] |
|
57 |
|
58 if makeData["MakeExecutable"]: |
|
59 self.makePicker.setText(makeData["MakeExecutable"]) |
|
60 else: |
|
61 self.makePicker.setText(self.__project.DefaultMake) |
|
62 if makeData["MakeFile"]: |
|
63 self.makefilePicker.setText(makeData["MakeFile"]) |
|
64 else: |
|
65 self.makefilePicker.setText(self.__project.DefaultMakefile) |
|
66 self.makeTargetEdit.setText(makeData["MakeTarget"]) |
|
67 self.makeParametersEdit.setText(makeData["MakeParameters"]) |
|
68 self.testOnlyCheckBox.setChecked(makeData["MakeTestOnly"]) |
|
69 |
|
70 self.__updateOkButton() |
|
71 |
|
72 def __updateOkButton(self): |
|
73 """ |
|
74 Private slot to update the enabled state of the OK button. |
|
75 """ |
|
76 self.buttonBox.button( |
|
77 QDialogButtonBox.StandardButton.Ok).setEnabled(bool( |
|
78 self.makeTargetEdit.text())) |
|
79 |
|
80 def storeData(self): |
|
81 """ |
|
82 Public method to store the entered/modified data. |
|
83 """ |
|
84 makeData = self.__project.pdata["MAKEPARAMS"] |
|
85 |
|
86 makeExe = self.makePicker.text() |
|
87 if makeExe == self.__project.DefaultMake: |
|
88 makeExe = "" |
|
89 makeData["MakeExecutable"] = makeExe |
|
90 |
|
91 makefile = self.__project.getRelativePath(self.makefilePicker.text()) |
|
92 if makefile == self.__project.DefaultMakefile: |
|
93 makefile = "" |
|
94 makeData["MakeFile"] = makefile |
|
95 |
|
96 makeData["MakeTarget"] = self.makeTargetEdit.text() |
|
97 makeData["MakeParameters"] = self.makeParametersEdit.text() |
|
98 makeData["MakeTestOnly"] = self.testOnlyCheckBox.isChecked() |