-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlauremotepowerwidget.h
96 lines (79 loc) · 2.69 KB
/
lauremotepowerwidget.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
#ifndef LAUREMOTEPOWERWIDGET_H
#define LAUREMOTEPOWERWIDGET_H
#include <QWidget>
#include <QDialog>
#include <QComboBox>
#include <QGroupBox>
#include <QLineEdit>
#include <QPushButton>
#include <QVBoxLayout>
#include <QRadioButton>
#include <QNetworkReply>
#include <QNetworkSession>
#include <QNetworkRequest>
#include <QDialogButtonBox>
#include <QNetworkAccessManager>
#include <QNetworkConfigurationManager>
/****************************************************************************/
/****************************************************************************/
/****************************************************************************/
class LAURemotePowerWidget : public QWidget
{
Q_OBJECT
public:
LAURemotePowerWidget(int N = 8, QWidget *parent = 0);
~LAURemotePowerWidget();
QStringList networkPorts();
bool isConnected()
{
return(connected);
}
public slots:
void onConnect();
void onRadioButtonToggled(bool state);
signals:
void emitConnected(bool connected);
private:
void testConnection();
void makeAuthorizedRequest(QString url);
QComboBox *portComboBox;
QGroupBox *ipAddressGroupBox;
QGroupBox *buttonGroupBox;
QLineEdit *ipAddressLineEdit;
QPushButton *connectButton;
QList<QRadioButton *> buttons;
QNetworkAccessManager *manager;
QNetworkRequest request;
QList<int> pendingStateRequestValues;
bool pendingRequest, pendingStateRequest, connected;
private slots:
void managerFinished(QNetworkReply *reply);
};
/****************************************************************************/
/****************************************************************************/
/****************************************************************************/
class LAURemotePowerDialog : public QDialog
{
Q_OBJECT
public:
explicit LAURemotePowerDialog(QWidget *parent = nullptr) : QDialog(parent)
{
widget = new LAURemotePowerWidget();
connect(widget, SIGNAL(emitConnected(bool)), this, SLOT(onConnected(bool)));
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(accept()));
connect(buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject()));
this->setLayout(new QVBoxLayout());
this->layout()->setContentsMargins(6, 6, 6, 6);
this->layout()->addWidget(widget);
this->layout()->addWidget(buttonBox);
}
protected:
void showEvent(QShowEvent *)
{
this->setFixedSize(this->size());
}
private:
LAURemotePowerWidget *widget;
};
#endif // LAUREMOTEPOWERWIDGET_H