Puzzle app. Fix updating layout when file already opened.

This commit is contained in:
Roman Telezhynskyi 2023-10-13 18:07:48 +03:00
parent ff27cb217a
commit a312e154b7
3 changed files with 21 additions and 8 deletions

View file

@ -47,6 +47,7 @@
- Validate sheet and layout names before proposing file name.
- Puzzle app. Fix piece position move when update layout data.
- Puzzle app. Fix losing selection by piece.
- Puzzle app. Fix updating layout when file already opened.
# Valentina 0.7.52 September 12, 2022
- Fix crash when default locale is ru.

View file

@ -697,9 +697,23 @@ auto VPApplication::StartWithFiles(const VPCommandLinePtr &cmd, const QStringLis
{
if (not cmd->IsGuiEnabled())
{
delete MainWindow();
return false; // process only one input file
}
delete MainWindow();
if (not rawLayouts.isEmpty())
{
// Maybe already opened
QList<VPMainWindow *> list = VPApplication::VApp()->MainWindows();
auto w = std::find_if(list.begin(), list.end(),
[arg](VPMainWindow *window) { return window->CurrentFile() == arg; });
if (w != list.end())
{
(*w)->activateWindow();
(*w)->ImportRawLayouts(rawLayouts);
}
}
continue;
}

View file

@ -4217,7 +4217,7 @@ void MainWindow::on_actionOpenPuzzle_triggered()
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::on_actionCreateManualLayout_triggered()
{
QTemporaryFile rldFile(QDir::tempPath() + "/puzzle.rld.XXXXXX");
QTemporaryFile rldFile(QDir::tempPath() + "/puzzle.rld.XXXXXX"_L1);
if (rldFile.open())
{
QVector<DetailForLayout> detailsInLayout = SortDetailsForLayout(pattern->DataPieces());
@ -4238,8 +4238,7 @@ void MainWindow::on_actionCreateManualLayout_triggered()
}
catch (VException &e)
{
QMessageBox::warning(this, tr("Export details"),
tr("Can't export details.") + QStringLiteral(" \n") + e.ErrorMessage(),
QMessageBox::warning(this, tr("Export details"), tr("Can't export details.") + " \n"_L1 + e.ErrorMessage(),
QMessageBox::Ok, QMessageBox::Ok);
return;
}
@ -4274,7 +4273,7 @@ void MainWindow::on_actionCreateManualLayout_triggered()
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::on_actionUpdateManualLayout_triggered()
{
const QString filter(tr("Manual layout files") + QStringLiteral(" (*.vlt)"));
const QString filter(tr("Manual layout files") + " (*.vlt)"_L1);
VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings();
@ -4290,7 +4289,7 @@ void MainWindow::on_actionUpdateManualLayout_triggered()
settings->SetPathManualLayouts(QFileInfo(filePath).absolutePath());
QTemporaryFile rldFile(QDir::tempPath() + "/puzzle.rld.XXXXXX");
QTemporaryFile rldFile(QDir::tempPath() + "/puzzle.rld.XXXXXX"_L1);
rldFile.setAutoRemove(false);
if (rldFile.open())
{
@ -4312,8 +4311,7 @@ void MainWindow::on_actionUpdateManualLayout_triggered()
}
catch (VException &e)
{
QMessageBox::warning(this, tr("Export details"),
tr("Can't export details.") + QStringLiteral(" \n") + e.ErrorMessage(),
QMessageBox::warning(this, tr("Export details"), tr("Can't export details.") + " \n"_L1 + e.ErrorMessage(),
QMessageBox::Ok, QMessageBox::Ok);
return;
}
@ -4332,7 +4330,7 @@ void MainWindow::on_actionUpdateManualLayout_triggered()
QStringList arguments{filePath, "-r", rldFile.fileName()};
if (isNoScaling)
{
arguments.append(QStringLiteral("--") + LONG_OPTION_NO_HDPI_SCALING);
arguments.append("--"_L1 + LONG_OPTION_NO_HDPI_SCALING);
}
rldFile.setAutoRemove(false);