Fix QGraphicsView cursor regression.
--HG-- branch : develop
This commit is contained in:
parent
b8c8c284a8
commit
15339939ef
|
@ -208,11 +208,8 @@ const QString unitINCH = QStringLiteral("inch");
|
|||
const QString unitPX = QStringLiteral("px");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void SetItemOverrideCursor(QGraphicsItem *item, const QString &pixmapPath, int hotX, int hotY)
|
||||
QPixmap QPixmapFromCache(const QString &pixmapPath)
|
||||
{
|
||||
#ifndef QT_NO_CURSOR
|
||||
SCASSERT(item != nullptr)
|
||||
|
||||
QPixmap pixmap;
|
||||
|
||||
if (not QPixmapCache::find(pixmapPath, pixmap))
|
||||
|
@ -220,8 +217,15 @@ void SetItemOverrideCursor(QGraphicsItem *item, const QString &pixmapPath, int h
|
|||
pixmap = QPixmap(pixmapPath);
|
||||
QPixmapCache::insert(pixmapPath, pixmap);
|
||||
}
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
item->setCursor(QCursor(pixmap, hotX, hotY));
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void SetItemOverrideCursor(QGraphicsItem *item, const QString &pixmapPath, int hotX, int hotY)
|
||||
{
|
||||
#ifndef QT_NO_CURSOR
|
||||
SCASSERT(item != nullptr)
|
||||
item->setCursor(QCursor(QPixmapFromCache(pixmapPath), hotX, hotY));
|
||||
#else
|
||||
Q_UNUSED(item)
|
||||
Q_UNUSED(pixmapPath)
|
||||
|
|
|
@ -413,6 +413,7 @@ extern const QString unitCM;
|
|||
extern const QString unitINCH;
|
||||
extern const QString unitPX;
|
||||
|
||||
QPixmap QPixmapFromCache(const QString &pixmapPath);
|
||||
void SetItemOverrideCursor(QGraphicsItem *item, const QString & pixmapPath, int hotX = -1, int hotY = -1);
|
||||
|
||||
Q_REQUIRED_RESULT double ToPixel(double val, const Unit &unit);
|
||||
|
|
|
@ -504,13 +504,18 @@ void VMainGraphicsView::mouseMoveEvent(QMouseEvent *event)
|
|||
{
|
||||
// Hack to fix problem with mouse cursor. Looks like after we switch cursor back it is rewrited back by a dialog.
|
||||
// Because no real way to catch this call we will check state for each move and compare to excpected state.
|
||||
if (dragMode() != QGraphicsView::ScrollHandDrag &&
|
||||
if (dragMode() != QGraphicsView::ScrollHandDrag)
|
||||
{
|
||||
QCursor cur = viewport()->cursor();
|
||||
// No way to restore bitmap from shape and we really don't need this for now.
|
||||
m_currentCursor != Qt::BitmapCursor &&
|
||||
m_currentCursor != viewport()->cursor().shape())
|
||||
if (m_currentCursor != Qt::BitmapCursor
|
||||
&& cur.shape() == Qt::BitmapCursor
|
||||
&& cur.pixmap().cacheKey() != QPixmapFromCache(cursorArrowOpenHand).cacheKey()
|
||||
&& cur.pixmap().cacheKey() != QPixmapFromCache(cursorArrowCloseHand).cacheKey())
|
||||
{
|
||||
viewport()->setCursor(m_currentCursor);
|
||||
}
|
||||
}
|
||||
|
||||
if (dragMode() == QGraphicsView::ScrollHandDrag)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user