QTfrontend/chatwidget.cpp
changeset 2948 3f21a9dc93d0
parent 2847 cde320fd3122
child 3019 d6e19f35d98d
equal deleted inserted replaced
2947:803b277e4894 2948:3f21a9dc93d0
    49        sound[1] = Mix_LoadWAV(QString(tmpdir.absolutePath() + "/Default/Hello.ogg").toLocal8Bit().constData());
    49        sound[1] = Mix_LoadWAV(QString(tmpdir.absolutePath() + "/Default/Hello.ogg").toLocal8Bit().constData());
    50        sound[2] = Mix_LoadWAV(QString(tmpdir.absolutePath() + "/Mobster/Hello.ogg").toLocal8Bit().constData());
    50        sound[2] = Mix_LoadWAV(QString(tmpdir.absolutePath() + "/Mobster/Hello.ogg").toLocal8Bit().constData());
    51        sound[3] = Mix_LoadWAV(QString(tmpdir.absolutePath() + "/Russian/Hello.ogg").toLocal8Bit().constData());
    51        sound[3] = Mix_LoadWAV(QString(tmpdir.absolutePath() + "/Russian/Hello.ogg").toLocal8Bit().constData());
    52     }
    52     }
    53 
    53 
    54 	mainLayout.setSpacing(1);
    54     mainLayout.setSpacing(1);
    55 	mainLayout.setMargin(1);
    55     mainLayout.setMargin(1);
    56 	mainLayout.setSizeConstraint(QLayout::SetMinimumSize);
    56     mainLayout.setSizeConstraint(QLayout::SetMinimumSize);
    57 	mainLayout.setColumnStretch(0, 75);
    57     mainLayout.setColumnStretch(0, 75);
    58 	mainLayout.setColumnStretch(1, 25);
    58     mainLayout.setColumnStretch(1, 25);
    59 
    59 
    60 	chatEditLine = new QLineEdit(this);
    60     chatEditLine = new QLineEdit(this);
    61 	chatEditLine->setMaxLength(300);
    61     chatEditLine->setMaxLength(300);
    62 	connect(chatEditLine, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
    62     connect(chatEditLine, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
    63 
    63 
    64 	mainLayout.addWidget(chatEditLine, 1, 0, 1, 2);
    64     mainLayout.addWidget(chatEditLine, 1, 0, 1, 2);
    65 
    65 
    66 	chatText = new QTextBrowser(this);
    66     chatText = new QTextBrowser(this);
    67 	chatText->setMinimumHeight(20);
    67     chatText->setMinimumHeight(20);
    68 	chatText->setMinimumWidth(10);
    68     chatText->setMinimumWidth(10);
    69 	chatText->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    69     chatText->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    70 	chatText->setOpenExternalLinks(true);
    70     chatText->setOpenExternalLinks(true);
    71 	mainLayout.addWidget(chatText, 0, 0);
    71     mainLayout.addWidget(chatText, 0, 0);
    72 
    72 
    73 	chatNicks = new QListWidget(this);
    73     chatNicks = new QListWidget(this);
    74 	chatNicks->setMinimumHeight(10);
    74     chatNicks->setMinimumHeight(10);
    75 	chatNicks->setMinimumWidth(10);
    75     chatNicks->setMinimumWidth(10);
    76 	chatNicks->setSortingEnabled(true);
    76     chatNicks->setSortingEnabled(true);
    77 	chatNicks->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    77     chatNicks->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    78 	chatNicks->setContextMenuPolicy(Qt::ActionsContextMenu);
    78     chatNicks->setContextMenuPolicy(Qt::ActionsContextMenu);
    79 	connect(chatNicks, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
    79     connect(chatNicks, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
    80 		this, SLOT(chatNickDoubleClicked(QListWidgetItem *)));
    80         this, SLOT(chatNickDoubleClicked(QListWidgetItem *)));
    81 	connect(chatNicks, SIGNAL(currentRowChanged(int)),
    81     connect(chatNicks, SIGNAL(currentRowChanged(int)),
    82 		this, SLOT(chatNickSelected(int)));
    82         this, SLOT(chatNickSelected(int)));
    83 
    83 
    84 	mainLayout.addWidget(chatNicks, 0, 1);
    84     mainLayout.addWidget(chatNicks, 0, 1);
    85 
    85 
    86 	acInfo = new QAction(QAction::tr("Info"), chatNicks);
    86     acInfo = new QAction(QAction::tr("Info"), chatNicks);
    87 	connect(acInfo, SIGNAL(triggered(bool)), this, SLOT(onInfo()));
    87     connect(acInfo, SIGNAL(triggered(bool)), this, SLOT(onInfo()));
    88 	acKick = new QAction(QAction::tr("Kick"), chatNicks);
    88     acKick = new QAction(QAction::tr("Kick"), chatNicks);
    89 	connect(acKick, SIGNAL(triggered(bool)), this, SLOT(onKick()));
    89     connect(acKick, SIGNAL(triggered(bool)), this, SLOT(onKick()));
    90 	acBan = new QAction(QAction::tr("Ban"), chatNicks);
    90     acBan = new QAction(QAction::tr("Ban"), chatNicks);
    91 	connect(acBan, SIGNAL(triggered(bool)), this, SLOT(onBan()));
    91     connect(acBan, SIGNAL(triggered(bool)), this, SLOT(onBan()));
    92 	acFollow = new QAction(QAction::tr("Follow"), chatNicks);
    92     acFollow = new QAction(QAction::tr("Follow"), chatNicks);
    93 	connect(acFollow, SIGNAL(triggered(bool)), this, SLOT(onFollow()));
    93     connect(acFollow, SIGNAL(triggered(bool)), this, SLOT(onFollow()));
    94 	acIgnore = new QAction(QAction::tr("Ignore"), chatNicks);
    94     acIgnore = new QAction(QAction::tr("Ignore"), chatNicks);
    95 	connect(acIgnore, SIGNAL(triggered(bool)), this, SLOT(onIgnore()));
    95     connect(acIgnore, SIGNAL(triggered(bool)), this, SLOT(onIgnore()));
    96 	acFriend = new QAction(QAction::tr("Add friend"), chatNicks);
    96     acFriend = new QAction(QAction::tr("Add friend"), chatNicks);
    97 	connect(acFriend, SIGNAL(triggered(bool)), this, SLOT(onFriend()));
    97     connect(acFriend, SIGNAL(triggered(bool)), this, SLOT(onFriend()));
    98 
    98 
    99 	chatNicks->insertAction(0, acInfo);
    99     chatNicks->insertAction(0, acInfo);
   100 	chatNicks->insertAction(0, acFollow);
   100     chatNicks->insertAction(0, acFollow);
   101 	chatNicks->insertAction(0, acIgnore);
   101     chatNicks->insertAction(0, acIgnore);
   102 	chatNicks->insertAction(0, acFriend);
   102     chatNicks->insertAction(0, acFriend);
   103 	
   103     
   104 	showReady = false;
   104     showReady = false;
   105 }
   105 }
   106 
   106 
   107 void HWChatWidget::loadList(QStringList & list, const QString & file)
   107 void HWChatWidget::loadList(QStringList & list, const QString & file)
   108 {
   108 {
   109 	list.clear();
   109     list.clear();
   110 	QFile txt((cfgdir->absolutePath() + "/" + file).toLocal8Bit().constData());
   110     QFile txt((cfgdir->absolutePath() + "/" + file).toLocal8Bit().constData());
   111 	if(!txt.open(QIODevice::ReadOnly))
   111     if(!txt.open(QIODevice::ReadOnly))
   112 		return;
   112         return;
   113 	QTextStream stream(&txt);
   113     QTextStream stream(&txt);
   114 	stream.setCodec("UTF-8");
   114     stream.setCodec("UTF-8");
   115 
   115 
   116 	while(!stream.atEnd())
   116     while(!stream.atEnd())
   117 	{
   117     {
   118 		QString str = stream.readLine();
   118         QString str = stream.readLine();
   119 		if(str.startsWith(";") || str.length() == 0)
   119         if(str.startsWith(";") || str.length() == 0)
   120 			continue;
   120             continue;
   121 		list << str.trimmed();
   121         list << str.trimmed();
   122 	}
   122     }
   123 	list.removeDuplicates();
   123     list.removeDuplicates();
   124 	txt.close();
   124     txt.close();
   125 }
   125 }
   126 
   126 
   127 void HWChatWidget::saveList(QStringList & list, const QString & file)
   127 void HWChatWidget::saveList(QStringList & list, const QString & file)
   128 {
   128 {
   129 	QFile txt((cfgdir->absolutePath() + "/" + file).toLocal8Bit().constData());
   129     QFile txt((cfgdir->absolutePath() + "/" + file).toLocal8Bit().constData());
   130 	if(!txt.open(QIODevice::WriteOnly | QIODevice::Truncate))
   130     if(!txt.open(QIODevice::WriteOnly | QIODevice::Truncate))
   131 		return;
   131         return;
   132 	QTextStream stream(&txt);
   132     QTextStream stream(&txt);
   133 	stream.setCodec("UTF-8");
   133     stream.setCodec("UTF-8");
   134 
   134 
   135 	stream << "; this list is used by Hedgewars - do not edit it unless you know what you're doing!" << endl;
   135     stream << "; this list is used by Hedgewars - do not edit it unless you know what you're doing!" << endl;
   136 	for(int i = 0; i < list.size(); i++)
   136     for(int i = 0; i < list.size(); i++)
   137 		stream << list[i] << endl;
   137         stream << list[i] << endl;
   138 	txt.close();
   138     txt.close();
   139 }
   139 }
   140 
   140 
   141 void HWChatWidget::updateIcon(QListWidgetItem *item)
   141 void HWChatWidget::updateIcon(QListWidgetItem *item)
   142 {
   142 {
   143 	QString nick = item->text();
   143     QString nick = item->text();
   144 
   144 
   145 	if(ignoreList.contains(nick, Qt::CaseInsensitive))
   145     if(ignoreList.contains(nick, Qt::CaseInsensitive))
   146 	{
   146     {
   147 		item->setIcon(QIcon(showReady ? (item->data(Qt::UserRole).toBool() ? ":/res/chat_ignore_on" : ":/res/chat_ignore_off") : ":/res/chat_ignore.png"));
   147         item->setIcon(QIcon(showReady ? (item->data(Qt::UserRole).toBool() ? ":/res/chat_ignore_on" : ":/res/chat_ignore_off") : ":/res/chat_ignore.png"));
   148 		item->setForeground(Qt::gray);
   148         item->setForeground(Qt::gray);
   149 	}
   149     }
   150 	else if(friendsList.contains(nick, Qt::CaseInsensitive))
   150     else if(friendsList.contains(nick, Qt::CaseInsensitive))
   151 	{
   151     {
   152 		item->setIcon(QIcon(showReady ? (item->data(Qt::UserRole).toBool() ? ":/res/chat_friend_on" : ":/res/chat_friend_off") : ":/res/chat_friend.png"));
   152         item->setIcon(QIcon(showReady ? (item->data(Qt::UserRole).toBool() ? ":/res/chat_friend_on" : ":/res/chat_friend_off") : ":/res/chat_friend.png"));
   153 		item->setForeground(Qt::green);
   153         item->setForeground(Qt::green);
   154 	}
   154     }
   155 	else
   155     else
   156 	{
   156     {
   157 		item->setIcon(QIcon(showReady ? (item->data(Qt::UserRole).toBool() ? ":/res/chat_default_on" : ":/res/chat_default_off") : ":/res/chat_default.png"));
   157         item->setIcon(QIcon(showReady ? (item->data(Qt::UserRole).toBool() ? ":/res/chat_default_on" : ":/res/chat_default_off") : ":/res/chat_default.png"));
   158 		item->setForeground(QBrush(QColor(0xff, 0xcc, 0x00)));
   158         item->setForeground(QBrush(QColor(0xff, 0xcc, 0x00)));
   159 	}
   159     }
   160 }
   160 }
   161 
   161 
   162 void HWChatWidget::updateIcons()
   162 void HWChatWidget::updateIcons()
   163 {
   163 {
   164 	for(int i = 0; i < chatNicks->count(); i++)
   164     for(int i = 0; i < chatNicks->count(); i++)
   165 		updateIcon(chatNicks->item(i));
   165         updateIcon(chatNicks->item(i));
   166 }
   166 }
   167 
   167 
   168 void HWChatWidget::loadLists(const QString & nick)
   168 void HWChatWidget::loadLists(const QString & nick)
   169 {
   169 {
   170 	loadList(ignoreList, nick.toLower() + "_ignore.txt");
   170     loadList(ignoreList, nick.toLower() + "_ignore.txt");
   171 	loadList(friendsList, nick.toLower() + "_friends.txt");
   171     loadList(friendsList, nick.toLower() + "_friends.txt");
   172 	updateIcons();
   172     updateIcons();
   173 }
   173 }
   174 
   174 
   175 void HWChatWidget::saveLists(const QString & nick)
   175 void HWChatWidget::saveLists(const QString & nick)
   176 {
   176 {
   177 	saveList(ignoreList, nick.toLower() + "_ignore.txt");
   177     saveList(ignoreList, nick.toLower() + "_ignore.txt");
   178 	saveList(friendsList, nick.toLower() + "_friends.txt");
   178     saveList(friendsList, nick.toLower() + "_friends.txt");
   179 }
   179 }
   180 
   180 
   181 void HWChatWidget::returnPressed()
   181 void HWChatWidget::returnPressed()
   182 {
   182 {
   183 	emit chatLine(chatEditLine->text());
   183     emit chatLine(chatEditLine->text());
   184 	chatEditLine->clear();
   184     chatEditLine->clear();
   185 }
   185 }
   186 
   186 
   187 void HWChatWidget::onChatString(const QString& str)
   187 void HWChatWidget::onChatString(const QString& str)
   188 {
   188 {
   189 	if (chatStrings.size() > 250)
   189     if (chatStrings.size() > 250)
   190 		chatStrings.removeFirst();
   190         chatStrings.removeFirst();
   191 
   191 
   192 	QString formattedStr = Qt::escape(str.mid(1));
   192     QString formattedStr = Qt::escape(str.mid(1));
   193 	QStringList parts = formattedStr.split(QRegExp("\\W+"), QString::SkipEmptyParts);
   193     QStringList parts = formattedStr.split(QRegExp("\\W+"), QString::SkipEmptyParts);
   194 
   194 
   195 	if (!formattedStr.startsWith(" ***")) // don't ignore status messages
   195     if (!formattedStr.startsWith(" ***")) // don't ignore status messages
   196 	{
   196     {
   197 		if (formattedStr.startsWith(" *")) // emote
   197         if (formattedStr.startsWith(" *")) // emote
   198 			parts[0] = parts[1];
   198             parts[0] = parts[1];
   199 		if(parts.size() > 0 && ignoreList.contains(parts[0], Qt::CaseInsensitive))
   199         if(parts.size() > 0 && ignoreList.contains(parts[0], Qt::CaseInsensitive))
   200 			return;
   200             return;
   201 	}
   201     }
   202 
   202 
   203 	QString color("");
   203     QString color("");
   204 	bool isFriend = friendsList.contains(parts[0], Qt::CaseInsensitive);
   204     bool isFriend = friendsList.contains(parts[0], Qt::CaseInsensitive);
   205 	
   205     
   206 	if (str.startsWith("\x03"))
   206     if (str.startsWith("\x03"))
   207 		color = QString("#c0c0c0");
   207         color = QString("#c0c0c0");
   208 	else if (str.startsWith("\x02"))
   208     else if (str.startsWith("\x02"))
   209 		color = QString(isFriend ? "#00ff00" : "#ff00ff");
   209         color = QString(isFriend ? "#00ff00" : "#ff00ff");
   210 	else if (isFriend)
   210     else if (isFriend)
   211 		color = QString("#00c000");
   211         color = QString("#00c000");
   212 
   212 
   213 	if(color.compare("") != 0)
   213     if(color.compare("") != 0)
   214 		formattedStr = QString("<font color=\"%2\">%1</font>").arg(formattedStr).arg(color);
   214         formattedStr = QString("<font color=\"%2\">%1</font>").arg(formattedStr).arg(color);
   215 
   215 
   216 	chatStrings.append(formattedStr);
   216     chatStrings.append(formattedStr);
   217 
   217 
   218 	chatText->setHtml(chatStrings.join("<br>"));
   218     chatText->setHtml(chatStrings.join("<br>"));
   219 
   219 
   220 	chatText->moveCursor(QTextCursor::End);
   220     chatText->moveCursor(QTextCursor::End);
   221 }
   221 }
   222 
   222 
   223 void HWChatWidget::onServerMessage(const QString& str)
   223 void HWChatWidget::onServerMessage(const QString& str)
   224 {
   224 {
   225 	if (chatStrings.size() > 250)
   225     if (chatStrings.size() > 250)
   226 		chatStrings.removeFirst();
   226         chatStrings.removeFirst();
   227 
   227 
   228 	chatStrings.append("<hr>" + str + "<hr>");
   228     chatStrings.append("<hr>" + str + "<hr>");
   229 
   229 
   230 	chatText->setHtml(chatStrings.join("<br>"));
   230     chatText->setHtml(chatStrings.join("<br>"));
   231 
   231 
   232 	chatText->moveCursor(QTextCursor::End);
   232     chatText->moveCursor(QTextCursor::End);
   233 }
   233 }
   234 
   234 
   235 void HWChatWidget::nickAdded(const QString& nick, bool notifyNick)
   235 void HWChatWidget::nickAdded(const QString& nick, bool notifyNick)
   236 {
   236 {
   237 	QListWidgetItem * item = new QListWidgetItem(nick);
   237     QListWidgetItem * item = new QListWidgetItem(nick);
   238 	updateIcon(item);
   238     updateIcon(item);
   239 	chatNicks->addItem(item);
   239     chatNicks->addItem(item);
   240 
   240 
   241     if(notifyNick && notify && gameSettings->value("audio/frontendsound", true).toBool()) {
   241     if(notifyNick && notify && gameSettings->value("audio/frontendsound", true).toBool()) {
   242        Mix_PlayChannel(-1, sound[rand()%4], 0);
   242        Mix_PlayChannel(-1, sound[rand()%4], 0);
   243     }
   243     }
   244 }
   244 }
   245 
   245 
   246 void HWChatWidget::nickRemoved(const QString& nick)
   246 void HWChatWidget::nickRemoved(const QString& nick)
   247 {
   247 {
   248 	QList<QListWidgetItem *> items = chatNicks->findItems(nick, Qt::MatchExactly);
   248     QList<QListWidgetItem *> items = chatNicks->findItems(nick, Qt::MatchExactly);
   249 	for(QList<QListWidgetItem *>::iterator it=items.begin(); it!=items.end();) {
   249     for(QList<QListWidgetItem *>::iterator it=items.begin(); it!=items.end();) {
   250 		chatNicks->takeItem(chatNicks->row(*it));
   250         chatNicks->takeItem(chatNicks->row(*it));
   251 		++it;
   251         ++it;
   252 	}
   252     }
   253 }
   253 }
   254 
   254 
   255 void HWChatWidget::clear()
   255 void HWChatWidget::clear()
   256 {
   256 {
   257 	chatText->clear();
   257     chatText->clear();
   258 	chatStrings.clear();
   258     chatStrings.clear();
   259 	chatNicks->clear();
   259     chatNicks->clear();
   260 }
   260 }
   261 
   261 
   262 void HWChatWidget::onKick()
   262 void HWChatWidget::onKick()
   263 {
   263 {
   264 	QListWidgetItem * curritem = chatNicks->currentItem();
   264     QListWidgetItem * curritem = chatNicks->currentItem();
   265 	if (curritem)
   265     if (curritem)
   266 		emit kick(curritem->text());
   266         emit kick(curritem->text());
   267 }
   267 }
   268 
   268 
   269 void HWChatWidget::onBan()
   269 void HWChatWidget::onBan()
   270 {
   270 {
   271 	QListWidgetItem * curritem = chatNicks->currentItem();
   271     QListWidgetItem * curritem = chatNicks->currentItem();
   272 	if (curritem)
   272     if (curritem)
   273 		emit ban(curritem->text());
   273         emit ban(curritem->text());
   274 }
   274 }
   275 
   275 
   276 void HWChatWidget::onInfo()
   276 void HWChatWidget::onInfo()
   277 {
   277 {
   278 	QListWidgetItem * curritem = chatNicks->currentItem();
   278     QListWidgetItem * curritem = chatNicks->currentItem();
   279 	if (curritem)
   279     if (curritem)
   280 		emit info(curritem->text());
   280         emit info(curritem->text());
   281 }
   281 }
   282 
   282 
   283 void HWChatWidget::onFollow()
   283 void HWChatWidget::onFollow()
   284 {
   284 {
   285 	QListWidgetItem * curritem = chatNicks->currentItem();
   285     QListWidgetItem * curritem = chatNicks->currentItem();
   286 	if (curritem)
   286     if (curritem)
   287 		emit follow(curritem->text());
   287         emit follow(curritem->text());
   288 }
   288 }
   289 
   289 
   290 void HWChatWidget::onIgnore()
   290 void HWChatWidget::onIgnore()
   291 {
   291 {
   292 	QListWidgetItem * curritem = chatNicks->currentItem();
   292     QListWidgetItem * curritem = chatNicks->currentItem();
   293 	if(!curritem)
   293     if(!curritem)
   294 		return;
   294         return;
   295 
   295 
   296 	if(ignoreList.contains(curritem->text(), Qt::CaseInsensitive)) // already on list - remove him
   296     if(ignoreList.contains(curritem->text(), Qt::CaseInsensitive)) // already on list - remove him
   297 	{
   297     {
   298 		ignoreList.removeAll(curritem->text().toLower());
   298         ignoreList.removeAll(curritem->text().toLower());
   299 		onChatString(HWChatWidget::tr("%1 *** %2 has been removed from your ignore list").arg('\x03').arg(curritem->text()));
   299         onChatString(HWChatWidget::tr("%1 *** %2 has been removed from your ignore list").arg('\x03').arg(curritem->text()));
   300 	}
   300     }
   301 	else // not on list - add
   301     else // not on list - add
   302 	{
   302     {
   303 		ignoreList << curritem->text().toLower();
   303         ignoreList << curritem->text().toLower();
   304 		onChatString(HWChatWidget::tr("%1 *** %2 has been added to your ignore list").arg('\x03').arg(curritem->text()));
   304         onChatString(HWChatWidget::tr("%1 *** %2 has been added to your ignore list").arg('\x03').arg(curritem->text()));
   305 	}
   305     }
   306 	updateIcon(curritem); // update icon
   306     updateIcon(curritem); // update icon
   307 	chatNickSelected(0); // update context menu
   307     chatNickSelected(0); // update context menu
   308 }
   308 }
   309 
   309 
   310 void HWChatWidget::onFriend()
   310 void HWChatWidget::onFriend()
   311 {
   311 {
   312 	QListWidgetItem * curritem = chatNicks->currentItem();
   312     QListWidgetItem * curritem = chatNicks->currentItem();
   313 	if(!curritem)
   313     if(!curritem)
   314 		return;
   314         return;
   315 
   315 
   316 	if(friendsList.contains(curritem->text(), Qt::CaseInsensitive)) // already on list - remove him
   316     if(friendsList.contains(curritem->text(), Qt::CaseInsensitive)) // already on list - remove him
   317 	{
   317     {
   318 		friendsList.removeAll(curritem->text().toLower());
   318         friendsList.removeAll(curritem->text().toLower());
   319 		onChatString(HWChatWidget::tr("%1 *** %2 has been removed from your friends list").arg('\x03').arg(curritem->text()));
   319         onChatString(HWChatWidget::tr("%1 *** %2 has been removed from your friends list").arg('\x03').arg(curritem->text()));
   320 	}
   320     }
   321 	else // not on list - add
   321     else // not on list - add
   322 	{
   322     {
   323 		friendsList << curritem->text().toLower();
   323         friendsList << curritem->text().toLower();
   324 		onChatString(HWChatWidget::tr("%1 *** %2 has been added to your friends list").arg('\x03').arg(curritem->text()));
   324         onChatString(HWChatWidget::tr("%1 *** %2 has been added to your friends list").arg('\x03').arg(curritem->text()));
   325 	}
   325     }
   326 	updateIcon(curritem); // update icon
   326     updateIcon(curritem); // update icon
   327 	chatNickSelected(0); // update context menu
   327     chatNickSelected(0); // update context menu
   328 }
   328 }
   329 
   329 
   330 void HWChatWidget::chatNickDoubleClicked(QListWidgetItem * item)
   330 void HWChatWidget::chatNickDoubleClicked(QListWidgetItem * item)
   331 {
   331 {
   332 	if (item) onFollow();
   332     if (item) onFollow();
   333 }
   333 }
   334 
   334 
   335 void HWChatWidget::chatNickSelected(int index)
   335 void HWChatWidget::chatNickSelected(int index)
   336 {
   336 {
   337 	QListWidgetItem* item = chatNicks->currentItem();
   337     QListWidgetItem* item = chatNicks->currentItem();
   338 	if (!item)
   338     if (!item)
   339 		return;
   339         return;
   340 
   340 
   341 	// update context menu labels according to possible action
   341     // update context menu labels according to possible action
   342 	if(ignoreList.contains(item->text(), Qt::CaseInsensitive))
   342     if(ignoreList.contains(item->text(), Qt::CaseInsensitive))
   343 		acIgnore->setText(QAction::tr("Unignore"));
   343         acIgnore->setText(QAction::tr("Unignore"));
   344 	else
   344     else
   345 		acIgnore->setText(QAction::tr("Ignore"));
   345         acIgnore->setText(QAction::tr("Ignore"));
   346 
   346 
   347 	if(friendsList.contains(item->text(), Qt::CaseInsensitive))
   347     if(friendsList.contains(item->text(), Qt::CaseInsensitive))
   348 		acFriend->setText(QAction::tr("Remove friend"));
   348         acFriend->setText(QAction::tr("Remove friend"));
   349 	else
   349     else
   350 		acFriend->setText(QAction::tr("Add friend"));
   350         acFriend->setText(QAction::tr("Add friend"));
   351 }
   351 }
   352 
   352 
   353 void HWChatWidget::setShowReady(bool s)
   353 void HWChatWidget::setShowReady(bool s)
   354 {
   354 {
   355 	showReady = s;
   355     showReady = s;
   356 }
   356 }
   357 
   357 
   358 void HWChatWidget::setReadyStatus(const QString & nick, bool isReady)
   358 void HWChatWidget::setReadyStatus(const QString & nick, bool isReady)
   359 {
   359 {
   360 	QList<QListWidgetItem *> items = chatNicks->findItems(nick, Qt::MatchExactly);
   360     QList<QListWidgetItem *> items = chatNicks->findItems(nick, Qt::MatchExactly);
   361 	if (items.size() != 1)
   361     if (items.size() != 1)
   362 	{
   362     {
   363 		qWarning("Bug: cannot find user in chat");
   363         qWarning("Bug: cannot find user in chat");
   364 		return;
   364         return;
   365 	}
   365     }
   366 
   366 
   367 	items[0]->setData(Qt::UserRole, isReady); // bulb status
   367     items[0]->setData(Qt::UserRole, isReady); // bulb status
   368 	updateIcon(items[0]);
   368     updateIcon(items[0]);
   369 
   369 
   370 	// ensure we're still showing the status bulbs
   370     // ensure we're still showing the status bulbs
   371 	showReady = true;
   371     showReady = true;
   372 }
   372 }
   373 
   373 
   374 void HWChatWidget::adminAccess(bool b)
   374 void HWChatWidget::adminAccess(bool b)
   375 {
   375 {
   376 	chatNicks->removeAction(acKick);
   376     chatNicks->removeAction(acKick);
   377 	chatNicks->removeAction(acBan);
   377     chatNicks->removeAction(acBan);
   378 
   378 
   379 	if(b)
   379     if(b)
   380 	{
   380     {
   381 		chatNicks->insertAction(0, acKick);
   381         chatNicks->insertAction(0, acKick);
   382 //		chatNicks->insertAction(0, acBan);
   382 //      chatNicks->insertAction(0, acBan);
   383 	}
   383     }
   384 }
   384 }