From d3cf15f5b88399418591fb0662f7ebf21fe6aa61 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 28 Oct 2017 17:31:18 +0300 Subject: [PATCH] Fix some bugs. --HG-- branch : develop --- src/app/valentina/mainwindow.cpp | 121 ++++++++++-------- src/app/valentina/mainwindow.h | 2 +- .../toolcut/vtoolcutsplinepath.cpp | 2 + .../toolsinglepoint/vtoolsinglepoint.cpp | 2 +- src/libs/vtools/tools/vtoolseamallowance.cpp | 44 ++++--- .../visualization/path/vistoolcutspline.cpp | 6 +- .../path/vistoolduplicatedetail.cpp | 2 + src/libs/vwidgets/vgrainlineitem.cpp | 17 ++- src/libs/vwidgets/vgraphicssimpletextitem.cpp | 2 +- src/libs/vwidgets/vmaingraphicsview.cpp | 16 ++- src/libs/vwidgets/vsimplecurve.cpp | 2 +- src/libs/vwidgets/vsimplepoint.cpp | 2 +- src/libs/vwidgets/vtextgraphicsitem.cpp | 24 +++- src/libs/vwidgets/vtextgraphicsitem.h | 1 + 14 files changed, 156 insertions(+), 87 deletions(-) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index f725dd054..f9710b139 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -694,7 +694,7 @@ void MainWindow::ClosedDialog(int result) // Do not check for nullptr! See issue #719. ui->view->itemClicked(tool); } - ArrowTool(); + ArrowTool(true); } //--------------------------------------------------------------------------------------------------------------------- @@ -718,7 +718,7 @@ void MainWindow::ClosedDialogWithApply(int result, VMainGraphicsScene *scene) vtool->DialogLinkDestroy(); connect(vtool, &DrawTool::ToolTip, this, &MainWindow::ShowToolTip); } - ArrowTool(); + ArrowTool(true); ui->view->itemClicked(vtool);// Don't check for nullptr here // If insert not to the end of file call lite parse if (doc->getCursor() > 0) @@ -1131,7 +1131,7 @@ void MainWindow::ClosedDialogDuplicateDetail(int result) // Do not check for nullptr! See issue #719. ui->view->itemClicked(tool); } - ArrowTool(); + ArrowTool(true); } //--------------------------------------------------------------------------------------------------------------------- @@ -1209,7 +1209,7 @@ void MainWindow::ClosedDialogGroup(int result) qApp->getUndoStack()->push(addGroup); } } - ArrowTool(); + ArrowTool(true); } //--------------------------------------------------------------------------------------------------------------------- @@ -1220,7 +1220,7 @@ void MainWindow::ClosedDialogPiecePath(int result) { VToolPiecePath::Create(dialogTool, sceneDetails, doc, pattern); } - ArrowTool(); + ArrowTool(true); doc->LiteParseTree(Document::LiteParse); } @@ -1232,7 +1232,7 @@ void MainWindow::ClosedDialogPin(int result) { VToolPin::Create(dialogTool, doc, pattern); } - ArrowTool(); + ArrowTool(true); doc->LiteParseTree(Document::LiteParse); } @@ -1244,7 +1244,7 @@ void MainWindow::ClosedDialogPlaceLabel(int result) { VToolPlaceLabel::Create(dialogTool, doc, pattern); } - ArrowTool(); + ArrowTool(true); doc->LiteParseTree(Document::LiteParse); } @@ -1258,7 +1258,7 @@ void MainWindow::ClosedDialogInsertNode(int result) SCASSERT(dTool != nullptr) VToolSeamAllowance::InsertNode(dTool->GetNode(), dTool->GetPieceId(), sceneDetails, pattern, doc); } - ArrowTool(); + ArrowTool(true); doc->LiteParseTree(Document::LiteParse); } @@ -2271,49 +2271,58 @@ QT_WARNING_POP /** * @brief ArrowTool enable arrow tool. */ -void MainWindow::ArrowTool() +void MainWindow::ArrowTool(bool checked) { - qCDebug(vMainWindow, "Arrow tool."); - CancelTool(); - for (auto pointer : toolButtonPointerList) + if (checked) { - pointer->setChecked(true); + qCDebug(vMainWindow, "Arrow tool."); + CancelTool(); + for (auto pointer : toolButtonPointerList) + { + pointer->setChecked(true); + } + currentTool = Tool::Arrow; + emit EnableItemMove(true); + emit ItemsSelection(SelectionType::ByMouseRelease); + VAbstractTool::m_suppressContextMenu = false; + + // Only true for rubber band selection + emit EnableLabelSelection(true); + emit EnablePointSelection(false); + emit EnableLineSelection(false); + emit EnableArcSelection(false); + emit EnableElArcSelection(false); + emit EnableSplineSelection(false); + emit EnableSplinePathSelection(false); + emit EnableNodeLabelSelection(true); + emit EnableNodePointSelection(true); + emit EnableDetailSelection(true);// Disable when done visualization details + + // Hovering + emit EnableLabelHover(true); + emit EnablePointHover(true); + emit EnableLineHover(true); + emit EnableArcHover(true); + emit EnableElArcHover(true); + emit EnableSplineHover(true); + emit EnableSplinePathHover(true); + emit EnableNodeLabelHover(true); + emit EnableNodePointHover(true); + emit EnableDetailHover(true); + + ui->view->AllowRubberBand(true); + ui->view->viewport()->setCursor(QCursor(Qt::ArrowCursor)); + helpLabel->setText(""); + ui->view->setShowToolOptions(true); + qCDebug(vMainWindow, "Enabled arrow tool."); + } + else + { + for (auto pointer : toolButtonPointerList) + { + pointer->setChecked(true); + } } - currentTool = Tool::Arrow; - emit EnableItemMove(true); - emit ItemsSelection(SelectionType::ByMouseRelease); - VAbstractTool::m_suppressContextMenu = false; - - // Only true for rubber band selection - emit EnableLabelSelection(true); - emit EnablePointSelection(false); - emit EnableLineSelection(false); - emit EnableArcSelection(false); - emit EnableElArcSelection(false); - emit EnableSplineSelection(false); - emit EnableSplinePathSelection(false); - emit EnableNodeLabelSelection(true); - emit EnableNodePointSelection(true); - emit EnableDetailSelection(true);// Disable when done visualization details - - // Hovering - emit EnableLabelHover(true); - emit EnablePointHover(true); - emit EnableLineHover(true); - emit EnableArcHover(true); - emit EnableElArcHover(true); - emit EnableSplineHover(true); - emit EnableSplinePathHover(true); - emit EnableNodeLabelHover(true); - emit EnableNodePointHover(true); - emit EnableDetailHover(true); - - ui->view->AllowRubberBand(true); - - ui->view->viewport()->unsetCursor(); - helpLabel->setText(""); - ui->view->setShowToolOptions(true); - qCDebug(vMainWindow, "Enabled arrow tool."); } //--------------------------------------------------------------------------------------------------------------------- @@ -2326,7 +2335,7 @@ void MainWindow::keyPressEvent ( QKeyEvent * event ) switch (event->key()) { case Qt::Key_Escape: - ArrowTool(); + ArrowTool(true); break; case Qt::Key_Return: case Qt::Key_Enter: @@ -2387,7 +2396,7 @@ void MainWindow::ActionDraw(bool checked) if (checked) { qCDebug(vMainWindow, "Show draw scene"); - ArrowTool(); + ArrowTool(true); leftGoToStage->setPixmap(QPixmap("://icon/24x24/fast_forward_left_to_right_arrow.png")); rightGoToStage->setPixmap(QPixmap("://icon/24x24/left_to_right_arrow.png")); @@ -2437,7 +2446,7 @@ void MainWindow::ActionDetails(bool checked) { if (checked) { - ArrowTool(); + ArrowTool(true); if(drawMode) { @@ -2514,7 +2523,7 @@ void MainWindow::ActionLayout(bool checked) { if (checked) { - ArrowTool(); + ArrowTool(true); if(drawMode) { @@ -2879,7 +2888,7 @@ void MainWindow::Clear() qCDebug(vMainWindow, "Clearing scenes."); sceneDraw->clear(); sceneDetails->clear(); - ArrowTool(); + ArrowTool(true); comboBoxDraws->clear(); ui->actionDraw->setEnabled(false); ui->actionDetails->setEnabled(false); @@ -3151,7 +3160,7 @@ void MainWindow::SetEnabledGUI(bool enabled) { if (enabled == false) { - ArrowTool(); + ArrowTool(true); qApp->getUndoStack()->clear(); } SetEnableWidgets(enabled); @@ -3794,7 +3803,7 @@ void MainWindow::LastUsedTool() { pointer->setChecked(true); } - ArrowTool(); + ArrowTool(true); break; case Tool::BasePoint: case Tool::SinglePoint: @@ -4912,7 +4921,7 @@ void MainWindow::ChangePP(int index, bool zoomBestFit) emit RefreshHistory(); if (drawMode) { - ArrowTool(); + ArrowTool(true); if (zoomBestFit) { ZoomFitBestCurrent(); diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index 386f04058..a811bfdef 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -124,7 +124,7 @@ private slots: void ExportLayoutAs(); void ExportDetailsAs(); - void ArrowTool(); + void ArrowTool(bool checked); void ToolEndLine(bool checked); void ToolLine(bool checked); void ToolAlongLine(bool checked); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp index 58e12eea6..399096692 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp @@ -210,7 +210,9 @@ VPointF *VToolCutSplinePath::CutSplinePath(qreal length, const QSharedPointerGetApproximationScale()); *splPath1 = new VSplinePath(); + (*splPath1)->SetApproximationScale(splPath->GetApproximationScale()); *splPath2 = new VSplinePath(); + (*splPath2)->SetApproximationScale(splPath->GetApproximationScale()); for (qint32 i = 0; i < points.size(); i++) { diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp index c975e7a6e..a02276b2d 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp @@ -237,7 +237,7 @@ void VToolSinglePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (selectionType == SelectionType::ByMouseRelease) { - if (event->button() == Qt::LeftButton) + if (event->button() == Qt::LeftButton && contains(event->pos())) { PointChoosed(); } diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 4cc0724b2..67fb54b0d 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -141,6 +141,7 @@ VToolSeamAllowance *VToolSeamAllowance::Create(VToolSeamAllowanceInitData &initD VAbstractTool::AddRecord(initData.id, Tool::Piece, initData.doc); piece = new VToolSeamAllowance(initData); initData.scene->addItem(piece); + VMainGraphicsView::NewSceneRect(initData.scene, qApp->getSceneView(), piece); VAbstractPattern::AddTool(initData.id, piece); } //Very important to delete it. Only this tool need this special variable. @@ -584,12 +585,19 @@ void VToolSeamAllowance::FullUpdateFromFile() void VToolSeamAllowance::EnableToolMove(bool move) { setFlag(QGraphicsItem::ItemIsMovable, move); + + m_dataLabel->setFlag(QGraphicsItem::ItemIsMovable, move); + m_patternInfo->setFlag(QGraphicsItem::ItemIsMovable, move); + m_grainLine->setFlag(QGraphicsItem::ItemIsMovable, move); } //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::AllowHover(bool enabled) { setAcceptHoverEvents(enabled); + m_dataLabel->setAcceptHoverEvents(enabled); + m_patternInfo->setAcceptHoverEvents(enabled); + m_grainLine->setAcceptHoverEvents(enabled); } //--------------------------------------------------------------------------------------------------------------------- @@ -1086,13 +1094,18 @@ void VToolSeamAllowance::mousePressEvent(QGraphicsSceneMouseEvent *event) } } - if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) + if (selectionType == SelectionType::ByMouseRelease) { - doc->SelectedDetail(m_id); - emit ChoosedTool(m_id, SceneObject::Detail); + event->accept();// Special for not selectable item first need to call standard mousePressEvent then accept event + } + else + { + if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) + { + doc->SelectedDetail(m_id); + emit ChoosedTool(m_id, SceneObject::Detail); + } } - - event->accept();// Special for not selectable item first need to call standard mousePressEvent then accept event } //--------------------------------------------------------------------------------------------------------------------- @@ -1102,6 +1115,15 @@ void VToolSeamAllowance::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); } + + if (selectionType == SelectionType::ByMouseRelease) + { + if (event->button() == Qt::LeftButton && contains(event->pos())) + { + doc->SelectedDetail(m_id); + emit ChoosedTool(m_id, SceneObject::Detail); + } + } QGraphicsPathItem::mouseReleaseEvent(event); } @@ -1112,16 +1134,6 @@ void VToolSeamAllowance::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); } - else - { - if (QGraphicsScene *scene = this->scene()) - { - if (QGraphicsView *view = scene->views().at(0)) - { - setCursor(view->viewport()->cursor()); - } - } - } QGraphicsPathItem::hoverEnterEvent(event); } @@ -1258,6 +1270,8 @@ VToolSeamAllowance::VToolSeamAllowance(const VToolSeamAllowanceInitData &initDat setAcceptHoverEvents(true); connect(this, &VToolSeamAllowance::ChoosedTool, m_sceneDetails, &VMainGraphicsScene::ChoosedItem); + connect(m_sceneDetails, &VMainGraphicsScene::EnableToolMove, this, &VToolSeamAllowance::EnableToolMove); + connect(m_sceneDetails, &VMainGraphicsScene::ItemSelection, this, &VToolSeamAllowance::ToolSelectionType); ConnectOutsideSignals(); } diff --git a/src/libs/vtools/visualization/path/vistoolcutspline.cpp b/src/libs/vtools/visualization/path/vistoolcutspline.cpp index 46c53038c..47d8c7174 100644 --- a/src/libs/vtools/visualization/path/vistoolcutspline.cpp +++ b/src/libs/vtools/visualization/path/vistoolcutspline.cpp @@ -76,8 +76,10 @@ void VisToolCutSpline::RefreshGeometry() QPointF spl2p3; const QPointF p = spl->CutSpline (length, spl1p2, spl1p3, spl2p2, spl2p3 ); - const VSpline sp1 = VSpline(spl->GetP1(), spl1p2, spl1p3, VPointF(p)); - const VSpline sp2 = VSpline(VPointF(p), spl2p2, spl2p3, spl->GetP4()); + VSpline sp1 = VSpline(spl->GetP1(), spl1p2, spl1p3, VPointF(p)); + sp1.SetApproximationScale(spl->GetApproximationScale()); + VSpline sp2 = VSpline(VPointF(p), spl2p2, spl2p3, spl->GetP4()); + sp2.SetApproximationScale(spl->GetApproximationScale()); DrawPoint(point, p, mainColor); diff --git a/src/libs/vtools/visualization/path/vistoolduplicatedetail.cpp b/src/libs/vtools/visualization/path/vistoolduplicatedetail.cpp index 971eeaf90..386cf2d6a 100644 --- a/src/libs/vtools/visualization/path/vistoolduplicatedetail.cpp +++ b/src/libs/vtools/visualization/path/vistoolduplicatedetail.cpp @@ -45,10 +45,12 @@ void VisToolDuplicateDetail::RefreshGeometry() { m_start = Visualization::scenePos; m_started = true; + setPos(QPointF(piece.GetMx(), piece.GetMy())); } else { m_diff = Visualization::scenePos - m_start; + m_diff = QPointF(m_diff.x() + piece.GetMx(), m_diff.y() + piece.GetMy()); setPos(m_diff); } diff --git a/src/libs/vwidgets/vgrainlineitem.cpp b/src/libs/vwidgets/vgrainlineitem.cpp index 9b54482a1..f9e09b762 100644 --- a/src/libs/vwidgets/vgrainlineitem.cpp +++ b/src/libs/vwidgets/vgrainlineitem.cpp @@ -271,7 +271,8 @@ bool VGrainlineItem::IsContained(const QPointF& pt, qreal dRot, qreal &dX, qreal */ void VGrainlineItem::mousePressEvent(QGraphicsSceneMouseEvent* pME) { - if (pME->button() == Qt::LeftButton && pME->type() != QEvent::GraphicsSceneMouseDoubleClick) + if (pME->button() == Qt::LeftButton && pME->type() != QEvent::GraphicsSceneMouseDoubleClick + && (flags() & QGraphicsItem::ItemIsMovable)) { if (m_moveType == NotMovable) { @@ -457,7 +458,7 @@ void VGrainlineItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME) { if (pME->button() == Qt::LeftButton) { - if (m_eMode == mMove || m_eMode == mRotate || m_eMode == mResize) + if ((m_eMode == mMove || m_eMode == mRotate || m_eMode == mResize) && (flags() & QGraphicsItem::ItemIsMovable)) { SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); } @@ -508,14 +509,22 @@ void VGrainlineItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME) //--------------------------------------------------------------------------------------------------------------------- void VGrainlineItem::hoverEnterEvent(QGraphicsSceneHoverEvent *pME) { - m_penWidth = LINE_PEN_WIDTH + 1; + if (flags() & QGraphicsItem::ItemIsMovable) + { + SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); + m_penWidth = LINE_PEN_WIDTH + 1; + } VPieceItem::hoverEnterEvent(pME); } //--------------------------------------------------------------------------------------------------------------------- void VGrainlineItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *pME) { - m_penWidth = LINE_PEN_WIDTH; + if (flags() & QGraphicsItem::ItemIsMovable) + { + setCursor(QCursor()); + m_penWidth = LINE_PEN_WIDTH; + } VPieceItem::hoverLeaveEvent(pME); } diff --git a/src/libs/vwidgets/vgraphicssimpletextitem.cpp b/src/libs/vwidgets/vgraphicssimpletextitem.cpp index da049ec3c..4f0412588 100644 --- a/src/libs/vwidgets/vgraphicssimpletextitem.cpp +++ b/src/libs/vwidgets/vgraphicssimpletextitem.cpp @@ -289,7 +289,7 @@ void VGraphicsSimpleTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) } } - if (selectionType == SelectionType::ByMouseRelease) + if (selectionType == SelectionType::ByMouseRelease && contains(event->pos())) { emit PointChoosed(); } diff --git a/src/libs/vwidgets/vmaingraphicsview.cpp b/src/libs/vwidgets/vmaingraphicsview.cpp index b5f29890b..9ba8bf5c5 100644 --- a/src/libs/vwidgets/vmaingraphicsview.cpp +++ b/src/libs/vwidgets/vmaingraphicsview.cpp @@ -596,9 +596,21 @@ void VMainGraphicsView::NewSceneRect(QGraphicsScene *sc, QGraphicsView *view, QG //Unite two rects sc->setSceneRect(itemsRect.united(viewRect)); } - else if (not sc->sceneRect().contains(item->sceneBoundingRect())) + else { - sc->setSceneRect(sc->sceneRect().united(item->sceneBoundingRect())); + QRectF rect = item->sceneBoundingRect(); + foreach(QGraphicsItem *child, item->childItems()) + { + if(child->isVisible()) + { + rect = rect.united(child->sceneBoundingRect()); + } + } + + if (not sc->sceneRect().contains(rect)) + { + sc->setSceneRect(sc->sceneRect().united(rect)); + } } } diff --git a/src/libs/vwidgets/vsimplecurve.cpp b/src/libs/vwidgets/vsimplecurve.cpp index 9c2138a6e..86bbeb2f8 100644 --- a/src/libs/vwidgets/vsimplecurve.cpp +++ b/src/libs/vwidgets/vsimplecurve.cpp @@ -116,7 +116,7 @@ void VSimpleCurve::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (selectionType == SelectionType::ByMouseRelease) { - if (event->button() == Qt::LeftButton) + if (event->button() == Qt::LeftButton && contains(event->pos())) { emit Choosed(id); } diff --git a/src/libs/vwidgets/vsimplepoint.cpp b/src/libs/vwidgets/vsimplepoint.cpp index ce0b28b66..72b9ed871 100644 --- a/src/libs/vwidgets/vsimplepoint.cpp +++ b/src/libs/vwidgets/vsimplepoint.cpp @@ -177,7 +177,7 @@ void VSimplePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (selectionType == SelectionType::ByMouseRelease) { - if (event->button() == Qt::LeftButton) + if (event->button() == Qt::LeftButton && contains(event->pos())) { emit Choosed(id); } diff --git a/src/libs/vwidgets/vtextgraphicsitem.cpp b/src/libs/vwidgets/vtextgraphicsitem.cpp index 67d4ad222..cb2ae0d79 100644 --- a/src/libs/vwidgets/vtextgraphicsitem.cpp +++ b/src/libs/vwidgets/vtextgraphicsitem.cpp @@ -375,7 +375,8 @@ int VTextGraphicsItem::GetFontSize() const */ void VTextGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *pME) { - if (pME->button() == Qt::LeftButton && pME->type() != QEvent::GraphicsSceneMouseDoubleClick) + if (pME->button() == Qt::LeftButton && pME->type() != QEvent::GraphicsSceneMouseDoubleClick + && (flags() & QGraphicsItem::ItemIsMovable)) { if (m_moveType == NotMovable) { @@ -455,6 +456,10 @@ void VTextGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *pME) pME->ignore(); } } + else + { + pME->ignore(); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -552,7 +557,7 @@ void VTextGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME) if (pME->button() == Qt::LeftButton) { // restore the cursor - if (m_eMode == mMove || m_eMode == mRotate || m_eMode == mResize) + if ((m_eMode == mMove || m_eMode == mRotate || m_eMode == mResize) && (flags() & QGraphicsItem::ItemIsMovable)) { SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); } @@ -620,6 +625,16 @@ void VTextGraphicsItem::hoverMoveEvent(QGraphicsSceneHoverEvent* pHE) VPieceItem::hoverMoveEvent(pHE); } +//--------------------------------------------------------------------------------------------------------------------- +void VTextGraphicsItem::hoverEnterEvent(QGraphicsSceneHoverEvent *pME) +{ + if (flags() & QGraphicsItem::ItemIsMovable) + { + SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); + } + VPieceItem::hoverEnterEvent(pME); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief VTextGraphicsItem::hoverLeaveEvent tries to restore normal mouse cursor @@ -627,7 +642,10 @@ void VTextGraphicsItem::hoverMoveEvent(QGraphicsSceneHoverEvent* pHE) */ void VTextGraphicsItem::hoverLeaveEvent(QGraphicsSceneHoverEvent* pHE) { - setCursor(QCursor()); + if (flags() & QGraphicsItem::ItemIsMovable) + { + setCursor(QCursor()); + } VPieceItem::hoverLeaveEvent(pHE); } diff --git a/src/libs/vwidgets/vtextgraphicsitem.h b/src/libs/vwidgets/vtextgraphicsitem.h index 2021e1381..db32717bb 100644 --- a/src/libs/vwidgets/vtextgraphicsitem.h +++ b/src/libs/vwidgets/vtextgraphicsitem.h @@ -73,6 +73,7 @@ protected: virtual void mousePressEvent(QGraphicsSceneMouseEvent* pME) Q_DECL_OVERRIDE; virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* pME) Q_DECL_OVERRIDE; virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* pME) Q_DECL_OVERRIDE; + virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *pME) Q_DECL_OVERRIDE; virtual void hoverMoveEvent(QGraphicsSceneHoverEvent* pHE) Q_DECL_OVERRIDE; virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* pHE) Q_DECL_OVERRIDE;