Project/NewDialogClassDialog.py

changeset 4582
3a1d1d4c6f4f
parent 4021
195a471c327b
child 4631
5c1a96925da4
equal deleted inserted replaced
4581:76999ca7bbf1 4582:3a1d1d4c6f4f
9 9
10 from __future__ import unicode_literals 10 from __future__ import unicode_literals
11 11
12 import os 12 import os
13 13
14 from PyQt5.QtCore import QDir, pyqtSlot
15 from PyQt5.QtWidgets import QDialog, QDialogButtonBox 14 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
16 15
17 from E5Gui.E5Completers import E5DirCompleter 16 from E5Gui.E5PathPicker import E5PathPickerModes
18 from E5Gui import E5FileDialog
19 17
20 from .Ui_NewDialogClassDialog import Ui_NewDialogClassDialog 18 from .Ui_NewDialogClassDialog import Ui_NewDialogClassDialog
21
22 import UI.PixmapCache
23 19
24 20
25 class NewDialogClassDialog(QDialog, Ui_NewDialogClassDialog): 21 class NewDialogClassDialog(QDialog, Ui_NewDialogClassDialog):
26 """ 22 """
27 Class implementing a dialog to ente the data for a new dialog class file. 23 Class implementing a dialog to ente the data for a new dialog class file.
37 @param parent parent widget if the dialog (QWidget) 33 @param parent parent widget if the dialog (QWidget)
38 """ 34 """
39 super(NewDialogClassDialog, self).__init__(parent) 35 super(NewDialogClassDialog, self).__init__(parent)
40 self.setupUi(self) 36 self.setupUi(self)
41 37
42 self.pathButton.setIcon(UI.PixmapCache.getIcon("open.png")) 38 self.pathnamePicker.setMode(E5PathPickerModes.DirectoryMode)
43 39
44 self.okButton = self.buttonBox.button(QDialogButtonBox.Ok) 40 self.okButton = self.buttonBox.button(QDialogButtonBox.Ok)
45 self.okButton.setEnabled(False) 41 self.okButton.setEnabled(False)
46 42
47 self.pathnameCompleter = E5DirCompleter(self.pathnameEdit)
48
49 self.classnameEdit.setText(defaultClassName) 43 self.classnameEdit.setText(defaultClassName)
50 self.filenameEdit.setText(defaultFile) 44 self.filenameEdit.setText(defaultFile)
51 self.pathnameEdit.setText(QDir.toNativeSeparators(defaultPath)) 45 self.pathnamePicker.setText(defaultPath)
52 46
53 msh = self.minimumSizeHint() 47 msh = self.minimumSizeHint()
54 self.resize(max(self.width(), msh.width()), msh.height()) 48 self.resize(max(self.width(), msh.width()), msh.height())
55
56 @pyqtSlot()
57 def on_pathButton_clicked(self):
58 """
59 Private slot called to open a directory selection dialog.
60 """
61 path = E5FileDialog.getExistingDirectory(
62 self,
63 self.tr("Select source directory"),
64 QDir.fromNativeSeparators(self.pathnameEdit.text()))
65 if path:
66 self.pathnameEdit.setText(QDir.toNativeSeparators(path))
67 49
68 def __enableOkButton(self): 50 def __enableOkButton(self):
69 """ 51 """
70 Private slot to set the enable state of theok button. 52 Private slot to set the enable state of theok button.
71 """ 53 """
72 self.okButton.setEnabled( 54 self.okButton.setEnabled(
73 self.classnameEdit.text() != "" and 55 self.classnameEdit.text() != "" and
74 self.filenameEdit.text() != "" and 56 self.filenameEdit.text() != "" and
75 self.pathnameEdit.text() != "") 57 self.pathnamePicker.text() != "")
76 58
77 def on_classnameEdit_textChanged(self, text): 59 def on_classnameEdit_textChanged(self, text):
78 """ 60 """
79 Private slot called, when thext of the classname edit has changed. 61 Private slot called, when thext of the classname edit has changed.
80 62
88 70
89 @param text changed text (string) 71 @param text changed text (string)
90 """ 72 """
91 self.__enableOkButton() 73 self.__enableOkButton()
92 74
93 def on_pathnameEdit_textChanged(self, text): 75 def on_pathnamePicker_textChanged(self, text):
94 """ 76 """
95 Private slot called, when thext of the pathname edit has changed. 77 Private slot called, when the text of the path name has changed.
96 78
97 @param text changed text (string) 79 @param text changed text (string)
98 """ 80 """
99 self.__enableOkButton() 81 self.__enableOkButton()
100 82
103 Public method to retrieve the data entered into the dialog. 85 Public method to retrieve the data entered into the dialog.
104 86
105 @return tuple giving the classname (string) and the file name (string) 87 @return tuple giving the classname (string) and the file name (string)
106 """ 88 """
107 return self.classnameEdit.text(), \ 89 return self.classnameEdit.text(), \
108 os.path.join(self.pathnameEdit.text(), 90 os.path.join(self.pathnamePicker.text(),
109 self.filenameEdit.text()) 91 self.filenameEdit.text())

eric ide

mercurial