Fix bug with mouse cursor when use line tool.
--HG-- branch : develop
This commit is contained in:
parent
132b7c9fc6
commit
736d21d71c
|
@ -66,14 +66,15 @@ VToolLine::VToolLine(const VToolLineInitData &initData, QGraphicsItem *parent)
|
|||
firstPoint(initData.firstPoint),
|
||||
secondPoint(initData.secondPoint),
|
||||
lineColor(initData.lineColor),
|
||||
m_isHovered(false)
|
||||
m_isHovered(false),
|
||||
m_acceptHoverEvents(true)
|
||||
{
|
||||
this->m_lineType = initData.typeLine;
|
||||
//Line
|
||||
RefreshGeometry();
|
||||
this->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||
this->setAcceptHoverEvents(true);
|
||||
this->setAcceptHoverEvents(m_acceptHoverEvents);
|
||||
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
@ -232,7 +233,8 @@ void VToolLine::Disable(bool disable, const QString &namePP)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolLine::AllowHover(bool enabled)
|
||||
{
|
||||
setAcceptHoverEvents(enabled);
|
||||
// Manually handle hover events. Need for setting cursor for not selectable paths.
|
||||
m_acceptHoverEvents = enabled;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -285,9 +287,16 @@ void VToolLine::AddToFile()
|
|||
*/
|
||||
void VToolLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
m_isHovered = true;
|
||||
setToolTip(MakeToolTip());
|
||||
QGraphicsLineItem::hoverEnterEvent(event);
|
||||
if (m_acceptHoverEvents)
|
||||
{
|
||||
m_isHovered = true;
|
||||
setToolTip(MakeToolTip());
|
||||
QGraphicsLineItem::hoverEnterEvent(event);
|
||||
}
|
||||
else
|
||||
{
|
||||
setCursor(qApp->getSceneView()->viewport()->cursor());
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -297,7 +306,7 @@ void VToolLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
|||
*/
|
||||
void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
if (vis.isNull())
|
||||
if (m_acceptHoverEvents && vis.isNull())
|
||||
{
|
||||
m_isHovered = false;
|
||||
QGraphicsLineItem::hoverLeaveEvent(event);
|
||||
|
|
|
@ -125,6 +125,7 @@ private:
|
|||
QString lineColor;
|
||||
|
||||
bool m_isHovered;
|
||||
bool m_acceptHoverEvents;
|
||||
|
||||
VToolLine(const VToolLineInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user