18 |
18 |
19 class NewDialogClassDialog(QDialog, Ui_NewDialogClassDialog): |
19 class NewDialogClassDialog(QDialog, Ui_NewDialogClassDialog): |
20 """ |
20 """ |
21 Class implementing a dialog to ente the data for a new dialog class file. |
21 Class implementing a dialog to ente the data for a new dialog class file. |
22 """ |
22 """ |
23 def __init__(self, defaultClassName, defaultFile, defaultPath, |
23 |
24 parent=None): |
24 def __init__(self, defaultClassName, defaultFile, defaultPath, parent=None): |
25 """ |
25 """ |
26 Constructor |
26 Constructor |
27 |
27 |
28 @param defaultClassName proposed name for the new class (string) |
28 @param defaultClassName proposed name for the new class (string) |
29 @param defaultFile proposed name for the source file (string) |
29 @param defaultFile proposed name for the source file (string) |
30 @param defaultPath default path for the new file (string) |
30 @param defaultPath default path for the new file (string) |
31 @param parent parent widget if the dialog (QWidget) |
31 @param parent parent widget if the dialog (QWidget) |
32 """ |
32 """ |
33 super().__init__(parent) |
33 super().__init__(parent) |
34 self.setupUi(self) |
34 self.setupUi(self) |
35 |
35 |
36 self.pathnamePicker.setMode(EricPathPickerModes.DIRECTORY_MODE) |
36 self.pathnamePicker.setMode(EricPathPickerModes.DIRECTORY_MODE) |
37 |
37 |
38 self.okButton = self.buttonBox.button( |
38 self.okButton = self.buttonBox.button(QDialogButtonBox.StandardButton.Ok) |
39 QDialogButtonBox.StandardButton.Ok) |
|
40 self.okButton.setEnabled(False) |
39 self.okButton.setEnabled(False) |
41 |
40 |
42 self.classnameEdit.setText(defaultClassName) |
41 self.classnameEdit.setText(defaultClassName) |
43 self.filenameEdit.setText(defaultFile) |
42 self.filenameEdit.setText(defaultFile) |
44 self.pathnamePicker.setText(defaultPath) |
43 self.pathnamePicker.setText(defaultPath) |
45 |
44 |
46 msh = self.minimumSizeHint() |
45 msh = self.minimumSizeHint() |
47 self.resize(max(self.width(), msh.width()), msh.height()) |
46 self.resize(max(self.width(), msh.width()), msh.height()) |
48 |
47 |
49 def __enableOkButton(self): |
48 def __enableOkButton(self): |
50 """ |
49 """ |
51 Private slot to set the enable state of theok button. |
50 Private slot to set the enable state of theok button. |
52 """ |
51 """ |
53 self.okButton.setEnabled( |
52 self.okButton.setEnabled( |
54 self.classnameEdit.text() != "" and |
53 self.classnameEdit.text() != "" |
55 self.filenameEdit.text() != "" and |
54 and self.filenameEdit.text() != "" |
56 self.pathnamePicker.text() != "") |
55 and self.pathnamePicker.text() != "" |
57 |
56 ) |
|
57 |
58 def on_classnameEdit_textChanged(self, text): |
58 def on_classnameEdit_textChanged(self, text): |
59 """ |
59 """ |
60 Private slot called, when thext of the classname edit has changed. |
60 Private slot called, when thext of the classname edit has changed. |
61 |
61 |
62 @param text changed text (string) |
62 @param text changed text (string) |
63 """ |
63 """ |
64 self.__enableOkButton() |
64 self.__enableOkButton() |
65 |
65 |
66 def on_filenameEdit_textChanged(self, text): |
66 def on_filenameEdit_textChanged(self, text): |
67 """ |
67 """ |
68 Private slot called, when thext of the filename edit has changed. |
68 Private slot called, when thext of the filename edit has changed. |
69 |
69 |
70 @param text changed text (string) |
70 @param text changed text (string) |
71 """ |
71 """ |
72 self.__enableOkButton() |
72 self.__enableOkButton() |
73 |
73 |
74 def on_pathnamePicker_textChanged(self, text): |
74 def on_pathnamePicker_textChanged(self, text): |
75 """ |
75 """ |
76 Private slot called, when the text of the path name has changed. |
76 Private slot called, when the text of the path name has changed. |
77 |
77 |
78 @param text changed text (string) |
78 @param text changed text (string) |
79 """ |
79 """ |
80 self.__enableOkButton() |
80 self.__enableOkButton() |
81 |
81 |
82 def getData(self): |
82 def getData(self): |
83 """ |
83 """ |
84 Public method to retrieve the data entered into the dialog. |
84 Public method to retrieve the data entered into the dialog. |
85 |
85 |
86 @return tuple giving the classname (string) and the file name (string) |
86 @return tuple giving the classname (string) and the file name (string) |
87 """ |
87 """ |
88 return ( |
88 return ( |
89 self.classnameEdit.text(), |
89 self.classnameEdit.text(), |
90 os.path.join(self.pathnamePicker.text(), |
90 os.path.join(self.pathnamePicker.text(), self.filenameEdit.text()), |
91 self.filenameEdit.text()) |
|
92 ) |
91 ) |