author | nemo |
Fri, 26 Feb 2010 16:29:00 +0000 | |
changeset 2873 | e7acb0251a22 |
parent 2847 | cde320fd3122 |
child 2948 | 3f21a9dc93d0 |
permissions | -rw-r--r-- |
480 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
486 | 3 |
* Copyright (c) 2007 Igor Ulyanov <iulyanov@gmail.com> |
1577 | 4 |
* Copyright (c) 2009 Andrey Korotaev <unC0Rr@gmail.com> |
480 | 5 |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
|
7 |
* it under the terms of the GNU General Public License as published by |
|
8 |
* the Free Software Foundation; version 2 of the License |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
18 |
*/ |
|
19 |
||
1520
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1516
diff
changeset
|
20 |
#include <QTextBrowser> |
461 | 21 |
#include <QLineEdit> |
1391 | 22 |
#include <QAction> |
1577 | 23 |
#include <QApplication> |
1587 | 24 |
#include <QTextDocument> |
2773
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
25 |
#include <QDir> |
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
26 |
#include <QSettings> |
2845 | 27 |
#include <QFile> |
28 |
#include <QTextStream> |
|
461 | 29 |
|
2773
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
30 |
#include "hwconsts.h" |
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
31 |
#include "SDLs.h" |
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
32 |
#include "gameuiconfig.h" |
461 | 33 |
#include "chatwidget.h" |
34 |
||
2775 | 35 |
HWChatWidget::HWChatWidget(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli, bool notify) : |
461 | 36 |
QWidget(parent), |
37 |
mainLayout(this) |
|
38 |
{ |
|
2773
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
39 |
this->gameSettings = gameSettings; |
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
40 |
this->sdli = sdli; |
2775 | 41 |
this->notify = notify; |
2776 | 42 |
if(notify && gameSettings->value("audio/frontendsound", true).toBool()) { |
2775 | 43 |
QDir tmpdir; |
44 |
||
45 |
tmpdir.cd(datadir->absolutePath()); |
|
2779
e1ae0019d43f
Suggestion from Tiy. Use a random hi. Could maybe be shorter sounds, using the 4 shortest voicepacks already
nemo
parents:
2777
diff
changeset
|
46 |
tmpdir.cd("Sounds/voices"); |
2775 | 47 |
sdli->SDLMusicInit(); |
2779
e1ae0019d43f
Suggestion from Tiy. Use a random hi. Could maybe be shorter sounds, using the 4 shortest voicepacks already
nemo
parents:
2777
diff
changeset
|
48 |
sound[0] = Mix_LoadWAV(QString(tmpdir.absolutePath() + "/Classic/Hello.ogg").toLocal8Bit().constData()); |
e1ae0019d43f
Suggestion from Tiy. Use a random hi. Could maybe be shorter sounds, using the 4 shortest voicepacks already
nemo
parents:
2777
diff
changeset
|
49 |
sound[1] = Mix_LoadWAV(QString(tmpdir.absolutePath() + "/Default/Hello.ogg").toLocal8Bit().constData()); |
e1ae0019d43f
Suggestion from Tiy. Use a random hi. Could maybe be shorter sounds, using the 4 shortest voicepacks already
nemo
parents:
2777
diff
changeset
|
50 |
sound[2] = Mix_LoadWAV(QString(tmpdir.absolutePath() + "/Mobster/Hello.ogg").toLocal8Bit().constData()); |
e1ae0019d43f
Suggestion from Tiy. Use a random hi. Could maybe be shorter sounds, using the 4 shortest voicepacks already
nemo
parents:
2777
diff
changeset
|
51 |
sound[3] = Mix_LoadWAV(QString(tmpdir.absolutePath() + "/Russian/Hello.ogg").toLocal8Bit().constData()); |
2775 | 52 |
} |
2773
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
53 |
|
1577 | 54 |
mainLayout.setSpacing(1); |
55 |
mainLayout.setMargin(1); |
|
56 |
mainLayout.setSizeConstraint(QLayout::SetMinimumSize); |
|
57 |
mainLayout.setColumnStretch(0, 75); |
|
58 |
mainLayout.setColumnStretch(1, 25); |
|
461 | 59 |
|
1577 | 60 |
chatEditLine = new QLineEdit(this); |
61 |
chatEditLine->setMaxLength(300); |
|
62 |
connect(chatEditLine, SIGNAL(returnPressed()), this, SLOT(returnPressed())); |
|
461 | 63 |
|
1577 | 64 |
mainLayout.addWidget(chatEditLine, 1, 0, 1, 2); |
462 | 65 |
|
1577 | 66 |
chatText = new QTextBrowser(this); |
67 |
chatText->setMinimumHeight(20); |
|
68 |
chatText->setMinimumWidth(10); |
|
69 |
chatText->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
1589 | 70 |
chatText->setOpenExternalLinks(true); |
1577 | 71 |
mainLayout.addWidget(chatText, 0, 0); |
462 | 72 |
|
1577 | 73 |
chatNicks = new QListWidget(this); |
74 |
chatNicks->setMinimumHeight(10); |
|
75 |
chatNicks->setMinimumWidth(10); |
|
1666 | 76 |
chatNicks->setSortingEnabled(true); |
1577 | 77 |
chatNicks->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
78 |
chatNicks->setContextMenuPolicy(Qt::ActionsContextMenu); |
|
2706
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2428
diff
changeset
|
79 |
connect(chatNicks, SIGNAL(itemDoubleClicked(QListWidgetItem *)), |
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2428
diff
changeset
|
80 |
this, SLOT(chatNickDoubleClicked(QListWidgetItem *))); |
2847 | 81 |
connect(chatNicks, SIGNAL(currentRowChanged(int)), |
82 |
this, SLOT(chatNickSelected(int))); |
|
2706
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2428
diff
changeset
|
83 |
|
1577 | 84 |
mainLayout.addWidget(chatNicks, 0, 1); |
1391 | 85 |
|
1860 | 86 |
acInfo = new QAction(QAction::tr("Info"), chatNicks); |
1577 | 87 |
connect(acInfo, SIGNAL(triggered(bool)), this, SLOT(onInfo())); |
1860 | 88 |
acKick = new QAction(QAction::tr("Kick"), chatNicks); |
89 |
connect(acKick, SIGNAL(triggered(bool)), this, SLOT(onKick())); |
|
90 |
acBan = new QAction(QAction::tr("Ban"), chatNicks); |
|
91 |
connect(acBan, SIGNAL(triggered(bool)), this, SLOT(onBan())); |
|
2706
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2428
diff
changeset
|
92 |
acFollow = new QAction(QAction::tr("Follow"), chatNicks); |
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2428
diff
changeset
|
93 |
connect(acFollow, SIGNAL(triggered(bool)), this, SLOT(onFollow())); |
2845 | 94 |
acIgnore = new QAction(QAction::tr("Ignore"), chatNicks); |
95 |
connect(acIgnore, SIGNAL(triggered(bool)), this, SLOT(onIgnore())); |
|
2846 | 96 |
acFriend = new QAction(QAction::tr("Add friend"), chatNicks); |
2845 | 97 |
connect(acFriend, SIGNAL(triggered(bool)), this, SLOT(onFriend())); |
2377 | 98 |
|
1577 | 99 |
chatNicks->insertAction(0, acInfo); |
2706
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2428
diff
changeset
|
100 |
chatNicks->insertAction(0, acFollow); |
2845 | 101 |
chatNicks->insertAction(0, acIgnore); |
102 |
chatNicks->insertAction(0, acFriend); |
|
103 |
||
104 |
showReady = false; |
|
105 |
} |
|
106 |
||
107 |
void HWChatWidget::loadList(QStringList & list, const QString & file) |
|
108 |
{ |
|
109 |
list.clear(); |
|
110 |
QFile txt((cfgdir->absolutePath() + "/" + file).toLocal8Bit().constData()); |
|
111 |
if(!txt.open(QIODevice::ReadOnly)) |
|
112 |
return; |
|
113 |
QTextStream stream(&txt); |
|
114 |
stream.setCodec("UTF-8"); |
|
115 |
||
116 |
while(!stream.atEnd()) |
|
117 |
{ |
|
118 |
QString str = stream.readLine(); |
|
119 |
if(str.startsWith(";") || str.length() == 0) |
|
120 |
continue; |
|
121 |
list << str.trimmed(); |
|
122 |
} |
|
123 |
list.removeDuplicates(); |
|
124 |
txt.close(); |
|
125 |
} |
|
126 |
||
127 |
void HWChatWidget::saveList(QStringList & list, const QString & file) |
|
128 |
{ |
|
129 |
QFile txt((cfgdir->absolutePath() + "/" + file).toLocal8Bit().constData()); |
|
130 |
if(!txt.open(QIODevice::WriteOnly | QIODevice::Truncate)) |
|
131 |
return; |
|
132 |
QTextStream stream(&txt); |
|
133 |
stream.setCodec("UTF-8"); |
|
134 |
||
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++) |
|
137 |
stream << list[i] << endl; |
|
138 |
txt.close(); |
|
139 |
} |
|
140 |
||
141 |
void HWChatWidget::updateIcon(QListWidgetItem *item) |
|
142 |
{ |
|
143 |
QString nick = item->text(); |
|
144 |
||
145 |
if(ignoreList.contains(nick, Qt::CaseInsensitive)) |
|
146 |
{ |
|
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); |
|
149 |
} |
|
150 |
else if(friendsList.contains(nick, Qt::CaseInsensitive)) |
|
151 |
{ |
|
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); |
|
154 |
} |
|
155 |
else |
|
156 |
{ |
|
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))); |
|
159 |
} |
|
160 |
} |
|
161 |
||
162 |
void HWChatWidget::updateIcons() |
|
163 |
{ |
|
164 |
for(int i = 0; i < chatNicks->count(); i++) |
|
165 |
updateIcon(chatNicks->item(i)); |
|
166 |
} |
|
167 |
||
168 |
void HWChatWidget::loadLists(const QString & nick) |
|
169 |
{ |
|
170 |
loadList(ignoreList, nick.toLower() + "_ignore.txt"); |
|
171 |
loadList(friendsList, nick.toLower() + "_friends.txt"); |
|
172 |
updateIcons(); |
|
173 |
} |
|
174 |
||
175 |
void HWChatWidget::saveLists(const QString & nick) |
|
176 |
{ |
|
177 |
saveList(ignoreList, nick.toLower() + "_ignore.txt"); |
|
178 |
saveList(friendsList, nick.toLower() + "_friends.txt"); |
|
461 | 179 |
} |
180 |
||
181 |
void HWChatWidget::returnPressed() |
|
182 |
{ |
|
1577 | 183 |
emit chatLine(chatEditLine->text()); |
184 |
chatEditLine->clear(); |
|
461 | 185 |
} |
2846 | 186 |
|
1360 | 187 |
void HWChatWidget::onChatString(const QString& str) |
461 | 188 |
{ |
1520
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1516
diff
changeset
|
189 |
if (chatStrings.size() > 250) |
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1516
diff
changeset
|
190 |
chatStrings.removeFirst(); |
1626 | 191 |
|
2396 | 192 |
QString formattedStr = Qt::escape(str.mid(1)); |
2845 | 193 |
QStringList parts = formattedStr.split(QRegExp("\\W+"), QString::SkipEmptyParts); |
194 |
||
195 |
if (!formattedStr.startsWith(" ***")) // don't ignore status messages |
|
196 |
{ |
|
197 |
if (formattedStr.startsWith(" *")) // emote |
|
198 |
parts[0] = parts[1]; |
|
199 |
if(parts.size() > 0 && ignoreList.contains(parts[0], Qt::CaseInsensitive)) |
|
200 |
return; |
|
201 |
} |
|
202 |
||
203 |
QString color(""); |
|
204 |
bool isFriend = friendsList.contains(parts[0], Qt::CaseInsensitive); |
|
205 |
||
2396 | 206 |
if (str.startsWith("\x03")) |
2845 | 207 |
color = QString("#c0c0c0"); |
2396 | 208 |
else if (str.startsWith("\x02")) |
2845 | 209 |
color = QString(isFriend ? "#00ff00" : "#ff00ff"); |
210 |
else if (isFriend) |
|
211 |
color = QString("#00c000"); |
|
2396 | 212 |
|
2845 | 213 |
if(color.compare("") != 0) |
214 |
formattedStr = QString("<font color=\"%2\">%1</font>").arg(formattedStr).arg(color); |
|
2377 | 215 |
|
1626 | 216 |
chatStrings.append(formattedStr); |
2377 | 217 |
|
1587 | 218 |
chatText->setHtml(chatStrings.join("<br>")); |
219 |
||
220 |
chatText->moveCursor(QTextCursor::End); |
|
221 |
} |
|
222 |
||
223 |
void HWChatWidget::onServerMessage(const QString& str) |
|
224 |
{ |
|
225 |
if (chatStrings.size() > 250) |
|
226 |
chatStrings.removeFirst(); |
|
2377 | 227 |
|
1588 | 228 |
chatStrings.append("<hr>" + str + "<hr>"); |
2377 | 229 |
|
1584
90f6a5abad17
Save much space for chat widget on lobby page by removing server message widget (now this messages goes to chat)
unc0rr
parents:
1577
diff
changeset
|
230 |
chatText->setHtml(chatStrings.join("<br>")); |
1516
bb9fa5809c49
Limit chat history to 250 entries to avoid DoS attack with its use
unc0rr
parents:
1457
diff
changeset
|
231 |
|
1520
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1516
diff
changeset
|
232 |
chatText->moveCursor(QTextCursor::End); |
461 | 233 |
} |
465 | 234 |
|
2777 | 235 |
void HWChatWidget::nickAdded(const QString& nick, bool notifyNick) |
465 | 236 |
{ |
1391 | 237 |
QListWidgetItem * item = new QListWidgetItem(nick); |
2845 | 238 |
updateIcon(item); |
1391 | 239 |
chatNicks->addItem(item); |
2773
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
240 |
|
2777 | 241 |
if(notifyNick && notify && gameSettings->value("audio/frontendsound", true).toBool()) { |
2779
e1ae0019d43f
Suggestion from Tiy. Use a random hi. Could maybe be shorter sounds, using the 4 shortest voicepacks already
nemo
parents:
2777
diff
changeset
|
242 |
Mix_PlayChannel(-1, sound[rand()%4], 0); |
2773
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
243 |
} |
465 | 244 |
} |
245 |
||
246 |
void HWChatWidget::nickRemoved(const QString& nick) |
|
247 |
{ |
|
1520
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1516
diff
changeset
|
248 |
QList<QListWidgetItem *> items = chatNicks->findItems(nick, Qt::MatchExactly); |
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1516
diff
changeset
|
249 |
for(QList<QListWidgetItem *>::iterator it=items.begin(); it!=items.end();) { |
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1516
diff
changeset
|
250 |
chatNicks->takeItem(chatNicks->row(*it)); |
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1516
diff
changeset
|
251 |
++it; |
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1516
diff
changeset
|
252 |
} |
465 | 253 |
} |
254 |
||
255 |
void HWChatWidget::clear() |
|
256 |
{ |
|
1311 | 257 |
chatText->clear(); |
1520
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1516
diff
changeset
|
258 |
chatStrings.clear(); |
1311 | 259 |
chatNicks->clear(); |
465 | 260 |
} |
1391 | 261 |
|
262 |
void HWChatWidget::onKick() |
|
263 |
{ |
|
264 |
QListWidgetItem * curritem = chatNicks->currentItem(); |
|
265 |
if (curritem) |
|
266 |
emit kick(curritem->text()); |
|
267 |
} |
|
1405 | 268 |
|
1860 | 269 |
void HWChatWidget::onBan() |
270 |
{ |
|
271 |
QListWidgetItem * curritem = chatNicks->currentItem(); |
|
272 |
if (curritem) |
|
273 |
emit ban(curritem->text()); |
|
274 |
} |
|
275 |
||
1577 | 276 |
void HWChatWidget::onInfo() |
277 |
{ |
|
278 |
QListWidgetItem * curritem = chatNicks->currentItem(); |
|
279 |
if (curritem) |
|
280 |
emit info(curritem->text()); |
|
281 |
} |
|
282 |
||
2706
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2428
diff
changeset
|
283 |
void HWChatWidget::onFollow() |
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2428
diff
changeset
|
284 |
{ |
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2428
diff
changeset
|
285 |
QListWidgetItem * curritem = chatNicks->currentItem(); |
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2428
diff
changeset
|
286 |
if (curritem) |
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2428
diff
changeset
|
287 |
emit follow(curritem->text()); |
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2428
diff
changeset
|
288 |
} |
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2428
diff
changeset
|
289 |
|
2845 | 290 |
void HWChatWidget::onIgnore() |
291 |
{ |
|
292 |
QListWidgetItem * curritem = chatNicks->currentItem(); |
|
293 |
if(!curritem) |
|
294 |
return; |
|
295 |
||
296 |
if(ignoreList.contains(curritem->text(), Qt::CaseInsensitive)) // already on list - remove him |
|
297 |
{ |
|
298 |
ignoreList.removeAll(curritem->text().toLower()); |
|
299 |
onChatString(HWChatWidget::tr("%1 *** %2 has been removed from your ignore list").arg('\x03').arg(curritem->text())); |
|
300 |
} |
|
301 |
else // not on list - add |
|
302 |
{ |
|
303 |
ignoreList << curritem->text().toLower(); |
|
304 |
onChatString(HWChatWidget::tr("%1 *** %2 has been added to your ignore list").arg('\x03').arg(curritem->text())); |
|
305 |
} |
|
2847 | 306 |
updateIcon(curritem); // update icon |
307 |
chatNickSelected(0); // update context menu |
|
2845 | 308 |
} |
309 |
||
310 |
void HWChatWidget::onFriend() |
|
311 |
{ |
|
312 |
QListWidgetItem * curritem = chatNicks->currentItem(); |
|
313 |
if(!curritem) |
|
314 |
return; |
|
315 |
||
316 |
if(friendsList.contains(curritem->text(), Qt::CaseInsensitive)) // already on list - remove him |
|
317 |
{ |
|
318 |
friendsList.removeAll(curritem->text().toLower()); |
|
319 |
onChatString(HWChatWidget::tr("%1 *** %2 has been removed from your friends list").arg('\x03').arg(curritem->text())); |
|
320 |
} |
|
321 |
else // not on list - add |
|
322 |
{ |
|
323 |
friendsList << curritem->text().toLower(); |
|
324 |
onChatString(HWChatWidget::tr("%1 *** %2 has been added to your friends list").arg('\x03').arg(curritem->text())); |
|
325 |
} |
|
2847 | 326 |
updateIcon(curritem); // update icon |
327 |
chatNickSelected(0); // update context menu |
|
2845 | 328 |
} |
329 |
||
2706
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2428
diff
changeset
|
330 |
void HWChatWidget::chatNickDoubleClicked(QListWidgetItem * item) |
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2428
diff
changeset
|
331 |
{ |
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2428
diff
changeset
|
332 |
if (item) onFollow(); |
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2428
diff
changeset
|
333 |
} |
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2428
diff
changeset
|
334 |
|
2847 | 335 |
void HWChatWidget::chatNickSelected(int index) |
2846 | 336 |
{ |
2847 | 337 |
QListWidgetItem* item = chatNicks->currentItem(); |
2846 | 338 |
if (!item) |
339 |
return; |
|
340 |
||
341 |
// update context menu labels according to possible action |
|
342 |
if(ignoreList.contains(item->text(), Qt::CaseInsensitive)) |
|
343 |
acIgnore->setText(QAction::tr("Unignore")); |
|
344 |
else |
|
345 |
acIgnore->setText(QAction::tr("Ignore")); |
|
346 |
||
347 |
if(friendsList.contains(item->text(), Qt::CaseInsensitive)) |
|
348 |
acFriend->setText(QAction::tr("Remove friend")); |
|
349 |
else |
|
350 |
acFriend->setText(QAction::tr("Add friend")); |
|
351 |
} |
|
352 |
||
2845 | 353 |
void HWChatWidget::setShowReady(bool s) |
354 |
{ |
|
355 |
showReady = s; |
|
356 |
} |
|
357 |
||
1405 | 358 |
void HWChatWidget::setReadyStatus(const QString & nick, bool isReady) |
359 |
{ |
|
360 |
QList<QListWidgetItem *> items = chatNicks->findItems(nick, Qt::MatchExactly); |
|
361 |
if (items.size() != 1) |
|
362 |
{ |
|
363 |
qWarning("Bug: cannot find user in chat"); |
|
364 |
return; |
|
365 |
} |
|
366 |
||
2845 | 367 |
items[0]->setData(Qt::UserRole, isReady); // bulb status |
368 |
updateIcon(items[0]); |
|
369 |
||
370 |
// ensure we're still showing the status bulbs |
|
371 |
showReady = true; |
|
1405 | 372 |
} |
1860 | 373 |
|
374 |
void HWChatWidget::adminAccess(bool b) |
|
375 |
{ |
|
376 |
chatNicks->removeAction(acKick); |
|
377 |
chatNicks->removeAction(acBan); |
|
2377 | 378 |
|
1860 | 379 |
if(b) |
380 |
{ |
|
381 |
chatNicks->insertAction(0, acKick); |
|
1921 | 382 |
// chatNicks->insertAction(0, acBan); |
1860 | 383 |
} |
384 |
} |