Set (restore) cursor only if not active (active).
--HG-- branch : develop
This commit is contained in:
parent
cfeaf2ffa0
commit
fc92e0b4a4
|
@ -202,10 +202,7 @@ void VToolSinglePoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
|||
{
|
||||
VToolPoint::hoverEnterEvent(event);
|
||||
|
||||
#ifndef QT_NO_CURSOR
|
||||
QPixmap pixmap(QLatin1String("://cursor/cursor-arrow-openhand.png"));
|
||||
QApplication::setOverrideCursor(QCursor(pixmap, 1, 1));
|
||||
#endif
|
||||
VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png"), 1, 1);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -214,9 +211,7 @@ void VToolSinglePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||
VToolPoint::hoverLeaveEvent(event);
|
||||
|
||||
//Disable cursor-arrow-openhand
|
||||
#ifndef QT_NO_CURSOR
|
||||
QApplication::restoreOverrideCursor();
|
||||
#endif
|
||||
VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png"), 1, 1);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -224,10 +219,7 @@ void VToolSinglePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||
{
|
||||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||
{
|
||||
#ifndef QT_NO_CURSOR
|
||||
QPixmap pixmap(QLatin1String("://cursor/cursor-arrow-closehand.png"));
|
||||
QApplication::setOverrideCursor(QCursor(pixmap, 1, 1));
|
||||
#endif
|
||||
VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png"), 1, 1);
|
||||
}
|
||||
VToolPoint::mousePressEvent(event);
|
||||
}
|
||||
|
@ -238,9 +230,7 @@ void VToolSinglePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||
{
|
||||
//Disable cursor-arrow-closehand
|
||||
#ifndef QT_NO_CURSOR
|
||||
QApplication::restoreOverrideCursor();
|
||||
#endif
|
||||
VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png"), 1, 1);
|
||||
}
|
||||
VToolPoint::mouseReleaseEvent(event);
|
||||
}
|
||||
|
|
|
@ -88,10 +88,7 @@ void VControlPointSpline::paint(QPainter *painter, const QStyleOptionGraphicsIte
|
|||
void VControlPointSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine())));
|
||||
#ifndef QT_NO_CURSOR
|
||||
QPixmap pixmap(QLatin1String("://cursor/cursor-arrow-openhand.png"));
|
||||
QApplication::setOverrideCursor(QCursor(pixmap, 1, 1));
|
||||
#endif
|
||||
VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png"), 1, 1);
|
||||
QGraphicsEllipseItem::hoverEnterEvent(event);
|
||||
}
|
||||
|
||||
|
@ -100,9 +97,7 @@ void VControlPointSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||
{
|
||||
this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())));
|
||||
//Disable cursor-arrow-openhand
|
||||
#ifndef QT_NO_CURSOR
|
||||
QApplication::restoreOverrideCursor();
|
||||
#endif
|
||||
VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png"), 1, 1);
|
||||
QGraphicsEllipseItem::hoverLeaveEvent(event);
|
||||
}
|
||||
|
||||
|
@ -129,10 +124,7 @@ void VControlPointSpline::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||
{
|
||||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||
{
|
||||
#ifndef QT_NO_CURSOR
|
||||
QPixmap pixmap(QLatin1String("://cursor/cursor-arrow-closehand.png"));
|
||||
QApplication::setOverrideCursor(QCursor(pixmap, 1, 1));
|
||||
#endif
|
||||
VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png"), 1, 1);
|
||||
}
|
||||
QGraphicsEllipseItem::mousePressEvent(event);
|
||||
}
|
||||
|
@ -143,9 +135,7 @@ void VControlPointSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||
{
|
||||
//Disable cursor-arrow-closehand
|
||||
#ifndef QT_NO_CURSOR
|
||||
QApplication::restoreOverrideCursor();
|
||||
#endif
|
||||
VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png"), 1, 1);
|
||||
}
|
||||
QGraphicsEllipseItem::mouseReleaseEvent(event);
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include <QStyleOptionGraphicsItem>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
|
||||
#include "../widgets/vapplication.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VGraphicsSimpleTextItem default constructor.
|
||||
|
@ -105,10 +107,7 @@ void VGraphicsSimpleTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
|||
{
|
||||
this->setBrush(Qt::green);
|
||||
|
||||
#ifndef QT_NO_CURSOR
|
||||
QPixmap pixmap(QLatin1String("://cursor/cursor-arrow-openhand.png"));
|
||||
QApplication::setOverrideCursor(QCursor(pixmap, 1, 1));
|
||||
#endif
|
||||
VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png"), 1, 1);
|
||||
QGraphicsSimpleTextItem::hoverEnterEvent(event);
|
||||
}
|
||||
|
||||
|
@ -123,9 +122,7 @@ void VGraphicsSimpleTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||
this->setBrush(Qt::black);
|
||||
|
||||
//Disable cursor-arrow-openhand
|
||||
#ifndef QT_NO_CURSOR
|
||||
QApplication::restoreOverrideCursor();
|
||||
#endif
|
||||
VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png"), 1, 1);
|
||||
QGraphicsSimpleTextItem::hoverLeaveEvent(event);
|
||||
}
|
||||
|
||||
|
@ -144,10 +141,7 @@ void VGraphicsSimpleTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||
{
|
||||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||
{
|
||||
#ifndef QT_NO_CURSOR
|
||||
QPixmap pixmap(QLatin1String("://cursor/cursor-arrow-closehand.png"));
|
||||
QApplication::setOverrideCursor(QCursor(pixmap, 1, 1));
|
||||
#endif
|
||||
VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png"), 1, 1);
|
||||
}
|
||||
QGraphicsSimpleTextItem::mousePressEvent(event);
|
||||
}
|
||||
|
@ -158,9 +152,7 @@ void VGraphicsSimpleTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||
{
|
||||
//Disable cursor-arrow-closehand
|
||||
#ifndef QT_NO_CURSOR
|
||||
QApplication::restoreOverrideCursor();
|
||||
#endif
|
||||
VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png"), 1, 1);
|
||||
}
|
||||
QGraphicsSimpleTextItem::mouseReleaseEvent(event);
|
||||
}
|
||||
|
|
|
@ -2029,3 +2029,45 @@ void VApplication::setCurrentScene(VMainGraphicsScene *value)
|
|||
{
|
||||
currentScene = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VApplication::setOverrideCursor(const QString &pixmapPath, int hotX, int hotY)
|
||||
{
|
||||
#ifndef QT_NO_CURSOR
|
||||
QPixmap oldPixmap;
|
||||
if (QCursor *oldCursor = QGuiApplication::overrideCursor())
|
||||
{
|
||||
oldPixmap = oldCursor->pixmap();
|
||||
}
|
||||
QPixmap newPixmap(pixmapPath);
|
||||
|
||||
QImage oldImage = oldPixmap.toImage();
|
||||
QImage newImage = newPixmap.toImage();
|
||||
|
||||
if (oldImage != newImage )
|
||||
{
|
||||
QApplication::setOverrideCursor(QCursor(newPixmap, hotX, hotY));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VApplication::restoreOverrideCursor(const QString &pixmapPath, int hotX, int hotY)
|
||||
{
|
||||
#ifndef QT_NO_CURSOR
|
||||
QPixmap oldPixmap;
|
||||
if (QCursor *oldCursor = QGuiApplication::overrideCursor())
|
||||
{
|
||||
oldPixmap = oldCursor->pixmap();
|
||||
}
|
||||
QPixmap newPixmap(pixmapPath);
|
||||
|
||||
QImage oldImage = oldPixmap.toImage();
|
||||
QImage newImage = newPixmap.toImage();
|
||||
|
||||
if (oldImage == newImage )
|
||||
{
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -95,6 +95,9 @@ public:
|
|||
|
||||
void setCurrentDocument(VPattern *doc);
|
||||
VPattern *getCurrentDocument()const;
|
||||
|
||||
static void setOverrideCursor(const QString & pixmapPath, int hotX = -1, int hotY = -1);
|
||||
static void restoreOverrideCursor(const QString & pixmapPath, int hotX = -1, int hotY = -1);
|
||||
private:
|
||||
Q_DISABLE_COPY(VApplication)
|
||||
Unit _patternUnit;
|
||||
|
|
Loading…
Reference in New Issue
Block a user