(fix
issue #126) moved initial nickname popup to the netconnection page
--- a/QTfrontend/gameuiconfig.cpp Mon Jul 04 10:26:16 2011 +0400
+++ b/QTfrontend/gameuiconfig.cpp Mon Jul 04 12:28:58 2011 +0200
@@ -66,13 +66,6 @@
Form->ui.pageOptions->volumeBox->setValue(value("audio/volume", 100).toUInt());
QString netNick = value("net/nick", "").toString();
- if (netNick.isEmpty())
- netNick = QInputDialog::getText(Form,
- QObject::tr("Nickname"),
- QObject::tr("Please enter your nickname"),
- QLineEdit::Normal,
- QDir::home().dirName());
-
Form->ui.pageOptions->editNetNick->setText(netNick);
Form->ui.pageOptions->editNetPassword->installEventFilter(this);
@@ -314,6 +307,11 @@
return Form->ui.pageOptions->editNetNick->text();
}
+void GameUIConfig::updNetNick()
+{
+ Form->ui.pageOptions->editNetNick->setText(value("net/nick", "").toString());
+}
+
QByteArray GameUIConfig::netPasswordHash()
{
return QCryptographicHash::hash(Form->ui.pageOptions->editNetPassword->text().toLatin1(), QCryptographicHash::Md5).toHex();
--- a/QTfrontend/gameuiconfig.h Mon Jul 04 10:26:16 2011 +0400
+++ b/QTfrontend/gameuiconfig.h Mon Jul 04 12:28:58 2011 +0200
@@ -70,6 +70,7 @@
public slots:
void SaveOptions();
+ void updNetNick();
private:
bool netPasswordIsValid();
bool eventFilter(QObject *object, QEvent *event);
--- a/QTfrontend/newnetclient.cpp Mon Jul 04 10:26:16 2011 +0400
+++ b/QTfrontend/newnetclient.cpp Mon Jul 04 12:28:58 2011 +0200
@@ -70,7 +70,16 @@
void HWNewNet::Connect(const QString & hostName, quint16 port, const QString & nick)
{
- mynick = nick.isEmpty() ? QLineEdit::tr("unnamed") : nick;
+ mynick = nick;
+ while (mynick.isEmpty()) {
+ mynick = QInputDialog::getText(m_pGameCFGWidget,
+ QObject::tr("Nickname"),
+ QObject::tr("Please enter your nickname"),
+ QLineEdit::Normal,
+ QDir::home().dirName());
+ config->setValue("net/nick",mynick);
+ config->updNetNick();
+ }
myhost = hostName + QString(":%1").arg(port);
NetSocket.connectToHost(hostName, port);
}
@@ -507,7 +516,7 @@
// If the password is blank, ask the user to enter one in
if (passLength == 0)
{
- QString password = QInputDialog::getText(0, tr("Password"), tr("Your nickname %1 is\nregistered on Hedgewars.org\nPlease provide your password below\nor pick another nickname in game config:").arg(mynick), QLineEdit::Password, passLength==0?NULL:QString(passLength,'\0'), &ok);
+ QString password = QInputDialog::getText(m_pGameCFGWidget, tr("Password"), tr("Your nickname %1 is\nregistered on Hedgewars.org\nPlease provide your password below\nor pick another nickname in game config:").arg(mynick), QLineEdit::Password, passLength==0?NULL:QString(passLength,'\0'), &ok);
if (!ok) {
Disconnect();
@@ -831,6 +840,7 @@
}
config->setValue("net/nick", newNick);
+ config->updNetNick();
mynick = newNick;
RawSendNet(QString("NICK%1%2").arg(delimeter).arg(newNick));