Change behavior of new pattern piece dialog.
Button Cancel did not cancel creating a new pattern piece.
This commit is contained in:
parent
89d0dd4815
commit
cf51f3837d
|
@ -2143,13 +2143,13 @@ void MainWindow::ToolBarDraws()
|
||||||
|
|
||||||
connect(ui->actionOptionDraw, &QAction::triggered, this, [this]()
|
connect(ui->actionOptionDraw, &QAction::triggered, this, [this]()
|
||||||
{
|
{
|
||||||
const QString activDraw = doc->GetNameActivPP();
|
QString draw = doc->GetNameActivPP();
|
||||||
const QString nameDraw = PatternPieceName(activDraw);
|
bool ok = PatternPieceName(draw);
|
||||||
if (nameDraw.isEmpty() || activDraw == nameDraw)
|
if (not ok)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qApp->getUndoStack()->push(new RenamePP(doc, nameDraw, comboBoxDraws));
|
qApp->getUndoStack()->push(new RenamePP(doc, draw, comboBoxDraws));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4524,11 +4524,10 @@ void MainWindow::CreateActions()
|
||||||
qCDebug(vMainWindow, "Generated PP name: %s", qUtf8Printable(patternPieceName));
|
qCDebug(vMainWindow, "Generated PP name: %s", qUtf8Printable(patternPieceName));
|
||||||
|
|
||||||
qCDebug(vMainWindow, "PP count %d", comboBoxDraws->count());
|
qCDebug(vMainWindow, "PP count %d", comboBoxDraws->count());
|
||||||
patternPieceName = PatternPieceName(patternPieceName);
|
bool ok = PatternPieceName(patternPieceName);
|
||||||
qCDebug(vMainWindow, "PP name: %s", qUtf8Printable(patternPieceName));
|
qCDebug(vMainWindow, "PP name: %s", qUtf8Printable(patternPieceName));
|
||||||
if (patternPieceName.isEmpty())
|
if (not ok)
|
||||||
{
|
{
|
||||||
qCDebug(vMainWindow, "Name empty.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4733,7 +4732,7 @@ void MainWindow::InitAutoSave()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString MainWindow::PatternPieceName(const QString &text)
|
bool MainWindow::PatternPieceName(QString &name)
|
||||||
{
|
{
|
||||||
QScopedPointer<QInputDialog> dlg(new QInputDialog(this));
|
QScopedPointer<QInputDialog> dlg(new QInputDialog(this));
|
||||||
dlg->setInputMode( QInputDialog::TextInput );
|
dlg->setInputMode( QInputDialog::TextInput );
|
||||||
|
@ -4741,23 +4740,29 @@ QString MainWindow::PatternPieceName(const QString &text)
|
||||||
dlg->setTextEchoMode(QLineEdit::Normal);
|
dlg->setTextEchoMode(QLineEdit::Normal);
|
||||||
dlg->setWindowTitle(tr("Enter a new label for the pattern piece."));
|
dlg->setWindowTitle(tr("Enter a new label for the pattern piece."));
|
||||||
dlg->resize(300, 100);
|
dlg->resize(300, 100);
|
||||||
dlg->setTextValue(text);
|
dlg->setTextValue(name);
|
||||||
QString nameDraw;
|
QString nameDraw;
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
const bool bOk = dlg->exec();
|
const bool bOk = dlg->exec();
|
||||||
nameDraw = dlg->textValue();
|
nameDraw = dlg->textValue();
|
||||||
if (bOk == false || nameDraw.isEmpty() || text == nameDraw)
|
if (not bOk)
|
||||||
{
|
{
|
||||||
return text;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nameDraw.isEmpty())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (comboBoxDraws->findText(nameDraw) == -1)
|
if (comboBoxDraws->findText(nameDraw) == -1)
|
||||||
{
|
{
|
||||||
break;//repeate show dialog
|
name = nameDraw;
|
||||||
|
break;// unique name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nameDraw;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -335,7 +335,7 @@ private:
|
||||||
void CreateMenus();
|
void CreateMenus();
|
||||||
void CreateActions();
|
void CreateActions();
|
||||||
void InitAutoSave();
|
void InitAutoSave();
|
||||||
QString PatternPieceName(const QString &text);
|
bool PatternPieceName(QString &name);
|
||||||
QString CheckPathToMeasurements(const QString &patternPath, const QString &path);
|
QString CheckPathToMeasurements(const QString &patternPath, const QString &path);
|
||||||
QComboBox *SetGradationList(QLabel *label, const QStringList &list);
|
QComboBox *SetGradationList(QLabel *label, const QStringList &list);
|
||||||
void ChangePP(int index, bool zoomBestFit = true);
|
void ChangePP(int index, bool zoomBestFit = true);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user