Fixes password not actually saving when "save password" is checked in the HWPasswordDialog called by HWForm.
authordag10 <gottlieb.drew@gmail.com>
Sat, 19 Jan 2013 18:48:21 -0500
changeset 8407 686f2e716c97
parent 8406 8a834943609d
child 8408 286823b10f35
Fixes password not actually saving when "save password" is checked in the HWPasswordDialog called by HWForm. Added padding to QDialogButtonBox buttons. Fixed code indentation starting on hwform.cpp:1343.
QTfrontend/hwform.cpp
QTfrontend/res/css/qt.css
--- a/QTfrontend/hwform.cpp	Sat Jan 19 17:46:06 2013 -0500
+++ b/QTfrontend/hwform.cpp	Sat Jan 19 18:48:21 2013 -0500
@@ -1336,75 +1336,77 @@
     QString nickname = config->value("net/nick", "").toString();
     QString password;
 
-    if (nickname.isEmpty() || hash.isEmpty()) { //if something from login is missing, start dialog loop
-
+    //if something from login is missing, start dialog loop
+    if (nickname.isEmpty() || hash.isEmpty())
+    {
         while (nickname.isEmpty() || (hash.isEmpty() && temphash.isEmpty())) //while a nickname, or both hashes are missing
         {
-        //open dialog
+            //open dialog
             HWPasswordDialog * pwDialog = new HWPasswordDialog(this);
             // make the "new account" button dialog open a browser with the registration page
             connect(pwDialog->pbNewAccount, SIGNAL(clicked()), this, SLOT(openRegistrationPage()));
             pwDialog->cbSave->setChecked(config->value("net/savepassword", true).toBool());
 
-        //if nickname is present, put it into the field
-        if (!nickname.isEmpty()) {
-            pwDialog->leNickname->setText(nickname);
-            pwDialog->lePassword->setFocus();
-        }
+            //if nickname is present, put it into the field
+            if (!nickname.isEmpty()) {
+                pwDialog->leNickname->setText(nickname);
+                pwDialog->lePassword->setFocus();
+            }
+
+            //if dialog close, create an error message
+            if (pwDialog->exec() != QDialog::Accepted) {
+                delete pwDialog;
+                GoBack();
+                return;
+            }
+
+            //set nick and pass from the dialog
+            nickname = pwDialog->leNickname->text();
+            password = pwDialog->lePassword->text();
 
-        //if dialog close, create an error message
-        if (pwDialog->exec() != QDialog::Accepted) {
-            delete pwDialog;
-            GoBack();
-            return;
-        }
+            //check the nickname variable
+            if (nickname.isEmpty()) {
+                int retry = RetryDialog(tr("Hedgewars - Empty nickname"), tr("No nickname supplied."));
+                GoBack();
+                delete pwDialog;
+                if (retry) {
+                    NetConnectOfficialServer();
+                }
+                return;
+            }
+
+            if (!password.isEmpty()) {
+                //calculate temphash and set it into config
+                temphash = QCryptographicHash::hash(password.toUtf8(), QCryptographicHash::Md5).toHex();
+                config->setTempHash(temphash);
 
-        //set nick and pass from the dialog
-        nickname = pwDialog->leNickname->text();
-        password = pwDialog->lePassword->text();
+                //if user wants to save password
+                bool save = pwDialog->cbSave->isChecked();
+                config->setValue("net/savepassword", save);
+                if (save) // user wants to save password
+                {
+                    ui.pageOptions->CBSavePassword->setChecked(true);
+                    config->setPasswordHash(temphash);
+                }
+            }
+            else {
+                delete pwDialog;
+                config->setValue("net/nick", nickname);
+                config->updNetNick();
+                config->clearPasswordHash();
+                break;
+            }
 
-        //check the nickname variable
-        if (nickname.isEmpty()) {
-            int retry = RetryDialog(tr("Hedgewars - Empty nickname"), tr("No nickname supplied."));
-            GoBack();
             delete pwDialog;
-            if (retry) {
-                NetConnectOfficialServer();
-            }
-            return;
-        }
 
-        if (!password.isEmpty()) {
-            //calculate temphash and set it into config
-            temphash = QCryptographicHash::hash(password.toUtf8(), QCryptographicHash::Md5).toHex();
-            config->setTempHash(temphash);
-
-            //if user wants to save password
-            bool save = pwDialog->cbSave->isChecked();
-            config->setValue("net/savepassword", save);
-            if (save) // user wants to save password
-            {
-                config->setPasswordHash(temphash);
-            }
-        }
-        else {
-            delete pwDialog;
+            //update nickname
             config->setValue("net/nick", nickname);
             config->updNetNick();
-            config->clearPasswordHash();
-            break;
-        }
 
-        delete pwDialog;
-
-        //update nickname
-        config->setValue("net/nick", nickname);
-        config->updNetNick();
-
-        //and all the variables
-        hash = config->passwordHash();
-        temphash = config->tempHash();
-        nickname = config->value("net/nick", "").toString();
+            //and all the variables
+            hash = config->passwordHash();
+            temphash = config->tempHash();
+            nickname = config->value("net/nick", "").toString();
         }
     }
 
--- a/QTfrontend/res/css/qt.css	Sat Jan 19 17:46:06 2013 -0500
+++ b/QTfrontend/res/css/qt.css	Sat Jan 19 18:48:21 2013 -0500
@@ -309,4 +309,8 @@
 
 #hatList::item:selected {
 background-color: #150A61;
+}
+
+QDialogButtonBox QPushButton {
+padding: 3px 5px;
 }
\ No newline at end of file