-
Notifications
You must be signed in to change notification settings - Fork 0
/
dsconvocommon.h
58 lines (42 loc) · 1.21 KB
/
dsconvocommon.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
#ifndef DSCONVOCOMMON_H
#define DSCONVOCOMMON_H
#include <QPair>
#include <QHostAddress>
#include <QObject>
#include <QPlainTextEdit>
#include <QApplication>
namespace DSConvo {
typedef QPair<QHostAddress, quint16> AddressPort;
typedef QPair<QAbstractSocket::SocketError, QString> SocketErrorInfo;
struct CommandLineOptions {
const QString *address;
const QString *database;
bool server;
};
constexpr quint16 DEFAULT_PORT = 5500;
constexpr quint16 MAX_MESSAGE = 255;
extern CommandLineOptions cmdline;
extern AddressPort serverAddress;
QString normalizeText(const QString&);
void initialize(QApplication &app);
bool validatePort(const QString&, quint16* = nullptr);
bool validateAddressPort(const QString&, AddressPort&, bool = false);
QString addressPortToString(const AddressPort&);
namespace QtUtil {
class PlainTextEditLimit : public QObject
{
Q_OBJECT
public:
explicit PlainTextEditLimit(int limit, QPlainTextEdit *parent);
inline int limit() const { return limit_; }
inline void setLimit(int l) { limit_ = l; }
signals:
void limitExceeded(bool*);
private:
int limit_;
private slots:
void parentTextChanged();
};
} // namespace DSConvo::QtUtil
} // namespace DSConvo
#endif