diff options
author | kali <kali@leap.se> | 2012-11-12 12:25:11 +0900 |
---|---|---|
committer | kali <kali@leap.se> | 2012-11-12 12:25:11 +0900 |
commit | fe16e62fa83c24d2ef379a3f9e102d336e527656 (patch) | |
tree | 53baa59579c2ba15820ae342c693a97518a872ef /src/leap | |
parent | 13c4bd9087e4caaf9e440efa210d5762b8aca875 (diff) |
cleanup errors on page init and on field change
Diffstat (limited to 'src/leap')
-rw-r--r-- | src/leap/gui/firstrun/providerinfo.py | 3 | ||||
-rw-r--r-- | src/leap/gui/firstrun/providerselect.py | 18 | ||||
-rw-r--r-- | src/leap/gui/firstrun/register.py | 18 | ||||
-rw-r--r-- | src/leap/gui/progress.py | 13 |
4 files changed, 47 insertions, 5 deletions
diff --git a/src/leap/gui/firstrun/providerinfo.py b/src/leap/gui/firstrun/providerinfo.py index 0c557d66..ef3b32c1 100644 --- a/src/leap/gui/firstrun/providerinfo.py +++ b/src/leap/gui/firstrun/providerinfo.py @@ -31,6 +31,9 @@ class ProviderInfoPage(ValidationPage): QtGui.QWizard.LogoPixmap, QtGui.QPixmap(APP_LOGO)) + self.prev_page = "providerselection" + #self.current_page = "providerinfo" + def create_info_panel(self): # Use stacked widget instead # of reparenting the layout. diff --git a/src/leap/gui/firstrun/providerselect.py b/src/leap/gui/firstrun/providerselect.py index a20f40b3..3fb76557 100644 --- a/src/leap/gui/firstrun/providerselect.py +++ b/src/leap/gui/firstrun/providerselect.py @@ -153,13 +153,27 @@ class SelectProviderPage(QtGui.QWizardPage): def populateErrors(self): # XXX could move this to ValidationMixin + # with some defaults for the validating fields + # (now it only allows one field, manually specified) #logger.debug('getting errors') errors = self.wizard().get_validation_error( self.current_page) if errors: - #logger.debug('errors! -> %s', errors) - self.validationMsg.setText(errors) + bad_str = getattr(self, 'bad_string', None) + cur_str = self.providerNameEdit.text() + showerr = self.validationMsg.setText + if bad_str is None: + # first time we fall here. + # save the current bad_string value + self.bad_string = cur_str + showerr(errors) + else: + # not the first time + if cur_str == bad_str: + showerr(errors) + else: + showerr('') def paintEvent(self, event): """ diff --git a/src/leap/gui/firstrun/register.py b/src/leap/gui/firstrun/register.py index 0a7ba34b..6d15c156 100644 --- a/src/leap/gui/firstrun/register.py +++ b/src/leap/gui/firstrun/register.py @@ -87,13 +87,25 @@ class RegisterUserPage(QtGui.QWizardPage, UserFormMixIn): def populateErrors(self): # XXX could move this to ValidationMixin + # used in providerselect too - #logger.debug('getting errors') errors = self.wizard().get_validation_error( self.current_page) if errors: - #logger.debug('errors! -> %s', errors) - self.validationMsg.setText(errors) + bad_str = getattr(self, 'bad_string', None) + cur_str = self.userNameLineEdit.text() + showerr = self.validationMsg.setText + if bad_str is None: + # first time we fall here. + # save the current bad_string value + self.bad_string = cur_str + showerr(errors) + else: + # not the first time + if cur_str == bad_str: + showerr(errors) + else: + showerr('') def paintEvent(self, event): """ diff --git a/src/leap/gui/progress.py b/src/leap/gui/progress.py index b2e34e22..2b1b40d9 100644 --- a/src/leap/gui/progress.py +++ b/src/leap/gui/progress.py @@ -192,6 +192,17 @@ class ValidationPage(QtGui.QWizardPage): def pop_first_error(self): return list(reversed(self.errors.items())).pop() + def clean_errors(self): + self.errors = OrderedDict() + + def clean_wizard_errors(self, pagename=None): + if pagename is None: + pagename = getattr(self, 'prev_page', None) + if pagename is None: + return + logger.debug('cleaning wizard errors for %s' % pagename) + self.wizard().set_validation_error(pagename, None) + def populateStepsTable(self): # from examples, # but I guess it's not needed to re-populate @@ -255,6 +266,8 @@ class ValidationPage(QtGui.QWizardPage): self.wizard().next() def initializePage(self): + self.clean_errors() + self.clean_wizard_errors() self.steps.removeAllSteps() self.clearTable() self.resizeTable() |