119 lines
3.9 KiB
C++
119 lines
3.9 KiB
C++
#include "mainwin.h"
|
|
#include "fast.h"
|
|
#include "expertwin.h"
|
|
#include "brightwin.h"
|
|
#include "pcapwin.h"
|
|
#include "gqt.h"
|
|
#include <QLabel>
|
|
#include <QPushButton>
|
|
#include <QToolButton>
|
|
#include <QComboBox>
|
|
#include <QMouseEvent>
|
|
#include <QPainter>
|
|
#include <QPainterPath>
|
|
#include <QTimer>
|
|
|
|
class ImgBtn : public QToolButton {
|
|
public:
|
|
ImgBtn() {
|
|
setStyleSheet("QToolButton{border: none; padding-top: 4px;}");
|
|
}
|
|
bool isEnter{false};
|
|
protected:
|
|
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);
|
|
setStyleSheet("QToolButton{border: none;}");
|
|
setIconSize(QSize(width(), width()));
|
|
}
|
|
void leaveEvent(QEvent *event) override {
|
|
QToolButton::leaveEvent(event);
|
|
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;
|
|
}
|
|
ImgBtn *addImg(QHBoxLayout *parent, const QIcon &icon, const QString &text) {
|
|
auto imgBtn = new ImgBtn();
|
|
imgBtn->setIcon(icon);
|
|
imgBtn->setText(text);
|
|
imgBtn->setFixedSize(76, 100);
|
|
imgBtn->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
|
parent->addWidget(imgBtn);
|
|
return imgBtn;
|
|
}
|
|
|
|
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();
|
|
auto btnImg = addImg(imgsBar, QPixmap(":/imgs/fast.png").scaledToWidth(128, Qt::SmoothTransformation), "快速调屏");
|
|
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());
|
|
// }
|
|
});
|
|
btnImg = addImg(imgsBar, QPixmap(":/imgs/expert.png").scaledToWidth(128, Qt::SmoothTransformation), "专家调屏");
|
|
connect(btnImg, &ImgBtn::clicked, this, [=](){
|
|
(new ExpertWin(this))->show();
|
|
});
|
|
btnImg = addImg(imgsBar, QPixmap(":/imgs/bright.png").scaledToWidth(128, Qt::SmoothTransformation), "亮度控制");
|
|
connect(btnImg, &ImgBtn::clicked, this, [=](){
|
|
(new BrightWin(this))->show();
|
|
});
|
|
btnImg = addImg(imgsBar, QPixmap(":/imgs/correct.png").scaledToWidth(128, Qt::SmoothTransformation), "相机矫正");
|
|
connect(btnImg, &ImgBtn::clicked, this, [=](){
|
|
|
|
});
|
|
btnImg = addImg(imgsBar, QPixmap(":/imgs/monitor.png").scaledToWidth(128, Qt::SmoothTransformation), "屏体监控");
|
|
connect(btnImg, &ImgBtn::clicked, this, [=](){
|
|
|
|
});
|
|
btnImg = addImg(imgsBar, QPixmap(":/imgs/multi.png").scaledToWidth(128, Qt::SmoothTransformation), "多功能卡");
|
|
connect(btnImg, &ImgBtn::clicked, this, [=](){
|
|
//win->move(win->x()-1, win->y());
|
|
});
|
|
btnImg = addImg(imgsBar, QPixmap(":/imgs/video.png").scaledToWidth(128, Qt::SmoothTransformation), "网口通信");
|
|
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), "创意显示");
|
|
connect(btnImg, &ImgBtn::clicked, this, [=](){
|
|
//qDebug()<<"geometry"<<win->geometry()<<"screen"<<win->screen();
|
|
});
|
|
vBox->addLayout(imgsBar);
|
|
|
|
vBox->addSpacing(16);
|
|
vBox->addWidget(new QLabel(" 硬件信息"));
|
|
|
|
|
|
vBox->addStretch();
|
|
}
|