Frontend:
authorsmxx
Mon, 22 Feb 2010 23:03:50 +0000
changeset 2846 1cb8b4c425ed
parent 2845 19db164dd20d
child 2847 cde320fd3122
Frontend: * Some cleanup and updating context menu entries for chat widget
QTfrontend/chatwidget.cpp
QTfrontend/chatwidget.h
--- a/QTfrontend/chatwidget.cpp	Mon Feb 22 22:51:21 2010 +0000
+++ b/QTfrontend/chatwidget.cpp	Mon Feb 22 23:03:50 2010 +0000
@@ -78,6 +78,8 @@
 	chatNicks->setContextMenuPolicy(Qt::ActionsContextMenu);
 	connect(chatNicks, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
 		this, SLOT(chatNickDoubleClicked(QListWidgetItem *)));
+	connect(chatNicks, SIGNAL(itemClicked(QListWidgetItem *)),
+		this, SLOT(chatNickClicked(QListWidgetItem *)));
 
 	mainLayout.addWidget(chatNicks, 0, 1);
 
@@ -91,7 +93,7 @@
 	connect(acFollow, SIGNAL(triggered(bool)), this, SLOT(onFollow()));
 	acIgnore = new QAction(QAction::tr("Ignore"), chatNicks);
 	connect(acIgnore, SIGNAL(triggered(bool)), this, SLOT(onIgnore()));
-	acFriend = new QAction(QAction::tr("Friend"), chatNicks);
+	acFriend = new QAction(QAction::tr("Add friend"), chatNicks);
 	connect(acFriend, SIGNAL(triggered(bool)), this, SLOT(onFriend()));
 
 	chatNicks->insertAction(0, acInfo);
@@ -181,7 +183,7 @@
 	emit chatLine(chatEditLine->text());
 	chatEditLine->clear();
 }
-#include <QMessageBox>
+
 void HWChatWidget::onChatString(const QString& str)
 {
 	if (chatStrings.size() > 250)
@@ -328,6 +330,23 @@
 	if (item) onFollow();
 }
 
+void HWChatWidget::chatNickClicked(QListWidgetItem * item)
+{
+	if (!item)
+		return;
+
+	// update context menu labels according to possible action
+	if(ignoreList.contains(item->text(), Qt::CaseInsensitive))
+		acIgnore->setText(QAction::tr("Unignore"));
+	else
+		acIgnore->setText(QAction::tr("Ignore"));
+
+	if(friendsList.contains(item->text(), Qt::CaseInsensitive))
+		acFriend->setText(QAction::tr("Remove friend"));
+	else
+		acFriend->setText(QAction::tr("Add friend"));
+}
+
 void HWChatWidget::setShowReady(bool s)
 {
 	showReady = s;
@@ -342,11 +361,6 @@
 		return;
 	}
 
-	/*if(isReady)
-		items[0]->setIcon(QIcon(":/res/lightbulb_on.png"));
-	else
-		items[0]->setIcon(QIcon(":/res/lightbulb_off.png"));*/
-
 	items[0]->setData(Qt::UserRole, isReady); // bulb status
 	updateIcon(items[0]);
 
--- a/QTfrontend/chatwidget.h	Mon Feb 22 22:51:21 2010 +0000
+++ b/QTfrontend/chatwidget.h	Mon Feb 22 23:03:50 2010 +0000
@@ -92,6 +92,7 @@
   void onIgnore();
   void onFriend();
   void chatNickDoubleClicked(QListWidgetItem * item);
+  void chatNickClicked(QListWidgetItem * item);
 };
 
 #endif // _CHAT_WIDGET_INCLUDED