eric7/Project/NewDialogClassDialog.py

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

eric ide

mercurial