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