qt/ledset/mainwin.cpp

123 lines
4.0 KiB
C++
Raw Normal View History

2022-08-25 18:43:03 +08:00
#include "mainwin.h"
#include "fast.h"
#include "expertwin.h"
#include "brightwin.h"
#include "pcapwin.h"
#include "videowin.h"
2022-08-25 18:43:03 +08:00
#include "gqt.h"
#include <QLabel>
2022-08-25 18:43:03 +08:00
#include <QPushButton>
#include <QToolButton>
#include <QComboBox>
#include <QMouseEvent>
#include <QPainter>
#include <QPainterPath>
#include <QTimer>
#include <QMessageBox>
#include <QDebug>
2022-08-25 18:43:03 +08:00
class ImgBtn : public QToolButton {
public:
2022-09-06 23:40:02 +08:00
ImgBtn() {
setStyleSheet("QToolButton{border: none; padding-top: 4px;}");
2022-08-25 18:43:03 +08:00
}
2022-09-06 23:40:02 +08:00
bool isEnter{false};
2022-08-25 18:43:03 +08:00
protected:
2022-09-06 23:40:02 +08:00
void resizeEvent(QResizeEvent *event) override {
QToolButton::resizeEvent(event);
if(isEnter) setIconSize(QSize(width(), width()));
else setIconSize(QSize(width()-8, width()-8));
}
void enterEvent(QEvent *event) override {
QToolButton::enterEvent(event);
2022-08-25 18:43:03 +08:00
setStyleSheet("QToolButton{border: none;}");
setIconSize(QSize(width(), width()));
}
2022-09-06 23:40:02 +08:00
void leaveEvent(QEvent *event) override {
QToolButton::leaveEvent(event);
2022-08-25 18:43:03 +08:00
setIconSize(QSize(width()-8, width()-8));
setStyleSheet("QToolButton{border: none; padding-top: 4px;}");
}
};
inline QLabel *newImgLabel(QPixmap pixmap){
QLabel *lb = new QLabel();
lb->setPixmap(pixmap);
return lb;
}
inline QLabel *newSubLabel(QString txt){
QLabel *lb = new QLabel(txt);
lb->setAlignment(Qt::AlignCenter);
return lb;
}
2022-09-06 23:40:02 +08:00
ImgBtn *addImg(QHBoxLayout *parent, const QIcon &icon, const QString &text) {
auto imgBtn = new ImgBtn();
imgBtn->setIcon(icon);
imgBtn->setText(text);
2022-08-25 18:43:03 +08:00
imgBtn->setFixedSize(76, 100);
imgBtn->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
parent->addWidget(imgBtn);
2022-09-06 23:40:02 +08:00
return imgBtn;
2022-08-25 18:43:03 +08:00
}
MainWin::MainWin() {
setWindowTitle("Led Set");
resize(860, 540);
auto vBox = new QVBoxLayout(center);
vBox->setContentsMargins(0,0,0,0);
vBox->addLayout(addBtns(new QHBoxLayout()));
QHBoxLayout *imgsBar = new QHBoxLayout();
2022-09-06 23:40:02 +08:00
auto btnImg = addImg(imgsBar, QPixmap(":/imgs/fast.png").scaledToWidth(128, Qt::SmoothTransformation), "快速调屏");
2022-08-25 18:43:03 +08:00
connect(btnImg, &ImgBtn::clicked, this, [=](){
(new Fast(this))->show();
// if(win==0) {
// win = new QWidget;
// win->setWindowFlag(Qt::FramelessWindowHint);
// win->resize(600,100);
// win->show();
// } else {
// win->move(win->x()-100, win->y());
// }
});
2022-09-06 23:40:02 +08:00
btnImg = addImg(imgsBar, QPixmap(":/imgs/expert.png").scaledToWidth(128, Qt::SmoothTransformation), "专家调屏");
2022-08-25 18:43:03 +08:00
connect(btnImg, &ImgBtn::clicked, this, [=](){
(new ExpertWin(this))->show();
});
2022-09-06 23:40:02 +08:00
btnImg = addImg(imgsBar, QPixmap(":/imgs/bright.png").scaledToWidth(128, Qt::SmoothTransformation), "亮度控制");
2022-08-25 18:43:03 +08:00
connect(btnImg, &ImgBtn::clicked, this, [=](){
(new BrightWin(this))->show();
});
2022-09-06 23:40:02 +08:00
btnImg = addImg(imgsBar, QPixmap(":/imgs/correct.png").scaledToWidth(128, Qt::SmoothTransformation), "相机矫正");
2022-08-25 18:43:03 +08:00
connect(btnImg, &ImgBtn::clicked, this, [=](){
});
2022-09-06 23:40:02 +08:00
btnImg = addImg(imgsBar, QPixmap(":/imgs/monitor.png").scaledToWidth(128, Qt::SmoothTransformation), "屏体监控");
2022-08-25 18:43:03 +08:00
connect(btnImg, &ImgBtn::clicked, this, [=](){
});
2022-09-06 23:40:02 +08:00
btnImg = addImg(imgsBar, QPixmap(":/imgs/multi.png").scaledToWidth(128, Qt::SmoothTransformation), "多功能卡");
2022-08-25 18:43:03 +08:00
connect(btnImg, &ImgBtn::clicked, this, [=](){
//win->move(win->x()-1, win->y());
});
2022-09-06 23:40:02 +08:00
btnImg = addImg(imgsBar, QPixmap(":/imgs/video.png").scaledToWidth(128, Qt::SmoothTransformation), "网口通信");
2022-08-25 18:43:03 +08:00
connect(btnImg, &ImgBtn::clicked, this, [=](){
auto ins = PcapWin::newIns(this);
if(ins) ins->show();
});
btnImg = addImg(imgsBar, QPixmap(":/imgs/idea.png").scaledToWidth(128, Qt::SmoothTransformation), "视频传输");
2022-08-25 18:43:03 +08:00
connect(btnImg, &ImgBtn::clicked, this, [=](){
auto ins = VideoWin::newIns(this);
ins->show();
2022-08-25 18:43:03 +08:00
});
vBox->addLayout(imgsBar);
vBox->addSpacing(16);
vBox->addWidget(new QLabel(" 硬件信息"));
vBox->addStretch();
}