10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 |
11 |
12 import os |
12 import os |
13 |
13 |
14 from PyQt4.QtCore import QDir, pyqtSlot |
14 from PyQt4.QtCore import QDir, pyqtSlot |
15 from PyQt4.QtGui import QDialog |
15 from PyQt4.QtGui import QDialog, QDialogButtonBox |
16 |
16 |
17 from E5Gui.E5Application import e5App |
17 from E5Gui.E5Application import e5App |
18 from E5Gui.E5Completers import E5FileCompleter, E5DirCompleter |
18 from E5Gui.E5Completers import E5FileCompleter, E5DirCompleter |
19 from E5Gui import E5FileDialog |
19 from E5Gui import E5FileDialog |
20 |
20 |
21 from .Ui_PropertiesDialog import Ui_PropertiesDialog |
21 from .Ui_PropertiesDialog import Ui_PropertiesDialog |
22 |
22 |
23 import Utilities |
23 import Utilities |
24 import Preferences |
24 import Preferences |
|
25 import UI.PixmapCache |
25 |
26 |
26 |
27 |
27 class PropertiesDialog(QDialog, Ui_PropertiesDialog): |
28 class PropertiesDialog(QDialog, Ui_PropertiesDialog): |
28 """ |
29 """ |
29 Class implementing the project properties dialog. |
30 Class implementing the project properties dialog. |
40 super(PropertiesDialog, self).__init__(parent) |
41 super(PropertiesDialog, self).__init__(parent) |
41 if name: |
42 if name: |
42 self.setObjectName(name) |
43 self.setObjectName(name) |
43 self.setupUi(self) |
44 self.setupUi(self) |
44 |
45 |
|
46 self.dirButton.setIcon(UI.PixmapCache.getIcon("open.png")) |
|
47 self.mainscriptButton.setIcon(UI.PixmapCache.getIcon("open.png")) |
|
48 |
45 self.project = project |
49 self.project = project |
46 self.newProject = new |
50 self.newProject = new |
47 self.transPropertiesDlg = None |
51 self.transPropertiesDlg = None |
48 self.spellPropertiesDlg = None |
52 self.spellPropertiesDlg = None |
49 |
53 |
55 projectTypes = project.getProjectTypes() |
59 projectTypes = project.getProjectTypes() |
56 self.projectTypeComboBox.clear() |
60 self.projectTypeComboBox.clear() |
57 for projectType in sorted(projectTypes.keys()): |
61 for projectType in sorted(projectTypes.keys()): |
58 self.projectTypeComboBox.addItem( |
62 self.projectTypeComboBox.addItem( |
59 projectTypes[projectType], projectType) |
63 projectTypes[projectType], projectType) |
|
64 |
|
65 ipath = Preferences.getMultiProject("Workspace") or \ |
|
66 Utilities.getHomeDir() |
|
67 self.__initPaths = [ |
|
68 Utilities.fromNativeSeparators(ipath), |
|
69 Utilities.fromNativeSeparators(ipath) + "/", |
|
70 ] |
60 |
71 |
61 if not new: |
72 if not new: |
62 name = os.path.splitext(self.project.pfile)[0] |
73 name = os.path.splitext(self.project.pfile)[0] |
63 self.nameEdit.setText(os.path.basename(name)) |
74 self.nameEdit.setText(os.path.basename(name)) |
64 self.languageComboBox.setCurrentIndex( |
75 self.languageComboBox.setCurrentIndex( |
106 vcsSystemDisplay = \ |
117 vcsSystemDisplay = \ |
107 vcsSystemsDict[self.project.pdata["VCS"][0]] |
118 vcsSystemsDict[self.project.pdata["VCS"][0]] |
108 except KeyError: |
119 except KeyError: |
109 vcsSystemDisplay = "None" |
120 vcsSystemDisplay = "None" |
110 self.vcsLabel.setText( |
121 self.vcsLabel.setText( |
111 self.trUtf8( |
122 self.tr( |
112 "The project is version controlled by <b>{0}</b>.") |
123 "The project is version controlled by <b>{0}</b>.") |
113 .format(vcsSystemDisplay)) |
124 .format(vcsSystemDisplay)) |
114 self.vcsInfoButton.show() |
125 self.vcsInfoButton.show() |
115 else: |
126 else: |
116 self.vcsLabel.setText( |
127 self.vcsLabel.setText( |
117 self.trUtf8("The project is not version controlled.")) |
128 self.tr("The project is not version controlled.")) |
118 self.vcsInfoButton.hide() |
129 self.vcsInfoButton.hide() |
119 self.vcsCheckBox.hide() |
130 self.vcsCheckBox.hide() |
120 else: |
131 else: |
121 self.languageComboBox.setCurrentIndex( |
132 self.languageComboBox.setCurrentIndex( |
122 self.languageComboBox.findText("Python3")) |
133 self.languageComboBox.findText("Python3")) |
123 self.projectTypeComboBox.setCurrentIndex( |
134 self.projectTypeComboBox.setCurrentIndex( |
124 self.projectTypeComboBox.findData("Qt4")) |
135 self.projectTypeComboBox.findData("Qt4")) |
125 hp = Preferences.getMultiProject("Workspace") or \ |
136 self.dirEdit.setText(self.__initPaths[0]) |
126 Utilities.getHomeDir() |
|
127 self.dirEdit.setText(hp) |
|
128 self.versionEdit.setText('0.1') |
137 self.versionEdit.setText('0.1') |
129 self.vcsLabel.hide() |
138 self.vcsLabel.hide() |
130 self.vcsInfoButton.hide() |
139 self.vcsInfoButton.hide() |
131 if not self.project.vcsSoftwareAvailable(): |
140 if not self.project.vcsSoftwareAvailable(): |
132 self.vcsCheckBox.hide() |
141 self.vcsCheckBox.hide() |
|
142 |
|
143 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled( |
|
144 bool(self.dirEdit.text()) and |
|
145 Utilities.fromNativeSeparators(self.dirEdit.text()) not in |
|
146 self.__initPaths) |
133 |
147 |
134 @pyqtSlot(str) |
148 @pyqtSlot(str) |
135 def on_languageComboBox_currentIndexChanged(self, language): |
149 def on_languageComboBox_currentIndexChanged(self, language): |
136 """ |
150 """ |
137 Private slot handling the selection of a programming language. |
151 Private slot handling the selection of a programming language. |
147 projectTypes[projectType], projectType) |
161 projectTypes[projectType], projectType) |
148 |
162 |
149 self.projectTypeComboBox.setCurrentIndex( |
163 self.projectTypeComboBox.setCurrentIndex( |
150 self.projectTypeComboBox.findData(curProjectType)) |
164 self.projectTypeComboBox.findData(curProjectType)) |
151 |
165 |
|
166 @pyqtSlot(str) |
|
167 def on_dirEdit_textChanged(self, txt): |
|
168 """ |
|
169 Private slot to handle a change of the project directory. |
|
170 |
|
171 @param txt name of the project directory (string) |
|
172 """ |
|
173 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled( |
|
174 bool(txt) and |
|
175 Utilities.fromNativeSeparators(txt) not in self.__initPaths) |
|
176 |
152 @pyqtSlot() |
177 @pyqtSlot() |
153 def on_dirButton_clicked(self): |
178 def on_dirButton_clicked(self): |
154 """ |
179 """ |
155 Private slot to display a directory selection dialog. |
180 Private slot to display a directory selection dialog. |
156 """ |
181 """ |
157 directory = E5FileDialog.getExistingDirectory( |
182 directory = E5FileDialog.getExistingDirectory( |
158 self, |
183 self, |
159 self.trUtf8("Select project directory"), |
184 self.tr("Select project directory"), |
160 self.dirEdit.text(), |
185 self.dirEdit.text(), |
161 E5FileDialog.Options(E5FileDialog.ShowDirsOnly)) |
186 E5FileDialog.Options(E5FileDialog.ShowDirsOnly)) |
162 |
187 |
163 if directory: |
188 if directory: |
164 self.dirEdit.setText(Utilities.toNativeSeparators(directory)) |
189 self.dirEdit.setText(Utilities.toNativeSeparators(directory)) |
203 dir = QDir.currentPath() |
228 dir = QDir.currentPath() |
204 patterns = [] |
229 patterns = [] |
205 for pattern, filetype in list(self.project.pdata["FILETYPES"].items()): |
230 for pattern, filetype in list(self.project.pdata["FILETYPES"].items()): |
206 if filetype == "SOURCES": |
231 if filetype == "SOURCES": |
207 patterns.append(pattern) |
232 patterns.append(pattern) |
208 filters = self.trUtf8("Source Files ({0});;All Files (*)")\ |
233 filters = self.tr("Source Files ({0});;All Files (*)")\ |
209 .format(" ".join(patterns)) |
234 .format(" ".join(patterns)) |
210 fn = E5FileDialog.getOpenFileName( |
235 fn = E5FileDialog.getOpenFileName( |
211 self, |
236 self, |
212 self.trUtf8("Select main script file"), |
237 self.tr("Select main script file"), |
213 dir, |
238 dir, |
214 filters) |
239 filters) |
215 |
240 |
216 if fn: |
241 if fn: |
217 ppath = self.dirEdit.text() |
242 ppath = self.dirEdit.text() |