author | unc0rr |
Sun, 27 Jan 2013 21:46:25 +0400 | |
changeset 8451 | 8c7da08df048 |
parent 8430 | 5a5c34a75e1a |
child 8759 | 1a4b9b9fe2b0 |
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> |
6952 | 4 |
* Copyright (c) 2004-2012 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> |
|
24 |
#include <QString> |
|
25 |
#include <QGridLayout> |
|
6214 | 26 |
#include <QList> |
6229
4c834af76c3b
* fix highlighting (i just broke it by not negating a boolean expression)
sheepluva
parents:
6227
diff
changeset
|
27 |
#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
|
28 |
#include <QRegExp> |
7720 | 29 |
#include <QHash> |
7723 | 30 |
#include <QListWidgetItem> |
461 | 31 |
|
6165
6fe3e922246e
moving and renaming SDLs.*, making it a singleton; cleaning up class responsibilties wrt SDLInteraction; some comments
sheepluva
parents:
6147
diff
changeset
|
32 |
#include "SDLInteraction.h" |
2775 | 33 |
|
6147
b4d7d8d62feb
feature-pimpin'-up the chat input line in frontend:
sheepluva
parents:
6060
diff
changeset
|
34 |
#include "SmartLineEdit.h" |
b4d7d8d62feb
feature-pimpin'-up the chat input line in frontend:
sheepluva
parents:
6060
diff
changeset
|
35 |
|
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; |
7723 | 38 |
class QListView; |
2773
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
39 |
class QSettings; |
7725 | 40 |
class QAbstractItemModel; |
7740 | 41 |
class QMenu; |
461 | 42 |
|
6185 | 43 |
/** |
6200 | 44 |
* @brief Chat widget. |
6185 | 45 |
* |
46 |
* By default uses :res/css/chat.css as style sheet for chat. |
|
47 |
* See \repo{res/css/chat.css} for a more detailed description. |
|
48 |
* |
|
49 |
* @see http://doc.qt.nokia.com/4.5/richtext-html-subset.html#css-properties |
|
50 |
*/ |
|
51 |
||
461 | 52 |
class HWChatWidget : public QWidget |
53 |
{ |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
54 |
Q_OBJECT |
461 | 55 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
56 |
public: |
8179
a1ffcb559f99
Refactor: get rid of excessive QSettings instances on the same poor hedgewars.ini file
unc0rr
parents:
7742
diff
changeset
|
57 |
HWChatWidget(QWidget* parent, bool notify); |
6929
c305d31642ac
reimplement auto-kick for ignored players (it was temporarily removed during refactoring)
sheepluva
parents:
6928
diff
changeset
|
58 |
void setIgnoreListKick(bool enabled); ///< automatically kick people on ignore list (if possible) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
59 |
void setShowFollow(bool enabled); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
60 |
static const QString & styleSheet(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
61 |
void displayError(const QString & message); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
62 |
void displayNotice(const QString & message); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
63 |
void displayWarning(const QString & message); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
64 |
void setUser(const QString & nickname); |
7725 | 65 |
void setUsersModel(QAbstractItemModel * model); |
8179
a1ffcb559f99
Refactor: get rid of excessive QSettings instances on the same poor hedgewars.ini file
unc0rr
parents:
7742
diff
changeset
|
66 |
void setSettings(QSettings * settings); |
2845 | 67 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
68 |
protected: |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
69 |
virtual void dragEnterEvent(QDragEnterEvent * event); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
70 |
virtual void dropEvent(QDropEvent * event); |
6197 | 71 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
72 |
private: |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
73 |
static QString * s_styleSheet; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
74 |
static QStringList * s_displayNone; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
75 |
static bool s_isTimeStamped; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
76 |
static QString s_tsFormat; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
77 |
static const QRegExp URLREGEXP; |
6197 | 78 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
79 |
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
|
80 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
81 |
void addLine(const QString & cssClass, QString line, bool isHighlight = false); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
82 |
bool parseCommand(const QString & line); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
83 |
void discardStyleSheet(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
84 |
void saveStyleSheet(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
85 |
QString linkedNick(const QString & nickname); |
8451
8c7da08df048
Allow navigating backwards chat widget log while new lines are being added
unc0rr
parents:
8430
diff
changeset
|
86 |
void beforeContentAdd(); |
8c7da08df048
Allow navigating backwards chat widget log while new lines are being added
unc0rr
parents:
8430
diff
changeset
|
87 |
void afterContentAdd(); |
461 | 88 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
89 |
public slots: |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
90 |
void onChatString(const QString& str); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
91 |
void onChatString(const QString& nick, const QString& str); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
92 |
void onServerMessage(const QString& str); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
93 |
void nickAdded(const QString& nick, bool notifyNick); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
94 |
void nickRemoved(const QString& nick); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
95 |
void clear(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
96 |
void adminAccess(bool); |
461 | 97 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
98 |
signals: |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
99 |
void chatLine(const QString& str); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
100 |
void kick(const QString & str); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
101 |
void ban(const QString & str); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
102 |
void info(const QString & str); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
103 |
void follow(const QString &); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
104 |
void nickCountUpdate(int cnt); |
8396 | 105 |
void consoleCommand(const QString & command); |
461 | 106 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
107 |
private: |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
108 |
bool m_isAdmin; |
8430
5a5c34a75e1a
Aesthetic improvements to chat widget. Also fixed the ghosting issue in a few areas by using repaint().
dag10
parents:
8396
diff
changeset
|
109 |
QHBoxLayout mainLayout; |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
110 |
QTextBrowser* chatText; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
111 |
QStringList chatStrings; |
7723 | 112 |
QListView* chatNicks; |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
113 |
SmartLineEdit* chatEditLine; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
114 |
QAction * acInfo; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
115 |
QAction * acKick; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
116 |
QAction * acBan; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
117 |
QAction * acFollow; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
118 |
QAction * acIgnore; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
119 |
QAction * acFriend; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
120 |
QSettings * gameSettings; |
7740 | 121 |
QMenu * m_nicksMenu; |
6928
9562ace15141
nemo said I was boring for removing the "hello" randomizer on room join.
sheepluva
parents:
6700
diff
changeset
|
122 |
QStringList m_helloSounds; |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
123 |
QString m_hilightSound; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
124 |
QString m_userNick; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
125 |
QString m_clickedNick; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
126 |
QList<QRegExp> m_highlights; ///< regular expressions used for highlighting |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
127 |
bool notify; |
6929
c305d31642ac
reimplement auto-kick for ignored players (it was temporarily removed during refactoring)
sheepluva
parents:
6928
diff
changeset
|
128 |
bool m_autoKickEnabled; |
8451
8c7da08df048
Allow navigating backwards chat widget log while new lines are being added
unc0rr
parents:
8430
diff
changeset
|
129 |
bool m_scrollToBottom; |
8c7da08df048
Allow navigating backwards chat widget log while new lines are being added
unc0rr
parents:
8430
diff
changeset
|
130 |
int m_scrollBarPos; |
461 | 131 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
132 |
private slots: |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
133 |
void returnPressed(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
134 |
void onBan(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
135 |
void onKick(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
136 |
void onInfo(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
137 |
void onFollow(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
138 |
void onIgnore(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
139 |
void onFriend(); |
7742 | 140 |
void chatNickDoubleClicked(const QModelIndex & index); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6418
diff
changeset
|
141 |
void linkClicked(const QUrl & link); |
7740 | 142 |
void nicksContextMenuRequested(const QPoint & pos); |
461 | 143 |
}; |
144 |
||
145 |
#endif // _CHAT_WIDGET_INCLUDED |