fix: use SmoothTransformation when scale factor less than 100%
This commit is contained in:
parent
8fe860e4bf
commit
f49ed645fc
|
@ -60,6 +60,17 @@ void GraphicsScene::showGif(const QString &filepath)
|
|||
this->setSceneRect(m_theThing->boundingRect());
|
||||
}
|
||||
|
||||
bool GraphicsScene::trySetTransformationMode(Qt::TransformationMode mode)
|
||||
{
|
||||
QGraphicsPixmapItem * pixmapItem = qgraphicsitem_cast<QGraphicsPixmapItem *>(m_theThing);
|
||||
if (pixmapItem) {
|
||||
pixmapItem->setTransformationMode(mode);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QPixmap GraphicsScene::renderToPixmap()
|
||||
{
|
||||
QPixmap pixmap(sceneRect().toRect().size());
|
||||
|
|
|
@ -15,6 +15,8 @@ public:
|
|||
void showSvg(const QString &filepath);
|
||||
void showGif(const QString &filepath);
|
||||
|
||||
bool trySetTransformationMode(Qt::TransformationMode mode);
|
||||
|
||||
QPixmap renderToPixmap();
|
||||
|
||||
private:
|
||||
|
|
|
@ -117,6 +117,7 @@ void GraphicsView::zoomView(qreal scaleFactor)
|
|||
{
|
||||
m_enableFitInView = false;
|
||||
scale(scaleFactor, scaleFactor);
|
||||
applyTransformationModeByScaleFactor();
|
||||
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), m_rotateAngle);
|
||||
}
|
||||
|
||||
|
@ -136,6 +137,7 @@ void GraphicsView::rotateView(qreal rotateAngel)
|
|||
void GraphicsView::fitInView(const QRectF &rect, Qt::AspectRatioMode aspectRadioMode)
|
||||
{
|
||||
QGraphicsView::fitInView(rect, aspectRadioMode);
|
||||
applyTransformationModeByScaleFactor();
|
||||
}
|
||||
|
||||
void GraphicsView::checkAndDoFitInView()
|
||||
|
@ -298,6 +300,15 @@ void GraphicsView::setCheckerboardEnabled(bool enabled)
|
|||
}
|
||||
}
|
||||
|
||||
void GraphicsView::applyTransformationModeByScaleFactor()
|
||||
{
|
||||
if (this->scaleFactor() < 1) {
|
||||
scene()->trySetTransformationMode(Qt::SmoothTransformation);
|
||||
} else {
|
||||
scene()->trySetTransformationMode(Qt::FastTransformation);
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicsView::resetWithScaleAndRotate(qreal scaleFactor, qreal rotateAngle)
|
||||
{
|
||||
QGraphicsView::resetTransform();
|
||||
|
|
|
@ -54,6 +54,7 @@ private:
|
|||
bool isThingSmallerThanWindowWith(const QTransform &transform) const;
|
||||
bool shouldIgnoreMousePressMoveEvent(const QMouseEvent *event) const;
|
||||
void setCheckerboardEnabled(bool enabled);
|
||||
void applyTransformationModeByScaleFactor();
|
||||
|
||||
void resetWithScaleAndRotate(qreal scaleFactor, qreal rotateAngle);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user