diff --git a/src/app/puzzle/share/resources/puzzleicon.qrc b/src/app/puzzle/share/resources/puzzleicon.qrc index 83dde8c8e..cf7527f52 100644 --- a/src/app/puzzle/share/resources/puzzleicon.qrc +++ b/src/app/puzzle/share/resources/puzzleicon.qrc @@ -9,12 +9,12 @@ puzzleicon/64x64/iconPortrait.png puzzleicon/64x64/iconGrainlineVertical.png puzzleicon/64x64/iconGrainlineHorizontal.png - puzzleicon/64x64/cursorRotate.png puzzleicon/64x64/iconProperties.png puzzleicon/svg/icon_scissors.svg puzzleicon/svg/icon_scissors_vertical.svg puzzleicon/svg/icon_scissors_horizontal.svg puzzleicon/16x16/roll.png puzzleicon/16x16/template.png + puzzleicon/svg/cursor_rotate.svg diff --git a/src/app/puzzle/share/resources/puzzleicon/64x64/cursorRotate.png b/src/app/puzzle/share/resources/puzzleicon/64x64/cursorRotate.png index a9ade2aee..831f77ed0 100644 Binary files a/src/app/puzzle/share/resources/puzzleicon/64x64/cursorRotate.png and b/src/app/puzzle/share/resources/puzzleicon/64x64/cursorRotate.png differ diff --git a/src/app/puzzle/share/resources/puzzleicon/64x64/cursorRotate@2x.png b/src/app/puzzle/share/resources/puzzleicon/64x64/cursorRotate@2x.png index 0bde89ddb..4cb07973b 100644 Binary files a/src/app/puzzle/share/resources/puzzleicon/64x64/cursorRotate@2x.png and b/src/app/puzzle/share/resources/puzzleicon/64x64/cursorRotate@2x.png differ diff --git a/src/app/puzzle/share/resources/puzzleicon/svg/cursor_rotate.svg b/src/app/puzzle/share/resources/puzzleicon/svg/cursor_rotate.svg index f5b2423cb..2bc7aa1ac 100644 --- a/src/app/puzzle/share/resources/puzzleicon/svg/cursor_rotate.svg +++ b/src/app/puzzle/share/resources/puzzleicon/svg/cursor_rotate.svg @@ -1,6 +1,4 @@ - - - - + viewBox="0 0 128 128" + sodipodi:docname="cursor_rotate.svg" + inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)" + inkscape:export-filename="/home/ronan/Workspace_cpp/valentina/src/app/puzzle/share/resources/puzzleicon/64x64/cursorRotate@2x.png" + inkscape:export-xdpi="96" + inkscape:export-ydpi="96"> + id="metadata899"> @@ -52,16 +29,38 @@ + + + inkscape:label="Image" + id="g901"> + id="path1502" + style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-variant-east-asian:normal;font-feature-settings:normal;font-variation-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;shape-margin:0;inline-size:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:16.112;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate;stop-color:#000000;stop-opacity:1" + d="M 67.494019,3 C 45.635979,3 26.4721,14.832798 15.842825,32.458789 L 0,20.886257 10.290418,67.03627 50.234036,44.059307 30.104959,39.845618 c 7.88695,-12.507886 21.673605,-20.733626 37.38906,-20.733626 24.548563,0 44.393991,20.068893 44.393991,45.180711 0,25.111817 -19.845428,45.178617 -44.393991,45.178617 -18.793455,0 -34.829896,-11.76047 -41.31635,-28.542147 -12.799702,5.691961 -3.295568,1.770075 -14.669238,6.556583 C 20.55829,109.77568 42.229103,125.58331 67.494019,125.58331 100.88055,125.58331 128,97.98361 128,64.292703 128,30.601797 100.88055,3 67.494019,3 Z" + sodipodi:nodetypes="scccccsssccsss" /> diff --git a/src/app/puzzle/vpgraphicspiece.cpp b/src/app/puzzle/vpgraphicspiece.cpp index fda68e039..c0973ce34 100644 --- a/src/app/puzzle/vpgraphicspiece.cpp +++ b/src/app/puzzle/vpgraphicspiece.cpp @@ -31,13 +31,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include "vppiece.h" #include "vppiecelist.h" @@ -61,8 +61,13 @@ VPGraphicsPiece::VPGraphicsPiece(VPPiece *piece, QGraphicsItem *parent) : m_internalPaths(QVector()), m_internalPathsPenStyle(QVector()), m_placeLabels(QVector()), - m_rotationStartPoint(QPointF()) + m_rotationStartPoint(QPointF()), + m_rotateCursor(QCursor()) { + + QPixmap cursor_pixmap = QIcon("://puzzleicon/svg/cursor_rotate.svg").pixmap(QSize(32,32)); + m_rotateCursor= QCursor(cursor_pixmap, 16, 16); + Init(); } @@ -276,11 +281,24 @@ void VPGraphicsPiece::mousePressEvent(QGraphicsSceneMouseEvent *event) //perform the default behaviour QGraphicsItem::mousePressEvent(event); - // change the cursor when clicking left button + // change the cursor when clicking the left button + if((event->button() == Qt::LeftButton)) + { + if(event->modifiers() & Qt::AltModifier) + { + setCursor(m_rotateCursor); + } + else + { + setCursor(Qt::ClosedHandCursor); + } + } + + + // change the selected state when clicking left button if (event->button() == Qt::LeftButton) { setSelected(true); - setCursor(Qt::ClosedHandCursor); if (event->modifiers() & Qt::ControlModifier) { @@ -295,12 +313,6 @@ void VPGraphicsPiece::mousePressEvent(QGraphicsSceneMouseEvent *event) if((event->button() == Qt::LeftButton) && (event->modifiers() & Qt::AltModifier)) { m_rotationStartPoint = event->scenePos(); - - QPixmap cursor_pixmap = QPixmap(":/cursor_rotate"); - cursor_pixmap = cursor_pixmap.scaledToWidth(32); - QCursor cursor_rotate = QCursor(cursor_pixmap, 16, 16); - - setCursor(cursor_rotate); } } @@ -309,6 +321,8 @@ void VPGraphicsPiece::mouseMoveEvent(QGraphicsSceneMouseEvent * event) { if((event->buttons() == Qt::LeftButton) && (event->modifiers() & Qt::AltModifier)) { + //FIXME: it flickers between the arrow cursor and the rotate cursor + setCursor(m_rotateCursor); QPointF rotationNewPoint = event->scenePos(); QPointF rotationCenter = sceneBoundingRect().center(); @@ -365,20 +379,14 @@ void VPGraphicsPiece::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) //--------------------------------------------------------------------------------------------------------------------- void VPGraphicsPiece::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { - if(event->modifiers() & Qt::AltModifier) { - // TODO FIXME: find a more efficient way - - QPixmap cursor_pixmap = QPixmap(":/cursor_rotate"); - cursor_pixmap = cursor_pixmap.scaledToWidth(32); - QCursor cursor_rotate = QCursor(cursor_pixmap, 16, 16); - - setCursor(cursor_rotate); + //FIXME: it flickers between the arrow cursor and the rotate cursor + setCursor(m_rotateCursor); } else { - setCursor(QCursor(Qt::OpenHandCursor)); + setCursor(Qt::OpenHandCursor); } } diff --git a/src/app/puzzle/vpgraphicspiece.h b/src/app/puzzle/vpgraphicspiece.h index aefcca155..f7238a759 100644 --- a/src/app/puzzle/vpgraphicspiece.h +++ b/src/app/puzzle/vpgraphicspiece.h @@ -30,6 +30,7 @@ #define VPGRAPHICSPIECE_H #include +#include class VPPiece; @@ -105,6 +106,8 @@ private: QVector m_placeLabels; QPointF m_rotationStartPoint; + + QCursor m_rotateCursor; }; #endif // VPGRAPHICSPIECE_H