From d6069c920112426a65a45b070fc845a63eb4e32f Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 12 Feb 2015 13:55:35 +0200 Subject: [PATCH] Avoid declaring the same literal in multiple places. --HG-- branch : feature --- src/app/options.cpp | 3 +++ src/app/options.h | 3 +++ src/app/tools/drawTools/vtoolsinglepoint.cpp | 9 +++++---- src/app/tools/drawTools/vtoolspline.cpp | 9 +++++---- src/app/visualization/vcontrolpointspline.cpp | 8 ++++---- src/app/visualization/vgraphicssimpletextitem.cpp | 8 ++++---- 6 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/app/options.cpp b/src/app/options.cpp index 0f102247f..6d5b8fa53 100644 --- a/src/app/options.cpp +++ b/src/app/options.cpp @@ -37,6 +37,9 @@ const QString nameRegExp = QStringLiteral("^([^0-9-*/^+=\\s\\(\\)%:;!.,`'\"]){1, // furthermore blows up the binary sizes. const QString degreeSymbol = QStringLiteral("°"); +const QString cursorArrowOpenHand = QStringLiteral("://cursor/cursor-arrow-openhand.png"); +const QString cursorArrowCloseHand = QStringLiteral("://cursor/cursor-arrow-closehand.png"); + // Keep synchronize all names with initialization in VApllication class!!!!! //measurements //head and neck diff --git a/src/app/options.h b/src/app/options.h index 2a4e72fa0..6024d2d09 100644 --- a/src/app/options.h +++ b/src/app/options.h @@ -50,6 +50,9 @@ class QStringList; extern const QString nameRegExp; extern const QString degreeSymbol; +extern const QString cursorArrowOpenHand; +extern const QString cursorArrowCloseHand; + enum class SceneObject : char { Point, Line, Spline, Arc, SplinePath, Detail, Unknown }; enum class Tool : unsigned char { diff --git a/src/app/tools/drawTools/vtoolsinglepoint.cpp b/src/app/tools/drawTools/vtoolsinglepoint.cpp index 0948cecc1..dde2a162c 100644 --- a/src/app/tools/drawTools/vtoolsinglepoint.cpp +++ b/src/app/tools/drawTools/vtoolsinglepoint.cpp @@ -33,6 +33,7 @@ #include "../../undocommands/addpatternpiece.h" #include "../../undocommands/deletepatternpiece.h" #include "../../geometry/vpointf.h" +#include "../../options.h" #include @@ -207,7 +208,7 @@ void VToolSinglePoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event) if (flags() & QGraphicsItem::ItemIsMovable) { - VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png"), 1, 1); + VApplication::setOverrideCursor(cursorArrowOpenHand, 1, 1); } } @@ -219,7 +220,7 @@ void VToolSinglePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) if (flags() & QGraphicsItem::ItemIsMovable) { //Disable cursor-arrow-openhand - VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png")); + VApplication::restoreOverrideCursor(cursorArrowOpenHand); } } @@ -230,7 +231,7 @@ void VToolSinglePoint::mousePressEvent(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) { - VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png"), 1, 1); + VApplication::setOverrideCursor(cursorArrowCloseHand, 1, 1); } } VToolPoint::mousePressEvent(event); @@ -244,7 +245,7 @@ void VToolSinglePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) { //Disable cursor-arrow-closehand - VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png")); + VApplication::restoreOverrideCursor(cursorArrowCloseHand); } } VToolPoint::mouseReleaseEvent(event); diff --git a/src/app/tools/drawTools/vtoolspline.cpp b/src/app/tools/drawTools/vtoolspline.cpp index f6f4c6b71..847077453 100644 --- a/src/app/tools/drawTools/vtoolspline.cpp +++ b/src/app/tools/drawTools/vtoolspline.cpp @@ -31,6 +31,7 @@ #include "../../dialogs/tools/dialogspline.h" #include "../../undocommands/movespline.h" #include "../../visualization/vistoolspline.h" +#include "../../options.h" #include const QString VToolSpline::ToolType = QStringLiteral("simple"); @@ -371,7 +372,7 @@ void VToolSpline::mousePressEvent(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) { - VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png"), 1, 1); + VApplication::setOverrideCursor(cursorArrowCloseHand, 1, 1); oldPosition = event->scenePos(); event->accept(); } @@ -387,7 +388,7 @@ void VToolSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) { //Disable cursor-arrow-closehand - VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png")); + VApplication::restoreOverrideCursor(cursorArrowCloseHand); } } VAbstractSpline::mouseReleaseEvent(event); @@ -451,7 +452,7 @@ void VToolSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { if (flags() & QGraphicsItem::ItemIsMovable) { - VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png"), 1, 1); + VApplication::setOverrideCursor(cursorArrowOpenHand, 1, 1); } VAbstractSpline::hoverEnterEvent(event); @@ -463,7 +464,7 @@ void VToolSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) if (flags() & QGraphicsItem::ItemIsMovable) { //Disable cursor-arrow-openhand - VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png")); + VApplication::restoreOverrideCursor(cursorArrowOpenHand); } VAbstractSpline::hoverLeaveEvent(event); diff --git a/src/app/visualization/vcontrolpointspline.cpp b/src/app/visualization/vcontrolpointspline.cpp index 31c22d7aa..5fb35504a 100644 --- a/src/app/visualization/vcontrolpointspline.cpp +++ b/src/app/visualization/vcontrolpointspline.cpp @@ -90,7 +90,7 @@ void VControlPointSpline::paint(QPainter *painter, const QStyleOptionGraphicsIte void VControlPointSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()))); - VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png"), 1, 1); + VApplication::setOverrideCursor(cursorArrowOpenHand, 1, 1); QGraphicsEllipseItem::hoverEnterEvent(event); } @@ -99,7 +99,7 @@ void VControlPointSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine()))); //Disable cursor-arrow-openhand - VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png")); + VApplication::restoreOverrideCursor(cursorArrowOpenHand); QGraphicsEllipseItem::hoverLeaveEvent(event); } @@ -126,7 +126,7 @@ void VControlPointSpline::mousePressEvent(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) { - VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png"), 1, 1); + VApplication::setOverrideCursor(cursorArrowCloseHand, 1, 1); } QGraphicsEllipseItem::mousePressEvent(event); } @@ -137,7 +137,7 @@ void VControlPointSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) { //Disable cursor-arrow-closehand - VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png")); + VApplication::restoreOverrideCursor(cursorArrowCloseHand); } QGraphicsEllipseItem::mouseReleaseEvent(event); } diff --git a/src/app/visualization/vgraphicssimpletextitem.cpp b/src/app/visualization/vgraphicssimpletextitem.cpp index 85f07a71d..c937519fd 100644 --- a/src/app/visualization/vgraphicssimpletextitem.cpp +++ b/src/app/visualization/vgraphicssimpletextitem.cpp @@ -124,7 +124,7 @@ void VGraphicsSimpleTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { this->setBrush(Qt::green); - VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png"), 1, 1); + VApplication::setOverrideCursor(cursorArrowOpenHand, 1, 1); QGraphicsSimpleTextItem::hoverEnterEvent(event); } @@ -139,7 +139,7 @@ void VGraphicsSimpleTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) this->setBrush(Qt::black); //Disable cursor-arrow-openhand - VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png")); + VApplication::restoreOverrideCursor(cursorArrowOpenHand); QGraphicsSimpleTextItem::hoverLeaveEvent(event); } @@ -158,7 +158,7 @@ void VGraphicsSimpleTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) { - VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png"), 1, 1); + VApplication::setOverrideCursor(cursorArrowCloseHand, 1, 1); } QGraphicsSimpleTextItem::mousePressEvent(event); } @@ -169,7 +169,7 @@ void VGraphicsSimpleTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) { //Disable cursor-arrow-closehand - VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png")); + VApplication::restoreOverrideCursor(cursorArrowCloseHand); } QGraphicsSimpleTextItem::mouseReleaseEvent(event); }