Fixed issue #217. Bug with mouse cursor.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-02-09 11:54:19 +02:00
parent 2885abb5a1
commit c2191dd8d0
10 changed files with 54 additions and 49 deletions

View File

@ -92,6 +92,7 @@ MainWindow::MainWindow(QWidget *parent)
sceneDraw = new VMainGraphicsScene();
currentScene = sceneDraw;
qApp->setCurrentScene(currentScene);
connect(this, &MainWindow::EnableItemMove, sceneDraw, &VMainGraphicsScene::EnableItemMove);
connect(sceneDraw, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove);
sceneDetails = new VMainGraphicsScene();
connect(sceneDetails, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove);
@ -244,7 +245,9 @@ void MainWindow::ActionNewPP()
sceneDraw->addItem(spoint);
ui->view->itemClicked(spoint);
connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem);
connect(sceneDraw, &VMainGraphicsScene::DisableItem, spoint, &VToolSinglePoint::Disable);
connect(sceneDraw, &VMainGraphicsScene::NewFactor, spoint, &VToolSinglePoint::SetFactor);
connect(sceneDraw, &VMainGraphicsScene::EnableToolMove, spoint, &VToolSinglePoint::EnableToolMove);
QHash<quint32, VDataTool*>* tools = doc->getTools();
SCASSERT(tools != nullptr);
tools->insert(id, spoint);
@ -1046,114 +1049,75 @@ void MainWindow::CancelTool()
ui->actionArrowTool->setChecked(false);
helpLabel->setText("");
ui->actionStopTool->setEnabled(true);
break;
emit EnableItemMove(false);
return;
case Tool::SinglePoint:
Q_UNREACHABLE();
//Nothing to do here because we can't create this tool from main window.
break;
case Tool::EndLine:
ui->toolButtonEndLine->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::Line:
ui->toolButtonLine->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearFocus();
break;
case Tool::AlongLine:
ui->toolButtonAlongLine->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::ShoulderPoint:
ui->toolButtonShoulderPoint->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::Normal:
ui->toolButtonNormal->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::Bisector:
ui->toolButtonBisector->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::LineIntersect:
ui->toolButtonLineIntersect->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::Spline:
ui->toolButtonSpline->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::Arc:
ui->toolButtonArc->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::SplinePath:
ui->toolButtonSplinePath->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::PointOfContact:
ui->toolButtonPointOfContact->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::Detail:
ui->toolButtonNewDetail->setChecked(false);
break;
case Tool::Height:
ui->toolButtonHeight->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::Triangle:
ui->toolButtonTriangle->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::PointOfIntersection:
ui->toolButtonPointOfIntersection->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::CutSpline:
ui->toolButtonSplineCutPoint->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::CutSplinePath:
ui->toolButtonSplinePathCutPoint->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::UnionDetails:
ui->toolButtonUnionDetails->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::CutArc:
ui->toolButtonArcCutPoint->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::LineIntersectAxis:
ui->toolButtonLineIntersectAxis->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::CurveIntersectAxis:
ui->toolButtonCurveIntersectAxis->setChecked(false);
ui->toolButtonArcIntersectAxis->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::NodePoint:
case Tool::NodeArc:
@ -1163,6 +1127,9 @@ void MainWindow::CancelTool()
qDebug()<<"Got wrong tool type. Ignored.";
break;
}
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
emit EnableItemMove(true);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -139,6 +139,7 @@ signals:
void ModelChosen(QVector<VLayoutDetail> listDetails, const QString &curFile,
const QString &description);
void RefreshHistory();
void EnableItemMove(bool move);
protected:
virtual void keyPressEvent(QKeyEvent *event);
virtual void showEvent(QShowEvent *event);

View File

@ -206,6 +206,13 @@ void VDrawTool::SetFactor(qreal factor)
VApplication::CheckFactor(this->factor, factor);
}
//---------------------------------------------------------------------------------------------------------------------
void VDrawTool::EnableToolMove(bool move)
{
Q_UNUSED(move)
// Do nothing.
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief CheckFormula check formula.

View File

@ -69,6 +69,7 @@ public slots:
virtual void FullUpdateFromGuiOk(int result);
virtual void FullUpdateFromGuiApply();
virtual void SetFactor(qreal factor);
virtual void EnableToolMove(bool move);
protected:
/** @brief ignoreFullUpdate ignore or not full updates. */

View File

@ -216,6 +216,7 @@ void VToolPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(CorrectColor(baseColor), qApp->toPixel(qApp->widthHairLine())/factor));
QGraphicsEllipseItem::hoverLeaveEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -205,36 +205,48 @@ void VToolSinglePoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
VToolPoint::hoverEnterEvent(event);
if (flags() & QGraphicsItem::ItemIsMovable)
{
VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png"), 1, 1);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
VToolPoint::hoverLeaveEvent(event);
if (flags() & QGraphicsItem::ItemIsMovable)
{
//Disable cursor-arrow-openhand
VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png"));
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (flags() & QGraphicsItem::ItemIsMovable)
{
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png"), 1, 1);
}
}
VToolPoint::mousePressEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (flags() & QGraphicsItem::ItemIsMovable)
{
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
//Disable cursor-arrow-closehand
VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png"));
}
}
VToolPoint::mouseReleaseEvent(event);
}
@ -332,3 +344,9 @@ void VToolSinglePoint::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
ContextMenu<DialogSinglePoint>(this, event, false);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::EnableToolMove(bool move)
{
this->setFlag(QGraphicsItem::ItemIsMovable, move);
}

View File

@ -50,6 +50,7 @@ public slots:
virtual void FullUpdateFromFile();
virtual void SetFactor(qreal factor);
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
virtual void EnableToolMove(bool move);
signals:
/**
* @brief FullUpdateTree handle if need update pattern file.

View File

@ -126,3 +126,9 @@ void VMainGraphicsScene::SetFactor(qreal factor)
scaleFactor=scaleFactor*factor;
emit NewFactor(scaleFactor);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::EnableItemMove(bool move)
{
emit EnableToolMove(move);
}

View File

@ -52,6 +52,7 @@ public:
public slots:
void ChoosedItem(quint32 id, const SceneObject &type);
void SetFactor(qreal factor);
void EnableItemMove(bool move);
protected:
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
@ -78,6 +79,7 @@ signals:
*/
void NewFactor(qreal factor);
void DisableItem(bool disable);
void EnableToolMove(bool move);
private:
/** @brief horScrollBar value horizontal scroll bar. */
qint32 horScrollBar;

View File

@ -1163,6 +1163,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
connect(spoint, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, spoint, &VToolSinglePoint::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, spoint, &VToolSinglePoint::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, spoint, &VToolSinglePoint::EnableToolMove);
tools[id] = spoint;
}
}