disable button in new window when all fields are not filled
offlate/window.py
201 | 201 | self.combo.addItem(self.tr("Transifex")) | |
202 | 202 | self.formLayout.addRow(self.combo) | |
203 | 203 | ||
204 | + | self.nameWidget.textChanged.connect(self.modify) | |
205 | + | self.langWidget.textChanged.connect(self.modify) | |
206 | + | ||
204 | 207 | hhbox = QHBoxLayout() | |
205 | 208 | cancel = QPushButton(self.tr("Cancel")) | |
206 | - | ok = QPushButton(self.tr("OK")) | |
209 | + | self.okbutton = QPushButton(self.tr("OK")) | |
210 | + | self.okbutton.setEnabled(False) | |
207 | 211 | hhbox.addWidget(cancel) | |
208 | - | hhbox.addWidget(ok) | |
212 | + | hhbox.addWidget(self.okbutton) | |
209 | 213 | contentbox.addWidget(formbox) | |
210 | 214 | contentbox.addLayout(hhbox) | |
211 | 215 | hbox.addLayout(predefinedbox) | |
… | |||
215 | 219 | self.additionalFields.append([]) | |
216 | 220 | self.additionalFields.append([]) | |
217 | 221 | self.transifexOrganisation = QLineEdit() | |
222 | + | self.transifexOrganisation.textChanged.connect(self.modify) | |
218 | 223 | transifexOrganisationLabel = QLabel(self.tr("Organization")) | |
219 | 224 | self.additionalFields[1].append({'label': transifexOrganisationLabel, | |
220 | 225 | 'widget': self.transifexOrganisation}) | |
… | |||
223 | 228 | ||
224 | 229 | self.predefinedprojects.currentItemChanged.connect(self.fill) | |
225 | 230 | cancel.clicked.connect(self.close) | |
226 | - | ok.clicked.connect(self.ok) | |
231 | + | self.okbutton.clicked.connect(self.ok) | |
227 | 232 | self.searchfield.textChanged.connect(self.filter) | |
228 | 233 | self.combo.currentIndexChanged.connect(self.othersystem) | |
229 | 234 | ||
… | |||
249 | 254 | item.setData(Qt.UserRole, d) | |
250 | 255 | self.predefinedprojects.addItem(item) | |
251 | 256 | ||
257 | + | def modify(self): | |
258 | + | enable = False | |
259 | + | if self.nameWidget.text() != '' and self.langWidget.text() != '': | |
260 | + | enable = True | |
261 | + | for widget in self.additionalFields[self.combo.currentIndex()]: | |
262 | + | if widget['widget'].text() == '': | |
263 | + | enable = False | |
264 | + | break | |
265 | + | self.okbutton.setEnabled(enable) | |
266 | + | ||
252 | 267 | def wantNew(self): | |
253 | 268 | return self.askNew | |
254 | 269 | ||
… | |||
279 | 294 | self.formLayout.addRow(widget['label'], widget['widget']) | |
280 | 295 | widget['widget'].show() | |
281 | 296 | widget['label'].show() | |
297 | + | self.modify() | |
282 | 298 | ||
283 | 299 | class SettingsWindow(QDialog): | |
284 | 300 | def __init__(self, preferences, parent = None): |