-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwidget.h
130 lines (115 loc) · 3.14 KB
/
widget.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
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QMainWindow>
#include <QProgressBar>
#include <QLabel>
#include <QPushButton>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QString>
#include <QByteArray>
#include <QLineEdit>
#include <QTcpServer>
#include <QTcpSocket>
#include <QDebug>
#include <QFile>
#include <QMessageBox>
#include <QFileDialog>
#include <QHostAddress>
#include <QDateTime>
#include "widget.h"
#include <QApplication>
#include "ccissNetworkEnvironment.h"
#include "ccissServer.h"
#include "ccissClient.h"
#include "ccissWidget.h"
class ccissClient;
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget *parent = 0);
~Widget();
void constructIHM();
void setConnections();
//void startServer();
private:
QHBoxLayout* ccissWidgetLayoutAll;
QVBoxLayout* textVboxLayout;
QWidget* textWidget;
QPushButton* startServerPushButton;
QLabel* textLabel;
QVBoxLayout* ccissWidgetLayout;
QWidget* ccissWidget;
QHBoxLayout* homeAdressBarLayout;
QHBoxLayout* remoteAdressBarLayout;
QHBoxLayout* reciveProgressLayout;
QHBoxLayout* sendProgressLayout;
QHBoxLayout* startWidgetLayout;
QHBoxLayout* msgWidgetLayout;
QHBoxLayout* stateWidgetLayout;
//本机IP和端口
QLabel* homeIPLabel;
QLineEdit* homeIPLineEdit;
QLabel* homePortLabel;
QLineEdit* homePortLineEdit;
//远程IP和端口
QLabel* remoteIPLabel;
QLineEdit* remoteIPLineEdit;
QLabel* remotePortLabel;
QLineEdit* remotePortLineEdit;
//接收进度条
QLabel* reciveProgressLabel;
QProgressBar* reciveProgressBar;
//发送进度条
QLabel* sendProgressLabel;
QProgressBar* sendProgressBar;
//选择按钮
//QPushButton* startButton;
QPushButton* openButton;
QPushButton* sendButton;
QPushButton* closeButton;
//发送消息框
QLabel* msgLabel;
QLineEdit* msgLineEdit;
QPushButton* msgPushButton;
//当前状态
QLabel* stateLabel;
QWidget* homeAdressWidget;
QWidget* remoteAdressWidget;
QWidget* reciveProgressWidget;
QWidget* sendProgressWidget;
QWidget* startBarWidget;
QWidget* msgWidget;
//定义传送变量
ccissNetworkEnvironment *networkEnvironment;
ccissServer *server;
ccissClient *ccissToPiss;
QTcpServer* tcpServer;
QTcpSocket* client;
QTcpSocket *tcpClient;
QFile *localFile; //要发送的文件
qint64 totalBytes; //数据总大小
qint64 bytesWritten; //已经发送数据大小
qint64 bytesToWrite; //剩余数据大小
qint64 loadSize; //每次发送数据的大小
QString fileName; //保存文件路径
QByteArray outBlock; //数据缓冲区,即存放每次要发送的数据
bool fileSendReady;
bool msgSendReady;
QString msg;
qint8 msgtype;
private slots:
void acceptConnection();
void startRead();
void startServer();
void fileSend(); //文件请求连接服务器
void startTransferFile(); //发送文件大小等信息
void startTransferMsg(); //发送消息大小等信息
void updateClientProgress(qint64 numBytes); //发送数据,更新文件进度条
void displayError(QAbstractSocket::SocketError); //显示错误
void openFile(); //打开文件
void msgSend(); //消息请求连接服务器
};
#endif // WIDGET_H