author | Henek |
Mon, 31 Jan 2011 21:59:59 +0100 | |
changeset 4893 | 353781305c07 |
parent 4892 | b0610081ee95 |
child 4897 | 11598e7aa7e6 |
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> |
480 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*/ |
|
18 |
||
461 | 19 |
#ifndef _CHAT_WIDGET_INCLUDED |
20 |
#define _CHAT_WIDGET_INCLUDED |
|
21 |
||
22 |
#include <QWidget> |
|
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:
1860
diff
changeset
|
23 |
#include <QListWidget> |
461 | 24 |
#include <QString> |
25 |
#include <QGridLayout> |
|
26 |
||
2775 | 27 |
#include "SDLs.h" |
28 |
||
4876 | 29 |
class ListWidgetNickItem; |
1520
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1405
diff
changeset
|
30 |
class QTextBrowser; |
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1405
diff
changeset
|
31 |
class QLineEdit; |
461 | 32 |
class QListWidget; |
2773
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
33 |
class QSettings; |
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
34 |
class SDLInteraction; |
461 | 35 |
|
4876 | 36 |
// this class is for custom nick sorting |
37 |
class ListWidgetNickItem : public QListWidgetItem |
|
38 |
{ |
|
39 |
public: |
|
4884 | 40 |
ListWidgetNickItem(const QString& nick, bool isFriend, bool isIgnored); |
4876 | 41 |
bool operator<(const QListWidgetItem & other) const; |
4884 | 42 |
void setFriend(bool isFriend); |
43 |
void setIgnored(bool isIgnored); |
|
44 |
bool isFriend(); |
|
45 |
bool ignored(); |
|
46 |
||
47 |
private: |
|
48 |
bool aFriend; |
|
49 |
bool isIgnored; |
|
4876 | 50 |
}; |
51 |
||
461 | 52 |
class HWChatWidget : public QWidget |
53 |
{ |
|
54 |
Q_OBJECT |
|
55 |
||
56 |
public: |
|
2845 | 57 |
HWChatWidget(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli, bool notify); |
58 |
void loadLists(const QString & nick); |
|
59 |
void saveLists(const QString & nick); |
|
60 |
void setShowReady(bool s); |
|
4892 | 61 |
void setShowFollow(bool enabled); |
2845 | 62 |
|
63 |
private: |
|
64 |
void loadList(QStringList & list, const QString & file); |
|
65 |
void saveList(QStringList & list, const QString & file); |
|
4884 | 66 |
void updateNickItem(QListWidgetItem *item); |
67 |
void updateNickItems(); |
|
461 | 68 |
|
69 |
public slots: |
|
1360 | 70 |
void onChatString(const QString& str); |
1587 | 71 |
void onServerMessage(const QString& str); |
2777 | 72 |
void nickAdded(const QString& nick, bool notifyNick); |
465 | 73 |
void nickRemoved(const QString& nick); |
74 |
void clear(); |
|
1405 | 75 |
void setReadyStatus(const QString & nick, bool isReady); |
1860 | 76 |
void adminAccess(bool); |
461 | 77 |
|
78 |
signals: |
|
79 |
void chatLine(const QString& str); |
|
1391 | 80 |
void kick(const QString & str); |
1860 | 81 |
void ban(const QString & str); |
1577 | 82 |
void info(const QString & str); |
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:
1860
diff
changeset
|
83 |
void follow(const QString &); |
461 | 84 |
|
85 |
private: |
|
86 |
QGridLayout mainLayout; |
|
1520
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1405
diff
changeset
|
87 |
QTextBrowser* chatText; |
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1405
diff
changeset
|
88 |
QStringList chatStrings; |
2845 | 89 |
QStringList ignoreList, friendsList; |
462 | 90 |
QListWidget* chatNicks; |
461 | 91 |
QLineEdit* chatEditLine; |
1860 | 92 |
QAction * acInfo; |
93 |
QAction * acKick; |
|
94 |
QAction * acBan; |
|
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:
1860
diff
changeset
|
95 |
QAction * acFollow; |
2845 | 96 |
QAction * acIgnore; |
97 |
QAction * acFriend; |
|
2773
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
98 |
QSettings * gameSettings; |
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
99 |
SDLInteraction * sdli; |
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
|
100 |
Mix_Chunk *sound[4]; |
2775 | 101 |
bool notify; |
2845 | 102 |
bool showReady; |
461 | 103 |
|
104 |
private slots: |
|
105 |
void returnPressed(); |
|
1860 | 106 |
void onBan(); |
1391 | 107 |
void onKick(); |
1577 | 108 |
void onInfo(); |
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:
1860
diff
changeset
|
109 |
void onFollow(); |
2845 | 110 |
void onIgnore(); |
111 |
void onFriend(); |
|
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:
1860
diff
changeset
|
112 |
void chatNickDoubleClicked(QListWidgetItem * item); |
2847 | 113 |
void chatNickSelected(int index); |
461 | 114 |
}; |
115 |
||
116 |
#endif // _CHAT_WIDGET_INCLUDED |