Add settings for github
offlate/ui/settings.py
36 | 36 | self.addTPTab(tab) | |
37 | 37 | self.addTransifexTab(tab) | |
38 | 38 | self.addGitlabTab(tab) | |
39 | + | self.addGithubTab(tab) | |
39 | 40 | ||
40 | 41 | buttonbox = QHBoxLayout() | |
41 | 42 | cancel = QPushButton(self.tr("Cancel")) | |
… | |||
142 | 143 | self.done = True | |
143 | 144 | self.close() | |
144 | 145 | ||
146 | + | def addGithubTab(self, tab): | |
147 | + | formBox = QGroupBox(self.tr("Github")) | |
148 | + | formLayout = QFormLayout() | |
149 | + | self.GithubToken = QLineEdit() | |
150 | + | ||
151 | + | if not "Github" in self.data: | |
152 | + | self.data["Github"] = {} | |
153 | + | try: | |
154 | + | self.GithubToken.setText(self.data["Github"]["token"]) | |
155 | + | except Exception: | |
156 | + | pass | |
157 | + | ||
158 | + | self.GithubToken.textChanged.connect(self.updateGithub) | |
159 | + | label = QLabel(self.tr("You can get a token from <a href=\"#\">https://github.com/settings/tokens/new</a>. \ | |
160 | + | You will need at least to grant the public_repo permission.")) | |
161 | + | label.linkActivated.connect(self.openGithub) | |
162 | + | label.setWordWrap(True) | |
163 | + | ||
164 | + | formLayout.addRow(QLabel(self.tr("Token:")), self.GithubToken) | |
165 | + | formLayout.addRow(label) | |
166 | + | ||
167 | + | formBox.setLayout(formLayout) | |
168 | + | tab.addTab(formBox, "Github") | |
169 | + | ||
170 | + | def openGithub(self): | |
171 | + | QDesktopServices().openUrl(QUrl("https://github.com/settings/tokens/new")); | |
172 | + | ||
173 | + | def updateGithub(self): | |
174 | + | self.data["Github"] = {} | |
175 | + | self.data["Github"]["token"] = self.GithubToken.text() | |
176 | + | ||
145 | 177 | def addGitlabTab(self, tab): | |
146 | 178 | formBox = QGroupBox(self.tr("Gitlab")) | |
147 | 179 | formLayout = QVBoxLayout() |