diff options
author | Ira Rice <irarice@gmail.com> | 2009-03-10 08:29:49 -0600 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2009-03-10 08:29:49 -0600 |
commit | 67ea3716f8b01484527ead747c0cc6af3ac0cd76 (patch) | |
tree | 2d9656ab21c09fe0bd6562c8cb9e73ed57205643 /src/gui/login.cpp | |
parent | 443a10db52e909c4c2a33543795ec8837547e973 (diff) | |
download | mana-67ea3716f8b01484527ead747c0cc6af3ac0cd76.tar.gz mana-67ea3716f8b01484527ead747c0cc6af3ac0cd76.tar.bz2 mana-67ea3716f8b01484527ead747c0cc6af3ac0cd76.tar.xz mana-67ea3716f8b01484527ead747c0cc6af3ac0cd76.zip |
Moved enforcement of minimum widths and heights to the Window class.
This was needed in the Minimap class, but not migrated out to the Window
class until now.
Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/gui/login.cpp')
-rw-r--r-- | src/gui/login.cpp | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/src/gui/login.cpp b/src/gui/login.cpp index cd331322..ce13aaf0 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -117,11 +117,10 @@ LoginDialog::LoginDialog(LoginData *loginData): setLocationRelativeTo(getParent()); setVisible(true); - if (mUserField->getText().empty()) { + if (mUserField->getText().empty()) mUserField->requestFocus(); - } else { + else mPassField->requestFocus(); - } mOkButton->setEnabled(canSubmit()); } @@ -156,14 +155,12 @@ void LoginDialog::action(const gcn::ActionEvent &event) { // Transfer these fields on to the register dialog mLoginData->hostname = mServerField->getText(); + if (isUShort(mPortField->getText())) - { mLoginData->port = getUShort(mPortField->getText()); - } else - { mLoginData->port = 6901; - } + mLoginData->username = mUserField->getText(); mLoginData->password = mPassField->getText(); @@ -196,14 +193,12 @@ bool LoginDialog::isUShort(const std::string &str) strPtr != strEnd; ++strPtr) { if (*strPtr < '0' || *strPtr > '9') - { return false; - } + l = l * 10 + (*strPtr - '0'); // *strPtr - '0' will never be negative + if (l > 65535) - { return false; - } } return true; } @@ -279,9 +274,7 @@ void LoginDialog::DropDownList::save(const std::string &server, ++sPtr, ++pPtr) { if (*sPtr != server || *pPtr != port) - { saveEntry(*sPtr, *pPtr, position); - } } } @@ -293,26 +286,23 @@ int LoginDialog::DropDownList::getNumberOfElements() std::string LoginDialog::DropDownList::getElementAt(int i) { if (i < 0 || i >= getNumberOfElements()) - { return ""; - } + return getServerAt(i) + ":" + getPortAt(i); } std::string LoginDialog::DropDownList::getServerAt(int i) { if (i < 0 || i >= getNumberOfElements()) - { return ""; - } + return mServers.at(i); } std::string LoginDialog::DropDownList::getPortAt(int i) { if (i < 0 || i >= getNumberOfElements()) - { return ""; - } + return mPorts.at(i); } |