QTfrontend/gameuiconfig.cpp
changeset 8294 0e5782b0dd54
parent 8291 e4a0d980d1e2
child 8295 6ef114ea2298
equal deleted inserted replaced
8293:fae7a18afe03 8294:0e5782b0dd54
   235     setValue("net/nick", netNick());
   235     setValue("net/nick", netNick());
   236     if ((netPasswordLength()==0)) {
   236     if ((netPasswordLength()==0)) {
   237 	setValue("net/passwordhash", "");
   237 	setValue("net/passwordhash", "");
   238         setValue("net/passwordlength", 0);
   238         setValue("net/passwordlength", 0);
   239     }
   239     }
   240     else if (netPasswordIsValid() && Form->ui.pageOptions->CBSavePassword->isChecked())
   240     else if (netPasswordIsValid() && Form->ui.pageOptions->CBSavePassword->isChecked()) {
   241     {
   241 	setValue("net/passwordhash", "");
   242         setValue("net/passwordhash", netPasswordHash());
   242 	setValue("net/passwordlength", 0);
   243         setValue("net/passwordlength", netPasswordLength());
       
   244     }
   243     }
   245 
   244 
   246     setValue("net/savepassword", Form->ui.pageOptions->CBSavePassword->isChecked());
   245     setValue("net/savepassword", Form->ui.pageOptions->CBSavePassword->isChecked());
   247     setValue("net/ip", *netHost);
   246     setValue("net/ip", *netHost);
   248     setValue("net/port", netPort);
   247     setValue("net/port", netPort);
   480 bool GameUIConfig::netPasswordIsValid()
   479 bool GameUIConfig::netPasswordIsValid()
   481 {
   480 {
   482     return (netPasswordLength() == 0 || Form->ui.pageOptions->editNetPassword->text() != QString(netPasswordLength(), '*'));
   481     return (netPasswordLength() == 0 || Form->ui.pageOptions->editNetPassword->text() != QString(netPasswordLength(), '*'));
   483 }
   482 }
   484 
   483 
       
   484 void GameUIConfig::clearPasswordHash() 
       
   485 {
       
   486     setValue("net/passwordhash", QString());
       
   487     setValue("net/passwordlength", 0);
       
   488 }
       
   489 
       
   490 void GameUIConfig::setPasswordHash(const QString & passwordhash)
       
   491 {
       
   492     setValue("net/passwordhash", passwordhash);
       
   493     setValue("net/passwordlength", passwordhash.size());
       
   494     netPasswordLength();
       
   495 }
       
   496 
       
   497 QString GameUIConfig::passwordHash()
       
   498 {
       
   499     return value("net/passwordhash").toString();
       
   500 }
       
   501 
       
   502 void GameUIConfig::clearTempHash() 
       
   503 {
       
   504     setTempHash(QString());
       
   505 }
       
   506 
       
   507 void GameUIConfig::setTempHash(const QString & temphash)
       
   508 {
       
   509     this->temphash = temphash;
       
   510 }
       
   511 
       
   512 QString GameUIConfig::tempHash() {
       
   513     return this->temphash;
       
   514 }
       
   515 
   485 // When hedgewars launches, the password field is set with null characters. If the user tries to edit the field and there are such characters, then clear the field
   516 // When hedgewars launches, the password field is set with null characters. If the user tries to edit the field and there are such characters, then clear the field
   486 bool GameUIConfig::eventFilter(QObject *object, QEvent *event)
   517 bool GameUIConfig::eventFilter(QObject *object, QEvent *event)
   487 {
   518 {
   488     if (event->type() == QEvent::FocusIn)
   519     if (event->type() == QEvent::FocusIn)
   489     {
   520     {