def downloadLogo(self, url): logo = LogoDownloader(self.controller, self, url).download() logo.refreshData() map = logo.provideQPixmap() if self.team == 1: self.controller.logoManager.setTeam1Logo(logo) self.mainWindow.team1_icon.setPixmap(map) self.mainWindow.refreshLastUsed() elif self.team == 2: self.controller.logoManager.setTeam2Logo(logo) self.mainWindow.team2_icon.setPixmap(map) self.mainWindow.refreshLastUsed()
def logoFromUrlDialog(self, team): """Open dialog for team logo.""" url = "http://" regex = re.compile( r'^(?:http|ftp)s?://' # http:// or https:// # domain... r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+' r'(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' r'localhost|' # localhost... r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip r'(?::\d+)?' # optional port r'(?:/?|[/?]\S+)$', re.IGNORECASE) emsg = QErrorMessage(self) emsg.setWindowModality(Qt.WindowModal) while True: url, status = QInputDialog.getText(self, _("Logo from URL"), _("URL of Team Logo") + ":", QLineEdit.Normal, url) if status: if not regex.match(url): QMessageBox.critical( self, "Invalid URL", _('{} is not a valid URL.').format(url)) continue else: logo = LogoDownloader(self.controller, self, url).download() logo.refreshData() map = logo.provideQPixmap() if team == 1: self.controller.logoManager.setTeam1Logo(logo) self.team1_icon.setPixmap(map) self.refreshLastUsed() elif team == 2: self.controller.logoManager.setTeam2Logo(logo) self.team2_icon.setPixmap(map) self.refreshLastUsed() break else: break