From d3624f70600d9715e3884d398e875a54e17f119d Mon Sep 17 00:00:00 2001 From: dismine Date: Wed, 16 Jul 2014 11:45:42 +0300 Subject: [PATCH] Disable resizing pattern piece after full parsing. --HG-- branch : develop --- src/app/mainwindow.cpp | 49 +++++++++++++++++++++++++----------------- src/app/mainwindow.h | 3 ++- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index ea1a4f2c9..31bfed5dc 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -189,7 +189,7 @@ void MainWindow::ActionNewPP() return; } disconnect(comboBoxDraws, static_cast(&QComboBox::currentIndexChanged), - this, &MainWindow::currentDrawChanged); + this, &MainWindow::currentPPChanged); comboBoxDraws->addItem(patternPieceName); pattern->ClearGObjects(); @@ -217,7 +217,7 @@ void MainWindow::ActionNewPP() comboBoxDraws->setCurrentIndex(0); } connect(comboBoxDraws, static_cast(&QComboBox::currentIndexChanged), this, - &MainWindow::currentDrawChanged); + &MainWindow::currentPPChanged); } //--------------------------------------------------------------------------------------------------------------------- @@ -1037,7 +1037,7 @@ void MainWindow::ToolBarDraws() ui->toolBarDraws->addWidget(comboBoxDraws); comboBoxDraws->setSizeAdjustPolicy(QComboBox::AdjustToContents); connect(comboBoxDraws, static_cast(&QComboBox::currentIndexChanged), - this, &MainWindow::currentDrawChanged); + this, &MainWindow::currentPPChanged); ui->toolBarDraws->addAction(ui->actionOptionDraw); ui->actionOptionDraw->setEnabled(false); @@ -1101,22 +1101,12 @@ void MainWindow::InitToolButtons() //--------------------------------------------------------------------------------------------------------------------- /** - * @brief currentDrawChanged change active pattern peace. + * @brief currentPPChanged change active pattern piece. * @param index index in combobox. */ -void MainWindow::currentDrawChanged( int index ) +void MainWindow::currentPPChanged(int index) { - if (index != -1) - { - doc->ChangeActivPP(comboBoxDraws->itemText(index)); - doc->setCurrentData(); - if (drawMode) - { - ArrowTool(); - view->fitInView(doc->ActiveDrawBoundingRect(), Qt::KeepAspectRatio); - view->NewFactor(view->transform().m11()); - } - } + ChangePP(index); } //--------------------------------------------------------------------------------------------------------------------- @@ -1587,11 +1577,11 @@ void MainWindow::FullParseFile() patternPiece = comboBoxDraws->itemText(comboBoxDraws->currentIndex()); } disconnect(comboBoxDraws, static_cast(&QComboBox::currentIndexChanged), - this, &MainWindow::currentDrawChanged); + this, &MainWindow::currentPPChanged); comboBoxDraws->clear(); comboBoxDraws->addItems(doc->getPatternPieces()); connect(comboBoxDraws, static_cast(&QComboBox::currentIndexChanged), - this, &MainWindow::currentDrawChanged); + this, &MainWindow::currentPPChanged); ui->actionPattern_properties->setEnabled(true); qint32 index = comboBoxDraws->findText(patternPiece); @@ -1599,11 +1589,11 @@ void MainWindow::FullParseFile() { if ( index != -1 ) { // -1 for not found - currentDrawChanged(index); + ChangePP(index, false); } else { - currentDrawChanged(0); + ChangePP(0, false); } } catch (VExceptionBadId &e) @@ -2319,3 +2309,22 @@ void MainWindow::OpenPattern(const QString &filePath) } } } + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ChangePP(int index, bool zoomBestFit) +{ + if (index != -1) + { + doc->ChangeActivPP(comboBoxDraws->itemText(index)); + doc->setCurrentData(); + if (drawMode) + { + ArrowTool(); + if (zoomBestFit) + { + view->fitInView(doc->ActiveDrawBoundingRect(), Qt::KeepAspectRatio); + view->NewFactor(view->transform().m11()); + } + } + } +} diff --git a/src/app/mainwindow.h b/src/app/mainwindow.h index f96f8c446..862f2e069 100644 --- a/src/app/mainwindow.h +++ b/src/app/mainwindow.h @@ -78,7 +78,7 @@ public slots: void OpenRecentFile(); void Clear(); - void currentDrawChanged( int index ); + void currentPPChanged(int index); void OptionDraw(); void ChangedSize(const QString &text); void ChangedHeight(const QString & text); @@ -257,6 +257,7 @@ private: void OpenPattern(const QString &filePath); template void SetGradationList(const QString &label, const QStringList &list, Func changeSlot); + void ChangePP(int index , bool zoomBestFit = true); }; #endif // MAINWINDOW_H