QTfrontend/ui/widget/chatwidget.cpp
changeset 6418 f1a3c3aab5b4
parent 6240 5d8e478916b4
child 6616 f77bb02b669f
equal deleted inserted replaced
6417:eae5900fd8a4 6418:f1a3c3aab5b4
   243   QWidget(parent),
   243   QWidget(parent),
   244   mainLayout(this)
   244   mainLayout(this)
   245 {
   245 {
   246     this->gameSettings = gameSettings;
   246     this->gameSettings = gameSettings;
   247     this->notify = notify;
   247     this->notify = notify;
       
   248 
       
   249     m_isAdmin = false;
       
   250 
   248     if(gameSettings->value("frontend/sound", true).toBool())
   251     if(gameSettings->value("frontend/sound", true).toBool())
   249     {
   252     {
   250         if (notify)
   253         if (notify)
   251             m_helloSound = HWDataManager::instance().findFileForRead(
   254             m_helloSound = HWDataManager::instance().findFileForRead(
   252                             "Sounds/voices/Classic/Hello.ogg");
   255                             "Sounds/voices/Classic/Hello.ogg");
   708 
   711 
   709 void HWChatWidget::onKick()
   712 void HWChatWidget::onKick()
   710 {
   713 {
   711     QListWidgetItem * curritem = chatNicks->currentItem();
   714     QListWidgetItem * curritem = chatNicks->currentItem();
   712     if (curritem)
   715     if (curritem)
   713     {
       
   714         displayNotice(tr("Kicking %1 ...").arg(Qt::escape(curritem->text())));
       
   715         emit kick(curritem->text());
   716         emit kick(curritem->text());
   716     }
       
   717 }
   717 }
   718 
   718 
   719 void HWChatWidget::onBan()
   719 void HWChatWidget::onBan()
   720 {
   720 {
   721     QListWidgetItem * curritem = chatNicks->currentItem();
   721     QListWidgetItem * curritem = chatNicks->currentItem();
   830     if (item != NULL)
   830     if (item != NULL)
   831         nick = item->text();
   831         nick = item->text();
   832     else
   832     else
   833         nick = m_clickedNick;
   833         nick = m_clickedNick;
   834 
   834 
       
   835     // don't display all actions for own nick
       
   836     bool isSelf = (nick == m_userNick);
       
   837 
       
   838     acFollow->setVisible(!isSelf);
       
   839 
   835     // update context menu labels according to possible action
   840     // update context menu labels according to possible action
   836     if(ignoreList.contains(nick, Qt::CaseInsensitive))
   841     if(ignoreList.contains(nick, Qt::CaseInsensitive))
   837     {
   842     {
   838         acIgnore->setText(QAction::tr("Unignore"));
   843         acIgnore->setText(QAction::tr("Unignore"));
   839         acIgnore->setIcon(QIcon(":/res/unignore.png"));
   844         acIgnore->setIcon(QIcon(":/res/unignore.png"));
   840     }
   845     }
   841     else
   846     else
   842     {
   847     {
   843         acIgnore->setText(QAction::tr("Ignore"));
   848         acIgnore->setText(QAction::tr("Ignore"));
   844         acIgnore->setIcon(QIcon(":/res/ignore.png"));
   849         acIgnore->setIcon(QIcon(":/res/ignore.png"));
       
   850         acIgnore->setVisible(!isSelf);
   845     }
   851     }
   846 
   852 
   847     if(friendsList.contains(nick, Qt::CaseInsensitive))
   853     if(friendsList.contains(nick, Qt::CaseInsensitive))
   848     {
   854     {
   849         acFriend->setText(QAction::tr("Remove friend"));
   855         acFriend->setText(QAction::tr("Remove friend"));
   851     }
   857     }
   852     else
   858     else
   853     {
   859     {
   854         acFriend->setText(QAction::tr("Add friend"));
   860         acFriend->setText(QAction::tr("Add friend"));
   855         acFriend->setIcon(QIcon(":/res/addfriend.png"));
   861         acFriend->setIcon(QIcon(":/res/addfriend.png"));
       
   862         acFriend->setVisible(!isSelf);
       
   863     }
       
   864 
       
   865     if (m_isAdmin)
       
   866     {
       
   867         acKick->setVisible(!isSelf);
       
   868         acBan->setVisible(!isSelf);
   856     }
   869     }
   857 }
   870 }
   858 
   871 
   859 void HWChatWidget::setShowReady(bool s)
   872 void HWChatWidget::setShowReady(bool s)
   860 {
   873 {
   879 
   892 
   880 void HWChatWidget::adminAccess(bool b)
   893 void HWChatWidget::adminAccess(bool b)
   881 {
   894 {
   882     chatNicks->removeAction(acKick);
   895     chatNicks->removeAction(acKick);
   883     chatNicks->removeAction(acBan);
   896     chatNicks->removeAction(acBan);
       
   897 
       
   898     m_isAdmin = b;
   884 
   899 
   885     if(b)
   900     if(b)
   886     {
   901     {
   887         chatNicks->insertAction(0, acKick);
   902         chatNicks->insertAction(0, acKick);
   888 //      chatNicks->insertAction(0, acBan);
   903 //      chatNicks->insertAction(0, acBan);