Ask user for a nickname on first run, suggest login name
authorunc0rr
Thu, 27 Aug 2009 17:26:21 +0000
changeset 2334 3cf9290a518e
parent 2333 f53a208e9637
child 2335 0a61a3c2efc4
Ask user for a nickname on first run, suggest login name
QTfrontend/gameuiconfig.cpp
QTfrontend/newnetclient.cpp
--- a/QTfrontend/gameuiconfig.cpp	Thu Aug 27 12:59:21 2009 +0000
+++ b/QTfrontend/gameuiconfig.cpp	Thu Aug 27 17:26:21 2009 +0000
@@ -21,6 +21,7 @@
 #include <QLineEdit>
 #include <QDesktopWidget>
 #include <QApplication>
+#include <QInputDialog>
 
 #include "gameuiconfig.h"
 #include "hwform.h"
@@ -50,7 +51,15 @@
 	Form->ui.pageOptions->CBEnableMusic->setChecked(value("audio/music", true).toBool());
 	Form->ui.pageOptions->volumeBox->setValue(value("audio/volume", 100).toUInt());
 
-	Form->ui.pageOptions->editNetNick->setText(value("net/nick", QLineEdit::tr("unnamed")).toString());
+	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);
 
 	delete netHost;
 	netHost = new QString(value("net/ip", "").toString());
--- a/QTfrontend/newnetclient.cpp	Thu Aug 27 12:59:21 2009 +0000
+++ b/QTfrontend/newnetclient.cpp	Thu Aug 27 17:26:21 2009 +0000
@@ -66,7 +66,7 @@
 
 void HWNewNet::Connect(const QString & hostName, quint16 port, const QString & nick)
 {
-	mynick = nick;
+	mynick = nick.isEmpty() ? QLineEdit::tr("unnamed") : nick;
 	NetSocket.connectToHost(hostName, port);
 }