hide all context menu options for own nick, except for info
authorsheepluva
Thu, 24 Nov 2011 19:15:29 +0100
changeset 6418 f1a3c3aab5b4
parent 6417 eae5900fd8a4
child 6419 6a464d0a5c13
hide all context menu options for own nick, except for info
QTfrontend/ui/widget/chatwidget.cpp
QTfrontend/ui/widget/chatwidget.h
--- a/QTfrontend/ui/widget/chatwidget.cpp	Thu Nov 24 20:59:13 2011 +0300
+++ b/QTfrontend/ui/widget/chatwidget.cpp	Thu Nov 24 19:15:29 2011 +0100
@@ -245,6 +245,9 @@
 {
     this->gameSettings = gameSettings;
     this->notify = notify;
+
+    m_isAdmin = false;
+
     if(gameSettings->value("frontend/sound", true).toBool())
     {
         if (notify)
@@ -710,10 +713,7 @@
 {
     QListWidgetItem * curritem = chatNicks->currentItem();
     if (curritem)
-    {
-        displayNotice(tr("Kicking %1 ...").arg(Qt::escape(curritem->text())));
         emit kick(curritem->text());
-    }
 }
 
 void HWChatWidget::onBan()
@@ -832,6 +832,11 @@
     else
         nick = m_clickedNick;
 
+    // don't display all actions for own nick
+    bool isSelf = (nick == m_userNick);
+
+    acFollow->setVisible(!isSelf);
+
     // update context menu labels according to possible action
     if(ignoreList.contains(nick, Qt::CaseInsensitive))
     {
@@ -842,6 +847,7 @@
     {
         acIgnore->setText(QAction::tr("Ignore"));
         acIgnore->setIcon(QIcon(":/res/ignore.png"));
+        acIgnore->setVisible(!isSelf);
     }
 
     if(friendsList.contains(nick, Qt::CaseInsensitive))
@@ -853,6 +859,13 @@
     {
         acFriend->setText(QAction::tr("Add friend"));
         acFriend->setIcon(QIcon(":/res/addfriend.png"));
+        acFriend->setVisible(!isSelf);
+    }
+
+    if (m_isAdmin)
+    {
+        acKick->setVisible(!isSelf);
+        acBan->setVisible(!isSelf);
     }
 }
 
@@ -882,6 +895,8 @@
     chatNicks->removeAction(acKick);
     chatNicks->removeAction(acBan);
 
+    m_isAdmin = b;
+
     if(b)
     {
         chatNicks->insertAction(0, acKick);
--- a/QTfrontend/ui/widget/chatwidget.h	Thu Nov 24 20:59:13 2011 +0300
+++ b/QTfrontend/ui/widget/chatwidget.h	Thu Nov 24 19:15:29 2011 +0100
@@ -123,6 +123,7 @@
   void nickCountUpdate(int cnt);
 
  private:
+  bool m_isAdmin;
   QGridLayout mainLayout;
   QTextBrowser* chatText;
   QStringList chatStrings;