From 42ba228eecb5726506848bd08758bd1f925905cc Mon Sep 17 00:00:00 2001 From: kali Date: Mon, 12 Nov 2012 12:45:37 +0900 Subject: fix prevalidation error showing in register page. --- src/leap/gui/firstrun/providerselect.py | 14 ++++++++++++++ src/leap/gui/firstrun/register.py | 27 +++++++++++++++++++++++---- src/leap/gui/firstrun/regvalidation.py | 1 + 3 files changed, 38 insertions(+), 4 deletions(-) (limited to 'src/leap/gui') diff --git a/src/leap/gui/firstrun/providerselect.py b/src/leap/gui/firstrun/providerselect.py index 3fb76557..8d1aa869 100644 --- a/src/leap/gui/firstrun/providerselect.py +++ b/src/leap/gui/firstrun/providerselect.py @@ -175,6 +175,13 @@ class SelectProviderPage(QtGui.QWizardPage): else: showerr('') + def cleanup_errormsg(self): + """ + we reset bad_string to None + should be called before leaving the page + """ + self.bad_string = None + def paintEvent(self, event): """ we hook our populate errors @@ -190,6 +197,13 @@ class SelectProviderPage(QtGui.QWizardPage): self.validationMsg.setText('') self.certinfoGroup.hide() + def validatePage(self): + # some cleanup before we leave the page + self.cleanup_errormsg() + + # go + return True + def nextId(self): wizard = self.wizard() if not wizard: diff --git a/src/leap/gui/firstrun/register.py b/src/leap/gui/firstrun/register.py index 6d15c156..b46dd4cd 100644 --- a/src/leap/gui/firstrun/register.py +++ b/src/leap/gui/firstrun/register.py @@ -95,18 +95,30 @@ class RegisterUserPage(QtGui.QWizardPage, UserFormMixIn): bad_str = getattr(self, 'bad_string', None) cur_str = self.userNameLineEdit.text() showerr = self.validationMsg.setText + prev_er = getattr(self, 'prevalidation_error', None) + if bad_str is None: # first time we fall here. # save the current bad_string value self.bad_string = cur_str showerr(errors) else: + if prev_er: + showerr(prev_er) + return # not the first time if cur_str == bad_str: showerr(errors) else: showerr('') + def cleanup_errormsg(self): + """ + we reset bad_string to None + should be called before leaving the page + """ + self.bad_string = None + def paintEvent(self, event): """ we hook our populate errors @@ -118,6 +130,9 @@ class RegisterUserPage(QtGui.QWizardPage, UserFormMixIn): super(RegisterUserPage, self).paintEvent(event) self.populateErrors() + def set_prevalidation_error(self, error): + self.prevalidation_error = error + def validatePage(self): """ we only pre-validate here password weakness @@ -137,18 +152,22 @@ class RegisterUserPage(QtGui.QWizardPage, UserFormMixIn): # to assess strenght and avoid silly stuff. if password != password2: - self.set_validation_status('Password does not match.') + self.set_prevalidation_error('Password does not match.') return False if len(password) < 6: - self.set_validation_status('Password too short.') + self.set_prevalidation_error('Password too short.') return False if password == "123456": - # joking - self.set_validation_status('Password too obvious.') + # joking, but not too much. + self.set_prevalidation_error('Password too obvious.') return False + # some cleanup before we leave the page + self.cleanup_errormsg() + + # go return True def initializePage(self): diff --git a/src/leap/gui/firstrun/regvalidation.py b/src/leap/gui/firstrun/regvalidation.py index e2d6d425..b1308051 100644 --- a/src/leap/gui/firstrun/regvalidation.py +++ b/src/leap/gui/firstrun/regvalidation.py @@ -94,6 +94,7 @@ class RegisterUserValidationPage(ValidationPage): # if NOT from_login. step = "register" + update_signal.emit("checking availability", 20) update_signal.emit("registering with provider", 40) logger.debug('registering user') -- cgit v1.2.3