-
Notifications
You must be signed in to change notification settings - Fork 0
/
cyanchat.h
170 lines (146 loc) · 3.91 KB
/
cyanchat.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#ifndef CYANCHAT_H
#define CYANCHAT_H
#define CC_VERSION "v1.9.6"
#include <QMainWindow>
#include <QSystemTrayIcon>
#include <QTextBrowser>
#include <QModelIndex>
#include <QTcpSocket>
#include <QShortcut>
#include <QSettings>
#include <QString>
#include <QTimer>
#include <QTime>
#include <QFile>
#include "useriptable.h"
namespace Ui {
class CyanChat;
}
class Options;
class CyanChat : public QMainWindow {
Q_OBJECT
public:
CyanChat(QWidget *parent = 0);
~CyanChat();
class User {
public:
static QColor levelColors[5];
QString name;
QString addr;
int level;
User() {}
User(QString str);
void fromString(QString str);
QString toString() const;
QString fullName() const;
QColor color() const;
bool isIgnored(QList<User>& ignoreList);
};
class Msg {
public:
QString text;
int flag;
Msg() {}
Msg(QString str);
Msg(QString str, int type);
void fromString(QString str);
};
enum {
kMsgTypePM, kMsgTypeChat, kMsgTypeJoin, kMsgTypeLeave, kMsgTypePMTab
};
void insertTextDetectLinks(QTextCursor cursor, QTextCharFormat format, QString text);
void addChatLine(QTextBrowser* textBrowser, const User& user, const Msg& message);
void writePlainLogLine(const User& user, const Msg& message);
void writeHTMLLogLine(const User& user, const Msg& message);
// core network output functions
void name(QString name);
void ignore(User user);
void chat(QString msg);
void pm(User target, QString msg);
static QString verString;
static QColor msgColors[2];
static QRegExp linkRegex;
QString currentName;
// if this is set, it has the effect of setNameOnConnect, without saving as an option
bool reconnecting;
// options
QSettings settings;
void writeSettings();
void readSettings();
void applyFontSize();
bool minimizeToTray;
bool alwaysShowTray;
bool highlightLocalName;
bool reformatActions;
bool displayTimestamps;
QString timestampFormat;
QString host;
int port;
QString defaultName;
bool connectOnStartup;
bool setNameOnConnect;
bool autoCreatePMTabs;
QString setNameString;
QString switchTabString;
QString closeTabString;
bool writePlainLog;
bool writeHTMLLog;
QString plainLog;
QString HTMLLog;
bool logClientAnnounce;
bool logTimestamps;
bool logPrivate;
int fontSize;
bool showOrigNames;
public slots:
void onConnect();
void loginSlot();
void renameSlot();
void ignoreSlot();
void chatSlot();
void openPmSlot();
void showAddressSlot();
void requestVersionSlot();
void closeTabSlot(QWidget* tab);
void closeCurrentTab();
void tabChanged(int num);
void recvData();
void sockError();
void pingSlot();
void iconActivated(QSystemTrayIcon::ActivationReason reason);
void hideWindowSlot();
void showWindowSlot();
void nextTabSlot();
void netConnect();
void netDisconnect();
void showOptions();
void optionsFinished(int value);
void setTrayVis(bool vis);
void saveSplitterState(int, int);
void showUserListContextMenu(QPoint);
void showNamesSlot();
void setOrigNameSlot();
void refreshUserListSlot();
void nameCompleteSlot();
signals:
void hideWindowSignal();
private:
Ui::CyanChat *ui;
QTcpSocket* sock;
Options* optionsDialog;
bool name_reg;
QList<User> userList;
QList<User> ignoreList;
QString startName;
QString lastAttemptedName;
QSystemTrayIcon* trayIcon;
QFile HTMLLogFile;
QFile plainLogFile;
UserIPTable userIPTable;
void sendLine(QString line);
void changeEvent(QEvent* event);
protected:
void resizeEvent(QResizeEvent*);
void moveEvent(QMoveEvent*);
};
#endif // CYANCHAT_H