diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index 376dfcaa6..e94be27c1 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -1067,6 +1067,9 @@ void MainWindow::ToolBarTools() Qt::ControlModifier + Qt::Key_Minus + Qt::KeypadModifier}; ui->actionZoomOut->setShortcuts(zoomOutShortcuts); connect(ui->actionZoomOut, &QAction::triggered, view, &VMainGraphicsView::ZoomOut); + + connect(ui->actionZoomOriginal, &QAction::triggered, view, &VMainGraphicsView::ZoomOriginal); + connect(ui->actionZoomFitBest, &QAction::triggered, view, &VMainGraphicsView::ZoomFitBest); } //--------------------------------------------------------------------------------------------------------------------- @@ -1737,6 +1740,8 @@ void MainWindow::SetEnableWidgets(bool enable) ui->actionEdit_pattern_code->setEnabled(enable); ui->actionZoomIn->setEnabled(enable); ui->actionZoomOut->setEnabled(enable); + ui->actionZoomFitBest->setEnabled(enable); + ui->actionZoomOriginal->setEnabled(enable); } //--------------------------------------------------------------------------------------------------------------------- @@ -2179,6 +2184,10 @@ MainWindow::~MainWindow() */ void MainWindow::LoadPattern(const QString &fileName) { + // Fit scene to view + VAbstractTool::NewSceneRect(sceneDraw, view); + VAbstractTool::NewSceneRect(sceneDetails, view); + qApp->setOpeningPattern();//Begin opening file try { @@ -2231,6 +2240,15 @@ void MainWindow::LoadPattern(const QString &fileName) helpLabel->setText(tr("File loaded")); qApp->setOpeningPattern();// End opening file + + VAbstractTool::NewSceneRect(sceneDraw, view); + VAbstractTool::NewSceneRect(sceneDetails, view); + + ActionDetails(true); + view->ZoomFitBest(); + + ActionDraw(true); + view->ZoomFitBest(); } //--------------------------------------------------------------------------------------------------------------------- @@ -2292,9 +2310,6 @@ void MainWindow::OpenPattern(const QString &filePath) if (curFile.isEmpty() && this->isWindowModified() == false) { LoadPattern(filePath); - - VAbstractTool::NewSceneRect(sceneDraw, view); - VAbstractTool::NewSceneRect(sceneDetails, view); } else { diff --git a/src/app/mainwindow.ui b/src/app/mainwindow.ui index 3bce59e51..5c7b8c73d 100644 --- a/src/app/mainwindow.ui +++ b/src/app/mainwindow.ui @@ -47,7 +47,7 @@ 0 0 - 150 + 144 150 @@ -302,7 +302,7 @@ 0 0 - 150 + 100 58 @@ -378,7 +378,7 @@ 0 0 - 150 + 100 104 @@ -579,7 +579,7 @@ 0 0 - 150 + 100 58 @@ -779,6 +779,8 @@ + + @@ -1062,6 +1064,28 @@ Edit pattern XML code + + + false + + + + + + ZoomOriginal + + + + + false + + + + + + ZoomFitBest + + diff --git a/src/app/share/resources/icons/win.icon.theme/16x16/actions/zoom-fit-best.png b/src/app/share/resources/icons/win.icon.theme/16x16/actions/zoom-fit-best.png new file mode 100644 index 000000000..fbba7abda Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/16x16/actions/zoom-fit-best.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/16x16/actions/zoom-original.png b/src/app/share/resources/icons/win.icon.theme/16x16/actions/zoom-original.png new file mode 100644 index 000000000..61a4118ae Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/16x16/actions/zoom-original.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/24x24/actions/zoom-fit-best.png b/src/app/share/resources/icons/win.icon.theme/24x24/actions/zoom-fit-best.png new file mode 100644 index 000000000..80a56b918 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/24x24/actions/zoom-fit-best.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/24x24/actions/zoom-in.png b/src/app/share/resources/icons/win.icon.theme/24x24/actions/zoom-in.png index 64606208e..fe0fb3a8e 100644 Binary files a/src/app/share/resources/icons/win.icon.theme/24x24/actions/zoom-in.png and b/src/app/share/resources/icons/win.icon.theme/24x24/actions/zoom-in.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/24x24/actions/zoom-original.png b/src/app/share/resources/icons/win.icon.theme/24x24/actions/zoom-original.png new file mode 100644 index 000000000..37c2c8f86 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/24x24/actions/zoom-original.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/24x24/actions/zoom-out.png b/src/app/share/resources/icons/win.icon.theme/24x24/actions/zoom-out.png index 61fc868ea..f605abbbf 100644 Binary files a/src/app/share/resources/icons/win.icon.theme/24x24/actions/zoom-out.png and b/src/app/share/resources/icons/win.icon.theme/24x24/actions/zoom-out.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/actions/zoom-fit-best.png b/src/app/share/resources/icons/win.icon.theme/32x32/actions/zoom-fit-best.png new file mode 100644 index 000000000..3b4a67890 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/32x32/actions/zoom-fit-best.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/actions/zoom-original.png b/src/app/share/resources/icons/win.icon.theme/32x32/actions/zoom-original.png new file mode 100644 index 000000000..23faebbc1 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/32x32/actions/zoom-original.png differ diff --git a/src/app/share/resources/theme.qrc b/src/app/share/resources/theme.qrc index efa266e2b..7a3862edc 100644 --- a/src/app/share/resources/theme.qrc +++ b/src/app/share/resources/theme.qrc @@ -43,5 +43,11 @@ icons/win.icon.theme/16x16/actions/go-down.png icons/win.icon.theme/24x24/actions/go-down.png icons/win.icon.theme/32x32/actions/go-down.png + icons/win.icon.theme/16x16/actions/zoom-fit-best.png + icons/win.icon.theme/16x16/actions/zoom-original.png + icons/win.icon.theme/24x24/actions/zoom-fit-best.png + icons/win.icon.theme/24x24/actions/zoom-original.png + icons/win.icon.theme/32x32/actions/zoom-fit-best.png + icons/win.icon.theme/32x32/actions/zoom-original.png diff --git a/src/app/widgets/vgraphicssimpletextitem.cpp b/src/app/widgets/vgraphicssimpletextitem.cpp index 62076f3d5..34012b5d7 100644 --- a/src/app/widgets/vgraphicssimpletextitem.cpp +++ b/src/app/widgets/vgraphicssimpletextitem.cpp @@ -43,7 +43,7 @@ VGraphicsSimpleTextItem::VGraphicsSimpleTextItem(QGraphicsItem * parent) this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); this->setAcceptHoverEvents(true); QFont font = this->font(); - font.setPointSize(font.pointSize()+3); + font.setPointSize(font.pointSize()+20); fontSize = font.pointSize(); this->setFont(font); } diff --git a/src/app/widgets/vmaingraphicsview.cpp b/src/app/widgets/vmaingraphicsview.cpp index b59ba8114..1e597d23c 100644 --- a/src/app/widgets/vmaingraphicsview.cpp +++ b/src/app/widgets/vmaingraphicsview.cpp @@ -158,6 +158,33 @@ void VMainGraphicsView::ZoomOut() emit NewFactor(1.0/1.1); } +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsView::ZoomOriginal() +{ + QTransform trans = this->transform(); + trans.setMatrix(1.0, trans.m12(), trans.m13(), trans.m21(), 1.0, trans.m23(), trans.m31(), trans.m32(), + trans.m33()); + this->setTransform(trans); + VAbstractTool::NewSceneRect(this->scene(), this); + emit NewFactor(1.0); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsView::ZoomFitBest() +{ + QRectF rect = this->scene()->itemsBoundingRect(); + + if (rect.isEmpty()) + { + return; + } + + this->fitInView(rect,Qt::KeepAspectRatio); + VAbstractTool::NewSceneRect(this->scene(), this); + QTransform trans = this->transform(); + emit NewFactor(trans.m11()); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief mousePressEvent handle mouse press events. diff --git a/src/app/widgets/vmaingraphicsview.h b/src/app/widgets/vmaingraphicsview.h index c275ab525..d67981bf9 100644 --- a/src/app/widgets/vmaingraphicsview.h +++ b/src/app/widgets/vmaingraphicsview.h @@ -52,6 +52,8 @@ public slots: void animFinished(); void ZoomIn(); void ZoomOut(); + void ZoomOriginal(); + void ZoomFitBest(); protected: void wheelEvent ( QWheelEvent * event ); void mousePressEvent(QMouseEvent *mousePress);