Open links in browser
offlate/core/config.py
| 19 | 19 | A configuration specification is a list of specifications. This class | |
| 20 | 20 | represents one such specification. | |
| 21 | 21 | """ | |
| 22 | - | def __init__(self, key, name, description, optional): | |
| 22 | + | def __init__(self, key, name, description, optional, link): | |
| 23 | 23 | self.key = key | |
| 24 | 24 | self.name = name | |
| 25 | 25 | self.description = description | |
| 26 | 26 | self.optional = optional | |
| 27 | + | self.link = link | |
| 27 | 28 | ||
| 28 | 29 | def isConfigured(self, conf): | |
| 29 | 30 | """ | |
… | |||
| 38 | 39 | """ | |
| 39 | 40 | The specification of a string. | |
| 40 | 41 | """ | |
| 41 | - | def __init__(self, key, name, description, placeholder='', optional=False): | |
| 42 | - | ConfigSpec.__init__(self, key, name, description, optional) | |
| 42 | + | def __init__(self, key, name, description, link=None, placeholder='', optional=False): | |
| 43 | + | ConfigSpec.__init__(self, key, name, description, optional, link) | |
| 43 | 44 | self.placeholder = placeholder | |
| 44 | 45 | ||
| 45 | 46 | def isConfigured(self, conf): | |
… | |||
| 51 | 52 | The specification of a list of configurations. | |
| 52 | 53 | """ | |
| 53 | 54 | def __init__(self, key, name, description, specifications, indexKey, | |
| 54 | - | hasRequiredRow, optional=False): | |
| 55 | - | ConfigSpec.__init__(self, key, name, description, optional) | |
| 55 | + | hasRequiredRow, link=None, optional=False): | |
| 56 | + | ConfigSpec.__init__(self, key, name, description, optional, link) | |
| 56 | 57 | self.specifications = specifications | |
| 57 | 58 | self.indexKey = indexKey | |
| 58 | 59 | self.hasRequiredRow = hasRequiredRow | |
offlate/systems/github.py
| 97 | 97 | def getSystemConfigSpec(): | |
| 98 | 98 | specs = [StringConfigSpec('token', Project.tr('Token'), | |
| 99 | 99 | Project.tr('You can get a token from <a href=\"#\">https://github.com/settings/tokens/new</a>. \ | |
| 100 | - | You will need at least to grant the public_repo permission.'))] | |
| 100 | + | You will need at least to grant the public_repo permission.'), | |
| 101 | + | link='https://github.com/settings/tokens/new')] | |
| 101 | 102 | specs.extend(GitProject.getSystemConfigSpec()) | |
| 102 | 103 | return specs |
offlate/systems/transifex.py
| 145 | 145 | @staticmethod | |
| 146 | 146 | def getSystemConfigSpec(): | |
| 147 | 147 | return [StringConfigSpec('token', Project.tr('Token'), | |
| 148 | - | Project.tr('You can get a token from <a href=\"#\">https://www.transifex.com/user/settings/api/</a>'))] | |
| 148 | + | Project.tr('You can get a token from <a href=\"#\">https://www.transifex.com/user/settings/api/</a>'), | |
| 149 | + | link='https://www.transifex.com/user/settings/api/')] | |
| 149 | 150 | ||
| 150 | 151 | @staticmethod | |
| 151 | 152 | def getProjectConfigSpec(): |
offlate/ui/settings.py
| 61 | 61 | for s in spec: | |
| 62 | 62 | label = QLabel(self.tr(s.description)) | |
| 63 | 63 | label.setWordWrap(True) | |
| 64 | + | label.linkActivated.connect(self.linkOpener(s.link)) | |
| 64 | 65 | widget = None | |
| 65 | 66 | if isinstance(s, StringConfigSpec): | |
| 66 | 67 | widget = SettingsLineEdit() | |
… | |||
| 95 | 96 | ||
| 96 | 97 | tab.setCurrentIndex(self.system + 1) | |
| 97 | 98 | ||
| 99 | + | def linkOpener(self, url): | |
| 100 | + | return lambda : self.openLink(url) | |
| 101 | + | ||
| 102 | + | def openLink(self, url): | |
| 103 | + | print(url) | |
| 104 | + | QDesktopServices().openUrl(QUrl(url)); | |
| 105 | + | ||
| 98 | 106 | def update(self): | |
| 99 | 107 | for system in systems: | |
| 100 | 108 | name = system['name'] | |