fix _DTSizeItem visible
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
|
|
||||||
_DTSizeItem::_DTSizeItem(): QGraphicsObject() {
|
_DTSizeItem::_DTSizeItem(): QGraphicsObject() {
|
||||||
cur_item = 0;
|
cur_item = nullptr;
|
||||||
grid = 10.;
|
grid = 10.;
|
||||||
in_process = can_drag = false;
|
in_process = can_drag = false;
|
||||||
setData(bvidItemSelection, true);
|
setData(bvidItemSelection, true);
|
||||||
@@ -31,41 +31,44 @@ _DTSizeItem::_DTSizeItem(): QGraphicsObject() {
|
|||||||
|
|
||||||
|
|
||||||
_DTSizeItem::~_DTSizeItem() {
|
_DTSizeItem::~_DTSizeItem() {
|
||||||
assignObject(0);
|
assignObject(nullptr);
|
||||||
//qDebug() << "!!!";
|
//qDebug() << "!!!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void _DTSizeItem::assignObject(QGraphicsItem * item) {
|
void _DTSizeItem::assignObject(QGraphicsItem * item) {
|
||||||
if (cur_item)
|
if (cur_item) {
|
||||||
if (qgraphicsitem_cast<QGraphicsItem*>(cur_item))
|
cur_item->removeSceneEventFilter(this);
|
||||||
cur_item->removeSceneEventFilter(this);
|
}
|
||||||
cur_item = item;
|
cur_item = item;
|
||||||
if (!cur_item) {
|
if (!cur_item) {
|
||||||
for (int i = 0; i < 8; ++i) {
|
for (int i = 0; i < 8; ++i) {
|
||||||
rects[i].hide();
|
rects[i].hide();
|
||||||
rects[i].setParentItem(0);
|
rects[i].setParentItem(nullptr);
|
||||||
rects[i].removeSceneEventFilter(this);
|
rects[i].removeSceneEventFilter(this);
|
||||||
}
|
}
|
||||||
|
hide();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (item)
|
if (cur_item->scene()) {
|
||||||
if (item->scene())
|
if (!cur_item->scene()->views().isEmpty()) {
|
||||||
if (!item->scene()->views().isEmpty())
|
grid = qobject_cast<BlockView*>(cur_item->scene()->views()[0])->gridStep();
|
||||||
grid = ((BlockView*)(item->scene()->views()[0]))->gridStep();
|
}
|
||||||
|
}
|
||||||
QGraphicsRectItem * irect = qgraphicsitem_cast<QGraphicsRectItem*>(cur_item);
|
QGraphicsRectItem * irect = qgraphicsitem_cast<QGraphicsRectItem*>(cur_item);
|
||||||
QGraphicsEllipseItem * iell = qgraphicsitem_cast<QGraphicsEllipseItem*>(cur_item);
|
QGraphicsEllipseItem * iell = qgraphicsitem_cast<QGraphicsEllipseItem*>(cur_item);
|
||||||
QGraphicsLineItem * iline = qgraphicsitem_cast<QGraphicsLineItem*>(cur_item);
|
QGraphicsLineItem * iline = qgraphicsitem_cast<QGraphicsLineItem*>(cur_item);
|
||||||
if (irect || iell || iline) {
|
if (irect || iell || iline) {
|
||||||
resizeHandles();
|
resizeHandles();
|
||||||
is_line = qgraphicsitem_cast<QGraphicsLineItem*>(item);
|
is_line = qgraphicsitem_cast<QGraphicsLineItem*>(cur_item);
|
||||||
for (int i = 0; i < (is_line ? 2 : 8); ++i) {
|
for (int i = 0; i < (is_line ? 2 : 8); ++i) {
|
||||||
rects[i].setParentItem(item);
|
rects[i].setParentItem(cur_item);
|
||||||
rects[i].installSceneEventFilter(this);
|
rects[i].installSceneEventFilter(this);
|
||||||
rects[i].show();
|
rects[i].show();
|
||||||
}
|
}
|
||||||
|
show();
|
||||||
}
|
}
|
||||||
item->installSceneEventFilter(this);
|
cur_item->installSceneEventFilter(this);
|
||||||
moveRects();
|
moveRects();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,12 +98,9 @@ void _DTSizeItem::applyRect() {
|
|||||||
QGraphicsRectItem * irect = qgraphicsitem_cast<QGraphicsRectItem*>(cur_item);
|
QGraphicsRectItem * irect = qgraphicsitem_cast<QGraphicsRectItem*>(cur_item);
|
||||||
QGraphicsEllipseItem * iell = qgraphicsitem_cast<QGraphicsEllipseItem*>(cur_item);
|
QGraphicsEllipseItem * iell = qgraphicsitem_cast<QGraphicsEllipseItem*>(cur_item);
|
||||||
QGraphicsLineItem * iline = qgraphicsitem_cast<QGraphicsLineItem*>(cur_item);
|
QGraphicsLineItem * iline = qgraphicsitem_cast<QGraphicsLineItem*>(cur_item);
|
||||||
if (irect)
|
if (irect) irect->setRect(nrect);
|
||||||
irect->setRect(nrect);
|
if (iell) iell->setRect(nrect);
|
||||||
if (iell)
|
if (iline) iline->setLine(QLineF(nrect.topLeft(), nrect.bottomRight()));
|
||||||
iell->setRect(nrect);
|
|
||||||
if (iline)
|
|
||||||
iline->setLine(QLineF(nrect.topLeft(), nrect.bottomRight()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -120,30 +120,29 @@ void _DTSizeItem::doubleClick() {
|
|||||||
void _DTSizeItem::resizeHandles() {
|
void _DTSizeItem::resizeHandles() {
|
||||||
double sz = fontHeight() / 3.;
|
double sz = fontHeight() / 3.;
|
||||||
QRectF r(-sz, -sz, sz*2, sz*2);
|
QRectF r(-sz, -sz, sz*2, sz*2);
|
||||||
for (int i = 0; i < 8; ++i)
|
for (int i = 0; i < 8; ++i) {
|
||||||
rects[i].setRect(r);
|
rects[i].setRect(r);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QRectF _DTSizeItem::itemRect(const QGraphicsItem * item) const {
|
QRectF _DTSizeItem::itemRect(const QGraphicsItem *) const {
|
||||||
if (!cur_item) return QRectF();
|
if (!cur_item) return QRectF();
|
||||||
QGraphicsRectItem * irect = qgraphicsitem_cast<QGraphicsRectItem*>(cur_item);
|
QGraphicsRectItem * irect = qgraphicsitem_cast<QGraphicsRectItem*>(cur_item);
|
||||||
QGraphicsEllipseItem * iell = qgraphicsitem_cast<QGraphicsEllipseItem*>(cur_item);
|
QGraphicsEllipseItem * iell = qgraphicsitem_cast<QGraphicsEllipseItem*>(cur_item);
|
||||||
QGraphicsLineItem * iline = qgraphicsitem_cast<QGraphicsLineItem*>(cur_item);
|
QGraphicsLineItem * iline = qgraphicsitem_cast<QGraphicsLineItem*>(cur_item);
|
||||||
if (irect)
|
if (irect) return irect->rect();
|
||||||
return irect->rect();
|
if (iell) return iell->rect();
|
||||||
if (iell)
|
if (iline) return QRectF(iline->line().p1(), iline->line().p2());
|
||||||
return iell->rect();
|
|
||||||
if (iline)
|
|
||||||
return QRectF(iline->line().p1(), iline->line().p2());
|
|
||||||
return QRectF();
|
return QRectF();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QRectF _DTSizeItem::boundingRect() const {
|
QRectF _DTSizeItem::boundingRect() const {
|
||||||
QRectF ret = rects[0].boundingRect().translated(rects[0].pos());
|
QRectF ret = rects[0].boundingRect().translated(rects[0].pos());
|
||||||
for (int i = 1; i < 8; ++i)
|
for (int i = 1; i < 8; ++i) {
|
||||||
ret |= rects[i].boundingRect().translated(rects[i].pos());
|
ret |= rects[i].boundingRect().translated(rects[i].pos());
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +151,7 @@ bool _DTSizeItem::sceneEventFilter(QGraphicsItem * watched, QEvent * event) {
|
|||||||
QGraphicsSceneMouseEvent * me = (QGraphicsSceneMouseEvent * )event;
|
QGraphicsSceneMouseEvent * me = (QGraphicsSceneMouseEvent * )event;
|
||||||
if (watched == cur_item) {
|
if (watched == cur_item) {
|
||||||
if (event->type() == QEvent::Close) {
|
if (event->type() == QEvent::Close) {
|
||||||
assignObject(0);
|
assignObject(nullptr);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (event->type() == QEvent::GraphicsSceneMouseDoubleClick) {
|
if (event->type() == QEvent::GraphicsSceneMouseDoubleClick) {
|
||||||
@@ -161,9 +160,10 @@ bool _DTSizeItem::sceneEventFilter(QGraphicsItem * watched, QEvent * event) {
|
|||||||
}
|
}
|
||||||
return QGraphicsItem::sceneEventFilter(watched, event);
|
return QGraphicsItem::sceneEventFilter(watched, event);
|
||||||
}
|
}
|
||||||
if (!cur_item)
|
if (!cur_item) {
|
||||||
return QGraphicsItem::sceneEventFilter(watched, event);
|
return QGraphicsItem::sceneEventFilter(watched, event);
|
||||||
view_ = 0;
|
}
|
||||||
|
view_ = nullptr;
|
||||||
switch (event->type()) {
|
switch (event->type()) {
|
||||||
case QEvent::GraphicsSceneHoverEnter:
|
case QEvent::GraphicsSceneHoverEnter:
|
||||||
if (watched->scene()) if (!watched->scene()->views().isEmpty()) view_ = watched->scene()->views()[0];
|
if (watched->scene()) if (!watched->scene()->views().isEmpty()) view_ = watched->scene()->views()[0];
|
||||||
@@ -211,8 +211,7 @@ bool _DTSizeItem::sceneEventFilter(QGraphicsItem * watched, QEvent * event) {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case QEvent::GraphicsSceneMouseRelease:
|
case QEvent::GraphicsSceneMouseRelease:
|
||||||
if (in_process)
|
if (in_process) emit sizeChanged();
|
||||||
emit sizeChanged();
|
|
||||||
in_process = false;
|
in_process = false;
|
||||||
can_drag = false;
|
can_drag = false;
|
||||||
return true;
|
return true;
|
||||||
@@ -238,7 +237,7 @@ actions_Z_up(this), actions_Z_top(this), actions_Z_down(this), actions_Z_bottom(
|
|||||||
int thick = lineThickness(this);
|
int thick = lineThickness(this);
|
||||||
QSize sz(fh * 2.5, fh);
|
QSize sz(fh * 2.5, fh);
|
||||||
ui->comboLineStyle->setIconSize(sz);
|
ui->comboLineStyle->setIconSize(sz);
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; ++i) {
|
||||||
QPixmap pix(sz);
|
QPixmap pix(sz);
|
||||||
pix.fill();
|
pix.fill();
|
||||||
QPainter p(&pix);
|
QPainter p(&pix);
|
||||||
@@ -257,8 +256,8 @@ actions_Z_up(this), actions_Z_top(this), actions_Z_down(this), actions_Z_bottom(
|
|||||||
ui->buttonAlignHor->setMenu(&menu_hor);
|
ui->buttonAlignHor->setMenu(&menu_hor);
|
||||||
ui->buttonAlignVer->setMenu(&menu_ver);
|
ui->buttonAlignVer->setMenu(&menu_ver);
|
||||||
new_type = -1;
|
new_type = -1;
|
||||||
new_item = cur_item = 0;
|
new_item = cur_item = nullptr;
|
||||||
view_ = 0;
|
view_ = nullptr;
|
||||||
resize_enabled = true;
|
resize_enabled = true;
|
||||||
text_dlg.setLayout(new QBoxLayout(QBoxLayout::TopToBottom));
|
text_dlg.setLayout(new QBoxLayout(QBoxLayout::TopToBottom));
|
||||||
QDialogButtonBox * bbox = new QDialogButtonBox(QDialogButtonBox::Save | QDialogButtonBox::Cancel);
|
QDialogButtonBox * bbox = new QDialogButtonBox(QDialogButtonBox::Save | QDialogButtonBox::Cancel);
|
||||||
@@ -278,10 +277,12 @@ actions_Z_up(this), actions_Z_top(this), actions_Z_down(this), actions_Z_bottom(
|
|||||||
buttons_align << ui->buttonAlignTL << ui->buttonAlignTC << ui->buttonAlignTR
|
buttons_align << ui->buttonAlignTL << ui->buttonAlignTC << ui->buttonAlignTR
|
||||||
<< ui->buttonAlignCL << ui->buttonAlignCC << ui->buttonAlignCR
|
<< ui->buttonAlignCL << ui->buttonAlignCC << ui->buttonAlignCR
|
||||||
<< ui->buttonAlignBL << ui->buttonAlignBC << ui->buttonAlignBR;
|
<< ui->buttonAlignBL << ui->buttonAlignBC << ui->buttonAlignBR;
|
||||||
foreach (QAction * a, actions_add)
|
foreach (QAction * a, actions_add) {
|
||||||
connect(a, SIGNAL(toggled(bool)), this, SLOT(toggleNewItem(bool)));
|
connect(a, SIGNAL(toggled(bool)), this, SLOT(toggleNewItem(bool)));
|
||||||
foreach (QToolButton * b, buttons_align)
|
}
|
||||||
|
foreach (QToolButton * b, buttons_align) {
|
||||||
connect(b, SIGNAL(clicked(bool)), this, SLOT(alignClicked()));
|
connect(b, SIGNAL(clicked(bool)), this, SLOT(alignClicked()));
|
||||||
|
}
|
||||||
connect(ui->buttonImage, SIGNAL(clicked(bool)), this, SLOT(buttonImage_clicked()));
|
connect(ui->buttonImage, SIGNAL(clicked(bool)), this, SLOT(buttonImage_clicked()));
|
||||||
connect(ui->buttonImagePaste, SIGNAL(clicked(bool)), this, SLOT(buttonImagePaste_clicked()));
|
connect(ui->buttonImagePaste, SIGNAL(clicked(bool)), this, SLOT(buttonImagePaste_clicked()));
|
||||||
connect(ui->buttonFont, SIGNAL(clicked(bool)), this, SLOT(buttonFont_clicked()));
|
connect(ui->buttonFont, SIGNAL(clicked(bool)), this, SLOT(buttonFont_clicked()));
|
||||||
@@ -321,7 +322,7 @@ actions_Z_up(this), actions_Z_top(this), actions_Z_down(this), actions_Z_bottom(
|
|||||||
|
|
||||||
|
|
||||||
DrawTools::~DrawTools() {
|
DrawTools::~DrawTools() {
|
||||||
size_item.assignObject(0);
|
size_item.assignObject(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -329,7 +330,9 @@ void DrawTools::retranslate() {
|
|||||||
QStringList styles;
|
QStringList styles;
|
||||||
styles << tr("NoPen") << tr("Solid") << tr("Dash")
|
styles << tr("NoPen") << tr("Solid") << tr("Dash")
|
||||||
<< tr("Dot") << tr("Dash-Dot") << tr("Dash-Dot-Dot");
|
<< tr("Dot") << tr("Dash-Dot") << tr("Dash-Dot-Dot");
|
||||||
for (int i = 0; i < styles.size(); i++) ui->comboLineStyle->setItemText(i, styles[i]);
|
for (int i = 0; i < styles.size(); i++) {
|
||||||
|
ui->comboLineStyle->setItemText(i, styles[i]);
|
||||||
|
}
|
||||||
text_dlg.setWindowTitle(tr("Edit text"));
|
text_dlg.setWindowTitle(tr("Edit text"));
|
||||||
actions_Z_up.setText(tr("Bring\nforward"));
|
actions_Z_up.setText(tr("Bring\nforward"));
|
||||||
actions_Z_top.setText(tr("Bring\nto front"));
|
actions_Z_top.setText(tr("Bring\nto front"));
|
||||||
@@ -361,33 +364,36 @@ void DrawTools::setAlignCompact(bool yes) {
|
|||||||
|
|
||||||
|
|
||||||
bool DrawTools::eventFilter(QObject * o, QEvent * e) {
|
bool DrawTools::eventFilter(QObject * o, QEvent * e) {
|
||||||
QMouseEvent * me = (QMouseEvent*)e;
|
QMouseEvent * me = (QMouseEvent *)e;
|
||||||
QPointF sp;
|
QPointF sp;
|
||||||
if (e->type() == QEvent::FontChange || e->type() == QEvent::Polish)
|
if (e->type() == QEvent::FontChange || e->type() == QEvent::Polish) {
|
||||||
ui->labelPen->setMinimumSize(preferredIconSize(1.5, widget_props));
|
ui->labelPen->setMinimumSize(preferredIconSize(1.5, widget_props));
|
||||||
if (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseMove)
|
}
|
||||||
|
if (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseMove) {
|
||||||
sp = quantize(view_->mapToScene(me->pos()), view_->gridStep());
|
sp = quantize(view_->mapToScene(me->pos()), view_->gridStep());
|
||||||
|
}
|
||||||
QRectF mr;
|
QRectF mr;
|
||||||
switch (e->type()) {
|
switch (e->type()) {
|
||||||
case QEvent::MouseButtonPress:
|
case QEvent::MouseButtonPress:
|
||||||
if (new_type < 0) break;
|
if (new_type < 0) break;
|
||||||
if (new_item) {
|
if (new_item) {
|
||||||
delete new_item;
|
delete new_item;
|
||||||
new_item = 0;
|
new_item = nullptr;
|
||||||
if (!me->modifiers().testFlag(Qt::ControlModifier)) {
|
if (!me->modifiers().testFlag(Qt::ControlModifier)) {
|
||||||
foreach (QAction * a, actions_add)
|
foreach (QAction * a, actions_add) {
|
||||||
a->setChecked(false);
|
a->setChecked(false);
|
||||||
|
}
|
||||||
new_type = -1;
|
new_type = -1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
new_item = 0;
|
new_item = nullptr;
|
||||||
pp = sp;
|
pp = sp;
|
||||||
switch (new_type) {
|
switch (new_type) {
|
||||||
case 0:
|
case 0:
|
||||||
new_item = new AlignedTextItem();
|
new_item = new AlignedTextItem();
|
||||||
((AlignedTextItem*)new_item)->setText("Text");
|
qgraphicsitem_cast<AlignedTextItem *>(new_item)->setText("Text");
|
||||||
((AlignedTextItem*)new_item)->setPos(sp);
|
qgraphicsitem_cast<AlignedTextItem *>(new_item)->setPos(sp);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
new_item = new QGraphicsRectItem();
|
new_item = new QGraphicsRectItem();
|
||||||
@@ -397,15 +403,16 @@ bool DrawTools::eventFilter(QObject * o, QEvent * e) {
|
|||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
new_item = new QGraphicsPixmapItem(QPixmap(":/icons/view-preview.png"));
|
new_item = new QGraphicsPixmapItem(QPixmap(":/icons/view-preview.png"));
|
||||||
((QGraphicsPixmapItem*)new_item)->setPos(sp - QPointF(new_item->boundingRect().width() / 2, new_item->boundingRect().height() / 2));
|
qgraphicsitem_cast<QGraphicsPixmapItem *>(new_item)->setPos(sp - QPointF(new_item->boundingRect().width() / 2, new_item->boundingRect().height() / 2));
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
new_item = new QGraphicsLineItem(QLineF(sp, sp));
|
new_item = new QGraphicsLineItem(QLineF(sp, sp));
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
if (new_item) {
|
if (new_item) {
|
||||||
if (new_type == 1 || new_type == 2)
|
if (new_type == 1 || new_type == 2) {
|
||||||
((QAbstractGraphicsShapeItem*)new_item)->setBrush(Qt::white);
|
qgraphicsitem_cast<QAbstractGraphicsShapeItem *>(new_item)->setBrush(Qt::white);
|
||||||
|
}
|
||||||
new_item->setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable);
|
new_item->setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable);
|
||||||
new_item->setData(bvidBlockDecor, true);
|
new_item->setData(bvidBlockDecor, true);
|
||||||
emit itemCreated(new_item);
|
emit itemCreated(new_item);
|
||||||
@@ -418,19 +425,19 @@ bool DrawTools::eventFilter(QObject * o, QEvent * e) {
|
|||||||
mr = new_item->mapRectFromScene(QRectF(pp, sp).normalized());
|
mr = new_item->mapRectFromScene(QRectF(pp, sp).normalized());
|
||||||
switch (new_type) {
|
switch (new_type) {
|
||||||
case 0:
|
case 0:
|
||||||
((AlignedTextItem*)new_item)->setPos(sp);
|
qgraphicsitem_cast<AlignedTextItem *>(new_item)->setPos(sp);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
((QGraphicsRectItem*)new_item)->setRect(mr);
|
qgraphicsitem_cast<QGraphicsRectItem *>(new_item)->setRect(mr);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
((QGraphicsEllipseItem*)new_item)->setRect(mr);
|
qgraphicsitem_cast<QGraphicsEllipseItem *>(new_item)->setRect(mr);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
((QGraphicsPixmapItem*)new_item)->setPos(sp - QPointF(new_item->boundingRect().width() / 2, new_item->boundingRect().height() / 2));
|
qgraphicsitem_cast<QGraphicsPixmapItem *>(new_item)->setPos(sp - QPointF(new_item->boundingRect().width() / 2, new_item->boundingRect().height() / 2));
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
((QGraphicsLineItem*)new_item)->setLine(QLineF(pp, sp));
|
qgraphicsitem_cast<QGraphicsLineItem *>(new_item)->setLine(QLineF(pp, sp));
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
return true;
|
return true;
|
||||||
@@ -439,19 +446,20 @@ bool DrawTools::eventFilter(QObject * o, QEvent * e) {
|
|||||||
break;
|
break;
|
||||||
case QEvent::MouseButtonRelease:
|
case QEvent::MouseButtonRelease:
|
||||||
if (new_item) {
|
if (new_item) {
|
||||||
if (new_item->boundingRect().isEmpty())
|
if (new_item->boundingRect().isEmpty()) {
|
||||||
delete new_item;
|
delete new_item;
|
||||||
else {
|
} else {
|
||||||
emit itemAddConfirm(new_item);
|
emit itemAddConfirm(new_item);
|
||||||
if (view_) {
|
if (view_) {
|
||||||
view_->selectNone();
|
view_->selectNone();
|
||||||
new_item->setSelected(true);
|
new_item->setSelected(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
new_item = 0;
|
new_item = nullptr;
|
||||||
if (!me->modifiers().testFlag(Qt::ControlModifier)) {
|
if (!me->modifiers().testFlag(Qt::ControlModifier)) {
|
||||||
foreach (QAction * a, actions_add)
|
foreach (QAction * a, actions_add) {
|
||||||
a->setChecked(false);
|
a->setChecked(false);
|
||||||
|
}
|
||||||
new_type = -1;
|
new_type = -1;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -490,9 +498,9 @@ QAction * DrawTools::newAction(const QIcon & icon, int type) {
|
|||||||
|
|
||||||
void DrawTools::toggleNewItem(bool on) {
|
void DrawTools::toggleNewItem(bool on) {
|
||||||
QAction * sa = (QAction * )sender();
|
QAction * sa = (QAction * )sender();
|
||||||
foreach (QAction * a, actions_add)
|
foreach (QAction * a, actions_add) {
|
||||||
if (a != sa)
|
if (a != sa) a->setChecked(false);
|
||||||
a->setChecked(false);
|
}
|
||||||
if (!on) {
|
if (!on) {
|
||||||
new_type = -1;
|
new_type = -1;
|
||||||
view_->unsetCursor();
|
view_->unsetCursor();
|
||||||
@@ -505,9 +513,9 @@ void DrawTools::toggleNewItem(bool on) {
|
|||||||
|
|
||||||
void DrawTools::alignClicked() {
|
void DrawTools::alignClicked() {
|
||||||
QToolButton * sb = (QToolButton * )sender();
|
QToolButton * sb = (QToolButton * )sender();
|
||||||
foreach (QToolButton * b, buttons_align)
|
foreach (QToolButton * b, buttons_align) {
|
||||||
if (b != sb)
|
if (b != sb) b->setChecked(false);
|
||||||
b->setChecked(false);
|
}
|
||||||
sb->setChecked(true);
|
sb->setChecked(true);
|
||||||
align = Qt::Alignment();
|
align = Qt::Alignment();
|
||||||
QString als = sb->objectName().right(2).toLower();
|
QString als = sb->objectName().right(2).toLower();
|
||||||
@@ -555,8 +563,9 @@ void DrawTools::blockPropSignals(bool block_) {
|
|||||||
ui->actionHCenter->blockSignals(block_);
|
ui->actionHCenter->blockSignals(block_);
|
||||||
ui->actionLeft->blockSignals(block_);
|
ui->actionLeft->blockSignals(block_);
|
||||||
ui->actionRight->blockSignals(block_);
|
ui->actionRight->blockSignals(block_);
|
||||||
foreach (QToolButton * b, buttons_align)
|
foreach (QToolButton * b, buttons_align) {
|
||||||
b->blockSignals(block_);
|
b->blockSignals(block_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -566,25 +575,27 @@ void DrawTools::actionAlignTrigger(bool vert, Qt::AlignmentFlag value) {
|
|||||||
else foreach (QAction * a, menu_hor.actions()) a->setChecked(false);
|
else foreach (QAction * a, menu_hor.actions()) a->setChecked(false);
|
||||||
align = align & (vert ? Qt::AlignHorizontal_Mask : Qt::AlignVertical_Mask);
|
align = align & (vert ? Qt::AlignHorizontal_Mask : Qt::AlignVertical_Mask);
|
||||||
align |= value;
|
align |= value;
|
||||||
((QAction*)sender())->setChecked(true);
|
qobject_cast<QAction *>(sender())->setChecked(true);
|
||||||
blockPropSignals(false);
|
blockPropSignals(false);
|
||||||
propertyChanged();
|
propertyChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DrawTools::emitZAvailabe(QGraphicsItem * item) {
|
void DrawTools::emitZAvailabe(QGraphicsItem * item) {
|
||||||
BlockView * view = 0;
|
BlockView * view = nullptr;
|
||||||
if (item) if (item->scene()) if (!item->scene()->views().isEmpty()) view = qobject_cast<BlockView * >(item->scene()->views()[0]);
|
if (item) if (item->scene()) if (!item->scene()->views().isEmpty()) view = qobject_cast<BlockView *>(item->scene()->views()[0]);
|
||||||
if (view == 0) {
|
if (!view) {
|
||||||
moveZUpAvailable(false);
|
moveZUpAvailable(false);
|
||||||
moveZDownAvailable(false);
|
moveZDownAvailable(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QList<QGraphicsItem * > dl;
|
QList<QGraphicsItem *> dl;
|
||||||
if (item->parentItem() == 0) dl = view->decors();
|
if (!item->parentItem()) {
|
||||||
else {
|
dl = view->decors();
|
||||||
if (item->parentItem()->data(bvidType).toInt() == bvitBlock)
|
} else {
|
||||||
dl = ((BlockItem*)(item->parentItem()))->decors_;
|
if (item->parentItem()->data(bvidType).toInt() == bvitBlock) {
|
||||||
|
dl = qgraphicsitem_cast<BlockItem *>(item->parentItem())->decors_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (dl.size() <= 1) {
|
if (dl.size() <= 1) {
|
||||||
moveZUpAvailable(false);
|
moveZUpAvailable(false);
|
||||||
@@ -603,13 +614,13 @@ void DrawTools::emitZAvailabe(QGraphicsItem * item) {
|
|||||||
|
|
||||||
|
|
||||||
void DrawTools::selectionChanged() {
|
void DrawTools::selectionChanged() {
|
||||||
cur_item = 0;
|
cur_item = nullptr;
|
||||||
size_item.assignObject(0);
|
size_item.assignObject(nullptr);
|
||||||
if (!view_) {
|
if (!view_) {
|
||||||
emitZAvailabe();
|
emitZAvailabe();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QList<QGraphicsItem * > sil = view_->scene()->selectedItems();
|
QList<QGraphicsItem *> sil = view_->scene()->selectedItems();
|
||||||
if (sil.size() != 1) {
|
if (sil.size() != 1) {
|
||||||
emitZAvailabe();
|
emitZAvailabe();
|
||||||
widget_props->setEnabled(false);
|
widget_props->setEnabled(false);
|
||||||
@@ -621,12 +632,12 @@ void DrawTools::selectionChanged() {
|
|||||||
emitZAvailabe();
|
emitZAvailabe();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QGraphicsSimpleTextItem * itext = qgraphicsitem_cast<QGraphicsSimpleTextItem*>(cur_item);
|
QGraphicsSimpleTextItem * itext = qgraphicsitem_cast<QGraphicsSimpleTextItem *>(cur_item);
|
||||||
AlignedTextItem * iatext = qgraphicsitem_cast<AlignedTextItem*>(cur_item);
|
AlignedTextItem * iatext = qgraphicsitem_cast<AlignedTextItem *>(cur_item);
|
||||||
QGraphicsPixmapItem * ipixmap = qgraphicsitem_cast<QGraphicsPixmapItem*>(cur_item);
|
QGraphicsPixmapItem * ipixmap = qgraphicsitem_cast<QGraphicsPixmapItem *>(cur_item);
|
||||||
QGraphicsRectItem * irect = qgraphicsitem_cast<QGraphicsRectItem*>(cur_item);
|
QGraphicsRectItem * irect = qgraphicsitem_cast<QGraphicsRectItem *>(cur_item);
|
||||||
QGraphicsEllipseItem * iell = qgraphicsitem_cast<QGraphicsEllipseItem*>(cur_item);
|
QGraphicsEllipseItem * iell = qgraphicsitem_cast<QGraphicsEllipseItem *>(cur_item);
|
||||||
QGraphicsLineItem * iline = qgraphicsitem_cast<QGraphicsLineItem*>(cur_item);
|
QGraphicsLineItem * iline = qgraphicsitem_cast<QGraphicsLineItem *>(cur_item);
|
||||||
blockPropSignals(true);
|
blockPropSignals(true);
|
||||||
if (itext) {
|
if (itext) {
|
||||||
ui->stackedProperties->setCurrentIndex(0);
|
ui->stackedProperties->setCurrentIndex(0);
|
||||||
@@ -657,13 +668,15 @@ void DrawTools::selectionChanged() {
|
|||||||
if (align.testFlag(Qt::AlignLeft)) {als += "L"; ui->actionLeft->setChecked(true);}
|
if (align.testFlag(Qt::AlignLeft)) {als += "L"; ui->actionLeft->setChecked(true);}
|
||||||
if (align.testFlag(Qt::AlignHCenter)) {als += "C"; ui->actionHCenter->setChecked(true);}
|
if (align.testFlag(Qt::AlignHCenter)) {als += "C"; ui->actionHCenter->setChecked(true);}
|
||||||
if (align.testFlag(Qt::AlignRight)) {als += "R"; ui->actionRight->setChecked(true);}
|
if (align.testFlag(Qt::AlignRight)) {als += "R"; ui->actionRight->setChecked(true);}
|
||||||
foreach (QToolButton * b, buttons_align)
|
foreach (QToolButton * b, buttons_align) {
|
||||||
b->setChecked(false);
|
b->setChecked(false);
|
||||||
foreach (QToolButton * b, buttons_align)
|
}
|
||||||
|
foreach (QToolButton * b, buttons_align) {
|
||||||
if (b->objectName().endsWith(als)) {
|
if (b->objectName().endsWith(als)) {
|
||||||
b->setChecked(true);
|
b->setChecked(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ui->widgetAlign2->setEnabled(true);
|
ui->widgetAlign2->setEnabled(true);
|
||||||
ui->widgetAlign9->setEnabled(true);
|
ui->widgetAlign9->setEnabled(true);
|
||||||
size_item.assignObject(iatext);
|
size_item.assignObject(iatext);
|
||||||
@@ -674,7 +687,7 @@ void DrawTools::selectionChanged() {
|
|||||||
size_item.assignObject(ipixmap);
|
size_item.assignObject(ipixmap);
|
||||||
} else if (irect || iell) {
|
} else if (irect || iell) {
|
||||||
ui->stackedProperties->setCurrentIndex(1);
|
ui->stackedProperties->setCurrentIndex(1);
|
||||||
QAbstractGraphicsShapeItem * ishape(0);
|
QAbstractGraphicsShapeItem * ishape = nullptr;
|
||||||
if (irect) {
|
if (irect) {
|
||||||
ishape = irect;
|
ishape = irect;
|
||||||
ui->spinWidth->setValue(irect->rect().width());
|
ui->spinWidth->setValue(irect->rect().width());
|
||||||
@@ -691,8 +704,7 @@ void DrawTools::selectionChanged() {
|
|||||||
ui->spinThick->setValue(ishape->pen().widthF());
|
ui->spinThick->setValue(ishape->pen().widthF());
|
||||||
ui->comboLineStyle->setCurrentIndex(qMin<int>((int)ishape->pen().style(), ui->comboLineStyle->count() - 1));
|
ui->comboLineStyle->setCurrentIndex(qMin<int>((int)ishape->pen().style(), ui->comboLineStyle->count() - 1));
|
||||||
setToolButtonsEnabled(true, true, true);
|
setToolButtonsEnabled(true, true, true);
|
||||||
if (resize_enabled)
|
if (resize_enabled) size_item.assignObject(ishape);
|
||||||
size_item.assignObject(ishape);
|
|
||||||
}
|
}
|
||||||
} else if (iline) {
|
} else if (iline) {
|
||||||
ui->stackedProperties->setCurrentIndex(1);
|
ui->stackedProperties->setCurrentIndex(1);
|
||||||
@@ -700,8 +712,7 @@ void DrawTools::selectionChanged() {
|
|||||||
ui->spinThick->setValue(iline->pen().widthF());
|
ui->spinThick->setValue(iline->pen().widthF());
|
||||||
ui->comboLineStyle->setCurrentIndex(qMin<int>((int)iline->pen().style(), ui->comboLineStyle->count() - 1));
|
ui->comboLineStyle->setCurrentIndex(qMin<int>((int)iline->pen().style(), ui->comboLineStyle->count() - 1));
|
||||||
setToolButtonsEnabled(true, false, false);
|
setToolButtonsEnabled(true, false, false);
|
||||||
if (resize_enabled)
|
if (resize_enabled) size_item.assignObject(iline);
|
||||||
size_item.assignObject(iline);
|
|
||||||
} else {
|
} else {
|
||||||
ui->stackedProperties->setCurrentIndex(3);
|
ui->stackedProperties->setCurrentIndex(3);
|
||||||
widget_props->setEnabled(false);
|
widget_props->setEnabled(false);
|
||||||
@@ -713,8 +724,8 @@ void DrawTools::selectionChanged() {
|
|||||||
|
|
||||||
void DrawTools::sizeChanged() {
|
void DrawTools::sizeChanged() {
|
||||||
blockPropSignals(true);
|
blockPropSignals(true);
|
||||||
QGraphicsRectItem * irect = qgraphicsitem_cast<QGraphicsRectItem*>(cur_item);
|
QGraphicsRectItem * irect = qgraphicsitem_cast<QGraphicsRectItem *>(cur_item);
|
||||||
QGraphicsEllipseItem * iell = qgraphicsitem_cast<QGraphicsEllipseItem*>(cur_item);
|
QGraphicsEllipseItem * iell = qgraphicsitem_cast<QGraphicsEllipseItem *>(cur_item);
|
||||||
if (irect || iell) {
|
if (irect || iell) {
|
||||||
if (irect) {
|
if (irect) {
|
||||||
ui->spinWidth->setValue(irect->rect().width());
|
ui->spinWidth->setValue(irect->rect().width());
|
||||||
@@ -732,12 +743,12 @@ void DrawTools::sizeChanged() {
|
|||||||
|
|
||||||
void DrawTools::propertyChanged() {
|
void DrawTools::propertyChanged() {
|
||||||
if (!cur_item) return;
|
if (!cur_item) return;
|
||||||
QGraphicsSimpleTextItem * itext = qgraphicsitem_cast<QGraphicsSimpleTextItem*>(cur_item);
|
QGraphicsSimpleTextItem * itext = qgraphicsitem_cast<QGraphicsSimpleTextItem *>(cur_item);
|
||||||
AlignedTextItem * iatext = qgraphicsitem_cast<AlignedTextItem*>(cur_item);
|
AlignedTextItem * iatext = qgraphicsitem_cast<AlignedTextItem *>(cur_item);
|
||||||
QGraphicsPixmapItem * ipixmap = qgraphicsitem_cast<QGraphicsPixmapItem*>(cur_item);
|
QGraphicsPixmapItem * ipixmap = qgraphicsitem_cast<QGraphicsPixmapItem *>(cur_item);
|
||||||
QGraphicsRectItem * irect = qgraphicsitem_cast<QGraphicsRectItem*>(cur_item);
|
QGraphicsRectItem * irect = qgraphicsitem_cast<QGraphicsRectItem *>(cur_item);
|
||||||
QGraphicsEllipseItem * iell = qgraphicsitem_cast<QGraphicsEllipseItem*>(cur_item);
|
QGraphicsEllipseItem * iell = qgraphicsitem_cast<QGraphicsEllipseItem *>(cur_item);
|
||||||
QGraphicsLineItem * iline = qgraphicsitem_cast<QGraphicsLineItem*>(cur_item);
|
QGraphicsLineItem * iline = qgraphicsitem_cast<QGraphicsLineItem *>(cur_item);
|
||||||
if (itext) {
|
if (itext) {
|
||||||
QRectF obr = itext->boundingRect();
|
QRectF obr = itext->boundingRect();
|
||||||
itext->setFont(font_dlg.currentFont());
|
itext->setFont(font_dlg.currentFont());
|
||||||
@@ -763,7 +774,7 @@ void DrawTools::propertyChanged() {
|
|||||||
QSizeF ds = (os - ns) / 2.;
|
QSizeF ds = (os - ns) / 2.;
|
||||||
ipixmap->setPos(ipixmap->pos() + QPointF(ds.width(), ds.height()));
|
ipixmap->setPos(ipixmap->pos() + QPointF(ds.width(), ds.height()));
|
||||||
} else if (irect || iell) {
|
} else if (irect || iell) {
|
||||||
QAbstractGraphicsShapeItem * ishape(0);
|
QAbstractGraphicsShapeItem * ishape = nullptr;
|
||||||
if (irect) {
|
if (irect) {
|
||||||
ishape = irect;
|
ishape = irect;
|
||||||
irect->setRect(QRectF(irect->rect().topLeft(), QSizeF(ui->spinWidth->value(), ui->spinHeight->value())));
|
irect->setRect(QRectF(irect->rect().topLeft(), QSizeF(ui->spinWidth->value(), ui->spinHeight->value())));
|
||||||
@@ -775,28 +786,24 @@ void DrawTools::propertyChanged() {
|
|||||||
if (ishape) {
|
if (ishape) {
|
||||||
ishape->setPen(QPen(ui->colorButtonPen->color(), ui->spinThick->value(), (Qt::PenStyle)ui->comboLineStyle->currentIndex()));
|
ishape->setPen(QPen(ui->colorButtonPen->color(), ui->spinThick->value(), (Qt::PenStyle)ui->comboLineStyle->currentIndex()));
|
||||||
ishape->setBrush(ui->colorButtonBrush->color());
|
ishape->setBrush(ui->colorButtonBrush->color());
|
||||||
if (resize_enabled)
|
if (resize_enabled) size_item.assignObject(ishape);
|
||||||
size_item.assignObject(ishape);
|
|
||||||
}
|
}
|
||||||
} else if (iline) {
|
} else if (iline) {
|
||||||
iline->setPen(QPen(ui->colorButtonPen->color(), ui->spinThick->value(), (Qt::PenStyle)ui->comboLineStyle->currentIndex()));
|
iline->setPen(QPen(ui->colorButtonPen->color(), ui->spinThick->value(), (Qt::PenStyle)ui->comboLineStyle->currentIndex()));
|
||||||
if (resize_enabled)
|
if (resize_enabled) size_item.assignObject(iline);
|
||||||
size_item.assignObject(iline);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DrawTools::comboLineStyleChanged() {
|
void DrawTools::comboLineStyleChanged() {
|
||||||
if (!cur_item) return;
|
if (!cur_item) return;
|
||||||
QGraphicsRectItem * irect = qgraphicsitem_cast<QGraphicsRectItem*>(cur_item);
|
QGraphicsRectItem * irect = qgraphicsitem_cast<QGraphicsRectItem *>(cur_item);
|
||||||
QGraphicsEllipseItem * iell = qgraphicsitem_cast<QGraphicsEllipseItem*>(cur_item);
|
QGraphicsEllipseItem * iell = qgraphicsitem_cast<QGraphicsEllipseItem *>(cur_item);
|
||||||
QGraphicsLineItem * iline = qgraphicsitem_cast<QGraphicsLineItem*>(cur_item);
|
QGraphicsLineItem * iline = qgraphicsitem_cast<QGraphicsLineItem *>(cur_item);
|
||||||
if (irect || iell) {
|
if (irect || iell) {
|
||||||
QAbstractGraphicsShapeItem * ishape(0);
|
QAbstractGraphicsShapeItem * ishape = nullptr;
|
||||||
if (irect)
|
if (irect) ishape = irect;
|
||||||
ishape = irect;
|
if (iell) ishape = iell;
|
||||||
if (iell)
|
|
||||||
ishape = iell;
|
|
||||||
if (ishape) {
|
if (ishape) {
|
||||||
QPen p(ishape->pen());
|
QPen p(ishape->pen());
|
||||||
p.setStyle((Qt::PenStyle)ui->comboLineStyle->currentIndex());
|
p.setStyle((Qt::PenStyle)ui->comboLineStyle->currentIndex());
|
||||||
@@ -813,7 +820,7 @@ void DrawTools::comboLineStyleChanged() {
|
|||||||
|
|
||||||
|
|
||||||
void DrawTools::buttonImage_clicked() {
|
void DrawTools::buttonImage_clicked() {
|
||||||
QGraphicsPixmapItem * pi = qgraphicsitem_cast<QGraphicsPixmapItem * >(cur_item);
|
QGraphicsPixmapItem * pi = qgraphicsitem_cast<QGraphicsPixmapItem *>(cur_item);
|
||||||
if (!pi) return;
|
if (!pi) return;
|
||||||
QList<QByteArray> sif(QImageReader::supportedImageFormats());
|
QList<QByteArray> sif(QImageReader::supportedImageFormats());
|
||||||
QString f;
|
QString f;
|
||||||
@@ -837,7 +844,7 @@ void DrawTools::buttonImage_clicked() {
|
|||||||
|
|
||||||
|
|
||||||
void DrawTools::buttonImagePaste_clicked() {
|
void DrawTools::buttonImagePaste_clicked() {
|
||||||
QGraphicsPixmapItem * pi = qgraphicsitem_cast<QGraphicsPixmapItem * >(cur_item);
|
QGraphicsPixmapItem * pi = qgraphicsitem_cast<QGraphicsPixmapItem *>(cur_item);
|
||||||
if (!pi) return;
|
if (!pi) return;
|
||||||
QPixmap pm = QApplication::clipboard()->pixmap();
|
QPixmap pm = QApplication::clipboard()->pixmap();
|
||||||
if (pm.isNull()) return;
|
if (pm.isNull()) return;
|
||||||
@@ -852,8 +859,8 @@ void DrawTools::buttonImagePaste_clicked() {
|
|||||||
|
|
||||||
void DrawTools::buttonFont_clicked() {
|
void DrawTools::buttonFont_clicked() {
|
||||||
if (!cur_item) return;
|
if (!cur_item) return;
|
||||||
QGraphicsSimpleTextItem * ti = qgraphicsitem_cast<QGraphicsSimpleTextItem * >(cur_item);
|
QGraphicsSimpleTextItem * ti = qgraphicsitem_cast<QGraphicsSimpleTextItem *>(cur_item);
|
||||||
AlignedTextItem * ati = qgraphicsitem_cast<AlignedTextItem * >(cur_item);
|
AlignedTextItem * ati = qgraphicsitem_cast<AlignedTextItem *>(cur_item);
|
||||||
if (!ti && !ati) return;
|
if (!ti && !ati) return;
|
||||||
QFont font_prev;
|
QFont font_prev;
|
||||||
if (ti) font_prev = ti->font();
|
if (ti) font_prev = ti->font();
|
||||||
@@ -861,10 +868,11 @@ void DrawTools::buttonFont_clicked() {
|
|||||||
font_dlg.blockSignals(true);
|
font_dlg.blockSignals(true);
|
||||||
font_dlg.setCurrentFont(font_prev);
|
font_dlg.setCurrentFont(font_prev);
|
||||||
font_dlg.blockSignals(false);
|
font_dlg.blockSignals(false);
|
||||||
if (font_dlg.exec() == QDialog::Rejected)
|
if (font_dlg.exec() == QDialog::Rejected) {
|
||||||
font_dlg.setCurrentFont(font_prev);
|
font_dlg.setCurrentFont(font_prev);
|
||||||
else
|
} else {
|
||||||
changeFinished();
|
changeFinished();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -873,8 +881,7 @@ void DrawTools::buttonTextEdit_clicked() {
|
|||||||
text_edit.setPlainText(ui->comboText->lineEdit()->text());
|
text_edit.setPlainText(ui->comboText->lineEdit()->text());
|
||||||
text_edit.selectAll();
|
text_edit.selectAll();
|
||||||
text_edit.setFocus();
|
text_edit.setFocus();
|
||||||
if (text_dlg.exec() == QDialog::Rejected)
|
if (text_dlg.exec() == QDialog::Rejected) return;
|
||||||
return;
|
|
||||||
ui->comboText->lineEdit()->setText(text_edit.toPlainText());
|
ui->comboText->lineEdit()->setText(text_edit.toPlainText());
|
||||||
propertyChanged();
|
propertyChanged();
|
||||||
changeFinished();
|
changeFinished();
|
||||||
@@ -884,12 +891,13 @@ void DrawTools::buttonTextEdit_clicked() {
|
|||||||
void DrawTools::actionZ_triggered() {
|
void DrawTools::actionZ_triggered() {
|
||||||
if (!cur_item) return;
|
if (!cur_item) return;
|
||||||
if (cur_item->data(bvidType).toInt() == bvitDecor) {
|
if (cur_item->data(bvidType).toInt() == bvitDecor) {
|
||||||
BlockView * view = 0;
|
BlockView * view = nullptr;
|
||||||
if (cur_item->scene()) if (!cur_item->scene()->views().isEmpty())
|
if (cur_item->scene()) if (!cur_item->scene()->views().isEmpty()) {
|
||||||
view = qobject_cast<BlockView * >(cur_item->scene()->views()[0]);
|
view = qobject_cast<BlockView *>(cur_item->scene()->views()[0]);
|
||||||
|
}
|
||||||
if (!view) return;
|
if (!view) return;
|
||||||
QGraphicsScene * scene = view->scene();
|
QGraphicsScene * scene = view->scene();
|
||||||
QList<QGraphicsItem*> dl = view->decors();
|
QList<QGraphicsItem *> dl = view->decors();
|
||||||
scene->blockSignals(true);
|
scene->blockSignals(true);
|
||||||
foreach (QGraphicsItem * d, dl) scene->removeItem(d);
|
foreach (QGraphicsItem * d, dl) scene->removeItem(d);
|
||||||
int ind = dl.indexOf(cur_item);
|
int ind = dl.indexOf(cur_item);
|
||||||
@@ -902,10 +910,10 @@ void DrawTools::actionZ_triggered() {
|
|||||||
scene->blockSignals(false);
|
scene->blockSignals(false);
|
||||||
}
|
}
|
||||||
if (cur_item->data(bvidBlockDecor).toBool()) {
|
if (cur_item->data(bvidBlockDecor).toBool()) {
|
||||||
BlockItem * bi = qgraphicsitem_cast<BlockItem*>(cur_item->parentItem());
|
BlockItem * bi = qgraphicsitem_cast<BlockItem *>(cur_item->parentItem());
|
||||||
if (!bi) return;
|
if (!bi) return;
|
||||||
QList<QGraphicsItem*> dl = bi->decors_;
|
QList<QGraphicsItem *> dl = bi->decors_;
|
||||||
foreach (QGraphicsItem * d, dl) d->setParentItem(0);
|
foreach (QGraphicsItem * d, dl) d->setParentItem(nullptr);
|
||||||
int ind = dl.indexOf(cur_item);
|
int ind = dl.indexOf(cur_item);
|
||||||
dl.removeAt(ind);
|
dl.removeAt(ind);
|
||||||
if (sender() == &actions_Z_up) dl.insert(ind + 1, cur_item);
|
if (sender() == &actions_Z_up) dl.insert(ind + 1, cur_item);
|
||||||
@@ -924,9 +932,8 @@ void DrawTools::actionZ_triggered() {
|
|||||||
void DrawTools::setResizeHandlesEnabled(bool on) {
|
void DrawTools::setResizeHandlesEnabled(bool on) {
|
||||||
resize_enabled = on;
|
resize_enabled = on;
|
||||||
if (!on) {
|
if (!on) {
|
||||||
size_item.assignObject(0);
|
size_item.assignObject(nullptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (cur_item && on)
|
if (cur_item && on) propertyChanged();
|
||||||
propertyChanged();
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user