Fixed cursor handling on vtextgraphicsitem

--HG--
branch : feature
This commit is contained in:
BojanKverh 2016-07-12 23:11:17 +02:00
parent e93f2c117b
commit 7c2f4e54ba
3 changed files with 31 additions and 11 deletions

View file

@ -484,6 +484,28 @@ void RestoreOverrideCursor(const QString &pixmapPath)
#endif
}
//---------------------------------------------------------------------------------------------------------------------
void RestoreOverrideCursor(Qt::CursorShape shape)
{
#ifndef QT_NO_CURSOR
QPixmap oldPixmap;
QCursor* pOldCursor = QGuiApplication::overrideCursor();
if (pOldCursor != 0)
{
oldPixmap = pOldCursor->pixmap();
}
QCursor cursor(shape);
QPixmap newPixmap = cursor.pixmap();
if (oldPixmap.toImage() == newPixmap.toImage())
{
QApplication::restoreOverrideCursor();
}
#else
Q_UNUSED(shape);
#endif
}
const qreal PrintDPI = 96.0;
//---------------------------------------------------------------------------------------------------------------------

View file

@ -597,7 +597,7 @@ extern const QString falseStr;
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);
extern const qreal PrintDPI;

View file

@ -238,14 +238,6 @@ void VTextGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *pME)
//---------------------------------------------------------------------------------------------------------------------
void VTextGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent* pME)
{
if (m_rectResize.contains(pME->pos()) == true)
{
SetOverrideCursor(Qt::SizeFDiagCursor);
}
else
{
RestoreOverrideCursor(cursorArrowOpenHand);
}
QPointF ptDiff = pME->scenePos() - m_ptStart;
if (m_eMode == mMove)
{
@ -293,7 +285,14 @@ void VTextGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME)
{
if (pME->button() == Qt::LeftButton)
{
RestoreOverrideCursor(cursorArrowCloseHand);
if (m_eMode == mMove)
{
RestoreOverrideCursor(cursorArrowCloseHand);
}
else if (m_eMode == mResize)
{
RestoreOverrideCursor(Qt::SizeFDiagCursor);
}
double dDist = fabs(pME->scenePos().x() - m_ptStart.x()) + fabs(pME->scenePos().y() - m_ptStart.y());
bool bShort = (dDist < 2);
@ -323,7 +322,6 @@ void VTextGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME)
if (bShort == true)
{
m_eMode = mMove;
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
UpdateBox();
}
else