diff --git a/src/board/UBFeaturesController.cpp b/src/board/UBFeaturesController.cpp index 68890f2a..1cfe431e 100644 --- a/src/board/UBFeaturesController.cpp +++ b/src/board/UBFeaturesController.cpp @@ -59,8 +59,8 @@ const QString UBFeaturesController::webSearchPath = rootPath + "/Web search"; void UBFeaturesComputingThread::scanFS(const QUrl & currentPath, const QString & currVirtualPath, const QSet &pFavoriteSet) { // Q_ASSERT(QFileInfo(currentPath.toLocalFile()).exists()); - if(QFileInfo(currentPath.toLocalFile()).exists()) - return; +// if(QFileInfo(currentPath.toLocalFile()).exists()) +// return; QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(currentPath.toLocalFile()); diff --git a/src/domain/UBGraphicsItemDelegate.cpp b/src/domain/UBGraphicsItemDelegate.cpp index 752758d6..2f7977cd 100644 --- a/src/domain/UBGraphicsItemDelegate.cpp +++ b/src/domain/UBGraphicsItemDelegate.cpp @@ -316,6 +316,7 @@ void UBGraphicsItemDelegate::postpaint(QPainter *painter, const QStyleOptionGrap painter->setPen(Qt::NoPen); painter->setBrush(QColor(0x88, 0x88, 0x88, 0x77)); painter->drawRect(option->rect); + painter->restore(); } } diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index a00e2923..dbda4d5f 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -249,9 +249,15 @@ qreal UBZLayerController::changeZLevelTo(QGraphicsItem *item, moveDestination de item->scene()->clearSelection(); item->setSelected(true); + foreach (QGraphicsItem *iitem, sortedItems.values()) { + if (iitem) + iitem != item + ? qDebug() << "current value" << iitem->zValue() + : qDebug() << "marked value" << QString::number(iitem->zValue(), 'f'); + } + //Return new z value assigned to item return item->data(UBGraphicsItemData::ItemOwnZValue).toReal(); - } itemLayerType::Enum UBZLayerController::typeForData(QGraphicsItem *item) const @@ -317,7 +323,7 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoSta } // Just for debug. Do not delete please -// connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing())); + connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing())); connect(this, SIGNAL(selectionChanged()), this, SLOT(updateGroupButtonState())); connect(UBApplication::undoStack.data(), SIGNAL(indexChanged(int)), this, SLOT(updateSelectionFrameWrapper(int))); } diff --git a/src/domain/UBSelectionFrame.cpp b/src/domain/UBSelectionFrame.cpp index c50e4c45..cab64b40 100644 --- a/src/domain/UBSelectionFrame.cpp +++ b/src/domain/UBSelectionFrame.cpp @@ -9,6 +9,7 @@ #include "gui/UBResources.h" #include "core/UBApplication.h" #include "domain/UBGraphicsScene.h" +#include "board/UBBoardView.h" UBSelectionFrame::UBSelectionFrame() : mThickness(UBSettings::settings()->objectFrameWidth) @@ -125,6 +126,7 @@ void UBSelectionFrame::mousePressEvent(QGraphicsSceneMouseEvent *event) { mPressedPos = mLastMovedPos = event->pos(); mLastTranslateOffset = QPointF(); + mRotationAngle = 0; if (scene()->itemAt(event->scenePos()) == mRotateButton) { mOperationMode = om_rotating; @@ -142,6 +144,7 @@ void UBSelectionFrame::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBSelectionFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { QPointF dp = event->pos() - mPressedPos; + QPointF rotCenter = mapToScene(rect().center()); foreach (UBGraphicsItemDelegate *curDelegate, mEnclosedtems) { @@ -174,17 +177,24 @@ void UBSelectionFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) QGraphicsItem *item = curDelegate->delegated(); QTransform ownTransform = item->transform(); - qreal cntrX = item->boundingRect().center().x(); - qreal cntrY = item->boundingRect().center().y(); + + QPointF nextRotCenter = item->mapFromScene(rotCenter); + + qreal cntrX = nextRotCenter.x(); + qreal cntrY = nextRotCenter.y(); ownTransform.translate(cntrX, cntrY); mRotationAngle -= dAngle; - ownTransform.rotate(mRotationAngle); + ownTransform.rotate(-dAngle); ownTransform.translate(-cntrX, -cntrY); - item->setTransform(ownTransform); + item->update(); + item->setTransform(ownTransform, false); + + int resultAngle = (int)mRotationAngle % 360; +// setCursorFromAngle(QString::number(resultAngle)); - qDebug() << "curAngle" << dAngle; + qDebug() << "curAngle" << mRotationAngle; } break; } @@ -356,6 +366,38 @@ inline UBGraphicsScene *UBSelectionFrame::ubscene() return qobject_cast(scene()); } +void UBSelectionFrame::setCursorFromAngle(QString angle) +{ + QWidget *controlViewport = UBApplication::boardController->controlView()->viewport(); + + QSize cursorSize(45,30); + + + QImage mask_img(cursorSize, QImage::Format_Mono); + mask_img.fill(0xff); + QPainter mask_ptr(&mask_img); + mask_ptr.setBrush( QBrush( QColor(0, 0, 0) ) ); + mask_ptr.drawRoundedRect(0,0, cursorSize.width()-1, cursorSize.height()-1, 6, 6); + QBitmap bmpMask = QBitmap::fromImage(mask_img); + + + QPixmap pixCursor(cursorSize); + pixCursor.fill(QColor(Qt::white)); + + QPainter painter(&pixCursor); + + painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); + painter.setBrush(QBrush(Qt::white)); + painter.setPen(QPen(QColor(Qt::black))); + painter.drawRoundedRect(1,1,cursorSize.width()-2,cursorSize.height()-2,6,6); + painter.setFont(QFont("Arial", 10)); + painter.drawText(1,1,cursorSize.width(),cursorSize.height(), Qt::AlignCenter, angle.append(QChar(176))); + painter.end(); + + pixCursor.setMask(bmpMask); + controlViewport->setCursor(pixCursor); +} + QList UBSelectionFrame::sortedByZ(const QList &pItems) { //select only items wiht the same z-level as item's one and push it to sortedItems QMultiMap @@ -394,7 +436,7 @@ QList UBSelectionFrame::buttonsForFlags(UBGraphicsFlags fls) { if (!mZOrderUpButton) { mZOrderUpButton = new DelegateButton(":/images/z_layer_up.svg", this, 0, Qt::BottomLeftSection); mZOrderUpButton->setShowProgressIndicator(true); - connect(mZOrderUpButton, SIGNAL(clicked()), this, SLOT(increaseZlrfevelUp())); + connect(mZOrderUpButton, SIGNAL(clicked()), this, SLOT(increaseZlevelUp())); connect(mZOrderUpButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelTop())); } diff --git a/src/domain/UBSelectionFrame.h b/src/domain/UBSelectionFrame.h index 18278c17..b9069ebe 100644 --- a/src/domain/UBSelectionFrame.h +++ b/src/domain/UBSelectionFrame.h @@ -15,7 +15,7 @@ class UBSelectionFrame : public QObject, public QGraphicsRectItem public: enum {om_idle, om_moving, om_rotating} mOperationMode; - enum { Type = UBGraphicsItemType::PixmapItemType }; + enum { Type = UBGraphicsItemType::SelectionFrameType }; UBSelectionFrame(); @@ -54,6 +54,7 @@ private: void clearButtons(); inline int adjThickness() const {return mThickness * mAntiscaleRatio;} inline UBGraphicsScene* ubscene(); + void setCursorFromAngle(QString angle); QList sortedByZ(const QList &pItems); QList buttonsForFlags(UBGraphicsFlags fls);