Improve working with mouse cursors. Instead of setting global value set cursor
for each item separately. --HG-- branch : develop
This commit is contained in:
parent
145a0923cb
commit
0894f686ef
|
@ -2199,10 +2199,7 @@ void MainWindow::ArrowTool()
|
|||
|
||||
ui->view->AllowRubberBand(true);
|
||||
|
||||
RestoreOverrideCursor(cursorArrowCloseHand);
|
||||
RestoreOverrideCursor(cursorArrowOpenHand);
|
||||
QCursor cur(Qt::ArrowCursor);
|
||||
ui->view->setCursor(cur);
|
||||
ui->view->setCursor(Qt::ArrowCursor);
|
||||
helpLabel->setText("");
|
||||
ui->view->setShowToolOptions(true);
|
||||
qCDebug(vMainWindow, "Enabled arrow tool.");
|
||||
|
|
|
@ -51,6 +51,8 @@
|
|||
#include <QStringData>
|
||||
#include <QStringDataPtr>
|
||||
#include <QtDebug>
|
||||
#include <QPixmapCache>
|
||||
#include <QGraphicsItem>
|
||||
|
||||
#include "vabstractapplication.h"
|
||||
|
||||
|
@ -125,97 +127,28 @@ const QString unitINCH = QStringLiteral("inch");
|
|||
const QString unitPX = QStringLiteral("px");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void SetOverrideCursor(const QString &pixmapPath, int hotX, int hotY)
|
||||
void SetItemOverrideCursor(QGraphicsItem *item, const QString &pixmapPath, int hotX, int hotY)
|
||||
{
|
||||
#ifndef QT_NO_CURSOR
|
||||
QPixmap oldPixmap;
|
||||
if (QCursor *oldCursor = QGuiApplication::overrideCursor())
|
||||
{
|
||||
oldPixmap = oldCursor->pixmap();
|
||||
}
|
||||
QPixmap newPixmap(pixmapPath);
|
||||
SCASSERT(item != nullptr)
|
||||
|
||||
QImage oldImage = oldPixmap.toImage();
|
||||
QImage newImage = newPixmap.toImage();
|
||||
QPixmap pixmap;
|
||||
|
||||
if (oldImage != newImage )
|
||||
if (not QPixmapCache::find(pixmapPath, pixmap))
|
||||
{
|
||||
QGuiApplication::setOverrideCursor(QCursor(newPixmap, hotX, hotY));
|
||||
pixmap = QPixmap(pixmapPath);
|
||||
QPixmapCache::insert(pixmapPath, pixmap);
|
||||
}
|
||||
|
||||
item->setCursor(QCursor(pixmap, hotX, hotY));
|
||||
#else
|
||||
Q_UNUSED(item)
|
||||
Q_UNUSED(pixmapPath)
|
||||
Q_UNUSED(hotX)
|
||||
Q_UNUSED(hotY)
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void SetOverrideCursor(Qt::CursorShape shape)
|
||||
{
|
||||
#ifndef QT_NO_CURSOR
|
||||
QPixmap oldPixmap;
|
||||
QCursor* pOldCursor = QGuiApplication::overrideCursor();
|
||||
if (pOldCursor != nullptr)
|
||||
{
|
||||
oldPixmap = pOldCursor->pixmap();
|
||||
}
|
||||
QCursor cursor(shape);
|
||||
QPixmap newPixmap = cursor.pixmap();
|
||||
if (oldPixmap.toImage() != newPixmap.toImage())
|
||||
{
|
||||
QGuiApplication::setOverrideCursor(cursor);
|
||||
}
|
||||
|
||||
#else
|
||||
Q_UNUSED(shape)
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void RestoreOverrideCursor(const QString &pixmapPath)
|
||||
{
|
||||
#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 )
|
||||
{
|
||||
QGuiApplication::restoreOverrideCursor();
|
||||
}
|
||||
#else
|
||||
Q_UNUSED(pixmapPath)
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void RestoreOverrideCursor(Qt::CursorShape shape)
|
||||
{
|
||||
#ifndef QT_NO_CURSOR
|
||||
QPixmap oldPixmap;
|
||||
QCursor* pOldCursor = QGuiApplication::overrideCursor();
|
||||
if (pOldCursor != nullptr)
|
||||
{
|
||||
oldPixmap = pOldCursor->pixmap();
|
||||
}
|
||||
QCursor cursor(shape);
|
||||
QPixmap newPixmap = cursor.pixmap();
|
||||
if (oldPixmap.toImage() == newPixmap.toImage())
|
||||
{
|
||||
QGuiApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
#else
|
||||
Q_UNUSED(shape)
|
||||
#endif
|
||||
}
|
||||
|
||||
const qreal PrintDPI = 96.0;
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -51,6 +51,7 @@ template <class T> class QSharedPointer;
|
|||
class QComboBox;
|
||||
class QMarginsF;
|
||||
class VTranslateMeasurements;
|
||||
class QGraphicsItem;
|
||||
|
||||
#define SceneSize 50000
|
||||
|
||||
|
@ -373,10 +374,7 @@ extern const QString unitCM;
|
|||
extern const QString unitINCH;
|
||||
extern const QString unitPX;
|
||||
|
||||
void SetOverrideCursor(const QString & pixmapPath, int hotX = -1, int hotY = -1);
|
||||
void SetOverrideCursor(Qt::CursorShape shape);
|
||||
void RestoreOverrideCursor(const QString & pixmapPath);
|
||||
void RestoreOverrideCursor(Qt::CursorShape shape);
|
||||
void SetItemOverrideCursor(QGraphicsItem *item, const QString & pixmapPath, int hotX = -1, int hotY = -1);
|
||||
|
||||
extern const qreal PrintDPI;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
# File with common stuff for whole project
|
||||
include(../../../common.pri)
|
||||
|
||||
QT += widgets printsupport testlib
|
||||
QT += widgets printsupport testlib gui
|
||||
|
||||
# Name of library
|
||||
TARGET = vmisc
|
||||
|
|
|
@ -122,13 +122,6 @@ VToolSpline::VToolSpline(VAbstractPattern *doc, VContainer *data, quint32 id, co
|
|||
ToolCreation(typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolSpline::~VToolSpline()
|
||||
{
|
||||
//Disable cursor-arrow-openhand
|
||||
RestoreOverrideCursor(cursorArrowOpenHand);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief setDialog set dialog when user want change tool option.
|
||||
|
@ -367,7 +360,7 @@ void VToolSpline::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||
{
|
||||
if (IsMovable())
|
||||
{
|
||||
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
|
||||
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
|
||||
oldPosition = event->scenePos();
|
||||
event->accept();
|
||||
}
|
||||
|
@ -385,8 +378,7 @@ void VToolSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
{
|
||||
if (IsMovable())
|
||||
{
|
||||
//Disable cursor-arrow-closehand
|
||||
RestoreOverrideCursor(cursorArrowCloseHand);
|
||||
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -477,7 +469,7 @@ void VToolSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
|||
{
|
||||
if (IsMovable())
|
||||
{
|
||||
SetOverrideCursor(cursorArrowOpenHand, 1, 1);
|
||||
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -491,8 +483,7 @@ void VToolSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||
{
|
||||
if (IsMovable())
|
||||
{
|
||||
//Disable cursor-arrow-openhand
|
||||
RestoreOverrideCursor(cursorArrowOpenHand);
|
||||
setCursor(QCursor());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ class VToolSpline:public VAbstractSpline
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
virtual ~VToolSpline() Q_DECL_OVERRIDE;
|
||||
virtual ~VToolSpline() =default;
|
||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolSpline *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data);
|
||||
|
|
|
@ -131,13 +131,6 @@ VToolSplinePath::VToolSplinePath(VAbstractPattern *doc, VContainer *data, quint3
|
|||
ToolCreation(typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolSplinePath::~VToolSplinePath()
|
||||
{
|
||||
//Disable cursor-arrow-openhand
|
||||
RestoreOverrideCursor(cursorArrowOpenHand);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief setDialog set dialog when user want change tool option.
|
||||
|
@ -491,7 +484,7 @@ void VToolSplinePath::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||
splIndex = splPath->Segment(oldPosition);
|
||||
if (IsMovable(splIndex))
|
||||
{
|
||||
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
|
||||
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
@ -507,8 +500,7 @@ void VToolSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||
{
|
||||
oldPosition = event->scenePos();
|
||||
//Disable cursor-arrow-closehand
|
||||
RestoreOverrideCursor(cursorArrowCloseHand);
|
||||
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
|
||||
}
|
||||
}
|
||||
VAbstractSpline::mouseReleaseEvent(event);
|
||||
|
@ -606,7 +598,7 @@ void VToolSplinePath::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
|||
splIndex = splPath->Segment(oldPosition);
|
||||
if (IsMovable(splIndex))
|
||||
{
|
||||
SetOverrideCursor(cursorArrowOpenHand, 1, 1);
|
||||
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -619,8 +611,7 @@ void VToolSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||
if (flags() & QGraphicsItem::ItemIsMovable)
|
||||
{
|
||||
oldPosition = event->scenePos();
|
||||
//Disable cursor-arrow-openhand
|
||||
RestoreOverrideCursor(cursorArrowOpenHand);
|
||||
setCursor(QCursor());
|
||||
}
|
||||
|
||||
VAbstractSpline::hoverLeaveEvent(event);
|
||||
|
|
|
@ -53,7 +53,7 @@ class VToolSplinePath:public VAbstractSpline
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
virtual ~VToolSplinePath() Q_DECL_OVERRIDE;
|
||||
virtual ~VToolSplinePath() =default;
|
||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolSplinePath *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data);
|
||||
|
|
|
@ -90,13 +90,6 @@ VToolBasePoint::VToolBasePoint (VAbstractPattern *doc, VContainer *data, quint32
|
|||
ToolCreation(typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolBasePoint::~VToolBasePoint()
|
||||
{
|
||||
//Disable cursor-arrow-openhand
|
||||
RestoreOverrideCursor(cursorArrowOpenHand);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief setDialog set dialog when user want change tool option.
|
||||
|
@ -316,7 +309,7 @@ void VToolBasePoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
|||
|
||||
if (flags() & QGraphicsItem::ItemIsMovable)
|
||||
{
|
||||
SetOverrideCursor(cursorArrowOpenHand, 1, 1);
|
||||
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -327,8 +320,7 @@ void VToolBasePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||
|
||||
if (flags() & QGraphicsItem::ItemIsMovable)
|
||||
{
|
||||
//Disable cursor-arrow-openhand
|
||||
RestoreOverrideCursor(cursorArrowOpenHand);
|
||||
setCursor(QCursor());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -339,7 +331,7 @@ void VToolBasePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||
{
|
||||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||
{
|
||||
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
|
||||
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
|
||||
}
|
||||
}
|
||||
VToolSinglePoint::mousePressEvent(event);
|
||||
|
@ -352,8 +344,7 @@ void VToolBasePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
{
|
||||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||
{
|
||||
//Disable cursor-arrow-closehand
|
||||
RestoreOverrideCursor(cursorArrowCloseHand);
|
||||
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
|
||||
}
|
||||
}
|
||||
VToolSinglePoint::mouseReleaseEvent(event);
|
||||
|
|
|
@ -53,7 +53,7 @@ class VToolBasePoint : public VToolSinglePoint
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
virtual ~VToolBasePoint() Q_DECL_OVERRIDE;
|
||||
virtual ~VToolBasePoint() =default;
|
||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolBasePoint *Create(quint32 _id, const QString &nameActivPP, VPointF *point,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
|
|
|
@ -975,7 +975,7 @@ void VToolSeamAllowance::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||
{
|
||||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||
{
|
||||
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
|
||||
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -993,28 +993,17 @@ void VToolSeamAllowance::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
{
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
//Disable cursor-arrow-closehand
|
||||
RestoreOverrideCursor(cursorArrowCloseHand);
|
||||
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
|
||||
}
|
||||
QGraphicsPathItem::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolSeamAllowance::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
if (flags() & QGraphicsItem::ItemIsMovable)
|
||||
{
|
||||
SetOverrideCursor(cursorArrowOpenHand, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolSeamAllowance::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
if (flags() & QGraphicsItem::ItemIsMovable)
|
||||
{
|
||||
SetOverrideCursor(cursorArrowOpenHand, 1, 1);
|
||||
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
|
||||
}
|
||||
QGraphicsPathItem::hoverEnterEvent(event);
|
||||
}
|
||||
|
@ -1025,7 +1014,7 @@ void VToolSeamAllowance::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||
//Disable cursor-arrow-openhand
|
||||
if (flags() & QGraphicsItem::ItemIsMovable)
|
||||
{
|
||||
RestoreOverrideCursor(cursorArrowOpenHand);
|
||||
setCursor(QCursor());
|
||||
}
|
||||
QGraphicsPathItem::hoverLeaveEvent(event);
|
||||
}
|
||||
|
|
|
@ -126,7 +126,6 @@ protected:
|
|||
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE;
|
||||
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event) Q_DECL_OVERRIDE;
|
||||
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void hoverMoveEvent( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
|
|
|
@ -91,13 +91,6 @@ VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointP
|
|||
SetCtrlLine(controlPoint, splinePoint);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VControlPointSpline::~VControlPointSpline()
|
||||
{
|
||||
//Disable cursor-arrow-openhand
|
||||
RestoreOverrideCursor(cursorArrowOpenHand);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VControlPointSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
|
@ -117,7 +110,7 @@ void VControlPointSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
|||
{
|
||||
if (freeAngle || freeLength)
|
||||
{
|
||||
SetOverrideCursor(cursorArrowOpenHand, 1, 1);
|
||||
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
|
||||
}
|
||||
VScenePoint::hoverEnterEvent(event);
|
||||
}
|
||||
|
@ -127,8 +120,7 @@ void VControlPointSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||
{
|
||||
if (freeAngle || freeLength)
|
||||
{
|
||||
//Disable cursor-arrow-openhand
|
||||
RestoreOverrideCursor(cursorArrowOpenHand);
|
||||
setCursor(QCursor());
|
||||
}
|
||||
VScenePoint::hoverLeaveEvent(event);
|
||||
}
|
||||
|
@ -226,7 +218,7 @@ void VControlPointSpline::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||
{
|
||||
if (freeAngle || freeLength)
|
||||
{
|
||||
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
|
||||
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
|
||||
}
|
||||
}
|
||||
VScenePoint::mousePressEvent(event);
|
||||
|
@ -239,8 +231,7 @@ void VControlPointSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
{
|
||||
if (freeAngle || freeLength)
|
||||
{
|
||||
//Disable cursor-arrow-closehand
|
||||
RestoreOverrideCursor(cursorArrowCloseHand);
|
||||
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
|
||||
}
|
||||
}
|
||||
VScenePoint::mouseReleaseEvent(event);
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position, QGraphicsItem * parent = nullptr);
|
||||
VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position, const QPointF &controlPoint,
|
||||
const QPointF &splinePoint, bool freeAngle, bool freeLength, QGraphicsItem * parent = nullptr);
|
||||
virtual ~VControlPointSpline();
|
||||
virtual ~VControlPointSpline() =default;
|
||||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ControlPointSpline)};
|
||||
|
|
|
@ -305,7 +305,7 @@ void VGrainlineItem::mousePressEvent(QGraphicsSceneMouseEvent* pME)
|
|||
else
|
||||
{
|
||||
m_eMode = mRotate;
|
||||
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
|
||||
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
|
||||
}
|
||||
setZValue(ACTIVE_Z);
|
||||
Update();
|
||||
|
@ -336,7 +336,7 @@ void VGrainlineItem::mousePressEvent(QGraphicsSceneMouseEvent* pME)
|
|||
else
|
||||
{
|
||||
m_eMode = mMove;
|
||||
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
|
||||
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
|
||||
}
|
||||
|
||||
setZValue(ACTIVE_Z);
|
||||
|
@ -458,13 +458,9 @@ void VGrainlineItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME)
|
|||
{
|
||||
if (pME->button() == Qt::LeftButton)
|
||||
{
|
||||
if (m_eMode == mMove || m_eMode == mRotate)
|
||||
if (m_eMode == mMove || m_eMode == mRotate || m_eMode == mResize)
|
||||
{
|
||||
RestoreOverrideCursor(cursorArrowCloseHand);
|
||||
}
|
||||
else if (m_eMode == mResize)
|
||||
{
|
||||
RestoreOverrideCursor(Qt::SizeFDiagCursor);
|
||||
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
|
||||
}
|
||||
|
||||
QPointF ptDiff = pME->scenePos() - m_ptStartMove;
|
||||
|
@ -709,7 +705,7 @@ void VGrainlineItem::AllUserModifications(const QPointF &pos)
|
|||
}
|
||||
else
|
||||
{
|
||||
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
|
||||
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -720,7 +716,7 @@ void VGrainlineItem::UserRotateAndMove()
|
|||
{
|
||||
m_eMode = mMove;
|
||||
}
|
||||
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
|
||||
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -729,12 +725,12 @@ void VGrainlineItem::UserMoveAndResize(const QPointF &pos)
|
|||
if (m_polyResize.containsPoint(pos, Qt::OddEvenFill) == true)
|
||||
{
|
||||
m_eMode = mResize;
|
||||
SetOverrideCursor(Qt::SizeFDiagCursor);
|
||||
setCursor(Qt::SizeFDiagCursor);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_eMode = mMove; // block later if need
|
||||
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
|
||||
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,13 +81,6 @@ VGraphicsSimpleTextItem::VGraphicsSimpleTextItem( const QString & text, QGraphic
|
|||
this->setAcceptHoverEvents(true);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VGraphicsSimpleTextItem::~VGraphicsSimpleTextItem()
|
||||
{
|
||||
//Disable cursor-arrow-openhand
|
||||
RestoreOverrideCursor(cursorArrowOpenHand);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
|
@ -194,7 +187,7 @@ void VGraphicsSimpleTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
|||
{
|
||||
if (flags() & QGraphicsItem::ItemIsMovable)
|
||||
{
|
||||
SetOverrideCursor(cursorArrowOpenHand, 1, 1);
|
||||
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
|
||||
}
|
||||
this->setBrush(Qt::green);
|
||||
QGraphicsSimpleTextItem::hoverEnterEvent(event);
|
||||
|
@ -209,8 +202,7 @@ void VGraphicsSimpleTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||
{
|
||||
if (flags() & QGraphicsItem::ItemIsMovable)
|
||||
{
|
||||
//Disable cursor-arrow-openhand
|
||||
RestoreOverrideCursor(cursorArrowOpenHand);
|
||||
setCursor(QCursor());
|
||||
}
|
||||
this->setBrush(Qt::black);
|
||||
QGraphicsSimpleTextItem::hoverLeaveEvent(event);
|
||||
|
@ -242,7 +234,7 @@ void VGraphicsSimpleTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||
{
|
||||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||
{
|
||||
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
|
||||
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
|
||||
}
|
||||
}
|
||||
if (selectionType == SelectionType::ByMouseRelease)
|
||||
|
@ -262,8 +254,7 @@ void VGraphicsSimpleTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
{
|
||||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||
{
|
||||
//Disable cursor-arrow-closehand
|
||||
RestoreOverrideCursor(cursorArrowCloseHand);
|
||||
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ class VGraphicsSimpleTextItem : public QObject, public QGraphicsSimpleTextItem
|
|||
public:
|
||||
explicit VGraphicsSimpleTextItem(QGraphicsItem *parent = nullptr);
|
||||
explicit VGraphicsSimpleTextItem( const QString & text, QGraphicsItem *parent = nullptr );
|
||||
virtual ~VGraphicsSimpleTextItem() Q_DECL_OVERRIDE;
|
||||
virtual ~VGraphicsSimpleTextItem() =default;
|
||||
|
||||
qint32 BaseFontSize()const;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
|
|
|
@ -432,7 +432,7 @@ void VTextGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *pME)
|
|||
else
|
||||
{
|
||||
m_eMode = mRotate;
|
||||
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
|
||||
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
|
||||
}
|
||||
setZValue(ACTIVE_Z);
|
||||
Update();
|
||||
|
@ -463,7 +463,7 @@ void VTextGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *pME)
|
|||
else
|
||||
{
|
||||
m_eMode = mMove;
|
||||
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
|
||||
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
|
||||
}
|
||||
|
||||
setZValue(ACTIVE_Z);
|
||||
|
@ -572,13 +572,9 @@ void VTextGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME)
|
|||
if (pME->button() == Qt::LeftButton)
|
||||
{
|
||||
// restore the cursor
|
||||
if (m_eMode == mMove || m_eMode == mRotate)
|
||||
if (m_eMode == mMove || m_eMode == mRotate || m_eMode == mResize)
|
||||
{
|
||||
RestoreOverrideCursor(cursorArrowCloseHand);
|
||||
}
|
||||
else if (m_eMode == mResize)
|
||||
{
|
||||
RestoreOverrideCursor(Qt::SizeFDiagCursor);
|
||||
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
|
||||
}
|
||||
double dDist = fabs(pME->scenePos().x() - m_ptStart.x()) + fabs(pME->scenePos().y() - m_ptStart.y());
|
||||
// determine if this was just press/release (bShort == true) or user did some operation between press and release
|
||||
|
@ -634,11 +630,11 @@ void VTextGraphicsItem::hoverMoveEvent(QGraphicsSceneHoverEvent* pHE)
|
|||
{
|
||||
if (m_rectResize.contains(pHE->pos()) == true)
|
||||
{
|
||||
SetOverrideCursor(Qt::SizeFDiagCursor);
|
||||
setCursor(Qt::SizeFDiagCursor);
|
||||
}
|
||||
else
|
||||
{
|
||||
RestoreOverrideCursor(Qt::SizeFDiagCursor);
|
||||
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
|
||||
}
|
||||
}
|
||||
VPieceItem::hoverMoveEvent(pHE);
|
||||
|
@ -651,7 +647,7 @@ void VTextGraphicsItem::hoverMoveEvent(QGraphicsSceneHoverEvent* pHE)
|
|||
*/
|
||||
void VTextGraphicsItem::hoverLeaveEvent(QGraphicsSceneHoverEvent* pHE)
|
||||
{
|
||||
RestoreOverrideCursor(Qt::SizeFDiagCursor);
|
||||
setCursor(QCursor());
|
||||
VPieceItem::hoverLeaveEvent(pHE);
|
||||
}
|
||||
|
||||
|
@ -694,7 +690,7 @@ void VTextGraphicsItem::AllUserModifications(const QPointF &pos)
|
|||
}
|
||||
else
|
||||
{
|
||||
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
|
||||
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -705,7 +701,7 @@ void VTextGraphicsItem::UserRotateAndMove()
|
|||
{
|
||||
m_eMode = mMove;
|
||||
}
|
||||
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
|
||||
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -714,11 +710,11 @@ void VTextGraphicsItem::UserMoveAndResize(const QPointF &pos)
|
|||
if (m_rectResize.contains(pos) == true)
|
||||
{
|
||||
m_eMode = mResize;
|
||||
SetOverrideCursor(Qt::SizeFDiagCursor);
|
||||
setCursor(Qt::SizeFDiagCursor);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_eMode = mMove; // block later if need
|
||||
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
|
||||
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user