New hack to restore mouse cursor.
--HG-- branch : develop
This commit is contained in:
parent
a99212e89a
commit
34d1b91225
|
@ -608,6 +608,7 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons
|
||||||
QPixmap pixmap(cursorResource);
|
QPixmap pixmap(cursorResource);
|
||||||
QCursor cur(pixmap, 2, 2);
|
QCursor cur(pixmap, 2, 2);
|
||||||
ui->view->viewport()->setCursor(cur);
|
ui->view->viewport()->setCursor(cur);
|
||||||
|
ui->view->setCurrentCursorShape(); // Hack to fix problem with a cursor
|
||||||
helpLabel->setText(toolTip);
|
helpLabel->setText(toolTip);
|
||||||
ui->view->setShowToolOptions(false);
|
ui->view->setShowToolOptions(false);
|
||||||
dialogTool = QSharedPointer<Dialog>(new Dialog(pattern, 0, this));
|
dialogTool = QSharedPointer<Dialog>(new Dialog(pattern, 0, this));
|
||||||
|
@ -2315,7 +2316,9 @@ void MainWindow::ArrowTool(bool checked)
|
||||||
emit EnableDetailHover(true);
|
emit EnableDetailHover(true);
|
||||||
|
|
||||||
ui->view->AllowRubberBand(true);
|
ui->view->AllowRubberBand(true);
|
||||||
|
ui->view->viewport()->unsetCursor();
|
||||||
ui->view->viewport()->setCursor(QCursor(Qt::ArrowCursor));
|
ui->view->viewport()->setCursor(QCursor(Qt::ArrowCursor));
|
||||||
|
ui->view->setCurrentCursorShape(); // Hack to fix problem with a cursor
|
||||||
helpLabel->setText("");
|
helpLabel->setText("");
|
||||||
ui->view->setShowToolOptions(true);
|
ui->view->setShowToolOptions(true);
|
||||||
qCDebug(vMainWindow, "Enabled arrow tool.");
|
qCDebug(vMainWindow, "Enabled arrow tool.");
|
||||||
|
|
|
@ -358,12 +358,14 @@ void VToolSinglePoint::ChangeLabelPosition(quint32 id, const QPointF &pos)
|
||||||
void VToolSinglePoint::AllowHover(bool enabled)
|
void VToolSinglePoint::AllowHover(bool enabled)
|
||||||
{
|
{
|
||||||
setAcceptHoverEvents(enabled);
|
setAcceptHoverEvents(enabled);
|
||||||
|
AllowLabelHover(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolSinglePoint::AllowSelecting(bool enabled)
|
void VToolSinglePoint::AllowSelecting(bool enabled)
|
||||||
{
|
{
|
||||||
setFlag(QGraphicsItem::ItemIsSelectable, enabled);
|
setFlag(QGraphicsItem::ItemIsSelectable, enabled);
|
||||||
|
AllowLabelSelecting(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "vscenepoint.h"
|
#include "vscenepoint.h"
|
||||||
#include "../vmisc/vmath.h"
|
#include "../vmisc/vmath.h"
|
||||||
|
#include "../vmisc/vabstractapplication.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -211,6 +212,11 @@ void VGraphicsSimpleTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
|
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setCursor(qApp->getSceneView()->viewport()->cursor());
|
||||||
|
}
|
||||||
|
|
||||||
this->setBrush(Qt::green);
|
this->setBrush(Qt::green);
|
||||||
|
|
||||||
if(QGraphicsItem *parent = parentItem())
|
if(QGraphicsItem *parent = parentItem())
|
||||||
|
|
|
@ -353,7 +353,8 @@ VMainGraphicsView::VMainGraphicsView(QWidget *parent)
|
||||||
showToolOptions(true),
|
showToolOptions(true),
|
||||||
isAllowRubberBand(true),
|
isAllowRubberBand(true),
|
||||||
m_ptStartPos(),
|
m_ptStartPos(),
|
||||||
m_oldCursor()
|
m_oldCursor(),
|
||||||
|
m_currentCursor(Qt::ArrowCursor)
|
||||||
{
|
{
|
||||||
this->setResizeAnchor(QGraphicsView::AnchorUnderMouse);
|
this->setResizeAnchor(QGraphicsView::AnchorUnderMouse);
|
||||||
this->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
this->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
||||||
|
@ -486,6 +487,16 @@ void VMainGraphicsView::mousePressEvent(QMouseEvent *event)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VMainGraphicsView::mouseMoveEvent(QMouseEvent *event)
|
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 &&
|
||||||
|
// 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())
|
||||||
|
{
|
||||||
|
viewport()->setCursor(m_currentCursor);
|
||||||
|
}
|
||||||
|
|
||||||
if (dragMode() == QGraphicsView::ScrollHandDrag)
|
if (dragMode() == QGraphicsView::ScrollHandDrag)
|
||||||
{
|
{
|
||||||
QScrollBar *hBar = horizontalScrollBar();
|
QScrollBar *hBar = horizontalScrollBar();
|
||||||
|
@ -566,6 +577,12 @@ void VMainGraphicsView::EnsureVisibleWithDelay(const QGraphicsItem *item, unsign
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VMainGraphicsView::setCurrentCursorShape()
|
||||||
|
{
|
||||||
|
m_currentCursor = viewport()->cursor().shape();
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VMainGraphicsView::setShowToolOptions(bool value)
|
void VMainGraphicsView::setShowToolOptions(bool value)
|
||||||
{
|
{
|
||||||
|
|
|
@ -129,6 +129,8 @@ public:
|
||||||
|
|
||||||
static const unsigned long scrollDelay;
|
static const unsigned long scrollDelay;
|
||||||
|
|
||||||
|
void setCurrentCursorShape();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
* @brief MouseRelease help catch mouse release event.
|
* @brief MouseRelease help catch mouse release event.
|
||||||
|
@ -153,6 +155,7 @@ private:
|
||||||
bool isAllowRubberBand;
|
bool isAllowRubberBand;
|
||||||
QPoint m_ptStartPos;
|
QPoint m_ptStartPos;
|
||||||
QCursor m_oldCursor;
|
QCursor m_oldCursor;
|
||||||
|
Qt::CursorShape m_currentCursor;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VMAINGRAPHICSVIEW_H
|
#endif // VMAINGRAPHICSVIEW_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user