Nicer rotate cursor
This commit is contained in:
parent
214d46ffcf
commit
bbe27ec671
|
@ -9,12 +9,12 @@
|
|||
<file>puzzleicon/64x64/iconPortrait.png</file>
|
||||
<file>puzzleicon/64x64/iconGrainlineVertical.png</file>
|
||||
<file>puzzleicon/64x64/iconGrainlineHorizontal.png</file>
|
||||
<file alias="cursor_rotate">puzzleicon/64x64/cursorRotate.png</file>
|
||||
<file>puzzleicon/64x64/iconProperties.png</file>
|
||||
<file>puzzleicon/svg/icon_scissors.svg</file>
|
||||
<file>puzzleicon/svg/icon_scissors_vertical.svg</file>
|
||||
<file>puzzleicon/svg/icon_scissors_horizontal.svg</file>
|
||||
<file>puzzleicon/16x16/roll.png</file>
|
||||
<file>puzzleicon/16x16/template.png</file>
|
||||
<file>puzzleicon/svg/cursor_rotate.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.8 KiB |
|
@ -1,6 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
|
@ -9,39 +7,18 @@
|
|||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
id="svg893"
|
||||
width="128"
|
||||
height="128"
|
||||
viewBox="0 0 33.866666 33.866668"
|
||||
version="1.1"
|
||||
id="svg8"
|
||||
sodipodi:docname="icon_rotate.svg"
|
||||
inkscape:export-filename="/home/ronan/Desktop/iconRotate.png"
|
||||
inkscape:export-xdpi="48"
|
||||
inkscape:export-ydpi="48"
|
||||
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)">
|
||||
<defs
|
||||
id="defs2" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="1.4142136"
|
||||
inkscape:cx="-73.50406"
|
||||
inkscape:cy="-5.7476577"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
units="px"
|
||||
inkscape:window-width="1487"
|
||||
inkscape:window-height="906"
|
||||
inkscape:window-x="648"
|
||||
inkscape:window-y="365"
|
||||
inkscape:window-maximized="0" />
|
||||
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">
|
||||
<metadata
|
||||
id="metadata5">
|
||||
id="metadata899">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
|
@ -52,16 +29,38 @@
|
|||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs897" />
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1943"
|
||||
inkscape:window-height="957"
|
||||
id="namedview895"
|
||||
showgrid="false"
|
||||
inkscape:zoom="3.8141593"
|
||||
inkscape:cx="-9.2984942"
|
||||
inkscape:cy="78.770819"
|
||||
inkscape:window-x="-163"
|
||||
inkscape:window-y="86"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="g901"
|
||||
showguides="false"
|
||||
inkscape:lockguides="false" />
|
||||
<g
|
||||
inkscape:label="Ebene 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(0,-263.13332)">
|
||||
inkscape:label="Image"
|
||||
id="g901">
|
||||
<path
|
||||
style="fill:#000000;fill-opacity:0.99622641;stroke:#000000;stroke-width:0.56587124;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 7.0186194,287.41283 -6.32117702,-9.61886 4.59283552,0.0718 c 0.2260142,-13.99266 14.6277861,-19.32352 24.6168741,-9.04316 8.326613,8.56942 1.645094,23.6663 -11.704329,23.56294 l -0.02016,4.07882 -9.3161816,-5.90315 9.3649386,-5.23047 -0.0097,3.75053 c 12.855101,-0.23223 15.657569,-13.03558 9.321879,-19.01152 -6.380838,-6.01853 -18.7084318,-6.45152 -19.0255146,7.87916 l 4.6551916,0.099 z"
|
||||
id="path873"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccscccccsccc" />
|
||||
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" />
|
||||
</g>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 3.8 KiB |
|
@ -31,13 +31,13 @@
|
|||
#include <QPen>
|
||||
#include <QBrush>
|
||||
#include <QPainter>
|
||||
#include <QCursor>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
#include <QGraphicsSceneContextMenuEvent>
|
||||
#include <QMenu>
|
||||
#include <QtMath>
|
||||
#include <QGraphicsScene>
|
||||
#include <QApplication>
|
||||
|
||||
#include "vppiece.h"
|
||||
#include "vppiecelist.h"
|
||||
|
@ -61,8 +61,13 @@ VPGraphicsPiece::VPGraphicsPiece(VPPiece *piece, QGraphicsItem *parent) :
|
|||
m_internalPaths(QVector<QPainterPath>()),
|
||||
m_internalPathsPenStyle(QVector<Qt::PenStyle>()),
|
||||
m_placeLabels(QVector<QPainterPath>()),
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#define VPGRAPHICSPIECE_H
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include <QCursor>
|
||||
|
||||
class VPPiece;
|
||||
|
||||
|
@ -105,6 +106,8 @@ private:
|
|||
QVector<QPainterPath> m_placeLabels;
|
||||
|
||||
QPointF m_rotationStartPoint;
|
||||
|
||||
QCursor m_rotateCursor;
|
||||
};
|
||||
|
||||
#endif // VPGRAPHICSPIECE_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user