|
|
@ -42,8 +42,9 @@ UBSelectionFrame::UBSelectionFrame() |
|
|
|
// connect(mZOrderDownButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelBottom()));
|
|
|
|
// connect(mZOrderDownButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelBottom()));
|
|
|
|
mButtons << mZOrderDownButton; |
|
|
|
mButtons << mZOrderDownButton; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect(UBApplication::boardController, SIGNAL(zoomChanged(qreal)), this, SLOT(onZoomChanged(qreal))); |
|
|
|
connect(UBApplication::boardController, SIGNAL(zoomChanged(qreal)), this, SLOT(onZoomChanged(qreal))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onZoomChanged(UBApplication::boardController->currentZoom()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBSelectionFrame::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
|
|
void UBSelectionFrame::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
|
@ -53,11 +54,11 @@ void UBSelectionFrame::paint(QPainter *painter, const QStyleOptionGraphicsItem * |
|
|
|
|
|
|
|
|
|
|
|
QPainterPath path; |
|
|
|
QPainterPath path; |
|
|
|
QRectF shRect = option->rect; |
|
|
|
QRectF shRect = option->rect; |
|
|
|
path.addRoundedRect(shRect, mThickness / 2, mThickness / 2); |
|
|
|
path.addRoundedRect(shRect, adjThickness() / 2, adjThickness() / 2); |
|
|
|
|
|
|
|
|
|
|
|
if (rect().width() > 1 && rect().height() > 1) { |
|
|
|
if (rect().width() > 1 && rect().height() > 1) { |
|
|
|
QPainterPath extruded; |
|
|
|
QPainterPath extruded; |
|
|
|
extruded.addRect(shRect.adjusted(mThickness, mThickness, (mThickness * -1), (mThickness * -1))); |
|
|
|
extruded.addRect(shRect.adjusted(adjThickness(), adjThickness(), (adjThickness() * -1), (adjThickness() * -1))); |
|
|
|
path = path.subtracted(extruded); |
|
|
|
path = path.subtracted(extruded); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -66,15 +67,15 @@ void UBSelectionFrame::paint(QPainter *painter, const QStyleOptionGraphicsItem * |
|
|
|
|
|
|
|
|
|
|
|
QRectF UBSelectionFrame::boundingRect() const |
|
|
|
QRectF UBSelectionFrame::boundingRect() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
return rect().adjusted(-mThickness, -mThickness, mThickness, mThickness); |
|
|
|
return rect().adjusted(-adjThickness(), -adjThickness(), adjThickness(), adjThickness()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QPainterPath UBSelectionFrame::shape() const |
|
|
|
QPainterPath UBSelectionFrame::shape() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
QPainterPath resShape; |
|
|
|
QPainterPath resShape; |
|
|
|
QRectF ownRect = rect(); |
|
|
|
QRectF ownRect = rect(); |
|
|
|
QRectF shRect = ownRect.adjusted(-mThickness, -mThickness, mThickness, mThickness); |
|
|
|
QRectF shRect = ownRect.adjusted(-adjThickness(), -adjThickness(), adjThickness(), adjThickness()); |
|
|
|
resShape.addRoundedRect(shRect, mThickness / 2, mThickness / 2); |
|
|
|
resShape.addRoundedRect(shRect, adjThickness() / 2, adjThickness() / 2); |
|
|
|
|
|
|
|
|
|
|
|
if (rect().width() > 1 && rect().height() > 1) { |
|
|
|
if (rect().width() > 1 && rect().height() > 1) { |
|
|
|
QPainterPath extruded; |
|
|
|
QPainterPath extruded; |
|
|
@ -89,6 +90,8 @@ void UBSelectionFrame::setEnclosedItems(const QList<QGraphicsItem*> pGraphicsIte |
|
|
|
{ |
|
|
|
{ |
|
|
|
mButtons.clear(); |
|
|
|
mButtons.clear(); |
|
|
|
mButtons.append(mDeleteButton); |
|
|
|
mButtons.append(mDeleteButton); |
|
|
|
|
|
|
|
mButtons.append(mZOrderUpButton); |
|
|
|
|
|
|
|
mButtons.append(mZOrderDownButton); |
|
|
|
|
|
|
|
|
|
|
|
QRegion resultRegion; |
|
|
|
QRegion resultRegion; |
|
|
|
mEnclosedtems.clear(); |
|
|
|
mEnclosedtems.clear(); |
|
|
@ -186,8 +189,15 @@ void UBSelectionFrame::mouseReleaseEvent(QGraphicsSceneMouseEvent */*event*/) |
|
|
|
|
|
|
|
|
|
|
|
void UBSelectionFrame::onZoomChanged(qreal pZoom) |
|
|
|
void UBSelectionFrame::onZoomChanged(qreal pZoom) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// mAntiscaleRatio = pZoom;
|
|
|
|
qDebug() << "Pzoom" << pZoom; |
|
|
|
|
|
|
|
qDebug() << "Board current zoom" << UBApplication::boardController->currentZoom(); |
|
|
|
|
|
|
|
qDebug() << "UBApplication::boardController->systemScaleFactor()" << UBApplication::boardController->systemScaleFactor(); |
|
|
|
|
|
|
|
mAntiscaleRatio = 1 / (UBApplication::boardController->systemScaleFactor() * pZoom); |
|
|
|
// updateScale();
|
|
|
|
// updateScale();
|
|
|
|
|
|
|
|
// QTransform tr;
|
|
|
|
|
|
|
|
// tr.scale(mAntiscaleRatio, mAntiscaleRatio);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// this->setTransform(tr);
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBSelectionFrame::remove() |
|
|
|
void UBSelectionFrame::remove() |
|
|
@ -206,55 +216,38 @@ void UBSelectionFrame::translateItem(QGraphicsItem */*item*/, const QPointF &/*t |
|
|
|
void UBSelectionFrame::placeButtons() |
|
|
|
void UBSelectionFrame::placeButtons() |
|
|
|
{ |
|
|
|
{ |
|
|
|
QTransform tr; |
|
|
|
QTransform tr; |
|
|
|
// tr.scale(mAntiScaleRatio, mAntiScaleRatio);
|
|
|
|
tr.scale(mAntiscaleRatio, mAntiscaleRatio); |
|
|
|
|
|
|
|
|
|
|
|
mDeleteButton->setParentItem(this); |
|
|
|
mDeleteButton->setParentItem(this); |
|
|
|
// mDeleteButton->setTransform(tr);
|
|
|
|
mDeleteButton->setTransform(tr); |
|
|
|
|
|
|
|
|
|
|
|
qreal topX = rect().left() - mDeleteButton->renderer()->viewBox().width() /** mAntiScaleRatio*/ * 1.2; |
|
|
|
QRectF frRect = boundingRect(); |
|
|
|
qreal topY = rect().top() - mDeleteButton->renderer()->viewBox().height() /** mAntiScaleRatio*/ * 1.2; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qreal bottomX = rect().left() - mDeleteButton->renderer()->viewBox().width() /** mAntiScaleRatio*/ / 2; |
|
|
|
qreal topX = frRect.left() - mDeleteButton->renderer()->viewBox().width() * mAntiscaleRatio / 2; |
|
|
|
qreal bottomY = rect().bottom() - mDeleteButton->renderer()->viewBox().height() /** mAntiScaleRatio*/ / 2; |
|
|
|
qreal topY = frRect.top() - mDeleteButton->renderer()->viewBox().height() * mAntiscaleRatio / 2; |
|
|
|
|
|
|
|
|
|
|
|
mDeleteButton->setPos(topX, topY); |
|
|
|
qreal bottomX = topX; |
|
|
|
// mDeleteButton->setPos(0, 0);
|
|
|
|
qreal bottomY = frRect.bottom() - mDeleteButton->renderer()->viewBox().height() * mAntiscaleRatio / 2; |
|
|
|
|
|
|
|
|
|
|
|
// if (!mDeleteButton->scene())
|
|
|
|
mDeleteButton->setPos(topX, topY); |
|
|
|
// {
|
|
|
|
|
|
|
|
// if (scene())
|
|
|
|
|
|
|
|
// scene()->addItem(mDeleteButton);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
mDeleteButton->show(); |
|
|
|
mDeleteButton->show(); |
|
|
|
|
|
|
|
|
|
|
|
// if (showUpdated)
|
|
|
|
int i = 1, j = 0, k = 0; |
|
|
|
// mDeleteButton->show();
|
|
|
|
while ((i + j + k) < mButtons.size()) { |
|
|
|
|
|
|
|
DelegateButton* button = mButtons[i + j]; |
|
|
|
// int i = 1, j = 0, k = 0;
|
|
|
|
|
|
|
|
// while ((i + j + k) < mButtons.size()) {
|
|
|
|
if (button->getSection() == Qt::TopLeftSection) { |
|
|
|
// DelegateButton* button = mButtons[i + j];
|
|
|
|
button->setParentItem(this); |
|
|
|
|
|
|
|
button->setPos(topX + (i++ * 1.6 * adjThickness()), topY); |
|
|
|
// if (button->getSection() == Qt::TopLeftSection) {
|
|
|
|
button->setTransform(tr); |
|
|
|
// button->setParentItem(mFrame);
|
|
|
|
} else if (button->getSection() == Qt::BottomLeftSection) { |
|
|
|
// button->setPos(topX + (i++ * 1.6 * mFrameWidth * mAntiScaleRatio), topY);
|
|
|
|
button->setParentItem(this); |
|
|
|
// button->setTransform(tr);
|
|
|
|
button->setPos(bottomX + (++j * 1.6 * adjThickness()), bottomY); |
|
|
|
// } else if (button->getSection() == Qt::BottomLeftSection) {
|
|
|
|
button->setTransform(tr); |
|
|
|
// button->setParentItem(mFrame);
|
|
|
|
} else { |
|
|
|
// button->setPos(bottomX + (++j * 1.6 * mFrameWidth * mAntiScaleRatio), bottomY);
|
|
|
|
++k; |
|
|
|
// button->setTransform(tr);
|
|
|
|
} |
|
|
|
// } else if (button->getSection() == Qt::TitleBarArea || button->getSection() == Qt::NoSection){
|
|
|
|
button->show(); |
|
|
|
// ++k;
|
|
|
|
} |
|
|
|
// }
|
|
|
|
|
|
|
|
// if (!button->scene())
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// if (mDelegated->scene())
|
|
|
|
|
|
|
|
// mDelegated->scene()->addItem(button);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (showUpdated) {
|
|
|
|
|
|
|
|
// button->show();
|
|
|
|
|
|
|
|
// button->setZValue(delegated()->zValue());
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBSelectionFrame::clearButtons() |
|
|
|
void UBSelectionFrame::clearButtons() |
|
|
|