# HG changeset patch # User smxx # Date 1266879830 0 # Node ID 1cb8b4c425ed039f5509bd91c1eae5927244fcc3 # Parent 19db164dd20d0a41d8137750b1ec97181228ccc2 Frontend: * Some cleanup and updating context menu entries for chat widget diff -r 19db164dd20d -r 1cb8b4c425ed QTfrontend/chatwidget.cpp --- 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 + 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]); diff -r 19db164dd20d -r 1cb8b4c425ed QTfrontend/chatwidget.h --- 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