qt/ledset/expertboxlayoutwin.h

77 lines
2.1 KiB
C
Raw Permalink Normal View History

2023-04-18 18:21:34 +08:00
#ifndef EXPERTBOXLAYOUTWIN_H
#define EXPERTBOXLAYOUTWIN_H
#include "basewin.h"
2023-08-21 11:21:00 +08:00
#include "gutil/qjson.h"
2023-04-18 18:21:34 +08:00
#include <QLabel>
2023-08-21 11:21:00 +08:00
#include <QButtonGroup>
#include <QCheckBox>
2023-04-18 18:21:34 +08:00
2023-08-21 11:21:00 +08:00
class ExpertWin;
class BoxPanel;
2023-04-18 18:21:34 +08:00
class ExpertBoxLayoutWin : public BaseWin {
Q_OBJECT
public:
2023-08-21 11:21:00 +08:00
explicit ExpertBoxLayoutWin(ExpertWin *parent = 0);
2023-08-24 16:55:38 +08:00
QCheckBox *fdHasPos, *fdHasSize, *fdHasConn, *fdHasName, *fdHasOutline, *fdSnap;
2023-08-21 11:21:00 +08:00
QButtonGroup *grpGrp;
BoxPanel *box{0};
QLabel *fdModNum, *fdBoxSize;
};
class ModuleUnit;
class BoxPanel : public QWidget {
Q_OBJECT
public:
2023-08-24 16:55:38 +08:00
explicit BoxPanel(ExpertBoxLayoutWin *boxWin) : boxWin(boxWin) {
setFocusPolicy(Qt::ClickFocus);
}
2023-08-21 11:21:00 +08:00
void fitSize() {
boxRect = childrenRect();
auto www = qMax(1000, boxRect.x()+boxRect.width()+1);
auto hhh = qMax(1000, boxRect.y()+boxRect.height()+1);
if(www!=width() || hhh!=height()) resize(www, hhh);
else update();
boxWin->fdBoxSize->setText(QString("%1 x %2").arg(boxRect.width()).arg(boxRect.height()));
}
2023-08-24 16:55:38 +08:00
void del();
2023-08-21 11:21:00 +08:00
QRect boxRect, grpRect;
2023-07-28 14:48:41 +08:00
double rate{1};
2023-08-21 11:21:00 +08:00
QRectF rect;
2023-08-24 16:55:38 +08:00
std::vector<ModuleUnit *> sels;
std::vector<ModuleUnit *> copieds;
ExpertBoxLayoutWin *boxWin;
2023-08-21 11:21:00 +08:00
bool isDrawing{false};
protected:
2023-08-24 16:55:38 +08:00
void keyPressEvent(QKeyEvent *event) override;
2023-08-21 11:21:00 +08:00
void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *) override;
void mouseMoveEvent(QMouseEvent *event) override;
void paintEvent(QPaintEvent *event) override;
};
class ModuleUnit : public QWidget {
Q_OBJECT
public:
2023-09-01 16:17:33 +08:00
explicit ModuleUnit(int, int, int, int, const JObj &module, const QString &name, QWidget *parent = 0);
2023-08-21 11:21:00 +08:00
void drawed();
2023-09-01 16:17:33 +08:00
BoxPanel *box;
QPoint mPressRel{INT_MIN, INT_MIN};
2023-08-21 11:21:00 +08:00
int mX, mY, mW, mH;
JObj mModule;
QString name;
2023-09-01 16:17:33 +08:00
bool isSel = false;
bool isVerticalMirror = false;
bool isHorizonMirror = false;
2023-08-21 11:21:00 +08:00
protected:
void mousePressEvent(QMouseEvent *) override;
void mouseReleaseEvent(QMouseEvent *) override;
void mouseMoveEvent(QMouseEvent *) override;
2023-04-18 18:21:34 +08:00
};
#endif // EXPERTBOXLAYOUTWIN_H