-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclientwindow.h
57 lines (47 loc) · 1.2 KB
/
clientwindow.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
#ifndef CLIENTWINDOW_H
#define CLIENTWINDOW_H
#include <QMainWindow>
#include <QMessageBox>
#include <QTcpSocket>
#include <QTimer>
#include "dsconvoclient.h"
QT_BEGIN_NAMESPACE
namespace Ui { class ClientWindow; }
QT_END_NAMESPACE
class ClientWindow : public QMainWindow
{
Q_OBJECT
public:
ClientWindow(QWidget *parent = nullptr);
~ClientWindow();
protected:
bool eventFilter(QObject *object, QEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
private:
enum UiMode {
CanConnect,
Connecting,
CanSend,
Disconnecting,
};
void switchUi(UiMode mode);
void doConnect();
void doDisconnect();
void initClientConnection();
void updateCompleter();
Ui::ClientWindow *ui;
QMessageBox *errorMessage;
UiMode uiMode;
DSConvoClient *client;
QTimer *completerTimer;
bool canUpdateCompleter;
private slots:
void toggleConnection();
void sendMessage();
void clientStateChanged();
void clientConnGreeted();
void clientConnMessaged(const DSConvo::Protocol::MessageBroadcast &m);
void clientConnErrorOccurred(DSConvoClientConnection::Error e);
void completerTimerTimeout();
};
#endif