diff --git a/ChangeLog.txt b/ChangeLog.txt index 422978267..a7c97399e 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -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. diff --git a/src/app/puzzle/vpapplication.cpp b/src/app/puzzle/vpapplication.cpp index a2534dca4..e32f73f0f 100644 --- a/src/app/puzzle/vpapplication.cpp +++ b/src/app/puzzle/vpapplication.cpp @@ -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 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; } diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 6e9e70388..1f4fb2388 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -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 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);