Add settings for github

Julien LepillerSun Nov 10 11:35:18+0100 2019

a3a9deb

Add settings for github

offlate/ui/settings.py

3636
        self.addTPTab(tab)
3737
        self.addTransifexTab(tab)
3838
        self.addGitlabTab(tab)
39+
        self.addGithubTab(tab)
3940
4041
        buttonbox = QHBoxLayout()
4142
        cancel = QPushButton(self.tr("Cancel"))

142143
        self.done = True
143144
        self.close()
144145
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+
145177
    def addGitlabTab(self, tab):
146178
        formBox = QGroupBox(self.tr("Gitlab"))
147179
        formLayout = QVBoxLayout()