QTfrontend/chatwidget.cpp
changeset 1860 ce140b2b928a
parent 1666 b66e014510e7
child 1921 2a09f7f786a0
--- a/QTfrontend/chatwidget.cpp	Wed Mar 04 13:55:53 2009 +0000
+++ b/QTfrontend/chatwidget.cpp	Wed Mar 04 16:35:36 2009 +0000
@@ -57,12 +57,13 @@
 	chatNicks->setContextMenuPolicy(Qt::ActionsContextMenu);
 	mainLayout.addWidget(chatNicks, 0, 1);
 
-	QAction * acBan = new QAction(QAction::tr("Kick"), chatNicks);
-	connect(acBan, SIGNAL(triggered(bool)), this, SLOT(onKick()));
-	chatNicks->insertAction(0, acBan);
-
-	QAction * acInfo = new QAction(QAction::tr("Info"), chatNicks);
+	acInfo = new QAction(QAction::tr("Info"), chatNicks);
 	connect(acInfo, SIGNAL(triggered(bool)), this, SLOT(onInfo()));
+	acKick = new QAction(QAction::tr("Kick"), chatNicks);
+	connect(acKick, SIGNAL(triggered(bool)), this, SLOT(onKick()));
+	acBan = new QAction(QAction::tr("Ban"), chatNicks);
+	connect(acBan, SIGNAL(triggered(bool)), this, SLOT(onBan()));
+	
 	chatNicks->insertAction(0, acInfo);
 }
 
@@ -129,6 +130,13 @@
 		emit kick(curritem->text());
 }
 
+void HWChatWidget::onBan()
+{
+	QListWidgetItem * curritem = chatNicks->currentItem();
+	if (curritem)
+		emit ban(curritem->text());
+}
+
 void HWChatWidget::onInfo()
 {
 	QListWidgetItem * curritem = chatNicks->currentItem();
@@ -150,3 +158,15 @@
 	else
 		items[0]->setIcon(QIcon(":/res/lightbulb_off.png"));
 }
+
+void HWChatWidget::adminAccess(bool b)
+{
+	chatNicks->removeAction(acKick);
+	chatNicks->removeAction(acBan);
+	
+	if(b)
+	{
+		chatNicks->insertAction(0, acKick);
+		chatNicks->insertAction(0, acBan);
+	}
+}