ledok增加边框
|
@ -42,7 +42,6 @@ SOURCES += \
|
|||
LoQClass/locolorselector.cpp \
|
||||
LoQClass/lodateselector.cpp \
|
||||
LoQClass/loglwindow.cpp \
|
||||
LoQClass/loqgraphicsobject.cpp \
|
||||
LoQClass/loqgraphicsvideoitem.cpp \
|
||||
LoQClass/loqgraphicsview.cpp \
|
||||
LoQClass/loqheaderviewcheckbox.cpp \
|
||||
|
@ -187,7 +186,6 @@ HEADERS += \
|
|||
LoQClass/locolorselector.h \
|
||||
LoQClass/lodateselector.h \
|
||||
LoQClass/loglwindow.h \
|
||||
LoQClass/loqgraphicsobject.h \
|
||||
LoQClass/loqgraphicsvideoitem.h \
|
||||
LoQClass/loqgraphicsview.h \
|
||||
LoQClass/loqheaderviewcheckbox.h \
|
||||
|
@ -401,6 +399,16 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
|
|||
!isEmpty(target.path): INSTALLS += target
|
||||
|
||||
DISTFILES += \
|
||||
qss/00_Common.css \
|
||||
qss/01_Global.css \
|
||||
qss/10_MainWindow.css \
|
||||
qss/11_MainWindowTab.css \
|
||||
qss/20_DeviceManager.css \
|
||||
qss/21_DeviceSetting.css \
|
||||
qss/30_ProgramManager.css \
|
||||
qss/31_EditProgram.css \
|
||||
qss/32_PageAttr.css \
|
||||
qss/33_EWindow.css \
|
||||
qss/MainWnd.css \
|
||||
qss/MainTab.css \
|
||||
qss/TabDeviceManager.css \
|
||||
|
|
|
@ -1,578 +0,0 @@
|
|||
#include "loqgraphicsobject.h"
|
||||
#include "QCoreApplication"
|
||||
LoQGraphicsObject::LoQGraphicsObject(InteractiveType type, QGraphicsItem *parent) :
|
||||
QGraphicsObject(parent),
|
||||
m_interactiveType(type),
|
||||
m_movable(false),
|
||||
m_handleLen(10),
|
||||
m_rLimit(INVALID_RECT)
|
||||
{
|
||||
setGeometry(0, 0, 100, 100);
|
||||
init();
|
||||
}
|
||||
|
||||
LoQGraphicsObject::LoQGraphicsObject(QRectF rect, InteractiveType type, QGraphicsItem *parent) :
|
||||
QGraphicsObject(parent),
|
||||
m_interactiveType(type),
|
||||
m_movable(false),
|
||||
m_handleLen(10),
|
||||
m_rLimit(INVALID_RECT)
|
||||
{
|
||||
setGeometry(rect);
|
||||
init();
|
||||
}
|
||||
|
||||
LoQGraphicsObject::LoQGraphicsObject(qreal x, qreal y, qreal w, qreal h, InteractiveType type, QGraphicsItem *parent) :
|
||||
QGraphicsObject(parent),
|
||||
m_interactiveType(type),
|
||||
m_movable(false),
|
||||
m_handleLen(10),
|
||||
m_rLimit(INVALID_RECT)
|
||||
{
|
||||
setGeometry(x, y, w, h);
|
||||
init();
|
||||
}
|
||||
|
||||
void LoQGraphicsObject::setInteractiveType(InteractiveType type)
|
||||
{
|
||||
m_interactiveType = type;
|
||||
GraphicsItemFlags flag = flags();
|
||||
if(Dynamic == m_interactiveType) {
|
||||
flag |= ItemIsMovable;
|
||||
flag |= ItemIsSelectable;
|
||||
flag &= ~ItemIsFocusable;
|
||||
} else {
|
||||
flag &= ~ItemIsMovable;
|
||||
flag &= ~ItemIsSelectable;
|
||||
flag &= ~ItemIsFocusable;
|
||||
}
|
||||
setFlags(flag);
|
||||
}
|
||||
|
||||
void LoQGraphicsObject::init()
|
||||
{
|
||||
setInteractiveType(m_interactiveType);
|
||||
|
||||
m_handlePen.setBrush(QBrush(QColor::fromRgb(0, 255, 0)));
|
||||
m_handlePen.setWidth(1);
|
||||
|
||||
QVector<qreal> dashes;
|
||||
qreal space = 2;
|
||||
qreal solid = 2;
|
||||
dashes << solid << space << solid <<space;
|
||||
m_borderPen.setBrush(QBrush(QColor::fromRgb(0, 255, 0)));
|
||||
m_borderPen.setDashPattern(dashes);
|
||||
m_borderPen.setWidth(1);
|
||||
}
|
||||
|
||||
QRectF LoQGraphicsObject::boundingRect() const
|
||||
{
|
||||
qreal x, y, w, h;
|
||||
QRectF r = rect();
|
||||
x = r.x() - m_handleLen;
|
||||
y = r.y() - m_handleLen;
|
||||
w = r.width() + m_handleLen * 2;
|
||||
h = r.height() + m_handleLen * 2;
|
||||
return QRectF(x, y, w, h);
|
||||
}
|
||||
//绘制选中和未选中的区域边框
|
||||
void LoQGraphicsObject::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
painter->save();
|
||||
//绘制边框
|
||||
QPen pen; // creates a default pen
|
||||
|
||||
// pen.setStyle(Qt::DashDotLine);
|
||||
// QLinearGradient svGradient(0, 0, 2, 0);
|
||||
// svGradient.setColorAt(1, QColor("#00ff00"));
|
||||
// svGradient.setColorAt(0, QColor("#ffffff"));
|
||||
// QBrush myBrush(svGradient);
|
||||
|
||||
QString qexeFullPath = QCoreApplication::applicationDirPath();
|
||||
QString qtBordImage=qexeFullPath+"/m/"+"M8_8.bmp";
|
||||
QPixmap aa(qtBordImage);
|
||||
int iBordWidth=aa.height();
|
||||
pen.setWidth(iBordWidth);
|
||||
QBrush myBrush(aa);
|
||||
//myBrush.setTexture(aa);
|
||||
pen.setBrush(myBrush);
|
||||
pen.setCapStyle(Qt::RoundCap);
|
||||
pen.setJoinStyle(Qt::RoundJoin);
|
||||
|
||||
|
||||
QPainterPath path;
|
||||
|
||||
path.moveTo(iBordWidth/2,iBordWidth/2);
|
||||
path.lineTo(rect().right()-iBordWidth/2,iBordWidth/2);
|
||||
path.lineTo(rect().right()-iBordWidth/2,rect().bottom()-iBordWidth/2);
|
||||
path.lineTo(iBordWidth/2,rect().bottom()-iBordWidth/2);
|
||||
path.lineTo(iBordWidth/2,iBordWidth/2);
|
||||
painter->setPen(pen);
|
||||
painter->drawPath(path);
|
||||
|
||||
QMatrix matrix2;
|
||||
matrix2.rotate(90);
|
||||
QBrush myBrush2;
|
||||
QPixmap bb=aa.transformed(matrix2, Qt::SmoothTransformation);
|
||||
myBrush2.setTexture(bb);
|
||||
QPen pen2;
|
||||
pen2.setBrush(myBrush2);
|
||||
QPainterPath path2;
|
||||
path2.moveTo(rect().right()-iBordWidth/2,iBordWidth/2);
|
||||
path2.lineTo(rect().right()-iBordWidth/2,rect().bottom()-iBordWidth/2);
|
||||
painter->setPen(pen2);
|
||||
painter->drawPath(path2);
|
||||
|
||||
//QMatrix matrix3;
|
||||
//matrix3.rotate(0);
|
||||
// QBrush myBrush3;
|
||||
// QPainterPath path3;
|
||||
//// myBrush3.setTexture(aa);
|
||||
//// pen.setBrush(myBrush);
|
||||
//// painter->setPen(pen);
|
||||
// path3.moveTo(rect().right()-iBordWidth/2,rect().bottom()-iBordWidth/2);
|
||||
// path3.lineTo(iBordWidth/2,rect().bottom()-iBordWidth/2);
|
||||
// painter->drawPath(path3);
|
||||
|
||||
// QMatrix matrix4;
|
||||
// matrix4.rotate(270);
|
||||
// QBrush myBrush4;
|
||||
// QPainterPath path4;
|
||||
// myBrush4.setTexture(aa.transformed(matrix4, Qt::SmoothTransformation));
|
||||
// pen.setBrush(myBrush4);
|
||||
// path4.moveTo(iBordWidth/2,rect().bottom()-iBordWidth/2);
|
||||
// path4.lineTo(iBordWidth/2,iBordWidth/2);
|
||||
// painter->drawPath(path4);
|
||||
|
||||
if(isSelected()) {
|
||||
QPainterPath pRect;
|
||||
pRect.addRect(rect());
|
||||
m_borderPen.setBrush(QBrush(QColor::fromRgb(0, 255, 0)));
|
||||
painter->setPen(m_borderPen);
|
||||
painter->drawPath(pRect);
|
||||
QPainterPath pHandle;
|
||||
pHandle.addRect(m_rLT);
|
||||
pHandle.addRect(m_rT);
|
||||
pHandle.addRect(m_rRT);
|
||||
pHandle.addRect(m_rL);
|
||||
pHandle.addRect(m_rR);
|
||||
pHandle.addRect(m_rLB);
|
||||
pHandle.addRect(m_rB);
|
||||
pHandle.addRect(m_rRB);
|
||||
painter->setPen(m_handlePen);
|
||||
painter->drawPath(pHandle);
|
||||
}
|
||||
else {
|
||||
|
||||
m_borderPen.setBrush(QBrush(QColor::fromRgb(0, 125, 0)));
|
||||
|
||||
QPainterPath pRect;
|
||||
pRect.addRect(rect());
|
||||
painter->setPen(m_borderPen);
|
||||
painter->drawPath(pRect);
|
||||
|
||||
}
|
||||
|
||||
//磁条吸附时两化吸附的边
|
||||
QPen CitiePen=QPen(QColor::fromRgb(0, 255, 0),1,Qt::SolidLine);
|
||||
painter->setPen(CitiePen);
|
||||
//if(bMousePress)
|
||||
{
|
||||
if (bLeftCitie) {
|
||||
painter->setPen(CitiePen);
|
||||
//painter->drawLine(QPointF(rect().x(),rect().y()-100),QPointF(rect().x(),rect().bottom()+100));
|
||||
painter->drawLine(QPointF(rect().topLeft()),QPointF(rect().bottomLeft()));
|
||||
}
|
||||
if (bTopCitie) {
|
||||
painter->setPen(CitiePen);
|
||||
painter->drawLine(QPointF(rect().topLeft()),QPointF(rect().topRight()));
|
||||
}
|
||||
if (bRightCitie) {
|
||||
painter->setPen(CitiePen);
|
||||
painter->drawLine(QPointF(rect().topRight()),QPointF(rect().bottomRight()));
|
||||
}
|
||||
if (bBottomCitie) {
|
||||
painter->setPen(CitiePen);
|
||||
painter->drawLine(QPointF(rect().bottomLeft()),QPointF(rect().bottomRight()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// QPen(const QBrush &brush,
|
||||
// qreal width,
|
||||
// Qt::PenStyle style = Qt::SolidLine,
|
||||
// Qt::PenCapStyle cap = Qt::SquareCap,
|
||||
// Qt::PenJoinStyle join = Qt::BevelJoin);
|
||||
// QPen pen(Qt::green, 3, Qt::DashDotLine, Qt::RoundCap, Qt::RoundJoin);
|
||||
|
||||
|
||||
//painter->drawLine(QPointF(rect().bottomLeft()),QPointF(rect().bottomRight()));
|
||||
painter->restore();
|
||||
}
|
||||
void LoQGraphicsObject::setBrightBianLeft(bool b)
|
||||
{
|
||||
//if(bMousePress)
|
||||
// {
|
||||
// bLeftCitie=b;
|
||||
|
||||
// }
|
||||
// else {
|
||||
// bLeftCitie=false;
|
||||
// }
|
||||
bLeftCitie=b;
|
||||
updateGeometry();
|
||||
|
||||
}
|
||||
void LoQGraphicsObject::setBrightBianRight(bool b)
|
||||
{
|
||||
// if(bMousePress)
|
||||
// {
|
||||
// bRightCitie=b;
|
||||
|
||||
// }
|
||||
// else {
|
||||
// bRightCitie=false;
|
||||
// }
|
||||
bRightCitie=b;
|
||||
updateGeometry();
|
||||
|
||||
}
|
||||
void LoQGraphicsObject::setBrightBianTop(bool b)
|
||||
{
|
||||
// if(bMousePress)
|
||||
// {
|
||||
// bTopCitie=b;
|
||||
|
||||
// }
|
||||
// else {
|
||||
// bTopCitie=false;
|
||||
// }
|
||||
bTopCitie=b;
|
||||
updateGeometry();
|
||||
|
||||
}
|
||||
void LoQGraphicsObject::setBrightBianbottom(bool b)
|
||||
{
|
||||
// if(bMousePress)
|
||||
// {
|
||||
// bBottomCitie=b;
|
||||
|
||||
// }
|
||||
// else {
|
||||
// bBottomCitie=false;
|
||||
// }
|
||||
bBottomCitie=b;
|
||||
updateGeometry();
|
||||
|
||||
}
|
||||
void LoQGraphicsObject::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
// return;
|
||||
if(false == m_movable) return;
|
||||
|
||||
qreal cx, cy, cw, ch;
|
||||
qreal mx, my, mw, mh;
|
||||
QPointF ePos = pointToParent(event->pos());
|
||||
QPointF absoluteOfs = ePos - m_pOrg;
|
||||
|
||||
mx = m_rOrg.x();
|
||||
my = m_rOrg.y();
|
||||
mw = m_w;
|
||||
mh = m_h;
|
||||
|
||||
if(m_hDir != NONE) {
|
||||
prepareGeometryChange();
|
||||
|
||||
switch(m_hDir) {
|
||||
case LT:
|
||||
cx = m_rOrg.x() + absoluteOfs.x();
|
||||
cy = m_rOrg.y() + absoluteOfs.y();
|
||||
if(m_rOrg.right() - cx < m_handleLen) cx = m_rOrg.right() - m_handleLen;
|
||||
if(m_rOrg.bottom() - cy < m_handleLen) cy = m_rOrg.bottom() - m_handleLen;
|
||||
mx = cx;
|
||||
my = cy;
|
||||
if(m_rLimit != INVALID_RECT) {
|
||||
if(mx < 0) mx = 0;
|
||||
if(my < 0) my = 0;
|
||||
}
|
||||
mw = m_rOrg.right() - mx;
|
||||
mh = m_rOrg.bottom() - my;
|
||||
break;
|
||||
|
||||
case T:
|
||||
cy = m_rOrg.y() + absoluteOfs.y();
|
||||
if(m_rOrg.bottom() - cy < m_handleLen) cy = m_rOrg.bottom() - m_handleLen;
|
||||
my = cy;
|
||||
if(m_rLimit != INVALID_RECT) {
|
||||
if(my < 0) my = 0;
|
||||
}
|
||||
mh = m_rOrg.bottom() - my;
|
||||
break;
|
||||
|
||||
case RT:
|
||||
cy = m_rOrg.y() + absoluteOfs.y();
|
||||
cw = m_rOrg.width() + absoluteOfs.x();
|
||||
if(m_rOrg.bottom() - cy < m_handleLen) cy = m_rOrg.bottom() - m_handleLen;
|
||||
if(cw < m_handleLen) cw = m_handleLen;
|
||||
my = cy;
|
||||
mw = cw;
|
||||
if(m_rLimit != INVALID_RECT) {
|
||||
if(my < 0) my = 0;
|
||||
if(mx + mw > m_rLimit.width()) mw = m_rLimit.width() - mx;
|
||||
}
|
||||
mh = m_rOrg.bottom() - my;
|
||||
break;
|
||||
|
||||
case L:
|
||||
cx = m_rOrg.x() + absoluteOfs.x();
|
||||
if(m_rOrg.right() - cx < m_handleLen) cx = m_rOrg.right() - m_handleLen;
|
||||
mx = cx;
|
||||
if(m_rLimit != INVALID_RECT) {
|
||||
if(mx < 0) mx = 0;
|
||||
}
|
||||
mw = m_rOrg.right() - mx;
|
||||
break;
|
||||
|
||||
case R:
|
||||
cw = m_rOrg.width() + absoluteOfs.x();
|
||||
if(cw < m_handleLen) cw = m_handleLen;
|
||||
mw = cw;
|
||||
if(m_rLimit != INVALID_RECT) {
|
||||
if(mx + mw > m_rLimit.width()) mw = m_rLimit.width() - mx;
|
||||
}
|
||||
break;
|
||||
|
||||
case LB:
|
||||
cx = m_rOrg.x() + absoluteOfs.x();
|
||||
ch = m_rOrg.height() + absoluteOfs.y();
|
||||
if(m_rOrg.right() - cx < m_handleLen) cx = m_rOrg.right() - m_handleLen;
|
||||
if(ch < m_handleLen) ch = m_handleLen;
|
||||
mx = cx;
|
||||
if(m_rLimit != INVALID_RECT) {
|
||||
if(mx < 0) mx = 0;
|
||||
}
|
||||
mw = m_rOrg.right() - mx;
|
||||
mh = ch;
|
||||
if(m_rLimit != INVALID_RECT) {
|
||||
if(my + mh > m_rLimit.height()) mh = m_rLimit.height() - my;
|
||||
}
|
||||
break;
|
||||
|
||||
case B:
|
||||
ch = m_rOrg.height() + absoluteOfs.y();
|
||||
if(ch < m_handleLen) ch = m_handleLen;
|
||||
mh = ch;
|
||||
if(m_rLimit != INVALID_RECT) {
|
||||
if(my + mh > m_rLimit.height()) mh = m_rLimit.height() - my;
|
||||
}
|
||||
break;
|
||||
|
||||
case RB:
|
||||
cw = m_rOrg.width() + absoluteOfs.x();
|
||||
ch = m_rOrg.height() + absoluteOfs.y();
|
||||
if(cw < m_handleLen) cw = m_handleLen;
|
||||
if(ch < m_handleLen) ch = m_handleLen;
|
||||
mw = cw;
|
||||
mh = ch;
|
||||
if(m_rLimit != INVALID_RECT) {
|
||||
if(mx + mw > m_rLimit.width()) mw = m_rLimit.width() - mx;
|
||||
if(my + mh > m_rLimit.height()) mh = m_rLimit.height() - my;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
setPos(mx, my);
|
||||
m_w = mw;
|
||||
m_h = mh;
|
||||
adjustHandle();
|
||||
updateGeometry(m_rOrg);
|
||||
rectChanged(rect());
|
||||
} else {
|
||||
mx = m_rOrg.x() + absoluteOfs.x();
|
||||
my = m_rOrg.y() + absoluteOfs.y();
|
||||
if(m_rLimit != INVALID_RECT) {
|
||||
if(mx < 0) mx = 0;
|
||||
if(my < 0) my = 0;
|
||||
if(mx + mw > m_rLimit.width()) mx = m_rLimit.width() - mw;
|
||||
if(my + mh > m_rLimit.height()) my = m_rLimit.height() - mh;
|
||||
}
|
||||
setPos(mx, my);
|
||||
}
|
||||
|
||||
geometryChanged(geometry());
|
||||
if(bMousePress)
|
||||
{
|
||||
|
||||
emit sigCiTie(true,m_hDir);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void LoQGraphicsObject::setRLimit(const QRectF &r)
|
||||
{
|
||||
if(m_rLimit != INVALID_RECT) {
|
||||
qreal mx, my, mw, mh;
|
||||
qreal scale_w = r.width() / m_rLimit.width();
|
||||
qreal scale_h = r.height() / m_rLimit.height();
|
||||
mx = std::round(x() * scale_w);
|
||||
my = std::round(y() * scale_h);
|
||||
mw = std::round(m_w * scale_w);
|
||||
mh = std::round(m_h * scale_h);
|
||||
setPos(mx, my);
|
||||
m_w = mw;
|
||||
m_h = mh;
|
||||
adjustHandle();
|
||||
geometryChanged(geometry());
|
||||
}
|
||||
m_rLimit = r;
|
||||
}
|
||||
|
||||
void LoQGraphicsObject::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if(Qt::LeftButton == event->button()) {
|
||||
|
||||
m_hDir = handleDir(event->pos());
|
||||
m_pOrg = pointToParent(event->pos());
|
||||
m_rOrg = geometry();
|
||||
m_movable = true;
|
||||
bMousePress=true;
|
||||
|
||||
}
|
||||
QGraphicsItem::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void LoQGraphicsObject::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
bMousePress=false;
|
||||
|
||||
if(Qt::LeftButton == event->button()) {
|
||||
m_hDir = NONE;
|
||||
m_movable = false;
|
||||
bLeftCitie=false;
|
||||
bRightCitie=false;
|
||||
bTopCitie=false;
|
||||
bBottomCitie=false;
|
||||
m_keyPressId++;
|
||||
emit sigCiTie(false,m_keyPressId);
|
||||
|
||||
}
|
||||
QGraphicsItem::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void LoQGraphicsObject::setGeometry(const QRectF &r)
|
||||
{
|
||||
if(r != geometry()) {
|
||||
prepareGeometryChange();
|
||||
setPos(r.x(), r.y());
|
||||
m_w = r.width();
|
||||
m_h = r.height();
|
||||
adjustHandle();
|
||||
emit rectChanged(rect());
|
||||
}
|
||||
}
|
||||
|
||||
void LoQGraphicsObject::updateGeometry()
|
||||
{
|
||||
QRectF r = geometry();
|
||||
qreal x, y, w, h;
|
||||
x = r.x() - m_handleLen;
|
||||
y = r.y() - m_handleLen;
|
||||
w = r.width() + m_handleLen * 2;
|
||||
h = r.height() + m_handleLen * 2;
|
||||
r = QRectF(x, y, w, h);
|
||||
if(nullptr != scene()) {
|
||||
scene()->update(r);
|
||||
}
|
||||
emit requestUpdate(r);
|
||||
}
|
||||
|
||||
void LoQGraphicsObject::updateGeometry(const QRectF &gC, const QRectF &gL)
|
||||
{
|
||||
qreal x, y, w, h;
|
||||
QRectF gCur, gLast;
|
||||
x = gC.x() - m_handleLen;
|
||||
y = gC.y() - m_handleLen;
|
||||
w = gC.width() + m_handleLen * 2;
|
||||
h = gC.height() + m_handleLen * 2;
|
||||
gCur = QRectF(x, y, w, h);
|
||||
x = gL.x() - m_handleLen;
|
||||
y = gL.y() - m_handleLen;
|
||||
w = gL.width() + m_handleLen * 2;
|
||||
h = gL.height() + m_handleLen * 2;
|
||||
gLast = QRectF(x, y, w, h);
|
||||
qreal l = (gCur.left() < gLast.left()) ? gCur.left() : gLast.left();
|
||||
qreal t = (gCur.top() < gLast.top()) ? gCur.top() : gLast.top();
|
||||
qreal r = (gCur.right() > gLast.right()) ? gCur.right() : gLast.right();
|
||||
qreal b = (gCur.bottom() > gLast.bottom()) ? gCur.bottom() : gLast.bottom();
|
||||
QRectF gFlash = QRectF(QPointF(l, t), QPointF(r, b));
|
||||
if(nullptr != scene()) {
|
||||
scene()->update(gFlash);
|
||||
}
|
||||
emit requestUpdate(gFlash);
|
||||
}
|
||||
|
||||
QPointF LoQGraphicsObject::pointToParent(const QPointF &p)
|
||||
{
|
||||
qreal px, py;
|
||||
px = p.x() + x();
|
||||
py = p.y() + y();
|
||||
return QPointF(px, py);
|
||||
}
|
||||
|
||||
LoQGraphicsObject::HANDLE_DIR LoQGraphicsObject::handleDir(const QPointF &p)
|
||||
{
|
||||
HANDLE_DIR hDir = NONE;
|
||||
if(isSelected()) {
|
||||
if(m_rLT.contains(p)) hDir = LT;
|
||||
else if(m_rT.contains(p)) hDir = T;
|
||||
else if(m_rRT.contains(p)) hDir = RT;
|
||||
else if(m_rL.contains(p)) hDir = L;
|
||||
else if(m_rR.contains(p)) hDir = R;
|
||||
else if(m_rLB.contains(p)) hDir = LB;
|
||||
else if(m_rB.contains(p)) hDir = B;
|
||||
else if(m_rRB.contains(p)) hDir = RB;
|
||||
}
|
||||
return hDir;
|
||||
}
|
||||
//拖拽的虚线矩形
|
||||
void LoQGraphicsObject::adjustHandle()
|
||||
{
|
||||
const QRectF &r = rect();
|
||||
//左上角
|
||||
m_rLT = QRectF(r.left() - m_handleLen/2,
|
||||
r.top() - m_handleLen/2,
|
||||
m_handleLen, m_handleLen);
|
||||
//上中
|
||||
m_rT = QRectF(r.center().x() - m_handleLen / 2,
|
||||
r.top() - m_handleLen/2,
|
||||
m_handleLen, m_handleLen);
|
||||
//右上角
|
||||
m_rRT = QRectF(r.right()-m_handleLen/2,
|
||||
r.top() - m_handleLen/2,
|
||||
m_handleLen, m_handleLen);
|
||||
//左中
|
||||
m_rL = QRectF(r.left() - m_handleLen/2,
|
||||
r.center().y() - m_handleLen / 2,
|
||||
m_handleLen, m_handleLen);
|
||||
//右中
|
||||
m_rR = QRectF(r.right()-m_handleLen/2,
|
||||
r.center().y() - m_handleLen / 2,
|
||||
m_handleLen, m_handleLen);
|
||||
//左下角
|
||||
m_rLB = QRectF(r.left() - m_handleLen/2,
|
||||
r.bottom()-m_handleLen / 2,
|
||||
m_handleLen, m_handleLen);
|
||||
//中下
|
||||
m_rB = QRectF(r.center().x() - m_handleLen / 2,
|
||||
r.bottom()-m_handleLen / 2,
|
||||
m_handleLen, m_handleLen);
|
||||
//右下角
|
||||
m_rRB = QRectF(r.right()-m_handleLen / 2,
|
||||
r.bottom()-m_handleLen / 2,
|
||||
m_handleLen, m_handleLen);
|
||||
}
|
|
@ -1,117 +0,0 @@
|
|||
#ifndef LOQGRAPHICSOBJECT_H
|
||||
#define LOQGRAPHICSOBJECT_H
|
||||
|
||||
#include <cmath>
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsObject>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
|
||||
#define INVALID_RECT QRect(-1, -5, -6, -8)
|
||||
|
||||
class LoQGraphicsObject : public QGraphicsObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
typedef enum {
|
||||
NONE = 0,
|
||||
LT,
|
||||
T,
|
||||
RT,
|
||||
L,
|
||||
R,
|
||||
LB,
|
||||
B,
|
||||
RB
|
||||
} HANDLE_DIR;
|
||||
|
||||
public:
|
||||
enum InteractiveType {
|
||||
Dynamic = 0,
|
||||
Static,
|
||||
Custom
|
||||
};
|
||||
|
||||
public:
|
||||
explicit LoQGraphicsObject(InteractiveType type = Dynamic, QGraphicsItem *parent = nullptr);
|
||||
LoQGraphicsObject(QRectF rect, InteractiveType type = Dynamic, QGraphicsItem *parent = nullptr);
|
||||
LoQGraphicsObject(qreal x, qreal y, qreal w, qreal h, InteractiveType type = Dynamic, QGraphicsItem *parent = nullptr);
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
public:
|
||||
virtual QRectF boundingRect() const override;
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
virtual void setInteractiveType(InteractiveType type = Dynamic);
|
||||
|
||||
public:
|
||||
InteractiveType interactiveType() const { return m_interactiveType; }
|
||||
QRectF rect() const { return QRectF(0, 0, m_w, m_h); }
|
||||
QRectF geometry() const { return QRectF(x(), y(), m_w, m_h); }
|
||||
|
||||
public:
|
||||
void setRLimit(const QRectF &r);
|
||||
QRectF rLimit() const { return m_rLimit; }
|
||||
|
||||
signals:
|
||||
void requestUpdate(const QRectF &);
|
||||
void geometryChanged(const QRectF &);
|
||||
void rectChanged(const QRectF &);
|
||||
|
||||
void sigCiTie(bool,int);
|
||||
public slots:
|
||||
void setGeometry (qreal x, qreal y, qreal w, qreal h) { setGeometry(QRectF(x, y, w, h)); }
|
||||
void setGeometry (const QRectF &r);
|
||||
void updateGeometry();
|
||||
void updateGeometry(const QRectF &gLast) { updateGeometry(geometry(), gLast); }
|
||||
void updateGeometry(const QRectF &gCur, const QRectF &gLast);
|
||||
void setBrightBianLeft(bool);
|
||||
void setBrightBianTop(bool);
|
||||
void setBrightBianRight(bool);
|
||||
void setBrightBianbottom(bool);
|
||||
|
||||
protected:
|
||||
int handleLen() const { return m_handleLen; }
|
||||
QPointF pointToParent(const QPointF &p);
|
||||
HANDLE_DIR handleDir(const QPointF &p);
|
||||
void adjustHandle();
|
||||
|
||||
private:
|
||||
InteractiveType m_interactiveType;
|
||||
bool m_movable;
|
||||
int m_handleLen;
|
||||
QPen m_handlePen;
|
||||
QPen m_borderPen;
|
||||
|
||||
private:
|
||||
qreal m_w;
|
||||
qreal m_h;
|
||||
QRectF m_rLT;
|
||||
QRectF m_rT;
|
||||
|
||||
QRectF m_rRT;
|
||||
QRectF m_rL;
|
||||
QRectF m_rR;
|
||||
QRectF m_rLB;
|
||||
QRectF m_rB;
|
||||
QRectF m_rRB;
|
||||
QRectF m_rOrg;
|
||||
QPointF m_pOrg;
|
||||
HANDLE_DIR m_hDir;
|
||||
QRectF m_rLimit;
|
||||
bool bMousePress=false;
|
||||
bool bLeftCitie=false;
|
||||
bool bRightCitie=false;
|
||||
bool bTopCitie=false;
|
||||
bool bBottomCitie=false;
|
||||
int m_keyPressId=0;
|
||||
|
||||
};
|
||||
|
||||
#endif // LOQGRAPHICSOBJECT_H
|
|
@ -23,19 +23,15 @@ void LoQHeaderViewCheckBox::HideHeaderCheckBox(bool b)
|
|||
}
|
||||
void LoQHeaderViewCheckBox::paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const
|
||||
{
|
||||
qDebug() <<"paintSection -s";
|
||||
QHeaderView::paintSection(painter, rect, logicalIndex);
|
||||
if (logicalIndex == 0) {
|
||||
m_checkBox->setGeometry(rect);
|
||||
}
|
||||
qDebug() <<"paintSection -o";
|
||||
}
|
||||
|
||||
void LoQHeaderViewCheckBox::onAllChecked(bool f)
|
||||
{
|
||||
qDebug() <<"onAllChecked -s";
|
||||
m_checkBox->blockSignals(true);
|
||||
m_checkBox->setChecked(f);
|
||||
m_checkBox->blockSignals(false);
|
||||
qDebug() <<"onAllChecked -o";
|
||||
}
|
||||
|
|
|
@ -1,5 +1,79 @@
|
|||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>res/splash.png</file>
|
||||
<file>res/borders/M1_0.bmp</file>
|
||||
<file>res/borders/M1_1.bmp</file>
|
||||
<file>res/borders/M1_2.bmp</file>
|
||||
<file>res/borders/M1_3.bmp</file>
|
||||
<file>res/borders/M1_4.bmp</file>
|
||||
<file>res/borders/M1_5.bmp</file>
|
||||
<file>res/borders/M1_6.bmp</file>
|
||||
<file>res/borders/M1_7.bmp</file>
|
||||
<file>res/borders/M1_8.bmp</file>
|
||||
<file>res/borders/M2_0.bmp</file>
|
||||
<file>res/borders/M2_1.bmp</file>
|
||||
<file>res/borders/M2_2.bmp</file>
|
||||
<file>res/borders/M2_3.bmp</file>
|
||||
<file>res/borders/M2_4.bmp</file>
|
||||
<file>res/borders/M2_5.bmp</file>
|
||||
<file>res/borders/M2_6.bmp</file>
|
||||
<file>res/borders/M2_7.bmp</file>
|
||||
<file>res/borders/M2_8.bmp</file>
|
||||
<file>res/borders/M3_0.bmp</file>
|
||||
<file>res/borders/M3_1.bmp</file>
|
||||
<file>res/borders/M3_2.bmp</file>
|
||||
<file>res/borders/M3_3.bmp</file>
|
||||
<file>res/borders/M3_4.bmp</file>
|
||||
<file>res/borders/M3_5.bmp</file>
|
||||
<file>res/borders/M3_6.bmp</file>
|
||||
<file>res/borders/M3_7.bmp</file>
|
||||
<file>res/borders/M3_8.bmp</file>
|
||||
<file>res/borders/M4_0.bmp</file>
|
||||
<file>res/borders/M4_1.bmp</file>
|
||||
<file>res/borders/M4_2.bmp</file>
|
||||
<file>res/borders/M4_3.bmp</file>
|
||||
<file>res/borders/M4_4.bmp</file>
|
||||
<file>res/borders/M4_5.bmp</file>
|
||||
<file>res/borders/M4_6.bmp</file>
|
||||
<file>res/borders/M4_7.bmp</file>
|
||||
<file>res/borders/M4_8.bmp</file>
|
||||
<file>res/borders/M5_0.bmp</file>
|
||||
<file>res/borders/M5_1.bmp</file>
|
||||
<file>res/borders/M5_2.bmp</file>
|
||||
<file>res/borders/M5_3.bmp</file>
|
||||
<file>res/borders/M5_4.bmp</file>
|
||||
<file>res/borders/M5_5.bmp</file>
|
||||
<file>res/borders/M5_6.bmp</file>
|
||||
<file>res/borders/M5_7.bmp</file>
|
||||
<file>res/borders/M5_8.bmp</file>
|
||||
<file>res/borders/M6_0.bmp</file>
|
||||
<file>res/borders/M6_1.bmp</file>
|
||||
<file>res/borders/M6_2.bmp</file>
|
||||
<file>res/borders/M6_3.bmp</file>
|
||||
<file>res/borders/M6_4.bmp</file>
|
||||
<file>res/borders/M6_5.bmp</file>
|
||||
<file>res/borders/M6_6.bmp</file>
|
||||
<file>res/borders/M6_7.bmp</file>
|
||||
<file>res/borders/M6_8.bmp</file>
|
||||
<file>res/borders/M6_9.bmp</file>
|
||||
<file>res/borders/M7_0.bmp</file>
|
||||
<file>res/borders/M7_1.bmp</file>
|
||||
<file>res/borders/M7_2.bmp</file>
|
||||
<file>res/borders/M7_3.bmp</file>
|
||||
<file>res/borders/M7_4.bmp</file>
|
||||
<file>res/borders/M7_5.bmp</file>
|
||||
<file>res/borders/M7_6.bmp</file>
|
||||
<file>res/borders/M7_7.bmp</file>
|
||||
<file>res/borders/M7_8.bmp</file>
|
||||
<file>res/borders/M8_0.bmp</file>
|
||||
<file>res/borders/M8_1.bmp</file>
|
||||
<file>res/borders/M8_2.bmp</file>
|
||||
<file>res/borders/M8_3.bmp</file>
|
||||
<file>res/borders/M8_4.bmp</file>
|
||||
<file>res/borders/M8_5.bmp</file>
|
||||
<file>res/borders/M8_6.bmp</file>
|
||||
<file>res/borders/M8_7.bmp</file>
|
||||
<file>res/borders/M8_8.bmp</file>
|
||||
<file>res/borders/M9_0.bmp</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
After Width: | Height: | Size: 248 B |
After Width: | Height: | Size: 248 B |
After Width: | Height: | Size: 248 B |
After Width: | Height: | Size: 248 B |
After Width: | Height: | Size: 248 B |
After Width: | Height: | Size: 248 B |
After Width: | Height: | Size: 248 B |
After Width: | Height: | Size: 248 B |
After Width: | Height: | Size: 248 B |
After Width: | Height: | Size: 440 B |
After Width: | Height: | Size: 440 B |
After Width: | Height: | Size: 440 B |
After Width: | Height: | Size: 440 B |
After Width: | Height: | Size: 440 B |
After Width: | Height: | Size: 440 B |
After Width: | Height: | Size: 440 B |
After Width: | Height: | Size: 440 B |
After Width: | Height: | Size: 440 B |
After Width: | Height: | Size: 632 B |
After Width: | Height: | Size: 632 B |
After Width: | Height: | Size: 632 B |
After Width: | Height: | Size: 632 B |
After Width: | Height: | Size: 632 B |
After Width: | Height: | Size: 632 B |
After Width: | Height: | Size: 632 B |
After Width: | Height: | Size: 632 B |
After Width: | Height: | Size: 632 B |
After Width: | Height: | Size: 824 B |
After Width: | Height: | Size: 824 B |
After Width: | Height: | Size: 824 B |
After Width: | Height: | Size: 824 B |
After Width: | Height: | Size: 824 B |
After Width: | Height: | Size: 824 B |
After Width: | Height: | Size: 824 B |
After Width: | Height: | Size: 824 B |
After Width: | Height: | Size: 824 B |
After Width: | Height: | Size: 1016 B |
After Width: | Height: | Size: 1016 B |
After Width: | Height: | Size: 1016 B |
After Width: | Height: | Size: 1016 B |
After Width: | Height: | Size: 1016 B |
After Width: | Height: | Size: 1016 B |
After Width: | Height: | Size: 1016 B |
After Width: | Height: | Size: 1016 B |
After Width: | Height: | Size: 1016 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.7 KiB |
|
@ -137,9 +137,7 @@ void wDevicesItem::DeviceItemHttpPost()
|
|||
HttpPostByTypeJsonObject(json8);
|
||||
|
||||
}
|
||||
void wDevicesItem::onSendHeartbeat()
|
||||
{
|
||||
qDebug() <<"wDevicesItem::onSendHeartbeat()";
|
||||
void wDevicesItem::onSendHeartbeat(){
|
||||
m_HeartbeatCount++;
|
||||
// qDebug()<< "m_HeartbeatCount="<<m_HeartbeatCount;
|
||||
QJsonObject json4;
|
||||
|
@ -171,7 +169,6 @@ void wDevicesItem::OnControlTcpSend(int iProgramIndex)
|
|||
|
||||
void wDevicesItem::HttpPostByTypeJsonObject(QJsonObject json)
|
||||
{
|
||||
qDebug() <<"wDevicesItem::HttpPostByTypeJsonObject()";
|
||||
QJsonDocument doc;
|
||||
doc.setObject(json);
|
||||
QByteArray post_loginArray = doc.toJson(QJsonDocument::Compact);
|
||||
|
|
|
@ -1,53 +1,86 @@
|
|||
#include "eobject.h"
|
||||
#include "eobjectattr.h"
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
|
||||
eObject::eObject(InteractiveType type, QGraphicsItem *parent) :
|
||||
LoQGraphicsObject(type, parent)
|
||||
{
|
||||
eObject::eObject(InteractiveType type, QGraphicsItem *parent) : QGraphicsObject(parent),
|
||||
m_interactiveType(type),
|
||||
m_movable(false),
|
||||
m_handleLen(10),
|
||||
m_rLimit(INVALID_RECT) {
|
||||
setGeometry(0, 0, 100, 100);
|
||||
init();
|
||||
}
|
||||
|
||||
eObject::eObject(QRectF rect, InteractiveType type, QGraphicsItem *parent) :
|
||||
LoQGraphicsObject(rect, type, parent)
|
||||
{
|
||||
eObject::eObject(QRectF rect, InteractiveType type, QGraphicsItem *parent) : QGraphicsObject(parent),
|
||||
m_interactiveType(type),
|
||||
m_movable(false),
|
||||
m_handleLen(10),
|
||||
m_rLimit(INVALID_RECT) {
|
||||
setGeometry(rect);
|
||||
init();
|
||||
}
|
||||
|
||||
eObject::eObject(const QJsonObject &json, InteractiveType type, QGraphicsItem *parent) :
|
||||
LoQGraphicsObject(type, parent)
|
||||
{
|
||||
setZValue(json["order"].toInt());//toDouble());
|
||||
// setGeometry(QRectF(json["x"].toDouble(), json["y"].toDouble(),
|
||||
// json["w"].toDouble(), json["h"].toDouble()));
|
||||
eObject::eObject(const QJsonObject &json, InteractiveType type, QGraphicsItem *parent) : QGraphicsObject(parent),
|
||||
m_interactiveType(type),
|
||||
m_movable(false),
|
||||
m_handleLen(10),
|
||||
m_rLimit(INVALID_RECT) {
|
||||
setZValue(json["order"].toInt());
|
||||
setGeometry(QRectF(json["x"].toInt(), json["y"].toInt(),
|
||||
json["w"].toInt(), json["h"].toInt()));
|
||||
init();
|
||||
}
|
||||
|
||||
void eObject::init()
|
||||
{
|
||||
void eObject::init(){
|
||||
qDebug()<<"eObject::init()";
|
||||
setInteractiveType(m_interactiveType);
|
||||
|
||||
m_handlePen.setBrush(QBrush(QColor::fromRgb(0, 255, 0)));
|
||||
m_handlePen.setWidth(1);
|
||||
|
||||
QVector<qreal> dashes;
|
||||
qreal space = 2;
|
||||
qreal solid = 2;
|
||||
dashes << solid << space << solid <<space;
|
||||
m_borderPen.setBrush(QBrush(QColor::fromRgb(0, 255, 0)));
|
||||
m_borderPen.setDashPattern(dashes);
|
||||
m_borderPen.setWidth(1);
|
||||
|
||||
connect(this, SIGNAL(sPlayBQ()), this, SLOT(playElectment()), Qt::BlockingQueuedConnection);
|
||||
connect(this, SIGNAL(sStopBQ()), this, SLOT(stopElectment()), Qt::BlockingQueuedConnection);
|
||||
|
||||
|
||||
}
|
||||
void eObject::setInteractiveType(InteractiveType type){
|
||||
qDebug()<<"eObject::setInteractiveType(InteractiveType)";
|
||||
m_interactiveType = type;
|
||||
GraphicsItemFlags flag = flags();
|
||||
if(Dynamic == m_interactiveType) {
|
||||
flag |= ItemIsMovable;
|
||||
flag |= ItemIsSelectable;
|
||||
flag &= ~ItemIsFocusable;
|
||||
} else {
|
||||
flag &= ~ItemIsMovable;
|
||||
flag &= ~ItemIsSelectable;
|
||||
flag &= ~ItemIsFocusable;
|
||||
}
|
||||
setFlags(flag);
|
||||
}
|
||||
|
||||
QWidget* eObject::wAttr()
|
||||
{
|
||||
Data data;
|
||||
data.x = geometry().x();
|
||||
data.y = geometry().y();
|
||||
data.w = geometry().width();
|
||||
data.h = geometry().height();
|
||||
eObjectAttr *w = new eObjectAttr(data, rLimit());
|
||||
connect(this, SIGNAL(geometryChanged(const QRectF &)), this, SLOT(onAttrSetting(const QRectF &)));
|
||||
connect( w, SIGNAL(sAttrChanged(const eObject::Data &)), this, SLOT(onAttrChanged(const eObject::Data &)));
|
||||
connect(this, SIGNAL(sAttrSetting(const eObject::Data &)), w, SLOT(onAttrSetting(const eObject::Data &)));
|
||||
m_wAttr = w;
|
||||
return w;
|
||||
QWidget* eObject::wAttr(){
|
||||
qDebug()<<"eObject::wAttr()";
|
||||
m_wAttr = new eObjectAttr(geometry(), rLimit());
|
||||
connect(this, SIGNAL(geometryChanged(const QRectF &)), m_wAttr, SLOT(onAttrSetting(const QRectF &)));
|
||||
connect(m_wAttr, SIGNAL(sAttrChanged(const QRectF &)), this, SLOT(onAttrChanged(const QRectF &)));
|
||||
void(QComboBox::*currentIndexChanged)(int) = &QComboBox::currentIndexChanged;
|
||||
connect(m_wAttr->borderFd, currentIndexChanged, this, [this](int idx){
|
||||
//m_wAttr->borderFd->itemIcon(idx).data_ptr().;
|
||||
});
|
||||
return m_wAttr;
|
||||
}
|
||||
|
||||
QJsonObject eObject::elementJson() const
|
||||
{
|
||||
QJsonObject eObject::elementJson() const {
|
||||
qDebug()<<"eObject::elementJson()";
|
||||
QJsonObject oRoot;
|
||||
QRectF r = geometry();
|
||||
oRoot["order"] = zValue();
|
||||
|
@ -58,39 +91,496 @@ QJsonObject eObject::elementJson() const
|
|||
return oRoot;
|
||||
}
|
||||
|
||||
void eObject::setRLimit(const QRectF r)
|
||||
{
|
||||
if(isSelected())
|
||||
m_wAttr->setRLimit(r);
|
||||
LoQGraphicsObject::setRLimit(r);
|
||||
void eObject::setRLimit(const QRectF &r) {
|
||||
qDebug()<<"eObject::setRLimit(QRectF)";
|
||||
if(isSelected()) m_wAttr->setRLimit(r);
|
||||
|
||||
if(m_rLimit != INVALID_RECT) {
|
||||
qreal mx, my, mw, mh;
|
||||
qreal scale_w = r.width() / m_rLimit.width();
|
||||
qreal scale_h = r.height() / m_rLimit.height();
|
||||
mx = std::round(x() * scale_w);
|
||||
my = std::round(y() * scale_h);
|
||||
mw = std::round(m_w * scale_w);
|
||||
mh = std::round(m_h * scale_h);
|
||||
setPos(mx, my);
|
||||
m_w = mw;
|
||||
m_h = mh;
|
||||
adjustHandle();
|
||||
geometryChanged(geometry());
|
||||
}
|
||||
m_rLimit = r;
|
||||
}
|
||||
|
||||
void eObject::onAttrChanged(const eObject::Data &data)
|
||||
{
|
||||
setGeometry(data.x, data.y, data.w, data.h);
|
||||
void eObject::onAttrChanged(const QRectF &rect){
|
||||
qDebug()<<"eObject::onAttrChanged(QRectF)";
|
||||
setGeometry(rect);
|
||||
}
|
||||
|
||||
void eObject::onAttrSetting(const QRectF &r)
|
||||
{
|
||||
eObject::Data data;
|
||||
data.x = r.x();
|
||||
data.y = r.y();
|
||||
data.w = r.width();
|
||||
data.h = r.height();
|
||||
emit sAttrSetting(data);
|
||||
|
||||
QRectF eObject::boundingRect() const {
|
||||
int m2 = m_handleLen * 2;
|
||||
return QRectF(-m_handleLen, -m_handleLen, m_w+m2, m_h+m2);
|
||||
}
|
||||
//QString eObject::getFileMd5(QString filePath)
|
||||
//绘制选中和未选中的区域边框
|
||||
void eObject::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){
|
||||
//qDebug()<<"eObject::paint(QPainter, QStyleOptionGraphicsItem)";
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
painter->save();
|
||||
//绘制边框
|
||||
QPixmap img("borders/M8_8.bmp");
|
||||
int borderWidth = img.height();
|
||||
QBrush brush(img);
|
||||
|
||||
QPainterPath path(QPointF(0, 0));
|
||||
path.lineTo(m_w, 0);
|
||||
path.lineTo(m_w - borderWidth, borderWidth);
|
||||
path.lineTo(borderWidth, borderWidth);
|
||||
path.closeSubpath();
|
||||
painter->fillPath(path, brush);
|
||||
|
||||
QTransform transform;
|
||||
transform.rotate(90);
|
||||
brush.setTransform(transform);
|
||||
path = QPainterPath(QPointF(m_w, 0));
|
||||
path.lineTo(m_w, m_h);
|
||||
path.lineTo(m_w - borderWidth, m_h - borderWidth);
|
||||
path.lineTo(m_w - borderWidth, borderWidth);
|
||||
path.closeSubpath();
|
||||
painter->fillPath(path, brush);
|
||||
|
||||
transform.rotate(90);
|
||||
brush.setTransform(transform);
|
||||
path = QPainterPath(QPointF(m_w, m_h));
|
||||
path.lineTo(0, m_h);
|
||||
path.lineTo(borderWidth, m_h - borderWidth);
|
||||
path.lineTo(m_w - borderWidth, m_h - borderWidth);
|
||||
path.closeSubpath();
|
||||
painter->fillPath(path, brush);
|
||||
|
||||
transform.rotate(90);
|
||||
brush.setTransform(transform);
|
||||
path = QPainterPath(QPointF(0, m_h));
|
||||
path.lineTo(0, 0);
|
||||
path.lineTo(borderWidth, borderWidth);
|
||||
path.lineTo(borderWidth, m_h - borderWidth);
|
||||
path.closeSubpath();
|
||||
painter->fillPath(path, brush);
|
||||
|
||||
|
||||
if(isSelected()) {
|
||||
QPainterPath pRect;
|
||||
pRect.addRect(rect());
|
||||
m_borderPen.setBrush(QBrush(QColor::fromRgb(0, 255, 0)));
|
||||
painter->setPen(m_borderPen);
|
||||
painter->drawPath(pRect);
|
||||
QPainterPath pHandle;
|
||||
pHandle.addRect(m_rLT);
|
||||
pHandle.addRect(m_rT);
|
||||
pHandle.addRect(m_rRT);
|
||||
pHandle.addRect(m_rL);
|
||||
pHandle.addRect(m_rR);
|
||||
pHandle.addRect(m_rLB);
|
||||
pHandle.addRect(m_rB);
|
||||
pHandle.addRect(m_rRB);
|
||||
painter->setPen(m_handlePen);
|
||||
painter->drawPath(pHandle);
|
||||
} else {
|
||||
m_borderPen.setBrush(QBrush(QColor::fromRgb(0, 125, 0)));
|
||||
QPainterPath pRect;
|
||||
pRect.addRect(rect());
|
||||
painter->setPen(m_borderPen);
|
||||
painter->drawPath(pRect);
|
||||
}
|
||||
|
||||
//磁条吸附时两化吸附的边
|
||||
QPen CitiePen=QPen(QColor::fromRgb(0, 255, 0),1,Qt::SolidLine);
|
||||
painter->setPen(CitiePen);
|
||||
//if(bMousePress)
|
||||
{
|
||||
if (bLeftCitie) {
|
||||
painter->setPen(CitiePen);
|
||||
//painter->drawLine(QPointF(rect().x(),rect().y()-100),QPointF(rect().x(),rect().bottom()+100));
|
||||
painter->drawLine(QPointF(rect().topLeft()),QPointF(rect().bottomLeft()));
|
||||
}
|
||||
if (bTopCitie) {
|
||||
painter->setPen(CitiePen);
|
||||
painter->drawLine(QPointF(rect().topLeft()),QPointF(rect().topRight()));
|
||||
}
|
||||
if (bRightCitie) {
|
||||
painter->setPen(CitiePen);
|
||||
painter->drawLine(QPointF(rect().topRight()),QPointF(rect().bottomRight()));
|
||||
}
|
||||
if (bBottomCitie) {
|
||||
painter->setPen(CitiePen);
|
||||
painter->drawLine(QPointF(rect().bottomLeft()),QPointF(rect().bottomRight()));
|
||||
}
|
||||
}
|
||||
// QPen(const QBrush &brush,
|
||||
// qreal width,
|
||||
// Qt::PenStyle style = Qt::SolidLine,
|
||||
// Qt::PenCapStyle cap = Qt::SquareCap,
|
||||
// Qt::PenJoinStyle join = Qt::BevelJoin);
|
||||
// QPen pen(Qt::green, 3, Qt::DashDotLine, Qt::RoundCap, Qt::RoundJoin);
|
||||
|
||||
|
||||
//painter->drawLine(QPointF(rect().bottomLeft()),QPointF(rect().bottomRight()));
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
void eObject::mousePressEvent(QGraphicsSceneMouseEvent *event){
|
||||
if(Qt::LeftButton == event->button()) {
|
||||
|
||||
m_hDir = handleDir(event->pos());
|
||||
m_pOrg = pointToParent(event->pos());
|
||||
m_rOrg = geometry();
|
||||
m_movable = true;
|
||||
bMousePress=true;
|
||||
|
||||
}
|
||||
QGraphicsItem::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void eObject::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){
|
||||
bMousePress=false;
|
||||
|
||||
if(Qt::LeftButton == event->button()) {
|
||||
m_hDir = NONE;
|
||||
m_movable = false;
|
||||
bLeftCitie=false;
|
||||
bRightCitie=false;
|
||||
bTopCitie=false;
|
||||
bBottomCitie=false;
|
||||
m_keyPressId++;
|
||||
emit sigCiTie(false,m_keyPressId);
|
||||
|
||||
}
|
||||
QGraphicsItem::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void eObject::mouseMoveEvent(QGraphicsSceneMouseEvent *event){
|
||||
if(false == m_movable) return;
|
||||
|
||||
qreal cx, cy, cw, ch;
|
||||
qreal mx, my, mw, mh;
|
||||
QPointF ePos = pointToParent(event->pos());
|
||||
QPointF absoluteOfs = ePos - m_pOrg;
|
||||
|
||||
mx = m_rOrg.x();
|
||||
my = m_rOrg.y();
|
||||
mw = m_w;
|
||||
mh = m_h;
|
||||
|
||||
if(m_hDir != NONE) {
|
||||
prepareGeometryChange();
|
||||
|
||||
switch(m_hDir) {
|
||||
case LT:
|
||||
cx = m_rOrg.x() + absoluteOfs.x();
|
||||
cy = m_rOrg.y() + absoluteOfs.y();
|
||||
if(m_rOrg.right() - cx < m_handleLen) cx = m_rOrg.right() - m_handleLen;
|
||||
if(m_rOrg.bottom() - cy < m_handleLen) cy = m_rOrg.bottom() - m_handleLen;
|
||||
mx = cx;
|
||||
my = cy;
|
||||
if(m_rLimit != INVALID_RECT) {
|
||||
if(mx < 0) mx = 0;
|
||||
if(my < 0) my = 0;
|
||||
}
|
||||
mw = m_rOrg.right() - mx;
|
||||
mh = m_rOrg.bottom() - my;
|
||||
break;
|
||||
|
||||
case T:
|
||||
cy = m_rOrg.y() + absoluteOfs.y();
|
||||
if(m_rOrg.bottom() - cy < m_handleLen) cy = m_rOrg.bottom() - m_handleLen;
|
||||
my = cy;
|
||||
if(m_rLimit != INVALID_RECT) {
|
||||
if(my < 0) my = 0;
|
||||
}
|
||||
mh = m_rOrg.bottom() - my;
|
||||
break;
|
||||
|
||||
case RT:
|
||||
cy = m_rOrg.y() + absoluteOfs.y();
|
||||
cw = m_rOrg.width() + absoluteOfs.x();
|
||||
if(m_rOrg.bottom() - cy < m_handleLen) cy = m_rOrg.bottom() - m_handleLen;
|
||||
if(cw < m_handleLen) cw = m_handleLen;
|
||||
my = cy;
|
||||
mw = cw;
|
||||
if(m_rLimit != INVALID_RECT) {
|
||||
if(my < 0) my = 0;
|
||||
if(mx + mw > m_rLimit.width()) mw = m_rLimit.width() - mx;
|
||||
}
|
||||
mh = m_rOrg.bottom() - my;
|
||||
break;
|
||||
|
||||
case L:
|
||||
cx = m_rOrg.x() + absoluteOfs.x();
|
||||
if(m_rOrg.right() - cx < m_handleLen) cx = m_rOrg.right() - m_handleLen;
|
||||
mx = cx;
|
||||
if(m_rLimit != INVALID_RECT) {
|
||||
if(mx < 0) mx = 0;
|
||||
}
|
||||
mw = m_rOrg.right() - mx;
|
||||
break;
|
||||
|
||||
case R:
|
||||
cw = m_rOrg.width() + absoluteOfs.x();
|
||||
if(cw < m_handleLen) cw = m_handleLen;
|
||||
mw = cw;
|
||||
if(m_rLimit != INVALID_RECT) {
|
||||
if(mx + mw > m_rLimit.width()) mw = m_rLimit.width() - mx;
|
||||
}
|
||||
break;
|
||||
|
||||
case LB:
|
||||
cx = m_rOrg.x() + absoluteOfs.x();
|
||||
ch = m_rOrg.height() + absoluteOfs.y();
|
||||
if(m_rOrg.right() - cx < m_handleLen) cx = m_rOrg.right() - m_handleLen;
|
||||
if(ch < m_handleLen) ch = m_handleLen;
|
||||
mx = cx;
|
||||
if(m_rLimit != INVALID_RECT) {
|
||||
if(mx < 0) mx = 0;
|
||||
}
|
||||
mw = m_rOrg.right() - mx;
|
||||
mh = ch;
|
||||
if(m_rLimit != INVALID_RECT) {
|
||||
if(my + mh > m_rLimit.height()) mh = m_rLimit.height() - my;
|
||||
}
|
||||
break;
|
||||
|
||||
case B:
|
||||
ch = m_rOrg.height() + absoluteOfs.y();
|
||||
if(ch < m_handleLen) ch = m_handleLen;
|
||||
mh = ch;
|
||||
if(m_rLimit != INVALID_RECT) {
|
||||
if(my + mh > m_rLimit.height()) mh = m_rLimit.height() - my;
|
||||
}
|
||||
break;
|
||||
|
||||
case RB:
|
||||
cw = m_rOrg.width() + absoluteOfs.x();
|
||||
ch = m_rOrg.height() + absoluteOfs.y();
|
||||
if(cw < m_handleLen) cw = m_handleLen;
|
||||
if(ch < m_handleLen) ch = m_handleLen;
|
||||
mw = cw;
|
||||
mh = ch;
|
||||
if(m_rLimit != INVALID_RECT) {
|
||||
if(mx + mw > m_rLimit.width()) mw = m_rLimit.width() - mx;
|
||||
if(my + mh > m_rLimit.height()) mh = m_rLimit.height() - my;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
setPos(mx, my);
|
||||
m_w = mw;
|
||||
m_h = mh;
|
||||
adjustHandle();
|
||||
updateGeometry(m_rOrg);
|
||||
rectChanged(rect());
|
||||
} else {
|
||||
mx = m_rOrg.x() + absoluteOfs.x();
|
||||
my = m_rOrg.y() + absoluteOfs.y();
|
||||
if(m_rLimit != INVALID_RECT) {
|
||||
if(mx < 0) mx = 0;
|
||||
if(my < 0) my = 0;
|
||||
if(mx + mw > m_rLimit.width()) mx = m_rLimit.width() - mw;
|
||||
if(my + mh > m_rLimit.height()) my = m_rLimit.height() - mh;
|
||||
}
|
||||
setPos(mx, my);
|
||||
}
|
||||
|
||||
geometryChanged(geometry());
|
||||
if(bMousePress)
|
||||
{
|
||||
|
||||
emit sigCiTie(true,m_hDir);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void eObject::setBrightBianLeft(bool b){
|
||||
qDebug()<<"eObject::setBrightBianLeft(bool)";
|
||||
//if(bMousePress)
|
||||
// {
|
||||
// QFile theFile(filePath);
|
||||
// theFile.open(QIODevice::ReadOnly);
|
||||
// QByteArray ba = QCryptographicHash::hash(theFile.readAll(), QCryptographicHash::Md5);
|
||||
// theFile.close();
|
||||
// QString strRes="";
|
||||
// strRes.append(ba.toHex());
|
||||
// return strRes;
|
||||
// bLeftCitie=b;
|
||||
|
||||
// }
|
||||
QString eObject::getFileMd5(QString filePath)
|
||||
{
|
||||
// else {
|
||||
// bLeftCitie=false;
|
||||
// }
|
||||
bLeftCitie=b;
|
||||
updateGeometry();
|
||||
|
||||
}
|
||||
void eObject::setBrightBianRight(bool b){
|
||||
qDebug()<<"eObject::setBrightBianRight(bool)";
|
||||
// if(bMousePress)
|
||||
// {
|
||||
// bRightCitie=b;
|
||||
|
||||
// }
|
||||
// else {
|
||||
// bRightCitie=false;
|
||||
// }
|
||||
bRightCitie=b;
|
||||
updateGeometry();
|
||||
|
||||
}
|
||||
void eObject::setBrightBianTop(bool b){
|
||||
qDebug()<<"eObject::setBrightBianTop(bool)";
|
||||
// if(bMousePress)
|
||||
// {
|
||||
// bTopCitie=b;
|
||||
|
||||
// }
|
||||
// else {
|
||||
// bTopCitie=false;
|
||||
// }
|
||||
bTopCitie=b;
|
||||
updateGeometry();
|
||||
|
||||
}
|
||||
void eObject::setBrightBianbottom(bool b){
|
||||
qDebug()<<"eObject::setBrightBianbottom(bool)";
|
||||
// if(bMousePress)
|
||||
// {
|
||||
// bBottomCitie=b;
|
||||
|
||||
// }
|
||||
// else {
|
||||
// bBottomCitie=false;
|
||||
// }
|
||||
bBottomCitie=b;
|
||||
updateGeometry();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void eObject::setGeometry(const QRectF &r){
|
||||
qDebug()<<"eObject::setGeometry(QRectF)";
|
||||
if(r != geometry()) {
|
||||
prepareGeometryChange();
|
||||
setPos(r.x(), r.y());
|
||||
m_w = r.width();
|
||||
m_h = r.height();
|
||||
adjustHandle();
|
||||
emit rectChanged(rect());
|
||||
}
|
||||
}
|
||||
|
||||
void eObject::updateGeometry(){
|
||||
qDebug()<<"eObject::updateGeometry()";
|
||||
QRectF r = geometry();
|
||||
qreal x, y, w, h;
|
||||
x = r.x() - m_handleLen;
|
||||
y = r.y() - m_handleLen;
|
||||
w = r.width() + m_handleLen * 2;
|
||||
h = r.height() + m_handleLen * 2;
|
||||
r = QRectF(x, y, w, h);
|
||||
if(nullptr != scene()) {
|
||||
scene()->update(r);
|
||||
}
|
||||
emit requestUpdate(r);
|
||||
}
|
||||
|
||||
void eObject::updateGeometry(const QRectF &gC, const QRectF &gL){
|
||||
qDebug()<<"eObject::updateGeometry(QRectF,QRectF)";
|
||||
qreal x, y, w, h;
|
||||
QRectF gCur, gLast;
|
||||
x = gC.x() - m_handleLen;
|
||||
y = gC.y() - m_handleLen;
|
||||
w = gC.width() + m_handleLen * 2;
|
||||
h = gC.height() + m_handleLen * 2;
|
||||
gCur = QRectF(x, y, w, h);
|
||||
x = gL.x() - m_handleLen;
|
||||
y = gL.y() - m_handleLen;
|
||||
w = gL.width() + m_handleLen * 2;
|
||||
h = gL.height() + m_handleLen * 2;
|
||||
gLast = QRectF(x, y, w, h);
|
||||
qreal l = (gCur.left() < gLast.left()) ? gCur.left() : gLast.left();
|
||||
qreal t = (gCur.top() < gLast.top()) ? gCur.top() : gLast.top();
|
||||
qreal r = (gCur.right() > gLast.right()) ? gCur.right() : gLast.right();
|
||||
qreal b = (gCur.bottom() > gLast.bottom()) ? gCur.bottom() : gLast.bottom();
|
||||
QRectF gFlash = QRectF(QPointF(l, t), QPointF(r, b));
|
||||
if(nullptr != scene()) {
|
||||
scene()->update(gFlash);
|
||||
}
|
||||
emit requestUpdate(gFlash);
|
||||
}
|
||||
|
||||
QPointF eObject::pointToParent(const QPointF &p){
|
||||
qDebug()<<"eObject::pointToParent(QPointF)";
|
||||
qreal px, py;
|
||||
px = p.x() + x();
|
||||
py = p.y() + y();
|
||||
return QPointF(px, py);
|
||||
}
|
||||
|
||||
eObject::HANDLE_DIR eObject::handleDir(const QPointF &p){
|
||||
qDebug()<<"eObject::handleDir(QPointF)";
|
||||
HANDLE_DIR hDir = NONE;
|
||||
if(isSelected()) {
|
||||
if(m_rLT.contains(p)) hDir = LT;
|
||||
else if(m_rT.contains(p)) hDir = T;
|
||||
else if(m_rRT.contains(p)) hDir = RT;
|
||||
else if(m_rL.contains(p)) hDir = L;
|
||||
else if(m_rR.contains(p)) hDir = R;
|
||||
else if(m_rLB.contains(p)) hDir = LB;
|
||||
else if(m_rB.contains(p)) hDir = B;
|
||||
else if(m_rRB.contains(p)) hDir = RB;
|
||||
}
|
||||
return hDir;
|
||||
}
|
||||
//拖拽的虚线矩形
|
||||
void eObject::adjustHandle(){
|
||||
qDebug()<<"eObject::adjustHandle()";
|
||||
const QRectF &r = rect();
|
||||
//左上角
|
||||
m_rLT = QRectF(r.left() - m_handleLen/2,
|
||||
r.top() - m_handleLen/2,
|
||||
m_handleLen, m_handleLen);
|
||||
//上中
|
||||
m_rT = QRectF(r.center().x() - m_handleLen / 2,
|
||||
r.top() - m_handleLen/2,
|
||||
m_handleLen, m_handleLen);
|
||||
//右上角
|
||||
m_rRT = QRectF(r.right()-m_handleLen/2,
|
||||
r.top() - m_handleLen/2,
|
||||
m_handleLen, m_handleLen);
|
||||
//左中
|
||||
m_rL = QRectF(r.left() - m_handleLen/2,
|
||||
r.center().y() - m_handleLen / 2,
|
||||
m_handleLen, m_handleLen);
|
||||
//右中
|
||||
m_rR = QRectF(r.right()-m_handleLen/2,
|
||||
r.center().y() - m_handleLen / 2,
|
||||
m_handleLen, m_handleLen);
|
||||
//左下角
|
||||
m_rLB = QRectF(r.left() - m_handleLen/2,
|
||||
r.bottom()-m_handleLen / 2,
|
||||
m_handleLen, m_handleLen);
|
||||
//中下
|
||||
m_rB = QRectF(r.center().x() - m_handleLen / 2,
|
||||
r.bottom()-m_handleLen / 2,
|
||||
m_handleLen, m_handleLen);
|
||||
//右下角
|
||||
m_rRB = QRectF(r.right()-m_handleLen / 2,
|
||||
r.bottom()-m_handleLen / 2,
|
||||
m_handleLen, m_handleLen);
|
||||
}
|
||||
|
||||
|
||||
QString eObject::getFileMd5(QString filePath){
|
||||
qDebug()<<"eObject::getFileMd5(QString)";
|
||||
QFile localFile(filePath);
|
||||
|
||||
if (!localFile.open(QFile::ReadOnly))
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
#ifndef EOBJECT_H
|
||||
#define EOBJECT_H
|
||||
|
||||
#include "loappconfig.h"
|
||||
#include "loapptools.h"
|
||||
#include "globaldefine.h"
|
||||
#include <math.h>
|
||||
#include <QGraphicsObject>
|
||||
#include <QGraphicsScene>
|
||||
|
||||
#include <QDebug>
|
||||
#include <LoQClass/loqgraphicsobject.h>
|
||||
#include <QPainter>
|
||||
#include <QJsonValue>
|
||||
#include <QJsonArray>
|
||||
|
@ -16,17 +20,32 @@
|
|||
#include <QFileInfo>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include "loappconfig.h"
|
||||
#include "loapptools.h"
|
||||
#include "globaldefine.h"
|
||||
|
||||
#define MACRO_DEFAULT_PLAYDURATION 10
|
||||
#define INVALID_RECT QRect(-1, -5, -6, -8)
|
||||
|
||||
class eObjectAttr;
|
||||
class eObject : public LoQGraphicsObject
|
||||
{
|
||||
class eObject : public QGraphicsObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
typedef enum {
|
||||
NONE = 0,
|
||||
LT,
|
||||
T,
|
||||
RT,
|
||||
L,
|
||||
R,
|
||||
LB,
|
||||
B,
|
||||
RB
|
||||
} HANDLE_DIR;
|
||||
|
||||
enum InteractiveType {
|
||||
Dynamic = 0,
|
||||
Static,
|
||||
Custom
|
||||
};
|
||||
|
||||
enum ElementType {
|
||||
Text = QGraphicsItem::UserType + 1,
|
||||
Photo,
|
||||
|
@ -44,51 +63,95 @@ public:
|
|||
Window
|
||||
};
|
||||
|
||||
struct Data {
|
||||
qreal x;
|
||||
qreal y;
|
||||
qreal w;
|
||||
qreal h;
|
||||
};
|
||||
|
||||
public:
|
||||
explicit eObject(InteractiveType type = Dynamic, QGraphicsItem *parent = nullptr);
|
||||
explicit eObject(QRectF rect, InteractiveType type = Dynamic, QGraphicsItem *parent = nullptr);
|
||||
explicit eObject(const QJsonObject &json, InteractiveType type = Dynamic, QGraphicsItem *parent = nullptr);
|
||||
int m_iType=-1;
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
public:
|
||||
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override { Q_UNUSED(event); }
|
||||
|
||||
public:
|
||||
virtual QRectF boundingRect() const override;
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *) override{};
|
||||
virtual void setInteractiveType(InteractiveType type = Dynamic);
|
||||
virtual QJsonObject save(const QString &pRoot) = 0;
|
||||
virtual QWidget* wAttrElement() = 0;
|
||||
|
||||
public:
|
||||
virtual QWidget* wAttr();
|
||||
virtual QStringList filesList() const { return QStringList(); }
|
||||
virtual QJsonObject elementJson() const;
|
||||
|
||||
public:
|
||||
void setRLimit(const QRectF r);
|
||||
void setRLimit(const QRectF &r);
|
||||
QRectF rLimit() const { return m_rLimit; }
|
||||
InteractiveType interactiveType() const { return m_interactiveType; }
|
||||
QRectF rect() const { return QRectF(0, 0, m_w, m_h); }
|
||||
QRectF geometry() const { return QRectF(x(), y(), m_w, m_h); }
|
||||
|
||||
|
||||
QString getFileMd5(QString filePath);
|
||||
|
||||
signals: // Qt::BlockingQueuedConnection
|
||||
void requestUpdate(const QRectF &);
|
||||
void geometryChanged(const QRectF &);
|
||||
void rectChanged(const QRectF &);
|
||||
void sigCiTie(bool,int);
|
||||
|
||||
void sPlayBQ();
|
||||
void sStopBQ();
|
||||
void sAttrSetting(const eObject::Data &);
|
||||
|
||||
public slots:
|
||||
void setGeometry (qreal x, qreal y, qreal w, qreal h) { setGeometry(QRectF(x, y, w, h)); }
|
||||
void setGeometry (const QRectF &r);
|
||||
void updateGeometry();
|
||||
void updateGeometry(const QRectF &gLast) { updateGeometry(geometry(), gLast); }
|
||||
void updateGeometry(const QRectF &gCur, const QRectF &gLast);
|
||||
void setBrightBianLeft(bool);
|
||||
void setBrightBianTop(bool);
|
||||
void setBrightBianRight(bool);
|
||||
void setBrightBianbottom(bool);
|
||||
|
||||
virtual void playElectment() {}
|
||||
virtual void stopElectment() {}
|
||||
void onAttrChanged(const eObject::Data &data);
|
||||
void onAttrSetting(const QRectF &r);
|
||||
void onAttrChanged(const QRectF &);
|
||||
|
||||
|
||||
protected:
|
||||
int handleLen() const { return m_handleLen; }
|
||||
QPointF pointToParent(const QPointF &p);
|
||||
HANDLE_DIR handleDir(const QPointF &p);
|
||||
void adjustHandle();
|
||||
|
||||
InteractiveType m_interactiveType;
|
||||
bool m_movable;
|
||||
int m_handleLen;
|
||||
QPen m_handlePen;
|
||||
QPen m_borderPen;
|
||||
|
||||
qreal m_w;
|
||||
qreal m_h;
|
||||
QRectF m_rLT;
|
||||
QRectF m_rT;
|
||||
|
||||
QRectF m_rRT;
|
||||
QRectF m_rL;
|
||||
QRectF m_rR;
|
||||
QRectF m_rLB;
|
||||
QRectF m_rB;
|
||||
QRectF m_rRB;
|
||||
QRectF m_rOrg;
|
||||
QPointF m_pOrg;
|
||||
HANDLE_DIR m_hDir;
|
||||
QRectF m_rLimit;
|
||||
bool bMousePress=false;
|
||||
bool bLeftCitie=false;
|
||||
bool bRightCitie=false;
|
||||
bool bTopCitie=false;
|
||||
bool bBottomCitie=false;
|
||||
int m_keyPressId=0;
|
||||
|
||||
private:
|
||||
eObjectAttr *m_wAttr;
|
||||
void init();
|
||||
};
|
||||
|
||||
#endif // EOBJECT_H
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include "eobjectattr.h"
|
||||
#include "ui_eobjectattr.h"
|
||||
#include <QDirIterator>
|
||||
|
||||
eObjectAttr::eObjectAttr(const eObject::Data &data, const QRectF &rLimit, QWidget *parent) :
|
||||
eObjectAttr::eObjectAttr(const QRectF &data, const QRectF &rLimit, QWidget *parent) :
|
||||
QGroupBox(parent),
|
||||
ui(new Ui::eObjectAttr)
|
||||
{
|
||||
|
@ -11,10 +12,10 @@ eObjectAttr::eObjectAttr(const eObject::Data &data, const QRectF &rLimit, QWidge
|
|||
m_rLimit.setHeight(rLimit.height());
|
||||
|
||||
ui->setupUi(this);
|
||||
ui->wX->setValue(static_cast<int>(data.x));
|
||||
ui->wY->setValue(static_cast<int>(data.y));
|
||||
ui->wW->setValue(static_cast<int>(data.w));
|
||||
ui->wH->setValue(static_cast<int>(data.h));
|
||||
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()));
|
||||
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)));
|
||||
|
@ -23,6 +24,31 @@ eObjectAttr::eObjectAttr(const eObject::Data &data, const QRectF &rLimit, QWidge
|
|||
QHBoxLayout *hBox = new QHBoxLayout();
|
||||
ui->verticalLayout->addLayout(hBox);
|
||||
hBox->addWidget(new QLabel("边框:"));
|
||||
borderFd = new QComboBox();
|
||||
borderFd->setStyleSheet("QComboBox{padding-left:4px; padding-right:4px;}");
|
||||
hBox->addWidget(borderFd);
|
||||
QDirIterator it(":res/borders/", QDirIterator::Subdirectories);
|
||||
int maxImgWidth = 0;
|
||||
while(it.hasNext()) {
|
||||
QString path = it.next();
|
||||
QPixmap img(path);
|
||||
if(img.width()>maxImgWidth) maxImgWidth = img.width();
|
||||
borderFd->addItem(QIcon(img), QString::number(img.height()));
|
||||
}
|
||||
borderFd->setIconSize(QSize(maxImgWidth, 24));
|
||||
connect(borderFd, SIGNAL(currentIndexChanged(int)), this, SLOT(onHChanged(int)));
|
||||
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
eObjectAttr::~eObjectAttr()
|
||||
|
@ -32,6 +58,7 @@ eObjectAttr::~eObjectAttr()
|
|||
|
||||
void eObjectAttr::onXChanged(int n)
|
||||
{
|
||||
qDebug()<<"eObjectAttr::onXChanged(int)";
|
||||
if(m_rLimit != INVALID_RECT) {
|
||||
int mx = n;
|
||||
int mw = ui->wW->value();
|
||||
|
@ -47,6 +74,7 @@ void eObjectAttr::onXChanged(int n)
|
|||
|
||||
void eObjectAttr::onYChanged(int n)
|
||||
{
|
||||
qDebug()<<"eObjectAttr::onYChanged(int)";
|
||||
if(m_rLimit != INVALID_RECT) {
|
||||
int my = n;
|
||||
int mh = ui->wH->value();
|
||||
|
@ -62,6 +90,7 @@ void eObjectAttr::onYChanged(int n)
|
|||
|
||||
void eObjectAttr::onWChanged(int n)
|
||||
{
|
||||
qDebug()<<"eObjectAttr::onWChanged(int)";
|
||||
if(m_rLimit != INVALID_RECT) {
|
||||
int mx = ui->wX->value();
|
||||
int mw = n;
|
||||
|
@ -77,6 +106,7 @@ void eObjectAttr::onWChanged(int n)
|
|||
|
||||
void eObjectAttr::onHChanged(int n)
|
||||
{
|
||||
qDebug()<<"eObjectAttr::onHChanged(int)";
|
||||
if(m_rLimit != INVALID_RECT) {
|
||||
int my = ui->wY->value();
|
||||
int mh = n;
|
||||
|
@ -92,18 +122,16 @@ void eObjectAttr::onHChanged(int n)
|
|||
|
||||
void eObjectAttr::onAttrChanged()
|
||||
{
|
||||
eObject::Data data;
|
||||
data.x = ui->wX->value();
|
||||
data.y = ui->wY->value();
|
||||
data.w = ui->wW->value();
|
||||
data.h = ui->wH->value();
|
||||
emit sAttrChanged(data);
|
||||
qDebug()<<"eObjectAttr::onAttrChanged()";
|
||||
QRectF rect(ui->wX->value(), ui->wY->value(), ui->wW->value(), ui->wH->value());
|
||||
emit sAttrChanged(rect);
|
||||
}
|
||||
|
||||
void eObjectAttr::onAttrSetting(const eObject::Data &data)
|
||||
void eObjectAttr::onAttrSetting(const QRectF &rect)
|
||||
{
|
||||
ui->wX->setValue(static_cast<int>(data.x));
|
||||
ui->wY->setValue(static_cast<int>(data.y));
|
||||
ui->wW->setValue(static_cast<int>(data.w));
|
||||
ui->wH->setValue(static_cast<int>(data.h));
|
||||
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()));
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#ifndef EOBJECTATTR_H
|
||||
#define EOBJECTATTR_H
|
||||
|
||||
#include "eobject.h"
|
||||
#include <QGroupBox>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include "eobject.h"
|
||||
#include <QComboBox>
|
||||
|
||||
namespace Ui {
|
||||
class eObjectAttr;
|
||||
|
@ -14,9 +15,12 @@ class eObjectAttr : public QGroupBox
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit eObjectAttr(const eObject::Data &data, const QRectF &rLimit, QWidget *parent = nullptr);
|
||||
explicit eObjectAttr(const QRectF &, const QRectF &, QWidget *parent = nullptr);
|
||||
~eObjectAttr();
|
||||
|
||||
QComboBox* borderFd;
|
||||
QComboBox* borderEffFd;
|
||||
|
||||
public:
|
||||
void setRLimit(const QRectF r)
|
||||
{
|
||||
|
@ -28,11 +32,11 @@ public:
|
|||
}
|
||||
|
||||
signals:
|
||||
void sAttrChanged(const eObject::Data &);
|
||||
void sAttrChanged(const QRectF &);
|
||||
|
||||
public slots:
|
||||
void onAttrChanged();
|
||||
void onAttrSetting(const eObject::Data &);
|
||||
void onAttrSetting(const QRectF &);
|
||||
|
||||
protected slots:
|
||||
void onXChanged(int n);
|
||||
|
|
|
@ -6,20 +6,20 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>302</width>
|
||||
<height>90</height>
|
||||
<width>249</width>
|
||||
<height>110</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>90</height>
|
||||
<height>110</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>90</height>
|
||||
<height>120</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
|
|
@ -124,7 +124,7 @@ void ePhoto::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW
|
|||
painter->save();
|
||||
painter->drawImage(rect(), m_photo);
|
||||
painter->restore();
|
||||
LoQGraphicsObject::paint(painter, option, widget);
|
||||
eObject::paint(painter, option, widget);
|
||||
}
|
||||
void ePhoto:: deleteContent()
|
||||
{
|
||||
|
|
|
@ -358,7 +358,7 @@ void eText::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWi
|
|||
|
||||
painter->restore();
|
||||
|
||||
LoQGraphicsObject::paint(painter, option, widget);
|
||||
eObject::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
//void eText::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||
|
|
|
@ -287,7 +287,7 @@ void wDrawingBoard::onCreatElement(int type)
|
|||
}
|
||||
if(nullptr != element1)
|
||||
{
|
||||
connect(static_cast<LoQGraphicsObject*>(element1),SIGNAL(sigCiTie(bool,int)),this,SLOT(OnCiTieProcess(bool,int)));
|
||||
connect(element1,SIGNAL(sigCiTie(bool,int)),this,SLOT(OnCiTieProcess(bool,int)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -339,7 +339,7 @@ void wDrawingBoard::onCreatElement(int type)
|
|||
}
|
||||
if(nullptr != element1)
|
||||
{
|
||||
connect(static_cast<LoQGraphicsObject*>(element1),SIGNAL(sigCiTie(bool,int)),this,SLOT(OnCiTieProcess(bool,int)));
|
||||
connect(element1,SIGNAL(sigCiTie(bool,int)),this,SLOT(OnCiTieProcess(bool,int)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -444,7 +444,7 @@ void wDrawingBoard::onCreatElement(int type)
|
|||
}
|
||||
if(nullptr != element)
|
||||
{
|
||||
connect(static_cast<LoQGraphicsObject*>(element),SIGNAL(sigCiTie(bool,int)),this,SLOT(OnCiTieProcess(bool,int)));
|
||||
connect(element,SIGNAL(sigCiTie(bool,int)),this,SLOT(OnCiTieProcess(bool,int)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ void wPageItem::connectCiTieSignal(wDrawingBoard *drawingboard)
|
|||
eObject *element = static_cast<eObject*>(item);
|
||||
if(element!=nullptr)
|
||||
{
|
||||
connect(static_cast<LoQGraphicsObject*>(element),SIGNAL(sigCiTie(bool,int)),drawingboard,SLOT(OnCiTieProcess(bool,int)));
|
||||
connect(element,SIGNAL(sigCiTie(bool,int)),drawingboard,SLOT(OnCiTieProcess(bool,int)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ void wPageItem::disconnectCiTieSignal(wDrawingBoard *drawingboard)
|
|||
eObject *element = static_cast<eObject*>(item);
|
||||
if(element!=nullptr)
|
||||
{
|
||||
disconnect(static_cast<LoQGraphicsObject*>(element),SIGNAL(sigCiTie(bool,int)),drawingboard,SLOT(OnCiTieProcess(bool,int)));
|
||||
disconnect(element,SIGNAL(sigCiTie(bool,int)),drawingboard,SLOT(OnCiTieProcess(bool,int)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|