Class VControlPointSpline more independent.
--HG-- branch : feature
This commit is contained in:
parent
78dbb63c1b
commit
fe704484c5
|
@ -608,48 +608,6 @@ void VApplication::setCurrentScene(QGraphicsScene *value)
|
||||||
currentScene = value;
|
currentScene = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VApplication::setOverrideCursor(const QString &pixmapPath, int hotX, int hotY)
|
|
||||||
{
|
|
||||||
#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 )
|
|
||||||
{
|
|
||||||
QApplication::setOverrideCursor(QCursor(newPixmap, hotX, hotY));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VApplication::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 )
|
|
||||||
{
|
|
||||||
QApplication::restoreOverrideCursor();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QStringList VApplication::LabelLanguages()
|
QStringList VApplication::LabelLanguages()
|
||||||
{
|
{
|
||||||
|
|
|
@ -105,9 +105,6 @@ public:
|
||||||
void setCurrentDocument(VPattern *doc);
|
void setCurrentDocument(VPattern *doc);
|
||||||
VPattern *getCurrentDocument()const;
|
VPattern *getCurrentDocument()const;
|
||||||
|
|
||||||
static void setOverrideCursor(const QString & pixmapPath, int hotX = -1, int hotY = -1);
|
|
||||||
static void restoreOverrideCursor(const QString & pixmapPath);
|
|
||||||
|
|
||||||
static QStringList LabelLanguages();
|
static QStringList LabelLanguages();
|
||||||
|
|
||||||
void StartLogging();
|
void StartLogging();
|
||||||
|
|
|
@ -32,6 +32,3 @@
|
||||||
// From documantation: If you use QStringLiteral you should avoid declaring the same literal in multiple places: This
|
// From documantation: If you use QStringLiteral you should avoid declaring the same literal in multiple places: This
|
||||||
// furthermore blows up the binary sizes.
|
// furthermore blows up the binary sizes.
|
||||||
const QString degreeSymbol = QStringLiteral("°");
|
const QString degreeSymbol = QStringLiteral("°");
|
||||||
|
|
||||||
const QString cursorArrowOpenHand = QStringLiteral("://cursor/cursor-arrow-openhand.png");
|
|
||||||
const QString cursorArrowCloseHand = QStringLiteral("://cursor/cursor-arrow-closehand.png");
|
|
||||||
|
|
|
@ -52,9 +52,6 @@ class QStringList;
|
||||||
|
|
||||||
extern const QString degreeSymbol;
|
extern const QString degreeSymbol;
|
||||||
|
|
||||||
extern const QString cursorArrowOpenHand;
|
|
||||||
extern const QString cursorArrowCloseHand;
|
|
||||||
|
|
||||||
enum class Source : char { FromGui, FromFile, FromTool };
|
enum class Source : char { FromGui, FromFile, FromTool };
|
||||||
enum class Contour : char { OpenContour, CloseContour };
|
enum class Contour : char { OpenContour, CloseContour };
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ VToolSinglePoint::VToolSinglePoint (VPattern *doc, VContainer *data, quint32 id,
|
||||||
VToolSinglePoint::~VToolSinglePoint()
|
VToolSinglePoint::~VToolSinglePoint()
|
||||||
{
|
{
|
||||||
//Disable cursor-arrow-openhand
|
//Disable cursor-arrow-openhand
|
||||||
VApplication::restoreOverrideCursor(cursorArrowOpenHand);
|
RestoreOverrideCursor(cursorArrowOpenHand);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -207,7 +207,7 @@ void VToolSinglePoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
|
||||||
if (flags() & QGraphicsItem::ItemIsMovable)
|
if (flags() & QGraphicsItem::ItemIsMovable)
|
||||||
{
|
{
|
||||||
VApplication::setOverrideCursor(cursorArrowOpenHand, 1, 1);
|
SetOverrideCursor(cursorArrowOpenHand, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ void VToolSinglePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
if (flags() & QGraphicsItem::ItemIsMovable)
|
if (flags() & QGraphicsItem::ItemIsMovable)
|
||||||
{
|
{
|
||||||
//Disable cursor-arrow-openhand
|
//Disable cursor-arrow-openhand
|
||||||
VApplication::restoreOverrideCursor(cursorArrowOpenHand);
|
RestoreOverrideCursor(cursorArrowOpenHand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ void VToolSinglePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||||
{
|
{
|
||||||
VApplication::setOverrideCursor(cursorArrowCloseHand, 1, 1);
|
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VToolPoint::mousePressEvent(event);
|
VToolPoint::mousePressEvent(event);
|
||||||
|
@ -244,7 +244,7 @@ void VToolSinglePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||||
{
|
{
|
||||||
//Disable cursor-arrow-closehand
|
//Disable cursor-arrow-closehand
|
||||||
VApplication::restoreOverrideCursor(cursorArrowCloseHand);
|
RestoreOverrideCursor(cursorArrowCloseHand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VToolPoint::mouseReleaseEvent(event);
|
VToolPoint::mouseReleaseEvent(event);
|
||||||
|
|
|
@ -94,7 +94,7 @@ VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const QStr
|
||||||
VToolSpline::~VToolSpline()
|
VToolSpline::~VToolSpline()
|
||||||
{
|
{
|
||||||
//Disable cursor-arrow-openhand
|
//Disable cursor-arrow-openhand
|
||||||
VApplication::restoreOverrideCursor(cursorArrowOpenHand);
|
RestoreOverrideCursor(cursorArrowOpenHand);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -345,7 +345,7 @@ void VToolSpline::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||||
{
|
{
|
||||||
VApplication::setOverrideCursor(cursorArrowCloseHand, 1, 1);
|
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
|
||||||
oldPosition = event->scenePos();
|
oldPosition = event->scenePos();
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
@ -361,7 +361,7 @@ void VToolSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||||
{
|
{
|
||||||
//Disable cursor-arrow-closehand
|
//Disable cursor-arrow-closehand
|
||||||
VApplication::restoreOverrideCursor(cursorArrowCloseHand);
|
RestoreOverrideCursor(cursorArrowCloseHand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VAbstractSpline::mouseReleaseEvent(event);
|
VAbstractSpline::mouseReleaseEvent(event);
|
||||||
|
@ -425,7 +425,7 @@ void VToolSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
if (flags() & QGraphicsItem::ItemIsMovable)
|
if (flags() & QGraphicsItem::ItemIsMovable)
|
||||||
{
|
{
|
||||||
VApplication::setOverrideCursor(cursorArrowOpenHand, 1, 1);
|
SetOverrideCursor(cursorArrowOpenHand, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
VAbstractSpline::hoverEnterEvent(event);
|
VAbstractSpline::hoverEnterEvent(event);
|
||||||
|
@ -437,7 +437,7 @@ void VToolSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
if (flags() & QGraphicsItem::ItemIsMovable)
|
if (flags() & QGraphicsItem::ItemIsMovable)
|
||||||
{
|
{
|
||||||
//Disable cursor-arrow-openhand
|
//Disable cursor-arrow-openhand
|
||||||
VApplication::restoreOverrideCursor(cursorArrowOpenHand);
|
RestoreOverrideCursor(cursorArrowOpenHand);
|
||||||
}
|
}
|
||||||
|
|
||||||
VAbstractSpline::hoverLeaveEvent(event);
|
VAbstractSpline::hoverLeaveEvent(event);
|
||||||
|
|
|
@ -95,7 +95,7 @@ VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, co
|
||||||
VToolSplinePath::~VToolSplinePath()
|
VToolSplinePath::~VToolSplinePath()
|
||||||
{
|
{
|
||||||
//Disable cursor-arrow-openhand
|
//Disable cursor-arrow-openhand
|
||||||
VApplication::restoreOverrideCursor(cursorArrowOpenHand);
|
RestoreOverrideCursor(cursorArrowOpenHand);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -412,7 +412,7 @@ void VToolSplinePath::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||||
{
|
{
|
||||||
VApplication::setOverrideCursor(cursorArrowCloseHand, 1, 1);
|
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
|
||||||
oldPosition = event->scenePos();
|
oldPosition = event->scenePos();
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
@ -428,7 +428,7 @@ void VToolSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||||
{
|
{
|
||||||
//Disable cursor-arrow-closehand
|
//Disable cursor-arrow-closehand
|
||||||
VApplication::restoreOverrideCursor(cursorArrowCloseHand);
|
RestoreOverrideCursor(cursorArrowCloseHand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VAbstractSpline::mouseReleaseEvent(event);
|
VAbstractSpline::mouseReleaseEvent(event);
|
||||||
|
@ -502,7 +502,7 @@ void VToolSplinePath::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
if (flags() & QGraphicsItem::ItemIsMovable)
|
if (flags() & QGraphicsItem::ItemIsMovable)
|
||||||
{
|
{
|
||||||
VApplication::setOverrideCursor(cursorArrowOpenHand, 1, 1);
|
SetOverrideCursor(cursorArrowOpenHand, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
VAbstractSpline::hoverEnterEvent(event);
|
VAbstractSpline::hoverEnterEvent(event);
|
||||||
|
@ -514,7 +514,7 @@ void VToolSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
if (flags() & QGraphicsItem::ItemIsMovable)
|
if (flags() & QGraphicsItem::ItemIsMovable)
|
||||||
{
|
{
|
||||||
//Disable cursor-arrow-openhand
|
//Disable cursor-arrow-openhand
|
||||||
VApplication::restoreOverrideCursor(cursorArrowOpenHand);
|
RestoreOverrideCursor(cursorArrowOpenHand);
|
||||||
}
|
}
|
||||||
|
|
||||||
VAbstractSpline::hoverLeaveEvent(event);
|
VAbstractSpline::hoverLeaveEvent(event);
|
||||||
|
|
|
@ -27,12 +27,10 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vcontrolpointspline.h"
|
#include "vcontrolpointspline.h"
|
||||||
#include "../tools/vabstracttool.h"
|
|
||||||
|
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
#include <QPen>
|
#include <QPen>
|
||||||
#include <QStyleOptionGraphicsItem>
|
#include <QStyleOptionGraphicsItem>
|
||||||
#include "../core/vapplication.h"
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -54,7 +52,7 @@ VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointP
|
||||||
QRectF rec = QRectF(0, 0, radius*2, radius*2);
|
QRectF rec = QRectF(0, 0, radius*2, radius*2);
|
||||||
rec.translate(-rec.center().x(), -rec.center().y());
|
rec.translate(-rec.center().x(), -rec.center().y());
|
||||||
this->setRect(rec);
|
this->setRect(rec);
|
||||||
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(patternUnit))));
|
this->setPen(QPen(Qt::black, ToPixel(WidthHairLine(patternUnit), patternUnit)));
|
||||||
this->setBrush(QBrush(Qt::NoBrush));
|
this->setBrush(QBrush(Qt::NoBrush));
|
||||||
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||||
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||||
|
@ -66,7 +64,7 @@ VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointP
|
||||||
QPointF p1, p2;
|
QPointF p1, p2;
|
||||||
VGObject::LineIntersectCircle(QPointF(), radius, QLineF( QPointF(), splinePoint-controlPoint), p1, p2);
|
VGObject::LineIntersectCircle(QPointF(), radius, QLineF( QPointF(), splinePoint-controlPoint), p1, p2);
|
||||||
controlLine = new QGraphicsLineItem(QLineF(splinePoint-controlPoint, p1), this);
|
controlLine = new QGraphicsLineItem(QLineF(splinePoint-controlPoint, p1), this);
|
||||||
controlLine->setPen(QPen(Qt::red, qApp->toPixel(WidthHairLine(patternUnit))));
|
controlLine->setPen(QPen(Qt::red, ToPixel(WidthHairLine(patternUnit), patternUnit)));
|
||||||
controlLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
controlLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +72,7 @@ VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointP
|
||||||
VControlPointSpline::~VControlPointSpline()
|
VControlPointSpline::~VControlPointSpline()
|
||||||
{
|
{
|
||||||
//Disable cursor-arrow-openhand
|
//Disable cursor-arrow-openhand
|
||||||
VApplication::restoreOverrideCursor(cursorArrowOpenHand);
|
RestoreOverrideCursor(cursorArrowOpenHand);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -97,17 +95,17 @@ void VControlPointSpline::paint(QPainter *painter, const QStyleOptionGraphicsIte
|
||||||
*/
|
*/
|
||||||
void VControlPointSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
void VControlPointSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
this->setPen(QPen(Qt::black, qApp->toPixel(WidthMainLine(patternUnit))));
|
this->setPen(QPen(Qt::black, ToPixel(WidthMainLine(patternUnit), patternUnit)));
|
||||||
VApplication::setOverrideCursor(cursorArrowOpenHand, 1, 1);
|
SetOverrideCursor(cursorArrowOpenHand, 1, 1);
|
||||||
QGraphicsEllipseItem::hoverEnterEvent(event);
|
QGraphicsEllipseItem::hoverEnterEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VControlPointSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
void VControlPointSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(patternUnit))));
|
this->setPen(QPen(Qt::black, ToPixel(WidthHairLine(patternUnit), patternUnit)));
|
||||||
//Disable cursor-arrow-openhand
|
//Disable cursor-arrow-openhand
|
||||||
VApplication::restoreOverrideCursor(cursorArrowOpenHand);
|
RestoreOverrideCursor(cursorArrowOpenHand);
|
||||||
QGraphicsEllipseItem::hoverLeaveEvent(event);
|
QGraphicsEllipseItem::hoverLeaveEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +132,7 @@ void VControlPointSpline::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||||
{
|
{
|
||||||
VApplication::setOverrideCursor(cursorArrowCloseHand, 1, 1);
|
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
|
||||||
}
|
}
|
||||||
QGraphicsEllipseItem::mousePressEvent(event);
|
QGraphicsEllipseItem::mousePressEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -145,7 +143,7 @@ void VControlPointSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||||
{
|
{
|
||||||
//Disable cursor-arrow-closehand
|
//Disable cursor-arrow-closehand
|
||||||
VApplication::restoreOverrideCursor(cursorArrowCloseHand);
|
RestoreOverrideCursor(cursorArrowCloseHand);
|
||||||
}
|
}
|
||||||
QGraphicsEllipseItem::mouseReleaseEvent(event);
|
QGraphicsEllipseItem::mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -184,14 +182,14 @@ void VControlPointSpline::setEnabledPoint(bool enable)
|
||||||
{
|
{
|
||||||
if (enable == true)
|
if (enable == true)
|
||||||
{
|
{
|
||||||
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(patternUnit))));
|
this->setPen(QPen(Qt::black, ToPixel(WidthHairLine(patternUnit), patternUnit)));
|
||||||
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||||
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||||
this->setAcceptHoverEvents(true);
|
this->setAcceptHoverEvents(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->setPen(QPen(Qt::gray, qApp->toPixel(WidthHairLine(patternUnit))));
|
this->setPen(QPen(Qt::gray, ToPixel(WidthHairLine(patternUnit), patternUnit)));
|
||||||
this->setFlag(QGraphicsItem::ItemIsSelectable, false);
|
this->setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||||
this->setFlag(QGraphicsItem::ItemIsMovable, false);
|
this->setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||||
this->setAcceptHoverEvents(false);
|
this->setAcceptHoverEvents(false);
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include <QGraphicsEllipseItem>
|
#include <QGraphicsEllipseItem>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "../libs/vgeometry/vsplinepath.h"
|
#include "../libs/vgeometry/vsplinepath.h"
|
||||||
#include "../options.h"
|
#include "../libs/vmisc/def.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VControlPointSpline class control spline point.
|
* @brief The VControlPointSpline class control spline point.
|
||||||
|
|
|
@ -74,7 +74,7 @@ VGraphicsSimpleTextItem::VGraphicsSimpleTextItem( const QString & text, QGraphic
|
||||||
VGraphicsSimpleTextItem::~VGraphicsSimpleTextItem()
|
VGraphicsSimpleTextItem::~VGraphicsSimpleTextItem()
|
||||||
{
|
{
|
||||||
//Disable cursor-arrow-openhand
|
//Disable cursor-arrow-openhand
|
||||||
VApplication::restoreOverrideCursor(cursorArrowOpenHand);
|
RestoreOverrideCursor(cursorArrowOpenHand);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -133,7 +133,7 @@ void VGraphicsSimpleTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
this->setBrush(Qt::green);
|
this->setBrush(Qt::green);
|
||||||
|
|
||||||
VApplication::setOverrideCursor(cursorArrowOpenHand, 1, 1);
|
SetOverrideCursor(cursorArrowOpenHand, 1, 1);
|
||||||
}
|
}
|
||||||
QGraphicsSimpleTextItem::hoverEnterEvent(event);
|
QGraphicsSimpleTextItem::hoverEnterEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ void VGraphicsSimpleTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
this->setBrush(Qt::black);
|
this->setBrush(Qt::black);
|
||||||
|
|
||||||
//Disable cursor-arrow-openhand
|
//Disable cursor-arrow-openhand
|
||||||
VApplication::restoreOverrideCursor(cursorArrowOpenHand);
|
RestoreOverrideCursor(cursorArrowOpenHand);
|
||||||
}
|
}
|
||||||
QGraphicsSimpleTextItem::hoverLeaveEvent(event);
|
QGraphicsSimpleTextItem::hoverLeaveEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ void VGraphicsSimpleTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||||
{
|
{
|
||||||
VApplication::setOverrideCursor(cursorArrowCloseHand, 1, 1);
|
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QGraphicsSimpleTextItem::mousePressEvent(event);
|
QGraphicsSimpleTextItem::mousePressEvent(event);
|
||||||
|
@ -187,7 +187,7 @@ void VGraphicsSimpleTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||||
{
|
{
|
||||||
//Disable cursor-arrow-closehand
|
//Disable cursor-arrow-closehand
|
||||||
VApplication::restoreOverrideCursor(cursorArrowCloseHand);
|
RestoreOverrideCursor(cursorArrowCloseHand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
#include "def.h"
|
#include "def.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
// Keep synchronize all names with initialization in VApllication class!!!!!
|
// Keep synchronize all names with initialization in VApllication class!!!!!
|
||||||
//measurements
|
//measurements
|
||||||
//head and neck
|
//head and neck
|
||||||
|
@ -216,3 +218,48 @@ const QStringList builInFunctions = QStringList() << sin_F << cos_F << tan_F
|
||||||
const QString cm_Oprt = QStringLiteral("cm");
|
const QString cm_Oprt = QStringLiteral("cm");
|
||||||
const QString mm_Oprt = QStringLiteral("mm");
|
const QString mm_Oprt = QStringLiteral("mm");
|
||||||
const QString in_Oprt = QStringLiteral("in");
|
const QString in_Oprt = QStringLiteral("in");
|
||||||
|
|
||||||
|
const QString cursorArrowOpenHand = QStringLiteral("://cursor/cursor-arrow-openhand.png");
|
||||||
|
const QString cursorArrowCloseHand = QStringLiteral("://cursor/cursor-arrow-closehand.png");
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void SetOverrideCursor(const QString &pixmapPath, int hotX, int hotY)
|
||||||
|
{
|
||||||
|
#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 )
|
||||||
|
{
|
||||||
|
QApplication::setOverrideCursor(QCursor(newPixmap, hotX, hotY));
|
||||||
|
}
|
||||||
|
#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 )
|
||||||
|
{
|
||||||
|
QApplication::restoreOverrideCursor();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
|
@ -368,4 +368,10 @@ extern const QString cm_Oprt;
|
||||||
extern const QString mm_Oprt;
|
extern const QString mm_Oprt;
|
||||||
extern const QString in_Oprt;
|
extern const QString in_Oprt;
|
||||||
|
|
||||||
|
extern const QString cursorArrowOpenHand;
|
||||||
|
extern const QString cursorArrowCloseHand;
|
||||||
|
|
||||||
|
void SetOverrideCursor(const QString & pixmapPath, int hotX = -1, int hotY = -1);
|
||||||
|
void RestoreOverrideCursor(const QString & pixmapPath);
|
||||||
|
|
||||||
#endif // DEF_H
|
#endif // DEF_H
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
# File with common stuff for whole project
|
# File with common stuff for whole project
|
||||||
include(../../../Valentina.pri)
|
include(../../../Valentina.pri)
|
||||||
|
|
||||||
|
QT += widgets
|
||||||
|
|
||||||
# Name of library
|
# Name of library
|
||||||
TARGET = vmisc
|
TARGET = vmisc
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user