qt/LedOK/wProgramManager/wEditProgram/wElement/eobjectattr.cpp

127 lines
3.7 KiB
C++
Raw Normal View History

2022-01-04 18:11:48 +08:00
#include "eobjectattr.h"
#include "ui_eobjectattr.h"
2022-01-07 18:22:58 +08:00
#include <QDirIterator>
2022-01-04 18:11:48 +08:00
2022-01-07 18:22:58 +08:00
eObjectAttr::eObjectAttr(const QRectF &data, const QRectF &rLimit, QWidget *parent) :
2022-01-04 18:11:48 +08:00
QGroupBox(parent),
ui(new Ui::eObjectAttr)
{
m_rLimit.setX(rLimit.x());
m_rLimit.setY(rLimit.y());
m_rLimit.setWidth(rLimit.width());
m_rLimit.setHeight(rLimit.height());
ui->setupUi(this);
2022-01-07 18:22:58 +08:00
ui->wX->setValue(static_cast<int>(data.x()));
ui->wY->setValue(static_cast<int>(data.y()));
ui->wW->setValue(static_cast<int>(data.width()));
ui->wH->setValue(static_cast<int>(data.height()));
2022-01-04 18:11:48 +08:00
connect(ui->wX, SIGNAL(valueChanged(int)), this, SLOT(onXChanged(int)));
connect(ui->wY, SIGNAL(valueChanged(int)), this, SLOT(onYChanged(int)));
connect(ui->wW, SIGNAL(valueChanged(int)), this, SLOT(onWChanged(int)));
connect(ui->wH, SIGNAL(valueChanged(int)), this, SLOT(onHChanged(int)));
QHBoxLayout *hBox = new QHBoxLayout();
ui->verticalLayout->addLayout(hBox);
hBox->addWidget(new QLabel("边框:"));
2022-01-07 18:22:58 +08:00
borderFd = new QComboBox();
borderFd->setStyleSheet("QComboBox{padding-left:4px; padding-right:4px;}");
2022-01-20 10:08:17 +08:00
borderFd->addItem("");
2022-01-07 18:22:58 +08:00
hBox->addWidget(borderFd);
hBox->addWidget(new QLabel("特效:"));
borderEffFd = new QComboBox();
borderEffFd->setStyleSheet("QComboBox{padding-left:4px; padding-right:4px}");
borderEffFd->addItem("静止");
borderEffFd->addItem("旋转");
borderEffFd->addItem("闪烁");
hBox->addWidget(borderEffFd);
hBox->addStretch();
ui->verticalLayout->addStretch();
2022-01-04 18:11:48 +08:00
}
eObjectAttr::~eObjectAttr()
{
delete ui;
}
void eObjectAttr::onXChanged(int n)
{
2022-01-07 18:22:58 +08:00
qDebug()<<"eObjectAttr::onXChanged(int)";
2022-01-04 18:11:48 +08:00
if(m_rLimit != INVALID_RECT) {
int mx = n;
int mw = ui->wW->value();
if(mx + mw > m_rLimit.width()) {
mx = static_cast<int>(m_rLimit.width()) - mw;
ui->wX->blockSignals(true);
ui->wX->setValue(mx);
ui->wX->blockSignals(false);
}
}
onAttrChanged();
}
void eObjectAttr::onYChanged(int n)
{
2022-01-07 18:22:58 +08:00
qDebug()<<"eObjectAttr::onYChanged(int)";
2022-01-04 18:11:48 +08:00
if(m_rLimit != INVALID_RECT) {
int my = n;
int mh = ui->wH->value();
if(my + mh > m_rLimit.height()) {
my = static_cast<int>(m_rLimit.height()) - mh;
ui->wY->blockSignals(true);
ui->wY->setValue(my);
ui->wY->blockSignals(false);
}
}
onAttrChanged();
}
void eObjectAttr::onWChanged(int n)
{
2022-01-07 18:22:58 +08:00
qDebug()<<"eObjectAttr::onWChanged(int)";
2022-01-04 18:11:48 +08:00
if(m_rLimit != INVALID_RECT) {
int mx = ui->wX->value();
int mw = n;
if(mx + mw > m_rLimit.width()) {
mw = static_cast<int>(m_rLimit.width()) - mx;
ui->wW->blockSignals(true);
ui->wW->setValue(mw);
ui->wW->blockSignals(false);
}
}
onAttrChanged();
}
void eObjectAttr::onHChanged(int n)
{
2022-01-07 18:22:58 +08:00
qDebug()<<"eObjectAttr::onHChanged(int)";
2022-01-04 18:11:48 +08:00
if(m_rLimit != INVALID_RECT) {
int my = ui->wY->value();
int mh = n;
if(my + mh > m_rLimit.height()) {
mh = static_cast<int>(m_rLimit.height()) - my;
ui->wH->blockSignals(true);
ui->wH->setValue(mh);
ui->wH->blockSignals(false);
}
}
onAttrChanged();
}
2022-01-20 10:08:17 +08:00
void eObjectAttr::onAttrChanged(){
2022-01-07 18:22:58 +08:00
QRectF rect(ui->wX->value(), ui->wY->value(), ui->wW->value(), ui->wH->value());
emit sAttrChanged(rect);
2022-01-04 18:11:48 +08:00
}
2022-01-07 18:22:58 +08:00
void eObjectAttr::onAttrSetting(const QRectF &rect)
2022-01-04 18:11:48 +08:00
{
2022-01-07 18:22:58 +08:00
qDebug()<<"eObjectAttr::onAttrSetting(QRectF)";
ui->wX->setValue(static_cast<int>(rect.x()));
ui->wY->setValue(static_cast<int>(rect.y()));
ui->wW->setValue(static_cast<int>(rect.width()));
ui->wH->setValue(static_cast<int>(rect.height()));
2022-01-04 18:11:48 +08:00
}