You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

233 lines
7.7 KiB
C++

#ifndef MONITOROVOZEZ_H
#define MONITOROVOZEZ_H
#include <QtCore/QVariant>
#include <QtWidgets/QApplication>
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QSpacerItem>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QWidget>
#include <QtWidgets/QScrollArea>
#include <QDebug>
#include "MonitorTagUI.h"
#include "../HTTPClient/client.h"
QT_BEGIN_NAMESPACE
class Ui_MonitorWidget:public QWidget
{
public:
QVBoxLayout *verticalLayout;
QHBoxLayout *operationLayout;
QPushButton *exchangeButton;
QSpacerItem *horizontalSpacer;
QGridLayout *monitorLayout;
QHBoxLayout *filterlLayout;
QPushButton *interruptedButton;
QPushButton *normalButton;
QPushButton *standbyButton;
QPushButton *hutdownButton;
QPushButton *failureButton;
QPushButton *runButton;
QWidget *fillWidget;
int state;
QList<QList<MonitorTag*>> tagList;
void setupUi(QWidget *MonitorWidget)
{
state = 0;
if (MonitorWidget->objectName().isEmpty())
MonitorWidget->setObjectName(QString::fromUtf8("MonitorWidget"));
verticalLayout = new QVBoxLayout(MonitorWidget);
verticalLayout->setSpacing(0);
verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
verticalLayout->setContentsMargins(0, 0, 0, 0);
operationLayout = new QHBoxLayout();
operationLayout->setObjectName(QString::fromUtf8("operationLayout"));
exchangeButton = new QPushButton(MonitorWidget);
exchangeButton->setObjectName(QString::fromUtf8("exchangeButton"));
operationLayout->addWidget(exchangeButton);
horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
operationLayout->addItem(horizontalSpacer);
verticalLayout->addLayout(operationLayout);
monitorLayout = new QGridLayout();
monitorLayout->setObjectName(QString::fromUtf8("monitorLayout"));
monitorLayout->setSpacing(30);
monitorLayout->setContentsMargins(20, 20, 20, 20);
monitorLayout->setColumnStretch(0, 1);
monitorLayout->setColumnStretch(1, 1);
monitorLayout->setColumnStretch(2, 1);
monitorLayout->setColumnStretch(3, 1);
monitorLayout->setColumnStretch(4, 1);
monitorLayout->setColumnStretch(5, 1);
monitorLayout->setColumnStretch(6, 1);
fillWidget = new QWidget();
fillWidget->setLayout(monitorLayout);
connect(exchangeButton, &QPushButton::clicked, this, [=](){this->changeState();});
QScrollArea *scrollArea = new QScrollArea();
scrollArea->setWidget(fillWidget);
scrollArea->setWidgetResizable(true);
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
verticalLayout->addWidget(scrollArea);
filterlLayout = new QHBoxLayout();
filterlLayout->setObjectName(QString::fromUtf8("filterlLayout"));
interruptedButton = new QPushButton(MonitorWidget);
interruptedButton->setObjectName(QString::fromUtf8("interruptedButton"));
filterlLayout->addWidget(interruptedButton);
normalButton = new QPushButton(MonitorWidget);
normalButton->setObjectName(QString::fromUtf8("normalButton"));
filterlLayout->addWidget(normalButton);
standbyButton = new QPushButton(MonitorWidget);
standbyButton->setObjectName(QString::fromUtf8("standbyButton"));
filterlLayout->addWidget(standbyButton);
hutdownButton = new QPushButton(MonitorWidget);
hutdownButton->setObjectName(QString::fromUtf8("hutdownButton"));
filterlLayout->addWidget(hutdownButton);
failureButton = new QPushButton(MonitorWidget);
failureButton->setObjectName(QString::fromUtf8("failureButton"));
filterlLayout->addWidget(failureButton);
runButton = new QPushButton(MonitorWidget);
runButton->setObjectName(QString::fromUtf8("runButton"));
filterlLayout->addWidget(runButton);
filterlLayout->setContentsMargins(10, 10, 10, 10);
filterlLayout->setSpacing(20);
verticalLayout->addLayout(filterlLayout);
verticalLayout->setStretch(0, 2);
verticalLayout->setStretch(1, 30);
verticalLayout->setStretch(2, 3);
MonitorWidget->setLayout(verticalLayout);
retranslateUi(MonitorWidget);
QMetaObject::connectSlotsByName(MonitorWidget);
addTag();
} // setupUi
void retranslateUi(QWidget *MonitorWidget)
{
MonitorWidget->setWindowTitle(QCoreApplication::translate("MonitorWidget", "Form", nullptr));
exchangeButton->setText(QCoreApplication::translate("MonitorWidget", "\345\244\247\345\260\217\345\233\276\346\240\207\345\210\207\346\215\242", nullptr));
interruptedButton->setText(QCoreApplication::translate("MonitorWidget", "\351\200\232\350\256\257\344\270\255\346\226\255 x\345\217\260", nullptr));
normalButton->setText(QCoreApplication::translate("MonitorWidget", "\346\255\243\345\270\270\350\277\220\350\241\214 x\345\217\260", nullptr));
standbyButton->setText(QCoreApplication::translate("MonitorWidget", "\345\276\205\346\234\272\347\255\211\351\243\216 x\345\217\260", nullptr));
hutdownButton->setText(QCoreApplication::translate("MonitorWidget", "\345\201\234\346\234\272\347\273\264\346\212\244 x\345\217\260", nullptr));
failureButton->setText(QCoreApplication::translate("MonitorWidget", "\346\225\205\351\232\234\345\276\205\346\234\272 x\345\217\260", nullptr));
runButton->setText(QCoreApplication::translate("MonitorWidget", "\345\220\257\345\212\250 x\345\217\260", nullptr));
} // retranslateUi
void exchangeClicked(MonitorTag *newTag)
{
if (this->state == 1) {
newTag->stackedWidget->setCurrentIndex(1);
} else if (this->state == 0) {
newTag->stackedWidget->setCurrentIndex(0);
}
}
void changeState()
{
if (state == 0){
state = 1;
} else if (state == 1) {
state = 0;
}
}
void addTag()
{
map fans = httpClient.getFanList().allFans;
tagList.clear();
int count = 0;
int index = 0;
QList<MonitorTag*> tags;
for (auto it = fans.begin(); it != fans.end(); ++it) {
if (index == 6){
tagList.append(tags);
tags.clear();
index = 0;
count++;
}
MonitorTag *newTag = new MonitorTag(it->second);
connect(exchangeButton, &QPushButton::clicked, this, [=](){this->exchangeClicked(newTag);});
monitorLayout->addWidget(newTag, count, index);
tags.append(newTag);
index++;
}
if (fans.size() < 28){
fillWidget->setFixedHeight(228 * 4);
for (int i = 0; i < 28 - fans.size(); i++) {
if (index == 6){
index = 0;
count++;
}
QWidget *w = new QWidget();
monitorLayout->addWidget(w, count, index);
index++;
}
monitorLayout->setRowStretch(0, 1);
monitorLayout->setRowStretch(1, 1);
monitorLayout->setRowStretch(2, 1);
monitorLayout->setRowStretch(3, 1);
}
fillWidget->setFixedWidth(1900);
int c = monitorLayout->count();
qDebug() << c;
}
Ui_MonitorWidget()
{
setupUi(this);
}
};
namespace Ui {
class MonitorWidget: public Ui_MonitorWidget {};
} // namespace Ui
QT_END_NAMESPACE
#endif // MONITOROVOZEZ_H