remember username during guest login
This commit is contained in:
@@ -50,7 +50,7 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
|
|||||||
myConfigState = OK;
|
myConfigState = OK;
|
||||||
|
|
||||||
// !!!! Revisionsnummer der Configdefaults !!!!!
|
// !!!! Revisionsnummer der Configdefaults !!!!!
|
||||||
configRev = 86;
|
configRev = 87;
|
||||||
|
|
||||||
//standard defaults
|
//standard defaults
|
||||||
logOnOffDefault = "1";
|
logOnOffDefault = "1";
|
||||||
@@ -237,6 +237,7 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
|
|||||||
configList.push_back(ConfigInfo("ChatCleanerUseIpv6", CONFIG_TYPE_INT, "0"));
|
configList.push_back(ConfigInfo("ChatCleanerUseIpv6", CONFIG_TYPE_INT, "0"));
|
||||||
configList.push_back(ConfigInfo("MyName", CONFIG_TYPE_STRING, "Human Player"));
|
configList.push_back(ConfigInfo("MyName", CONFIG_TYPE_STRING, "Human Player"));
|
||||||
configList.push_back(ConfigInfo("MyAvatar", CONFIG_TYPE_STRING, ""));
|
configList.push_back(ConfigInfo("MyAvatar", CONFIG_TYPE_STRING, ""));
|
||||||
|
configList.push_back(ConfigInfo("MyRememberedNameDuringGuestLogin", CONFIG_TYPE_STRING, ""));
|
||||||
configList.push_back(ConfigInfo("Opponent1Name", CONFIG_TYPE_STRING, "Player 1"));
|
configList.push_back(ConfigInfo("Opponent1Name", CONFIG_TYPE_STRING, "Player 1"));
|
||||||
configList.push_back(ConfigInfo("Opponent1Avatar", CONFIG_TYPE_STRING, ""));
|
configList.push_back(ConfigInfo("Opponent1Avatar", CONFIG_TYPE_STRING, ""));
|
||||||
configList.push_back(ConfigInfo("Opponent2Name", CONFIG_TYPE_STRING, "Player 2"));
|
configList.push_back(ConfigInfo("Opponent2Name", CONFIG_TYPE_STRING, "Player 2"));
|
||||||
|
|||||||
@@ -4,114 +4,123 @@
|
|||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
|
|
||||||
internetGameLoginDialogImpl::internetGameLoginDialogImpl(QWidget *parent, ConfigFile *c) :
|
internetGameLoginDialogImpl::internetGameLoginDialogImpl(QWidget *parent, ConfigFile *c) :
|
||||||
QDialog(parent), myConfig(c){
|
QDialog(parent), myConfig(c){
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
connect(groupBox_reguser, SIGNAL(toggled(bool)), this, SLOT(regUserToggled(bool)));
|
connect(groupBox_reguser, SIGNAL(toggled(bool)), this, SLOT(regUserToggled(bool)));
|
||||||
connect(checkBox_guest, SIGNAL(toggled(bool)), this, SLOT(guestUserToggled(bool)));
|
connect(checkBox_guest, SIGNAL(toggled(bool)), this, SLOT(guestUserToggled(bool)));
|
||||||
connect(lineEdit_password, SIGNAL(textEdited(QString)), this, SLOT(okButtonCheck()));
|
connect(lineEdit_password, SIGNAL(textEdited(QString)), this, SLOT(okButtonCheck()));
|
||||||
connect(lineEdit_username, SIGNAL(textEdited(QString)), this, SLOT(okButtonCheck()));
|
connect(lineEdit_username, SIGNAL(textEdited(QString)), this, SLOT(okButtonCheck()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void internetGameLoginDialogImpl::regUserToggled(bool b) {
|
void internetGameLoginDialogImpl::regUserToggled(bool b) {
|
||||||
|
|
||||||
checkBox_guest->setChecked(!b);
|
|
||||||
|
|
||||||
if(b) {
|
checkBox_guest->setChecked(!b);
|
||||||
|
|
||||||
|
if(b) {
|
||||||
|
if(QString::fromUtf8(myConfig->readConfigString("MyRememberedNameDuringGuestLogin").c_str()).isEmpty()) {
|
||||||
lineEdit_username->setText(QString::fromUtf8(myConfig->readConfigString("MyName").c_str()));
|
lineEdit_username->setText(QString::fromUtf8(myConfig->readConfigString("MyName").c_str()));
|
||||||
if(myConfig->readConfigInt("InternetSavePassword")) {
|
|
||||||
checkBox_rememberPassword->setChecked(true);
|
|
||||||
lineEdit_password->setText(QString::fromUtf8(QByteArray::fromBase64(myConfig->readConfigString("InternetLoginPassword").c_str())));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
checkBox_rememberPassword->setChecked(false);
|
|
||||||
lineEdit_password->clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
lineEdit_username->setText(QString::fromUtf8(myConfig->readConfigString("MyRememberedNameDuringGuestLogin").c_str()));
|
||||||
|
}
|
||||||
|
if(myConfig->readConfigInt("InternetSavePassword")) {
|
||||||
|
checkBox_rememberPassword->setChecked(true);
|
||||||
|
lineEdit_password->setText(QString::fromUtf8(QByteArray::fromBase64(myConfig->readConfigString("InternetLoginPassword").c_str())));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
checkBox_rememberPassword->setChecked(false);
|
||||||
|
lineEdit_password->clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
okButtonCheck();
|
okButtonCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
void internetGameLoginDialogImpl::guestUserToggled(bool b) {
|
void internetGameLoginDialogImpl::guestUserToggled(bool b) {
|
||||||
|
|
||||||
groupBox_reguser->setChecked(!b);
|
groupBox_reguser->setChecked(!b);
|
||||||
|
|
||||||
if(b) {
|
|
||||||
checkBox_rememberPassword->setChecked(false);
|
|
||||||
lineEdit_password->clear();
|
|
||||||
lineEdit_username->clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
okButtonCheck();
|
if(b) {
|
||||||
|
myConfig->writeConfigString("MyRememberedNameDuringGuestLogin", lineEdit_username->text().toUtf8().constData());
|
||||||
|
checkBox_rememberPassword->setChecked(false);
|
||||||
|
lineEdit_password->clear();
|
||||||
|
lineEdit_username->clear();
|
||||||
|
|
||||||
|
myConfig->writeBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
okButtonCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
void internetGameLoginDialogImpl::exec() {
|
void internetGameLoginDialogImpl::exec() {
|
||||||
|
|
||||||
if(myConfig->readConfigInt("InternetLoginMode") == 0) {
|
if(myConfig->readConfigInt("InternetLoginMode") == 0) {
|
||||||
groupBox_reguser->setChecked(true);
|
groupBox_reguser->setChecked(true);
|
||||||
lineEdit_username->setText(QString::fromUtf8(myConfig->readConfigString("MyName").c_str()));
|
lineEdit_username->setText(QString::fromUtf8(myConfig->readConfigString("MyName").c_str()));
|
||||||
if(myConfig->readConfigInt("InternetSavePassword")) {
|
if(myConfig->readConfigInt("InternetSavePassword")) {
|
||||||
checkBox_rememberPassword->setChecked(true);
|
checkBox_rememberPassword->setChecked(true);
|
||||||
lineEdit_password->setText(QString::fromUtf8(QByteArray::fromBase64(myConfig->readConfigString("InternetLoginPassword").c_str())));
|
lineEdit_password->setText(QString::fromUtf8(QByteArray::fromBase64(myConfig->readConfigString("InternetLoginPassword").c_str())));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
checkBox_rememberPassword->setChecked(false);
|
checkBox_rememberPassword->setChecked(false);
|
||||||
lineEdit_password->clear();
|
lineEdit_password->clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
checkBox_guest->setChecked(true);
|
checkBox_guest->setChecked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
okButtonCheck();
|
okButtonCheck();
|
||||||
|
|
||||||
if(groupBox_reguser->isChecked() && !checkBox_rememberPassword->isChecked() && lineEdit_password->text().isEmpty()) {
|
if(groupBox_reguser->isChecked() && !checkBox_rememberPassword->isChecked() && lineEdit_password->text().isEmpty()) {
|
||||||
lineEdit_password->setFocus();
|
lineEdit_password->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
QDialog::exec();
|
QDialog::exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void internetGameLoginDialogImpl::accept() {
|
void internetGameLoginDialogImpl::accept() {
|
||||||
|
|
||||||
if(groupBox_reguser->isChecked()) {
|
if(groupBox_reguser->isChecked()) {
|
||||||
myConfig->writeConfigInt("InternetLoginMode", 0);
|
myConfig->writeConfigInt("InternetLoginMode", 0);
|
||||||
myConfig->writeConfigString("MyName", lineEdit_username->text().toUtf8().constData());
|
myConfig->writeConfigString("MyName", lineEdit_username->text().toUtf8().constData());
|
||||||
if(checkBox_rememberPassword->isChecked()) {
|
if(checkBox_rememberPassword->isChecked()) {
|
||||||
myConfig->writeConfigInt("InternetSavePassword", 1);
|
myConfig->writeConfigInt("InternetSavePassword", 1);
|
||||||
myConfig->writeConfigString("InternetLoginPassword", lineEdit_password->text().toUtf8().toBase64().constData());
|
myConfig->writeConfigString("InternetLoginPassword", lineEdit_password->text().toUtf8().toBase64().constData());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
myConfig->writeConfigInt("InternetSavePassword", 0);
|
myConfig->writeConfigInt("InternetSavePassword", 0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if(checkBox_guest->isChecked()) {
|
}
|
||||||
myConfig->writeConfigInt("InternetLoginMode", 1);
|
else if(checkBox_guest->isChecked()) {
|
||||||
// Generate a valid guest name.
|
myConfig->writeConfigInt("InternetLoginMode", 1);
|
||||||
QString guestName;
|
// Generate a valid guest name.
|
||||||
int guestId;
|
QString guestName;
|
||||||
Tools::getRandNumber(1, 99999, 1, &guestId, false);
|
int guestId;
|
||||||
guestName.sprintf("Guest%05d", guestId);
|
Tools::getRandNumber(1, 99999, 1, &guestId, false);
|
||||||
myConfig->writeConfigString("MyName", guestName.toUtf8().constData());
|
guestName.sprintf("Guest%05d", guestId);
|
||||||
}
|
myConfig->writeConfigString("MyName", guestName.toUtf8().constData());
|
||||||
|
}
|
||||||
myConfig->writeBuffer();
|
|
||||||
|
myConfig->writeBuffer();
|
||||||
QDialog::accept();
|
|
||||||
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void internetGameLoginDialogImpl::okButtonCheck() {
|
void internetGameLoginDialogImpl::okButtonCheck() {
|
||||||
|
|
||||||
if(groupBox_reguser->isChecked()) {
|
if(groupBox_reguser->isChecked()) {
|
||||||
if(!lineEdit_password->text().isEmpty() && !lineEdit_username->text().isEmpty()) {
|
if(!lineEdit_password->text().isEmpty() && !lineEdit_username->text().isEmpty()) {
|
||||||
pushButton_login->setEnabled(true);
|
pushButton_login->setEnabled(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pushButton_login->setEnabled(false);
|
pushButton_login->setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pushButton_login->setEnabled(true);
|
pushButton_login->setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user