|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2007 - 2019 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to enter the data for a new dialog class file. |
|
8 """ |
|
9 |
|
10 from __future__ import unicode_literals |
|
11 |
|
12 import os |
|
13 |
|
14 from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
|
15 |
|
16 from E5Gui.E5PathPicker import E5PathPickerModes |
|
17 |
|
18 from .Ui_NewDialogClassDialog import Ui_NewDialogClassDialog |
|
19 |
|
20 |
|
21 class NewDialogClassDialog(QDialog, Ui_NewDialogClassDialog): |
|
22 """ |
|
23 Class implementing a dialog to ente the data for a new dialog class file. |
|
24 """ |
|
25 def __init__(self, defaultClassName, defaultFile, defaultPath, |
|
26 parent=None): |
|
27 """ |
|
28 Constructor |
|
29 |
|
30 @param defaultClassName proposed name for the new class (string) |
|
31 @param defaultFile proposed name for the source file (string) |
|
32 @param defaultPath default path for the new file (string) |
|
33 @param parent parent widget if the dialog (QWidget) |
|
34 """ |
|
35 super(NewDialogClassDialog, self).__init__(parent) |
|
36 self.setupUi(self) |
|
37 |
|
38 self.pathnamePicker.setMode(E5PathPickerModes.DirectoryMode) |
|
39 |
|
40 self.okButton = self.buttonBox.button(QDialogButtonBox.Ok) |
|
41 self.okButton.setEnabled(False) |
|
42 |
|
43 self.classnameEdit.setText(defaultClassName) |
|
44 self.filenameEdit.setText(defaultFile) |
|
45 self.pathnamePicker.setText(defaultPath) |
|
46 |
|
47 msh = self.minimumSizeHint() |
|
48 self.resize(max(self.width(), msh.width()), msh.height()) |
|
49 |
|
50 def __enableOkButton(self): |
|
51 """ |
|
52 Private slot to set the enable state of theok button. |
|
53 """ |
|
54 self.okButton.setEnabled( |
|
55 self.classnameEdit.text() != "" and |
|
56 self.filenameEdit.text() != "" and |
|
57 self.pathnamePicker.text() != "") |
|
58 |
|
59 def on_classnameEdit_textChanged(self, text): |
|
60 """ |
|
61 Private slot called, when thext of the classname edit has changed. |
|
62 |
|
63 @param text changed text (string) |
|
64 """ |
|
65 self.__enableOkButton() |
|
66 |
|
67 def on_filenameEdit_textChanged(self, text): |
|
68 """ |
|
69 Private slot called, when thext of the filename edit has changed. |
|
70 |
|
71 @param text changed text (string) |
|
72 """ |
|
73 self.__enableOkButton() |
|
74 |
|
75 def on_pathnamePicker_textChanged(self, text): |
|
76 """ |
|
77 Private slot called, when the text of the path name has changed. |
|
78 |
|
79 @param text changed text (string) |
|
80 """ |
|
81 self.__enableOkButton() |
|
82 |
|
83 def getData(self): |
|
84 """ |
|
85 Public method to retrieve the data entered into the dialog. |
|
86 |
|
87 @return tuple giving the classname (string) and the file name (string) |
|
88 """ |
|
89 return self.classnameEdit.text(), \ |
|
90 os.path.join(self.pathnamePicker.text(), |
|
91 self.filenameEdit.text()) |