diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-10-19 14:18:04 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-10-19 14:18:04 -0600 |
commit | 7fc4b120bf35daa5d3d96eb565ec7d79ce153653 (patch) | |
tree | 159b576c6cb87486e043d5ba103b4b634ef1b230 /src/gui | |
parent | 72883051f1c947c324e259dc5e323ca3dfaf3737 (diff) | |
download | mana-client-7fc4b120bf35daa5d3d96eb565ec7d79ce153653.tar.gz mana-client-7fc4b120bf35daa5d3d96eb565ec7d79ce153653.tar.bz2 mana-client-7fc4b120bf35daa5d3d96eb565ec7d79ce153653.tar.xz mana-client-7fc4b120bf35daa5d3d96eb565ec7d79ce153653.zip |
Fix RegisterDialog tab order and detail lengths
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/changeemaildialog.cpp | 15 | ||||
-rw-r--r-- | src/gui/changepassworddialog.cpp | 16 | ||||
-rw-r--r-- | src/gui/register.cpp | 44 | ||||
-rw-r--r-- | src/gui/unregisterdialog.cpp | 14 |
4 files changed, 56 insertions, 33 deletions
diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp index f536bd4f..32e10e98 100644 --- a/src/gui/changeemaildialog.cpp +++ b/src/gui/changeemaildialog.cpp @@ -32,6 +32,8 @@ #include "gui/widgets/textfield.h" #include "net/logindata.h" +#include "net/loginhandler.h" +#include "net/net.h" #include "utils/gettext.h" #include "utils/stringutils.h" @@ -116,20 +118,21 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event) std::stringstream errorMessage; int error = 0; - if (newFirstEmail.length() < LEN_MIN_PASSWORD) + unsigned int min = Net::getLoginHandler()->getMinPasswordLength(); + unsigned int max = Net::getLoginHandler()->getMaxPasswordLength(); + + if (newFirstEmail.length() < min) { // First email address too short errorMessage << strprintf(_("The new email address needs to be at " - "least %d characters long."), - LEN_MIN_PASSWORD); + "least %d characters long."), min); error = 1; } - else if (newFirstEmail.length() > LEN_MAX_PASSWORD - 1 ) + else if (newFirstEmail.length() > max - 1 ) { // First email address too long errorMessage << strprintf(_("The new email address needs to be " - "less than %d characters long."), - LEN_MAX_PASSWORD); + "less than %d characters long."), max); error = 1; } else if (newFirstEmail != newSecondEmail) diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp index 0ad9071a..c79db7e9 100644 --- a/src/gui/changepassworddialog.cpp +++ b/src/gui/changepassworddialog.cpp @@ -34,6 +34,8 @@ #include "gui/widgets/layout.h" #include "net/logindata.h" +#include "net/loginhandler.h" +#include "net/net.h" #include "utils/gettext.h" #include "utils/stringutils.h" @@ -98,6 +100,9 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event) std::stringstream errorMessage; int error = 0; + unsigned int min = Net::getLoginHandler()->getMinPasswordLength(); + unsigned int max = Net::getLoginHandler()->getMaxPasswordLength(); + // Check old Password if (oldPassword.empty()) { @@ -105,19 +110,18 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event) errorMessage << _("Enter the old password first."); error = 1; } - else if (newFirstPass.length() < LEN_MIN_PASSWORD) + else if (newFirstPass.length() < min) { // First password too short - errorMessage << strprintf(_("The new password needs to be at least " - "%d characters long."), LEN_MIN_PASSWORD); + errorMessage << strprintf(_("The new password needs to be at least" + " %d characters long."), min); error = 2; } - else if (newFirstPass.length() > LEN_MAX_PASSWORD - 1 ) + else if (newFirstPass.length() > max - 1 ) { // First password too long errorMessage << strprintf(_("The new password needs to be less " - "than %d characters long."), - LEN_MAX_PASSWORD); + "than %d characters long."), max); error = 2; } else if (newFirstPass != newSecondPass) diff --git a/src/gui/register.cpp b/src/gui/register.cpp index 5d9469ca..0ce716bb 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -37,8 +37,8 @@ #include "gui/widgets/textfield.h" #include "net/logindata.h" -#include "net/net.h" #include "net/loginhandler.h" +#include "net/net.h" #include "utils/gettext.h" #include "utils/stringutils.h" @@ -79,25 +79,32 @@ RegisterDialog::RegisterDialog(LoginData *loginData): place(0, 1, passwordLabel); place(0, 2, confirmLabel); + place(1, 0, mUserField, 3).setPadding(2); + place(1, 1, mPasswordField, 3).setPadding(2); + place(1, 2, mConfirmField, 3).setPadding(2); + + int row = 3; + if (optionalActions & Net::LoginHandler::SetGenderOnRegister) { mMaleButton = new RadioButton(_("Male"), "sex", true); mFemaleButton = new RadioButton(_("Female"), "sex", false); - place(1, 3, mMaleButton); - place(2, 3, mFemaleButton); + place(1, row, mMaleButton); + place(2, row, mFemaleButton); + + row++; } if (optionalActions & Net::LoginHandler::SetEmailOnRegister) { gcn::Label *emailLabel = new Label(_("Email:")); mEmailField = new TextField; - place(0, 3, emailLabel); - place(1, 3, mEmailField, 3).setPadding(2); + place(0, row, emailLabel); + place(1, row, mEmailField, 3).setPadding(2); + + row++; } - place(1, 0, mUserField, 3).setPadding(2); - place(1, 1, mPasswordField, 3).setPadding(2); - place(1, 2, mConfirmField, 3).setPadding(2); place = getPlacer(0, 2); place(1, 0, mRegisterButton); place(2, 0, mCancelButton); @@ -147,36 +154,41 @@ void RegisterDialog::action(const gcn::ActionEvent &event) std::string errorMessage; int error = 0; - if (user.length() < LEN_MIN_USERNAME) + unsigned int minUser = Net::getLoginHandler()->getMinUserNameLength(); + unsigned int maxUser = Net::getLoginHandler()->getMaxUserNameLength(); + unsigned int minPass = Net::getLoginHandler()->getMinPasswordLength(); + unsigned int maxPass = Net::getLoginHandler()->getMaxPasswordLength(); + + if (user.length() < minUser) { // Name too short errorMessage = strprintf (_("The username needs to be at least %d characters long."), - LEN_MIN_USERNAME); + minUser); error = 1; } - else if (user.length() > LEN_MAX_USERNAME - 1 ) + else if (user.length() > maxUser - 1 ) { // Name too long errorMessage = strprintf (_("The username needs to be less than %d characters long."), - LEN_MAX_USERNAME); + maxUser); error = 1; } - else if (mPasswordField->getText().length() < LEN_MIN_PASSWORD) + else if (mPasswordField->getText().length() < minPass) { // Pass too short errorMessage = strprintf (_("The password needs to be at least %d characters long."), - LEN_MIN_PASSWORD); + minPass); error = 2; } - else if (mPasswordField->getText().length() > LEN_MAX_PASSWORD - 1 ) + else if (mPasswordField->getText().length() > maxPass - 1 ) { // Pass too long errorMessage = strprintf (_("The password needs to be less than %d characters long."), - LEN_MAX_PASSWORD); + maxPass); error = 2; } else if (mPasswordField->getText() != mConfirmField->getText()) diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp index 0dfc8df9..a5e96532 100644 --- a/src/gui/unregisterdialog.cpp +++ b/src/gui/unregisterdialog.cpp @@ -34,6 +34,8 @@ #include "gui/widgets/textfield.h" #include "net/logindata.h" +#include "net/loginhandler.h" +#include "net/net.h" #include "utils/gettext.h" #include "utils/stringutils.h" @@ -106,20 +108,22 @@ UnRegisterDialog::action(const gcn::ActionEvent &event) std::stringstream errorMessage; bool error = false; + unsigned int min = Net::getLoginHandler()->getMinPasswordLength(); + unsigned int max = Net::getLoginHandler()->getMaxPasswordLength(); + // Check password - if (password.length() < LEN_MIN_PASSWORD) + if (password.length() < min) { // Pass too short errorMessage << strprintf(_("The password needs to be at least %d " - "characters long."), LEN_MIN_PASSWORD); + "characters long."), min); error = true; } - else if (password.length() > LEN_MAX_PASSWORD - 1) + else if (password.length() > max - 1) { // Pass too long errorMessage << strprintf(_("The password needs to be less than " - "%d characters long."), - LEN_MAX_PASSWORD); + "%d characters long."), max); error = true; } |