summaryrefslogtreecommitdiffstats
path: root/examples/network/loopback/dialog.h
blob: c39ffb00ce18c69f4336b3f8415bceda29012928 (plain)
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
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#ifndef DIALOG_H
#define DIALOG_H

#include <QDialog>
#include <QTcpServer>
#include <QTcpSocket>

QT_BEGIN_NAMESPACE
class QDialogButtonBox;
class QLabel;
class QProgressBar;
class QPushButton;
QT_END_NAMESPACE

class Dialog : public QDialog
{
    Q_OBJECT

public:
    Dialog(QWidget *parent = nullptr);

public slots:
    void start();
    void acceptConnection();
    void startTransfer();
    void updateServerProgress();
    void updateClientProgress(qint64 numBytes);
    void displayError(QAbstractSocket::SocketError socketError);

private:
    QProgressBar *clientProgressBar = nullptr;
    QProgressBar *serverProgressBar = nullptr;
    QLabel *clientStatusLabel = nullptr;
    QLabel *serverStatusLabel = nullptr;

    QPushButton *startButton = nullptr;
    QPushButton *quitButton = nullptr;
    QDialogButtonBox *buttonBox = nullptr;

    QTcpServer tcpServer;
    QTcpSocket tcpClient;
    QTcpSocket *tcpServerConnection = nullptr;
    int bytesToWrite = 0;
    int bytesWritten = 0;
    int bytesReceived = 0;
};

#endif