author | sheepluva |
Sat, 29 Jan 2011 01:08:39 +0100 | |
changeset 4876 | 813ef4e8e385 |
parent 4560 | 5d6c7f88db73 |
child 4877 | 746ddd590dee |
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> |
3236
4ab3917d7d44
Update (c) lines to 2010 as unc0rr requested - they all had varying values so I just took the first year mentioned, then tacked on -2010
nemo
parents:
3123
diff
changeset
|
4 |
* Copyright (c) 2010 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 |
||
4876 | 35 |
ListWidgetNickItem::ListWidgetNickItem(const QString& nick) : QListWidgetItem(nick) {} |
36 |
||
37 |
bool ListWidgetNickItem::operator< (const QListWidgetItem & other) const |
|
38 |
{ |
|
39 |
// case in-sensitive comparison of the associated strings |
|
40 |
return (text().compare(other.text(), Qt::CaseInsensitive) < 0); |
|
41 |
} |
|
42 |
||
2775 | 43 |
HWChatWidget::HWChatWidget(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli, bool notify) : |
461 | 44 |
QWidget(parent), |
45 |
mainLayout(this) |
|
46 |
{ |
|
2773
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
47 |
this->gameSettings = gameSettings; |
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
48 |
this->sdli = sdli; |
2775 | 49 |
this->notify = notify; |
3019 | 50 |
if(notify && gameSettings->value("frontend/sound", true).toBool()) { |
2775 | 51 |
QDir tmpdir; |
52 |
||
53 |
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
|
54 |
tmpdir.cd("Sounds/voices"); |
2775 | 55 |
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
|
56 |
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
|
57 |
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
|
58 |
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
|
59 |
sound[3] = Mix_LoadWAV(QString(tmpdir.absolutePath() + "/Russian/Hello.ogg").toLocal8Bit().constData()); |
2775 | 60 |
} |
2773
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
61 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
62 |
mainLayout.setSpacing(1); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
63 |
mainLayout.setMargin(1); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
64 |
mainLayout.setSizeConstraint(QLayout::SetMinimumSize); |
3790 | 65 |
mainLayout.setColumnStretch(0, 76); |
66 |
mainLayout.setColumnStretch(1, 24); |
|
461 | 67 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
68 |
chatEditLine = new QLineEdit(this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
69 |
chatEditLine->setMaxLength(300); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
70 |
connect(chatEditLine, SIGNAL(returnPressed()), this, SLOT(returnPressed())); |
461 | 71 |
|
3790 | 72 |
mainLayout.addWidget(chatEditLine, 1, 0); |
462 | 73 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
74 |
chatText = new QTextBrowser(this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
75 |
chatText->setMinimumHeight(20); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
76 |
chatText->setMinimumWidth(10); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
77 |
chatText->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
78 |
chatText->setOpenExternalLinks(true); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
79 |
mainLayout.addWidget(chatText, 0, 0); |
462 | 80 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
81 |
chatNicks = new QListWidget(this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
82 |
chatNicks->setMinimumHeight(10); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
83 |
chatNicks->setMinimumWidth(10); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
84 |
chatNicks->setSortingEnabled(true); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
85 |
chatNicks->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
86 |
chatNicks->setContextMenuPolicy(Qt::ActionsContextMenu); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
87 |
connect(chatNicks, SIGNAL(itemDoubleClicked(QListWidgetItem *)), |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
88 |
this, SLOT(chatNickDoubleClicked(QListWidgetItem *))); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
89 |
connect(chatNicks, SIGNAL(currentRowChanged(int)), |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
90 |
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
|
91 |
|
3807 | 92 |
mainLayout.addWidget(chatNicks, 0, 1, -1, 1); |
1391 | 93 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
94 |
acInfo = new QAction(QAction::tr("Info"), chatNicks); |
3123 | 95 |
acInfo->setIcon(QIcon(":/res/info.png")); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
96 |
connect(acInfo, SIGNAL(triggered(bool)), this, SLOT(onInfo())); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
97 |
acKick = new QAction(QAction::tr("Kick"), chatNicks); |
3123 | 98 |
acKick->setIcon(QIcon(":/res/kick.png")); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
99 |
connect(acKick, SIGNAL(triggered(bool)), this, SLOT(onKick())); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
100 |
acBan = new QAction(QAction::tr("Ban"), chatNicks); |
3123 | 101 |
acBan->setIcon(QIcon(":/res/ban.png")); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
102 |
connect(acBan, SIGNAL(triggered(bool)), this, SLOT(onBan())); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
103 |
acFollow = new QAction(QAction::tr("Follow"), chatNicks); |
3123 | 104 |
acFollow->setIcon(QIcon(":/res/follow.png")); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
105 |
connect(acFollow, SIGNAL(triggered(bool)), this, SLOT(onFollow())); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
106 |
acIgnore = new QAction(QAction::tr("Ignore"), chatNicks); |
3123 | 107 |
acIgnore->setIcon(QIcon(":/res/ignore.png")); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
108 |
connect(acIgnore, SIGNAL(triggered(bool)), this, SLOT(onIgnore())); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
109 |
acFriend = new QAction(QAction::tr("Add friend"), chatNicks); |
3123 | 110 |
acFriend->setIcon(QIcon(":/res/addfriend.png")); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
111 |
connect(acFriend, SIGNAL(triggered(bool)), this, SLOT(onFriend())); |
2377 | 112 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
113 |
chatNicks->insertAction(0, acInfo); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
114 |
chatNicks->insertAction(0, acFollow); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
115 |
chatNicks->insertAction(0, acIgnore); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
116 |
chatNicks->insertAction(0, acFriend); |
3697 | 117 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
118 |
showReady = false; |
2845 | 119 |
} |
120 |
||
121 |
void HWChatWidget::loadList(QStringList & list, const QString & file) |
|
122 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
123 |
list.clear(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
124 |
QFile txt((cfgdir->absolutePath() + "/" + file).toLocal8Bit().constData()); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
125 |
if(!txt.open(QIODevice::ReadOnly)) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
126 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
127 |
QTextStream stream(&txt); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
128 |
stream.setCodec("UTF-8"); |
2845 | 129 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
130 |
while(!stream.atEnd()) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
131 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
132 |
QString str = stream.readLine(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
133 |
if(str.startsWith(";") || str.length() == 0) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
134 |
continue; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
135 |
list << str.trimmed(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
136 |
} |
3058 | 137 |
//readd once we require newer Qt than 4.4 |
138 |
//list.removeDuplicates(); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
139 |
txt.close(); |
2845 | 140 |
} |
141 |
||
142 |
void HWChatWidget::saveList(QStringList & list, const QString & file) |
|
143 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
144 |
QFile txt((cfgdir->absolutePath() + "/" + file).toLocal8Bit().constData()); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
145 |
if(!txt.open(QIODevice::WriteOnly | QIODevice::Truncate)) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
146 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
147 |
QTextStream stream(&txt); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
148 |
stream.setCodec("UTF-8"); |
2845 | 149 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
150 |
stream << "; this list is used by Hedgewars - do not edit it unless you know what you're doing!" << endl; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
151 |
for(int i = 0; i < list.size(); i++) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
152 |
stream << list[i] << endl; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
153 |
txt.close(); |
2845 | 154 |
} |
155 |
||
156 |
void HWChatWidget::updateIcon(QListWidgetItem *item) |
|
157 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
158 |
QString nick = item->text(); |
2845 | 159 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
160 |
if(ignoreList.contains(nick, Qt::CaseInsensitive)) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
161 |
{ |
3925
44b4218605f6
Missing file extensions for icons was screwing up Qt 4.7
nemo
parents:
3807
diff
changeset
|
162 |
item->setIcon(QIcon(showReady ? (item->data(Qt::UserRole).toBool() ? ":/res/chat_ignore_on.png" : ":/res/chat_ignore_off.png") : ":/res/chat_ignore.png")); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
163 |
item->setForeground(Qt::gray); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
164 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
165 |
else if(friendsList.contains(nick, Qt::CaseInsensitive)) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
166 |
{ |
3925
44b4218605f6
Missing file extensions for icons was screwing up Qt 4.7
nemo
parents:
3807
diff
changeset
|
167 |
item->setIcon(QIcon(showReady ? (item->data(Qt::UserRole).toBool() ? ":/res/chat_friend_on.png" : ":/res/chat_friend_off.png") : ":/res/chat_friend.png")); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
168 |
item->setForeground(Qt::green); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
169 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
170 |
else |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
171 |
{ |
3925
44b4218605f6
Missing file extensions for icons was screwing up Qt 4.7
nemo
parents:
3807
diff
changeset
|
172 |
item->setIcon(QIcon(showReady ? (item->data(Qt::UserRole).toBool() ? ":/res/chat_default_on.png" : ":/res/chat_default_off.png") : ":/res/chat_default.png")); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
173 |
item->setForeground(QBrush(QColor(0xff, 0xcc, 0x00))); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
174 |
} |
2845 | 175 |
} |
176 |
||
177 |
void HWChatWidget::updateIcons() |
|
178 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
179 |
for(int i = 0; i < chatNicks->count(); i++) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
180 |
updateIcon(chatNicks->item(i)); |
2845 | 181 |
} |
182 |
||
183 |
void HWChatWidget::loadLists(const QString & nick) |
|
184 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
185 |
loadList(ignoreList, nick.toLower() + "_ignore.txt"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
186 |
loadList(friendsList, nick.toLower() + "_friends.txt"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
187 |
updateIcons(); |
2845 | 188 |
} |
189 |
||
190 |
void HWChatWidget::saveLists(const QString & nick) |
|
191 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
192 |
saveList(ignoreList, nick.toLower() + "_ignore.txt"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
193 |
saveList(friendsList, nick.toLower() + "_friends.txt"); |
461 | 194 |
} |
195 |
||
196 |
void HWChatWidget::returnPressed() |
|
197 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
198 |
emit chatLine(chatEditLine->text()); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
199 |
chatEditLine->clear(); |
461 | 200 |
} |
2846 | 201 |
|
1360 | 202 |
void HWChatWidget::onChatString(const QString& str) |
461 | 203 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
204 |
if (chatStrings.size() > 250) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
205 |
chatStrings.removeFirst(); |
1626 | 206 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
207 |
QString formattedStr = Qt::escape(str.mid(1)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
208 |
QStringList parts = formattedStr.split(QRegExp("\\W+"), QString::SkipEmptyParts); |
2845 | 209 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
210 |
if (!formattedStr.startsWith(" ***")) // don't ignore status messages |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
211 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
212 |
if (formattedStr.startsWith(" *")) // emote |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
213 |
parts[0] = parts[1]; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
214 |
if(parts.size() > 0 && ignoreList.contains(parts[0], Qt::CaseInsensitive)) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
215 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
216 |
} |
2845 | 217 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
218 |
QString color(""); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
219 |
bool isFriend = friendsList.contains(parts[0], Qt::CaseInsensitive); |
3697 | 220 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
221 |
if (str.startsWith("\x03")) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
222 |
color = QString("#c0c0c0"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
223 |
else if (str.startsWith("\x02")) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
224 |
color = QString(isFriend ? "#00ff00" : "#ff00ff"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
225 |
else if (isFriend) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
226 |
color = QString("#00c000"); |
2396 | 227 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
228 |
if(color.compare("") != 0) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
229 |
formattedStr = QString("<font color=\"%2\">%1</font>").arg(formattedStr).arg(color); |
2377 | 230 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
231 |
chatStrings.append(formattedStr); |
2377 | 232 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
233 |
chatText->setHtml(chatStrings.join("<br>")); |
1587 | 234 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
235 |
chatText->moveCursor(QTextCursor::End); |
1587 | 236 |
} |
237 |
||
238 |
void HWChatWidget::onServerMessage(const QString& str) |
|
239 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
240 |
if (chatStrings.size() > 250) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
241 |
chatStrings.removeFirst(); |
2377 | 242 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
243 |
chatStrings.append("<hr>" + str + "<hr>"); |
2377 | 244 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
245 |
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
|
246 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
247 |
chatText->moveCursor(QTextCursor::End); |
461 | 248 |
} |
465 | 249 |
|
2777 | 250 |
void HWChatWidget::nickAdded(const QString& nick, bool notifyNick) |
465 | 251 |
{ |
4876 | 252 |
QListWidgetItem * item = new ListWidgetNickItem(nick); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
253 |
updateIcon(item); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
254 |
chatNicks->addItem(item); |
2773
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
255 |
|
3019 | 256 |
if(notifyNick && notify && gameSettings->value("frontend/sound", 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
|
257 |
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
|
258 |
} |
465 | 259 |
} |
260 |
||
261 |
void HWChatWidget::nickRemoved(const QString& nick) |
|
262 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
263 |
QList<QListWidgetItem *> items = chatNicks->findItems(nick, Qt::MatchExactly); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
264 |
for(QList<QListWidgetItem *>::iterator it=items.begin(); it!=items.end();) { |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
265 |
chatNicks->takeItem(chatNicks->row(*it)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
266 |
++it; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
267 |
} |
465 | 268 |
} |
269 |
||
270 |
void HWChatWidget::clear() |
|
271 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
272 |
chatText->clear(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
273 |
chatStrings.clear(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
274 |
chatNicks->clear(); |
465 | 275 |
} |
1391 | 276 |
|
277 |
void HWChatWidget::onKick() |
|
278 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
279 |
QListWidgetItem * curritem = chatNicks->currentItem(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
280 |
if (curritem) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
281 |
emit kick(curritem->text()); |
1391 | 282 |
} |
1405 | 283 |
|
1860 | 284 |
void HWChatWidget::onBan() |
285 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
286 |
QListWidgetItem * curritem = chatNicks->currentItem(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
287 |
if (curritem) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
288 |
emit ban(curritem->text()); |
1860 | 289 |
} |
290 |
||
1577 | 291 |
void HWChatWidget::onInfo() |
292 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
293 |
QListWidgetItem * curritem = chatNicks->currentItem(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
294 |
if (curritem) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
295 |
emit info(curritem->text()); |
1577 | 296 |
} |
297 |
||
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
|
298 |
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
|
299 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
300 |
QListWidgetItem * curritem = chatNicks->currentItem(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
301 |
if (curritem) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
302 |
emit follow(curritem->text()); |
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
|
303 |
} |
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
|
304 |
|
2845 | 305 |
void HWChatWidget::onIgnore() |
306 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
307 |
QListWidgetItem * curritem = chatNicks->currentItem(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
308 |
if(!curritem) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
309 |
return; |
2845 | 310 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
311 |
if(ignoreList.contains(curritem->text(), Qt::CaseInsensitive)) // already on list - remove him |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
312 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
313 |
ignoreList.removeAll(curritem->text().toLower()); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
314 |
onChatString(HWChatWidget::tr("%1 *** %2 has been removed from your ignore list").arg('\x03').arg(curritem->text())); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
315 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
316 |
else // not on list - add |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
317 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
318 |
ignoreList << curritem->text().toLower(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
319 |
onChatString(HWChatWidget::tr("%1 *** %2 has been added to your ignore list").arg('\x03').arg(curritem->text())); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
320 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
321 |
updateIcon(curritem); // update icon |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
322 |
chatNickSelected(0); // update context menu |
2845 | 323 |
} |
324 |
||
325 |
void HWChatWidget::onFriend() |
|
326 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
327 |
QListWidgetItem * curritem = chatNicks->currentItem(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
328 |
if(!curritem) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
329 |
return; |
2845 | 330 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
331 |
if(friendsList.contains(curritem->text(), Qt::CaseInsensitive)) // already on list - remove him |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
332 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
333 |
friendsList.removeAll(curritem->text().toLower()); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
334 |
onChatString(HWChatWidget::tr("%1 *** %2 has been removed from your friends list").arg('\x03').arg(curritem->text())); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
335 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
336 |
else // not on list - add |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
337 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
338 |
friendsList << curritem->text().toLower(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
339 |
onChatString(HWChatWidget::tr("%1 *** %2 has been added to your friends list").arg('\x03').arg(curritem->text())); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
340 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
341 |
updateIcon(curritem); // update icon |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
342 |
chatNickSelected(0); // update context menu |
2845 | 343 |
} |
344 |
||
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
|
345 |
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
|
346 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
347 |
if (item) onFollow(); |
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
|
348 |
} |
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
|
349 |
|
2847 | 350 |
void HWChatWidget::chatNickSelected(int index) |
2846 | 351 |
{ |
4560
5d6c7f88db73
- Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents:
3925
diff
changeset
|
352 |
Q_UNUSED(index); |
5d6c7f88db73
- Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents:
3925
diff
changeset
|
353 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
354 |
QListWidgetItem* item = chatNicks->currentItem(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
355 |
if (!item) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
356 |
return; |
2846 | 357 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
358 |
// update context menu labels according to possible action |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
359 |
if(ignoreList.contains(item->text(), Qt::CaseInsensitive)) |
3123 | 360 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
361 |
acIgnore->setText(QAction::tr("Unignore")); |
3123 | 362 |
acIgnore->setIcon(QIcon(":/res/unignore.png")); |
363 |
} |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
364 |
else |
3123 | 365 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
366 |
acIgnore->setText(QAction::tr("Ignore")); |
3123 | 367 |
acIgnore->setIcon(QIcon(":/res/ignore.png")); |
368 |
} |
|
2846 | 369 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
370 |
if(friendsList.contains(item->text(), Qt::CaseInsensitive)) |
3123 | 371 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
372 |
acFriend->setText(QAction::tr("Remove friend")); |
3123 | 373 |
acFriend->setIcon(QIcon(":/res/remfriend.png")); |
374 |
} |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
375 |
else |
3123 | 376 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
377 |
acFriend->setText(QAction::tr("Add friend")); |
3123 | 378 |
acFriend->setIcon(QIcon(":/res/addfriend.png")); |
379 |
} |
|
2846 | 380 |
} |
381 |
||
2845 | 382 |
void HWChatWidget::setShowReady(bool s) |
383 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
384 |
showReady = s; |
2845 | 385 |
} |
386 |
||
1405 | 387 |
void HWChatWidget::setReadyStatus(const QString & nick, bool isReady) |
388 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
389 |
QList<QListWidgetItem *> items = chatNicks->findItems(nick, Qt::MatchExactly); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
390 |
if (items.size() != 1) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
391 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
392 |
qWarning("Bug: cannot find user in chat"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
393 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
394 |
} |
1405 | 395 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
396 |
items[0]->setData(Qt::UserRole, isReady); // bulb status |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
397 |
updateIcon(items[0]); |
2845 | 398 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
399 |
// ensure we're still showing the status bulbs |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
400 |
showReady = true; |
1405 | 401 |
} |
1860 | 402 |
|
403 |
void HWChatWidget::adminAccess(bool b) |
|
404 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
405 |
chatNicks->removeAction(acKick); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
406 |
chatNicks->removeAction(acBan); |
2377 | 407 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
408 |
if(b) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
409 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
410 |
chatNicks->insertAction(0, acKick); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
411 |
// chatNicks->insertAction(0, acBan); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2847
diff
changeset
|
412 |
} |
1860 | 413 |
} |