QTfrontend/gameuiconfig.cpp
changeset 14761 7b2bd37d7503
parent 14698 93429d8f6b3f
child 14982 575dbd7b5f43
equal deleted inserted replaced
14760:5d5d7db9f417 14761:7b2bd37d7503
   113     Form->ui.pageOptions->CBMusic->setChecked(value("audio/music", true).toBool());
   113     Form->ui.pageOptions->CBMusic->setChecked(value("audio/music", true).toBool());
   114     Form->ui.pageOptions->CBFrontendMusic->setChecked(value("frontend/music", true).toBool());
   114     Form->ui.pageOptions->CBFrontendMusic->setChecked(value("frontend/music", true).toBool());
   115     Form->ui.pageOptions->CBDampenAudio->setChecked(value("audio/dampen", true).toBool());
   115     Form->ui.pageOptions->CBDampenAudio->setChecked(value("audio/dampen", true).toBool());
   116     Form->ui.pageOptions->SLVolume->setValue(value("audio/volume", 100).toUInt());
   116     Form->ui.pageOptions->SLVolume->setValue(value("audio/volume", 100).toUInt());
   117 
   117 
   118     QString netNick = value("net/nick", tr("Guest")+QString("%1").arg(rand())).toString();
   118     QString netNick = value("net/nick", getRandomNick()).toString();
   119     Form->ui.pageOptions->editNetNick->setText(netNick);
   119     Form->ui.pageOptions->editNetNick->setText(netNick);
   120     bool savePwd = value("net/savepassword",true).toBool();
   120     bool savePwd = value("net/savepassword",true).toBool();
   121     Form->ui.pageOptions->CBSavePassword->setChecked(savePwd);
   121     Form->ui.pageOptions->CBSavePassword->setChecked(savePwd);
   122 
   122 
   123     Form->ui.pageOptions->editNetPassword->installEventFilter(this);
   123     Form->ui.pageOptions->editNetPassword->installEventFilter(this);
   515 void GameUIConfig::updNetNick()
   515 void GameUIConfig::updNetNick()
   516 {
   516 {
   517     Form->ui.pageOptions->editNetNick->setText(value("net/nick", "").toString());
   517     Form->ui.pageOptions->editNetNick->setText(value("net/nick", "").toString());
   518 }
   518 }
   519 
   519 
       
   520 QString GameUIConfig::getRandomNick()
       
   521 {
       
   522     // Generate random nick name or pick old one if one was already generated.
       
   523     QString nick;
       
   524     if (cachedRandomNick.isNull())
       
   525         // "Guest" + number between 1 and 99999
       
   526         cachedRandomNick = tr("Guest") + QString("%1").arg(rand() % 99999 + 1);
       
   527     return cachedRandomNick;
       
   528 }
       
   529 
   520 QByteArray GameUIConfig::netPasswordHash()
   530 QByteArray GameUIConfig::netPasswordHash()
   521 {
   531 {
   522     return QCryptographicHash::hash(Form->ui.pageOptions->editNetPassword->text().toUtf8(), QCryptographicHash::Md5).toHex();
   532     return QCryptographicHash::hash(Form->ui.pageOptions->editNetPassword->text().toUtf8(), QCryptographicHash::Md5).toHex();
   523 }
   533 }
   524 
   534