Show "move cursor".

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-02-12 13:43:38 +02:00
parent 254d9b7b7a
commit d5eded4eda
3 changed files with 56 additions and 6 deletions

View File

@ -300,6 +300,7 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons
if (checked)
{
CancelTool();
emit EnableItemMove(true);
tool = t;
QPixmap pixmap(cursor);
QCursor cur(pixmap, 2, 3);
@ -340,6 +341,7 @@ void MainWindow::SetToolButtonWithApply(bool checked, Tool t, const QString &cur
if (checked)
{
CancelTool();
emit EnableItemMove(false);
tool = t;
QPixmap pixmap(cursor);
QCursor cur(pixmap, 2, 3);
@ -1050,7 +1052,6 @@ void MainWindow::CancelTool()
ui->actionArrowTool->setChecked(false);
helpLabel->setText("");
ui->actionStopTool->setEnabled(true);
emit EnableItemMove(false);
return;
case Tool::SinglePoint:
Q_UNREACHABLE();
@ -1130,7 +1131,6 @@ void MainWindow::CancelTool()
}
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
emit EnableItemMove(true);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -55,7 +55,6 @@ VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const QStr
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
this->setFlag(QGraphicsItem::ItemIsMovable, true);
//this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
this->setAcceptHoverEvents(true);
this->setPath(ToolPath());
@ -193,6 +192,7 @@ VToolSpline* VToolSpline::Create(const quint32 _id, const quint32 &p1, const qui
connect(spl, &VToolSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSpline::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, spl, &VToolSpline::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, spl, &VToolSpline::EnableToolMove);
doc->AddTool(id, spl);
doc->IncrementReferens(p1);
doc->IncrementReferens(p4);
@ -283,6 +283,12 @@ void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const Sp
qApp->getUndoStack()->push(moveSpl);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSpline::EnableToolMove(bool move)
{
this->setFlag(QGraphicsItem::ItemIsMovable, move);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.
@ -361,14 +367,32 @@ void VToolSpline::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
//---------------------------------------------------------------------------------------------------------------------
void VToolSpline::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
if (flags() & QGraphicsItem::ItemIsMovable)
{
oldPosition = event->scenePos();
event->accept();
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png"), 1, 1);
oldPosition = event->scenePos();
event->accept();
}
}
VAbstractSpline::mousePressEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSpline::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"));
}
}
VAbstractSpline::mouseReleaseEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSpline::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
@ -420,7 +444,29 @@ void VToolSpline::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
MoveSpline *moveSpl = new MoveSpline(doc, spline.data(), spl, id, this->scene());
connect(moveSpl, &MoveSpline::NeedLiteParsing, doc, &VPattern::LiteParseTree);
qApp->getUndoStack()->push(moveSpl);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
if (flags() & QGraphicsItem::ItemIsMovable)
{
VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png"), 1, 1);
}
VAbstractSpline::hoverEnterEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
if (flags() & QGraphicsItem::ItemIsMovable)
{
//Disable cursor-arrow-openhand
VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png"));
}
VAbstractSpline::hoverLeaveEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -58,13 +58,17 @@ public:
public slots:
void ControlPointChangePosition (const qint32 &indexSpline, const SplinePointPosition &position,
const QPointF &pos);
virtual void EnableToolMove(bool move);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void mousePressEvent(QGraphicsSceneMouseEvent * event);
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * event);
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
private:
Q_DISABLE_COPY(VToolSpline)
void RefreshGeometry ();