3 Commits

7 changed files with 35 additions and 13 deletions

View File

@ -6,7 +6,7 @@ include (GNUInstallDirs)
set (CMAKE_AUTOMOC ON)
set (CMAKE_AUTORCC ON)
set (QT_MINIMUM_VERSION "5.7.1")
set (QT_MINIMUM_VERSION "5.10")
find_package(Qt5 ${QT_MINIMUM_VERSION} CONFIG REQUIRED Widgets Svg LinguistTools)

View File

@ -1,11 +1,8 @@
environment:
matrix:
- build_name: mingw73_32_qt5_12_5
QTPATH: C:\Qt\5.12.5\mingw73_32
- build_name: mingw73_32_qt5_12_6
QTPATH: C:\Qt\5.12.6\mingw73_32
MINGW32: C:\Qt\Tools\mingw730_32
# - build_name: msvc2017_64
# QTPATH: C:\Qt\5.11.2\msvc2017_64
# MINGW32: C:\Qt\Tools\mingw530_32
install:
- cd %APPVEYOR_BUILD_FOLDER%

View File

@ -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());

View File

@ -15,6 +15,8 @@ public:
void showSvg(const QString &filepath);
void showGif(const QString &filepath);
bool trySetTransformationMode(Qt::TransformationMode mode);
QPixmap renderToPixmap();
private:

View File

@ -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()
@ -213,9 +215,9 @@ void GraphicsView::dragEnterEvent(QDragEnterEvent *event)
} else {
event->ignore();
}
qDebug() << event->mimeData() << "Drag Enter Event"
<< event->mimeData()->hasUrls() << event->mimeData()->hasImage()
<< event->mimeData()->formats() << event->mimeData()->hasFormat("text/uri-list");
// qDebug() << event->mimeData() << "Drag Enter Event"
// << event->mimeData()->hasUrls() << event->mimeData()->hasImage()
// << event->mimeData()->formats() << event->mimeData()->hasFormat("text/uri-list");
return QGraphicsView::dragEnterEvent(event);
}
@ -285,9 +287,9 @@ void GraphicsView::setCheckerboardEnabled(bool enabled)
if (m_checkerboardEnabled) {
// Prepare background check-board pattern
QPixmap tilePixmap(0x20, 0x20);
tilePixmap.fill(QColor(35, 35, 35, 110));
tilePixmap.fill(QColor(35, 35, 35, 170));
QPainter tilePainter(&tilePixmap);
QColor color(40, 40, 40, 110);
QColor color(45, 45, 45, 170);
tilePainter.fillRect(0, 0, 0x10, 0x10, color);
tilePainter.fillRect(0x10, 0x10, 0x10, 0x10, color);
tilePainter.end();
@ -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();

View File

@ -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);

View File

@ -268,8 +268,8 @@ void MainWindow::mousePressEvent(QMouseEvent *event)
if (event->buttons() & Qt::LeftButton && !isMaximized()) {
m_clickedOnWindow = true;
m_oldMousePos = event->pos();
qDebug() << m_oldMousePos << m_graphicsView->transform().m11()
<< m_graphicsView->transform().m22() << m_graphicsView->matrix().m12();
// qDebug() << m_oldMousePos << m_graphicsView->transform().m11()
// << m_graphicsView->transform().m22() << m_graphicsView->matrix().m12();
event->accept();
}