# HG changeset patch # User koda # Date 1335112714 -7200 # Node ID 1cda333286e059c7d2de3ffa6944a661e682b80c # Parent ea058558c68bb029326cd8e8bfad37a2ef2589c9 added savepassword checkbox to options page, which now reloads values at every acces diff -r ea058558c68b -r 1cda333286e0 QTfrontend/gameuiconfig.cpp --- a/QTfrontend/gameuiconfig.cpp Sun Apr 22 17:03:55 2012 +0200 +++ b/QTfrontend/gameuiconfig.cpp Sun Apr 22 18:38:34 2012 +0200 @@ -41,6 +41,11 @@ //Form->resize(value("frontend/width", 640).toUInt(), value("frontend/height", 450).toUInt()); resizeToConfigValues(); + reloadValues(); +} + +void GameUIConfig::reloadValues(void) +{ Form->ui.pageOptions->WeaponTooltip->setChecked(value("misc/weaponTooltips", true).toBool()); int t = Form->ui.pageOptions->CBResolution->findText(value("video/resolution").toString()); @@ -68,11 +73,18 @@ QString netNick = value("net/nick", "").toString(); Form->ui.pageOptions->editNetNick->setText(netNick); + bool savePwd = value("net/savepassword",true).toBool(); + Form->ui.pageOptions->CBSavePassword->setChecked(savePwd); Form->ui.pageOptions->editNetPassword->installEventFilter(this); int passLength = value("net/passwordlength", 0).toInt(); setNetPasswordLength(passLength); + if (savePwd == false) { + Form->ui.pageOptions->editNetPassword->setEnabled(savePwd); + Form->ui.pageOptions->editNetPassword->setText(""); + setNetPasswordLength(0); + } delete netHost; netHost = new QString(value("net/ip", "").toString()); @@ -149,11 +161,12 @@ setValue("audio/volume", Form->ui.pageOptions->volumeBox->value()); setValue("net/nick", netNick()); - if (netPasswordIsValid()) + if (netPasswordIsValid() && Form->ui.pageOptions->CBSavePassword->isChecked()) { setValue("net/passwordhash", netPasswordHash()); setValue("net/passwordlength", netPasswordLength()); } + setValue("net/savepassword", Form->ui.pageOptions->CBSavePassword->isChecked()); setValue("net/ip", *netHost); setValue("net/port", netPort); setValue("net/servername", Form->ui.pageNetServer->leServerDescr->text()); diff -r ea058558c68b -r 1cda333286e0 QTfrontend/gameuiconfig.h --- a/QTfrontend/gameuiconfig.h Sun Apr 22 17:03:55 2012 +0200 +++ b/QTfrontend/gameuiconfig.h Sun Apr 22 18:38:34 2012 +0200 @@ -64,6 +64,7 @@ bool isAutoUpdateEnabled(); #endif #endif + void reloadValues(void); signals: void frontendFullscreen(bool value); diff -r ea058558c68b -r 1cda333286e0 QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Sun Apr 22 17:03:55 2012 +0200 +++ b/QTfrontend/hwform.cpp Sun Apr 22 18:38:34 2012 +0200 @@ -593,6 +593,11 @@ ui.pageOptions->setTeamOptionsEnabled(true); } + if (id == ID_PAGE_SETUP) + { + config->reloadValues(); + } + // load and save ignore/friends lists if (lastid == ID_PAGE_NETGAME) // leaving a room ui.pageNetGame->pChatWidget->saveLists(ui.pageOptions->editNetNick->text()); diff -r ea058558c68b -r 1cda333286e0 QTfrontend/ui/page/pageoptions.cpp --- a/QTfrontend/ui/page/pageoptions.cpp Sun Apr 22 17:03:55 2012 +0200 +++ b/QTfrontend/ui/page/pageoptions.cpp Sun Apr 22 18:38:34 2012 +0200 @@ -187,28 +187,12 @@ groupMisc->setTitle(QGroupBox::tr("Misc")); QGridLayout * MiscLayout = new QGridLayout(groupMisc); - labelNN = new QLabel(groupMisc); - labelNN->setText(QLabel::tr("Net nick")); - MiscLayout->addWidget(labelNN, 0, 0); - - editNetNick = new QLineEdit(groupMisc); - editNetNick->setMaxLength(20); - editNetNick->setText(QLineEdit::tr("unnamed")); - connect(editNetNick, SIGNAL(editingFinished()), this, SLOT(trimNetNick())); - MiscLayout->addWidget(editNetNick, 0, 1); - - labelNetPassword = new QLabel(groupMisc); - labelNetPassword->setText(QLabel::tr("Password")); - MiscLayout->addWidget(labelNetPassword, 1, 0); - - editNetPassword = new QLineEdit(groupMisc); - editNetPassword->setEchoMode(QLineEdit::Password); - MiscLayout->addWidget(editNetPassword, 1, 1); - + // Label for "Language" QLabel *labelLanguage = new QLabel(groupMisc); labelLanguage->setText(QLabel::tr("Locale") + " *"); - MiscLayout->addWidget(labelLanguage, 2, 0); + MiscLayout->addWidget(labelLanguage, 0, 0); + // List of installed languages CBLanguage = new QComboBox(groupMisc); QDir tmpdir; tmpdir.cd(cfgdir->absolutePath()); @@ -233,26 +217,49 @@ CBLanguage->addItem(QLocale::languageToString(loc.language()) + " (" + QLocale::countryToString(loc.country()) + ")", loc.name()); } - MiscLayout->addWidget(CBLanguage, 2, 1); + MiscLayout->addWidget(CBLanguage, 0, 1); + + // Label and field for net nick + labelNN = new QLabel(groupMisc); + labelNN->setText(QLabel::tr("Nickname")); + MiscLayout->addWidget(labelNN, 1, 0); + + editNetNick = new QLineEdit(groupMisc); + editNetNick->setMaxLength(20); + editNetNick->setText(QLineEdit::tr("anonymous")); + MiscLayout->addWidget(editNetNick, 1, 1); + + // Label and field for password + labelNetPassword = new QLabel(groupMisc); + labelNetPassword->setText(QLabel::tr("Password")); + MiscLayout->addWidget(labelNetPassword, 2, 0); + + editNetPassword = new QLineEdit(groupMisc); + editNetPassword->setEchoMode(QLineEdit::Password); + MiscLayout->addWidget(editNetPassword, 2, 1); + + CBSavePassword = new QCheckBox(groupMisc); + CBSavePassword->setText(QCheckBox::tr("Save password")); + MiscLayout->addWidget(CBSavePassword, 3, 0, 1, 2); CBAltDamage = new QCheckBox(groupMisc); CBAltDamage->setText(QCheckBox::tr("Alternative damage show")); - MiscLayout->addWidget(CBAltDamage, 3, 0, 1, 2); + MiscLayout->addWidget(CBAltDamage, 4, 0, 1, 2); CBNameWithDate = new QCheckBox(groupMisc); CBNameWithDate->setText(QCheckBox::tr("Append date and time to record file name")); - MiscLayout->addWidget(CBNameWithDate, 4, 0, 1, 2); + MiscLayout->addWidget(CBNameWithDate, 5, 0, 1, 2); BtnAssociateFiles = new QPushButton(groupMisc); BtnAssociateFiles->setText(QPushButton::tr("Associate file extensions")); BtnAssociateFiles->setEnabled(!custom_data && !custom_config); - MiscLayout->addWidget(BtnAssociateFiles, 5, 0, 1, 2); + MiscLayout->addWidget(BtnAssociateFiles, 6, 0, 1, 2); #ifdef __APPLE__ #ifdef SPARKLE_ENABLED CBAutoUpdate = new QCheckBox(groupMisc); CBAutoUpdate->setText(QCheckBox::tr("Check for updates at startup")); - MiscLayout->addWidget(CBAutoUpdate, 6, 0, 1, 3); + MiscLayout->addWidget(CBAutoUpdate, 7, 0, 1, 3); #endif #endif gbTBLayout->addWidget(groupMisc, 2, 0); @@ -338,7 +345,6 @@ CBStereoMode->addItem(QComboBox::tr("Blue/Red grayscale")); CBStereoMode->addItem(QComboBox::tr("Red/Green grayscale")); CBStereoMode->addItem(QComboBox::tr("Green/Red grayscale")); - connect(CBStereoMode, SIGNAL(currentIndexChanged(int)), this, SLOT(forceFullscreen(int))); GBAstereolayout->addWidget(CBStereoMode); GBAlayout->addLayout(GBAstereolayout); @@ -402,9 +408,12 @@ void PageOptions::connectSignals() { + connect(SLQuality, SIGNAL(valueChanged(int)), this, SLOT(setQuality(int))); connect(CBResolution, SIGNAL(currentIndexChanged(int)), this, SLOT(setResolution(int))); connect(CBFullscreen, SIGNAL(stateChanged(int)), this, SLOT(setFullscreen(int))); - connect(SLQuality, SIGNAL(valueChanged(int)), this, SLOT(setQuality(int))); + connect(CBStereoMode, SIGNAL(currentIndexChanged(int)), this, SLOT(forceFullscreen(int))); + connect(editNetNick, SIGNAL(editingFinished()), this, SLOT(trimNetNick())); + connect(CBSavePassword, SIGNAL(stateChanged(int)), this, SLOT(savePwdChanged(int))); } PageOptions::PageOptions(QWidget* parent) : AbstractPage(parent) @@ -466,6 +475,14 @@ editNetNick->setText(editNetNick->text().trimmed()); } +void PageOptions::savePwdChanged(int state) { + if (state == 0) { + editNetPassword->setEnabled(false); + editNetPassword->setText(""); + } else + editNetPassword->setEnabled(true); +} + void PageOptions::requestEditSelectedTeam() { emit editTeamRequested(CBTeamName->currentText()); diff -r ea058558c68b -r 1cda333286e0 QTfrontend/ui/page/pageoptions.h --- a/QTfrontend/ui/page/pageoptions.h Sun Apr 22 17:03:55 2012 +0200 +++ b/QTfrontend/ui/page/pageoptions.h Sun Apr 22 18:38:34 2012 +0200 @@ -56,6 +56,7 @@ QCheckBox *CBFullscreen; QCheckBox *CBFrontendFullscreen; QCheckBox *CBShowFPS; + QCheckBox *CBSavePassword; QCheckBox *CBAltDamage; QCheckBox *CBNameWithDate; #ifdef __APPLE__ @@ -100,6 +101,7 @@ void trimNetNick(); void requestEditSelectedTeam(); void requestDeleteSelectedTeam(); + void savePwdChanged(int state); }; #endif