Merge branch 'develop' into feature/manual-layout

This commit is contained in:
Roman Telezhynskyi 2020-12-23 18:40:33 +02:00
commit a58a783aba
97 changed files with 2658 additions and 1484 deletions

View File

@ -1,9 +1,19 @@
# Version 0.7.41 (unreleased) # Version 0.7.42 (unreleased)
- Fix export of pattern recipe.
- Update translations.
- Fix a regression in tool Segment a spline path.
- Fix invalid visualization for tool Point of intersection circles.
- New warning. Warn about empty measurements dimension value when preparing placeholders.
- New option "Don't use the native file dialog".
- Improve the layout option "Auto crop unused width".
# Version 0.7.41 Dec 4, 2020
- Bug fixes. - Bug fixes.
- Improve canceling nesting. - Improve canceling nesting.
- Fix incorrect nesting status for valid cases. - Fix incorrect nesting status for valid cases.
- Improve crossing check for the layout algorithm. - Improve crossing check for the layout algorithm.
- Fix crash after creating an elliptical arc. - Fix crash after creating an elliptical arc.
- New option Reset label position.
# Version 0.7.40 Nov 23, 2020 # Version 0.7.40 Nov 23, 2020
- New function Warning. - New function Warning.

View File

@ -258,7 +258,7 @@ deploy:
package: valentina-win_auto-upload package: valentina-win_auto-upload
publish: true publish: true
override: true override: true
version: 0.7.40 version: 0.7.41
on: on:
DEPLOY: true DEPLOY: true
artifact: valentina-win-$(QT_VERSION)-$(APPVEYOR_REPO_BRANCH)-$(APPVEYOR_REPO_COMMIT) artifact: valentina-win-$(QT_VERSION)-$(APPVEYOR_REPO_BRANCH)-$(APPVEYOR_REPO_COMMIT)

View File

@ -1,5 +1,5 @@
valentina (0.7.40) trusty; urgency=low valentina (0.7.41) trusty; urgency=low
* Auto build. * Auto build.
-- dismine <dismine@dismine-To-be-filled-by-O-E-M> Mon, 23 Nov 2020 16:30:00 +0300 -- dismine <dismine@dismine-To-be-filled-by-O-E-M> Fri, 4 Dec 2020 16:30:00 +0300

View File

@ -1,5 +1,5 @@
valentina (0.7.40) trusty; urgency=low valentina (0.7.41) trusty; urgency=low
* Auto build. * Auto build.
-- dismine <dismine@dismine-To-be-filled-by-O-E-M> Mon, 23 Nov 2020 16:30:00 +0300 -- dismine <dismine@dismine-To-be-filled-by-O-E-M> Fri, 4 Dec 2020 16:30:00 +0300

View File

@ -19,9 +19,9 @@
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>io.bitbucket.valentinaproject.@EXECUTABLE@</string> <string>io.bitbucket.valentinaproject.@EXECUTABLE@</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>0.7.40</string> <string>0.7.41</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>0.7.40.0</string> <string>0.7.41.0</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string> <string>6.0</string>
<key>CFBundleDocumentTypes</key> <key>CFBundleDocumentTypes</key>

View File

@ -19,9 +19,9 @@
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>io.bitbucket.valentinaproject.@EXECUTABLE@</string> <string>io.bitbucket.valentinaproject.@EXECUTABLE@</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>0.7.40</string> <string>0.7.41</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>0.7.40.0</string> <string>0.7.41.0</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string> <string>6.0</string>
<key>CFBundleDocumentTypes</key> <key>CFBundleDocumentTypes</key>

2
dist/rpm/_service vendored
View File

@ -1,7 +1,7 @@
<services> <services>
<service name="tar_scm"> <service name="tar_scm">
<param name="url">git://github.com/dismine/Valentina_git.git</param> <param name="url">git://github.com/dismine/Valentina_git.git</param>
<param name="versionprefix">0.7.40</param> <param name="versionprefix">0.7.41</param>
<param name="filename">valentina</param> <param name="filename">valentina</param>
<param name="scm">git</param> <param name="scm">git</param>
<param name="exclude">.git</param> <param name="exclude">.git</param>

View File

@ -91,7 +91,7 @@ Requires: poppler-tools
Requires: poppler-utils Requires: poppler-utils
%endif %endif
Version: 0.7.40 Version: 0.7.41
Release: 0 Release: 0
URL: https://gitlab.com/smart-pattern/valentina URL: https://gitlab.com/smart-pattern/valentina
License: GPL-3.0+ License: GPL-3.0+

8
dist/valentina.dsc vendored
View File

@ -2,7 +2,7 @@ Format: 3.0 (native)
Source: valentina Source: valentina
Binary: valentina Binary: valentina
Architecture: i386 amd64 Architecture: i386 amd64
Version: 0.7.40 Version: 0.7.41
Maintainer: Roman Telezhynskyi <dismine@gmail.com> Maintainer: Roman Telezhynskyi <dismine@gmail.com>
Homepage: https://valentinaproject.bitbucket.io Homepage: https://valentinaproject.bitbucket.io
Standards-Version: 3.9.5 Standards-Version: 3.9.5
@ -18,8 +18,8 @@ Build-Depends: debhelper (>= 8.0.0),
Package-List: Package-List:
valentina deb graphics optional valentina deb graphics optional
Checksums-Sha1: Checksums-Sha1:
581eb1bf36b4ab7126b5983d809130f15396859e 24838101 valentina_0.7.40.tar 581eb1bf36b4ab7126b5983d809130f15396859e 24838101 valentina_0.7.41.tar
Checksums-Sha256: Checksums-Sha256:
9b156c7120a69b90373efb8ca9998c3e0563a60ad337210166cfd41b00b0f13c 24838101 valentina_0.7.40.tar 9b156c7120a69b90373efb8ca9998c3e0563a60ad337210166cfd41b00b0f13c 24838101 valentina_0.7.41.tar
Files: Files:
95677e29d3a59cf5b064f7be236a4b78 24838101 valentina_0.7.40.tar 95677e29d3a59cf5b064f7be236a4b78 24838101 valentina_0.7.41.tar

View File

@ -15,10 +15,10 @@
}, },
"version": { "version": {
"name": "0.7.40", "name": "0.7.41",
"desc": "Test branch release", "desc": "Test branch release",
"released": "2020-11-23", "released": "2020-12-4",
"vcs_tag": "v0.7.40", "vcs_tag": "v0.7.41",
"gpgSign": false "gpgSign": false
}, },

View File

@ -14057,6 +14057,10 @@ Do you want to save your changes?</translation>
<source>Show label</source> <source>Show label</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Restore label position</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>VException</name> <name>VException</name>

View File

@ -13721,6 +13721,10 @@ Chcete uložit změny?</translation>
<source>Show label</source> <source>Show label</source>
<translation>Ukázat popis</translation> <translation>Ukázat popis</translation>
</message> </message>
<message>
<source>Restore label position</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>VException</name> <name>VException</name>
@ -15280,7 +15284,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
</message> </message>
<message> <message>
<source>Point of intersection circle and segment</source> <source>Point of intersection circle and segment</source>
<translation type="unfinished">Průsečík kruhu a části</translation> <translation>Průsečík kruhu a části</translation>
</message> </message>
</context> </context>
<context> <context>

View File

@ -13714,6 +13714,10 @@ Do you want to save your changes?</source>
<source>Show label</source> <source>Show label</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Restore label position</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>VException</name> <name>VException</name>
@ -15230,7 +15234,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
</message> </message>
<message> <message>
<source>Point of intersection circle and segment</source> <source>Point of intersection circle and segment</source>
<translation type="unfinished">Punkt am Schnittpunkt von Kreis und Abschnitt</translation> <translation>Punkt am Schnittpunkt von Kreis und Abschnitt</translation>
</message> </message>
</context> </context>
<context> <context>

View File

@ -13212,6 +13212,10 @@ Do you want to save your changes?</source>
<source>Show label</source> <source>Show label</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Restore label position</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>VException</name> <name>VException</name>

View File

@ -13668,6 +13668,10 @@ Do you want to save your changes?</translation>
<source>Show label</source> <source>Show label</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Restore label position</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>VException</name> <name>VException</name>

View File

@ -13668,6 +13668,10 @@ Do you want to save your changes?</translation>
<source>Show label</source> <source>Show label</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Restore label position</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>VException</name> <name>VException</name>

View File

@ -13668,6 +13668,10 @@ Do you want to save your changes?</translation>
<source>Show label</source> <source>Show label</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Restore label position</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>VException</name> <name>VException</name>

View File

@ -13726,6 +13726,10 @@ Quieres guardar los cambios?</translation>
<source>Show label</source> <source>Show label</source>
<translation>Mostrar estiqueta</translation> <translation>Mostrar estiqueta</translation>
</message> </message>
<message>
<source>Restore label position</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>VException</name> <name>VException</name>
@ -15285,7 +15289,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
</message> </message>
<message> <message>
<source>Point of intersection circle and segment</source> <source>Point of intersection circle and segment</source>
<translation type="unfinished">Punto de intersección circulo y segmento</translation> <translation>Punto de intersección circulo y segmento</translation>
</message> </message>
</context> </context>
<context> <context>

View File

@ -12177,6 +12177,10 @@ Do you want to save your changes?</source>
<source>Show label</source> <source>Show label</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Restore label position</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>VException</name> <name>VException</name>

View File

@ -13639,6 +13639,10 @@ Voulez-vous enregistrer les changements?</translation>
<source>Show label</source> <source>Show label</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Restore label position</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>VException</name> <name>VException</name>

View File

@ -10894,6 +10894,10 @@ Do you want to save your changes?</source>
<source>Show label</source> <source>Show label</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Restore label position</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>VException</name> <name>VException</name>

View File

@ -11278,6 +11278,10 @@ Do you want to save your changes?</source>
<source>Show label</source> <source>Show label</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Restore label position</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>VException</name> <name>VException</name>

View File

@ -13600,6 +13600,10 @@ Vuoi salvare le tue modifiche?</translation>
<source>Show label</source> <source>Show label</source>
<translation>Mostra etichetta</translation> <translation>Mostra etichetta</translation>
</message> </message>
<message>
<source>Restore label position</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>VException</name> <name>VException</name>

View File

@ -12342,6 +12342,10 @@ Do you want to save your changes?</source>
<source>Show label</source> <source>Show label</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Restore label position</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>VException</name> <name>VException</name>
@ -15364,27 +15368,27 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
</message> </message>
<message> <message>
<source>Select all</source> <source>Select all</source>
<translation type="unfinished"></translation> <translation>Zaznaczono wszystko</translation>
</message> </message>
<message> <message>
<source>Select none</source> <source>Select none</source>
<translation type="unfinished"></translation> <translation>Zaznaczenie jest puste</translation>
</message> </message>
<message> <message>
<source>select all details</source> <source>select all details</source>
<translation type="unfinished"></translation> <translation>wybrano wszystkie szczegóły</translation>
</message> </message>
<message> <message>
<source>select none details</source> <source>select none details</source>
<translation type="unfinished"></translation> <translation>nie wybrano szczegółów</translation>
</message> </message>
<message> <message>
<source>Invert selection</source> <source>Invert selection</source>
<translation type="unfinished"></translation> <translation>Odwróć zaznaczenie</translation>
</message> </message>
<message> <message>
<source>invert selection</source> <source>invert selection</source>
<translation type="unfinished"></translation> <translation>Odwróć zaznaczenie</translation>
</message> </message>
<message> <message>
<source>Hide not in layout</source> <source>Hide not in layout</source>
@ -15755,7 +15759,19 @@ Do you want to save your changes?</source>
</message> </message>
<message> <message>
<source>INFO:</source> <source>INFO:</source>
<translation type="unfinished"></translation> <translation>INFORMACJA:</translation>
</message>
<message>
<source>Warning.</source>
<translation type="vanished">Ostrzeżenie.</translation>
</message>
<message>
<source>Critical error.</source>
<translation type="vanished">Błąd krytyczny.</translation>
</message>
<message>
<source>Fatal error.</source>
<translation type="vanished">Błąd krytyczny.</translation>
</message> </message>
<message> <message>
<source>Information.</source> <source>Information.</source>
@ -15763,15 +15779,15 @@ Do you want to save your changes?</source>
</message> </message>
<message> <message>
<source>Warning</source> <source>Warning</source>
<translation type="unfinished"></translation> <translation>Ostrzeżenie</translation>
</message> </message>
<message> <message>
<source>Critical error</source> <source>Critical error</source>
<translation type="unfinished"></translation> <translation>Błąd krytyczny</translation>
</message> </message>
<message> <message>
<source>Fatal error</source> <source>Fatal error</source>
<translation type="unfinished"></translation> <translation>Błąd krytyczny</translation>
</message> </message>
<message> <message>
<source>Information</source> <source>Information</source>
@ -15798,7 +15814,19 @@ Do you want to save your changes?</source>
</message> </message>
<message> <message>
<source>INFO:</source> <source>INFO:</source>
<translation type="unfinished"></translation> <translation>INFORMACJA:</translation>
</message>
<message>
<source>Warning.</source>
<translation type="vanished">Ostrzeżenie.</translation>
</message>
<message>
<source>Critical error.</source>
<translation type="vanished">Błąd krytyczny.</translation>
</message>
<message>
<source>Fatal error.</source>
<translation type="vanished">Błąd krytyczny.</translation>
</message> </message>
<message> <message>
<source>Information.</source> <source>Information.</source>
@ -15806,15 +15834,15 @@ Do you want to save your changes?</source>
</message> </message>
<message> <message>
<source>Warning</source> <source>Warning</source>
<translation type="unfinished"></translation> <translation>Ostrzeżenie</translation>
</message> </message>
<message> <message>
<source>Critical error</source> <source>Critical error</source>
<translation type="unfinished"></translation> <translation>Błąd krytyczny</translation>
</message> </message>
<message> <message>
<source>Fatal error</source> <source>Fatal error</source>
<translation type="unfinished"></translation> <translation>Błąd krytyczny</translation>
</message> </message>
<message> <message>
<source>Information</source> <source>Information</source>

View File

@ -13627,6 +13627,10 @@ Deseja salvar suas mudanças?</translation>
<source>Show label</source> <source>Show label</source>
<translation>Mostrar rótulo</translation> <translation>Mostrar rótulo</translation>
</message> </message>
<message>
<source>Restore label position</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>VException</name> <name>VException</name>

View File

@ -12059,6 +12059,10 @@ Do you want to save your changes?</source>
<source>Show label</source> <source>Show label</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Restore label position</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>VException</name> <name>VException</name>

View File

@ -3377,7 +3377,7 @@
</message> </message>
<message> <message>
<source>Insert nodes</source> <source>Insert nodes</source>
<translation type="unfinished"></translation> <translation>Вставить узлы</translation>
</message> </message>
<message> <message>
<source>Delete</source> <source>Delete</source>
@ -8886,7 +8886,7 @@ Do you want to save your changes?</source>
</message> </message>
<message> <message>
<source>The measurements file &lt;br/&gt;&lt;br/&gt; &lt;b&gt;%1&lt;/b&gt; &lt;br/&gt;&lt;br/&gt; could not be found. Do you want to update the file location?</source> <source>The measurements file &lt;br/&gt;&lt;br/&gt; &lt;b&gt;%1&lt;/b&gt; &lt;br/&gt;&lt;br/&gt; could not be found. Do you want to update the file location?</source>
<translation>Файл меток &lt;br/&gt;&lt;br/&gt; &lt;b&gt;%1&lt;/b&gt; &lt;br/&gt;&lt;br/&gt; не найден. Вы хотите обновить данные о местоположении файла?</translation> <translation>Файл мерок &lt;br/&gt;&lt;br/&gt; &lt;b&gt;%1&lt;/b&gt; &lt;br/&gt;&lt;br/&gt; не найден. Вы хотите обновить данные о местоположении файла?</translation>
</message> </message>
<message> <message>
<source>Flipping objects by line</source> <source>Flipping objects by line</source>
@ -13727,6 +13727,10 @@ Do you want to save your changes?</source>
<source>Show label</source> <source>Show label</source>
<translation>Показать метку</translation> <translation>Показать метку</translation>
</message> </message>
<message>
<source>Restore label position</source>
<translation>Восстановить положение метки</translation>
</message>
</context> </context>
<context> <context>
<name>VException</name> <name>VException</name>
@ -15286,7 +15290,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
</message> </message>
<message> <message>
<source>Point of intersection circle and segment</source> <source>Point of intersection circle and segment</source>
<translation type="unfinished">Точка пересечения окружности и отрезка</translation> <translation>Точка пересечения окружности и отрезка</translation>
</message> </message>
</context> </context>
<context> <context>
@ -17049,12 +17053,12 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
<message> <message>
<source>warning</source> <source>warning</source>
<comment>Calculation warning</comment> <comment>Calculation warning</comment>
<translation type="unfinished"></translation> <translation>предупреждение</translation>
</message> </message>
<message> <message>
<source>Show a warning in calculations</source> <source>Show a warning in calculations</source>
<comment>function warning</comment> <comment>function warning</comment>
<translation type="unfinished"></translation> <translation>Показывать предупреждение в расчетах</translation>
</message> </message>
</context> </context>
<context> <context>

View File

@ -13667,6 +13667,10 @@ Do you want to save your changes?</source>
<source>Show label</source> <source>Show label</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Restore label position</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>VException</name> <name>VException</name>

View File

@ -11095,6 +11095,10 @@ Do you want to save your changes?</source>
<source>Show label</source> <source>Show label</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Restore label position</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>VException</name> <name>VException</name>

View File

@ -39,12 +39,13 @@
#include "../vmisc/qt_dispatch/qt_dispatch.h" #include "../vmisc/qt_dispatch/qt_dispatch.h"
#include <QMessageBox> #include <QMessageBox>
#include <QLoggingCategory>
QT_WARNING_PUSH QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")
QT_WARNING_DISABLE_INTEL(1418) QT_WARNING_DISABLE_INTEL(1418)
Q_LOGGING_CATEGORY(mApp, "m.application") Q_LOGGING_CATEGORY(pApp, "p.application")
QT_WARNING_POP QT_WARNING_POP
@ -271,50 +272,50 @@ bool VPApplication::notify(QObject *receiver, QEvent *event)
} }
catch (const VExceptionObjectError &e) catch (const VExceptionObjectError &e)
{ {
qCCritical(mApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file. Program will be terminated.")), //-V807 qCCritical(pApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file. Program will be terminated.")), //-V807
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
exit(V_EX_DATAERR); exit(V_EX_DATAERR);
} }
catch (const VExceptionBadId &e) catch (const VExceptionBadId &e)
{ {
qCCritical(mApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error bad id. Program will be terminated.")), qCCritical(pApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error bad id. Program will be terminated.")),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
exit(V_EX_DATAERR); exit(V_EX_DATAERR);
} }
catch (const VExceptionConversionError &e) catch (const VExceptionConversionError &e)
{ {
qCCritical(mApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error can't convert value. Program will be terminated.")), qCCritical(pApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error can't convert value. Program will be terminated.")),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
exit(V_EX_DATAERR); exit(V_EX_DATAERR);
} }
catch (const VExceptionEmptyParameter &e) catch (const VExceptionEmptyParameter &e)
{ {
qCCritical(mApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error empty parameter. Program will be terminated.")), qCCritical(pApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error empty parameter. Program will be terminated.")),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
exit(V_EX_DATAERR); exit(V_EX_DATAERR);
} }
catch (const VExceptionWrongId &e) catch (const VExceptionWrongId &e)
{ {
qCCritical(mApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error wrong id. Program will be terminated.")), qCCritical(pApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error wrong id. Program will be terminated.")),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
exit(V_EX_DATAERR); exit(V_EX_DATAERR);
} }
catch (const VExceptionToolWasDeleted &e) catch (const VExceptionToolWasDeleted &e)
{ {
qCCritical(mApp, "%s\n\n%s\n\n%s", qCCritical(pApp, "%s\n\n%s\n\n%s",
qUtf8Printable("Unhadled deleting tool. Continue use object after deleting!"), qUtf8Printable("Unhadled deleting tool. Continue use object after deleting!"),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
exit(V_EX_DATAERR); exit(V_EX_DATAERR);
} }
catch (const VException &e) catch (const VException &e)
{ {
qCCritical(mApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Something's wrong!!")), qCCritical(pApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Something's wrong!!")),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
return true; return true;
} }
catch (std::exception &e) catch (std::exception &e)
{ {
qCCritical(mApp, "%s", qUtf8Printable(tr("Exception thrown: %1. Program will be terminated.").arg(e.what()))); qCCritical(pApp, "%s", qUtf8Printable(tr("Exception thrown: %1. Program will be terminated.").arg(e.what())));
exit(V_EX_SOFTWARE); exit(V_EX_SOFTWARE);
} }
return false; return false;
@ -374,12 +375,12 @@ void VPApplication::InitOptions()
OpenSettings(); OpenSettings();
qCDebug(mApp, "Version: %s", qUtf8Printable(APP_VERSION_STR)); qCDebug(pApp, "Version: %s", qUtf8Printable(APP_VERSION_STR));
qCDebug(mApp, "Build revision: %s", BUILD_REVISION); qCDebug(pApp, "Build revision: %s", BUILD_REVISION);
qCDebug(mApp, "%s", qUtf8Printable(buildCompatibilityString())); qCDebug(pApp, "%s", qUtf8Printable(buildCompatibilityString()));
qCDebug(mApp, "Built on %s at %s", __DATE__, __TIME__); qCDebug(pApp, "Built on %s at %s", __DATE__, __TIME__);
qCDebug(mApp, "Command-line arguments: %s", qUtf8Printable(arguments().join(", "))); qCDebug(pApp, "Command-line arguments: %s", qUtf8Printable(arguments().join(", ")));
qCDebug(mApp, "Process ID: %s", qUtf8Printable(QString().setNum(applicationPid()))); qCDebug(pApp, "Process ID: %s", qUtf8Printable(QString().setNum(applicationPid())));
LoadTranslation(QLocale().name());// By default the console version uses system locale LoadTranslation(QLocale().name());// By default the console version uses system locale
@ -450,7 +451,7 @@ void VPApplication::ParseCommandLine(const SocketConnection &connection, const Q
socket.connectToServer(serverName); socket.connectToServer(serverName);
if (socket.waitForConnected(1000)) if (socket.waitForConnected(1000))
{ {
qCDebug(mApp, "Connected to the server '%s'", qUtf8Printable(serverName)); qCDebug(pApp, "Connected to the server '%s'", qUtf8Printable(serverName));
QTextStream stream(&socket); QTextStream stream(&socket);
stream << arguments.join(";;"); stream << arguments.join(";;");
stream.flush(); stream.flush();
@ -459,20 +460,20 @@ void VPApplication::ParseCommandLine(const SocketConnection &connection, const Q
return; return;
} }
qCDebug(mApp, "Can't establish connection to the server '%s'", qUtf8Printable(serverName)); qCDebug(pApp, "Can't establish connection to the server '%s'", qUtf8Printable(serverName));
localServer = new QLocalServer(this); localServer = new QLocalServer(this);
connect(localServer, &QLocalServer::newConnection, this, &VPApplication::NewLocalSocketConnection); connect(localServer, &QLocalServer::newConnection, this, &VPApplication::NewLocalSocketConnection);
if (not localServer->listen(serverName)) if (not localServer->listen(serverName))
{ {
qCDebug(mApp, "Can't begin to listen for incoming connections on name '%s'", qCDebug(pApp, "Can't begin to listen for incoming connections on name '%s'",
qUtf8Printable(serverName)); qUtf8Printable(serverName));
if (localServer->serverError() == QAbstractSocket::AddressInUseError) if (localServer->serverError() == QAbstractSocket::AddressInUseError)
{ {
QLocalServer::removeServer(serverName); QLocalServer::removeServer(serverName);
if (not localServer->listen(serverName)) if (not localServer->listen(serverName))
{ {
qCWarning(mApp, "%s", qCWarning(pApp, "%s",
qUtf8Printable(tr("Can't begin to listen for incoming connections on name '%1'").arg(serverName))); qUtf8Printable(tr("Can't begin to listen for incoming connections on name '%1'").arg(serverName)));
} }
} }
@ -493,13 +494,13 @@ void VPApplication::ProcessArguments(const VPCommandLinePtr &cmd)
{ {
if (not cmd->IsGuiEnabled() && args.count() > 1) if (not cmd->IsGuiEnabled() && args.count() > 1)
{ {
qCCritical(mApp, "%s\n", qPrintable(tr("Export mode doesn't support openning several files."))); qCCritical(pApp, "%s\n", qPrintable(tr("Export mode doesn't support openning several files.")));
cmd.get()->parser.showHelp(V_EX_USAGE); cmd.get()->parser.showHelp(V_EX_USAGE);
} }
if (args.count() > 1 && rawLayouts.size() > 0) if (args.count() > 1 && rawLayouts.size() > 0)
{ {
qCCritical(mApp, "%s\n", qCCritical(pApp, "%s\n",
qPrintable(tr("Import raw layout data does not support penning several layout files."))); qPrintable(tr("Import raw layout data does not support penning several layout files.")));
cmd.get()->parser.showHelp(V_EX_USAGE); cmd.get()->parser.showHelp(V_EX_USAGE);
} }
@ -527,7 +528,7 @@ void VPApplication::ProcessArguments(const VPCommandLinePtr &cmd)
{ {
if (cmd->IsTestModeEnabled()) if (cmd->IsTestModeEnabled())
{ {
qCCritical(mApp, "%s\n", qPrintable(tr("Please, provide one input file."))); qCCritical(pApp, "%s\n", qPrintable(tr("Please, provide one input file.")));
cmd.get()->parser.showHelp(V_EX_USAGE); cmd.get()->parser.showHelp(V_EX_USAGE);
} }

View File

@ -53,7 +53,10 @@ TapePreferencesConfigurationPage::TapePreferencesConfigurationPage(QWidget *pare
ui->osOptionCheck->setChecked(qApp->TapeSettings()->GetOsSeparator()); ui->osOptionCheck->setChecked(qApp->TapeSettings()->GetOsSeparator());
// Theme // Theme
ui->darkModeCheck->setChecked(qApp->TapeSettings()->GetDarkMode()); ui->darkModeCheck->setChecked(qApp->TapeSettings()->GetDarkMode());
// Native dialogs
ui->checkBoxDontUseNativeDialog->setChecked(qApp->TapeSettings()->IsDontUseNativeDialog());
//---------------------- Pattern making system //---------------------- Pattern making system
ui->systemBookValueLabel->setFixedHeight(4 * QFontMetrics(ui->systemBookValueLabel->font()).lineSpacing()); ui->systemBookValueLabel->setFixedHeight(4 * QFontMetrics(ui->systemBookValueLabel->font()).lineSpacing());
@ -106,6 +109,11 @@ QStringList TapePreferencesConfigurationPage::Apply()
preferences.append(tr("dark mode")); preferences.append(tr("dark mode"));
} }
if (settings->IsDontUseNativeDialog() != ui->checkBoxDontUseNativeDialog->isChecked())
{
settings->SetDontUseNativeDialog(ui->checkBoxDontUseNativeDialog->isChecked());
}
if (m_langChanged || m_systemChanged) if (m_langChanged || m_systemChanged)
{ {
const QString locale = qvariant_cast<QString>(ui->langCombo->currentData()); const QString locale = qvariant_cast<QString>(ui->langCombo->currentData());

View File

@ -170,19 +170,22 @@
<property name="title"> <property name="title">
<string>User Interface</string> <string>User Interface</string>
</property> </property>
<widget class="QCheckBox" name="darkModeCheck"> <layout class="QVBoxLayout" name="verticalLayout_5">
<property name="geometry"> <item>
<rect> <widget class="QCheckBox" name="darkModeCheck">
<x>20</x> <property name="text">
<y>30</y> <string>Activate dark mode</string>
<width>351</width> </property>
<height>20</height> </widget>
</rect> </item>
</property> <item>
<property name="text"> <widget class="QCheckBox" name="checkBoxDontUseNativeDialog">
<string>Activate dark mode</string> <property name="text">
</property> <string>Don't use the native file dialog</string>
</widget> </property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
</layout> </layout>

View File

@ -149,8 +149,9 @@ void TapePreferencesPathPage::EditPath()
usedNotExistedDir = directory.mkpath(QChar('.')); usedNotExistedDir = directory.mkpath(QChar('.'));
} }
const QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), path, const QString dir = QFileDialog::getExistingDirectory(
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); this, tr("Open Directory"), path,
qApp->NativeFileDialog(QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks));
if (dir.isEmpty()) if (dir.isEmpty())
{ {
if (usedNotExistedDir) if (usedNotExistedDir)

View File

@ -520,7 +520,8 @@ void TMainWindow::CreateFromExisting()
usedNotExistedDir = directory.mkpath(QChar('.')); usedNotExistedDir = directory.mkpath(QChar('.'));
} }
const QString mPath = QFileDialog::getOpenFileName(this, tr("Select file"), pathTo, filter); const QString mPath = QFileDialog::getOpenFileName(this, tr("Select file"), pathTo, filter, nullptr,
qApp->NativeFileDialog());
if (not mPath.isEmpty()) if (not mPath.isEmpty())
{ {
@ -889,7 +890,8 @@ bool TMainWindow::FileSaveAs()
usedNotExistedDir = directory.mkpath(QChar('.')); usedNotExistedDir = directory.mkpath(QChar('.'));
} }
QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), dir + QChar('/') + fName, filters); QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), dir + QChar('/') + fName, filters, nullptr,
qApp->NativeFileDialog());
auto RemoveTempDir = qScopeGuard([usedNotExistedDir, dir]() auto RemoveTempDir = qScopeGuard([usedNotExistedDir, dir]()
{ {
@ -997,11 +999,8 @@ void TMainWindow::ImportDataFromCSV()
const QString filters = tr("Comma-Separated Values") + QStringLiteral(" (*.csv)"); const QString filters = tr("Comma-Separated Values") + QStringLiteral(" (*.csv)");
const QString suffix = QStringLiteral("csv"); const QString suffix = QStringLiteral("csv");
QString fileName = QFileDialog::getOpenFileName(this, tr("Import from CSV"), QDir::homePath(), filters, nullptr QString fileName = QFileDialog::getOpenFileName(this, tr("Import from CSV"), QDir::homePath(), filters, nullptr,
#ifdef Q_OS_LINUX qApp->NativeFileDialog());
, QFileDialog::DontUseNativeDialog
#endif
);
if (fileName.isEmpty()) if (fileName.isEmpty())
{ {
@ -1471,7 +1470,8 @@ void TMainWindow::ImportFromPattern()
//Use standard path to individual measurements //Use standard path to individual measurements
QString pathTo = qApp->TapeSettings()->GetPathPattern(); QString pathTo = qApp->TapeSettings()->GetPathPattern();
const QString mPath = QFileDialog::getOpenFileName(this, tr("Import from a pattern"), pathTo, filter); const QString mPath = QFileDialog::getOpenFileName(this, tr("Import from a pattern"), pathTo, filter, nullptr,
qApp->NativeFileDialog());
if (mPath.isEmpty()) if (mPath.isEmpty())
{ {
return; return;
@ -2189,7 +2189,7 @@ void TMainWindow::ExportToIndividual()
QString filters = tr("Individual measurements") + QStringLiteral(" (*.vit)"); QString filters = tr("Individual measurements") + QStringLiteral(" (*.vit)");
QString fName = tr("measurements.vit"); QString fName = tr("measurements.vit");
QString fileName = QFileDialog::getSaveFileName(this, tr("Export to individual"), dir + QChar('/') + fName, QString fileName = QFileDialog::getSaveFileName(this, tr("Export to individual"), dir + QChar('/') + fName,
filters); filters, nullptr, qApp->NativeFileDialog());
auto RemoveTempDir = qScopeGuard([usedNotExistedDir, dir]() auto RemoveTempDir = qScopeGuard([usedNotExistedDir, dir]()
{ {
@ -3358,7 +3358,8 @@ bool TMainWindow::EvalFormula(const QString &formula, bool fromUser, VContainer
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TMainWindow::Open(const QString &pathTo, const QString &filter) void TMainWindow::Open(const QString &pathTo, const QString &filter)
{ {
const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), pathTo, filter); const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), pathTo, filter, nullptr,
qApp->NativeFileDialog());
if (not mPath.isEmpty()) if (not mPath.isEmpty())
{ {

View File

@ -41,7 +41,7 @@ class VApplication;// use in define
#if defined(qApp) #if defined(qApp)
#undef qApp #undef qApp
#endif #endif
#define qApp (static_cast<VApplication*>(VAbstractApplication::instance())) #define qApp (qobject_cast<VApplication*>(VAbstractApplication::instance()))
/** /**
* @brief The VApplication class reimplamentation QApplication class. * @brief The VApplication class reimplamentation QApplication class.

View File

@ -82,10 +82,8 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTextAsPaths, (QLatin1String("lay
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingNestingTime, (QLatin1String("layout/time"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingNestingTime, (QLatin1String("layout/time")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingEfficiencyCoefficient, (QLatin1String("layout/efficiencyCoefficient"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingEfficiencyCoefficient, (QLatin1String("layout/efficiencyCoefficient")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFMargins, (QLatin1String("tiledPDF/margins")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFPaperHeight, (QLatin1String("tiledPDF/paperHeight"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFPaperHeight, (QLatin1String("tiledPDF/paperHeight")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFPaperWidth, (QLatin1String("tiledPDF/paperWidth"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFPaperWidth, (QLatin1String("tiledPDF/paperWidth")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFOrientation, (QLatin1String("tiledPDF/orientation")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingdockWidgetGroupsActive, (QLatin1String("dockWidget/groupsActive"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingdockWidgetGroupsActive, (QLatin1String("dockWidget/groupsActive")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetToolOptionsActive, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetToolOptionsActive,
@ -479,33 +477,6 @@ void VValentinaSettings::SetRememberPatternMaterials(bool value)
} }
// settings for the tiled PDFs // settings for the tiled PDFs
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetTiledPDFMargins returns the tiled pdf margins in the given unit. When the setting is
* called for the first time, the 4 default margins are 10mm.
* @param unit the unit in which are the value. Necessary because we save the values
* internaly as mm so there is conversion beeing made.
* @return tiled pdf margins
*/
QMarginsF VValentinaSettings::GetTiledPDFMargins(const Unit &unit) const
{
// default value is 10mm. We save the margins in mm in the setting.
return UnitConvertor(ValueOrDef<QMarginsF>(*this, *settingTiledPDFMargins, QMarginsF(10, 10, 10, 10)), Unit::Mm,
unit);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetTiledPDFMargins sets the setting tiled pdf margins to the given value.
* @param value the margins to save
* @param unit the unit in which are the value. Necessary because we save the values
* internaly as mm so there is conversion beeing made.
*/
void VValentinaSettings::SetTiledPDFMargins(const QMarginsF &value, const Unit &unit)
{
setValue(*settingTiledPDFMargins, QVariant::fromValue(UnitConvertor(value, unit, Unit::Mm)));
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief GetTiledPDFPaperHeight returns the paper height of tiled pdf in the desired unit. * @brief GetTiledPDFPaperHeight returns the paper height of tiled pdf in the desired unit.
@ -552,21 +523,6 @@ void VValentinaSettings::SetTiledPDFPaperWidth(qreal value, const Unit &unit)
setValue(*settingTiledPDFPaperWidth, UnitConvertor(value,unit, Unit::Mm)); setValue(*settingTiledPDFPaperWidth, UnitConvertor(value,unit, Unit::Mm));
} }
//---------------------------------------------------------------------------------------------------------------------
PageOrientation VValentinaSettings::GetTiledPDFOrientation() const
{
bool defaultValue = static_cast<bool>(PageOrientation::Portrait);
bool result = value(*settingTiledPDFOrientation, defaultValue).toBool();
return static_cast<PageOrientation>(result);
}
//---------------------------------------------------------------------------------------------------------------------
void VValentinaSettings::SetTiledPDFOrientation(PageOrientation value)
{
setValue(*settingTiledPDFOrientation, static_cast<bool> (value));
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VValentinaSettings::IsDockWidgetGroupsActive() const bool VValentinaSettings::IsDockWidgetGroupsActive() const

View File

@ -135,18 +135,12 @@ public:
void SetRememberPatternMaterials(bool value); void SetRememberPatternMaterials(bool value);
// settings for the tiled PDFs // settings for the tiled PDFs
QMarginsF GetTiledPDFMargins(const Unit &unit) const;
void SetTiledPDFMargins(const QMarginsF &value, const Unit &unit);
qreal GetTiledPDFPaperHeight(const Unit &unit) const; qreal GetTiledPDFPaperHeight(const Unit &unit) const;
void SetTiledPDFPaperHeight(qreal value, const Unit &unit); void SetTiledPDFPaperHeight(qreal value, const Unit &unit);
qreal GetTiledPDFPaperWidth(const Unit &unit) const; qreal GetTiledPDFPaperWidth(const Unit &unit) const;
void SetTiledPDFPaperWidth(qreal value, const Unit &unit); void SetTiledPDFPaperWidth(qreal value, const Unit &unit);
PageOrientation GetTiledPDFOrientation() const;
void SetTiledPDFOrientation(PageOrientation value);
bool IsDockWidgetGroupsActive() const; bool IsDockWidgetGroupsActive() const;
static bool GetDefDockWidgetGroupsActive(); static bool GetDefDockWidgetGroupsActive();
void SetDockWidgetGroupsActive(bool value); void SetDockWidgetGroupsActive(bool value);
@ -175,6 +169,9 @@ public:
private: private:
Q_DISABLE_COPY(VValentinaSettings) Q_DISABLE_COPY(VValentinaSettings)
template <typename T>
T GetCachedValue(T &cache, const QString &setting, T defValue, T valueMin, T valueMax) const;
}; };
#endif // VVALENTINASETTINGS_H #endif // VVALENTINASETTINGS_H

View File

@ -130,6 +130,9 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent)
// Tool panel // Tool panel
ui->checkBoxToolPanelScaling->setChecked(settings->GetToolPanelScaling()); ui->checkBoxToolPanelScaling->setChecked(settings->GetToolPanelScaling());
// Native dialogs
ui->checkBoxDontUseNativeDialog->setChecked(settings->IsDontUseNativeDialog());
// Tab Scrolling // Tab Scrolling
ui->spinBoxDuration->setMinimum(VValentinaSettings::scrollingDurationMin); ui->spinBoxDuration->setMinimum(VValentinaSettings::scrollingDurationMin);
ui->spinBoxDuration->setMaximum(VValentinaSettings::scrollingDurationMax); ui->spinBoxDuration->setMaximum(VValentinaSettings::scrollingDurationMax);
@ -186,6 +189,11 @@ QStringList PreferencesConfigurationPage::Apply()
settings->SetToolPanelScaling(ui->checkBoxToolPanelScaling->isChecked()); settings->SetToolPanelScaling(ui->checkBoxToolPanelScaling->isChecked());
} }
if (settings->IsDontUseNativeDialog() != ui->checkBoxDontUseNativeDialog->isChecked())
{
settings->SetDontUseNativeDialog(ui->checkBoxDontUseNativeDialog->isChecked());
}
settings->SetFreeCurveMode(ui->checkBoxFreeCurve->isChecked()); settings->SetFreeCurveMode(ui->checkBoxFreeCurve->isChecked());
settings->SetDoubleClickZoomFitBestCurrentPP(ui->checkBoxZoomFitBestCurrentPP->isChecked()); settings->SetDoubleClickZoomFitBestCurrentPP(ui->checkBoxZoomFitBestCurrentPP->isChecked());

View File

@ -33,9 +33,9 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>-161</y> <y>-189</y>
<width>624</width> <width>624</width>
<height>717</height> <height>745</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
@ -283,6 +283,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="checkBoxDontUseNativeDialog">
<property name="text">
<string>Don't use the native file dialog</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@ -173,13 +173,9 @@ void PreferencesPathPage::EditPath()
usedNotExistedDir = directory.mkpath(QChar('.')); usedNotExistedDir = directory.mkpath(QChar('.'));
} }
const QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), path, const QString dir = QFileDialog::getExistingDirectory(
QFileDialog::ShowDirsOnly this, tr("Open Directory"), path,
| QFileDialog::DontResolveSymlinks qApp->NativeFileDialog(QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks));
#ifdef Q_OS_LINUX
| QFileDialog::DontUseNativeDialog
#endif
);
if (dir.isEmpty()) if (dir.isEmpty())
{ {
if (usedNotExistedDir) if (usedNotExistedDir)

View File

@ -909,9 +909,6 @@ QSizeF DialogLayoutSettings::GetTemplateSize(const PaperSizeTemplate &tmpl, cons
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QMarginsF DialogLayoutSettings::MinPrinterFields() const QMarginsF DialogLayoutSettings::MinPrinterFields() const
{ {

View File

@ -32,7 +32,7 @@
#include <QCloseEvent> #include <QCloseEvent>
#include <QMargins> #include <QMargins>
#include "vabstractlayoutdialog.h" #include "../vlayout/dialogs/vabstractlayoutdialog.h"
#include "../vlayout/vbank.h" #include "../vlayout/vbank.h"
namespace Ui namespace Ui

View File

@ -411,11 +411,8 @@ void DialogPatternProperties::InitImage()
void DialogPatternProperties::ChangeImage() void DialogPatternProperties::ChangeImage()
{ {
const QString filter = tr("Images") + QLatin1String(" (*.png *.jpg *.jpeg *.bmp)"); const QString filter = tr("Images") + QLatin1String(" (*.png *.jpg *.jpeg *.bmp)");
const QString fileName = QFileDialog::getOpenFileName(this, tr("Image for pattern"), QString(), filter, nullptr const QString fileName = QFileDialog::getOpenFileName(this, tr("Image for pattern"), QString(), filter, nullptr,
#ifdef Q_OS_LINUX qApp->NativeFileDialog());
, QFileDialog::DontUseNativeDialog
#endif
);
if (not fileName.isEmpty()) if (not fileName.isEmpty())
{ {
QImage image; QImage image;
@ -456,11 +453,8 @@ void DialogPatternProperties::SaveImage()
QByteArray ba = QByteArray::fromBase64(byteArray); QByteArray ba = QByteArray::fromBase64(byteArray);
const QString extension = doc->GetImageExtension().prepend(QChar('.')); const QString extension = doc->GetImageExtension().prepend(QChar('.'));
QString filter = tr("Images") + QStringLiteral(" (*") + extension + QChar(')'); QString filter = tr("Images") + QStringLiteral(" (*") + extension + QChar(')');
QString filename = QFileDialog::getSaveFileName(this, tr("Save File"), tr("untitled"), filter, &filter QString filename = QFileDialog::getSaveFileName(this, tr("Save File"), tr("untitled"), filter, &filter,
#ifdef Q_OS_LINUX qApp->NativeFileDialog());
, QFileDialog::DontUseNativeDialog
#endif
);
if (not filename.isEmpty()) if (not filename.isEmpty())
{ {
if (not filename.endsWith(extension.toUpper())) if (not filename.endsWith(extension.toUpper()))

View File

@ -36,6 +36,5 @@
#include "dialogaboutapp.h" #include "dialogaboutapp.h"
#include "dialogpreferences.h" #include "dialogpreferences.h"
#include "dialogfinalmeasurements.h" #include "dialogfinalmeasurements.h"
#include "dialoglayoutscale.h"
#endif // DIALOGS_H #endif // DIALOGS_H

View File

@ -2,7 +2,6 @@
# This need for corect working file translations.pro # This need for corect working file translations.pro
HEADERS += \ HEADERS += \
$$PWD/dialoglayoutscale.h \
$$PWD/dialogs.h \ $$PWD/dialogs.h \
$$PWD/dialogincrements.h \ $$PWD/dialogincrements.h \
$$PWD/dialoghistory.h \ $$PWD/dialoghistory.h \
@ -21,13 +20,11 @@ HEADERS += \
$$PWD/dialogdatetimeformats.h \ $$PWD/dialogdatetimeformats.h \
$$PWD/dialogknownmaterials.h \ $$PWD/dialogknownmaterials.h \
$$PWD/dialogpatternmaterials.h \ $$PWD/dialogpatternmaterials.h \
$$PWD/dialogfinalmeasurements.h \ $$PWD/dialogfinalmeasurements.h
$$PWD/vabstractlayoutdialog.h
SOURCES += \ SOURCES += \
$$PWD/dialogincrements.cpp \ $$PWD/dialogincrements.cpp \
$$PWD/dialoghistory.cpp \ $$PWD/dialoghistory.cpp \
$$PWD/dialoglayoutscale.cpp \
$$PWD/dialogpatternproperties.cpp \ $$PWD/dialogpatternproperties.cpp \
$$PWD/dialognewpattern.cpp \ $$PWD/dialognewpattern.cpp \
$$PWD/dialogaboutapp.cpp \ $$PWD/dialogaboutapp.cpp \
@ -43,13 +40,11 @@ SOURCES += \
$$PWD/dialogdatetimeformats.cpp \ $$PWD/dialogdatetimeformats.cpp \
$$PWD/dialogknownmaterials.cpp \ $$PWD/dialogknownmaterials.cpp \
$$PWD/dialogpatternmaterials.cpp \ $$PWD/dialogpatternmaterials.cpp \
$$PWD/dialogfinalmeasurements.cpp \ $$PWD/dialogfinalmeasurements.cpp
$$PWD/vabstractlayoutdialog.cpp
FORMS += \ FORMS += \
$$PWD/dialogincrements.ui \ $$PWD/dialogincrements.ui \
$$PWD/dialoghistory.ui \ $$PWD/dialoghistory.ui \
$$PWD/dialoglayoutscale.ui \
$$PWD/dialogpatternproperties.ui \ $$PWD/dialogpatternproperties.ui \
$$PWD/dialognewpattern.ui \ $$PWD/dialognewpattern.ui \
$$PWD/dialogaboutapp.ui \ $$PWD/dialogaboutapp.ui \

View File

@ -31,6 +31,7 @@
#include "../core/vapplication.h" #include "../core/vapplication.h"
#include "../core/vvalentinasettings.h" #include "../core/vvalentinasettings.h"
#include "../ifc/exception/vexception.h" #include "../ifc/exception/vexception.h"
#include "../vlayout/vlayoutexporter.h"
#include <QDir> #include <QDir>
#include <QFileDialog> #include <QFileDialog>
@ -128,13 +129,9 @@ DialogSaveLayout::DialogSaveLayout(int count, Draw mode, const QString &fileName
usedNotExistedDir = directory.mkpath(QChar('.')); usedNotExistedDir = directory.mkpath(QChar('.'));
} }
const QString dir = QFileDialog::getExistingDirectory(this, tr("Select folder"), dirPath, const QString dir = QFileDialog::getExistingDirectory(
QFileDialog::ShowDirsOnly this, tr("Select folder"), dirPath,
| QFileDialog::DontResolveSymlinks qApp->NativeFileDialog(QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks));
#ifdef Q_OS_LINUX
| QFileDialog::DontUseNativeDialog
#endif
);
if (not dir.isEmpty()) if (not dir.isEmpty())
{// If paths equal the signal will not be called, we will do this manually {// If paths equal the signal will not be called, we will do this manually
dir == ui->lineEditPath->text() ? PathChanged(dir) : ui->lineEditPath->setText(dir); dir == ui->lineEditPath->text() ? PathChanged(dir) : ui->lineEditPath->setText(dir);
@ -803,35 +800,12 @@ bool DialogSaveLayout::SupportPSTest()
{ {
if (!tested) if (!tested)
{ {
havePdf = TestPdf(); havePdf = VLayoutExporter::SupportPDFConversion();
tested = true; tested = true;
} }
return havePdf; return havePdf;
} }
//---------------------------------------------------------------------------------------------------------------------
bool DialogSaveLayout::TestPdf()
{
bool res = false;
QProcess proc;
#if defined(Q_OS_WIN) || defined(Q_OS_OSX)
// Seek pdftops in app bundle or near valentin.exe
proc.start(qApp->applicationDirPath() + QLatin1String("/")+ PDFTOPS, QStringList());
#else
proc.start(PDFTOPS, QStringList()); // Seek pdftops in standard path
#endif
if (proc.waitForStarted(15000) && (proc.waitForFinished(15000) || proc.state() == QProcess::NotRunning))
{
res = true;
}
else
{
qDebug()<<PDFTOPS<<"error"<<proc.error()<<proc.errorString();
}
return res;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<std::pair<QString, LayoutExportFormats> > DialogSaveLayout::InitFormats() QVector<std::pair<QString, LayoutExportFormats> > DialogSaveLayout::InitFormats()
{ {

View File

@ -30,17 +30,9 @@
#define DIALOGSAVELAYOUT_H #define DIALOGSAVELAYOUT_H
#include "../vgeometry/vgeometrydef.h" #include "../vgeometry/vgeometrydef.h"
#include "vabstractlayoutdialog.h" #include "../vlayout/dialogs/vabstractlayoutdialog.h"
#include "../vlayout/vlayoutdef.h" #include "../vlayout/vlayoutdef.h"
#ifndef PDFTOPS
#ifdef Q_OS_WIN
# define PDFTOPS QStringLiteral("pdftops.exe")
#else
# define PDFTOPS QStringLiteral("pdftops")
#endif
#endif
namespace Ui namespace Ui
{ {
class DialogSaveLAyout; class DialogSaveLAyout;
@ -115,7 +107,6 @@ private:
static bool havePdf; static bool havePdf;
static bool tested; static bool tested;
static bool SupportPSTest(); static bool SupportPSTest();
static bool TestPdf();
static QVector<std::pair<QString, LayoutExportFormats> > InitFormats(); static QVector<std::pair<QString, LayoutExportFormats> > InitFormats();
void RemoveFormatFromList(LayoutExportFormats format); void RemoveFormatFromList(LayoutExportFormats format);

View File

@ -1641,10 +1641,7 @@ void MainWindow::customEvent(QEvent *event)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::CleanLayout() void MainWindow::CleanLayout()
{ {
qDeleteAll (scenes); m_layoutSettings->CleanLayout();
scenes.clear();
shadows.clear();
papers.clear();
gcontours.clear(); gcontours.clear();
ui->listWidget->clear(); ui->listWidget->clear();
SetLayoutModeActions(); SetLayoutModeActions();
@ -1654,14 +1651,14 @@ void MainWindow::CleanLayout()
void MainWindow::PrepareSceneList(PreviewQuatilty quality) void MainWindow::PrepareSceneList(PreviewQuatilty quality)
{ {
ui->listWidget->clear(); ui->listWidget->clear();
for (int i=1; i<=scenes.size(); ++i) for (int i=1; i<=m_layoutSettings->LayoutScenes().size(); ++i)
{ {
QListWidgetItem *item = new QListWidgetItem(ScenePreview(i-1, ui->listWidget->iconSize(), quality), QListWidgetItem *item = new QListWidgetItem(ScenePreview(i-1, ui->listWidget->iconSize(), quality),
QString::number(i)); QString::number(i));
ui->listWidget->addItem(item); ui->listWidget->addItem(item);
} }
if (not scenes.isEmpty()) if (not m_layoutSettings->LayoutScenes().isEmpty())
{ {
ui->listWidget->setCurrentRow(0); ui->listWidget->setCurrentRow(0);
SetLayoutModeActions(); SetLayoutModeActions();
@ -1769,11 +1766,8 @@ void MainWindow::LoadIndividual()
usedNotExistedDir = directory.mkpath(QChar('.')); usedNotExistedDir = directory.mkpath(QChar('.'));
} }
const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter, nullptr const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter, nullptr,
#ifdef Q_OS_LINUX qApp->NativeFileDialog());
, QFileDialog::DontUseNativeDialog
#endif
);
if (not mPath.isEmpty()) if (not mPath.isEmpty())
{ {
@ -1810,11 +1804,8 @@ void MainWindow::LoadMultisize()
//Use standard path to multisize measurements //Use standard path to multisize measurements
QString path = qApp->ValentinaSettings()->GetPathMultisizeMeasurements(); QString path = qApp->ValentinaSettings()->GetPathMultisizeMeasurements();
path = VCommonSettings::PrepareMultisizeTables(path); path = VCommonSettings::PrepareMultisizeTables(path);
const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter, nullptr const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter, nullptr,
#ifdef Q_OS_LINUX qApp->NativeFileDialog());
, QFileDialog::DontUseNativeDialog
#endif
);
if (not mPath.isEmpty()) if (not mPath.isEmpty())
{ {
@ -2034,7 +2025,8 @@ void MainWindow::LoadWatermark()
const QString filter(tr("Watermark files") + QLatin1String(" (*.vwm)")); const QString filter(tr("Watermark files") + QLatin1String(" (*.vwm)"));
QString dir = QDir::homePath(); QString dir = QDir::homePath();
qDebug("Run QFileDialog::getOpenFileName: dir = %s.", qUtf8Printable(dir)); qDebug("Run QFileDialog::getOpenFileName: dir = %s.", qUtf8Printable(dir));
const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter, nullptr); const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter, nullptr,
qApp->NativeFileDialog());
if (filePath.isEmpty()) if (filePath.isEmpty())
{ {
return; return;
@ -3067,7 +3059,7 @@ void MainWindow::ActionLayout(bool checked)
ShowPaper(ui->listWidget->currentRow()); ShowPaper(ui->listWidget->currentRow());
if (scenes.isEmpty() || isLayoutStale) if (m_layoutSettings->LayoutScenes().isEmpty() || m_layoutSettings->IsLayoutStale())
{ {
ui->toolButtonLayoutSettings->click(); ui->toolButtonLayoutSettings->click();
} }
@ -3108,11 +3100,7 @@ bool MainWindow::on_actionSaveAs_triggered()
QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"),
dir + QLatin1String("/") + tr("pattern") + QLatin1String(".val"), dir + QLatin1String("/") + tr("pattern") + QLatin1String(".val"),
filters, nullptr filters, nullptr, qApp->NativeFileDialog());
#ifdef Q_OS_LINUX
, QFileDialog::DontUseNativeDialog
#endif
);
auto RemoveTempDir = qScopeGuard([usedNotExistedDir, dir]() auto RemoveTempDir = qScopeGuard([usedNotExistedDir, dir]()
{ {
@ -3305,11 +3293,8 @@ void MainWindow::on_actionOpen_triggered()
dir = QFileInfo(files.first()).absolutePath(); dir = QFileInfo(files.first()).absolutePath();
} }
qCDebug(vMainWindow, "Run QFileDialog::getOpenFileName: dir = %s.", qUtf8Printable(dir)); qCDebug(vMainWindow, "Run QFileDialog::getOpenFileName: dir = %s.", qUtf8Printable(dir));
const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter, nullptr const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter, nullptr,
#ifdef Q_OS_LINUX qApp->NativeFileDialog());
, QFileDialog::DontUseNativeDialog
#endif
);
if (filePath.isEmpty()) if (filePath.isEmpty())
{ {
return; return;
@ -3975,7 +3960,7 @@ void MainWindow::PatternChangesWereSaved(bool saved)
const bool state = doc->IsModified() || !saved; const bool state = doc->IsModified() || !saved;
setWindowModified(state); setWindowModified(state);
not patternReadOnly ? ui->actionSave->setEnabled(state): ui->actionSave->setEnabled(false); not patternReadOnly ? ui->actionSave->setEnabled(state): ui->actionSave->setEnabled(false);
isLayoutStale = true; m_layoutSettings->SetLayoutStale(true);
isNeedAutosave = not saved; isNeedAutosave = not saved;
} }
} }
@ -4335,7 +4320,7 @@ QT_WARNING_POP
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::SetLayoutModeActions() void MainWindow::SetLayoutModeActions()
{ {
const bool enabled = not scenes.isEmpty(); const bool enabled = not m_layoutSettings->LayoutScenes().isEmpty();
ui->toolButtonLayoutExportAs->setEnabled(enabled); ui->toolButtonLayoutExportAs->setEnabled(enabled);
ui->actionExportAs->setEnabled(enabled); ui->actionExportAs->setEnabled(enabled);
@ -4908,13 +4893,13 @@ void MainWindow::CreateActions()
QString fileName = QString fileName =
QFileDialog::getSaveFileName(this, tr("Export recipe"), QFileDialog::getSaveFileName(this, tr("Export recipe"),
QDir::homePath() + '/' + tr("recipe") + QStringLiteral(".vpr"), QDir::homePath() + '/' + tr("recipe") + QStringLiteral(".vpr"),
filters, nullptr); filters, nullptr, qApp->NativeFileDialog());
if (fileName.isEmpty()) if (fileName.isEmpty())
{ {
return; return;
} }
VPatternRecipe recipe(pattern, doc); VPatternRecipe recipe(doc);
QString error; QString error;
if (not recipe.SaveDocument(fileName, error)) if (not recipe.SaveDocument(fileName, error))
{ {
@ -5169,7 +5154,6 @@ bool MainWindow::PatternPieceName(QString &name)
MainWindow::~MainWindow() MainWindow::~MainWindow()
{ {
CancelTool(); CancelTool();
qDeleteAll (scenes);
delete doc; delete doc;
delete ui; delete ui;
@ -5425,6 +5409,7 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile)
ActionDraw(true); ActionDraw(true);
qApp->setOpeningPattern();// End opening file qApp->setOpeningPattern();// End opening file
m_statusLabel->setText(QString());
return true; return true;
} }
else else
@ -5494,13 +5479,13 @@ void MainWindow::ToolBoxSizePolicy()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::ShowPaper(int index) void MainWindow::ShowPaper(int index)
{ {
if (index < 0 || index >= scenes.size()) if (index < 0 || index >= m_layoutSettings->LayoutScenes().size())
{ {
ui->view->setScene(tempSceneLayout); ui->view->setScene(tempSceneLayout);
} }
else else
{ {
ui->view->setScene(scenes.at(index)); ui->view->setScene(m_layoutSettings->LayoutScenes().at(index));
} }
ui->view->fitInView(ui->view->scene()->sceneRect(), Qt::KeepAspectRatio); ui->view->fitInView(ui->view->scene()->sceneRect(), Qt::KeepAspectRatio);
@ -5557,9 +5542,9 @@ void MainWindow::ExportLayoutAs()
{ {
auto Uncheck = qScopeGuard([this] {ui->toolButtonLayoutExportAs->setChecked(false);}); auto Uncheck = qScopeGuard([this] {ui->toolButtonLayoutExportAs->setChecked(false);});
if (isLayoutStale) if (m_layoutSettings->IsLayoutStale())
{ {
if (ContinueIfLayoutStale() == QMessageBox::No) if (VPrintLayout::ContinueIfLayoutStale(this) == QMessageBox::No)
{ {
return; return;
} }
@ -5567,8 +5552,8 @@ void MainWindow::ExportLayoutAs()
try try
{ {
m_dialogSaveLayout = QSharedPointer<DialogSaveLayout>(new DialogSaveLayout(scenes.size(), Draw::Layout, m_dialogSaveLayout = QSharedPointer<DialogSaveLayout>(
FileName(), this)); new DialogSaveLayout(m_layoutSettings->LayoutScenes().size(), Draw::Layout, FileName(), this));
if (m_dialogSaveLayout->exec() == QDialog::Rejected) if (m_dialogSaveLayout->exec() == QDialog::Rejected)
{ {
@ -5714,6 +5699,7 @@ QString MainWindow::CheckPathToMeasurements(const QString &patternPath, const QS
QFileDialog dialog(this, tr("Open file"), dirPath, filter); QFileDialog dialog(this, tr("Open file"), dirPath, filter);
dialog.selectFile(selectedName); dialog.selectFile(selectedName);
dialog.setFileMode(QFileDialog::ExistingFile); dialog.setFileMode(QFileDialog::ExistingFile);
dialog.setOption(QFileDialog::DontUseNativeDialog, qApp->Settings()->IsDontUseNativeDialog());
if (dialog.exec() == QDialog::Accepted) if (dialog.exec() == QDialog::Accepted)
{ {
mPath = dialog.selectedFiles().value(0); mPath = dialog.selectedFiles().value(0);
@ -5985,9 +5971,9 @@ bool MainWindow::DoExport(const VCommandLinePtr &expParams)
{ {
try try
{ {
m_dialogSaveLayout = QSharedPointer<DialogSaveLayout>(new DialogSaveLayout(scenes.size(), Draw::Layout, m_dialogSaveLayout = QSharedPointer<DialogSaveLayout>(
expParams->OptBaseName(), new DialogSaveLayout(m_layoutSettings->LayoutScenes().size(),
this)); Draw::Layout, expParams->OptBaseName(), this));
m_dialogSaveLayout->SetDestinationPath(expParams->OptDestinationPath()); m_dialogSaveLayout->SetDestinationPath(expParams->OptDestinationPath());
m_dialogSaveLayout->SelectFormat(static_cast<LayoutExportFormats>(expParams->OptExportType())); m_dialogSaveLayout->SelectFormat(static_cast<LayoutExportFormats>(expParams->OptExportType()));
m_dialogSaveLayout->SetBinaryDXFFormat(expParams->IsBinaryDXF()); m_dialogSaveLayout->SetBinaryDXFFormat(expParams->IsBinaryDXF());

File diff suppressed because it is too large Load Diff

View File

@ -40,6 +40,7 @@
#include "../vlayout/vlayoutgenerator.h" #include "../vlayout/vlayoutgenerator.h"
#include "../vwidgets/vabstractmainwindow.h" #include "../vwidgets/vabstractmainwindow.h"
#include "../vlayout/vtextmanager.h" #include "../vlayout/vtextmanager.h"
#include "../vlayout/vprintlayout.h"
class QGraphicsScene; class QGraphicsScene;
struct PosterData; struct PosterData;
@ -98,13 +99,9 @@ protected:
/** @brief doc dom document container */ /** @brief doc dom document container */
VPattern *doc; VPattern *doc;
QList<QGraphicsItem *> papers; QList<QGraphicsItem *> gcontours{};
QList<QGraphicsItem *> shadows;
QList<QGraphicsScene *> scenes;
QList<QList<QGraphicsItem *> > details;
QList<QGraphicsItem *> gcontours;
QVector<QVector<VLayoutPiece> > detailsOnLayout; QVector<QVector<VLayoutPiece> > detailsOnLayout{};
QAction *undoAction; QAction *undoAction;
QAction *redoAction; QAction *redoAction;
@ -112,12 +109,8 @@ protected:
QAction *actionDockWidgetGroups; QAction *actionDockWidgetGroups;
bool isNoScaling; bool isNoScaling;
bool isLayoutStale;
bool isNeedAutosave; bool isNeedAutosave;
bool ignorePrinterFields; VPrintLayout *m_layoutSettings{new VPrintLayout(this)};
bool isLayoutPortrait{true};
QMarginsF margins;
QSizeF paperSize;
QSharedPointer<DialogSaveLayout> m_dialogSaveLayout; QSharedPointer<DialogSaveLayout> m_dialogSaveLayout;
@ -140,7 +133,6 @@ protected:
virtual QStringList RecentFileList() const override; virtual QStringList RecentFileList() const override;
QIcon ScenePreview(int i, QSize iconSize, PreviewQuatilty quality) const; QIcon ScenePreview(int i, QSize iconSize, PreviewQuatilty quality) const;
bool GenerateLayout(VLayoutGenerator& lGenerator); bool GenerateLayout(VLayoutGenerator& lGenerator);
int ContinueIfLayoutStale();
QString FileName() const; QString FileName() const;
bool ExportFMeasurementsToCSVData(const QString &fileName, bool ExportFMeasurementsToCSVData(const QString &fileName,
@ -151,60 +143,15 @@ protected:
void CheckRequiredMeasurements(const VMeasurements *m) const; void CheckRequiredMeasurements(const VMeasurements *m) const;
void RLDFile(const QString &name, QVector<VLayoutPiece> details, qreal xScale=1, qreal yScale=1) const; void RLDFile(const QString &name, QVector<VLayoutPiece> details, qreal xScale=1, qreal yScale=1) const;
private slots:
void PrintPages (QPrinter *printer);
private: private:
Q_DISABLE_COPY(MainWindowsNoGUI) Q_DISABLE_COPY(MainWindowsNoGUI)
bool isTiled;
bool isAutoCropLength;
bool isAutoCropWidth;
bool isUnitePages;
QString layoutPrinterName;
qreal m_xscale{1};
qreal m_yscale{1};
static QList<QGraphicsItem *> CreateShadows(const QList<QGraphicsItem *> &papers); static QList<QGraphicsItem *> CreateShadows(const QList<QGraphicsItem *> &papers);
static QList<QGraphicsScene *> CreateScenes(const QList<QGraphicsItem *> &papers, static QList<QGraphicsScene *> CreateScenes(const QList<QGraphicsItem *> &papers,
const QList<QGraphicsItem *> &shadows, const QList<QGraphicsItem *> &shadows,
const QList<QList<QGraphicsItem *> > &details); const QList<QList<QGraphicsItem *> > &details);
void SvgFile(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene, const QMarginsF &margins)const;
void PngFile(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene, const QMarginsF &margins)const;
void PdfFile(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene, bool ignorePrinterFields,
const QMarginsF &margins)const;
void PdfTiledFile(const QString &name); void PdfTiledFile(const QString &name);
void EpsFile(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene, bool ignorePrinterFields,
const QMarginsF &margins)const;
void PsFile(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene, bool ignorePrinterFields,
const QMarginsF &margins)const;
void PdfToPs(const QStringList &params)const;
void ObjFile(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene)const;
void FlatDxfFile(const QString &name, int version, bool binary, QGraphicsRectItem *paper, QGraphicsScene *scene,
const QList<QList<QGraphicsItem *> > &details)const;
void AAMADxfFile(const QString &name, int version, bool binary, const QSize &size,
const QVector<VLayoutPiece> &details) const;
void ASTMDxfFile(const QString &name, int version, bool binary, const QSize &size,
const QVector<VLayoutPiece> &details) const;
void PreparePaper(int index) const;
void RestorePaper(int index) const;
void PrepareTextForDXF(const QString &placeholder, const QList<QList<QGraphicsItem *> > &details) const;
void RestoreTextAfterDXF(const QString &placeholder, const QList<QList<QGraphicsItem *> > &details) const;
void PrintPreview();
void LayoutPrint();
enum class PrintType : qint8 {PrintPDF, PrintPreview, PrintNative};
void SetPrinterSettings(QPrinter *printer, const PrintType &printType);
QPageSize::PageSizeId FindPageSizeId(const QSizeF &size) const;
bool isPagesUniform() const;
bool IsPagesFit(const QSizeF &printPaper) const;
void ExportScene(const QList<QGraphicsScene *> &scenes, void ExportScene(const QList<QGraphicsScene *> &scenes,
const QList<QGraphicsItem *> &papers, const QList<QGraphicsItem *> &papers,

View File

@ -93,7 +93,7 @@ WatermarkWindow::WatermarkWindow(const QString &patternPath, QWidget *parent) :
{ {
const QString filter = tr("Images") + QLatin1String(" (*.png *.jpg *.jpeg *.bmp)"); const QString filter = tr("Images") + QLatin1String(" (*.png *.jpg *.jpeg *.bmp)");
const QString fileName = QFileDialog::getOpenFileName(this, tr("Watermark image"), QString(), filter, const QString fileName = QFileDialog::getOpenFileName(this, tr("Watermark image"), QString(), filter,
nullptr); nullptr, qApp->NativeFileDialog());
if (not fileName.isEmpty()) if (not fileName.isEmpty())
{ {
ui->lineEditPath->setText(fileName); ui->lineEditPath->setText(fileName);
@ -284,7 +284,7 @@ bool WatermarkWindow::on_actionSaveAs_triggered()
QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"),
dir + QLatin1String("/") + tr("watermark") + QLatin1String(".vwm"), dir + QLatin1String("/") + tr("watermark") + QLatin1String(".vwm"),
filters, nullptr); filters, nullptr, qApp->NativeFileDialog());
if (fileName.isEmpty()) if (fileName.isEmpty())
{ {
@ -426,7 +426,8 @@ void WatermarkWindow::on_actionOpen_triggered()
const QString filter(tr("Watermark files") + QLatin1String(" (*.vwm)")); const QString filter(tr("Watermark files") + QLatin1String(" (*.vwm)"));
QString dir = QDir::homePath(); QString dir = QDir::homePath();
qDebug("Run QFileDialog::getOpenFileName: dir = %s.", qUtf8Printable(dir)); qDebug("Run QFileDialog::getOpenFileName: dir = %s.", qUtf8Printable(dir));
const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter, nullptr); const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter, nullptr,
qApp->NativeFileDialog());
if (filePath.isEmpty()) if (filePath.isEmpty())
{ {
return; return;

View File

@ -347,6 +347,41 @@ VContainer VPattern::GetCompleteData() const
return lastData; return lastData;
} }
//---------------------------------------------------------------------------------------------------------------------
VContainer VPattern::GetCompletePPData(const QString &name) const
{
const int countPP = CountPP();
if (countPP <= 0 || history.isEmpty() || tools.isEmpty())
{
return (data != nullptr ? *data : VContainer(nullptr, nullptr, VContainer::UniqueNamespace()));
}
const quint32 id = (countPP == 1 ? history.last().getId() : PPLastToolId(name));
if (id == NULL_ID)
{
return (data != nullptr ? *data : VContainer(nullptr, nullptr, VContainer::UniqueNamespace()));
}
try
{
ToolExists(id);
}
catch (VExceptionBadId &e)
{
Q_UNUSED(e)
return (data != nullptr ? *data : VContainer(nullptr, nullptr, VContainer::UniqueNamespace()));
}
const VDataTool *vTool = tools.value(id);
SCASSERT(vTool != nullptr)
VContainer lastData = vTool->getData();
//Delete special variables if exist
lastData.RemoveVariable(currentLength);
lastData.RemoveVariable(currentSeamAllowance);
return lastData;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief SPointActiveDraw return id base point current pattern peace. * @brief SPointActiveDraw return id base point current pattern peace.
@ -1176,8 +1211,8 @@ void VPattern::PointsCommonAttributes(const QDomElement &domElement, VToolSingle
void VPattern::PointsCommonAttributes(const QDomElement &domElement, quint32 &id, qreal &mx, qreal &my) void VPattern::PointsCommonAttributes(const QDomElement &domElement, quint32 &id, qreal &mx, qreal &my)
{ {
ToolsCommonAttributes(domElement, id); ToolsCommonAttributes(domElement, id);
mx = qApp->toPixel(GetParametrDouble(domElement, AttrMx, QStringLiteral("10.0"))); mx = qApp->toPixel(GetParametrDouble(domElement, AttrMx, QString::number(labelMX)));
my = qApp->toPixel(GetParametrDouble(domElement, AttrMy, QStringLiteral("15.0"))); my = qApp->toPixel(GetParametrDouble(domElement, AttrMy, QString::number(labelMY)));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -1185,8 +1220,8 @@ void VPattern::DrawPointsCommonAttributes(const QDomElement &domElement, quint32
QString &notes) QString &notes)
{ {
DrawToolsCommonAttributes(domElement, id, notes); DrawToolsCommonAttributes(domElement, id, notes);
mx = qApp->toPixel(GetParametrDouble(domElement, AttrMx, QStringLiteral("10.0"))); mx = qApp->toPixel(GetParametrDouble(domElement, AttrMx, QString::number(labelMX)));
my = qApp->toPixel(GetParametrDouble(domElement, AttrMy, QStringLiteral("15.0"))); my = qApp->toPixel(GetParametrDouble(domElement, AttrMy, QString::number(labelMY)));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -2460,13 +2495,13 @@ void VPattern::ParseToolTrueDarts(VMainGraphicsScene *scene, const QDomElement &
initData.dartP3Id = GetParametrUInt(domElement, AttrDartP3, NULL_ID_STR); initData.dartP3Id = GetParametrUInt(domElement, AttrDartP3, NULL_ID_STR);
initData.name1 = GetParametrString(domElement, AttrName1, QChar('A')); initData.name1 = GetParametrString(domElement, AttrName1, QChar('A'));
initData.mx1 = qApp->toPixel(GetParametrDouble(domElement, AttrMx1, QStringLiteral("10.0"))); initData.mx1 = qApp->toPixel(GetParametrDouble(domElement, AttrMx1, QString::number(labelMX)));
initData.my1 = qApp->toPixel(GetParametrDouble(domElement, AttrMy1, QStringLiteral("15.0"))); initData.my1 = qApp->toPixel(GetParametrDouble(domElement, AttrMy1, QString::number(labelMY)));
initData.showLabel1 = GetParametrBool(domElement, AttrShowLabel1, trueStr); initData.showLabel1 = GetParametrBool(domElement, AttrShowLabel1, trueStr);
initData.name2 = GetParametrString(domElement, AttrName2, QChar('A')); initData.name2 = GetParametrString(domElement, AttrName2, QChar('A'));
initData.mx2 = qApp->toPixel(GetParametrDouble(domElement, AttrMx2, QStringLiteral("10.0"))); initData.mx2 = qApp->toPixel(GetParametrDouble(domElement, AttrMx2, QString::number(labelMX)));
initData.my2 = qApp->toPixel(GetParametrDouble(domElement, AttrMy2, QStringLiteral("15.0"))); initData.my2 = qApp->toPixel(GetParametrDouble(domElement, AttrMy2, QString::number(labelMY)));
initData.showLabel2 = GetParametrBool(domElement, AttrShowLabel2, trueStr); initData.showLabel2 = GetParametrBool(domElement, AttrShowLabel2, trueStr);
VToolTrueDarts::Create(initData); VToolTrueDarts::Create(initData);
@ -3616,6 +3651,12 @@ quint32 VPattern::LastToolId() const
return NULL_ID; return NULL_ID;
} }
return PPLastToolId(name);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VPattern::PPLastToolId(const QString &name) const
{
const QVector<VToolRecord> localHistory = getLocalHistory(name); const QVector<VToolRecord> localHistory = getLocalHistory(name);
return (not localHistory.isEmpty() ? localHistory.last().getId() : NULL_ID); return (not localHistory.isEmpty() ? localHistory.last().getId() : NULL_ID);

View File

@ -58,7 +58,9 @@ public:
void setCurrentData(); void setCurrentData();
virtual void UpdateToolData(const quint32 &id, VContainer *data) override; virtual void UpdateToolData(const quint32 &id, VContainer *data) override;
VContainer GetCompleteData() const;
virtual VContainer GetCompleteData() const override;
virtual VContainer GetCompletePPData(const QString &name) const override;
virtual void IncrementReferens(quint32 id) const override; virtual void IncrementReferens(quint32 id) const override;
virtual void DecrementReferens(quint32 id) const override; virtual void DecrementReferens(quint32 id) const override;
@ -256,6 +258,7 @@ private:
QString LastDrawName() const; QString LastDrawName() const;
quint32 LastToolId() const; quint32 LastToolId() const;
quint32 PPLastToolId(const QString &name) const;
}; };
#endif // VPATTERN_H #endif // VPATTERN_H

View File

@ -2442,6 +2442,19 @@ QString VAbstractPattern::PieceDrawName(quint32 id)
return draw.attribute(VAbstractPattern::AttrName); return draw.attribute(VAbstractPattern::AttrName);
} }
//---------------------------------------------------------------------------------------------------------------------
VContainer VAbstractPattern::GetCompleteData() const
{
return VContainer(nullptr, nullptr, VContainer::UniqueNamespace());
}
//---------------------------------------------------------------------------------------------------------------------
VContainer VAbstractPattern::GetCompletePPData(const QString &name) const
{
Q_UNUSED(name)
return VContainer(nullptr, nullptr, VContainer::UniqueNamespace());
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QStringList VAbstractPattern::FilterGroupTags(const QString &tags) QStringList VAbstractPattern::FilterGroupTags(const QString &tags)
{ {

View File

@ -230,6 +230,9 @@ public:
QString PieceDrawName(quint32 id); QString PieceDrawName(quint32 id);
virtual VContainer GetCompleteData() const;
virtual VContainer GetCompletePPData(const QString &name) const;
static const QString TagPattern; static const QString TagPattern;
static const QString TagCalculation; static const QString TagCalculation;
static const QString TagModeling; static const QString TagModeling;

View File

@ -79,12 +79,10 @@ T *GetPatternTool(quint32 id)
} // namespace } // namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPatternRecipe::VPatternRecipe(VContainer *data, VAbstractPattern *pattern, QObject *parent) VPatternRecipe::VPatternRecipe(VAbstractPattern *pattern, QObject *parent)
: VDomDocument(parent), : VDomDocument(parent),
m_data(data),
m_pattern(pattern) m_pattern(pattern)
{ {
SCASSERT(data != nullptr)
SCASSERT(pattern != nullptr) SCASSERT(pattern != nullptr)
QDomElement recipeElement = createElement(QStringLiteral("recipe")); QDomElement recipeElement = createElement(QStringLiteral("recipe"));
@ -135,7 +133,8 @@ QDomElement VPatternRecipe::Measurements()
{ {
QDomElement measurements = createElement(QStringLiteral("measurements")); QDomElement measurements = createElement(QStringLiteral("measurements"));
QList<QSharedPointer<VMeasurement>> patternMeasurements = m_data->DataMeasurements().values(); VContainer data = m_pattern->GetCompleteData();
QList<QSharedPointer<VMeasurement>> patternMeasurements = data.DataMeasurements().values();
// Resore order // Resore order
std::sort(patternMeasurements.begin(), patternMeasurements.end(), std::sort(patternMeasurements.begin(), patternMeasurements.end(),
@ -174,7 +173,8 @@ QDomElement VPatternRecipe::Increments()
{ {
QDomElement increments = createElement(QStringLiteral("increments")); QDomElement increments = createElement(QStringLiteral("increments"));
QList<QSharedPointer<VIncrement>> patternIncrements = m_data->DataIncrements().values(); VContainer data = m_pattern->GetCompleteData();
QList<QSharedPointer<VIncrement>> patternIncrements = data.DataIncrementsWithSeparators().values();
// Resore order // Resore order
std::sort(patternIncrements.begin(), patternIncrements.end(), std::sort(patternIncrements.begin(), patternIncrements.end(),
@ -197,7 +197,8 @@ QDomElement VPatternRecipe::PreviewCalculations()
{ {
QDomElement previewCalculations = createElement(QStringLiteral("previewCalculations")); QDomElement previewCalculations = createElement(QStringLiteral("previewCalculations"));
QList<QSharedPointer<VIncrement>> patternIncrements = m_data->DataIncrements().values(); VContainer data = m_pattern->GetCompleteData();
QList<QSharedPointer<VIncrement>> patternIncrements = data.DataIncrementsWithSeparators().values();
// Resore order // Resore order
std::sort(patternIncrements.begin(), patternIncrements.end(), std::sort(patternIncrements.begin(), patternIncrements.end(),
@ -266,12 +267,14 @@ QDomElement VPatternRecipe::Draft(const QDomElement &draft)
const QString draftName = draft.attribute(QStringLiteral("name")); const QString draftName = draft.attribute(QStringLiteral("name"));
SetAttribute(recipeDraft, QStringLiteral("name"), draftName); SetAttribute(recipeDraft, QStringLiteral("name"), draftName);
VContainer data = m_pattern->GetCompletePPData(draftName);
QVector<VToolRecord> *history = m_pattern->getHistory(); QVector<VToolRecord> *history = m_pattern->getHistory();
for (auto &record : *history) for (auto &record : *history)
{ {
if (record.getNameDraw() == draftName) if (record.getNameDraw() == draftName)
{ {
QDomElement step = Step(record); QDomElement step = Step(record, data);
if (not step.isNull()) if (not step.isNull())
{ {
recipeDraft.appendChild(step); recipeDraft.appendChild(step);
@ -283,7 +286,7 @@ QDomElement VPatternRecipe::Draft(const QDomElement &draft)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QDomElement VPatternRecipe::Step(const VToolRecord &tool) QDomElement VPatternRecipe::Step(const VToolRecord &tool, const VContainer &data)
{ {
// This check helps to find missed tools in the switch // This check helps to find missed tools in the switch
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 55, "Not all tools were used in history."); Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 55, "Not all tools were used in history.");
@ -371,13 +374,13 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
case Tool::EllipticalArc: case Tool::EllipticalArc:
return EllipticalArc(tool); return EllipticalArc(tool);
case Tool::Rotation: case Tool::Rotation:
return Rotation(tool); return Rotation(tool, data);
case Tool::FlippingByLine: case Tool::FlippingByLine:
return FlippingByLine(tool); return FlippingByLine(tool, data);
case Tool::FlippingByAxis: case Tool::FlippingByAxis:
return FlippingByAxis(tool); return FlippingByAxis(tool, data);
case Tool::Move: case Tool::Move:
return Move(tool); return Move(tool, data);
//Because "history" not only show history of pattern, but help restore current data for each pattern's //Because "history" not only show history of pattern, but help restore current data for each pattern's
//piece, we need add record about details and nodes, but don't show them. //piece, we need add record about details and nodes, but don't show them.
case Tool::Piece: case Tool::Piece:
@ -411,17 +414,18 @@ QDomElement VPatternRecipe::FinalMeasurements()
QDomElement recipeFinalMeasurements = createElement(QStringLiteral("finalMeasurements")); QDomElement recipeFinalMeasurements = createElement(QStringLiteral("finalMeasurements"));
const QVector<VFinalMeasurement> measurements = m_pattern->GetFinalMeasurements(); const QVector<VFinalMeasurement> measurements = m_pattern->GetFinalMeasurements();
VContainer data = m_pattern->GetCompleteData();
for (auto &m : measurements) for (auto &m : measurements)
{ {
recipeFinalMeasurements.appendChild(FinalMeasurement(m)); recipeFinalMeasurements.appendChild(FinalMeasurement(m, data));
} }
return recipeFinalMeasurements; return recipeFinalMeasurements;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QDomElement VPatternRecipe::FinalMeasurement(const VFinalMeasurement &fm) QDomElement VPatternRecipe::FinalMeasurement(const VFinalMeasurement &fm, const VContainer &data)
{ {
QDomElement recipeFinalMeasurement = createElement(QStringLiteral("finalMeasurement")); QDomElement recipeFinalMeasurement = createElement(QStringLiteral("finalMeasurement"));
@ -430,7 +434,7 @@ QDomElement VPatternRecipe::FinalMeasurement(const VFinalMeasurement &fm)
SetAttribute(recipeFinalMeasurement, QStringLiteral("formula"), fm.formula); // TODO: localize SetAttribute(recipeFinalMeasurement, QStringLiteral("formula"), fm.formula); // TODO: localize
QScopedPointer<Calculator> cal(new Calculator()); QScopedPointer<Calculator> cal(new Calculator());
const qreal result = cal->EvalFormula(m_data->DataVariables(), fm.formula); const qreal result = cal->EvalFormula(data.DataVariables(), fm.formula);
if (qIsInf(result) || qIsNaN(result)) if (qIsInf(result) || qIsNaN(result))
{ {
const QString errorMsg = QString("%1\n\n%1").arg(tr("Reading final measurements error."), const QString errorMsg = QString("%1\n\n%1").arg(tr("Reading final measurements error."),
@ -1002,7 +1006,7 @@ QDomElement VPatternRecipe::EllipticalArc(const VToolRecord &record)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QDomElement VPatternRecipe::Rotation(const VToolRecord &record) QDomElement VPatternRecipe::Rotation(const VToolRecord &record, const VContainer &data)
{ {
auto *tool = GetPatternTool<VToolRotation>(record.getId()); auto *tool = GetPatternTool<VToolRotation>(record.getId());
@ -1013,13 +1017,13 @@ QDomElement VPatternRecipe::Rotation(const VToolRecord &record)
Formula(step, tool->GetFormulaAngle(), AttrAngle, AttrAngleValue); Formula(step, tool->GetFormulaAngle(), AttrAngle, AttrAngleValue);
SetAttribute(step, AttrSuffix, tool->Suffix()); SetAttribute(step, AttrSuffix, tool->Suffix());
step.appendChild(GroupOperationSource(tool, record.getId())); step.appendChild(GroupOperationSource(tool, record.getId(), data));
return step; return step;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QDomElement VPatternRecipe::FlippingByLine(const VToolRecord &record) QDomElement VPatternRecipe::FlippingByLine(const VToolRecord &record, const VContainer &data)
{ {
auto *tool = GetPatternTool<VToolFlippingByLine>(record.getId()); auto *tool = GetPatternTool<VToolFlippingByLine>(record.getId());
@ -1030,13 +1034,13 @@ QDomElement VPatternRecipe::FlippingByLine(const VToolRecord &record)
SetAttribute(step, AttrP2Line, tool->SecondLinePointName()); SetAttribute(step, AttrP2Line, tool->SecondLinePointName());
SetAttribute(step, AttrSuffix, tool->Suffix()); SetAttribute(step, AttrSuffix, tool->Suffix());
step.appendChild(GroupOperationSource(tool, record.getId())); step.appendChild(GroupOperationSource(tool, record.getId(), data));
return step; return step;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QDomElement VPatternRecipe::FlippingByAxis(const VToolRecord &record) QDomElement VPatternRecipe::FlippingByAxis(const VToolRecord &record, const VContainer &data)
{ {
auto *tool = GetPatternTool<VToolFlippingByAxis>(record.getId()); auto *tool = GetPatternTool<VToolFlippingByAxis>(record.getId());
@ -1047,13 +1051,13 @@ QDomElement VPatternRecipe::FlippingByAxis(const VToolRecord &record)
SetAttribute(step, AttrAxisType, static_cast<int>(tool->GetAxisType())); SetAttribute(step, AttrAxisType, static_cast<int>(tool->GetAxisType()));
SetAttribute(step, AttrSuffix, tool->Suffix()); SetAttribute(step, AttrSuffix, tool->Suffix());
step.appendChild(GroupOperationSource(tool, record.getId())); step.appendChild(GroupOperationSource(tool, record.getId(), data));
return step; return step;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QDomElement VPatternRecipe::Move(const VToolRecord &record) QDomElement VPatternRecipe::Move(const VToolRecord &record, const VContainer &data)
{ {
auto *tool = GetPatternTool<VToolMove>(record.getId()); auto *tool = GetPatternTool<VToolMove>(record.getId());
@ -1066,7 +1070,7 @@ QDomElement VPatternRecipe::Move(const VToolRecord &record)
SetAttribute(step, AttrCenter, tool->OriginPointName()); SetAttribute(step, AttrCenter, tool->OriginPointName());
SetAttribute(step, AttrSuffix, tool->Suffix()); SetAttribute(step, AttrSuffix, tool->Suffix());
step.appendChild(GroupOperationSource(tool, record.getId())); step.appendChild(GroupOperationSource(tool, record.getId(), data));
return step; return step;
} }
@ -1103,7 +1107,7 @@ void VPatternRecipe::CurveAttributes(QDomElement &step, T *tool)
SetAttribute(step, AttrPenStyle, tool->GetPenStyle()); SetAttribute(step, AttrPenStyle, tool->GetPenStyle());
SetAttribute(step, AttrAScale, tool->GetApproximationScale()); SetAttribute(step, AttrAScale, tool->GetApproximationScale());
SetAttribute(step, AttrDuplicate, tool->GetDuplicate()); SetAttribute(step, AttrDuplicate, tool->GetDuplicate());
SetAttribute(step, AttrAlias, tool->GetAliasSuffix()); SetAttributeOrRemoveIf(step, AttrAlias, tool->GetAliasSuffix(), tool->GetAliasSuffix().isEmpty());
} }
@ -1111,8 +1115,8 @@ void VPatternRecipe::CurveAttributes(QDomElement &step, T *tool)
template<typename T> template<typename T>
void VPatternRecipe::CutCurveAttributes(QDomElement &step, T *tool) void VPatternRecipe::CutCurveAttributes(QDomElement &step, T *tool)
{ {
SetAttribute(step, AttrAlias1, tool->GetAliasSuffix1()); SetAttributeOrRemoveIf(step, AttrAlias1, tool->GetAliasSuffix1(), tool->GetAliasSuffix1().isEmpty());
SetAttribute(step, AttrAlias2, tool->GetAliasSuffix2()); SetAttributeOrRemoveIf(step, AttrAlias2, tool->GetAliasSuffix2(), tool->GetAliasSuffix2().isEmpty());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -1125,7 +1129,7 @@ inline void VPatternRecipe::ToolAttributes(QDomElement &step, T *tool)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QDomElement VPatternRecipe::GroupOperationSource(VAbstractOperation *tool, quint32 id) QDomElement VPatternRecipe::GroupOperationSource(VAbstractOperation *tool, quint32 id, const VContainer &data)
{ {
SCASSERT(tool) SCASSERT(tool)
@ -1145,7 +1149,7 @@ QDomElement VPatternRecipe::GroupOperationSource(VAbstractOperation *tool, quint
try try
{ {
obj = m_data->GetGObject(item.id); obj = data.GetGObject(item.id);
} }
catch (const VExceptionBadId &e) catch (const VExceptionBadId &e)
{ {
@ -1153,11 +1157,8 @@ QDomElement VPatternRecipe::GroupOperationSource(VAbstractOperation *tool, quint
continue; continue;
} }
SetAttribute(node, AttrItem, obj->name()); SetAttribute(node, AttrItem, obj->ObjectName());
if (not obj->GetAlias().isEmpty()) SetAttributeOrRemoveIf(node, AttrAlias, item.alias, item.alias.isEmpty());
{
SetAttribute(node, AttrAlias, obj->GetAlias());
}
if (obj->getType() != GOType::Point) if (obj->getType() != GOType::Point)
{ {
@ -1172,6 +1173,34 @@ QDomElement VPatternRecipe::GroupOperationSource(VAbstractOperation *tool, quint
} }
} }
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default")
switch(static_cast<GOType>(obj->getType()))
{
case GOType::Point:
SetAttribute(node, AttrType, QStringLiteral("point"));
break;
case GOType::Arc:
SetAttribute(node, AttrType, QStringLiteral("arc"));
break;
case GOType::EllipticalArc:
SetAttribute(node, AttrType, QStringLiteral("elArc"));
break;
case GOType::Spline:
case GOType::CubicBezier:
SetAttribute(node, AttrType, QStringLiteral("spline"));
break;
case GOType::SplinePath:
case GOType::CubicBezierPath:
SetAttribute(node, AttrType, QStringLiteral("splinePath"));
break;
case GOType::Unknown:
case GOType::PlaceLabel:
Q_UNREACHABLE();
break;
}
QT_WARNING_POP
nodes.appendChild(node); nodes.appendChild(node);
} }

View File

@ -43,13 +43,12 @@ class VPatternRecipe : public VDomDocument
{ {
Q_DECLARE_TR_FUNCTIONS(VPatternRecipe) Q_DECLARE_TR_FUNCTIONS(VPatternRecipe)
public: public:
VPatternRecipe(VContainer *data, VAbstractPattern *pattern, QObject *parent = nullptr); explicit VPatternRecipe(VAbstractPattern *pattern, QObject *parent = nullptr);
virtual ~VPatternRecipe() Q_DECL_EQ_DEFAULT; virtual ~VPatternRecipe() Q_DECL_EQ_DEFAULT;
private: private:
Q_DISABLE_COPY(VPatternRecipe) Q_DISABLE_COPY(VPatternRecipe)
VContainer *m_data;
VAbstractPattern *m_pattern; VAbstractPattern *m_pattern;
QDomElement Prerequisite(); QDomElement Prerequisite();
@ -64,10 +63,10 @@ private:
QDomElement Content(); QDomElement Content();
QDomElement Draft(const QDomElement &draft); QDomElement Draft(const QDomElement &draft);
QDomElement Step(const VToolRecord &tool); QDomElement Step(const VToolRecord &tool, const VContainer &data);
QDomElement FinalMeasurements(); QDomElement FinalMeasurements();
QDomElement FinalMeasurement(const VFinalMeasurement &fm); QDomElement FinalMeasurement(const VFinalMeasurement &fm, const VContainer &data);
QDomElement BasePoint(const VToolRecord &record); QDomElement BasePoint(const VToolRecord &record);
QDomElement EndLine(const VToolRecord &record); QDomElement EndLine(const VToolRecord &record);
@ -99,10 +98,10 @@ private:
QDomElement PointFromArcAndTangent(const VToolRecord &record); QDomElement PointFromArcAndTangent(const VToolRecord &record);
QDomElement TrueDarts(const VToolRecord &record); QDomElement TrueDarts(const VToolRecord &record);
QDomElement EllipticalArc(const VToolRecord &record); QDomElement EllipticalArc(const VToolRecord &record);
QDomElement Rotation(const VToolRecord &record); QDomElement Rotation(const VToolRecord &record, const VContainer &data);
QDomElement FlippingByLine(const VToolRecord &record); QDomElement FlippingByLine(const VToolRecord &record, const VContainer &data);
QDomElement FlippingByAxis(const VToolRecord &record); QDomElement FlippingByAxis(const VToolRecord &record, const VContainer &data);
QDomElement Move(const VToolRecord &record); QDomElement Move(const VToolRecord &record, const VContainer &data);
void Formula(QDomElement &step, const VFormula &formula, const QString &formulaStr, const QString &formulaValue); void Formula(QDomElement &step, const VFormula &formula, const QString &formulaStr, const QString &formulaValue);
@ -118,7 +117,7 @@ private:
template <typename T> template <typename T>
void CutCurveAttributes(QDomElement &step, T* tool); void CutCurveAttributes(QDomElement &step, T* tool);
QDomElement GroupOperationSource(VAbstractOperation *tool, quint32 id); QDomElement GroupOperationSource(VAbstractOperation *tool, quint32 id, const VContainer &data);
}; };
#endif // VPATTERNRECIPE_H #endif // VPATTERNRECIPE_H

View File

@ -28,10 +28,11 @@
#include "dialoglayoutscale.h" #include "dialoglayoutscale.h"
#include "ui_dialoglayoutscale.h" #include "ui_dialoglayoutscale.h"
#include "../core/vapplication.h" #include "../vmisc/vabstractvalapplication.h"
#include "../core/vvalentinasettings.h" #include "../vmisc/vcommonsettings.h"
#include <QPushButton> #include <QPushButton>
#include <QShowEvent>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogLayoutScale::DialogLayoutScale(bool printTiled, QWidget *parent) DialogLayoutScale::DialogLayoutScale(bool printTiled, QWidget *parent)
@ -40,7 +41,7 @@ DialogLayoutScale::DialogLayoutScale(bool printTiled, QWidget *parent)
{ {
ui->setupUi(this); ui->setupUi(this);
qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok); QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
SCASSERT(bOk != nullptr) SCASSERT(bOk != nullptr)
@ -180,7 +181,7 @@ void DialogLayoutScale::VerticalScaleChanged(double d)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogLayoutScale::ReadSettings() void DialogLayoutScale::ReadSettings()
{ {
VValentinaSettings *settings = qApp->ValentinaSettings(); VCommonSettings *settings = qApp->Settings();
const Unit unit = qApp->patternUnits(); const Unit unit = qApp->patternUnits();
// read Margins top, right, bottom, left // read Margins top, right, bottom, left
@ -200,7 +201,7 @@ void DialogLayoutScale::ReadSettings()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogLayoutScale::WriteSettings() const void DialogLayoutScale::WriteSettings() const
{ {
VValentinaSettings *settings = qApp->ValentinaSettings(); VCommonSettings *settings = qApp->Settings();
const Unit unit = qApp->patternUnits(); const Unit unit = qApp->patternUnits();
// write Margins top, right, bottom, left // write Margins top, right, bottom, left

View File

@ -0,0 +1,13 @@
# ADD TO EACH PATH $$PWD VARIABLE!!!!!!
# This need for corect working file translations.pro
HEADERS += \
$$PWD/dialoglayoutscale.h \
$$PWD/vabstractlayoutdialog.h
SOURCES += \
$$PWD/dialoglayoutscale.cpp \
$$PWD/vabstractlayoutdialog.cpp
FORMS += \
$$PWD/dialoglayoutscale.ui

View File

@ -27,7 +27,7 @@
*************************************************************************/ *************************************************************************/
#include "vabstractlayoutdialog.h" #include "vabstractlayoutdialog.h"
#include "../core/vapplication.h" #include "../vmisc/vabstractapplication.h"
#include "../vmisc/vmath.h" #include "../vmisc/vmath.h"
//must be the same order as PaperSizeTemplate constants //must be the same order as PaperSizeTemplate constants
@ -61,8 +61,8 @@ VAbstractLayoutDialog::VAbstractLayoutDialog(QWidget *parent)
void VAbstractLayoutDialog::InitTemplates(QComboBox *comboBoxTemplates) void VAbstractLayoutDialog::InitTemplates(QComboBox *comboBoxTemplates)
{ {
SCASSERT(comboBoxTemplates != nullptr) SCASSERT(comboBoxTemplates != nullptr)
const QIcon icoPaper("://icon/16x16/template.png"); const QIcon icoPaper(QLatin1String("://icon/16x16/template.png"));
const QIcon icoRoll("://icon/16x16/roll.png"); const QIcon icoRoll(QLatin1String("://icon/16x16/roll.png"));
const QString pdi = QStringLiteral("(%1ppi)").arg(PrintDPI); const QString pdi = QStringLiteral("(%1ppi)").arg(PrintDPI);
auto cntr = static_cast<VIndexType>(PaperSizeTemplate::A0); auto cntr = static_cast<VIndexType>(PaperSizeTemplate::A0);
@ -85,7 +85,7 @@ void VAbstractLayoutDialog::InitTemplates(QComboBox *comboBoxTemplates)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QSizeF VAbstractLayoutDialog::GetTemplateSize(PaperSizeTemplate tmpl, Unit unit) auto VAbstractLayoutDialog::GetTemplateSize(PaperSizeTemplate tmpl, Unit unit) -> QSizeF
{ {
qreal width = 0; qreal width = 0;
qreal height = 0; qreal height = 0;
@ -159,11 +159,11 @@ QSizeF VAbstractLayoutDialog::GetTemplateSize(PaperSizeTemplate tmpl, Unit unit)
default: default:
break; break;
} }
return QSizeF(); return {};
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QSizeF VAbstractLayoutDialog::RoundTemplateSize(qreal width, qreal height, Unit unit) auto VAbstractLayoutDialog::RoundTemplateSize(qreal width, qreal height, Unit unit) -> QSizeF
{ {
qreal w = 0; qreal w = 0;
qreal h = 0; qreal h = 0;
@ -175,14 +175,14 @@ QSizeF VAbstractLayoutDialog::RoundTemplateSize(qreal width, qreal height, Unit
case Unit::Px: case Unit::Px:
w = vRound(width, 2); w = vRound(width, 2);
h = vRound(height, 2); h = vRound(height, 2);
return QSizeF(w, h); return {w, h};
case Unit::Inch: case Unit::Inch:
w = vRound(width, 5); w = vRound(width, 5);
h = vRound(height, 5); h = vRound(height, 5);
return QSizeF(w, h); return {w, h};
default: default:
break; break;
} }
return QSizeF(width, height); return {width, height};
} }

View File

@ -59,16 +59,16 @@ public:
explicit VAbstractLayoutDialog(QWidget *parent = nullptr); explicit VAbstractLayoutDialog(QWidget *parent = nullptr);
static QSizeF GetTemplateSize(PaperSizeTemplate tmpl, Unit unit); static auto GetTemplateSize(PaperSizeTemplate tmpl, Unit unit) -> QSizeF;
protected: protected:
typedef QStringList FormatsVector; typedef QStringList FormatsVector;
const static FormatsVector pageFormatNames; const static FormatsVector pageFormatNames;
typedef int VIndexType; typedef int VIndexType;
static QSizeF RoundTemplateSize(qreal width, qreal height, Unit unit); static auto RoundTemplateSize(qreal width, qreal height, Unit unit) -> QSizeF;
void InitTemplates(QComboBox *comboBoxTemplates); static void InitTemplates(QComboBox *comboBoxTemplates);
private: private:
Q_DISABLE_COPY(VAbstractLayoutDialog) Q_DISABLE_COPY(VAbstractLayoutDialog)
}; };

View File

@ -38,6 +38,7 @@
#include "../vmisc/typedef.h" #include "../vmisc/typedef.h"
#include "vlayoutpiece.h" #include "vlayoutpiece.h"
#include "vlayoutdef.h"
// An annoying char define, from the Windows team in <rpcndr.h> // An annoying char define, from the Windows team in <rpcndr.h>
// #define small char // #define small char
@ -49,8 +50,6 @@
Q_DECLARE_LOGGING_CATEGORY(lBank) Q_DECLARE_LOGGING_CATEGORY(lBank)
enum class Cases : qint8 { CaseThreeGroup = 0, CaseTwoGroup, CaseDesc, UnknownCase};
class VBank class VBank
{ {
Q_DECLARE_TR_FUNCTIONS(VBank) Q_DECLARE_TR_FUNCTIONS(VBank)

View File

@ -1,9 +1,13 @@
# ADD TO EACH PATH $$PWD VARIABLE!!!!!! # ADD TO EACH PATH $$PWD VARIABLE!!!!!!
# This need for corect working file translations.pro # This need for corect working file translations.pro
# Suport subdirectories. Just better project code tree.
include(dialogs/dialogs.pri)
HEADERS += \ HEADERS += \
$$PWD/stable.h \ $$PWD/stable.h \
$$PWD/testpath.h \ $$PWD/testpath.h \
$$PWD/vlayoutexporter.h \
$$PWD/vlayoutgenerator.h \ $$PWD/vlayoutgenerator.h \
$$PWD/vlayoutdef.h \ $$PWD/vlayoutdef.h \
$$PWD/vlayoutpaper.h \ $$PWD/vlayoutpaper.h \
@ -14,6 +18,7 @@ HEADERS += \
$$PWD/vbestsquare.h \ $$PWD/vbestsquare.h \
$$PWD/vposition.h \ $$PWD/vposition.h \
$$PWD/vrawlayout.h \ $$PWD/vrawlayout.h \
$$PWD/vprintlayout.h \
$$PWD/vsapoint.h \ $$PWD/vsapoint.h \
$$PWD/vtextmanager.h \ $$PWD/vtextmanager.h \
$$PWD/vposter.h \ $$PWD/vposter.h \
@ -29,6 +34,7 @@ HEADERS += \
SOURCES += \ SOURCES += \
$$PWD/testpath.cpp \ $$PWD/testpath.cpp \
$$PWD/vlayoutexporter.cpp \
$$PWD/vlayoutgenerator.cpp \ $$PWD/vlayoutgenerator.cpp \
$$PWD/vlayoutpaper.cpp \ $$PWD/vlayoutpaper.cpp \
$$PWD/vbank.cpp \ $$PWD/vbank.cpp \
@ -36,6 +42,7 @@ SOURCES += \
$$PWD/vbestsquare.cpp \ $$PWD/vbestsquare.cpp \
$$PWD/vposition.cpp \ $$PWD/vposition.cpp \
$$PWD/vrawlayout.cpp \ $$PWD/vrawlayout.cpp \
$$PWD/vprintlayout.cpp \
$$PWD/vtextmanager.cpp \ $$PWD/vtextmanager.cpp \
$$PWD/vposter.cpp \ $$PWD/vposter.cpp \
$$PWD/vgraphicsfillitem.cpp \ $$PWD/vgraphicsfillitem.cpp \

View File

@ -116,6 +116,8 @@ struct VCachedPositions
QPainterPath layoutAllowancePath{}; QPainterPath layoutAllowancePath{};
}; };
enum class Cases : qint8 { CaseThreeGroup = 0, CaseTwoGroup, CaseDesc, UnknownCase};
/* Warning! Debugging doesn't work stable in debug mode. If you need big allocation use release mode. Or disable /* Warning! Debugging doesn't work stable in debug mode. If you need big allocation use release mode. Or disable
* Address Sanitizer. See page https://bitbucket.org/dismine/valentina/wiki/developers/Address_Sanitizer * Address Sanitizer. See page https://bitbucket.org/dismine/valentina/wiki/developers/Address_Sanitizer
*/ */

View File

@ -0,0 +1,368 @@
/************************************************************************
**
** @file vlayoutexporter.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 19 12, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vlayoutexporter.h"
#include <QFileInfo>
#include <QGraphicsScene>
#include <QGuiApplication>
#include <QPainter>
#include <QPrinter>
#include <QProcess>
#include <QSvgGenerator>
#include <QTemporaryFile>
#include <QtDebug>
#include <QCursor>
#include <QGraphicsItem>
#include "../vmisc/vmath.h"
#include "../vmisc/defglobal.h"
#include "../vmisc/def.h"
#include "../vobj/vobjpaintdevice.h"
#include "../vdxf/vdxfpaintdevice.h"
namespace
{
#ifdef Q_OS_WIN
Q_GLOBAL_STATIC_WITH_ARGS(const QString, PDFTOPS, (QLatin1String("pdftops.exe")))
#else
Q_GLOBAL_STATIC_WITH_ARGS(const QString, PDFTOPS, (QLatin1String("pdftops")))
#endif
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief PrepareTextForDXF prepare QGraphicsSimpleTextItem items for export to flat dxf.
*
* Because QPaintEngine::drawTextItem doesn't pass whole string per time we mark end of each string by adding special
* placholder. This method append it.
*
* @param placeholder placeholder that will be appended to each QGraphicsSimpleTextItem item's text string.
*/
void PrepareTextForDXF(const QString &placeholder, const QList<QList<QGraphicsItem *> > &details)
{
for (const auto &paperItems : details)
{
for (auto *item : paperItems)
{
QList<QGraphicsItem *> pieceChildren = item->childItems();
for (auto *child : qAsConst(pieceChildren))
{
if (child->type() == QGraphicsSimpleTextItem::Type)
{
if(auto *textItem = qgraphicsitem_cast<QGraphicsSimpleTextItem *>(child))
{
textItem->setText(textItem->text() + placeholder);
}
}
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RestoreTextAfterDXF restore QGraphicsSimpleTextItem items after export to flat dxf.
*
* Because QPaintEngine::drawTextItem doesn't pass whole string per time we mark end of each string by adding special
* placholder. This method remove it.
*
* @param placeholder placeholder that will be removed from each QGraphicsSimpleTextItem item's text string.
*/
void RestoreTextAfterDXF(const QString &placeholder, const QList<QList<QGraphicsItem *> > &details)
{
for (const auto &paperItems : details)
{
for (auto *item : paperItems)
{
QList<QGraphicsItem *> pieceChildren = item->childItems();
for (auto *child : qAsConst(pieceChildren))
{
if (child->type() == QGraphicsSimpleTextItem::Type)
{
if(auto *textItem = qgraphicsitem_cast<QGraphicsSimpleTextItem *>(child))
{
QString text = textItem->text();
text.replace(placeholder, QString());
textItem->setText(text);
}
}
}
}
}
}
} // namespace
//---------------------------------------------------------------------------------------------------------------------
void VLayoutExporter::ExportToSVG(QGraphicsScene *scene) const
{
QSvgGenerator generator;
generator.setFileName(m_fileName);
QSize drawingSize;
drawingSize.setWidth(qFloor(m_imageRect.width() * m_xScale + m_margins.left() + m_margins.right()));
drawingSize.setHeight(qFloor(m_imageRect.height() * m_yScale + m_margins.top() + m_margins.bottom()));
generator.setSize(drawingSize);
QRectF viewBoxRect;
viewBoxRect.setWidth(m_imageRect.width() * m_xScale + m_margins.left() + m_margins.right());
viewBoxRect.setHeight(m_imageRect.height() * m_yScale + m_margins.top() + m_margins.bottom());
generator.setViewBox(viewBoxRect);
generator.setTitle(m_title);
generator.setDescription(m_description);
generator.setResolution(static_cast<int>(PrintDPI));
QPainter painter;
painter.begin(&generator);
painter.translate(m_margins.left(), m_margins.top());
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(m_pen);
painter.setBrush(QBrush(Qt::NoBrush));
painter.scale(m_xScale, m_yScale);
scene->render(&painter, m_imageRect, m_imageRect, Qt::IgnoreAspectRatio);
painter.end();
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutExporter::ExportToPNG(QGraphicsScene *scene) const
{
// Create the image with the exact size of the shrunk scene
QSize drawingSize;
drawingSize.setWidth(qFloor(m_imageRect.width() * m_xScale + m_margins.left() + m_margins.right()));
drawingSize.setHeight(qFloor(m_imageRect.height() * m_yScale + m_margins.top() + m_margins.bottom()));
QImage image(drawingSize, QImage::Format_ARGB32);
image.fill(Qt::white);
QPainter painter(&image);
painter.translate(m_margins.left(), m_margins.top());
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(m_pen);
painter.setBrush(QBrush(Qt::NoBrush));
painter.scale(m_xScale, m_yScale);
scene->render(&painter, m_imageRect, m_imageRect, Qt::IgnoreAspectRatio);
image.save(m_fileName);
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutExporter::ExportToPDF(QGraphicsScene *scene) const
{
QPrinter printer;
printer.setCreator(QGuiApplication::applicationDisplayName() + QChar(QChar::Space) +
QCoreApplication::applicationVersion());
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName(m_fileName);
printer.setDocName(QFileInfo(m_fileName).fileName());
printer.setResolution(static_cast<int>(PrintDPI));
printer.setOrientation(QPrinter::Portrait);
printer.setFullPage(m_ignorePrinterMargins);
qreal width = FromPixel(m_imageRect.width() * m_xScale + m_margins.left() + m_margins.right(), Unit::Mm);
qreal height = FromPixel(m_imageRect.height() * m_yScale + m_margins.top() + m_margins.bottom(), Unit::Mm);
if (not printer.setPageSize(QPageSize(QSizeF(width, height), QPageSize::Millimeter)))
{
qWarning() << tr("Cannot set printer page size");
}
const qreal left = FromPixel(m_margins.left(), Unit::Mm);
const qreal top = FromPixel(m_margins.top(), Unit::Mm);
const qreal right = FromPixel(m_margins.right(), Unit::Mm);
const qreal bottom = FromPixel(m_margins.bottom(), Unit::Mm);
if (not printer.setPageMargins(QMarginsF(left, top, right, bottom), QPageLayout::Millimeter))
{
qWarning() << tr("Cannot set printer margins");
}
QPainter painter;
if (not painter.begin(&printer))
{ // failed to open file
qCritical() << qUtf8Printable(tr("Can't open file '%1'").arg(m_fileName));
return;
}
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(m_pen);
painter.setBrush(QBrush(Qt::NoBrush));
painter.scale(m_xScale, m_yScale);
scene->render(&painter, m_imageRect, m_imageRect, Qt::IgnoreAspectRatio);
painter.end();
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutExporter::ExportToOBJ(QGraphicsScene *scene) const
{
VObjPaintDevice generator;
generator.setFileName(m_fileName);
generator.setSize(m_imageRect.size().toSize());
generator.setResolution(static_cast<int>(PrintDPI));
QPainter painter;
painter.begin(&generator);
scene->render(&painter, m_imageRect, m_imageRect, Qt::IgnoreAspectRatio);
painter.end();
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutExporter::ExportToPS(QGraphicsScene *scene) const
{
QTemporaryFile tmp;
if (tmp.open())
{
ExportToPDF(scene);
PdfToPs(QStringList{tmp.fileName(), m_fileName});
}
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutExporter::ExportToEPS(QGraphicsScene *scene) const
{
QTemporaryFile tmp;
if (tmp.open())
{
ExportToPDF(scene);
PdfToPs(QStringList{QStringLiteral("-eps"), tmp.fileName(), m_fileName});
}
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutExporter::ExportToFlatDXF(QGraphicsScene *scene, const QList<QList<QGraphicsItem *> > &details) const
{
PrepareTextForDXF(endStringPlaceholder, details);
VDxfPaintDevice generator;
generator.setFileName(m_fileName);
generator.setSize(QSize(qFloor(m_imageRect.width() * m_xScale), qFloor(m_imageRect.height() * m_yScale)));
generator.setResolution(PrintDPI);
generator.SetVersion(static_cast<DRW::Version>(m_dxfVersion));
generator.SetBinaryFormat(m_binaryDxfFormat);
generator.setInsunits(VarInsunits::Millimeters);// Decided to always use mm. See issue #745
QPainter painter;
if (painter.begin(&generator))
{
painter.scale(m_xScale, m_yScale);
scene->render(&painter, m_imageRect, m_imageRect, Qt::IgnoreAspectRatio);
painter.end();
}
RestoreTextAfterDXF(endStringPlaceholder, details);
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutExporter::ExportToAAMADXF(const QVector<VLayoutPiece> &details) const
{
VDxfPaintDevice generator;
generator.setFileName(m_fileName);
generator.setSize(QSize(qCeil(m_imageRect.width() * m_xScale), qCeil(m_imageRect.height() * m_yScale)));
generator.setResolution(PrintDPI);
generator.SetVersion(static_cast<DRW::Version>(m_dxfVersion));
generator.SetBinaryFormat(m_binaryDxfFormat);
generator.setInsunits(VarInsunits::Millimeters);// Decided to always use mm. See issue #745
generator.SetXScale(m_xScale);
generator.SetYScale(m_yScale);
generator.ExportToAAMA(details);
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutExporter::ExportToASTMDXF(const QVector<VLayoutPiece> &details) const
{
VDxfPaintDevice generator;
generator.setFileName(m_fileName);
generator.setSize(QSize(qCeil(m_imageRect.width() * m_xScale), qCeil(m_imageRect.height() * m_yScale)));
generator.setResolution(PrintDPI);
generator.SetVersion(static_cast<DRW::Version>(m_dxfVersion));
generator.SetBinaryFormat(m_binaryDxfFormat);
generator.setInsunits(VarInsunits::Millimeters);// Decided to always use mm. See issue #745
generator.SetXScale(m_xScale);
generator.SetYScale(m_yScale);
generator.ExportToASTM(details);
}
//---------------------------------------------------------------------------------------------------------------------
auto VLayoutExporter::SupportPDFConversion() -> bool
{
bool res = false;
QProcess proc;
#if defined(Q_OS_WIN) || defined(Q_OS_OSX)
// Seek pdftops in app bundle or near valentina.exe
proc.start(qApp->applicationDirPath() + QLatin1String("/")+ *PDFTOPS, QStringList());
#else
proc.start(*PDFTOPS, QStringList()); // Seek pdftops in standard path
#endif
const int timeout = 15000;
if (proc.waitForStarted(timeout) && (proc.waitForFinished(timeout) || proc.state() == QProcess::NotRunning))
{
res = true;
}
else
{
qDebug() << *PDFTOPS << "error" << proc.error() << proc.errorString();
}
return res;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief PdfToPs use external tool "pdftops" for converting pdf too eps or ps format.
* @param params string with parameter for tool. Parameters have format: "-eps input_file out_file". Use -eps when
* need create eps file.
*/
void VLayoutExporter::PdfToPs(const QStringList &params)
{
#ifndef QT_NO_CURSOR
QGuiApplication::setOverrideCursor(Qt::WaitCursor);
#endif
QProcess proc;
#if defined(Q_OS_MAC)
// Fix issue #594. Broken export on Mac.
proc.setWorkingDirectory(qApp->applicationDirPath());
proc.start(QLatin1String("./") + *PDFTOPS, params);
#else
proc.start(*PDFTOPS, params);
#endif
const int timeout = 15000;
if (proc.waitForStarted(timeout))
{
proc.waitForFinished(timeout);
}
#ifndef QT_NO_CURSOR
QGuiApplication::restoreOverrideCursor();
#endif
QFile f(params.last());
if (not f.exists())
{
qCritical() << qUtf8Printable(tr("Creating file '%1' failed! %2").arg(params.last(), proc.errorString()));
}
}

View File

@ -0,0 +1,240 @@
/************************************************************************
**
** @file vlayoutexporter.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 19 12, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VLAYOUTEXPORTER_H
#define VLAYOUTEXPORTER_H
#include <QMargins>
#include <QPen>
#include <QRectF>
#include <QString>
#include <QCoreApplication>
class QGraphicsScene;
class QGraphicsItem;
class VLayoutPiece;
class VLayoutExporter
{
Q_DECLARE_TR_FUNCTIONS(VLayoutExporter)
public:
VLayoutExporter() = default;
auto FileName() const -> QString;
void SetFileName(const QString &fileName);
auto Margins() const -> QMarginsF;
void SetMargins(const QMarginsF &margins);
auto ImageRect() const -> QRectF;
void SetImageRect(const QRectF &imageRect);
auto XScale() const -> qreal;
void SetXScale(qreal xScale);
auto YScale() const -> qreal;
void SetYScale(qreal yScale);
auto Title() const -> QString;
void SetTitle(const QString &title);
auto Description() const -> QString;
void SetDescription(const QString &description);
auto Pen() const -> QPen;
void SetPen(const QPen &pen);
auto IgnorePrinterMargins() const -> bool;
void SetIgnorePrinterMargins(bool ignorePrinterMargins);
auto BinaryDxfFormat() const -> bool;
void SetBinaryDxfFormat(bool binaryFormat);
auto DxfVersion() const -> int;
void SetDxfVersion(int dxfVersion);
void ExportToSVG(QGraphicsScene *scene) const;
void ExportToPNG(QGraphicsScene *scene) const;
void ExportToPDF(QGraphicsScene *scene) const;
void ExportToOBJ(QGraphicsScene *scene) const;
void ExportToPS(QGraphicsScene *scene) const;
void ExportToEPS(QGraphicsScene *scene) const;
void ExportToFlatDXF(QGraphicsScene *scene, const QList<QList<QGraphicsItem *> > &details) const;
void ExportToAAMADXF(const QVector<VLayoutPiece> &details) const;
void ExportToASTMDXF(const QVector<VLayoutPiece> &details) const;
static auto SupportPDFConversion() -> bool;
private:
QString m_fileName{};
QMarginsF m_margins{};
QRectF m_imageRect{};
qreal m_xScale{1.0};
qreal m_yScale{1.0};
QString m_title{};
QString m_description{};
QPen m_pen{};
bool m_ignorePrinterMargins{false};
bool m_binaryDxfFormat{false};
int m_dxfVersion{0};
static void PdfToPs(const QStringList &params);
};
//---------------------------------------------------------------------------------------------------------------------
inline auto VLayoutExporter::FileName() const -> QString
{
return m_fileName;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VLayoutExporter::SetFileName(const QString &fileName)
{
m_fileName = fileName;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VLayoutExporter::Margins() const -> QMarginsF
{
return m_margins;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VLayoutExporter::SetMargins(const QMarginsF &margins)
{
m_margins = margins;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VLayoutExporter::ImageRect() const -> QRectF
{
return m_imageRect;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VLayoutExporter::SetImageRect(const QRectF &imageRect)
{
m_imageRect = imageRect;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VLayoutExporter::XScale() const -> qreal
{
return m_xScale;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VLayoutExporter::SetXScale(qreal xScale)
{
m_xScale = xScale;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VLayoutExporter::YScale() const -> qreal
{
return m_yScale;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VLayoutExporter::SetYScale(qreal yScale)
{
m_yScale = yScale;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VLayoutExporter::Title() const -> QString
{
return m_title;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VLayoutExporter::SetTitle(const QString &title)
{
m_title = title;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VLayoutExporter::Description() const -> QString
{
return m_description;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VLayoutExporter::SetDescription(const QString &description)
{
m_description = description;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VLayoutExporter::Pen() const -> QPen
{
return m_pen;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VLayoutExporter::SetPen(const QPen &pen)
{
m_pen = pen;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VLayoutExporter::IgnorePrinterMargins() const -> bool
{
return m_ignorePrinterMargins;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VLayoutExporter::SetIgnorePrinterMargins(bool ignorePrinterMargins)
{
m_ignorePrinterMargins = ignorePrinterMargins;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VLayoutExporter::BinaryDxfFormat() const -> bool
{
return m_binaryDxfFormat;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VLayoutExporter::SetBinaryDxfFormat(bool binaryFormat)
{
m_binaryDxfFormat = binaryFormat;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VLayoutExporter::DxfVersion() const -> int
{
return m_dxfVersion;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VLayoutExporter::SetDxfVersion(int dxfVersion)
{
m_dxfVersion = dxfVersion;
}
#endif // VLAYOUTEXPORTER_H

View File

@ -263,6 +263,11 @@ void VLayoutGenerator::Generate(const QElapsedTimer &timer, qint64 timeout, Layo
GatherPages(); GatherPages();
} }
if (autoCropWidth)
{
OptimizeWidth();
}
if (IsUnitePages()) if (IsUnitePages())
{ {
UnitePages(); UnitePages();
@ -506,6 +511,27 @@ void VLayoutGenerator::GatherPages()
papers = nPapers; papers = nPapers;
} }
//---------------------------------------------------------------------------------------------------------------------
void VLayoutGenerator::OptimizeWidth()
{
QVector<VLayoutPiece> newDetails;
for (auto &paper : papers)
{
const QRectF rec = paper.DetailsBoundingRect();
QVector<VLayoutPiece> details = paper.GetDetails();
newDetails.resize(0); // resize(0) preserves capacity, unlike QVector::clear()
newDetails.reserve(details.size());
for (auto &d : details)
{
IsPortrait() ? d.Translate(-rec.x()+1, 0) : d.Translate(0, -rec.y()+1);
newDetails.append(d);
}
paper.SetDetails(newDetails);
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VLayoutGenerator::UnitePages() void VLayoutGenerator::UnitePages()
{ {
@ -785,6 +811,7 @@ void VLayoutGenerator::SetAutoCropLength(bool value)
autoCropLength = value; autoCropLength = value;
} }
//---------------------------------------------------------------------------------------------------------------------
bool VLayoutGenerator::GetAutoCropWidth() const bool VLayoutGenerator::GetAutoCropWidth() const
{ {
return autoCropWidth; return autoCropWidth;

View File

@ -169,6 +169,7 @@ private:
int PageHeight() const; int PageHeight() const;
int PageWidth() const; int PageWidth() const;
void OptimizeWidth();
void GatherPages(); void GatherPages();
void UnitePages(); void UnitePages();
void UniteDetails(int j, QList<QList<VLayoutPiece> > &nDetails, qreal length, int i) const; void UniteDetails(int j, QList<QList<VLayoutPiece> > &nDetails, qreal length, int i) const;

View File

@ -435,6 +435,12 @@ QVector<VLayoutPiece> VLayoutPaper::GetDetails() const
return d->details; return d->details;
} }
//---------------------------------------------------------------------------------------------------------------------
void VLayoutPaper::SetDetails(const QVector<VLayoutPiece> &details)
{
d->details = details;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VLayoutPaper::SetDetails(const QList<VLayoutPiece> &details) void VLayoutPaper::SetDetails(const QList<VLayoutPiece> &details)
{ {

View File

@ -99,6 +99,7 @@ public:
Q_REQUIRED_RESULT QList<QGraphicsItem *> GetItemDetails(bool textAsPaths) const; Q_REQUIRED_RESULT QList<QGraphicsItem *> GetItemDetails(bool textAsPaths) const;
QVector<VLayoutPiece> GetDetails() const; QVector<VLayoutPiece> GetDetails() const;
void SetDetails(const QVector<VLayoutPiece>& details);
void SetDetails(const QList<VLayoutPiece>& details); void SetDetails(const QList<VLayoutPiece>& details);
QRectF DetailsBoundingRect() const; QRectF DetailsBoundingRect() const;

View File

@ -0,0 +1,762 @@
/************************************************************************
**
** @file vprintlayout.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 22 12, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vprintlayout.h"
#include <QPrinterInfo>
#include <QMessageBox>
#include <QSpacerItem>
#include <QGridLayout>
#include <QPrintDialog>
#include <QGuiApplication>
#include <QDir>
#include <QDebug>
#include <QGraphicsRectItem>
#include <QPainter>
#include <QPixmapCache>
#include <QGraphicsScene>
#include <QPrintPreviewDialog>
#include <QPageSize>
#include "dialogs/dialoglayoutscale.h"
#include "../vmisc/vabstractvalapplication.h"
#include "dialogs/vabstractlayoutdialog.h"
#include "vposter.h"
#include "../vformat/vwatermark.h"
#include "../ifc/xml/vwatermarkconverter.h"
#include "../ifc/exception/vexception.h"
#include "../vmisc/vmath.h"
namespace
{
//---------------------------------------------------------------------------------------------------------------------
auto FindPageSizeId(QSizeF size) -> QPageSize::PageSizeId
{
auto TestSize = [size](float width, float height)
{
return size == QSizeF(width, height) || size == QSizeF(height, width);
};
constexpr int A0Width = 841;
constexpr int A0Height = 1189;
if (TestSize(A0Width, A0Height))
{
return QPageSize::A0;
}
constexpr int A1Width = 594;
constexpr int A1Height = 841;
if (TestSize(A1Width, A1Height))
{
return QPageSize::A1;
}
constexpr int A2Width = 420;
constexpr int A2Height = 594;
if (TestSize(A2Width, A2Height))
{
return QPageSize::A2;
}
constexpr int A3Width = 297;
constexpr int A3Height = 420;
if (TestSize(A3Width, A3Height))
{
return QPageSize::A3;
}
constexpr int A4Width = 210;
constexpr int A4Height = 297;
if (TestSize(A4Width, A4Height))
{
return QPageSize::A4;
}
constexpr float LegalWidth = 215.9F;
constexpr float LegalHeight = 355.6F;
if (TestSize(LegalWidth, LegalHeight))
{
return QPageSize::Legal;
}
constexpr float LetterWidth = 215.9F;
constexpr float LetterHeight = 279.4F;
if (TestSize(LetterWidth, LetterHeight))
{
return QPageSize::Letter;
}
return QPageSize::Custom;
}
//---------------------------------------------------------------------------------------------------------------------
Q_REQUIRED_RESULT auto PreparePrinter(
const QPrinterInfo &info, QPrinter::PrinterMode mode = QPrinter::ScreenResolution) -> QSharedPointer<QPrinter>;
auto PreparePrinter(const QPrinterInfo &info, QPrinter::PrinterMode mode) -> QSharedPointer<QPrinter>
{
QPrinterInfo tmpInfo = info;
if(tmpInfo.isNull() || tmpInfo.printerName().isEmpty())
{
const QStringList list = QPrinterInfo::availablePrinterNames();
if(list.isEmpty())
{
return QSharedPointer<QPrinter>();
}
tmpInfo = QPrinterInfo::printerInfo(list.first());
}
auto printer = QSharedPointer<QPrinter>(new QPrinter(tmpInfo, mode));
printer->setResolution(static_cast<int>(PrintDPI));
return printer;
}
} // namespace
//---------------------------------------------------------------------------------------------------------------------
VPrintLayout::VPrintLayout(QObject *parent)
: QObject(parent)
{}
//---------------------------------------------------------------------------------------------------------------------
VPrintLayout::~VPrintLayout()
{
qDeleteAll(m_layoutScenes);
}
//---------------------------------------------------------------------------------------------------------------------
void VPrintLayout::PrintTiled()
{
m_isTiled = true;
PrintLayout();
}
//---------------------------------------------------------------------------------------------------------------------
void VPrintLayout::PrintOrigin()
{
if (not IsPagesUniform())
{
qCritical()<<tr("For printing multipages document all sheet should have the same size.");
return;
}
m_isTiled = false;
PrintLayout();
}
//---------------------------------------------------------------------------------------------------------------------
void VPrintLayout::PrintPreviewTiled()
{
m_isTiled = true;
PrintPreview();
}
//---------------------------------------------------------------------------------------------------------------------
void VPrintLayout::PrintPreviewOrigin()
{
if (not IsPagesUniform())
{
qCritical()<<tr("For previewing multipage document all sheet should have the same size.");
return;
}
m_isTiled = false;
PrintPreview();
}
//---------------------------------------------------------------------------------------------------------------------
void VPrintLayout::PdfTiledFile(const QString &name)
{
m_isTiled = true;
if (m_isLayoutStale)
{
if (ContinueIfLayoutStale(m_parentWidget) == QMessageBox::No)
{
return;
}
}
QPrinter printer;
SetPrinterSettings(&printer, PrintType::PrintPDF, name);
// Call IsPagesFit after setting a printer settings and check if pages is not bigger than printer's paper size
if (not m_isTiled && not IsPagesFit(printer.pageLayout().paintRectPixels(printer.resolution()).size()))
{
qWarning()<<tr("Pages will be cropped because they do not fit printer paper size.");
}
printer.setResolution(static_cast<int>(PrintDPI));
PrintPages(&printer);
}
//---------------------------------------------------------------------------------------------------------------------
void VPrintLayout::CleanLayout()
{
qDeleteAll(m_layoutScenes);
m_layoutScenes.clear();
m_layoutPapers.clear();
m_layoutShadows.clear();
}
//---------------------------------------------------------------------------------------------------------------------
void VPrintLayout::PrintLayout()
{
if (m_isLayoutStale)
{
if (ContinueIfLayoutStale(m_parentWidget) == QMessageBox::No)
{
return;
}
}
// display print dialog and if accepted print
QPrinterInfo info = QPrinterInfo::printerInfo(m_layoutPrinterName);
if(info.isNull() || info.printerName().isEmpty())
{
info = QPrinterInfo::defaultPrinter();
}
QSharedPointer<QPrinter> printer = PreparePrinter(info, QPrinter::HighResolution);
if (printer.isNull())
{
qCritical("%s\n\n%s", qUtf8Printable(tr("Print error")),
qUtf8Printable(tr("Cannot proceed because there are no available printers in your system.")));
return;
}
{
DialogLayoutScale layoutScale(m_isTiled, m_parentWidget);
layoutScale.SetXScale(1);
layoutScale.SetYScale(1);
layoutScale.exec();
m_xscale = layoutScale.GetXScale();
m_yscale = layoutScale.GetYScale();
}
SetPrinterSettings(printer.data(), PrintType::PrintNative);
QPrintDialog dialog(printer.data(), m_parentWidget);
// If only user couldn't change page margins we could use method setMinMax();
dialog.setOption(QPrintDialog::PrintCurrentPage, false);
if (dialog.exec() == QDialog::Accepted)
{
printer->setResolution(static_cast<int>(PrintDPI));
PrintPages(printer.data());
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPrintLayout::PrintPreview()
{
if (m_isLayoutStale)
{
if (ContinueIfLayoutStale(m_parentWidget) == QMessageBox::No)
{
return;
}
}
QPrinterInfo info = QPrinterInfo::printerInfo(m_layoutPrinterName);
if(info.isNull() || info.printerName().isEmpty())
{
info = QPrinterInfo::defaultPrinter();
}
QSharedPointer<QPrinter> printer = PreparePrinter(info);
if (printer.isNull())
{
qCritical("%s\n\n%s", qUtf8Printable(tr("Print error")),
qUtf8Printable(tr("Cannot proceed because there are no available printers in your system.")));
return;
}
{
DialogLayoutScale layoutScale(m_isTiled, m_parentWidget);
layoutScale.SetXScale(1);
layoutScale.SetYScale(1);
layoutScale.exec();
m_xscale = layoutScale.GetXScale();
m_yscale = layoutScale.GetYScale();
}
SetPrinterSettings(printer.data(), PrintType::PrintPreview);
printer->setResolution(static_cast<int>(PrintDPI));
// display print preview dialog
QPrintPreviewDialog preview(printer.data());
connect(&preview, &QPrintPreviewDialog::paintRequested, this, &VPrintLayout::PrintPages);
preview.exec();
}
//---------------------------------------------------------------------------------------------------------------------
void VPrintLayout::PrintPages(QPrinter *printer)
{
QPainter painter;
if (not painter.begin(printer))
{ // failed to open file
qCritical() << tr("Failed to open file, is it writable?");
return;
}
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QPen(Qt::black, qApp->Settings()->WidthMainLine(), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter.setBrush ( QBrush ( Qt::NoBrush ) );
int count = 0;
QSharedPointer<QVector<PosterData>> poster;
QSharedPointer<VPoster> posterazor;
if (m_isTiled)
{
// when isTiled, the landscape tiles have to be rotated, because the pages
// stay portrait in the pdf
if(m_tiledPDFOrientation == PageOrientation::Landscape)
{
const int angle = -90;
painter.rotate(angle);
painter.translate(-ToPixel(printer->pageRect(QPrinter::Millimeter).height(), Unit::Mm), 0);
}
poster = QSharedPointer<QVector<PosterData>>(new QVector<PosterData>());
posterazor = QSharedPointer<VPoster>(new VPoster(printer));
for (int i=0; i < m_layoutScenes.size(); ++i)
{
auto *paper = qgraphicsitem_cast<QGraphicsRectItem *>(m_layoutPapers.at(i));
if (paper != nullptr)
{
QRectF paperRect = paper->rect();
QSizeF image(paperRect.width() * m_xscale, paperRect.height() * m_yscale);
*poster += posterazor->Calc(image.toSize(), i, m_tiledPDFOrientation);
}
}
count = poster->size();
}
else
{
count = m_layoutScenes.size();
}
// Handle the fromPage(), toPage(), supportsMultipleCopies(), and numCopies() values from QPrinter.
int firstPage = printer->fromPage() - 1;
if (firstPage >= count)
{
return;
}
if (firstPage == -1)
{
firstPage = 0;
}
int lastPage = printer->toPage() - 1;
if (lastPage == -1 || lastPage >= count)
{
lastPage = count - 1;
}
const int numPages = lastPage - firstPage + 1;
int copyCount = 1;
if (not printer->supportsMultipleCopies())
{
copyCount = printer->copyCount();
}
VWatermarkData data = WatermarkData();
// Here we try understand difference between printer's dpi and our.
// Get printer rect acording to our dpi.
const QRectF printerPageRect(0, 0, ToPixel(printer->pageRect(QPrinter::Millimeter).width(), Unit::Mm),
ToPixel(printer->pageRect(QPrinter::Millimeter).height(), Unit::Mm));
const QRect pageRect = printer->pageLayout().paintRectPixels(printer->resolution());
const double xscale = pageRect.width() / printerPageRect.width();
const double yscale = pageRect.height() / printerPageRect.height();
for (int i = 0; i < copyCount; ++i)
{
for (int j = 0; j < numPages; ++j)
{
if (i != 0 || j != 0)
{
if (not printer->newPage())
{
qCritical() << tr("Failed in flushing page to disk, disk full?");
return;
}
}
int index;
if (printer->pageOrder() == QPrinter::FirstPageFirst)
{
index = firstPage + j;
}
else
{
index = lastPage - j;
}
int paperIndex = -1;
m_isTiled ? paperIndex = static_cast<int>(poster->at(index).index) : paperIndex = index;
auto *paper = qgraphicsitem_cast<QGraphicsRectItem *>(m_layoutPapers.at(paperIndex));
if (paper != nullptr)
{
QVector<QGraphicsItem *> posterData;
if (m_isTiled)
{
// Draw tile
posterData = posterazor->Tile(paper, poster->at(index), m_layoutScenes.size(), data,
m_watermarkPath);
}
PreparePaper(paperIndex);
// Render
QRectF source;
m_isTiled ? source = poster->at(index).rect : source = paper->rect();
qreal x;
qreal y;
if(printer->fullPage())
{
QPageLayout layout = printer->pageLayout();
layout.setUnits(QPageLayout::Millimeter);
QMarginsF printerMargins = layout.margins();
x = qFloor(ToPixel(printerMargins.left(), Unit::Mm));
y = qFloor(ToPixel(printerMargins.top(), Unit::Mm));
}
else
{
x = 0; y = 0;
}
QRectF target(x * xscale, y * yscale, source.width() * xscale, source.height() * yscale);
m_layoutScenes.at(paperIndex)->render(&painter, target, source, Qt::IgnoreAspectRatio);
if (m_isTiled)
{
// Remove borders
qDeleteAll(posterData);
}
// Restore
RestorePaper(paperIndex);
}
}
}
painter.end();
}
//---------------------------------------------------------------------------------------------------------------------
void VPrintLayout::SetPrinterSettings(QPrinter *printer, PrintType printType, const QString &filePath)
{
SCASSERT(printer != nullptr)
printer->setCreator(QGuiApplication::applicationDisplayName() + QChar(QChar::Space) +
QCoreApplication::applicationVersion());
printer->setPageOrientation(m_isLayoutPortrait ? QPageLayout::Portrait : QPageLayout::Landscape);
SetPrinterPageSize(printer);
printer->setFullPage(m_ignorePrinterMargins);
SetPrinterPrinterMargins(printer);
SetPrinterOutputFileName(printer, printType, filePath);
printer->setDocName(filePath.isEmpty() ? DocName() : QFileInfo(filePath).baseName());
}
//---------------------------------------------------------------------------------------------------------------------
void VPrintLayout::SetPrinterPrinterMargins(QPrinter *printer)
{
SCASSERT(printer != nullptr)
QMarginsF printerMargins;
if (not m_isTiled)
{
printerMargins = QMarginsF(UnitConvertor(m_layoutMargins, Unit::Px, Unit::Mm));
}
else
{
if(m_tiledPDFOrientation == PageOrientation::Landscape)
{
// because when painting we have a -90rotation in landscape mode,
// see function PrintPages.
printerMargins = QMarginsF(m_tiledMargins.bottom(), m_tiledMargins.left(), m_tiledMargins.top(),
m_tiledMargins.right());
}
else
{
printerMargins = m_tiledMargins;
}
}
const bool success = printer->setPageMargins(printerMargins, QPageLayout::Millimeter);
if (not success)
{
qWarning() << tr("Cannot set printer margins");
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPrintLayout::SetPrinterOutputFileName(QPrinter *printer, PrintType printType, const QString &filePath)
{
SCASSERT(printer != nullptr)
switch(printType)
{
case PrintType::PrintPDF:
{
const QString outputFileName = filePath.isEmpty() ? QDir::homePath() + QDir::separator() + DocName()
: filePath;
#ifdef Q_OS_WIN
printer->setOutputFileName(outputFileName);
#else
printer->setOutputFileName(outputFileName + QStringLiteral(".pdf"));
#endif
#ifdef Q_OS_MAC
printer->setOutputFormat(QPrinter::NativeFormat);
#else
printer->setOutputFormat(QPrinter::PdfFormat);
#endif
break;
}
case PrintType::PrintNative:
printer->setOutputFileName(QString());//Disable printing to file if was enabled.
printer->setOutputFormat(QPrinter::NativeFormat);
break;
case PrintType::PrintPreview: /*do nothing*/
default:
break;
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPrintLayout::SetPrinterPageSize(QPrinter *printer)
{
SCASSERT(printer != nullptr)
if (not m_isTiled)
{
qreal width = FromPixel(m_layoutPaperSize.width(), Unit::Mm);
qreal height = FromPixel(m_layoutPaperSize.height(), Unit::Mm);
if (m_isAutoCropLength || m_isUnitePages)
{
auto *paper = qgraphicsitem_cast<QGraphicsRectItem *>(m_layoutPapers.at(0));
if (paper != nullptr)
{
if (m_isLayoutPortrait)
{
height = FromPixel(paper->rect().height() + m_layoutMargins.top() + m_layoutMargins.bottom(),
Unit::Mm);
}
else
{
width = FromPixel(paper->rect().width() + m_layoutMargins.left() + m_layoutMargins.right(),
Unit::Mm);
}
}
}
if (m_isAutoCropWidth)
{
auto *paper = qgraphicsitem_cast<QGraphicsRectItem *>(m_layoutPapers.at(0));
if (paper != nullptr)
{
if (m_isLayoutPortrait)
{
width = FromPixel(paper->rect().width() + m_layoutMargins.left() + m_layoutMargins.right(),
Unit::Mm);
}
else
{
height = FromPixel(paper->rect().height() + m_layoutMargins.top() + m_layoutMargins.bottom(),
Unit::Mm);
}
}
}
QSizeF size = QSizeF(width, height);
if (not m_isLayoutPortrait)
{
size.transpose(); // QPrinter reverse this for landscape orientation
}
const QPageSize::PageSizeId pSZ = FindPageSizeId(size);
if (pSZ == QPageSize::Custom)
{
if (not printer->setPageSize(QPageSize(size, QPageSize::Millimeter)))
{
qWarning() << tr("Cannot set custom printer page size");
}
}
else
{
if (not printer->setPageSize(QPageSize(pSZ)))
{
qWarning() << tr("Cannot set printer page size");
}
}
}
else
{
if (not printer->setPageSize(QPageSize(m_tiledPDFPaperSize, QPageSize::Millimeter)))
{
qWarning() << tr("Cannot set printer tiled page size");
}
}
}
//---------------------------------------------------------------------------------------------------------------------
auto VPrintLayout::DocName() const -> QString
{
return not m_fileName.isEmpty() ? m_fileName : tr("unamed");
}
//---------------------------------------------------------------------------------------------------------------------
void VPrintLayout::PreparePaper(int index) const
{
auto *paper = qgraphicsitem_cast<QGraphicsRectItem *>(m_layoutPapers.at(index));
if (paper != nullptr)
{
QBrush brush(Qt::white);
m_layoutScenes.at(index)->setBackgroundBrush(brush);
m_layoutShadows.at(index)->setVisible(false);
const float thinPen = 0.1F;
paper->setPen(QPen(Qt::white, thinPen, Qt::NoPen));// border
}
QTransform matrix;
matrix.scale(m_xscale, m_yscale);
QList<QGraphicsItem *> paperDetails = m_layoutDetails.at(index);
for (auto *detail : paperDetails)
{
QTransform m = detail->transform();
m *= matrix;
detail->setTransform(m);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPrintLayout::RestorePaper(int index) const
{
auto *paper = qgraphicsitem_cast<QGraphicsRectItem *>(m_layoutPapers.at(index));
if (paper != nullptr)
{
// Restore
paper->setPen(QPen(Qt::black, 1));
QBrush brush(Qt::gray);
m_layoutScenes.at(index)->setBackgroundBrush(brush);
m_layoutShadows.at(index)->setVisible(true);
}
QTransform matrix;
matrix.scale(1./m_xscale, 1./m_yscale);
QList<QGraphicsItem *> paperDetails = m_layoutDetails.at(index);
for (auto *detail : paperDetails)
{
QTransform m = detail->transform();
m *= matrix;
detail->setTransform(m);
}
}
//---------------------------------------------------------------------------------------------------------------------
auto VPrintLayout::IsPagesUniform() const -> bool
{
if (m_layoutPapers.size() < 2)
{
return true;
}
auto *paper = qgraphicsitem_cast<QGraphicsRectItem *>(m_layoutPapers.at(0));
SCASSERT(paper != nullptr)
return std::all_of(m_layoutPapers.begin(), m_layoutPapers.end(), [paper](QGraphicsItem *paperItem)
{
auto *p = qgraphicsitem_cast<QGraphicsRectItem *>(paperItem);
SCASSERT(p != nullptr)
return paper->rect() == p->rect();
});
}
//---------------------------------------------------------------------------------------------------------------------
auto VPrintLayout::IsPagesFit(QSizeF printPaper) const -> bool
{
// On previous stage already was checked if pages have uniform size
// Enough will be to check only one page
auto *p = qgraphicsitem_cast<QGraphicsRectItem *>(m_layoutPapers.at(0));
SCASSERT(p != nullptr)
const QSizeF pSize = p->rect().size();
return pSize.height() <= printPaper.height() && pSize.width() <= printPaper.width();
}
//---------------------------------------------------------------------------------------------------------------------
auto VPrintLayout::WatermarkData() const -> VWatermarkData
{
VWatermarkData data;
if (m_isTiled && not m_watermarkPath.isEmpty())
{
try
{
VWatermarkConverter converter(m_watermarkPath);
VWatermark watermark;
watermark.setXMLContent(converter.Convert());
data = watermark.GetWatermark();
if (not data.path.isEmpty())
{
// Clean previous cache
QPixmapCache::remove(AbsoluteMPath(m_watermarkPath, data.path));
}
}
catch (VException &e)
{
const QString errorMsg = tr("File error.\n\n%1\n\n%2").arg(e.ErrorMessage(), e.DetailedInformation());
qApp->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
}
}
return data;
}
//---------------------------------------------------------------------------------------------------------------------
auto VPrintLayout::ContinueIfLayoutStale(QWidget *parent) -> int
{
QMessageBox msgBox(parent);
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("The layout is stale."));
msgBox.setText(tr("The layout was not updated since last pattern modification. Do you want to continue?"));
msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
const int width = 500;
auto* horizontalSpacer = new QSpacerItem(width, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
auto* layout = qobject_cast<QGridLayout*>(msgBox.layout());
SCASSERT(layout != nullptr)
layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount());
return msgBox.exec();
}

View File

@ -0,0 +1,427 @@
/************************************************************************
**
** @file vprintlayout.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 22 12, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VPRINTLAYOUT_H
#define VPRINTLAYOUT_H
#include <QMargins>
#include <QObject>
#include <QSizeF>
#include "../vmisc/def.h"
enum class PrintType : qint8 {PrintPDF, PrintPreview, PrintNative};
class QPrinter;
class QGraphicsScene;
struct VWatermarkData;
class VPrintLayout : public QObject
{
Q_OBJECT
public:
VPrintLayout(QObject *parent = nullptr);
~VPrintLayout();
auto FileName() const -> QString;
void SetFileName(const QString &fileName);
auto LayoutPaperSize() const -> QSizeF;
void SetLayoutPaperSize(const QSizeF &paperSize);
auto LayoutMargins() const -> QMarginsF;
void SetLayoutMargins(const QMarginsF &layoutMargins);
auto ParentWidget() const -> QWidget *;
void SetParentWidget(QWidget *parentWidget);
auto IsLayoutPortrait() const -> bool;
void SetLayoutPortrait(bool isLayoutPortrait);
auto IgnorePrinterMargins() const -> bool;
void SetIgnorePrinterMargins(bool ignorePrinterFields);
auto IsAutoCropLength() const -> bool;
void SetAutoCropLength(bool isAutoCropLength);
auto IsAutoCropWidth() const -> bool;
void SetAutoCropWidth(bool isAutoCropWidth);
auto IsUnitePages() const -> bool;
void SetUnitePages(bool isUnitePages);
auto LayoutPrinterName() const -> QString;
void SetLayoutPrinterName(const QString &layoutPrinterName);
auto IsLayoutStale() const -> bool;
void SetLayoutStale(bool isLayoutStale);
auto TiledMargins() const -> QMarginsF;
void SetTiledMargins(const QMarginsF &tiledMargins);
auto TiledPDFOrientation() const -> PageOrientation;
void SetTiledPDFOrientation(const PageOrientation &tiledPDFOrientation);
auto TiledPDFPaperSize() const -> QSizeF;
void SetTiledPDFPaperSize(const QSizeF &tiledPDFPaperSize);
auto XScale() const -> qreal;
void SetXScale(const qreal &xscale);
auto YScale() const -> qreal;
void SetYScale(const qreal &yscale);
auto WatermarkPath() const -> QString;
void SetWatermarkPath(const QString &watermarkPath);
auto LayoutPapers() const -> QList<QGraphicsItem *>;
void SetLayoutPapers(const QList<QGraphicsItem *> &layoutPapers);
auto LayoutScenes() const -> QList<QGraphicsScene *>;
void SetLayoutScenes(const QList<QGraphicsScene *> &layoutScenes);
auto LayoutShadows() const -> QList<QGraphicsItem *>;
void SetLayoutShadows(const QList<QGraphicsItem *> &layoutShadows);
auto LayoutDetails() const -> QList<QList<QGraphicsItem *> >;
void SetLayoutDetails(const QList<QList<QGraphicsItem *> > &layoutDetails);
void PrintTiled();
void PrintOrigin();
void PrintPreviewTiled();
void PrintPreviewOrigin();
void PdfTiledFile(const QString &name);
void CleanLayout();
static auto ContinueIfLayoutStale(QWidget *parent) -> int;
private slots:
void PrintPages (QPrinter *printer);
private:
Q_DISABLE_COPY(VPrintLayout)
QString m_fileName{};
QSizeF m_layoutPaperSize{};
QMarginsF m_layoutMargins{};
QWidget *m_parentWidget{nullptr};
bool m_isLayoutPortrait{true};
bool m_ignorePrinterMargins{false};
bool m_isAutoCropLength{false};
bool m_isAutoCropWidth{false};
bool m_isUnitePages{false};
QString m_layoutPrinterName{};
bool m_isLayoutStale{true};
QMarginsF m_tiledMargins{};
PageOrientation m_tiledPDFOrientation{PageOrientation::Portrait};
QSizeF m_tiledPDFPaperSize{};
QString m_watermarkPath{};
QList<QGraphicsItem *> m_layoutPapers{};
QList<QGraphicsScene *> m_layoutScenes{};
QList<QGraphicsItem *> m_layoutShadows{};
QList<QList<QGraphicsItem *> > m_layoutDetails{};
bool m_isTiled{false};
qreal m_xscale{1};
qreal m_yscale{1};
void PrintLayout();
void PrintPreview();
void SetPrinterSettings(QPrinter *printer, PrintType printType, const QString &filePath = QString());
void SetPrinterPrinterMargins(QPrinter *printer);
void SetPrinterOutputFileName(QPrinter *printer, PrintType printType, const QString &filePath = QString());
void SetPrinterPageSize(QPrinter *printer);
QString DocName() const;
void PreparePaper(int index) const;
void RestorePaper(int index) const;
bool IsPagesUniform() const;
bool IsPagesFit(QSizeF printPaper) const;
auto WatermarkData() const -> VWatermarkData;
};
//---------------------------------------------------------------------------------------------------------------------
inline auto VPrintLayout::FileName() const -> QString
{
return m_fileName;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VPrintLayout::SetFileName(const QString &fileName)
{
m_fileName = fileName;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VPrintLayout::LayoutPaperSize() const -> QSizeF
{
return m_layoutPaperSize;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VPrintLayout::SetLayoutPaperSize(const QSizeF &paperSize)
{
m_layoutPaperSize = paperSize;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VPrintLayout::LayoutMargins() const -> QMarginsF
{
return m_layoutMargins;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VPrintLayout::SetLayoutMargins(const QMarginsF &layoutMargins)
{
m_layoutMargins = layoutMargins;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VPrintLayout::ParentWidget() const -> QWidget *
{
return m_parentWidget;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VPrintLayout::SetParentWidget(QWidget *parentWidget)
{
m_parentWidget = parentWidget;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VPrintLayout::IsLayoutPortrait() const -> bool
{
return m_isLayoutPortrait;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VPrintLayout::SetLayoutPortrait(bool isLayoutPortrait)
{
m_isLayoutPortrait = isLayoutPortrait;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VPrintLayout::IgnorePrinterMargins() const -> bool
{
return m_ignorePrinterMargins;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VPrintLayout::SetIgnorePrinterMargins(bool ignorePrinterFields)
{
m_ignorePrinterMargins = ignorePrinterFields;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VPrintLayout::IsAutoCropLength() const -> bool
{
return m_isAutoCropLength;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VPrintLayout::SetAutoCropLength(bool isAutoCropLength)
{
m_isAutoCropLength = isAutoCropLength;
}
//---------------------------------------------------------------------------------------------------------------------
inline bool VPrintLayout::IsAutoCropWidth() const
{
return m_isAutoCropWidth;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VPrintLayout::SetAutoCropWidth(bool isAutoCropWidth)
{
m_isAutoCropWidth = isAutoCropWidth;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VPrintLayout::IsUnitePages() const -> bool
{
return m_isUnitePages;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VPrintLayout::SetUnitePages(bool isUnitePages)
{
m_isUnitePages = isUnitePages;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VPrintLayout::LayoutPrinterName() const -> QString
{
return m_layoutPrinterName;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VPrintLayout::SetLayoutPrinterName(const QString &layoutPrinterName)
{
m_layoutPrinterName = layoutPrinterName;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VPrintLayout::IsLayoutStale() const -> bool
{
return m_isLayoutStale;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VPrintLayout::SetLayoutStale(bool isLayoutStale)
{
m_isLayoutStale = isLayoutStale;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VPrintLayout::TiledMargins() const -> QMarginsF
{
return m_tiledMargins;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VPrintLayout::SetTiledMargins(const QMarginsF &tiledMargins)
{
m_tiledMargins = tiledMargins;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VPrintLayout::TiledPDFOrientation() const -> PageOrientation
{
return m_tiledPDFOrientation;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VPrintLayout::SetTiledPDFOrientation(const PageOrientation &tiledPDFOrientation)
{
m_tiledPDFOrientation = tiledPDFOrientation;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VPrintLayout::TiledPDFPaperSize() const -> QSizeF
{
return m_tiledPDFPaperSize;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VPrintLayout::SetTiledPDFPaperSize(const QSizeF &tiledPDFPaperSize)
{
m_tiledPDFPaperSize = tiledPDFPaperSize;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VPrintLayout::LayoutPapers() const -> QList<QGraphicsItem *>
{
return m_layoutPapers;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VPrintLayout::SetLayoutPapers(const QList<QGraphicsItem *> &layoutPapers)
{
m_layoutPapers = layoutPapers;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VPrintLayout::LayoutScenes() const -> QList<QGraphicsScene *>
{
return m_layoutScenes;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VPrintLayout::SetLayoutScenes(const QList<QGraphicsScene *> &layoutScenes)
{
m_layoutScenes = layoutScenes;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VPrintLayout::LayoutShadows() const -> QList<QGraphicsItem *>
{
return m_layoutShadows;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VPrintLayout::SetLayoutShadows(const QList<QGraphicsItem *> &layoutShadows)
{
m_layoutShadows = layoutShadows;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VPrintLayout::LayoutDetails() const -> QList<QList<QGraphicsItem *> >
{
return m_layoutDetails;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VPrintLayout::SetLayoutDetails(const QList<QList<QGraphicsItem *> > &layoutDetails)
{
m_layoutDetails = layoutDetails;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VPrintLayout::YScale() const -> qreal
{
return m_yscale;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VPrintLayout::SetYScale(const qreal &yscale)
{
m_yscale = yscale;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VPrintLayout::XScale() const -> qreal
{
return m_xscale;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VPrintLayout::SetXScale(const qreal &xscale)
{
m_xscale = xscale;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VPrintLayout::WatermarkPath() const -> QString
{
return m_watermarkPath;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VPrintLayout::SetWatermarkPath(const QString &watermarkPath)
{
m_watermarkPath = watermarkPath;
}
#endif // VPRINTLAYOUT_H

View File

@ -284,6 +284,21 @@ void InitPiecePlaceholders(QMap<QString, QString> &placeholders, const QString &
QString ReplacePlaceholders(const QMap<QString, QString> &placeholders, QString line) QString ReplacePlaceholders(const QMap<QString, QString> &placeholders, QString line)
{ {
QChar per('%'); QChar per('%');
auto TestDimension = [per, placeholders, line](const QString &placeholder, const QString &errorMsg)
{
if (line.contains(per+placeholder+per) && placeholders.value(placeholder) == QChar('0'))
{
qApp->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
}
};
TestDimension(pl_height, QObject::tr("No data for the height dimension."));
TestDimension(pl_size, QObject::tr("No data for the size dimension."));
TestDimension(pl_hip, QObject::tr("No data for the hip dimension."));
TestDimension(pl_waist, QObject::tr("No data for the waist dimension."));
auto i = placeholders.constBegin(); auto i = placeholders.constBegin();
while (i != placeholders.constEnd()) while (i != placeholders.constEnd())
{ {

View File

@ -277,28 +277,6 @@ QString AbsoluteMPath(const QString &patternPath, const QString &relativeMPath)
return QFileInfo(QFileInfo(patternPath).absoluteDir(), relativeMPath).absoluteFilePath(); return QFileInfo(QFileInfo(patternPath).absoluteDir(), relativeMPath).absoluteFilePath();
} }
//---------------------------------------------------------------------------------------------------------------------
QSharedPointer<QPrinter> PreparePrinter(const QPrinterInfo &info, QPrinter::PrinterMode mode)
{
QPrinterInfo tmpInfo = info;
if(tmpInfo.isNull() || tmpInfo.printerName().isEmpty())
{
const QStringList list = QPrinterInfo::availablePrinterNames();
if(list.isEmpty())
{
return QSharedPointer<QPrinter>();
}
else
{
tmpInfo = QPrinterInfo::printerInfo(list.first());
}
}
auto printer = QSharedPointer<QPrinter>(new QPrinter(tmpInfo, mode));
printer->setResolution(static_cast<int>(PrintDPI));
return printer;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QMarginsF GetMinPrinterFields(const QSharedPointer<QPrinter> &printer) QMarginsF GetMinPrinterFields(const QSharedPointer<QPrinter> &printer)
{ {
@ -315,24 +293,21 @@ QMarginsF GetMinPrinterFields(const QSharedPointer<QPrinter> &printer)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QMarginsF GetPrinterFields(const QSharedPointer<QPrinter> &printer) auto GetPrinterFields(const QSharedPointer<QPrinter> &printer) -> QMarginsF
{ {
if (printer.isNull()) if (printer.isNull())
{ {
return QMarginsF(); return {};
} }
qreal left = 0;
qreal top = 0;
qreal right = 0;
qreal bottom = 0;
printer->getPageMargins(&left, &top, &right, &bottom, QPrinter::Millimeter);
// We can't use Unit::Px because our dpi in most cases is different // We can't use Unit::Px because our dpi in most cases is different
const QMarginsF m = printer->pageLayout().margins(QPageLayout::Millimeter);
QMarginsF def; QMarginsF def;
def.setLeft(UnitConvertor(left, Unit::Mm, Unit::Px)); def.setLeft(UnitConvertor(m.left(), Unit::Mm, Unit::Px));
def.setRight(UnitConvertor(right, Unit::Mm, Unit::Px)); def.setRight(UnitConvertor(m.right(), Unit::Mm, Unit::Px));
def.setTop(UnitConvertor(top, Unit::Mm, Unit::Px)); def.setTop(UnitConvertor(m.top(), Unit::Mm, Unit::Px));
def.setBottom(UnitConvertor(bottom, Unit::Mm, Unit::Px)); def.setBottom(UnitConvertor(m.bottom(), Unit::Mm, Unit::Px));
return def; return def;
} }

View File

@ -602,9 +602,6 @@ Q_REQUIRED_RESULT QString AbsoluteMPath(const QString &patternPath, const QStrin
QStringList SplitFilePaths(const QString &path); QStringList SplitFilePaths(const QString &path);
Q_REQUIRED_RESULT QSharedPointer<QPrinter> PreparePrinter(const QPrinterInfo &info,
QPrinter::PrinterMode mode = QPrinter::ScreenResolution);
QMarginsF GetMinPrinterFields(const QSharedPointer<QPrinter> &printer); QMarginsF GetMinPrinterFields(const QSharedPointer<QPrinter> &printer);
QMarginsF GetPrinterFields(const QSharedPointer<QPrinter> &printer); QMarginsF GetPrinterFields(const QSharedPointer<QPrinter> &printer);

View File

@ -42,7 +42,7 @@
extern const int MAJOR_VERSION = 0; extern const int MAJOR_VERSION = 0;
extern const int MINOR_VERSION = 7; extern const int MINOR_VERSION = 7;
extern const int DEBUG_VERSION = 40; extern const int DEBUG_VERSION = 41;
extern const QString APP_VERSION_STR(QStringLiteral("%1.%2.%3.%4").arg(MAJOR_VERSION).arg(MINOR_VERSION) extern const QString APP_VERSION_STR(QStringLiteral("%1.%2.%3.%4").arg(MAJOR_VERSION).arg(MINOR_VERSION)
.arg(DEBUG_VERSION).arg(LATEST_TAG_DISTANCE)); .arg(DEBUG_VERSION).arg(LATEST_TAG_DISTANCE));

View File

@ -49,8 +49,8 @@ extern const QString APP_VERSION_STR;
// Change version number in projectversion.cpp too. // Change version number in projectversion.cpp too.
// Synchronize valentina.nsi // Synchronize valentina.nsi
#define VER_FILEVERSION 0,7,40 #define VER_FILEVERSION 0,7,41
#define VER_FILEVERSION_STR "0.7.40\0" #define VER_FILEVERSION_STR "0.7.41\0"
#define V_PRERELEASE // Mark prerelease builds #define V_PRERELEASE // Mark prerelease builds

View File

@ -313,3 +313,14 @@ bool VAbstractApplication::IsWarningMessage(const QString &message) const
{ {
return VAbstractApplication::ClearMessage(message).startsWith(warningMessageSignature); return VAbstractApplication::ClearMessage(message).startsWith(warningMessageSignature);
} }
//---------------------------------------------------------------------------------------------------------------------
QFileDialog::Options VAbstractApplication::NativeFileDialog(QFileDialog::Options options) const
{
if (settings->IsDontUseNativeDialog())
{
options |= QFileDialog::DontUseNativeDialog;
}
return options;
}

View File

@ -39,6 +39,7 @@
#include <QString> #include <QString>
#include <QtGlobal> #include <QtGlobal>
#include <QTranslator> #include <QTranslator>
#include <QFileDialog>
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "../vpatterndb/vtranslatevars.h" #include "../vpatterndb/vtranslatevars.h"
@ -51,7 +52,7 @@ class VCommonSettings;
#if defined(qApp) #if defined(qApp)
#undef qApp #undef qApp
#endif #endif
#define qApp (static_cast<VAbstractApplication*>(QCoreApplication::instance())) #define qApp (qobject_cast<VAbstractApplication*>(QCoreApplication::instance()))
class VAbstractApplication : public QApplication class VAbstractApplication : public QApplication
{ {
@ -82,6 +83,8 @@ public:
static const QString warningMessageSignature; static const QString warningMessageSignature;
bool IsWarningMessage(const QString &message) const; bool IsWarningMessage(const QString &message) const;
QFileDialog::Options NativeFileDialog(QFileDialog::Options options = QFileDialog::Options()) const;
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
static void WinAttachConsole(); static void WinAttachConsole();
#endif #endif

View File

@ -40,7 +40,7 @@ class QGraphicsScene;
#if defined(qApp) #if defined(qApp)
#undef qApp #undef qApp
#endif #endif
#define qApp (static_cast<VAbstractValApplication*>(QCoreApplication::instance())) #define qApp (qobject_cast<VAbstractValApplication*>(QCoreApplication::instance()))
class VAbstractValApplication : public VAbstractApplication class VAbstractValApplication : public VAbstractApplication
{ {

View File

@ -67,6 +67,8 @@ const qreal VCommonSettings::defaultScrollingAcceleration = 1.3;
const qreal VCommonSettings::scrollingAccelerationMin = 1.0; const qreal VCommonSettings::scrollingAccelerationMin = 1.0;
const qreal VCommonSettings::scrollingAccelerationMax = 10.0; const qreal VCommonSettings::scrollingAccelerationMax = 10.0;
Q_DECLARE_METATYPE(QMarginsF)
namespace namespace
{ {
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsIndividualMeasurements, (QLatin1String("paths/individual_measurements"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsIndividualMeasurements, (QLatin1String("paths/individual_measurements")))
@ -87,6 +89,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationConfirmFormatRewrit
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationToolBarStyle, (QLatin1String("configuration/tool_bar_style"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationToolBarStyle, (QLatin1String("configuration/tool_bar_style")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationFreeCurveMode, (QLatin1String("configuration/freeCurveMode"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationFreeCurveMode, (QLatin1String("configuration/freeCurveMode")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDoubleClickZoomFitBestCurrentPP, (QLatin1String("configuration/doubleClickZoomFitBestCurrentPP"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDoubleClickZoomFitBestCurrentPP, (QLatin1String("configuration/doubleClickZoomFitBestCurrentPP")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDontUseNativeDialog, (QLatin1String("configuration/dontUseNativeDialog")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternUndo, (QLatin1String("pattern/undo"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternUndo, (QLatin1String("pattern/undo")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternForbidFlipping, (QLatin1String("pattern/forbidFlipping"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternForbidFlipping, (QLatin1String("pattern/forbidFlipping")))
@ -134,6 +137,9 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingSensorMouseScale,
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingWheelMouseScale, (QLatin1String("scrolling/wheelMouseScale"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingWheelMouseScale, (QLatin1String("scrolling/wheelMouseScale")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingAcceleration, (QLatin1String("scrolling/acceleration"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingAcceleration, (QLatin1String("scrolling/acceleration")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFMargins, (QLatin1String("tiledPDF/margins")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFOrientation, (QLatin1String("tiledPDF/orientation")))
// Reading settings file is very expensive, cache curve approximation to speed up getting value // Reading settings file is very expensive, cache curve approximation to speed up getting value
qreal curveApproximationCached = -1; qreal curveApproximationCached = -1;
Q_GLOBAL_STATIC(QString, localeCached) Q_GLOBAL_STATIC(QString, localeCached)
@ -1223,6 +1229,21 @@ void VCommonSettings::SetPieceShowMainPath(bool value)
setValue(*settingPatternPieceShowMainPath, pieceShowMainPath); setValue(*settingPatternPieceShowMainPath, pieceShowMainPath);
} }
//---------------------------------------------------------------------------------------------------------------------
bool VCommonSettings::IsDontUseNativeDialog() const
{
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
return settings.value(*settingConfigurationDontUseNativeDialog, false).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetDontUseNativeDialog(bool value)
{
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
settings.setValue(*settingConfigurationDontUseNativeDialog, value);
settings.sync();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VCommonSettings::GetLineWidth() const qreal VCommonSettings::GetLineWidth() const
{ {
@ -1368,3 +1389,44 @@ void VCommonSettings::SetGraphicalOutput(const bool &value)
settings.setValue(*settingPatternGraphicalOutput, value); settings.setValue(*settingPatternGraphicalOutput, value);
settings.sync(); settings.sync();
} }
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetTiledPDFMargins returns the tiled pdf margins in the given unit. When the setting is
* called for the first time, the 4 default margins are 10mm.
* @param unit the unit in which are the value. Necessary because we save the values
* internaly as mm so there is conversion beeing made.
* @return tiled pdf margins
*/
auto VCommonSettings::GetTiledPDFMargins(const Unit &unit) const -> QMarginsF
{
// default value is 10mm. We save the margins in mm in the setting.
return UnitConvertor(
ValueOrDef<QMarginsF>(*this, *settingTiledPDFMargins, QMarginsF(10, 10, 10, 10)), Unit::Mm, unit);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetTiledPDFMargins sets the setting tiled pdf margins to the given value.
* @param value the margins to save
* @param unit the unit in which are the value. Necessary because we save the values
* internaly as mm so there is conversion beeing made.
*/
void VCommonSettings::SetTiledPDFMargins(const QMarginsF &value, const Unit &unit)
{
setValue(*settingTiledPDFMargins, QVariant::fromValue(UnitConvertor(value, unit, Unit::Mm)));
}
//---------------------------------------------------------------------------------------------------------------------
auto VCommonSettings::GetTiledPDFOrientation() const -> PageOrientation
{
bool defaultValue = static_cast<bool>(PageOrientation::Portrait);
bool result = value(*settingTiledPDFOrientation, defaultValue).toBool();
return static_cast<PageOrientation>(result);
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetTiledPDFOrientation(PageOrientation value)
{
setValue(*settingTiledPDFOrientation, static_cast<bool> (value));
}

View File

@ -38,7 +38,10 @@
#include <QStringList> #include <QStringList>
#include <QtGlobal> #include <QtGlobal>
#include "../vlayout/vbank.h" #include "../vmisc/def.h"
#include "../vlayout/vlayoutdef.h"
class QMarginsF;
class VCommonSettings : public QSettings class VCommonSettings : public QSettings
{ {
@ -220,6 +223,9 @@ public:
bool IsPieceShowMainPath() const; bool IsPieceShowMainPath() const;
void SetPieceShowMainPath(bool value); void SetPieceShowMainPath(bool value);
bool IsDontUseNativeDialog() const;
void SetDontUseNativeDialog(bool value);
static qreal DefaultLineWidth(); static qreal DefaultLineWidth();
static qreal MinimalLineWidth(); static qreal MinimalLineWidth();
static qreal MaximalLineWidth(); static qreal MaximalLineWidth();
@ -228,6 +234,13 @@ public:
qreal WidthMainLine() const; qreal WidthMainLine() const;
qreal WidthHairLine() const; qreal WidthHairLine() const;
// settings for the tiled PDFs
auto GetTiledPDFMargins(const Unit &unit) const -> QMarginsF;
void SetTiledPDFMargins(const QMarginsF &value, const Unit &unit);
auto GetTiledPDFOrientation() const -> PageOrientation;
void SetTiledPDFOrientation(PageOrientation value);
static const int defaultScrollingDuration; static const int defaultScrollingDuration;
static const int scrollingDurationMin; static const int scrollingDurationMin;
static const int scrollingDurationMax; static const int scrollingDurationMax;

View File

@ -300,11 +300,7 @@ void DialogEditLabel::ExportTemplate()
QString fileName = QFileDialog::getSaveFileName(this, tr("Export label template"), QString fileName = QFileDialog::getSaveFileName(this, tr("Export label template"),
path + QLatin1String("/") + tr("template") + QLatin1String(".xml"), path + QLatin1String("/") + tr("template") + QLatin1String(".xml"),
filters, nullptr filters, nullptr, qApp->NativeFileDialog());
#ifdef Q_OS_LINUX
, QFileDialog::DontUseNativeDialog
#endif
);
if (fileName.isEmpty()) if (fileName.isEmpty())
{ {
@ -353,11 +349,8 @@ void DialogEditLabel::ImportTemplate()
QString filter(tr("Label template") + QLatin1String(" (*.xml)")); QString filter(tr("Label template") + QLatin1String(" (*.xml)"));
//Use standard path to label templates //Use standard path to label templates
const QString path = VCommonSettings::PrepareLabelTemplates(qApp->Settings()->GetPathLabelTemplate()); const QString path = VCommonSettings::PrepareLabelTemplates(qApp->Settings()->GetPathLabelTemplate());
const QString fileName = QFileDialog::getOpenFileName(this, tr("Import template"), path, filter, nullptr const QString fileName = QFileDialog::getOpenFileName(this, tr("Import template"), path, filter, nullptr,
#ifdef Q_OS_LINUX qApp->NativeFileDialog());
, QFileDialog::DontUseNativeDialog
#endif
);
if (fileName.isEmpty()) if (fileName.isEmpty())
{ {
return; return;
@ -586,10 +579,26 @@ void DialogEditLabel::InitPlaceholders()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString DialogEditLabel::ReplacePlaceholders(QString line) const QString DialogEditLabel::ReplacePlaceholders(QString line) const
{ {
QChar per('%');
auto TestDimension = [per, this, line](const QString &placeholder, const QString &errorMsg)
{
if (line.contains(per+placeholder+per) && m_placeholders.value(placeholder).second == QChar('0'))
{
qApp->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
}
};
TestDimension(pl_height, tr("No data for the height dimension."));
TestDimension(pl_size, tr("No data for the size dimension."));
TestDimension(pl_hip, tr("No data for the hip dimension."));
TestDimension(pl_waist, tr("No data for the waist dimension."));
auto i = m_placeholders.constBegin(); auto i = m_placeholders.constBegin();
while (i != m_placeholders.constEnd()) while (i != m_placeholders.constEnd())
{ {
line.replace(QChar('%')+i.key()+QChar('%'), i.value().second); line.replace(per+i.key()+per, i.value().second);
++i; ++i;
} }
return line; return line;

View File

@ -116,7 +116,7 @@ private:
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline bool DialogCutSplinePath::IsValid() const inline bool DialogCutSplinePath::IsValid() const
{ {
return flagFormula && flagAlias1 && flagAlias2; return flagFormula && flagAlias1 && flagAlias2 && flagName;
} }
#endif // DIALOGCUTSPLINEPATH_H #endif // DIALOGCUTSPLINEPATH_H

View File

@ -410,7 +410,7 @@ void DialogPointOfIntersectionCircles::SaveData()
point->setObject1Id(GetFirstCircleCenterId()); point->setObject1Id(GetFirstCircleCenterId());
point->setObject2Id(GetSecondCircleCenterId()); point->setObject2Id(GetSecondCircleCenterId());
point->setC1Radius(ui->plainTextEditCircle2Radius->toPlainText()); point->setC1Radius(ui->plainTextEditCircle1Radius->toPlainText());
point->setC2Radius(ui->plainTextEditCircle2Radius->toPlainText()); point->setC2Radius(ui->plainTextEditCircle2Radius->toPlainText());
point->setCrossPoint(GetCrossCirclesPoint()); point->setCrossPoint(GetCrossCirclesPoint());
point->RefreshGeometry(); point->RefreshGeometry();

View File

@ -152,7 +152,7 @@ protected:
virtual void ReadToolAttributes(const QDomElement &domElement) override; virtual void ReadToolAttributes(const QDomElement &domElement) override;
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) override; virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) override;
void UpdateNamePosition(quint32 id, const QPointF &pos); virtual void UpdateNamePosition(quint32 id, const QPointF &pos) override;
void SaveSourceDestination(QDomElement &tag); void SaveSourceDestination(QDomElement &tag);
template <typename T> template <typename T>

View File

@ -56,8 +56,8 @@ struct VToolTrueDartsInitData : VDrawToolInitData
dartP2Id(NULL_ID), dartP2Id(NULL_ID),
dartP3Id(NULL_ID), dartP3Id(NULL_ID),
name1(), name1(),
mx1(10), mx1(labelMX),
my1(15), my1(labelMY),
showLabel1(true), showLabel1(true),
name2(), name2(),
mx2(10), mx2(10),

View File

@ -50,8 +50,8 @@ struct VToolBasePointInitData : VToolSinglePointInitData
VToolBasePointInitData() VToolBasePointInitData()
: VToolSinglePointInitData(), : VToolSinglePointInitData(),
nameActivPP(), nameActivPP(),
x(10), x(labelMX),
y(10) y(labelMY)
{} {}
QString nameActivPP; QString nameActivPP;

View File

@ -49,8 +49,8 @@ struct VToolSinglePointInitData : VDrawToolInitData
VToolSinglePointInitData() VToolSinglePointInitData()
: VDrawToolInitData(), : VDrawToolInitData(),
name(), name(),
mx(5), mx(labelMX),
my(10), my(labelMY),
showLabel(true) showLabel(true)
{} {}

View File

@ -68,8 +68,6 @@ public slots:
protected: protected:
void SetPointName(quint32 id, const QString &name); void SetPointName(quint32 id, const QString &name);
virtual void UpdateNamePosition(quint32 id, const QPointF &pos)=0;
template <typename T> template <typename T>
static void InitToolConnections(VMainGraphicsScene *scene, T *tool); static void InitToolConnections(VMainGraphicsScene *scene, T *tool);

View File

@ -185,6 +185,13 @@ QString VDrawTool::MakeToolTip() const
return QString(); return QString();
} }
//---------------------------------------------------------------------------------------------------------------------
void VDrawTool::UpdateNamePosition(quint32 id, const QPointF &pos)
{
Q_UNUSED(id)
Q_UNUSED(pos)
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VDrawTool::CorrectDisable(bool disable, const QString &namePP) const bool VDrawTool::CorrectDisable(bool disable, const QString &namePP) const
{ {

View File

@ -52,6 +52,7 @@
#include "../vdatatool.h" #include "../vdatatool.h"
#include "../vgeometry/vpointf.h" #include "../vgeometry/vpointf.h"
#include "../vtools/undocommands/undogroup.h" #include "../vtools/undocommands/undogroup.h"
#include "../toolsdef.h"
struct VDrawToolInitData : VAbstractToolInitData struct VDrawToolInitData : VAbstractToolInitData
{ {
@ -120,6 +121,7 @@ protected:
void SaveOption(QSharedPointer<VGObject> &obj); void SaveOption(QSharedPointer<VGObject> &obj);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual QString MakeToolTip() const; virtual QString MakeToolTip() const;
virtual void UpdateNamePosition(quint32 id, const QPointF &pos);
bool CorrectDisable(bool disable, const QString &namePP) const; bool CorrectDisable(bool disable, const QString &namePP) const;
@ -241,6 +243,9 @@ void VDrawTool::ContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 itemI
actionShowLabel->setVisible(false); actionShowLabel->setVisible(false);
} }
QAction *actionRestoreLabelPosition = menu.addAction(VDrawTool::tr("Restore label position"));
actionRestoreLabelPosition->setVisible(itemType == GOType::Point);
QAction *actionRemove = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), VDrawTool::tr("Delete")); QAction *actionRemove = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), VDrawTool::tr("Delete"));
if (showRemove == RemoveOption::Enable) if (showRemove == RemoveOption::Enable)
{ {
@ -299,6 +304,10 @@ void VDrawTool::ContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 itemI
{ {
ChangeLabelVisibility(itemId, selectedAction->isChecked()); ChangeLabelVisibility(itemId, selectedAction->isChecked());
} }
else if (selectedAction == actionRestoreLabelPosition)
{
UpdateNamePosition(itemId, QPointF(labelMX, labelMY));
}
else if (selectedAction->actionGroup() == actionsAddToGroup) else if (selectedAction->actionGroup() == actionsAddToGroup)
{ {
quint32 groupId = selectedAction->data().toUInt(); quint32 groupId = selectedAction->data().toUInt();

View File

@ -47,6 +47,10 @@ struct SourceItem
Q_DECLARE_METATYPE(SourceItem) Q_DECLARE_METATYPE(SourceItem)
Q_DECLARE_TYPEINFO(SourceItem, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(SourceItem, Q_MOVABLE_TYPE);
// Default label position
const int labelMX = 10;
const int labelMY = 15;
QVector<quint32> SourceToObjects(const QVector<SourceItem> &source); QVector<quint32> SourceToObjects(const QVector<SourceItem> &source);
QString OriginAlias(quint32 id, const QVector<SourceItem> &source, const QSharedPointer<VGObject> &obj); QString OriginAlias(quint32 id, const QVector<SourceItem> &source, const QSharedPointer<VGObject> &obj);

View File

@ -180,11 +180,8 @@ QString VAbstractMainWindow::CSVFilePath()
const QString suffix("csv"); const QString suffix("csv");
const QString path = QDir::homePath() + QChar('/') + tr("values") + QChar('.') + suffix; const QString path = QDir::homePath() + QChar('/') + tr("values") + QChar('.') + suffix;
QString fileName = QFileDialog::getSaveFileName(this, tr("Export to CSV"), path, filters, nullptr QString fileName = QFileDialog::getSaveFileName(this, tr("Export to CSV"), path, filters, nullptr,
#ifdef Q_OS_LINUX qApp->NativeFileDialog());
, QFileDialog::DontUseNativeDialog
#endif
);
if (fileName.isEmpty()) if (fileName.isEmpty())
{ {

View File

@ -45,15 +45,13 @@ TST_VPoster::TST_VPoster(QObject *parent) :
void TST_VPoster::BigPoster() void TST_VPoster::BigPoster()
{ {
QPrinter printer; QPrinter printer;
printer.setResolution(96);// By default printer.setResolution(static_cast<int>(PrintDPI));// By default
printer.setPageSize(QPageSize(QPageSize::A4)); printer.setPageSize(QPageSize(QPageSize::A4));
printer.setFullPage(true); printer.setFullPage(true);
// We need to set full page because otherwise QPrinter->pageRect returns different values in Windows and Linux // We need to set full page because otherwise QPrinter->pageRect returns different values in Windows and Linux
//sets the margins to 0 to perform the test. //sets the margins to 0 to perform the test.
const qreal left = 0, top = 0, right = 0, bottom = 0; printer.setPageMargins(QMarginsF(), QPageLayout::Millimeter);
printer.setPageMargins(QMarginsF(left, top, right, bottom), QPageLayout::Millimeter);
const QSize image(2622, 3178); // Little bit bigger than A1 const QSize image(2622, 3178); // Little bit bigger than A1
VPoster posterazor(&printer); VPoster posterazor(&printer);