author | sheepluva |
Fri, 21 Oct 2011 18:53:36 +0200 | |
changeset 6170 | 2b1748161278 |
parent 6165 | 6fe3e922246e |
child 6180 | 0992fc5a4ad9 |
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> |
4976 | 4 |
* Copyright (c) 2007-2011 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 |
||
461 | 20 |
#ifndef _CHAT_WIDGET_INCLUDED |
21 |
#define _CHAT_WIDGET_INCLUDED |
|
22 |
||
23 |
#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
|
24 |
#include <QListWidget> |
461 | 25 |
#include <QString> |
26 |
#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
|
27 |
#include <QRegExp> |
461 | 28 |
|
6165
6fe3e922246e
moving and renaming SDLs.*, making it a singleton; cleaning up class responsibilties wrt SDLInteraction; some comments
sheepluva
parents:
6147
diff
changeset
|
29 |
#include "SDLInteraction.h" |
2775 | 30 |
|
6147
b4d7d8d62feb
feature-pimpin'-up the chat input line in frontend:
sheepluva
parents:
6060
diff
changeset
|
31 |
#include "SmartLineEdit.h" |
b4d7d8d62feb
feature-pimpin'-up the chat input line in frontend:
sheepluva
parents:
6060
diff
changeset
|
32 |
|
4876 | 33 |
class ListWidgetNickItem; |
1520
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1405
diff
changeset
|
34 |
class QTextBrowser; |
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1405
diff
changeset
|
35 |
class QLineEdit; |
461 | 36 |
class QListWidget; |
2773
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
37 |
class QSettings; |
461 | 38 |
|
6165
6fe3e922246e
moving and renaming SDLs.*, making it a singleton; cleaning up class responsibilties wrt SDLInteraction; some comments
sheepluva
parents:
6147
diff
changeset
|
39 |
/// This class is for custom nickname sorting |
4876 | 40 |
class ListWidgetNickItem : public QListWidgetItem |
41 |
{ |
|
42 |
public: |
|
4884 | 43 |
ListWidgetNickItem(const QString& nick, bool isFriend, bool isIgnored); |
4876 | 44 |
bool operator<(const QListWidgetItem & other) const; |
4884 | 45 |
void setFriend(bool isFriend); |
46 |
void setIgnored(bool isIgnored); |
|
47 |
bool isFriend(); |
|
48 |
bool ignored(); |
|
49 |
||
50 |
private: |
|
51 |
bool aFriend; |
|
52 |
bool isIgnored; |
|
4876 | 53 |
}; |
54 |
||
461 | 55 |
class HWChatWidget : public QWidget |
56 |
{ |
|
57 |
Q_OBJECT |
|
58 |
||
59 |
public: |
|
6165
6fe3e922246e
moving and renaming SDLs.*, making it a singleton; cleaning up class responsibilties wrt SDLInteraction; some comments
sheepluva
parents:
6147
diff
changeset
|
60 |
HWChatWidget(QWidget* parent, QSettings * gameSettings, bool notify); |
2845 | 61 |
void loadLists(const QString & nick); |
62 |
void saveLists(const QString & nick); |
|
63 |
void setShowReady(bool s); |
|
4892 | 64 |
void setShowFollow(bool enabled); |
5998
e8f44e9433f0
many many netclient/frondent changes (just the beginning though):
sheepluva
parents:
5259
diff
changeset
|
65 |
void addLine(const QString & cssClass, QString line); |
4897
11598e7aa7e6
make names in chats clickable. still color adjustments needed; and testing
sheepluva
parents:
4892
diff
changeset
|
66 |
static const char* STYLE; |
4958
84afe376a3b3
Autokick ignored players from game room on join. Needs testing.
nemo
parents:
4899
diff
changeset
|
67 |
QStringList ignoreList, friendsList; |
2845 | 68 |
|
69 |
private: |
|
70 |
void loadList(QStringList & list, const QString & file); |
|
71 |
void saveList(QStringList & list, const QString & file); |
|
4884 | 72 |
void updateNickItem(QListWidgetItem *item); |
73 |
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
|
74 |
static const QRegExp URLREGEXP; |
461 | 75 |
|
76 |
public slots: |
|
1360 | 77 |
void onChatString(const QString& str); |
4897
11598e7aa7e6
make names in chats clickable. still color adjustments needed; and testing
sheepluva
parents:
4892
diff
changeset
|
78 |
void onChatString(const QString& nick, const QString& str); |
1587 | 79 |
void onServerMessage(const QString& str); |
2777 | 80 |
void nickAdded(const QString& nick, bool notifyNick); |
465 | 81 |
void nickRemoved(const QString& nick); |
82 |
void clear(); |
|
1405 | 83 |
void setReadyStatus(const QString & nick, bool isReady); |
1860 | 84 |
void adminAccess(bool); |
461 | 85 |
|
86 |
signals: |
|
87 |
void chatLine(const QString& str); |
|
1391 | 88 |
void kick(const QString & str); |
1860 | 89 |
void ban(const QString & str); |
1577 | 90 |
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
|
91 |
void follow(const QString &); |
5259
926958e3e87b
display player count below and with label, just because it's funny to mess with unC0Rr's code and make him cry :P
sheepluva
parents:
5094
diff
changeset
|
92 |
void nickCountUpdate(int cnt); |
461 | 93 |
|
94 |
private: |
|
95 |
QGridLayout mainLayout; |
|
1520
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1405
diff
changeset
|
96 |
QTextBrowser* chatText; |
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1405
diff
changeset
|
97 |
QStringList chatStrings; |
462 | 98 |
QListWidget* chatNicks; |
6147
b4d7d8d62feb
feature-pimpin'-up the chat input line in frontend:
sheepluva
parents:
6060
diff
changeset
|
99 |
SmartLineEdit* chatEditLine; |
1860 | 100 |
QAction * acInfo; |
101 |
QAction * acKick; |
|
102 |
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
|
103 |
QAction * acFollow; |
2845 | 104 |
QAction * acIgnore; |
105 |
QAction * acFriend; |
|
2773
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
106 |
QSettings * gameSettings; |
6165
6fe3e922246e
moving and renaming SDLs.*, making it a singleton; cleaning up class responsibilties wrt SDLInteraction; some comments
sheepluva
parents:
6147
diff
changeset
|
107 |
QString helloSound; |
2775 | 108 |
bool notify; |
2845 | 109 |
bool showReady; |
461 | 110 |
|
111 |
private slots: |
|
112 |
void returnPressed(); |
|
1860 | 113 |
void onBan(); |
1391 | 114 |
void onKick(); |
1577 | 115 |
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
|
116 |
void onFollow(); |
2845 | 117 |
void onIgnore(); |
118 |
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
|
119 |
void chatNickDoubleClicked(QListWidgetItem * item); |
2847 | 120 |
void chatNickSelected(int index); |
4897
11598e7aa7e6
make names in chats clickable. still color adjustments needed; and testing
sheepluva
parents:
4892
diff
changeset
|
121 |
void linkClicked(const QUrl & link); |
461 | 122 |
}; |
123 |
||
124 |
#endif // _CHAT_WIDGET_INCLUDED |