author | unc0rr |
Wed, 09 Feb 2011 21:59:43 +0300 | |
changeset 4937 | 55b9145fea94 |
parent 4899 | 8163c9aaad0c |
child 4958 | 84afe376a3b3 |
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> |
|
4899
8163c9aaad0c
automatically convert hedgewars.org urls to actual links (in order to make support in the lobby/rooms easier
sheepluva
parents:
4897
diff
changeset
|
26 |
#include <QRegExp> |
461 | 27 |
|
2775 | 28 |
#include "SDLs.h" |
29 |
||
4876 | 30 |
class ListWidgetNickItem; |
1520
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1405
diff
changeset
|
31 |
class QTextBrowser; |
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1405
diff
changeset
|
32 |
class QLineEdit; |
461 | 33 |
class QListWidget; |
2773
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
34 |
class QSettings; |
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
35 |
class SDLInteraction; |
461 | 36 |
|
4876 | 37 |
// this class is for custom nick sorting |
38 |
class ListWidgetNickItem : public QListWidgetItem |
|
39 |
{ |
|
40 |
public: |
|
4884 | 41 |
ListWidgetNickItem(const QString& nick, bool isFriend, bool isIgnored); |
4876 | 42 |
bool operator<(const QListWidgetItem & other) const; |
4884 | 43 |
void setFriend(bool isFriend); |
44 |
void setIgnored(bool isIgnored); |
|
45 |
bool isFriend(); |
|
46 |
bool ignored(); |
|
47 |
||
48 |
private: |
|
49 |
bool aFriend; |
|
50 |
bool isIgnored; |
|
4876 | 51 |
}; |
52 |
||
461 | 53 |
class HWChatWidget : public QWidget |
54 |
{ |
|
55 |
Q_OBJECT |
|
56 |
||
57 |
public: |
|
2845 | 58 |
HWChatWidget(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli, bool notify); |
59 |
void loadLists(const QString & nick); |
|
60 |
void saveLists(const QString & nick); |
|
61 |
void setShowReady(bool s); |
|
4892 | 62 |
void setShowFollow(bool enabled); |
4897
11598e7aa7e6
make names in chats clickable. still color adjustments needed; and testing
sheepluva
parents:
4892
diff
changeset
|
63 |
static const char* STYLE; |
2845 | 64 |
|
65 |
private: |
|
66 |
void loadList(QStringList & list, const QString & file); |
|
67 |
void saveList(QStringList & list, const QString & file); |
|
4884 | 68 |
void updateNickItem(QListWidgetItem *item); |
69 |
void updateNickItems(); |
|
4899
8163c9aaad0c
automatically convert hedgewars.org urls to actual links (in order to make support in the lobby/rooms easier
sheepluva
parents:
4897
diff
changeset
|
70 |
static const QRegExp URLREGEXP; |
461 | 71 |
|
72 |
public slots: |
|
1360 | 73 |
void onChatString(const QString& str); |
4897
11598e7aa7e6
make names in chats clickable. still color adjustments needed; and testing
sheepluva
parents:
4892
diff
changeset
|
74 |
void onChatString(const QString& nick, const QString& str); |
1587 | 75 |
void onServerMessage(const QString& str); |
2777 | 76 |
void nickAdded(const QString& nick, bool notifyNick); |
465 | 77 |
void nickRemoved(const QString& nick); |
78 |
void clear(); |
|
1405 | 79 |
void setReadyStatus(const QString & nick, bool isReady); |
1860 | 80 |
void adminAccess(bool); |
461 | 81 |
|
82 |
signals: |
|
83 |
void chatLine(const QString& str); |
|
1391 | 84 |
void kick(const QString & str); |
1860 | 85 |
void ban(const QString & str); |
1577 | 86 |
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
|
87 |
void follow(const QString &); |
461 | 88 |
|
89 |
private: |
|
90 |
QGridLayout mainLayout; |
|
1520
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1405
diff
changeset
|
91 |
QTextBrowser* chatText; |
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1405
diff
changeset
|
92 |
QStringList chatStrings; |
2845 | 93 |
QStringList ignoreList, friendsList; |
462 | 94 |
QListWidget* chatNicks; |
461 | 95 |
QLineEdit* chatEditLine; |
1860 | 96 |
QAction * acInfo; |
97 |
QAction * acKick; |
|
98 |
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
|
99 |
QAction * acFollow; |
2845 | 100 |
QAction * acIgnore; |
101 |
QAction * acFriend; |
|
2773
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
102 |
QSettings * gameSettings; |
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
103 |
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
|
104 |
Mix_Chunk *sound[4]; |
2775 | 105 |
bool notify; |
2845 | 106 |
bool showReady; |
461 | 107 |
|
108 |
private slots: |
|
109 |
void returnPressed(); |
|
1860 | 110 |
void onBan(); |
1391 | 111 |
void onKick(); |
1577 | 112 |
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
|
113 |
void onFollow(); |
2845 | 114 |
void onIgnore(); |
115 |
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
|
116 |
void chatNickDoubleClicked(QListWidgetItem * item); |
2847 | 117 |
void chatNickSelected(int index); |
4897
11598e7aa7e6
make names in chats clickable. still color adjustments needed; and testing
sheepluva
parents:
4892
diff
changeset
|
118 |
void linkClicked(const QUrl & link); |
461 | 119 |
}; |
120 |
||
121 |
#endif // _CHAT_WIDGET_INCLUDED |