reimplement auto-kick for ignored players (it was temporarily removed during refactoring)
authorsheepluva
Wed, 25 Apr 2012 17:44:48 +0200
changeset 6929 c305d31642ac
parent 6928 9562ace15141
child 6930 d187ea93fc4f
reimplement auto-kick for ignored players (it was temporarily removed during refactoring)
QTfrontend/ui/page/pagenetgame.cpp
QTfrontend/ui/widget/chatwidget.cpp
QTfrontend/ui/widget/chatwidget.h
--- a/QTfrontend/ui/page/pagenetgame.cpp	Wed Apr 25 08:23:48 2012 +0200
+++ b/QTfrontend/ui/page/pagenetgame.cpp	Wed Apr 25 17:44:48 2012 +0200
@@ -40,6 +40,7 @@
     pChatWidget = new HWChatWidget(this, m_gameSettings, true);
     pChatWidget->setShowReady(true); // show status bulbs by default
     pChatWidget->setShowFollow(false); // don't show follow in nicks' context menus
+    pChatWidget->setIgnoreListKick(true); // kick ignored players automatically
     pageLayout->addWidget(pChatWidget, 2, 0, 1, 2);
     pageLayout->setRowStretch(1, 100);
     pageLayout->setRowStretch(2, 100);
--- a/QTfrontend/ui/widget/chatwidget.cpp	Wed Apr 25 08:23:48 2012 +0200
+++ b/QTfrontend/ui/widget/chatwidget.cpp	Wed Apr 25 17:44:48 2012 +0200
@@ -247,6 +247,7 @@
     this->notify = notify;
 
     m_isAdmin = false;
+    m_autoKickEnabled = false;
 
     if(gameSettings->value("frontend/sound", true).toBool())
     {
@@ -399,6 +400,11 @@
     }
 }
 
+void HWChatWidget::setIgnoreListKick(bool enabled)
+{
+    m_autoKickEnabled = enabled;
+}
+
 void HWChatWidget::loadList(QStringList & list, const QString & file)
 {
     list.clear();
@@ -636,6 +642,13 @@
 void HWChatWidget::nickAdded(const QString & nick, bool notifyNick)
 {
     bool isIgnored = ignoreList.contains(nick, Qt::CaseInsensitive);
+
+    if (isIgnored && m_isAdmin && m_autoKickEnabled)
+    {
+        emit kick(nick);
+        return;
+    }
+
     QListWidgetItem * item = new ListWidgetNickItem(nick, friendsList.contains(nick, Qt::CaseInsensitive), isIgnored);
     updateNickItem(item);
     chatNicks->addItem(item);
--- a/QTfrontend/ui/widget/chatwidget.h	Wed Apr 25 08:23:48 2012 +0200
+++ b/QTfrontend/ui/widget/chatwidget.h	Wed Apr 25 17:44:48 2012 +0200
@@ -72,6 +72,7 @@
         HWChatWidget(QWidget* parent, QSettings * gameSettings, bool notify);
         void loadLists(const QString & nick);
         void saveLists(const QString & nick);
+        void setIgnoreListKick(bool enabled); ///< automatically kick people on ignore list (if possible)
         void setShowReady(bool s);
         void setShowFollow(bool enabled);
         QStringList ignoreList, friendsList;
@@ -143,6 +144,7 @@
         QList<QRegExp> m_highlights; ///< regular expressions used for highlighting
         bool notify;
         bool showReady;
+        bool m_autoKickEnabled;
 
     private slots:
         void returnPressed();