Removed some compiler warnings and set the resize cursor when label is being resized
--HG-- branch : feature
This commit is contained in:
parent
a557b99409
commit
e5f7c47828
|
@ -439,6 +439,28 @@ void SetOverrideCursor(const QString &pixmapPath, int hotX, int hotY)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void SetOverrideCursor(Qt::CursorShape shape)
|
||||||
|
{
|
||||||
|
#ifndef QT_NO_CURSOR
|
||||||
|
QPixmap oldPixmap;
|
||||||
|
QCursor* pOldCursor = QGuiApplication::overrideCursor();
|
||||||
|
if (pOldCursor != 0)
|
||||||
|
{
|
||||||
|
oldPixmap = pOldCursor->pixmap();
|
||||||
|
}
|
||||||
|
QCursor cursor(shape);
|
||||||
|
QPixmap newPixmap = cursor.pixmap();
|
||||||
|
if (oldPixmap.toImage() != newPixmap.toImage())
|
||||||
|
{
|
||||||
|
QApplication::setOverrideCursor(cursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
Q_UNUSED(shape);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void RestoreOverrideCursor(const QString &pixmapPath)
|
void RestoreOverrideCursor(const QString &pixmapPath)
|
||||||
{
|
{
|
||||||
|
|
|
@ -595,8 +595,10 @@ extern const QString trueStr;
|
||||||
extern const QString falseStr;
|
extern const QString falseStr;
|
||||||
|
|
||||||
void SetOverrideCursor(const QString & pixmapPath, int hotX = -1, int hotY = -1);
|
void SetOverrideCursor(const QString & pixmapPath, int hotX = -1, int hotY = -1);
|
||||||
|
void SetOverrideCursor(Qt::CursorShape shape);
|
||||||
void RestoreOverrideCursor(const QString & pixmapPath);
|
void RestoreOverrideCursor(const QString & pixmapPath);
|
||||||
|
|
||||||
|
|
||||||
extern const qreal PrintDPI;
|
extern const qreal PrintDPI;
|
||||||
|
|
||||||
double ToPixel(double val, const Unit &unit) Q_REQUIRED_RESULT;
|
double ToPixel(double val, const Unit &unit) Q_REQUIRED_RESULT;
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QTransform>
|
#include <QTransform>
|
||||||
|
#include <QCursor>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
|
@ -95,7 +96,7 @@ void VTextGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
||||||
fnt.setWeight(tl.m_eFontWeight);
|
fnt.setWeight(tl.m_eFontWeight);
|
||||||
fnt.setStyle(tl.m_eStyle);
|
fnt.setStyle(tl.m_eStyle);
|
||||||
painter->setFont(fnt);
|
painter->setFont(fnt);
|
||||||
painter->drawText(0, iY, boundingRect().width(), iH, tl.m_eAlign, tl.m_qsText);
|
painter->drawText(0, iY, qRound(boundingRect().width()), iH, tl.m_eAlign, tl.m_qsText);
|
||||||
iY += iH + SPACING;
|
iY += iH + SPACING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,8 +114,8 @@ void VTextGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
||||||
|
|
||||||
if (m_eMode == mResize)
|
if (m_eMode == mResize)
|
||||||
{
|
{
|
||||||
painter->drawLine(0, 0, m_rectBoundingBox.width(), m_rectBoundingBox.height());
|
painter->drawLine(0, 0, qRound(m_rectBoundingBox.width()), qRound(m_rectBoundingBox.height()));
|
||||||
painter->drawLine(0, m_rectBoundingBox.height(), m_rectBoundingBox.width(), 0);
|
painter->drawLine(0, qRound(m_rectBoundingBox.height()), qRound(m_rectBoundingBox.width()), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -130,8 +131,8 @@ void VTextGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
||||||
painter->setBrush(Qt::NoBrush);
|
painter->setBrush(Qt::NoBrush);
|
||||||
int iTop = ROTATE_RECT - ROTATE_ARC;
|
int iTop = ROTATE_RECT - ROTATE_ARC;
|
||||||
int iLeft = ROTATE_RECT - ROTATE_ARC;
|
int iLeft = ROTATE_RECT - ROTATE_ARC;
|
||||||
int iRight = m_rectBoundingBox.width() - ROTATE_RECT;
|
int iRight = qRound(m_rectBoundingBox.width()) - ROTATE_RECT;
|
||||||
int iBottom = m_rectBoundingBox.height() - ROTATE_RECT;
|
int iBottom = qRound(m_rectBoundingBox.height()) - ROTATE_RECT;
|
||||||
painter->drawArc(iLeft, iTop, ROTATE_ARC, ROTATE_ARC, 180*16, -90*16);
|
painter->drawArc(iLeft, iTop, ROTATE_ARC, ROTATE_ARC, 180*16, -90*16);
|
||||||
painter->drawArc(iRight, iTop, ROTATE_ARC, ROTATE_ARC, 90*16, -90*16);
|
painter->drawArc(iRight, iTop, ROTATE_ARC, ROTATE_ARC, 90*16, -90*16);
|
||||||
painter->drawArc(iLeft, iBottom, ROTATE_ARC, ROTATE_ARC, 270*16, -90*16);
|
painter->drawArc(iLeft, iBottom, ROTATE_ARC, ROTATE_ARC, 270*16, -90*16);
|
||||||
|
@ -221,6 +222,7 @@ void VTextGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *pME)
|
||||||
if (m_rectResize.contains(pME->pos()) == true)
|
if (m_rectResize.contains(pME->pos()) == true)
|
||||||
{
|
{
|
||||||
m_eMode = mResize;
|
m_eMode = mResize;
|
||||||
|
SetOverrideCursor(Qt::SizeFDiagCursor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -236,6 +238,14 @@ void VTextGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *pME)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VTextGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent* pME)
|
void VTextGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent* pME)
|
||||||
{
|
{
|
||||||
|
if (m_rectResize.contains(pME->pos()) == true)
|
||||||
|
{
|
||||||
|
SetOverrideCursor(Qt::SizeFDiagCursor);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RestoreOverrideCursor(cursorArrowOpenHand);
|
||||||
|
}
|
||||||
QPointF ptDiff = pME->scenePos() - m_ptStart;
|
QPointF ptDiff = pME->scenePos() - m_ptStart;
|
||||||
if (m_eMode == mMove)
|
if (m_eMode == mMove)
|
||||||
{
|
{
|
||||||
|
|
|
@ -797,7 +797,6 @@ void VToolDetail::UpdatePatternInfo()
|
||||||
if (boundingRect().contains(pt) == false)
|
if (boundingRect().contains(pt) == false)
|
||||||
{
|
{
|
||||||
QRectF rect = boundingRect();
|
QRectF rect = boundingRect();
|
||||||
qDebug() << "FALSE" << rect << pt << pt.x() - rect.left();
|
|
||||||
pt.setX(qMin(rect.right(), qMax(pt.x(), rect.left())));
|
pt.setX(qMin(rect.right(), qMax(pt.x(), rect.left())));
|
||||||
pt.setY(qMin(rect.bottom(), qMax(pt.y(), rect.top())));
|
pt.setY(qMin(rect.bottom(), qMax(pt.y(), rect.top())));
|
||||||
pt.setX(pt.x() - geom.GetLabelWidth()/2);
|
pt.setX(pt.x() - geom.GetLabelWidth()/2);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user