author | unc0rr |
Thu, 27 Oct 2011 21:33:18 +0400 | |
changeset 6217 | ef53ba841791 |
parent 6214 | c06b7e2eb7a4 |
child 6222 | 96d10dcd6d84 |
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> |
|
6214 | 27 |
#include <QList> |
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
|
28 |
#include <QRegExp> |
461 | 29 |
|
6165
6fe3e922246e
moving and renaming SDLs.*, making it a singleton; cleaning up class responsibilties wrt SDLInteraction; some comments
sheepluva
parents:
6147
diff
changeset
|
30 |
#include "SDLInteraction.h" |
2775 | 31 |
|
6147
b4d7d8d62feb
feature-pimpin'-up the chat input line in frontend:
sheepluva
parents:
6060
diff
changeset
|
32 |
#include "SmartLineEdit.h" |
b4d7d8d62feb
feature-pimpin'-up the chat input line in frontend:
sheepluva
parents:
6060
diff
changeset
|
33 |
|
4876 | 34 |
class ListWidgetNickItem; |
1520
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1405
diff
changeset
|
35 |
class QTextBrowser; |
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1405
diff
changeset
|
36 |
class QLineEdit; |
461 | 37 |
class QListWidget; |
2773
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
38 |
class QSettings; |
461 | 39 |
|
6200 | 40 |
/// Class for custom nickname sorting |
4876 | 41 |
class ListWidgetNickItem : public QListWidgetItem |
42 |
{ |
|
43 |
public: |
|
4884 | 44 |
ListWidgetNickItem(const QString& nick, bool isFriend, bool isIgnored); |
4876 | 45 |
bool operator<(const QListWidgetItem & other) const; |
4884 | 46 |
void setFriend(bool isFriend); |
47 |
void setIgnored(bool isIgnored); |
|
48 |
bool isFriend(); |
|
49 |
bool ignored(); |
|
50 |
||
51 |
private: |
|
52 |
bool aFriend; |
|
53 |
bool isIgnored; |
|
4876 | 54 |
}; |
55 |
||
6185 | 56 |
|
57 |
/** |
|
6200 | 58 |
* @brief Chat widget. |
6185 | 59 |
* |
60 |
* By default uses :res/css/chat.css as style sheet for chat. |
|
61 |
* See \repo{res/css/chat.css} for a more detailed description. |
|
62 |
* |
|
63 |
* @see http://doc.qt.nokia.com/4.5/richtext-html-subset.html#css-properties |
|
64 |
*/ |
|
65 |
||
461 | 66 |
class HWChatWidget : public QWidget |
67 |
{ |
|
68 |
Q_OBJECT |
|
69 |
||
70 |
public: |
|
6165
6fe3e922246e
moving and renaming SDLs.*, making it a singleton; cleaning up class responsibilties wrt SDLInteraction; some comments
sheepluva
parents:
6147
diff
changeset
|
71 |
HWChatWidget(QWidget* parent, QSettings * gameSettings, bool notify); |
2845 | 72 |
void loadLists(const QString & nick); |
73 |
void saveLists(const QString & nick); |
|
74 |
void setShowReady(bool s); |
|
4892 | 75 |
void setShowFollow(bool enabled); |
4958
84afe376a3b3
Autokick ignored players from game room on join. Needs testing.
nemo
parents:
4899
diff
changeset
|
76 |
QStringList ignoreList, friendsList; |
6201
d88e7f6cf499
fix of /saveStyleSheet command, error message on stylesheet import fail
sheepluva
parents:
6200
diff
changeset
|
77 |
static const QString & styleSheet(); |
6180
0992fc5a4ad9
some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents:
6165
diff
changeset
|
78 |
void displayError(const QString & message); |
0992fc5a4ad9
some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents:
6165
diff
changeset
|
79 |
void displayNotice(const QString & message); |
0992fc5a4ad9
some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents:
6165
diff
changeset
|
80 |
void displayWarning(const QString & message); |
2845 | 81 |
|
6197 | 82 |
protected: |
83 |
virtual void dragEnterEvent(QDragEnterEvent * event); |
|
84 |
virtual void dropEvent(QDropEvent * event); |
|
85 |
||
2845 | 86 |
private: |
6180
0992fc5a4ad9
some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents:
6165
diff
changeset
|
87 |
static QString * s_styleSheet; |
0992fc5a4ad9
some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents:
6165
diff
changeset
|
88 |
static QStringList * s_displayNone; |
6197 | 89 |
static bool s_isTimeStamped; |
90 |
static const QRegExp URLREGEXP; |
|
91 |
||
92 |
static void setStyleSheet(const QString & styleSheet = ""); |
|
6180
0992fc5a4ad9
some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents:
6165
diff
changeset
|
93 |
|
2845 | 94 |
void loadList(QStringList & list, const QString & file); |
95 |
void saveList(QStringList & list, const QString & file); |
|
4884 | 96 |
void updateNickItem(QListWidgetItem *item); |
97 |
void updateNickItems(); |
|
6182
d56d18802481
some more chat fixes and changes, I think. hum. what was that? um. aaah, I better go catch some sheep ... er sleep.. um..
sheepluva
parents:
6180
diff
changeset
|
98 |
void addLine(const QString & cssClass, QString line, bool isHighlight = false); |
6197 | 99 |
bool parseCommand(const QString & line); |
100 |
void discardStyleSheet(); |
|
101 |
void saveStyleSheet(); |
|
461 | 102 |
|
103 |
public slots: |
|
1360 | 104 |
void onChatString(const QString& str); |
4897
11598e7aa7e6
make names in chats clickable. still color adjustments needed; and testing
sheepluva
parents:
4892
diff
changeset
|
105 |
void onChatString(const QString& nick, const QString& str); |
1587 | 106 |
void onServerMessage(const QString& str); |
2777 | 107 |
void nickAdded(const QString& nick, bool notifyNick); |
465 | 108 |
void nickRemoved(const QString& nick); |
109 |
void clear(); |
|
1405 | 110 |
void setReadyStatus(const QString & nick, bool isReady); |
1860 | 111 |
void adminAccess(bool); |
461 | 112 |
|
113 |
signals: |
|
114 |
void chatLine(const QString& str); |
|
1391 | 115 |
void kick(const QString & str); |
1860 | 116 |
void ban(const QString & str); |
1577 | 117 |
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
|
118 |
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
|
119 |
void nickCountUpdate(int cnt); |
461 | 120 |
|
121 |
private: |
|
122 |
QGridLayout mainLayout; |
|
1520
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1405
diff
changeset
|
123 |
QTextBrowser* chatText; |
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1405
diff
changeset
|
124 |
QStringList chatStrings; |
462 | 125 |
QListWidget* chatNicks; |
6147
b4d7d8d62feb
feature-pimpin'-up the chat input line in frontend:
sheepluva
parents:
6060
diff
changeset
|
126 |
SmartLineEdit* chatEditLine; |
1860 | 127 |
QAction * acInfo; |
128 |
QAction * acKick; |
|
129 |
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
|
130 |
QAction * acFollow; |
2845 | 131 |
QAction * acIgnore; |
132 |
QAction * acFriend; |
|
2773
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
133 |
QSettings * gameSettings; |
6182
d56d18802481
some more chat fixes and changes, I think. hum. what was that? um. aaah, I better go catch some sheep ... er sleep.. um..
sheepluva
parents:
6180
diff
changeset
|
134 |
QString m_helloSound; |
d56d18802481
some more chat fixes and changes, I think. hum. what was that? um. aaah, I better go catch some sheep ... er sleep.. um..
sheepluva
parents:
6180
diff
changeset
|
135 |
QString m_hilightSound; |
d56d18802481
some more chat fixes and changes, I think. hum. what was that? um. aaah, I better go catch some sheep ... er sleep.. um..
sheepluva
parents:
6180
diff
changeset
|
136 |
QString m_userNick; |
6214 | 137 |
QList<QRegExp> m_highlights; ///< regular expressions used for highlighting |
2775 | 138 |
bool notify; |
2845 | 139 |
bool showReady; |
461 | 140 |
|
141 |
private slots: |
|
142 |
void returnPressed(); |
|
1860 | 143 |
void onBan(); |
1391 | 144 |
void onKick(); |
1577 | 145 |
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
|
146 |
void onFollow(); |
2845 | 147 |
void onIgnore(); |
148 |
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
|
149 |
void chatNickDoubleClicked(QListWidgetItem * item); |
2847 | 150 |
void chatNickSelected(int index); |
4897
11598e7aa7e6
make names in chats clickable. still color adjustments needed; and testing
sheepluva
parents:
4892
diff
changeset
|
151 |
void linkClicked(const QUrl & link); |
461 | 152 |
}; |
153 |
||
154 |
#endif // _CHAT_WIDGET_INCLUDED |