update name autocompletion after nick change (since own nick isn't suggested)
authorsheepluva
Sat, 29 Oct 2011 11:47:37 +0200
changeset 6227 ce60b734fff1
parent 6225 505643d4c23d
child 6229 4c834af76c3b
update name autocompletion after nick change (since own nick isn't suggested)
QTfrontend/hwform.cpp
QTfrontend/ui/page/pagenetgame.cpp
QTfrontend/ui/page/pagenetgame.h
QTfrontend/ui/page/pageroomslist.cpp
QTfrontend/ui/page/pageroomslist.h
QTfrontend/ui/widget/chatwidget.cpp
QTfrontend/ui/widget/chatwidget.h
--- a/QTfrontend/hwform.cpp	Sat Oct 29 09:19:04 2011 +0200
+++ b/QTfrontend/hwform.cpp	Sat Oct 29 11:47:37 2011 +0200
@@ -755,6 +755,9 @@
     hwnet->NewNick(newNick);
     config->setValue("net/nick", newNick);
     config->updNetNick();
+
+    ui.pageRoomsList->setUser(nick);
+    ui.pageNetGame->setUser(nick);
 }
 
 void HWForm::NetAuthFailed()
@@ -800,8 +803,6 @@
         hwnet=0;
     }
 
-    ui.pageRoomsList->chatWidget->clear();
-
     hwnet = new HWNewNet();
 
     GoToPage(ID_PAGE_CONNECTING);
@@ -939,6 +940,10 @@
         config->setValue("net/nick",nick);
         config->updNetNick();
     }
+
+    ui.pageRoomsList->setUser(nick);
+    ui.pageNetGame->setUser(nick);
+
     hwnet->Connect(hostName, port, nick);
 }
 
--- a/QTfrontend/ui/page/pagenetgame.cpp	Sat Oct 29 09:19:04 2011 +0200
+++ b/QTfrontend/ui/page/pagenetgame.cpp	Sat Oct 29 11:47:37 2011 +0200
@@ -174,3 +174,7 @@
     leRoomName->setVisible(isMaster);
 }
 
+void PageNetGame::setUser(const QString & nickname)
+{
+    pChatWidget->setUser(nickname);
+}
--- a/QTfrontend/ui/page/pagenetgame.h	Sat Oct 29 09:19:04 2011 +0200
+++ b/QTfrontend/ui/page/pagenetgame.h	Sat Oct 29 11:47:37 2011 +0200
@@ -59,6 +59,7 @@
 
 public slots:
     void setReadyStatus(bool isReady);
+    void setUser(const QString & nickname);
     void onUpdateClick();
     void setMasterMode(bool isMaster);
 
--- a/QTfrontend/ui/page/pageroomslist.cpp	Sat Oct 29 09:19:04 2011 +0200
+++ b/QTfrontend/ui/page/pageroomslist.cpp	Sat Oct 29 11:47:37 2011 +0200
@@ -446,3 +446,8 @@
 {
     lblCount->setText(tr("%1 players online", 0, cnt).arg(cnt));
 }
+
+void PageRoomsList::setUser(const QString & nickname)
+{
+    chatWidget->setUser(nickname);
+}
--- a/QTfrontend/ui/page/pageroomslist.h	Sat Oct 29 09:19:04 2011 +0200
+++ b/QTfrontend/ui/page/pageroomslist.h	Sat Oct 29 11:47:37 2011 +0200
@@ -49,8 +49,9 @@
     QLabel * lblCount;
 
 public slots:
+    void setAdmin(bool);
     void setRoomsList(const QStringList & list);
-    void setAdmin(bool);
+    void setUser(const QString & nickname);
     void updateNickCounter(int cnt);
 
 signals:
--- a/QTfrontend/ui/widget/chatwidget.cpp	Sat Oct 29 09:19:04 2011 +0200
+++ b/QTfrontend/ui/widget/chatwidget.cpp	Sat Oct 29 11:47:37 2011 +0200
@@ -483,13 +483,13 @@
 // "link" nick, but before that encode it in base64 to make sure it can't
 // intefere with html/url syntax the nick is put as querystring as putting
 // it as host would convert it to it's lower case variant
-QString HWChatWidget::linkedNick(const QString & nickName)
+QString HWChatWidget::linkedNick(const QString & nickname)
 {
-    if (nickName != m_userNick)
+    if (nickname != m_userNick)
         return QString("<a href=\"hwnick://?%1\" class=\"nick\">%2</a>").arg(
-                    QString(nickName.toUtf8().toBase64())).arg(nickName);
+                    QString(nickname.toUtf8().toBase64())).arg(nickname);
     else
-        return QString("<span class=\"nick\">%1</span>").arg(nickName);
+        return QString("<span class=\"nick\">%1</span>").arg(nickname);
 }
 
 
@@ -539,7 +539,8 @@
 
     bool isHL = false;
 
-    if ((!nick.isEmpty()) && (nick != m_userNick))
+    if ((c != 3) && (!nick.isEmpty()) &&
+        (nick != m_userNick) && (m_userNick.isEmpty()))
     {
         QString lcStr = str.toLower();
 
@@ -637,7 +638,6 @@
     chatText->clear();
     chatStrings.clear();
     chatNicks->clear();
-    m_userNick = gameSettings->value("net/nick","").toString();
 
     // clear and re compile regexp for highlighting
     m_highlights.clear();
@@ -971,3 +971,11 @@
 
     return false;
 }
+
+
+void HWChatWidget::setUser(const QString & nickname)
+{
+    m_userNick = nickname;
+    nickRemoved(nickname);
+    clear();
+}
--- a/QTfrontend/ui/widget/chatwidget.h	Sat Oct 29 09:19:04 2011 +0200
+++ b/QTfrontend/ui/widget/chatwidget.h	Sat Oct 29 11:47:37 2011 +0200
@@ -78,6 +78,7 @@
   void displayError(const QString & message);
   void displayNotice(const QString & message);
   void displayWarning(const QString & message);
+  void setUser(const QString & nickname);
 
 protected:
     virtual void dragEnterEvent(QDragEnterEvent * event);
@@ -99,7 +100,7 @@
   bool parseCommand(const QString & line);
   void discardStyleSheet();
   void saveStyleSheet();
-  QString linkedNick(const QString & nickName);
+  QString linkedNick(const QString & nickname);
 
  public slots:
   void onChatString(const QString& str);