diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index b7e24a78b..3ef5a7360 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -85,6 +85,8 @@ MainWindow::MainWindow(QWidget *parent) helpLabel = new QLabel(QObject::tr("Create new pattern piece to start working.")); ui->statusBar->addWidget(helpLabel); + ToolBarZoom(); + pattern = new VContainer(); doc = new VPattern(pattern, comboBoxDraws, &mode); @@ -843,6 +845,24 @@ void MainWindow::ToolBarDraws() ui->actionLayout->setEnabled(false); } +void MainWindow::ToolBarZoom() +{ + /*First we will try use Standard Shortcuts from Qt, but because keypad "-" and "+" not the same keys like in main + keypad, shortcut Ctrl+"-" or "+" from keypad will not working with standard shortcut (QKeySequence::ZoomIn or + QKeySequence::ZoomOut). For examle "+" is Qt::Key_Plus + Qt::KeypadModifier for keypad. + Also for me don't work Qt:CTRL and work Qt::ControlModifier.*/ + + const QList zoomInShortcuts = {QKeySequence::ZoomIn, + Qt::ControlModifier + Qt::Key_Plus + Qt::KeypadModifier}; + ui->actionZoomIn->setShortcuts(zoomInShortcuts); + connect(ui->actionZoomIn, &QAction::triggered, view, &VMainGraphicsView::ZoomIn); + + const QList zoomOutShortcuts = {QKeySequence::ZoomOut, + Qt::ControlModifier + Qt::Key_Minus + Qt::KeypadModifier}; + ui->actionZoomOut->setShortcuts(zoomOutShortcuts); + connect(ui->actionZoomOut, &QAction::triggered, view, &VMainGraphicsView::ZoomOut); +} + //--------------------------------------------------------------------------------------------------------------------- void MainWindow::InitToolButtons() { @@ -1300,6 +1320,8 @@ void MainWindow::Clear() ui->actionOptionDraw->setEnabled(false); ui->actionSave->setEnabled(false); ui->actionPattern_properties->setEnabled(false); + ui->actionZoomIn->setEnabled(false); + ui->actionZoomOut->setEnabled(false); SetEnableTool(false); qApp->setPatternUnit(Valentina::Cm); qApp->setPatternType(Pattern::Individual); @@ -1374,6 +1396,8 @@ void MainWindow::SetEnableWidgets(bool enable) } ui->actionTable->setEnabled(enable); ui->actionHistory->setEnabled(enable); + ui->actionZoomIn->setEnabled(enable); + ui->actionZoomOut->setEnabled(enable); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/mainwindow.h b/src/app/mainwindow.h index df9eb14b3..5fe2a1c1e 100644 --- a/src/app/mainwindow.h +++ b/src/app/mainwindow.h @@ -203,6 +203,7 @@ private: QTimer *autoSaveTimer; void ToolBarOption(); void ToolBarDraws(); + void ToolBarZoom(); void InitToolButtons(); void CancelTool(); void ArrowTool(); diff --git a/src/app/mainwindow.ui b/src/app/mainwindow.ui index e3bdbaa57..9e5a75a61 100644 --- a/src/app/mainwindow.ui +++ b/src/app/mainwindow.ui @@ -694,6 +694,8 @@ + + @@ -757,6 +759,19 @@ false + + + toolBar_2 + + + TopToolBarArea + + + false + + + + @@ -1002,6 +1017,34 @@ Pattern properties + + + false + + + + + + Zoom In + + + zoom in + + + + + false + + + + + + Zoom Out + + + Zoom out + + diff --git a/src/app/widgets/vmaingraphicsview.cpp b/src/app/widgets/vmaingraphicsview.cpp index 5ba1cc11c..d60616362 100644 --- a/src/app/widgets/vmaingraphicsview.cpp +++ b/src/app/widgets/vmaingraphicsview.cpp @@ -123,6 +123,22 @@ void VMainGraphicsView::animFinished() sender()->~QObject(); } +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsView::ZoomIn() +{ + scale(1.1, 1.1); + VAbstractTool::NewSceneRect(this->scene(), this); + emit NewFactor(1.1); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsView::ZoomOut() +{ + scale(1.0/1.1, 1.0/1.1); + VAbstractTool::NewSceneRect(this->scene(), this); + emit NewFactor(1.0/1.1); +} + //--------------------------------------------------------------------------------------------------------------------- void VMainGraphicsView::mousePressEvent(QMouseEvent *mousePress) { diff --git a/src/app/widgets/vmaingraphicsview.h b/src/app/widgets/vmaingraphicsview.h index a2d1a5bed..aa87b9be2 100644 --- a/src/app/widgets/vmaingraphicsview.h +++ b/src/app/widgets/vmaingraphicsview.h @@ -64,6 +64,8 @@ public slots: * @brief animFinished */ void animFinished(); + void ZoomIn(); + void ZoomOut(); protected: /** * @brief wheelEvent handle wheel events.