Merge branch 'develop' into feature/manual-layout
This commit is contained in:
commit
a58a783aba
|
@ -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.
|
||||
- Improve canceling nesting.
|
||||
- Fix incorrect nesting status for valid cases.
|
||||
- Improve crossing check for the layout algorithm.
|
||||
- Fix crash after creating an elliptical arc.
|
||||
- New option Reset label position.
|
||||
|
||||
# Version 0.7.40 Nov 23, 2020
|
||||
- New function Warning.
|
||||
|
|
|
@ -258,7 +258,7 @@ deploy:
|
|||
package: valentina-win_auto-upload
|
||||
publish: true
|
||||
override: true
|
||||
version: 0.7.40
|
||||
version: 0.7.41
|
||||
on:
|
||||
DEPLOY: true
|
||||
artifact: valentina-win-$(QT_VERSION)-$(APPVEYOR_REPO_BRANCH)-$(APPVEYOR_REPO_COMMIT)
|
||||
|
|
4
dist/OBS_debian/debian.changelog
vendored
4
dist/OBS_debian/debian.changelog
vendored
|
@ -1,5 +1,5 @@
|
|||
valentina (0.7.40) trusty; urgency=low
|
||||
valentina (0.7.41) trusty; urgency=low
|
||||
|
||||
* 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
|
||||
|
|
4
dist/debian/changelog
vendored
4
dist/debian/changelog
vendored
|
@ -1,5 +1,5 @@
|
|||
valentina (0.7.40) trusty; urgency=low
|
||||
valentina (0.7.41) trusty; urgency=low
|
||||
|
||||
* 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
|
||||
|
|
4
dist/macx/tape/Info.plist
vendored
4
dist/macx/tape/Info.plist
vendored
|
@ -19,9 +19,9 @@
|
|||
<key>CFBundleIdentifier</key>
|
||||
<string>io.bitbucket.valentinaproject.@EXECUTABLE@</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.7.40</string>
|
||||
<string>0.7.41</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>0.7.40.0</string>
|
||||
<string>0.7.41.0</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
|
|
4
dist/macx/valentina/Info.plist
vendored
4
dist/macx/valentina/Info.plist
vendored
|
@ -19,9 +19,9 @@
|
|||
<key>CFBundleIdentifier</key>
|
||||
<string>io.bitbucket.valentinaproject.@EXECUTABLE@</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.7.40</string>
|
||||
<string>0.7.41</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>0.7.40.0</string>
|
||||
<string>0.7.41.0</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
|
|
2
dist/rpm/_service
vendored
2
dist/rpm/_service
vendored
|
@ -1,7 +1,7 @@
|
|||
<services>
|
||||
<service name="tar_scm">
|
||||
<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="scm">git</param>
|
||||
<param name="exclude">.git</param>
|
||||
|
|
2
dist/rpm/valentina.spec
vendored
2
dist/rpm/valentina.spec
vendored
|
@ -91,7 +91,7 @@ Requires: poppler-tools
|
|||
Requires: poppler-utils
|
||||
%endif
|
||||
|
||||
Version: 0.7.40
|
||||
Version: 0.7.41
|
||||
Release: 0
|
||||
URL: https://gitlab.com/smart-pattern/valentina
|
||||
License: GPL-3.0+
|
||||
|
|
8
dist/valentina.dsc
vendored
8
dist/valentina.dsc
vendored
|
@ -2,7 +2,7 @@ Format: 3.0 (native)
|
|||
Source: valentina
|
||||
Binary: valentina
|
||||
Architecture: i386 amd64
|
||||
Version: 0.7.40
|
||||
Version: 0.7.41
|
||||
Maintainer: Roman Telezhynskyi <dismine@gmail.com>
|
||||
Homepage: https://valentinaproject.bitbucket.io
|
||||
Standards-Version: 3.9.5
|
||||
|
@ -18,8 +18,8 @@ Build-Depends: debhelper (>= 8.0.0),
|
|||
Package-List:
|
||||
valentina deb graphics optional
|
||||
Checksums-Sha1:
|
||||
581eb1bf36b4ab7126b5983d809130f15396859e 24838101 valentina_0.7.40.tar
|
||||
581eb1bf36b4ab7126b5983d809130f15396859e 24838101 valentina_0.7.41.tar
|
||||
Checksums-Sha256:
|
||||
9b156c7120a69b90373efb8ca9998c3e0563a60ad337210166cfd41b00b0f13c 24838101 valentina_0.7.40.tar
|
||||
9b156c7120a69b90373efb8ca9998c3e0563a60ad337210166cfd41b00b0f13c 24838101 valentina_0.7.41.tar
|
||||
Files:
|
||||
95677e29d3a59cf5b064f7be236a4b78 24838101 valentina_0.7.40.tar
|
||||
95677e29d3a59cf5b064f7be236a4b78 24838101 valentina_0.7.41.tar
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
},
|
||||
|
||||
"version": {
|
||||
"name": "0.7.40",
|
||||
"name": "0.7.41",
|
||||
"desc": "Test branch release",
|
||||
"released": "2020-11-23",
|
||||
"vcs_tag": "v0.7.40",
|
||||
"released": "2020-12-4",
|
||||
"vcs_tag": "v0.7.41",
|
||||
"gpgSign": false
|
||||
},
|
||||
|
||||
|
|
|
@ -14057,6 +14057,10 @@ Do you want to save your changes?</translation>
|
|||
<source>Show label</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Restore label position</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>VException</name>
|
||||
|
|
|
@ -13721,6 +13721,10 @@ Chcete uložit změny?</translation>
|
|||
<source>Show label</source>
|
||||
<translation>Ukázat popis</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Restore label position</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>VException</name>
|
||||
|
@ -15280,7 +15284,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
|
|||
</message>
|
||||
<message>
|
||||
<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>
|
||||
</context>
|
||||
<context>
|
||||
|
|
|
@ -13714,6 +13714,10 @@ Do you want to save your changes?</source>
|
|||
<source>Show label</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Restore label position</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>VException</name>
|
||||
|
@ -15230,7 +15234,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
|
|||
</message>
|
||||
<message>
|
||||
<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>
|
||||
</context>
|
||||
<context>
|
||||
|
|
|
@ -13212,6 +13212,10 @@ Do you want to save your changes?</source>
|
|||
<source>Show label</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Restore label position</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>VException</name>
|
||||
|
|
|
@ -13668,6 +13668,10 @@ Do you want to save your changes?</translation>
|
|||
<source>Show label</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Restore label position</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>VException</name>
|
||||
|
|
|
@ -13668,6 +13668,10 @@ Do you want to save your changes?</translation>
|
|||
<source>Show label</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Restore label position</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>VException</name>
|
||||
|
|
|
@ -13668,6 +13668,10 @@ Do you want to save your changes?</translation>
|
|||
<source>Show label</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Restore label position</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>VException</name>
|
||||
|
|
|
@ -13726,6 +13726,10 @@ Quieres guardar los cambios?</translation>
|
|||
<source>Show label</source>
|
||||
<translation>Mostrar estiqueta</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Restore label position</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>VException</name>
|
||||
|
@ -15285,7 +15289,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
|
|||
</message>
|
||||
<message>
|
||||
<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>
|
||||
</context>
|
||||
<context>
|
||||
|
|
|
@ -12177,6 +12177,10 @@ Do you want to save your changes?</source>
|
|||
<source>Show label</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Restore label position</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>VException</name>
|
||||
|
|
|
@ -13639,6 +13639,10 @@ Voulez-vous enregistrer les changements?</translation>
|
|||
<source>Show label</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Restore label position</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>VException</name>
|
||||
|
|
|
@ -10894,6 +10894,10 @@ Do you want to save your changes?</source>
|
|||
<source>Show label</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Restore label position</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>VException</name>
|
||||
|
|
|
@ -11278,6 +11278,10 @@ Do you want to save your changes?</source>
|
|||
<source>Show label</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Restore label position</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>VException</name>
|
||||
|
|
|
@ -13600,6 +13600,10 @@ Vuoi salvare le tue modifiche?</translation>
|
|||
<source>Show label</source>
|
||||
<translation>Mostra etichetta</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Restore label position</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>VException</name>
|
||||
|
|
|
@ -12342,6 +12342,10 @@ Do you want to save your changes?</source>
|
|||
<source>Show label</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Restore label position</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>VException</name>
|
||||
|
@ -15364,27 +15368,27 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
|
|||
</message>
|
||||
<message>
|
||||
<source>Select all</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Zaznaczono wszystko</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Select none</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Zaznaczenie jest puste</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>select all details</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>wybrano wszystkie szczegóły</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>select none details</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>nie wybrano szczegółów</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Invert selection</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Odwróć zaznaczenie</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>invert selection</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Odwróć zaznaczenie</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Hide not in layout</source>
|
||||
|
@ -15755,7 +15759,19 @@ Do you want to save your changes?</source>
|
|||
</message>
|
||||
<message>
|
||||
<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>
|
||||
<source>Information.</source>
|
||||
|
@ -15763,15 +15779,15 @@ Do you want to save your changes?</source>
|
|||
</message>
|
||||
<message>
|
||||
<source>Warning</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Ostrzeżenie</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Critical error</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Błąd krytyczny</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Fatal error</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Błąd krytyczny</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Information</source>
|
||||
|
@ -15798,7 +15814,19 @@ Do you want to save your changes?</source>
|
|||
</message>
|
||||
<message>
|
||||
<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>
|
||||
<source>Information.</source>
|
||||
|
@ -15806,15 +15834,15 @@ Do you want to save your changes?</source>
|
|||
</message>
|
||||
<message>
|
||||
<source>Warning</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Ostrzeżenie</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Critical error</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Błąd krytyczny</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Fatal error</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Błąd krytyczny</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Information</source>
|
||||
|
|
|
@ -13627,6 +13627,10 @@ Deseja salvar suas mudanças?</translation>
|
|||
<source>Show label</source>
|
||||
<translation>Mostrar rótulo</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Restore label position</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>VException</name>
|
||||
|
|
|
@ -12059,6 +12059,10 @@ Do you want to save your changes?</source>
|
|||
<source>Show label</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Restore label position</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>VException</name>
|
||||
|
|
|
@ -3377,7 +3377,7 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>Insert nodes</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Вставить узлы</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Delete</source>
|
||||
|
@ -8886,7 +8886,7 @@ Do you want to save your changes?</source>
|
|||
</message>
|
||||
<message>
|
||||
<source>The measurements file <br/><br/> <b>%1</b> <br/><br/> could not be found. Do you want to update the file location?</source>
|
||||
<translation>Файл меток <br/><br/> <b>%1</b> <br/><br/> не найден. Вы хотите обновить данные о местоположении файла?</translation>
|
||||
<translation>Файл мерок <br/><br/> <b>%1</b> <br/><br/> не найден. Вы хотите обновить данные о местоположении файла?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Flipping objects by line</source>
|
||||
|
@ -13727,6 +13727,10 @@ Do you want to save your changes?</source>
|
|||
<source>Show label</source>
|
||||
<translation>Показать метку</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Restore label position</source>
|
||||
<translation>Восстановить положение метки</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>VException</name>
|
||||
|
@ -15286,7 +15290,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
|
|||
</message>
|
||||
<message>
|
||||
<source>Point of intersection circle and segment</source>
|
||||
<translation type="unfinished">Точка пересечения окружности и отрезка</translation>
|
||||
<translation>Точка пересечения окружности и отрезка</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
@ -17049,12 +17053,12 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
|
|||
<message>
|
||||
<source>warning</source>
|
||||
<comment>Calculation warning</comment>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>предупреждение</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Show a warning in calculations</source>
|
||||
<comment>function warning</comment>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Показывать предупреждение в расчетах</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
|
|
@ -13667,6 +13667,10 @@ Do you want to save your changes?</source>
|
|||
<source>Show label</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Restore label position</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>VException</name>
|
||||
|
|
|
@ -11095,6 +11095,10 @@ Do you want to save your changes?</source>
|
|||
<source>Show label</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Restore label position</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>VException</name>
|
||||
|
|
|
@ -39,12 +39,13 @@
|
|||
#include "../vmisc/qt_dispatch/qt_dispatch.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")
|
||||
QT_WARNING_DISABLE_INTEL(1418)
|
||||
|
||||
Q_LOGGING_CATEGORY(mApp, "m.application")
|
||||
Q_LOGGING_CATEGORY(pApp, "p.application")
|
||||
|
||||
QT_WARNING_POP
|
||||
|
||||
|
@ -271,50 +272,50 @@ bool VPApplication::notify(QObject *receiver, QEvent *event)
|
|||
}
|
||||
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()));
|
||||
exit(V_EX_DATAERR);
|
||||
}
|
||||
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()));
|
||||
exit(V_EX_DATAERR);
|
||||
}
|
||||
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()));
|
||||
exit(V_EX_DATAERR);
|
||||
}
|
||||
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()));
|
||||
exit(V_EX_DATAERR);
|
||||
}
|
||||
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()));
|
||||
exit(V_EX_DATAERR);
|
||||
}
|
||||
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(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||
exit(V_EX_DATAERR);
|
||||
}
|
||||
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()));
|
||||
return true;
|
||||
}
|
||||
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);
|
||||
}
|
||||
return false;
|
||||
|
@ -374,12 +375,12 @@ void VPApplication::InitOptions()
|
|||
|
||||
OpenSettings();
|
||||
|
||||
qCDebug(mApp, "Version: %s", qUtf8Printable(APP_VERSION_STR));
|
||||
qCDebug(mApp, "Build revision: %s", BUILD_REVISION);
|
||||
qCDebug(mApp, "%s", qUtf8Printable(buildCompatibilityString()));
|
||||
qCDebug(mApp, "Built on %s at %s", __DATE__, __TIME__);
|
||||
qCDebug(mApp, "Command-line arguments: %s", qUtf8Printable(arguments().join(", ")));
|
||||
qCDebug(mApp, "Process ID: %s", qUtf8Printable(QString().setNum(applicationPid())));
|
||||
qCDebug(pApp, "Version: %s", qUtf8Printable(APP_VERSION_STR));
|
||||
qCDebug(pApp, "Build revision: %s", BUILD_REVISION);
|
||||
qCDebug(pApp, "%s", qUtf8Printable(buildCompatibilityString()));
|
||||
qCDebug(pApp, "Built on %s at %s", __DATE__, __TIME__);
|
||||
qCDebug(pApp, "Command-line arguments: %s", qUtf8Printable(arguments().join(", ")));
|
||||
qCDebug(pApp, "Process ID: %s", qUtf8Printable(QString().setNum(applicationPid())));
|
||||
|
||||
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);
|
||||
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);
|
||||
stream << arguments.join(";;");
|
||||
stream.flush();
|
||||
|
@ -459,20 +460,20 @@ void VPApplication::ParseCommandLine(const SocketConnection &connection, const Q
|
|||
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);
|
||||
connect(localServer, &QLocalServer::newConnection, this, &VPApplication::NewLocalSocketConnection);
|
||||
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));
|
||||
if (localServer->serverError() == QAbstractSocket::AddressInUseError)
|
||||
{
|
||||
QLocalServer::removeServer(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)));
|
||||
}
|
||||
}
|
||||
|
@ -493,13 +494,13 @@ void VPApplication::ProcessArguments(const VPCommandLinePtr &cmd)
|
|||
{
|
||||
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);
|
||||
}
|
||||
|
||||
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.")));
|
||||
cmd.get()->parser.showHelp(V_EX_USAGE);
|
||||
}
|
||||
|
@ -527,7 +528,7 @@ void VPApplication::ProcessArguments(const VPCommandLinePtr &cmd)
|
|||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,10 @@ TapePreferencesConfigurationPage::TapePreferencesConfigurationPage(QWidget *pare
|
|||
ui->osOptionCheck->setChecked(qApp->TapeSettings()->GetOsSeparator());
|
||||
|
||||
// Theme
|
||||
ui->darkModeCheck->setChecked(qApp->TapeSettings()->GetDarkMode());
|
||||
ui->darkModeCheck->setChecked(qApp->TapeSettings()->GetDarkMode());
|
||||
|
||||
// Native dialogs
|
||||
ui->checkBoxDontUseNativeDialog->setChecked(qApp->TapeSettings()->IsDontUseNativeDialog());
|
||||
|
||||
//---------------------- Pattern making system
|
||||
ui->systemBookValueLabel->setFixedHeight(4 * QFontMetrics(ui->systemBookValueLabel->font()).lineSpacing());
|
||||
|
@ -106,6 +109,11 @@ QStringList TapePreferencesConfigurationPage::Apply()
|
|||
preferences.append(tr("dark mode"));
|
||||
}
|
||||
|
||||
if (settings->IsDontUseNativeDialog() != ui->checkBoxDontUseNativeDialog->isChecked())
|
||||
{
|
||||
settings->SetDontUseNativeDialog(ui->checkBoxDontUseNativeDialog->isChecked());
|
||||
}
|
||||
|
||||
if (m_langChanged || m_systemChanged)
|
||||
{
|
||||
const QString locale = qvariant_cast<QString>(ui->langCombo->currentData());
|
||||
|
|
|
@ -170,19 +170,22 @@
|
|||
<property name="title">
|
||||
<string>User Interface</string>
|
||||
</property>
|
||||
<widget class="QCheckBox" name="darkModeCheck">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>30</y>
|
||||
<width>351</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Activate dark mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="darkModeCheck">
|
||||
<property name="text">
|
||||
<string>Activate dark mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxDontUseNativeDialog">
|
||||
<property name="text">
|
||||
<string>Don't use the native file dialog</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
@ -149,8 +149,9 @@ void TapePreferencesPathPage::EditPath()
|
|||
usedNotExistedDir = directory.mkpath(QChar('.'));
|
||||
}
|
||||
|
||||
const QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), path,
|
||||
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||
const QString dir = QFileDialog::getExistingDirectory(
|
||||
this, tr("Open Directory"), path,
|
||||
qApp->NativeFileDialog(QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks));
|
||||
if (dir.isEmpty())
|
||||
{
|
||||
if (usedNotExistedDir)
|
||||
|
|
|
@ -520,7 +520,8 @@ void TMainWindow::CreateFromExisting()
|
|||
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())
|
||||
{
|
||||
|
@ -889,7 +890,8 @@ bool TMainWindow::FileSaveAs()
|
|||
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]()
|
||||
{
|
||||
|
@ -997,11 +999,8 @@ void TMainWindow::ImportDataFromCSV()
|
|||
const QString filters = tr("Comma-Separated Values") + QStringLiteral(" (*.csv)");
|
||||
const QString suffix = QStringLiteral("csv");
|
||||
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Import from CSV"), QDir::homePath(), filters, nullptr
|
||||
#ifdef Q_OS_LINUX
|
||||
, QFileDialog::DontUseNativeDialog
|
||||
#endif
|
||||
);
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Import from CSV"), QDir::homePath(), filters, nullptr,
|
||||
qApp->NativeFileDialog());
|
||||
|
||||
if (fileName.isEmpty())
|
||||
{
|
||||
|
@ -1471,7 +1470,8 @@ void TMainWindow::ImportFromPattern()
|
|||
//Use standard path to individual measurements
|
||||
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())
|
||||
{
|
||||
return;
|
||||
|
@ -2189,7 +2189,7 @@ void TMainWindow::ExportToIndividual()
|
|||
QString filters = tr("Individual measurements") + QStringLiteral(" (*.vit)");
|
||||
QString fName = tr("measurements.vit");
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Export to individual"), dir + QChar('/') + fName,
|
||||
filters);
|
||||
filters, nullptr, qApp->NativeFileDialog());
|
||||
|
||||
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)
|
||||
{
|
||||
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())
|
||||
{
|
||||
|
|
|
@ -41,7 +41,7 @@ class VApplication;// use in define
|
|||
#if defined(qApp)
|
||||
#undef qApp
|
||||
#endif
|
||||
#define qApp (static_cast<VApplication*>(VAbstractApplication::instance()))
|
||||
#define qApp (qobject_cast<VApplication*>(VAbstractApplication::instance()))
|
||||
|
||||
/**
|
||||
* @brief The VApplication class reimplamentation QApplication class.
|
||||
|
|
|
@ -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, 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, 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, settingDockWidgetToolOptionsActive,
|
||||
|
@ -479,33 +477,6 @@ void VValentinaSettings::SetRememberPatternMaterials(bool value)
|
|||
}
|
||||
|
||||
// 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.
|
||||
|
@ -552,21 +523,6 @@ void VValentinaSettings::SetTiledPDFPaperWidth(qreal value, const Unit &unit)
|
|||
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
|
||||
|
|
|
@ -135,18 +135,12 @@ public:
|
|||
void SetRememberPatternMaterials(bool value);
|
||||
|
||||
// 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;
|
||||
void SetTiledPDFPaperHeight(qreal value, const Unit &unit);
|
||||
|
||||
qreal GetTiledPDFPaperWidth(const Unit &unit) const;
|
||||
void SetTiledPDFPaperWidth(qreal value, const Unit &unit);
|
||||
|
||||
PageOrientation GetTiledPDFOrientation() const;
|
||||
void SetTiledPDFOrientation(PageOrientation value);
|
||||
|
||||
bool IsDockWidgetGroupsActive() const;
|
||||
static bool GetDefDockWidgetGroupsActive();
|
||||
void SetDockWidgetGroupsActive(bool value);
|
||||
|
@ -175,6 +169,9 @@ public:
|
|||
|
||||
private:
|
||||
Q_DISABLE_COPY(VValentinaSettings)
|
||||
|
||||
template <typename T>
|
||||
T GetCachedValue(T &cache, const QString &setting, T defValue, T valueMin, T valueMax) const;
|
||||
};
|
||||
|
||||
#endif // VVALENTINASETTINGS_H
|
||||
|
|
|
@ -130,6 +130,9 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent)
|
|||
// Tool panel
|
||||
ui->checkBoxToolPanelScaling->setChecked(settings->GetToolPanelScaling());
|
||||
|
||||
// Native dialogs
|
||||
ui->checkBoxDontUseNativeDialog->setChecked(settings->IsDontUseNativeDialog());
|
||||
|
||||
// Tab Scrolling
|
||||
ui->spinBoxDuration->setMinimum(VValentinaSettings::scrollingDurationMin);
|
||||
ui->spinBoxDuration->setMaximum(VValentinaSettings::scrollingDurationMax);
|
||||
|
@ -186,6 +189,11 @@ QStringList PreferencesConfigurationPage::Apply()
|
|||
settings->SetToolPanelScaling(ui->checkBoxToolPanelScaling->isChecked());
|
||||
}
|
||||
|
||||
if (settings->IsDontUseNativeDialog() != ui->checkBoxDontUseNativeDialog->isChecked())
|
||||
{
|
||||
settings->SetDontUseNativeDialog(ui->checkBoxDontUseNativeDialog->isChecked());
|
||||
}
|
||||
|
||||
settings->SetFreeCurveMode(ui->checkBoxFreeCurve->isChecked());
|
||||
settings->SetDoubleClickZoomFitBestCurrentPP(ui->checkBoxZoomFitBestCurrentPP->isChecked());
|
||||
|
||||
|
|
|
@ -33,9 +33,9 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>-161</y>
|
||||
<y>-189</y>
|
||||
<width>624</width>
|
||||
<height>717</height>
|
||||
<height>745</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
|
@ -283,6 +283,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxDontUseNativeDialog">
|
||||
<property name="text">
|
||||
<string>Don't use the native file dialog</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -173,13 +173,9 @@ void PreferencesPathPage::EditPath()
|
|||
usedNotExistedDir = directory.mkpath(QChar('.'));
|
||||
}
|
||||
|
||||
const QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), path,
|
||||
QFileDialog::ShowDirsOnly
|
||||
| QFileDialog::DontResolveSymlinks
|
||||
#ifdef Q_OS_LINUX
|
||||
| QFileDialog::DontUseNativeDialog
|
||||
#endif
|
||||
);
|
||||
const QString dir = QFileDialog::getExistingDirectory(
|
||||
this, tr("Open Directory"), path,
|
||||
qApp->NativeFileDialog(QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks));
|
||||
if (dir.isEmpty())
|
||||
{
|
||||
if (usedNotExistedDir)
|
||||
|
|
|
@ -909,9 +909,6 @@ QSizeF DialogLayoutSettings::GetTemplateSize(const PaperSizeTemplate &tmpl, cons
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QMarginsF DialogLayoutSettings::MinPrinterFields() const
|
||||
{
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <QCloseEvent>
|
||||
#include <QMargins>
|
||||
|
||||
#include "vabstractlayoutdialog.h"
|
||||
#include "../vlayout/dialogs/vabstractlayoutdialog.h"
|
||||
#include "../vlayout/vbank.h"
|
||||
|
||||
namespace Ui
|
||||
|
|
|
@ -411,11 +411,8 @@ void DialogPatternProperties::InitImage()
|
|||
void DialogPatternProperties::ChangeImage()
|
||||
{
|
||||
const QString filter = tr("Images") + QLatin1String(" (*.png *.jpg *.jpeg *.bmp)");
|
||||
const QString fileName = QFileDialog::getOpenFileName(this, tr("Image for pattern"), QString(), filter, nullptr
|
||||
#ifdef Q_OS_LINUX
|
||||
, QFileDialog::DontUseNativeDialog
|
||||
#endif
|
||||
);
|
||||
const QString fileName = QFileDialog::getOpenFileName(this, tr("Image for pattern"), QString(), filter, nullptr,
|
||||
qApp->NativeFileDialog());
|
||||
if (not fileName.isEmpty())
|
||||
{
|
||||
QImage image;
|
||||
|
@ -456,11 +453,8 @@ void DialogPatternProperties::SaveImage()
|
|||
QByteArray ba = QByteArray::fromBase64(byteArray);
|
||||
const QString extension = doc->GetImageExtension().prepend(QChar('.'));
|
||||
QString filter = tr("Images") + QStringLiteral(" (*") + extension + QChar(')');
|
||||
QString filename = QFileDialog::getSaveFileName(this, tr("Save File"), tr("untitled"), filter, &filter
|
||||
#ifdef Q_OS_LINUX
|
||||
, QFileDialog::DontUseNativeDialog
|
||||
#endif
|
||||
);
|
||||
QString filename = QFileDialog::getSaveFileName(this, tr("Save File"), tr("untitled"), filter, &filter,
|
||||
qApp->NativeFileDialog());
|
||||
if (not filename.isEmpty())
|
||||
{
|
||||
if (not filename.endsWith(extension.toUpper()))
|
||||
|
|
|
@ -36,6 +36,5 @@
|
|||
#include "dialogaboutapp.h"
|
||||
#include "dialogpreferences.h"
|
||||
#include "dialogfinalmeasurements.h"
|
||||
#include "dialoglayoutscale.h"
|
||||
|
||||
#endif // DIALOGS_H
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
# This need for corect working file translations.pro
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/dialoglayoutscale.h \
|
||||
$$PWD/dialogs.h \
|
||||
$$PWD/dialogincrements.h \
|
||||
$$PWD/dialoghistory.h \
|
||||
|
@ -21,13 +20,11 @@ HEADERS += \
|
|||
$$PWD/dialogdatetimeformats.h \
|
||||
$$PWD/dialogknownmaterials.h \
|
||||
$$PWD/dialogpatternmaterials.h \
|
||||
$$PWD/dialogfinalmeasurements.h \
|
||||
$$PWD/vabstractlayoutdialog.h
|
||||
$$PWD/dialogfinalmeasurements.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/dialogincrements.cpp \
|
||||
$$PWD/dialoghistory.cpp \
|
||||
$$PWD/dialoglayoutscale.cpp \
|
||||
$$PWD/dialogpatternproperties.cpp \
|
||||
$$PWD/dialognewpattern.cpp \
|
||||
$$PWD/dialogaboutapp.cpp \
|
||||
|
@ -43,13 +40,11 @@ SOURCES += \
|
|||
$$PWD/dialogdatetimeformats.cpp \
|
||||
$$PWD/dialogknownmaterials.cpp \
|
||||
$$PWD/dialogpatternmaterials.cpp \
|
||||
$$PWD/dialogfinalmeasurements.cpp \
|
||||
$$PWD/vabstractlayoutdialog.cpp
|
||||
$$PWD/dialogfinalmeasurements.cpp
|
||||
|
||||
FORMS += \
|
||||
$$PWD/dialogincrements.ui \
|
||||
$$PWD/dialoghistory.ui \
|
||||
$$PWD/dialoglayoutscale.ui \
|
||||
$$PWD/dialogpatternproperties.ui \
|
||||
$$PWD/dialognewpattern.ui \
|
||||
$$PWD/dialogaboutapp.ui \
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "../core/vapplication.h"
|
||||
#include "../core/vvalentinasettings.h"
|
||||
#include "../ifc/exception/vexception.h"
|
||||
#include "../vlayout/vlayoutexporter.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
|
@ -128,13 +129,9 @@ DialogSaveLayout::DialogSaveLayout(int count, Draw mode, const QString &fileName
|
|||
usedNotExistedDir = directory.mkpath(QChar('.'));
|
||||
}
|
||||
|
||||
const QString dir = QFileDialog::getExistingDirectory(this, tr("Select folder"), dirPath,
|
||||
QFileDialog::ShowDirsOnly
|
||||
| QFileDialog::DontResolveSymlinks
|
||||
#ifdef Q_OS_LINUX
|
||||
| QFileDialog::DontUseNativeDialog
|
||||
#endif
|
||||
);
|
||||
const QString dir = QFileDialog::getExistingDirectory(
|
||||
this, tr("Select folder"), dirPath,
|
||||
qApp->NativeFileDialog(QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks));
|
||||
if (not dir.isEmpty())
|
||||
{// If paths equal the signal will not be called, we will do this manually
|
||||
dir == ui->lineEditPath->text() ? PathChanged(dir) : ui->lineEditPath->setText(dir);
|
||||
|
@ -803,35 +800,12 @@ bool DialogSaveLayout::SupportPSTest()
|
|||
{
|
||||
if (!tested)
|
||||
{
|
||||
havePdf = TestPdf();
|
||||
havePdf = VLayoutExporter::SupportPDFConversion();
|
||||
tested = true;
|
||||
}
|
||||
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()
|
||||
{
|
||||
|
|
|
@ -30,17 +30,9 @@
|
|||
#define DIALOGSAVELAYOUT_H
|
||||
|
||||
#include "../vgeometry/vgeometrydef.h"
|
||||
#include "vabstractlayoutdialog.h"
|
||||
#include "../vlayout/dialogs/vabstractlayoutdialog.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
|
||||
{
|
||||
class DialogSaveLAyout;
|
||||
|
@ -115,7 +107,6 @@ private:
|
|||
static bool havePdf;
|
||||
static bool tested;
|
||||
static bool SupportPSTest();
|
||||
static bool TestPdf();
|
||||
static QVector<std::pair<QString, LayoutExportFormats> > InitFormats();
|
||||
|
||||
void RemoveFormatFromList(LayoutExportFormats format);
|
||||
|
|
|
@ -1641,10 +1641,7 @@ void MainWindow::customEvent(QEvent *event)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MainWindow::CleanLayout()
|
||||
{
|
||||
qDeleteAll (scenes);
|
||||
scenes.clear();
|
||||
shadows.clear();
|
||||
papers.clear();
|
||||
m_layoutSettings->CleanLayout();
|
||||
gcontours.clear();
|
||||
ui->listWidget->clear();
|
||||
SetLayoutModeActions();
|
||||
|
@ -1654,14 +1651,14 @@ void MainWindow::CleanLayout()
|
|||
void MainWindow::PrepareSceneList(PreviewQuatilty quality)
|
||||
{
|
||||
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),
|
||||
QString::number(i));
|
||||
ui->listWidget->addItem(item);
|
||||
}
|
||||
|
||||
if (not scenes.isEmpty())
|
||||
if (not m_layoutSettings->LayoutScenes().isEmpty())
|
||||
{
|
||||
ui->listWidget->setCurrentRow(0);
|
||||
SetLayoutModeActions();
|
||||
|
@ -1769,11 +1766,8 @@ void MainWindow::LoadIndividual()
|
|||
usedNotExistedDir = directory.mkpath(QChar('.'));
|
||||
}
|
||||
|
||||
const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter, nullptr
|
||||
#ifdef Q_OS_LINUX
|
||||
, QFileDialog::DontUseNativeDialog
|
||||
#endif
|
||||
);
|
||||
const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter, nullptr,
|
||||
qApp->NativeFileDialog());
|
||||
|
||||
if (not mPath.isEmpty())
|
||||
{
|
||||
|
@ -1810,11 +1804,8 @@ void MainWindow::LoadMultisize()
|
|||
//Use standard path to multisize measurements
|
||||
QString path = qApp->ValentinaSettings()->GetPathMultisizeMeasurements();
|
||||
path = VCommonSettings::PrepareMultisizeTables(path);
|
||||
const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter, nullptr
|
||||
#ifdef Q_OS_LINUX
|
||||
, QFileDialog::DontUseNativeDialog
|
||||
#endif
|
||||
);
|
||||
const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter, nullptr,
|
||||
qApp->NativeFileDialog());
|
||||
|
||||
if (not mPath.isEmpty())
|
||||
{
|
||||
|
@ -2034,7 +2025,8 @@ void MainWindow::LoadWatermark()
|
|||
const QString filter(tr("Watermark files") + QLatin1String(" (*.vwm)"));
|
||||
QString dir = QDir::homePath();
|
||||
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())
|
||||
{
|
||||
return;
|
||||
|
@ -3067,7 +3059,7 @@ void MainWindow::ActionLayout(bool checked)
|
|||
|
||||
ShowPaper(ui->listWidget->currentRow());
|
||||
|
||||
if (scenes.isEmpty() || isLayoutStale)
|
||||
if (m_layoutSettings->LayoutScenes().isEmpty() || m_layoutSettings->IsLayoutStale())
|
||||
{
|
||||
ui->toolButtonLayoutSettings->click();
|
||||
}
|
||||
|
@ -3108,11 +3100,7 @@ bool MainWindow::on_actionSaveAs_triggered()
|
|||
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"),
|
||||
dir + QLatin1String("/") + tr("pattern") + QLatin1String(".val"),
|
||||
filters, nullptr
|
||||
#ifdef Q_OS_LINUX
|
||||
, QFileDialog::DontUseNativeDialog
|
||||
#endif
|
||||
);
|
||||
filters, nullptr, qApp->NativeFileDialog());
|
||||
|
||||
auto RemoveTempDir = qScopeGuard([usedNotExistedDir, dir]()
|
||||
{
|
||||
|
@ -3305,11 +3293,8 @@ void MainWindow::on_actionOpen_triggered()
|
|||
dir = QFileInfo(files.first()).absolutePath();
|
||||
}
|
||||
qCDebug(vMainWindow, "Run QFileDialog::getOpenFileName: dir = %s.", qUtf8Printable(dir));
|
||||
const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter, nullptr
|
||||
#ifdef Q_OS_LINUX
|
||||
, QFileDialog::DontUseNativeDialog
|
||||
#endif
|
||||
);
|
||||
const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter, nullptr,
|
||||
qApp->NativeFileDialog());
|
||||
if (filePath.isEmpty())
|
||||
{
|
||||
return;
|
||||
|
@ -3975,7 +3960,7 @@ void MainWindow::PatternChangesWereSaved(bool saved)
|
|||
const bool state = doc->IsModified() || !saved;
|
||||
setWindowModified(state);
|
||||
not patternReadOnly ? ui->actionSave->setEnabled(state): ui->actionSave->setEnabled(false);
|
||||
isLayoutStale = true;
|
||||
m_layoutSettings->SetLayoutStale(true);
|
||||
isNeedAutosave = not saved;
|
||||
}
|
||||
}
|
||||
|
@ -4335,7 +4320,7 @@ QT_WARNING_POP
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MainWindow::SetLayoutModeActions()
|
||||
{
|
||||
const bool enabled = not scenes.isEmpty();
|
||||
const bool enabled = not m_layoutSettings->LayoutScenes().isEmpty();
|
||||
|
||||
ui->toolButtonLayoutExportAs->setEnabled(enabled);
|
||||
ui->actionExportAs->setEnabled(enabled);
|
||||
|
@ -4908,13 +4893,13 @@ void MainWindow::CreateActions()
|
|||
QString fileName =
|
||||
QFileDialog::getSaveFileName(this, tr("Export recipe"),
|
||||
QDir::homePath() + '/' + tr("recipe") + QStringLiteral(".vpr"),
|
||||
filters, nullptr);
|
||||
filters, nullptr, qApp->NativeFileDialog());
|
||||
if (fileName.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
VPatternRecipe recipe(pattern, doc);
|
||||
VPatternRecipe recipe(doc);
|
||||
QString error;
|
||||
if (not recipe.SaveDocument(fileName, error))
|
||||
{
|
||||
|
@ -5169,7 +5154,6 @@ bool MainWindow::PatternPieceName(QString &name)
|
|||
MainWindow::~MainWindow()
|
||||
{
|
||||
CancelTool();
|
||||
qDeleteAll (scenes);
|
||||
|
||||
delete doc;
|
||||
delete ui;
|
||||
|
@ -5425,6 +5409,7 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile)
|
|||
ActionDraw(true);
|
||||
|
||||
qApp->setOpeningPattern();// End opening file
|
||||
m_statusLabel->setText(QString());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
@ -5494,13 +5479,13 @@ void MainWindow::ToolBoxSizePolicy()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MainWindow::ShowPaper(int index)
|
||||
{
|
||||
if (index < 0 || index >= scenes.size())
|
||||
if (index < 0 || index >= m_layoutSettings->LayoutScenes().size())
|
||||
{
|
||||
ui->view->setScene(tempSceneLayout);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->view->setScene(scenes.at(index));
|
||||
ui->view->setScene(m_layoutSettings->LayoutScenes().at(index));
|
||||
}
|
||||
|
||||
ui->view->fitInView(ui->view->scene()->sceneRect(), Qt::KeepAspectRatio);
|
||||
|
@ -5557,9 +5542,9 @@ void MainWindow::ExportLayoutAs()
|
|||
{
|
||||
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;
|
||||
}
|
||||
|
@ -5567,8 +5552,8 @@ void MainWindow::ExportLayoutAs()
|
|||
|
||||
try
|
||||
{
|
||||
m_dialogSaveLayout = QSharedPointer<DialogSaveLayout>(new DialogSaveLayout(scenes.size(), Draw::Layout,
|
||||
FileName(), this));
|
||||
m_dialogSaveLayout = QSharedPointer<DialogSaveLayout>(
|
||||
new DialogSaveLayout(m_layoutSettings->LayoutScenes().size(), Draw::Layout, FileName(), this));
|
||||
|
||||
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);
|
||||
dialog.selectFile(selectedName);
|
||||
dialog.setFileMode(QFileDialog::ExistingFile);
|
||||
dialog.setOption(QFileDialog::DontUseNativeDialog, qApp->Settings()->IsDontUseNativeDialog());
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
mPath = dialog.selectedFiles().value(0);
|
||||
|
@ -5985,9 +5971,9 @@ bool MainWindow::DoExport(const VCommandLinePtr &expParams)
|
|||
{
|
||||
try
|
||||
{
|
||||
m_dialogSaveLayout = QSharedPointer<DialogSaveLayout>(new DialogSaveLayout(scenes.size(), Draw::Layout,
|
||||
expParams->OptBaseName(),
|
||||
this));
|
||||
m_dialogSaveLayout = QSharedPointer<DialogSaveLayout>(
|
||||
new DialogSaveLayout(m_layoutSettings->LayoutScenes().size(),
|
||||
Draw::Layout, expParams->OptBaseName(), this));
|
||||
m_dialogSaveLayout->SetDestinationPath(expParams->OptDestinationPath());
|
||||
m_dialogSaveLayout->SelectFormat(static_cast<LayoutExportFormats>(expParams->OptExportType()));
|
||||
m_dialogSaveLayout->SetBinaryDXFFormat(expParams->IsBinaryDXF());
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -40,6 +40,7 @@
|
|||
#include "../vlayout/vlayoutgenerator.h"
|
||||
#include "../vwidgets/vabstractmainwindow.h"
|
||||
#include "../vlayout/vtextmanager.h"
|
||||
#include "../vlayout/vprintlayout.h"
|
||||
|
||||
class QGraphicsScene;
|
||||
struct PosterData;
|
||||
|
@ -98,13 +99,9 @@ protected:
|
|||
/** @brief doc dom document container */
|
||||
VPattern *doc;
|
||||
|
||||
QList<QGraphicsItem *> papers;
|
||||
QList<QGraphicsItem *> shadows;
|
||||
QList<QGraphicsScene *> scenes;
|
||||
QList<QList<QGraphicsItem *> > details;
|
||||
QList<QGraphicsItem *> gcontours;
|
||||
QList<QGraphicsItem *> gcontours{};
|
||||
|
||||
QVector<QVector<VLayoutPiece> > detailsOnLayout;
|
||||
QVector<QVector<VLayoutPiece> > detailsOnLayout{};
|
||||
|
||||
QAction *undoAction;
|
||||
QAction *redoAction;
|
||||
|
@ -112,12 +109,8 @@ protected:
|
|||
QAction *actionDockWidgetGroups;
|
||||
|
||||
bool isNoScaling;
|
||||
bool isLayoutStale;
|
||||
bool isNeedAutosave;
|
||||
bool ignorePrinterFields;
|
||||
bool isLayoutPortrait{true};
|
||||
QMarginsF margins;
|
||||
QSizeF paperSize;
|
||||
VPrintLayout *m_layoutSettings{new VPrintLayout(this)};
|
||||
|
||||
QSharedPointer<DialogSaveLayout> m_dialogSaveLayout;
|
||||
|
||||
|
@ -140,7 +133,6 @@ protected:
|
|||
virtual QStringList RecentFileList() const override;
|
||||
QIcon ScenePreview(int i, QSize iconSize, PreviewQuatilty quality) const;
|
||||
bool GenerateLayout(VLayoutGenerator& lGenerator);
|
||||
int ContinueIfLayoutStale();
|
||||
QString FileName() const;
|
||||
|
||||
bool ExportFMeasurementsToCSVData(const QString &fileName,
|
||||
|
@ -151,60 +143,15 @@ protected:
|
|||
void CheckRequiredMeasurements(const VMeasurements *m) const;
|
||||
|
||||
void RLDFile(const QString &name, QVector<VLayoutPiece> details, qreal xScale=1, qreal yScale=1) const;
|
||||
private slots:
|
||||
void PrintPages (QPrinter *printer);
|
||||
private:
|
||||
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<QGraphicsScene *> CreateScenes(const QList<QGraphicsItem *> &papers,
|
||||
const QList<QGraphicsItem *> &shadows,
|
||||
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 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 ¶ms)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,
|
||||
const QList<QGraphicsItem *> &papers,
|
||||
|
|
|
@ -93,7 +93,7 @@ WatermarkWindow::WatermarkWindow(const QString &patternPath, QWidget *parent) :
|
|||
{
|
||||
const QString filter = tr("Images") + QLatin1String(" (*.png *.jpg *.jpeg *.bmp)");
|
||||
const QString fileName = QFileDialog::getOpenFileName(this, tr("Watermark image"), QString(), filter,
|
||||
nullptr);
|
||||
nullptr, qApp->NativeFileDialog());
|
||||
if (not fileName.isEmpty())
|
||||
{
|
||||
ui->lineEditPath->setText(fileName);
|
||||
|
@ -284,7 +284,7 @@ bool WatermarkWindow::on_actionSaveAs_triggered()
|
|||
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"),
|
||||
dir + QLatin1String("/") + tr("watermark") + QLatin1String(".vwm"),
|
||||
filters, nullptr);
|
||||
filters, nullptr, qApp->NativeFileDialog());
|
||||
|
||||
if (fileName.isEmpty())
|
||||
{
|
||||
|
@ -426,7 +426,8 @@ void WatermarkWindow::on_actionOpen_triggered()
|
|||
const QString filter(tr("Watermark files") + QLatin1String(" (*.vwm)"));
|
||||
QString dir = QDir::homePath();
|
||||
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())
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -347,6 +347,41 @@ VContainer VPattern::GetCompleteData() const
|
|||
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.
|
||||
|
@ -1176,8 +1211,8 @@ void VPattern::PointsCommonAttributes(const QDomElement &domElement, VToolSingle
|
|||
void VPattern::PointsCommonAttributes(const QDomElement &domElement, quint32 &id, qreal &mx, qreal &my)
|
||||
{
|
||||
ToolsCommonAttributes(domElement, id);
|
||||
mx = qApp->toPixel(GetParametrDouble(domElement, AttrMx, QStringLiteral("10.0")));
|
||||
my = qApp->toPixel(GetParametrDouble(domElement, AttrMy, QStringLiteral("15.0")));
|
||||
mx = qApp->toPixel(GetParametrDouble(domElement, AttrMx, QString::number(labelMX)));
|
||||
my = qApp->toPixel(GetParametrDouble(domElement, AttrMy, QString::number(labelMY)));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -1185,8 +1220,8 @@ void VPattern::DrawPointsCommonAttributes(const QDomElement &domElement, quint32
|
|||
QString ¬es)
|
||||
{
|
||||
DrawToolsCommonAttributes(domElement, id, notes);
|
||||
mx = qApp->toPixel(GetParametrDouble(domElement, AttrMx, QStringLiteral("10.0")));
|
||||
my = qApp->toPixel(GetParametrDouble(domElement, AttrMy, QStringLiteral("15.0")));
|
||||
mx = qApp->toPixel(GetParametrDouble(domElement, AttrMx, QString::number(labelMX)));
|
||||
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.name1 = GetParametrString(domElement, AttrName1, QChar('A'));
|
||||
initData.mx1 = qApp->toPixel(GetParametrDouble(domElement, AttrMx1, QStringLiteral("10.0")));
|
||||
initData.my1 = qApp->toPixel(GetParametrDouble(domElement, AttrMy1, QStringLiteral("15.0")));
|
||||
initData.mx1 = qApp->toPixel(GetParametrDouble(domElement, AttrMx1, QString::number(labelMX)));
|
||||
initData.my1 = qApp->toPixel(GetParametrDouble(domElement, AttrMy1, QString::number(labelMY)));
|
||||
initData.showLabel1 = GetParametrBool(domElement, AttrShowLabel1, trueStr);
|
||||
|
||||
initData.name2 = GetParametrString(domElement, AttrName2, QChar('A'));
|
||||
initData.mx2 = qApp->toPixel(GetParametrDouble(domElement, AttrMx2, QStringLiteral("10.0")));
|
||||
initData.my2 = qApp->toPixel(GetParametrDouble(domElement, AttrMy2, QStringLiteral("15.0")));
|
||||
initData.mx2 = qApp->toPixel(GetParametrDouble(domElement, AttrMx2, QString::number(labelMX)));
|
||||
initData.my2 = qApp->toPixel(GetParametrDouble(domElement, AttrMy2, QString::number(labelMY)));
|
||||
initData.showLabel2 = GetParametrBool(domElement, AttrShowLabel2, trueStr);
|
||||
|
||||
VToolTrueDarts::Create(initData);
|
||||
|
@ -3616,6 +3651,12 @@ quint32 VPattern::LastToolId() const
|
|||
return NULL_ID;
|
||||
}
|
||||
|
||||
return PPLastToolId(name);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VPattern::PPLastToolId(const QString &name) const
|
||||
{
|
||||
const QVector<VToolRecord> localHistory = getLocalHistory(name);
|
||||
|
||||
return (not localHistory.isEmpty() ? localHistory.last().getId() : NULL_ID);
|
||||
|
|
|
@ -58,7 +58,9 @@ public:
|
|||
|
||||
void setCurrentData();
|
||||
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 DecrementReferens(quint32 id) const override;
|
||||
|
@ -256,6 +258,7 @@ private:
|
|||
|
||||
QString LastDrawName() const;
|
||||
quint32 LastToolId() const;
|
||||
quint32 PPLastToolId(const QString &name) const;
|
||||
};
|
||||
|
||||
#endif // VPATTERN_H
|
||||
|
|
|
@ -2442,6 +2442,19 @@ QString VAbstractPattern::PieceDrawName(quint32 id)
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -230,6 +230,9 @@ public:
|
|||
|
||||
QString PieceDrawName(quint32 id);
|
||||
|
||||
virtual VContainer GetCompleteData() const;
|
||||
virtual VContainer GetCompletePPData(const QString &name) const;
|
||||
|
||||
static const QString TagPattern;
|
||||
static const QString TagCalculation;
|
||||
static const QString TagModeling;
|
||||
|
|
|
@ -79,12 +79,10 @@ T *GetPatternTool(quint32 id)
|
|||
} // namespace
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPatternRecipe::VPatternRecipe(VContainer *data, VAbstractPattern *pattern, QObject *parent)
|
||||
VPatternRecipe::VPatternRecipe(VAbstractPattern *pattern, QObject *parent)
|
||||
: VDomDocument(parent),
|
||||
m_data(data),
|
||||
m_pattern(pattern)
|
||||
{
|
||||
SCASSERT(data != nullptr)
|
||||
SCASSERT(pattern != nullptr)
|
||||
|
||||
QDomElement recipeElement = createElement(QStringLiteral("recipe"));
|
||||
|
@ -135,7 +133,8 @@ QDomElement VPatternRecipe::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
|
||||
std::sort(patternMeasurements.begin(), patternMeasurements.end(),
|
||||
|
@ -174,7 +173,8 @@ QDomElement VPatternRecipe::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
|
||||
std::sort(patternIncrements.begin(), patternIncrements.end(),
|
||||
|
@ -197,7 +197,8 @@ QDomElement VPatternRecipe::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
|
||||
std::sort(patternIncrements.begin(), patternIncrements.end(),
|
||||
|
@ -266,12 +267,14 @@ QDomElement VPatternRecipe::Draft(const QDomElement &draft)
|
|||
const QString draftName = draft.attribute(QStringLiteral("name"));
|
||||
SetAttribute(recipeDraft, QStringLiteral("name"), draftName);
|
||||
|
||||
VContainer data = m_pattern->GetCompletePPData(draftName);
|
||||
|
||||
QVector<VToolRecord> *history = m_pattern->getHistory();
|
||||
for (auto &record : *history)
|
||||
{
|
||||
if (record.getNameDraw() == draftName)
|
||||
{
|
||||
QDomElement step = Step(record);
|
||||
QDomElement step = Step(record, data);
|
||||
if (not step.isNull())
|
||||
{
|
||||
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
|
||||
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:
|
||||
return EllipticalArc(tool);
|
||||
case Tool::Rotation:
|
||||
return Rotation(tool);
|
||||
return Rotation(tool, data);
|
||||
case Tool::FlippingByLine:
|
||||
return FlippingByLine(tool);
|
||||
return FlippingByLine(tool, data);
|
||||
case Tool::FlippingByAxis:
|
||||
return FlippingByAxis(tool);
|
||||
return FlippingByAxis(tool, data);
|
||||
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
|
||||
//piece, we need add record about details and nodes, but don't show them.
|
||||
case Tool::Piece:
|
||||
|
@ -411,17 +414,18 @@ QDomElement VPatternRecipe::FinalMeasurements()
|
|||
QDomElement recipeFinalMeasurements = createElement(QStringLiteral("finalMeasurements"));
|
||||
|
||||
const QVector<VFinalMeasurement> measurements = m_pattern->GetFinalMeasurements();
|
||||
VContainer data = m_pattern->GetCompleteData();
|
||||
|
||||
for (auto &m : measurements)
|
||||
{
|
||||
recipeFinalMeasurements.appendChild(FinalMeasurement(m));
|
||||
recipeFinalMeasurements.appendChild(FinalMeasurement(m, data));
|
||||
}
|
||||
|
||||
return recipeFinalMeasurements;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QDomElement VPatternRecipe::FinalMeasurement(const VFinalMeasurement &fm)
|
||||
QDomElement VPatternRecipe::FinalMeasurement(const VFinalMeasurement &fm, const VContainer &data)
|
||||
{
|
||||
QDomElement recipeFinalMeasurement = createElement(QStringLiteral("finalMeasurement"));
|
||||
|
||||
|
@ -430,7 +434,7 @@ QDomElement VPatternRecipe::FinalMeasurement(const VFinalMeasurement &fm)
|
|||
SetAttribute(recipeFinalMeasurement, QStringLiteral("formula"), fm.formula); // TODO: localize
|
||||
|
||||
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))
|
||||
{
|
||||
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());
|
||||
|
||||
|
@ -1013,13 +1017,13 @@ QDomElement VPatternRecipe::Rotation(const VToolRecord &record)
|
|||
Formula(step, tool->GetFormulaAngle(), AttrAngle, AttrAngleValue);
|
||||
SetAttribute(step, AttrSuffix, tool->Suffix());
|
||||
|
||||
step.appendChild(GroupOperationSource(tool, record.getId()));
|
||||
step.appendChild(GroupOperationSource(tool, record.getId(), data));
|
||||
|
||||
return step;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QDomElement VPatternRecipe::FlippingByLine(const VToolRecord &record)
|
||||
QDomElement VPatternRecipe::FlippingByLine(const VToolRecord &record, const VContainer &data)
|
||||
{
|
||||
auto *tool = GetPatternTool<VToolFlippingByLine>(record.getId());
|
||||
|
||||
|
@ -1030,13 +1034,13 @@ QDomElement VPatternRecipe::FlippingByLine(const VToolRecord &record)
|
|||
SetAttribute(step, AttrP2Line, tool->SecondLinePointName());
|
||||
SetAttribute(step, AttrSuffix, tool->Suffix());
|
||||
|
||||
step.appendChild(GroupOperationSource(tool, record.getId()));
|
||||
step.appendChild(GroupOperationSource(tool, record.getId(), data));
|
||||
|
||||
return step;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QDomElement VPatternRecipe::FlippingByAxis(const VToolRecord &record)
|
||||
QDomElement VPatternRecipe::FlippingByAxis(const VToolRecord &record, const VContainer &data)
|
||||
{
|
||||
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, AttrSuffix, tool->Suffix());
|
||||
|
||||
step.appendChild(GroupOperationSource(tool, record.getId()));
|
||||
step.appendChild(GroupOperationSource(tool, record.getId(), data));
|
||||
|
||||
return step;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QDomElement VPatternRecipe::Move(const VToolRecord &record)
|
||||
QDomElement VPatternRecipe::Move(const VToolRecord &record, const VContainer &data)
|
||||
{
|
||||
auto *tool = GetPatternTool<VToolMove>(record.getId());
|
||||
|
||||
|
@ -1066,7 +1070,7 @@ QDomElement VPatternRecipe::Move(const VToolRecord &record)
|
|||
SetAttribute(step, AttrCenter, tool->OriginPointName());
|
||||
SetAttribute(step, AttrSuffix, tool->Suffix());
|
||||
|
||||
step.appendChild(GroupOperationSource(tool, record.getId()));
|
||||
step.appendChild(GroupOperationSource(tool, record.getId(), data));
|
||||
|
||||
return step;
|
||||
}
|
||||
|
@ -1103,7 +1107,7 @@ void VPatternRecipe::CurveAttributes(QDomElement &step, T *tool)
|
|||
SetAttribute(step, AttrPenStyle, tool->GetPenStyle());
|
||||
SetAttribute(step, AttrAScale, tool->GetApproximationScale());
|
||||
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>
|
||||
void VPatternRecipe::CutCurveAttributes(QDomElement &step, T *tool)
|
||||
{
|
||||
SetAttribute(step, AttrAlias1, tool->GetAliasSuffix1());
|
||||
SetAttribute(step, AttrAlias2, tool->GetAliasSuffix2());
|
||||
SetAttributeOrRemoveIf(step, AttrAlias1, tool->GetAliasSuffix1(), tool->GetAliasSuffix1().isEmpty());
|
||||
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)
|
||||
|
||||
|
@ -1145,7 +1149,7 @@ QDomElement VPatternRecipe::GroupOperationSource(VAbstractOperation *tool, quint
|
|||
|
||||
try
|
||||
{
|
||||
obj = m_data->GetGObject(item.id);
|
||||
obj = data.GetGObject(item.id);
|
||||
}
|
||||
catch (const VExceptionBadId &e)
|
||||
{
|
||||
|
@ -1153,11 +1157,8 @@ QDomElement VPatternRecipe::GroupOperationSource(VAbstractOperation *tool, quint
|
|||
continue;
|
||||
}
|
||||
|
||||
SetAttribute(node, AttrItem, obj->name());
|
||||
if (not obj->GetAlias().isEmpty())
|
||||
{
|
||||
SetAttribute(node, AttrAlias, obj->GetAlias());
|
||||
}
|
||||
SetAttribute(node, AttrItem, obj->ObjectName());
|
||||
SetAttributeOrRemoveIf(node, AttrAlias, item.alias, item.alias.isEmpty());
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,13 +43,12 @@ class VPatternRecipe : public VDomDocument
|
|||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(VPatternRecipe)
|
||||
public:
|
||||
VPatternRecipe(VContainer *data, VAbstractPattern *pattern, QObject *parent = nullptr);
|
||||
explicit VPatternRecipe(VAbstractPattern *pattern, QObject *parent = nullptr);
|
||||
virtual ~VPatternRecipe() Q_DECL_EQ_DEFAULT;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VPatternRecipe)
|
||||
|
||||
VContainer *m_data;
|
||||
VAbstractPattern *m_pattern;
|
||||
|
||||
QDomElement Prerequisite();
|
||||
|
@ -64,10 +63,10 @@ private:
|
|||
QDomElement Content();
|
||||
|
||||
QDomElement Draft(const QDomElement &draft);
|
||||
QDomElement Step(const VToolRecord &tool);
|
||||
QDomElement Step(const VToolRecord &tool, const VContainer &data);
|
||||
|
||||
QDomElement FinalMeasurements();
|
||||
QDomElement FinalMeasurement(const VFinalMeasurement &fm);
|
||||
QDomElement FinalMeasurement(const VFinalMeasurement &fm, const VContainer &data);
|
||||
|
||||
QDomElement BasePoint(const VToolRecord &record);
|
||||
QDomElement EndLine(const VToolRecord &record);
|
||||
|
@ -99,10 +98,10 @@ private:
|
|||
QDomElement PointFromArcAndTangent(const VToolRecord &record);
|
||||
QDomElement TrueDarts(const VToolRecord &record);
|
||||
QDomElement EllipticalArc(const VToolRecord &record);
|
||||
QDomElement Rotation(const VToolRecord &record);
|
||||
QDomElement FlippingByLine(const VToolRecord &record);
|
||||
QDomElement FlippingByAxis(const VToolRecord &record);
|
||||
QDomElement Move(const VToolRecord &record);
|
||||
QDomElement Rotation(const VToolRecord &record, const VContainer &data);
|
||||
QDomElement FlippingByLine(const VToolRecord &record, const VContainer &data);
|
||||
QDomElement FlippingByAxis(const VToolRecord &record, const VContainer &data);
|
||||
QDomElement Move(const VToolRecord &record, const VContainer &data);
|
||||
|
||||
void Formula(QDomElement &step, const VFormula &formula, const QString &formulaStr, const QString &formulaValue);
|
||||
|
||||
|
@ -118,7 +117,7 @@ private:
|
|||
template <typename T>
|
||||
void CutCurveAttributes(QDomElement &step, T* tool);
|
||||
|
||||
QDomElement GroupOperationSource(VAbstractOperation *tool, quint32 id);
|
||||
QDomElement GroupOperationSource(VAbstractOperation *tool, quint32 id, const VContainer &data);
|
||||
};
|
||||
|
||||
#endif // VPATTERNRECIPE_H
|
||||
|
|
|
@ -28,10 +28,11 @@
|
|||
|
||||
#include "dialoglayoutscale.h"
|
||||
#include "ui_dialoglayoutscale.h"
|
||||
#include "../core/vapplication.h"
|
||||
#include "../core/vvalentinasettings.h"
|
||||
#include "../vmisc/vabstractvalapplication.h"
|
||||
#include "../vmisc/vcommonsettings.h"
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QShowEvent>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DialogLayoutScale::DialogLayoutScale(bool printTiled, QWidget *parent)
|
||||
|
@ -40,7 +41,7 @@ DialogLayoutScale::DialogLayoutScale(bool printTiled, QWidget *parent)
|
|||
{
|
||||
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);
|
||||
SCASSERT(bOk != nullptr)
|
||||
|
@ -180,7 +181,7 @@ void DialogLayoutScale::VerticalScaleChanged(double d)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogLayoutScale::ReadSettings()
|
||||
{
|
||||
VValentinaSettings *settings = qApp->ValentinaSettings();
|
||||
VCommonSettings *settings = qApp->Settings();
|
||||
const Unit unit = qApp->patternUnits();
|
||||
|
||||
// read Margins top, right, bottom, left
|
||||
|
@ -200,7 +201,7 @@ void DialogLayoutScale::ReadSettings()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogLayoutScale::WriteSettings() const
|
||||
{
|
||||
VValentinaSettings *settings = qApp->ValentinaSettings();
|
||||
VCommonSettings *settings = qApp->Settings();
|
||||
const Unit unit = qApp->patternUnits();
|
||||
|
||||
// write Margins top, right, bottom, left
|
13
src/libs/vlayout/dialogs/dialogs.pri
Normal file
13
src/libs/vlayout/dialogs/dialogs.pri
Normal 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
|
|
@ -27,7 +27,7 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "vabstractlayoutdialog.h"
|
||||
#include "../core/vapplication.h"
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "../vmisc/vmath.h"
|
||||
|
||||
//must be the same order as PaperSizeTemplate constants
|
||||
|
@ -61,8 +61,8 @@ VAbstractLayoutDialog::VAbstractLayoutDialog(QWidget *parent)
|
|||
void VAbstractLayoutDialog::InitTemplates(QComboBox *comboBoxTemplates)
|
||||
{
|
||||
SCASSERT(comboBoxTemplates != nullptr)
|
||||
const QIcon icoPaper("://icon/16x16/template.png");
|
||||
const QIcon icoRoll("://icon/16x16/roll.png");
|
||||
const QIcon icoPaper(QLatin1String("://icon/16x16/template.png"));
|
||||
const QIcon icoRoll(QLatin1String("://icon/16x16/roll.png"));
|
||||
const QString pdi = QStringLiteral("(%1ppi)").arg(PrintDPI);
|
||||
|
||||
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 height = 0;
|
||||
|
@ -159,11 +159,11 @@ QSizeF VAbstractLayoutDialog::GetTemplateSize(PaperSizeTemplate tmpl, Unit unit)
|
|||
default:
|
||||
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 h = 0;
|
||||
|
@ -175,14 +175,14 @@ QSizeF VAbstractLayoutDialog::RoundTemplateSize(qreal width, qreal height, Unit
|
|||
case Unit::Px:
|
||||
w = vRound(width, 2);
|
||||
h = vRound(height, 2);
|
||||
return QSizeF(w, h);
|
||||
return {w, h};
|
||||
case Unit::Inch:
|
||||
w = vRound(width, 5);
|
||||
h = vRound(height, 5);
|
||||
return QSizeF(w, h);
|
||||
return {w, h};
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return QSizeF(width, height);
|
||||
return {width, height};
|
||||
}
|
|
@ -59,16 +59,16 @@ public:
|
|||
|
||||
explicit VAbstractLayoutDialog(QWidget *parent = nullptr);
|
||||
|
||||
static QSizeF GetTemplateSize(PaperSizeTemplate tmpl, Unit unit);
|
||||
static auto GetTemplateSize(PaperSizeTemplate tmpl, Unit unit) -> QSizeF;
|
||||
|
||||
protected:
|
||||
typedef QStringList FormatsVector;
|
||||
const static FormatsVector pageFormatNames;
|
||||
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:
|
||||
Q_DISABLE_COPY(VAbstractLayoutDialog)
|
||||
};
|
|
@ -38,6 +38,7 @@
|
|||
|
||||
#include "../vmisc/typedef.h"
|
||||
#include "vlayoutpiece.h"
|
||||
#include "vlayoutdef.h"
|
||||
|
||||
// An annoying char define, from the Windows team in <rpcndr.h>
|
||||
// #define small char
|
||||
|
@ -49,8 +50,6 @@
|
|||
|
||||
Q_DECLARE_LOGGING_CATEGORY(lBank)
|
||||
|
||||
enum class Cases : qint8 { CaseThreeGroup = 0, CaseTwoGroup, CaseDesc, UnknownCase};
|
||||
|
||||
class VBank
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(VBank)
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
# ADD TO EACH PATH $$PWD VARIABLE!!!!!!
|
||||
# This need for corect working file translations.pro
|
||||
|
||||
# Suport subdirectories. Just better project code tree.
|
||||
include(dialogs/dialogs.pri)
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/stable.h \
|
||||
$$PWD/testpath.h \
|
||||
$$PWD/vlayoutexporter.h \
|
||||
$$PWD/vlayoutgenerator.h \
|
||||
$$PWD/vlayoutdef.h \
|
||||
$$PWD/vlayoutpaper.h \
|
||||
|
@ -14,6 +18,7 @@ HEADERS += \
|
|||
$$PWD/vbestsquare.h \
|
||||
$$PWD/vposition.h \
|
||||
$$PWD/vrawlayout.h \
|
||||
$$PWD/vprintlayout.h \
|
||||
$$PWD/vsapoint.h \
|
||||
$$PWD/vtextmanager.h \
|
||||
$$PWD/vposter.h \
|
||||
|
@ -29,6 +34,7 @@ HEADERS += \
|
|||
|
||||
SOURCES += \
|
||||
$$PWD/testpath.cpp \
|
||||
$$PWD/vlayoutexporter.cpp \
|
||||
$$PWD/vlayoutgenerator.cpp \
|
||||
$$PWD/vlayoutpaper.cpp \
|
||||
$$PWD/vbank.cpp \
|
||||
|
@ -36,6 +42,7 @@ SOURCES += \
|
|||
$$PWD/vbestsquare.cpp \
|
||||
$$PWD/vposition.cpp \
|
||||
$$PWD/vrawlayout.cpp \
|
||||
$$PWD/vprintlayout.cpp \
|
||||
$$PWD/vtextmanager.cpp \
|
||||
$$PWD/vposter.cpp \
|
||||
$$PWD/vgraphicsfillitem.cpp \
|
||||
|
|
|
@ -116,6 +116,8 @@ struct VCachedPositions
|
|||
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
|
||||
* Address Sanitizer. See page https://bitbucket.org/dismine/valentina/wiki/developers/Address_Sanitizer
|
||||
*/
|
||||
|
|
368
src/libs/vlayout/vlayoutexporter.cpp
Normal file
368
src/libs/vlayout/vlayoutexporter.cpp
Normal 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 ¶ms)
|
||||
{
|
||||
#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()));
|
||||
}
|
||||
}
|
240
src/libs/vlayout/vlayoutexporter.h
Normal file
240
src/libs/vlayout/vlayoutexporter.h
Normal 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 ¶ms);
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
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
|
|
@ -263,6 +263,11 @@ void VLayoutGenerator::Generate(const QElapsedTimer &timer, qint64 timeout, Layo
|
|||
GatherPages();
|
||||
}
|
||||
|
||||
if (autoCropWidth)
|
||||
{
|
||||
OptimizeWidth();
|
||||
}
|
||||
|
||||
if (IsUnitePages())
|
||||
{
|
||||
UnitePages();
|
||||
|
@ -506,6 +511,27 @@ void VLayoutGenerator::GatherPages()
|
|||
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()
|
||||
{
|
||||
|
@ -785,6 +811,7 @@ void VLayoutGenerator::SetAutoCropLength(bool value)
|
|||
autoCropLength = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VLayoutGenerator::GetAutoCropWidth() const
|
||||
{
|
||||
return autoCropWidth;
|
||||
|
|
|
@ -169,6 +169,7 @@ private:
|
|||
int PageHeight() const;
|
||||
int PageWidth() const;
|
||||
|
||||
void OptimizeWidth();
|
||||
void GatherPages();
|
||||
void UnitePages();
|
||||
void UniteDetails(int j, QList<QList<VLayoutPiece> > &nDetails, qreal length, int i) const;
|
||||
|
|
|
@ -435,6 +435,12 @@ QVector<VLayoutPiece> VLayoutPaper::GetDetails() const
|
|||
return d->details;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VLayoutPaper::SetDetails(const QVector<VLayoutPiece> &details)
|
||||
{
|
||||
d->details = details;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VLayoutPaper::SetDetails(const QList<VLayoutPiece> &details)
|
||||
{
|
||||
|
|
|
@ -99,6 +99,7 @@ public:
|
|||
Q_REQUIRED_RESULT QList<QGraphicsItem *> GetItemDetails(bool textAsPaths) const;
|
||||
|
||||
QVector<VLayoutPiece> GetDetails() const;
|
||||
void SetDetails(const QVector<VLayoutPiece>& details);
|
||||
void SetDetails(const QList<VLayoutPiece>& details);
|
||||
|
||||
QRectF DetailsBoundingRect() const;
|
||||
|
|
762
src/libs/vlayout/vprintlayout.cpp
Normal file
762
src/libs/vlayout/vprintlayout.cpp
Normal 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();
|
||||
}
|
427
src/libs/vlayout/vprintlayout.h
Normal file
427
src/libs/vlayout/vprintlayout.h
Normal 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
|
|
@ -284,6 +284,21 @@ void InitPiecePlaceholders(QMap<QString, QString> &placeholders, const QString &
|
|||
QString ReplacePlaceholders(const QMap<QString, QString> &placeholders, QString line)
|
||||
{
|
||||
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();
|
||||
while (i != placeholders.constEnd())
|
||||
{
|
||||
|
|
|
@ -277,28 +277,6 @@ QString AbsoluteMPath(const QString &patternPath, const QString &relativeMPath)
|
|||
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)
|
||||
{
|
||||
|
@ -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())
|
||||
{
|
||||
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
|
||||
const QMarginsF m = printer->pageLayout().margins(QPageLayout::Millimeter);
|
||||
|
||||
QMarginsF def;
|
||||
def.setLeft(UnitConvertor(left, Unit::Mm, Unit::Px));
|
||||
def.setRight(UnitConvertor(right, Unit::Mm, Unit::Px));
|
||||
def.setTop(UnitConvertor(top, Unit::Mm, Unit::Px));
|
||||
def.setBottom(UnitConvertor(bottom, Unit::Mm, Unit::Px));
|
||||
def.setLeft(UnitConvertor(m.left(), Unit::Mm, Unit::Px));
|
||||
def.setRight(UnitConvertor(m.right(), Unit::Mm, Unit::Px));
|
||||
def.setTop(UnitConvertor(m.top(), Unit::Mm, Unit::Px));
|
||||
def.setBottom(UnitConvertor(m.bottom(), Unit::Mm, Unit::Px));
|
||||
return def;
|
||||
}
|
||||
|
||||
|
|
|
@ -602,9 +602,6 @@ Q_REQUIRED_RESULT QString AbsoluteMPath(const QString &patternPath, const QStrin
|
|||
|
||||
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 GetPrinterFields(const QSharedPointer<QPrinter> &printer);
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
extern const int MAJOR_VERSION = 0;
|
||||
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)
|
||||
.arg(DEBUG_VERSION).arg(LATEST_TAG_DISTANCE));
|
||||
|
|
|
@ -49,8 +49,8 @@ extern const QString APP_VERSION_STR;
|
|||
// Change version number in projectversion.cpp too.
|
||||
// Synchronize valentina.nsi
|
||||
|
||||
#define VER_FILEVERSION 0,7,40
|
||||
#define VER_FILEVERSION_STR "0.7.40\0"
|
||||
#define VER_FILEVERSION 0,7,41
|
||||
#define VER_FILEVERSION_STR "0.7.41\0"
|
||||
|
||||
#define V_PRERELEASE // Mark prerelease builds
|
||||
|
||||
|
|
|
@ -313,3 +313,14 @@ bool VAbstractApplication::IsWarningMessage(const QString &message) const
|
|||
{
|
||||
return VAbstractApplication::ClearMessage(message).startsWith(warningMessageSignature);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QFileDialog::Options VAbstractApplication::NativeFileDialog(QFileDialog::Options options) const
|
||||
{
|
||||
if (settings->IsDontUseNativeDialog())
|
||||
{
|
||||
options |= QFileDialog::DontUseNativeDialog;
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include <QString>
|
||||
#include <QtGlobal>
|
||||
#include <QTranslator>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "../vmisc/def.h"
|
||||
#include "../vpatterndb/vtranslatevars.h"
|
||||
|
@ -51,7 +52,7 @@ class VCommonSettings;
|
|||
#if defined(qApp)
|
||||
#undef qApp
|
||||
#endif
|
||||
#define qApp (static_cast<VAbstractApplication*>(QCoreApplication::instance()))
|
||||
#define qApp (qobject_cast<VAbstractApplication*>(QCoreApplication::instance()))
|
||||
|
||||
class VAbstractApplication : public QApplication
|
||||
{
|
||||
|
@ -82,6 +83,8 @@ public:
|
|||
static const QString warningMessageSignature;
|
||||
bool IsWarningMessage(const QString &message) const;
|
||||
|
||||
QFileDialog::Options NativeFileDialog(QFileDialog::Options options = QFileDialog::Options()) const;
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
static void WinAttachConsole();
|
||||
#endif
|
||||
|
|
|
@ -40,7 +40,7 @@ class QGraphicsScene;
|
|||
#if defined(qApp)
|
||||
#undef qApp
|
||||
#endif
|
||||
#define qApp (static_cast<VAbstractValApplication*>(QCoreApplication::instance()))
|
||||
#define qApp (qobject_cast<VAbstractValApplication*>(QCoreApplication::instance()))
|
||||
|
||||
class VAbstractValApplication : public VAbstractApplication
|
||||
{
|
||||
|
|
|
@ -67,6 +67,8 @@ const qreal VCommonSettings::defaultScrollingAcceleration = 1.3;
|
|||
const qreal VCommonSettings::scrollingAccelerationMin = 1.0;
|
||||
const qreal VCommonSettings::scrollingAccelerationMax = 10.0;
|
||||
|
||||
Q_DECLARE_METATYPE(QMarginsF)
|
||||
|
||||
namespace
|
||||
{
|
||||
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, settingConfigurationFreeCurveMode, (QLatin1String("configuration/freeCurveMode")))
|
||||
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, 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, 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
|
||||
qreal curveApproximationCached = -1;
|
||||
Q_GLOBAL_STATIC(QString, localeCached)
|
||||
|
@ -1223,6 +1229,21 @@ void VCommonSettings::SetPieceShowMainPath(bool value)
|
|||
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
|
||||
{
|
||||
|
@ -1368,3 +1389,44 @@ void VCommonSettings::SetGraphicalOutput(const bool &value)
|
|||
settings.setValue(*settingPatternGraphicalOutput, value);
|
||||
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));
|
||||
}
|
||||
|
|
|
@ -38,7 +38,10 @@
|
|||
#include <QStringList>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "../vlayout/vbank.h"
|
||||
#include "../vmisc/def.h"
|
||||
#include "../vlayout/vlayoutdef.h"
|
||||
|
||||
class QMarginsF;
|
||||
|
||||
class VCommonSettings : public QSettings
|
||||
{
|
||||
|
@ -220,6 +223,9 @@ public:
|
|||
bool IsPieceShowMainPath() const;
|
||||
void SetPieceShowMainPath(bool value);
|
||||
|
||||
bool IsDontUseNativeDialog() const;
|
||||
void SetDontUseNativeDialog(bool value);
|
||||
|
||||
static qreal DefaultLineWidth();
|
||||
static qreal MinimalLineWidth();
|
||||
static qreal MaximalLineWidth();
|
||||
|
@ -228,6 +234,13 @@ public:
|
|||
qreal WidthMainLine() 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 scrollingDurationMin;
|
||||
static const int scrollingDurationMax;
|
||||
|
|
|
@ -300,11 +300,7 @@ void DialogEditLabel::ExportTemplate()
|
|||
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Export label template"),
|
||||
path + QLatin1String("/") + tr("template") + QLatin1String(".xml"),
|
||||
filters, nullptr
|
||||
#ifdef Q_OS_LINUX
|
||||
, QFileDialog::DontUseNativeDialog
|
||||
#endif
|
||||
);
|
||||
filters, nullptr, qApp->NativeFileDialog());
|
||||
|
||||
if (fileName.isEmpty())
|
||||
{
|
||||
|
@ -353,11 +349,8 @@ void DialogEditLabel::ImportTemplate()
|
|||
QString filter(tr("Label template") + QLatin1String(" (*.xml)"));
|
||||
//Use standard path to label templates
|
||||
const QString path = VCommonSettings::PrepareLabelTemplates(qApp->Settings()->GetPathLabelTemplate());
|
||||
const QString fileName = QFileDialog::getOpenFileName(this, tr("Import template"), path, filter, nullptr
|
||||
#ifdef Q_OS_LINUX
|
||||
, QFileDialog::DontUseNativeDialog
|
||||
#endif
|
||||
);
|
||||
const QString fileName = QFileDialog::getOpenFileName(this, tr("Import template"), path, filter, nullptr,
|
||||
qApp->NativeFileDialog());
|
||||
if (fileName.isEmpty())
|
||||
{
|
||||
return;
|
||||
|
@ -586,10 +579,26 @@ void DialogEditLabel::InitPlaceholders()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
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();
|
||||
while (i != m_placeholders.constEnd())
|
||||
{
|
||||
line.replace(QChar('%')+i.key()+QChar('%'), i.value().second);
|
||||
line.replace(per+i.key()+per, i.value().second);
|
||||
++i;
|
||||
}
|
||||
return line;
|
||||
|
|
|
@ -116,7 +116,7 @@ private:
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline bool DialogCutSplinePath::IsValid() const
|
||||
{
|
||||
return flagFormula && flagAlias1 && flagAlias2;
|
||||
return flagFormula && flagAlias1 && flagAlias2 && flagName;
|
||||
}
|
||||
|
||||
#endif // DIALOGCUTSPLINEPATH_H
|
||||
|
|
|
@ -410,7 +410,7 @@ void DialogPointOfIntersectionCircles::SaveData()
|
|||
|
||||
point->setObject1Id(GetFirstCircleCenterId());
|
||||
point->setObject2Id(GetSecondCircleCenterId());
|
||||
point->setC1Radius(ui->plainTextEditCircle2Radius->toPlainText());
|
||||
point->setC1Radius(ui->plainTextEditCircle1Radius->toPlainText());
|
||||
point->setC2Radius(ui->plainTextEditCircle2Radius->toPlainText());
|
||||
point->setCrossPoint(GetCrossCirclesPoint());
|
||||
point->RefreshGeometry();
|
||||
|
|
|
@ -152,7 +152,7 @@ protected:
|
|||
virtual void ReadToolAttributes(const QDomElement &domElement) 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);
|
||||
|
||||
template <typename T>
|
||||
|
|
|
@ -56,8 +56,8 @@ struct VToolTrueDartsInitData : VDrawToolInitData
|
|||
dartP2Id(NULL_ID),
|
||||
dartP3Id(NULL_ID),
|
||||
name1(),
|
||||
mx1(10),
|
||||
my1(15),
|
||||
mx1(labelMX),
|
||||
my1(labelMY),
|
||||
showLabel1(true),
|
||||
name2(),
|
||||
mx2(10),
|
||||
|
|
|
@ -50,8 +50,8 @@ struct VToolBasePointInitData : VToolSinglePointInitData
|
|||
VToolBasePointInitData()
|
||||
: VToolSinglePointInitData(),
|
||||
nameActivPP(),
|
||||
x(10),
|
||||
y(10)
|
||||
x(labelMX),
|
||||
y(labelMY)
|
||||
{}
|
||||
|
||||
QString nameActivPP;
|
||||
|
|
|
@ -49,8 +49,8 @@ struct VToolSinglePointInitData : VDrawToolInitData
|
|||
VToolSinglePointInitData()
|
||||
: VDrawToolInitData(),
|
||||
name(),
|
||||
mx(5),
|
||||
my(10),
|
||||
mx(labelMX),
|
||||
my(labelMY),
|
||||
showLabel(true)
|
||||
{}
|
||||
|
||||
|
|
|
@ -68,8 +68,6 @@ public slots:
|
|||
protected:
|
||||
void SetPointName(quint32 id, const QString &name);
|
||||
|
||||
virtual void UpdateNamePosition(quint32 id, const QPointF &pos)=0;
|
||||
|
||||
template <typename T>
|
||||
static void InitToolConnections(VMainGraphicsScene *scene, T *tool);
|
||||
|
||||
|
|
|
@ -185,6 +185,13 @@ QString VDrawTool::MakeToolTip() const
|
|||
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
|
||||
{
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "../vdatatool.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
#include "../vtools/undocommands/undogroup.h"
|
||||
#include "../toolsdef.h"
|
||||
|
||||
struct VDrawToolInitData : VAbstractToolInitData
|
||||
{
|
||||
|
@ -120,6 +121,7 @@ protected:
|
|||
void SaveOption(QSharedPointer<VGObject> &obj);
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||
virtual QString MakeToolTip() const;
|
||||
virtual void UpdateNamePosition(quint32 id, const QPointF &pos);
|
||||
|
||||
bool CorrectDisable(bool disable, const QString &namePP) const;
|
||||
|
||||
|
@ -241,6 +243,9 @@ void VDrawTool::ContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 itemI
|
|||
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"));
|
||||
if (showRemove == RemoveOption::Enable)
|
||||
{
|
||||
|
@ -299,6 +304,10 @@ void VDrawTool::ContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 itemI
|
|||
{
|
||||
ChangeLabelVisibility(itemId, selectedAction->isChecked());
|
||||
}
|
||||
else if (selectedAction == actionRestoreLabelPosition)
|
||||
{
|
||||
UpdateNamePosition(itemId, QPointF(labelMX, labelMY));
|
||||
}
|
||||
else if (selectedAction->actionGroup() == actionsAddToGroup)
|
||||
{
|
||||
quint32 groupId = selectedAction->data().toUInt();
|
||||
|
|
|
@ -47,6 +47,10 @@ struct SourceItem
|
|||
Q_DECLARE_METATYPE(SourceItem)
|
||||
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);
|
||||
|
||||
QString OriginAlias(quint32 id, const QVector<SourceItem> &source, const QSharedPointer<VGObject> &obj);
|
||||
|
|
|
@ -180,11 +180,8 @@ QString VAbstractMainWindow::CSVFilePath()
|
|||
const QString suffix("csv");
|
||||
const QString path = QDir::homePath() + QChar('/') + tr("values") + QChar('.') + suffix;
|
||||
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Export to CSV"), path, filters, nullptr
|
||||
#ifdef Q_OS_LINUX
|
||||
, QFileDialog::DontUseNativeDialog
|
||||
#endif
|
||||
);
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Export to CSV"), path, filters, nullptr,
|
||||
qApp->NativeFileDialog());
|
||||
|
||||
if (fileName.isEmpty())
|
||||
{
|
||||
|
|
|
@ -45,15 +45,13 @@ TST_VPoster::TST_VPoster(QObject *parent) :
|
|||
void TST_VPoster::BigPoster()
|
||||
{
|
||||
QPrinter printer;
|
||||
printer.setResolution(96);// By default
|
||||
printer.setResolution(static_cast<int>(PrintDPI));// By default
|
||||
printer.setPageSize(QPageSize(QPageSize::A4));
|
||||
printer.setFullPage(true);
|
||||
// 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.
|
||||
const qreal left = 0, top = 0, right = 0, bottom = 0;
|
||||
printer.setPageMargins(QMarginsF(left, top, right, bottom), QPageLayout::Millimeter);
|
||||
|
||||
printer.setPageMargins(QMarginsF(), QPageLayout::Millimeter);
|
||||
|
||||
const QSize image(2622, 3178); // Little bit bigger than A1
|
||||
VPoster posterazor(&printer);
|
||||
|
|
Loading…
Reference in New Issue
Block a user