author | smxx |
Mon, 22 Feb 2010 22:51:21 +0000 | |
changeset 2845 | 19db164dd20d |
parent 2779 | e1ae0019d43f |
child 2846 | 1cb8b4c425ed |
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 *))); |
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
|
81 |
|
1577 | 82 |
mainLayout.addWidget(chatNicks, 0, 1); |
1391 | 83 |
|
1860 | 84 |
acInfo = new QAction(QAction::tr("Info"), chatNicks); |
1577 | 85 |
connect(acInfo, SIGNAL(triggered(bool)), this, SLOT(onInfo())); |
1860 | 86 |
acKick = new QAction(QAction::tr("Kick"), chatNicks); |
87 |
connect(acKick, SIGNAL(triggered(bool)), this, SLOT(onKick())); |
|
88 |
acBan = new QAction(QAction::tr("Ban"), chatNicks); |
|
89 |
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
|
90 |
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
|
91 |
connect(acFollow, SIGNAL(triggered(bool)), this, SLOT(onFollow())); |
2845 | 92 |
acIgnore = new QAction(QAction::tr("Ignore"), chatNicks); |
93 |
connect(acIgnore, SIGNAL(triggered(bool)), this, SLOT(onIgnore())); |
|
94 |
acFriend = new QAction(QAction::tr("Friend"), chatNicks); |
|
95 |
connect(acFriend, SIGNAL(triggered(bool)), this, SLOT(onFriend())); |
|
2377 | 96 |
|
1577 | 97 |
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
|
98 |
chatNicks->insertAction(0, acFollow); |
2845 | 99 |
chatNicks->insertAction(0, acIgnore); |
100 |
chatNicks->insertAction(0, acFriend); |
|
101 |
||
102 |
showReady = false; |
|
103 |
} |
|
104 |
||
105 |
void HWChatWidget::loadList(QStringList & list, const QString & file) |
|
106 |
{ |
|
107 |
list.clear(); |
|
108 |
QFile txt((cfgdir->absolutePath() + "/" + file).toLocal8Bit().constData()); |
|
109 |
if(!txt.open(QIODevice::ReadOnly)) |
|
110 |
return; |
|
111 |
QTextStream stream(&txt); |
|
112 |
stream.setCodec("UTF-8"); |
|
113 |
||
114 |
while(!stream.atEnd()) |
|
115 |
{ |
|
116 |
QString str = stream.readLine(); |
|
117 |
if(str.startsWith(";") || str.length() == 0) |
|
118 |
continue; |
|
119 |
list << str.trimmed(); |
|
120 |
} |
|
121 |
list.removeDuplicates(); |
|
122 |
txt.close(); |
|
123 |
} |
|
124 |
||
125 |
void HWChatWidget::saveList(QStringList & list, const QString & file) |
|
126 |
{ |
|
127 |
QFile txt((cfgdir->absolutePath() + "/" + file).toLocal8Bit().constData()); |
|
128 |
if(!txt.open(QIODevice::WriteOnly | QIODevice::Truncate)) |
|
129 |
return; |
|
130 |
QTextStream stream(&txt); |
|
131 |
stream.setCodec("UTF-8"); |
|
132 |
||
133 |
stream << "; this list is used by Hedgewars - do not edit it unless you know what you're doing!" << endl; |
|
134 |
for(int i = 0; i < list.size(); i++) |
|
135 |
stream << list[i] << endl; |
|
136 |
txt.close(); |
|
137 |
} |
|
138 |
||
139 |
void HWChatWidget::updateIcon(QListWidgetItem *item) |
|
140 |
{ |
|
141 |
QString nick = item->text(); |
|
142 |
||
143 |
if(ignoreList.contains(nick, Qt::CaseInsensitive)) |
|
144 |
{ |
|
145 |
item->setIcon(QIcon(showReady ? (item->data(Qt::UserRole).toBool() ? ":/res/chat_ignore_on" : ":/res/chat_ignore_off") : ":/res/chat_ignore.png")); |
|
146 |
item->setForeground(Qt::gray); |
|
147 |
} |
|
148 |
else if(friendsList.contains(nick, Qt::CaseInsensitive)) |
|
149 |
{ |
|
150 |
item->setIcon(QIcon(showReady ? (item->data(Qt::UserRole).toBool() ? ":/res/chat_friend_on" : ":/res/chat_friend_off") : ":/res/chat_friend.png")); |
|
151 |
item->setForeground(Qt::green); |
|
152 |
} |
|
153 |
else |
|
154 |
{ |
|
155 |
item->setIcon(QIcon(showReady ? (item->data(Qt::UserRole).toBool() ? ":/res/chat_default_on" : ":/res/chat_default_off") : ":/res/chat_default.png")); |
|
156 |
item->setForeground(QBrush(QColor(0xff, 0xcc, 0x00))); |
|
157 |
} |
|
158 |
} |
|
159 |
||
160 |
void HWChatWidget::updateIcons() |
|
161 |
{ |
|
162 |
for(int i = 0; i < chatNicks->count(); i++) |
|
163 |
updateIcon(chatNicks->item(i)); |
|
164 |
} |
|
165 |
||
166 |
void HWChatWidget::loadLists(const QString & nick) |
|
167 |
{ |
|
168 |
loadList(ignoreList, nick.toLower() + "_ignore.txt"); |
|
169 |
loadList(friendsList, nick.toLower() + "_friends.txt"); |
|
170 |
updateIcons(); |
|
171 |
} |
|
172 |
||
173 |
void HWChatWidget::saveLists(const QString & nick) |
|
174 |
{ |
|
175 |
saveList(ignoreList, nick.toLower() + "_ignore.txt"); |
|
176 |
saveList(friendsList, nick.toLower() + "_friends.txt"); |
|
461 | 177 |
} |
178 |
||
179 |
void HWChatWidget::returnPressed() |
|
180 |
{ |
|
1577 | 181 |
emit chatLine(chatEditLine->text()); |
182 |
chatEditLine->clear(); |
|
461 | 183 |
} |
2845 | 184 |
#include <QMessageBox> |
1360 | 185 |
void HWChatWidget::onChatString(const QString& str) |
461 | 186 |
{ |
1520
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1516
diff
changeset
|
187 |
if (chatStrings.size() > 250) |
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1516
diff
changeset
|
188 |
chatStrings.removeFirst(); |
1626 | 189 |
|
2396 | 190 |
QString formattedStr = Qt::escape(str.mid(1)); |
2845 | 191 |
QStringList parts = formattedStr.split(QRegExp("\\W+"), QString::SkipEmptyParts); |
192 |
||
193 |
if (!formattedStr.startsWith(" ***")) // don't ignore status messages |
|
194 |
{ |
|
195 |
if (formattedStr.startsWith(" *")) // emote |
|
196 |
parts[0] = parts[1]; |
|
197 |
if(parts.size() > 0 && ignoreList.contains(parts[0], Qt::CaseInsensitive)) |
|
198 |
return; |
|
199 |
} |
|
200 |
||
201 |
QString color(""); |
|
202 |
bool isFriend = friendsList.contains(parts[0], Qt::CaseInsensitive); |
|
203 |
||
2396 | 204 |
if (str.startsWith("\x03")) |
2845 | 205 |
color = QString("#c0c0c0"); |
2396 | 206 |
else if (str.startsWith("\x02")) |
2845 | 207 |
color = QString(isFriend ? "#00ff00" : "#ff00ff"); |
208 |
else if (isFriend) |
|
209 |
color = QString("#00c000"); |
|
2396 | 210 |
|
2845 | 211 |
if(color.compare("") != 0) |
212 |
formattedStr = QString("<font color=\"%2\">%1</font>").arg(formattedStr).arg(color); |
|
2377 | 213 |
|
1626 | 214 |
chatStrings.append(formattedStr); |
2377 | 215 |
|
1587 | 216 |
chatText->setHtml(chatStrings.join("<br>")); |
217 |
||
218 |
chatText->moveCursor(QTextCursor::End); |
|
219 |
} |
|
220 |
||
221 |
void HWChatWidget::onServerMessage(const QString& str) |
|
222 |
{ |
|
223 |
if (chatStrings.size() > 250) |
|
224 |
chatStrings.removeFirst(); |
|
2377 | 225 |
|
1588 | 226 |
chatStrings.append("<hr>" + str + "<hr>"); |
2377 | 227 |
|
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
|
228 |
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
|
229 |
|
1520
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1516
diff
changeset
|
230 |
chatText->moveCursor(QTextCursor::End); |
461 | 231 |
} |
465 | 232 |
|
2777 | 233 |
void HWChatWidget::nickAdded(const QString& nick, bool notifyNick) |
465 | 234 |
{ |
1391 | 235 |
QListWidgetItem * item = new QListWidgetItem(nick); |
2845 | 236 |
updateIcon(item); |
1391 | 237 |
chatNicks->addItem(item); |
2773
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
238 |
|
2777 | 239 |
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
|
240 |
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
|
241 |
} |
465 | 242 |
} |
243 |
||
244 |
void HWChatWidget::nickRemoved(const QString& nick) |
|
245 |
{ |
|
1520
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1516
diff
changeset
|
246 |
QList<QListWidgetItem *> items = chatNicks->findItems(nick, Qt::MatchExactly); |
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1516
diff
changeset
|
247 |
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
|
248 |
chatNicks->takeItem(chatNicks->row(*it)); |
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1516
diff
changeset
|
249 |
++it; |
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1516
diff
changeset
|
250 |
} |
465 | 251 |
} |
252 |
||
253 |
void HWChatWidget::clear() |
|
254 |
{ |
|
1311 | 255 |
chatText->clear(); |
1520
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1516
diff
changeset
|
256 |
chatStrings.clear(); |
1311 | 257 |
chatNicks->clear(); |
465 | 258 |
} |
1391 | 259 |
|
260 |
void HWChatWidget::onKick() |
|
261 |
{ |
|
262 |
QListWidgetItem * curritem = chatNicks->currentItem(); |
|
263 |
if (curritem) |
|
264 |
emit kick(curritem->text()); |
|
265 |
} |
|
1405 | 266 |
|
1860 | 267 |
void HWChatWidget::onBan() |
268 |
{ |
|
269 |
QListWidgetItem * curritem = chatNicks->currentItem(); |
|
270 |
if (curritem) |
|
271 |
emit ban(curritem->text()); |
|
272 |
} |
|
273 |
||
1577 | 274 |
void HWChatWidget::onInfo() |
275 |
{ |
|
276 |
QListWidgetItem * curritem = chatNicks->currentItem(); |
|
277 |
if (curritem) |
|
278 |
emit info(curritem->text()); |
|
279 |
} |
|
280 |
||
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
|
281 |
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
|
282 |
{ |
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 |
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
|
284 |
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
|
285 |
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
|
286 |
} |
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 |
|
2845 | 288 |
void HWChatWidget::onIgnore() |
289 |
{ |
|
290 |
QListWidgetItem * curritem = chatNicks->currentItem(); |
|
291 |
if(!curritem) |
|
292 |
return; |
|
293 |
||
294 |
if(ignoreList.contains(curritem->text(), Qt::CaseInsensitive)) // already on list - remove him |
|
295 |
{ |
|
296 |
ignoreList.removeAll(curritem->text().toLower()); |
|
297 |
onChatString(HWChatWidget::tr("%1 *** %2 has been removed from your ignore list").arg('\x03').arg(curritem->text())); |
|
298 |
} |
|
299 |
else // not on list - add |
|
300 |
{ |
|
301 |
ignoreList << curritem->text().toLower(); |
|
302 |
onChatString(HWChatWidget::tr("%1 *** %2 has been added to your ignore list").arg('\x03').arg(curritem->text())); |
|
303 |
} |
|
304 |
updateIcon(curritem); |
|
305 |
} |
|
306 |
||
307 |
void HWChatWidget::onFriend() |
|
308 |
{ |
|
309 |
QListWidgetItem * curritem = chatNicks->currentItem(); |
|
310 |
if(!curritem) |
|
311 |
return; |
|
312 |
||
313 |
if(friendsList.contains(curritem->text(), Qt::CaseInsensitive)) // already on list - remove him |
|
314 |
{ |
|
315 |
friendsList.removeAll(curritem->text().toLower()); |
|
316 |
onChatString(HWChatWidget::tr("%1 *** %2 has been removed from your friends list").arg('\x03').arg(curritem->text())); |
|
317 |
} |
|
318 |
else // not on list - add |
|
319 |
{ |
|
320 |
friendsList << curritem->text().toLower(); |
|
321 |
onChatString(HWChatWidget::tr("%1 *** %2 has been added to your friends list").arg('\x03').arg(curritem->text())); |
|
322 |
} |
|
323 |
updateIcon(curritem); |
|
324 |
} |
|
325 |
||
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
|
326 |
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
|
327 |
{ |
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
|
328 |
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
|
329 |
} |
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 |
|
2845 | 331 |
void HWChatWidget::setShowReady(bool s) |
332 |
{ |
|
333 |
showReady = s; |
|
334 |
} |
|
335 |
||
1405 | 336 |
void HWChatWidget::setReadyStatus(const QString & nick, bool isReady) |
337 |
{ |
|
338 |
QList<QListWidgetItem *> items = chatNicks->findItems(nick, Qt::MatchExactly); |
|
339 |
if (items.size() != 1) |
|
340 |
{ |
|
341 |
qWarning("Bug: cannot find user in chat"); |
|
342 |
return; |
|
343 |
} |
|
344 |
||
2845 | 345 |
/*if(isReady) |
1457 | 346 |
items[0]->setIcon(QIcon(":/res/lightbulb_on.png")); |
1405 | 347 |
else |
2845 | 348 |
items[0]->setIcon(QIcon(":/res/lightbulb_off.png"));*/ |
349 |
||
350 |
items[0]->setData(Qt::UserRole, isReady); // bulb status |
|
351 |
updateIcon(items[0]); |
|
352 |
||
353 |
// ensure we're still showing the status bulbs |
|
354 |
showReady = true; |
|
1405 | 355 |
} |
1860 | 356 |
|
357 |
void HWChatWidget::adminAccess(bool b) |
|
358 |
{ |
|
359 |
chatNicks->removeAction(acKick); |
|
360 |
chatNicks->removeAction(acBan); |
|
2377 | 361 |
|
1860 | 362 |
if(b) |
363 |
{ |
|
364 |
chatNicks->insertAction(0, acKick); |
|
1921 | 365 |
// chatNicks->insertAction(0, acBan); |
1860 | 366 |
} |
367 |
} |