From 713ad813ff0ea89a407039e556abcad8fbe72fbd Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 16 Oct 2021 13:49:36 +0300 Subject: [PATCH] Allow Valentina to open vlt files on Mac. --- dist/macx/valentina/Info.plist | 24 +++++++++++- share/fabric-pattern.svg | 1 + src/app/valentina/mainwindow.cpp | 67 +++++++++++++++++++++----------- 3 files changed, 68 insertions(+), 24 deletions(-) create mode 100644 share/fabric-pattern.svg diff --git a/dist/macx/valentina/Info.plist b/dist/macx/valentina/Info.plist index 84b551f86..58c3650a7 100755 --- a/dist/macx/valentina/Info.plist +++ b/dist/macx/valentina/Info.plist @@ -134,7 +134,29 @@ vst public.mime-type - text/xml + text/xml + + + + UTTypeConformsTo + + public.text + public.xml + + UTTypeDescription + Valentina layout + UTTypeIconFile + layout.icns + UTTypeIdentifier + io.bitbucket.valentinaproject.vlt + UTTypeTagSpecification + + public.filename-extension + + vlt + + public.mime-type + text/xml diff --git a/share/fabric-pattern.svg b/share/fabric-pattern.svg new file mode 100644 index 000000000..ea8a0350f --- /dev/null +++ b/share/fabric-pattern.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 13f5aa567..71382c2e9 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -5327,39 +5327,60 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) return false; } - try + if (fileName.endsWith(".vit") || fileName.endsWith(".vst")) { - // Here comes undocumented Valentina's feature. - // Because app bundle in Mac OS X doesn't allow setup assosiation for Tape we must do this through Valentina - VMeasurements m(pattern); - m.setXMLContent(fileName); - - if (m.Type() == MeasurementsType::Multisize || m.Type() == MeasurementsType::Individual) + try { - const QString tape = VApplication::VApp()->TapeFilePath(); - const QString workingDirectory = QFileInfo(tape).absoluteDir().absolutePath(); + // Here comes undocumented Valentina's feature. + // Because app bundle in Mac OS X doesn't allow setup assosiation for Tape we must do this through Valentina + VMeasurements m(pattern); + m.setXMLContent(fileName); - QStringList arguments = QStringList() << fileName; - if (isNoScaling) + if (m.Type() == MeasurementsType::Multisize || m.Type() == MeasurementsType::Individual) { - arguments.append(QLatin1String("--") + LONG_OPTION_NO_HDPI_SCALING); - } + const QString tape = VApplication::VApp()->TapeFilePath(); + const QString workingDirectory = QFileInfo(tape).absoluteDir().absolutePath(); - QProcess::startDetached(tape, arguments, workingDirectory); - qApp->exit(V_EX_OK); - return false; // stop continue processing + QStringList arguments = QStringList() << fileName; + if (isNoScaling) + { + arguments.append(QLatin1String("--") + LONG_OPTION_NO_HDPI_SCALING); + } + + QProcess::startDetached(tape, arguments, workingDirectory); + qApp->exit(V_EX_OK); + return false; // stop continue processing + } + } + catch (VException &e) + { + qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")), + qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + Clear(); + if (not VApplication::IsGUIMode()) + { + qApp->exit(V_EX_NOINPUT); + } + return false; } } - catch (VException &e) + + if (fileName.endsWith(".vlt")) { - qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); - Clear(); - if (not VApplication::IsGUIMode()) + // Here comes undocumented Valentina's feature. + // Because app bundle in Mac OS X doesn't allow setup assosiation for Puzzle we must do this through Valentina + const QString puzzle = VApplication::VApp()->PuzzleFilePath(); + const QString workingDirectory = QFileInfo(puzzle).absoluteDir().absolutePath(); + + QStringList arguments = QStringList() << fileName; + if (isNoScaling) { - qApp->exit(V_EX_NOINPUT); + arguments.append(QLatin1String("--") + LONG_OPTION_NO_HDPI_SCALING); } - return false; + + QProcess::startDetached(puzzle, arguments, workingDirectory); + qApp->exit(V_EX_OK); + return false; // stop continue processing } qCDebug(vMainWindow, "Loking file");