Disable resizing pattern piece after full parsing.

--HG--
branch : develop
This commit is contained in:
dismine 2014-07-16 11:45:42 +03:00
parent 4b9e40175a
commit d3624f7060
2 changed files with 31 additions and 21 deletions

View File

@ -189,7 +189,7 @@ void MainWindow::ActionNewPP()
return; return;
} }
disconnect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), disconnect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &MainWindow::currentDrawChanged); this, &MainWindow::currentPPChanged);
comboBoxDraws->addItem(patternPieceName); comboBoxDraws->addItem(patternPieceName);
pattern->ClearGObjects(); pattern->ClearGObjects();
@ -217,7 +217,7 @@ void MainWindow::ActionNewPP()
comboBoxDraws->setCurrentIndex(0); comboBoxDraws->setCurrentIndex(0);
} }
connect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, connect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&MainWindow::currentDrawChanged); &MainWindow::currentPPChanged);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -1037,7 +1037,7 @@ void MainWindow::ToolBarDraws()
ui->toolBarDraws->addWidget(comboBoxDraws); ui->toolBarDraws->addWidget(comboBoxDraws);
comboBoxDraws->setSizeAdjustPolicy(QComboBox::AdjustToContents); comboBoxDraws->setSizeAdjustPolicy(QComboBox::AdjustToContents);
connect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), connect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &MainWindow::currentDrawChanged); this, &MainWindow::currentPPChanged);
ui->toolBarDraws->addAction(ui->actionOptionDraw); ui->toolBarDraws->addAction(ui->actionOptionDraw);
ui->actionOptionDraw->setEnabled(false); 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. * @param index index in combobox.
*/ */
void MainWindow::currentDrawChanged( int index ) void MainWindow::currentPPChanged(int index)
{ {
if (index != -1) ChangePP(index);
{
doc->ChangeActivPP(comboBoxDraws->itemText(index));
doc->setCurrentData();
if (drawMode)
{
ArrowTool();
view->fitInView(doc->ActiveDrawBoundingRect(), Qt::KeepAspectRatio);
view->NewFactor(view->transform().m11());
}
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -1587,11 +1577,11 @@ void MainWindow::FullParseFile()
patternPiece = comboBoxDraws->itemText(comboBoxDraws->currentIndex()); patternPiece = comboBoxDraws->itemText(comboBoxDraws->currentIndex());
} }
disconnect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), disconnect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &MainWindow::currentDrawChanged); this, &MainWindow::currentPPChanged);
comboBoxDraws->clear(); comboBoxDraws->clear();
comboBoxDraws->addItems(doc->getPatternPieces()); comboBoxDraws->addItems(doc->getPatternPieces());
connect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), connect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &MainWindow::currentDrawChanged); this, &MainWindow::currentPPChanged);
ui->actionPattern_properties->setEnabled(true); ui->actionPattern_properties->setEnabled(true);
qint32 index = comboBoxDraws->findText(patternPiece); qint32 index = comboBoxDraws->findText(patternPiece);
@ -1599,11 +1589,11 @@ void MainWindow::FullParseFile()
{ {
if ( index != -1 ) if ( index != -1 )
{ // -1 for not found { // -1 for not found
currentDrawChanged(index); ChangePP(index, false);
} }
else else
{ {
currentDrawChanged(0); ChangePP(0, false);
} }
} }
catch (VExceptionBadId &e) 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());
}
}
}
}

View File

@ -78,7 +78,7 @@ public slots:
void OpenRecentFile(); void OpenRecentFile();
void Clear(); void Clear();
void currentDrawChanged( int index ); void currentPPChanged(int index);
void OptionDraw(); void OptionDraw();
void ChangedSize(const QString &text); void ChangedSize(const QString &text);
void ChangedHeight(const QString & text); void ChangedHeight(const QString & text);
@ -257,6 +257,7 @@ private:
void OpenPattern(const QString &filePath); void OpenPattern(const QString &filePath);
template <typename Func> template <typename Func>
void SetGradationList(const QString &label, const QStringList &list, Func changeSlot); void SetGradationList(const QString &label, const QStringList &list, Func changeSlot);
void ChangePP(int index , bool zoomBestFit = true);
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H