Add settings for transifex
offlate/window.py
243 | 243 | ||
244 | 244 | tab = QTabWidget() | |
245 | 245 | self.addTPTab(tab) | |
246 | + | self.addTransifexTab(tab) | |
246 | 247 | ||
247 | 248 | buttonbox = QHBoxLayout() | |
248 | 249 | cancel = QPushButton(self.tr("Cancel")) | |
… | |||
256 | 257 | cancel.clicked.connect(self.close) | |
257 | 258 | ok.clicked.connect(self.ok) | |
258 | 259 | ||
260 | + | def addTransifexTab(self, tab): | |
261 | + | formBox = QGroupBox(self.tr("Transifex")) | |
262 | + | formLayout = QFormLayout() | |
263 | + | self.TransifexToken = QLineEdit() | |
264 | + | ||
265 | + | if not "Transifex" in self.data: | |
266 | + | self.data["Transifex"] = {} | |
267 | + | try: | |
268 | + | self.TransifexToken.setText(self.data["Transifex"]["token"]) | |
269 | + | except Exception: | |
270 | + | pass | |
271 | + | ||
272 | + | self.TransifexToken.textChanged.connect(self.updateTransifex) | |
273 | + | label = QLabel(self.tr("You can get a token from <a href=\"#\">https://www.transifex.com/user/settings/api/</a>")) | |
274 | + | label.linkActivated.connect(self.openTransifex) | |
275 | + | ||
276 | + | formLayout.addRow(QLabel(self.tr("Token:")), self.TransifexToken) | |
277 | + | formLayout.addRow(label) | |
278 | + | ||
279 | + | formBox.setLayout(formLayout) | |
280 | + | tab.addTab(formBox, "Transifex") | |
281 | + | ||
282 | + | def openTransifex(self): | |
283 | + | QDesktopServices().openUrl(QUrl("https://www.transifex.com/user/settings/api/")); | |
284 | + | ||
285 | + | def updateTransifex(self): | |
286 | + | self.data["Transifex"] = {} | |
287 | + | self.data["Transifex"]["token"] = self.TransifexToken.text() | |
288 | + | ||
259 | 289 | def addTPTab(self, tab): | |
260 | - | formBox = QGroupBox("Form layout") | |
290 | + | formBox = QGroupBox(self.tr("Translation Project")) | |
261 | 291 | formLayout = QFormLayout() | |
262 | 292 | ||
263 | 293 | self.TPemail = QLineEdit() | |
… | |||
266 | 296 | ||
267 | 297 | if not "TP" in self.data: | |
268 | 298 | self.data["TP"] = {} | |
269 | - | self.TPemail.setText(self.data["TP"]["email"]) | |
270 | - | self.TPuser.setText(self.data["TP"]["user"]) | |
271 | - | self.TPserver.setText(self.data["TP"]["server"]) | |
299 | + | ||
300 | + | try: | |
301 | + | self.TPemail.setText(self.data["TP"]["email"]) | |
302 | + | self.TPuser.setText(self.data["TP"]["user"]) | |
303 | + | self.TPserver.setText(self.data["TP"]["server"]) | |
304 | + | except Exception: | |
305 | + | pass | |
272 | 306 | ||
273 | 307 | self.TPemail.textChanged.connect(self.updateTP) | |
274 | 308 | self.TPuser.textChanged.connect(self.updateTP) |