diff --git a/CMakeLists.txt b/CMakeLists.txt
index fa26a4806..18aecb39b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -550,6 +550,7 @@ add_subdirectory(resources/iconsets)
add_subdirectory(resources/keysets)
add_subdirectory(resources/loremipsum)
add_subdirectory(resources/manpages)
+add_subdirectory(resources/pagepresets)
add_subdirectory(resources/profiles)
add_subdirectory(resources/swatches)
add_subdirectory(resources/templates)
diff --git a/CMakeLists_Directories.cmake b/CMakeLists_Directories.cmake
index 264f01a97..1095159be 100644
--- a/CMakeLists_Directories.cmake
+++ b/CMakeLists_Directories.cmake
@@ -71,6 +71,21 @@ else()
add_definitions(-DICONDIR="${ICONDIR}")
endif()
+#PAGEPRESETDIR
+if(WIN32)
+ set(PAGEPRESETSDIR "${CMAKE_INSTALL_DATAROOTDIR}/pagepresets/")
+else()
+ set(PAGEPRESETSDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}${TAG_VERSION}/pagepresets/")
+endif()
+
+if(IS_ABSOLUTE ${PAGEPRESETSDIR} AND WANT_RELOCATABLE)
+ message(FATAL_ERROR "ERROR: PAGEPRESETSDIR must be relative when using WANT_RELOCATABLE option")
+elseif(NOT IS_ABSOLUTE ${PAGEPRESETSDIR} AND NOT WANT_RELOCATABLE)
+ add_definitions(-DPAGEPRESETSDIR="${CMAKE_INSTALL_PREFIX}/${PAGEPRESETSDIR}")
+else()
+ add_definitions(-DPAGEPRESETSDIR="${PAGEPRESETSDIR}")
+endif()
+
#SAMPLES
if(WIN32)
set(SAMPLESDIR "${CMAKE_INSTALL_DATAROOTDIR}/samples/")
diff --git a/resources/iconsets/1_7_0/1_7_0.xml b/resources/iconsets/1_7_0/1_7_0.xml
index 532520798..d17386b89 100644
--- a/resources/iconsets/1_7_0/1_7_0.xml
+++ b/resources/iconsets/1_7_0/1_7_0.xml
@@ -116,6 +116,7 @@ On Dark: #e580ff; rgb(229, 128, 255); hsl(288, 100, 75)
+
@@ -401,6 +402,7 @@ On Dark: #e580ff; rgb(229, 128, 255); hsl(288, 100, 75)
+
diff --git a/resources/pagepresets/Books.xml b/resources/pagepresets/Books.xml
new file mode 100644
index 000000000..f3b7447fa
--- /dev/null
+++ b/resources/pagepresets/Books.xml
@@ -0,0 +1,37 @@
+
+
+
+ Scribus
+ CC0
+
+ Books
+ Bücher
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Comic Book
+ Comic-Buch
+
+
+
+
+
+
diff --git a/resources/pagepresets/Business_Cards.xml b/resources/pagepresets/Business_Cards.xml
new file mode 100644
index 000000000..7b79052bd
--- /dev/null
+++ b/resources/pagepresets/Business_Cards.xml
@@ -0,0 +1,42 @@
+
+
+
+ Scribus
+ CC0
+
+ Business Cards
+ Visitenkarten
+
+
+
+
+
+
+ Europe
+ Europa
+
+
+
+
+ Hungary
+ Ungarn
+
+
+
+
+
+
+
+
+ India, Scandinavia
+ Indien, Skandinavien
+
+
+
+
+ US/Canada
+ US/Kanada
+
+
+
+
diff --git a/resources/pagepresets/CMakeLists.txt b/resources/pagepresets/CMakeLists.txt
new file mode 100644
index 000000000..e67bb6d7e
--- /dev/null
+++ b/resources/pagepresets/CMakeLists.txt
@@ -0,0 +1,7 @@
+include_directories(
+"${CMAKE_SOURCE_DIR}/scribus"
+)
+
+#Install our page preset files, selected from *.xml in this directory
+file( GLOB SCRIBUS_PAGEPRESET_FILES *.xml )
+install(FILES ${SCRIBUS_PAGEPRESET_FILES} DESTINATION ${PAGEPRESETSDIR})
diff --git a/resources/pagepresets/Canadian.xml b/resources/pagepresets/Canadian.xml
new file mode 100644
index 000000000..7fef64b8c
--- /dev/null
+++ b/resources/pagepresets/Canadian.xml
@@ -0,0 +1,19 @@
+
+
+
+ Scribus
+ CC0
+
+ Canadian
+ Kanadisch
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/pagepresets/Chinese.xml b/resources/pagepresets/Chinese.xml
new file mode 100644
index 000000000..061a5769a
--- /dev/null
+++ b/resources/pagepresets/Chinese.xml
@@ -0,0 +1,27 @@
+
+
+
+ Scribus
+ CC0
+
+ Chinese
+ Chinesisch
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/pagepresets/Colombian.xml b/resources/pagepresets/Colombian.xml
new file mode 100644
index 000000000..3666fa436
--- /dev/null
+++ b/resources/pagepresets/Colombian.xml
@@ -0,0 +1,20 @@
+
+
+
+ Scribus
+ CC0
+
+ Colombian
+ Kolumbianisch
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/pagepresets/French.xml b/resources/pagepresets/French.xml
new file mode 100644
index 000000000..12224ce1f
--- /dev/null
+++ b/resources/pagepresets/French.xml
@@ -0,0 +1,34 @@
+
+
+
+ Scribus
+ CC0
+
+ French
+ Französisch
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/pagepresets/German.xml b/resources/pagepresets/German.xml
new file mode 100644
index 000000000..b3bb0d09e
--- /dev/null
+++ b/resources/pagepresets/German.xml
@@ -0,0 +1,24 @@
+
+
+
+ Scribus
+ CC0
+
+ German
+ Deutsch
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/pagepresets/ISO_A_Paper.xml b/resources/pagepresets/ISO_A_Paper.xml
new file mode 100644
index 000000000..d661f4fa7
--- /dev/null
+++ b/resources/pagepresets/ISO_A_Paper.xml
@@ -0,0 +1,29 @@
+
+
+
+ Scribus
+ CC0
+
+ ISO A Paper
+ ISO A Papier
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/pagepresets/ISO_B_Paper.xml b/resources/pagepresets/ISO_B_Paper.xml
new file mode 100644
index 000000000..871d97bae
--- /dev/null
+++ b/resources/pagepresets/ISO_B_Paper.xml
@@ -0,0 +1,27 @@
+
+
+
+ Scribus
+ CC0
+
+ ISO B Paper
+ ISO B Papier
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/pagepresets/ISO_C_Envelope.xml b/resources/pagepresets/ISO_C_Envelope.xml
new file mode 100644
index 000000000..f57558ab8
--- /dev/null
+++ b/resources/pagepresets/ISO_C_Envelope.xml
@@ -0,0 +1,24 @@
+
+
+
+ Scribus
+ CC0
+
+ ISO C Envelope
+ ISO C Umschläge
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/pagepresets/Imperial.xml b/resources/pagepresets/Imperial.xml
new file mode 100644
index 000000000..cab9f102b
--- /dev/null
+++ b/resources/pagepresets/Imperial.xml
@@ -0,0 +1,25 @@
+
+
+
+ Scribus
+ CC0
+
+ Imperial
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/pagepresets/International_Envelopes.xml b/resources/pagepresets/International_Envelopes.xml
new file mode 100644
index 000000000..df0b95015
--- /dev/null
+++ b/resources/pagepresets/International_Envelopes.xml
@@ -0,0 +1,31 @@
+
+
+
+ Scribus
+ CC0
+
+ International Envelopes
+ Internationale Briefumschläge
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/pagepresets/Japanese.xml b/resources/pagepresets/Japanese.xml
new file mode 100644
index 000000000..cd1208942
--- /dev/null
+++ b/resources/pagepresets/Japanese.xml
@@ -0,0 +1,31 @@
+
+
+
+ Scribus
+ CC0
+
+ Japanese
+ Japanisch
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/pagepresets/Newspapers.xml b/resources/pagepresets/Newspapers.xml
new file mode 100644
index 000000000..9d4880554
--- /dev/null
+++ b/resources/pagepresets/Newspapers.xml
@@ -0,0 +1,107 @@
+
+
+
+ Scribus
+ CC0
+
+ Newspapers
+ Zeitungen
+
+
+
+
+
+ AU/NZ Broadsheet
+ AU/NZ Vollformat
+
+
+
+
+ Berliner Broadsheet
+ Berliner Vollformat
+
+
+
+
+ Berliner Tabloid
+ Berliner Halbformat
+
+
+
+
+ Canadian Tabloid
+ Kanadisches Halbformat
+
+
+
+
+ Canadian Tall Tabloid
+ Kanadisches Halbformat (hoch)
+
+
+
+
+
+
+
+ Nordisch Broadsheet
+ Nordisches Vollformat
+
+
+
+
+ Nordisch Tabloid
+ Nordisches Halbformat
+
+
+
+
+ Norwegian Tabloid
+ Norwegisches Halbformat
+
+
+
+
+ Rhenish Broadsheet
+ Rheinisches Vollformat
+
+
+
+
+ Rhenish Tabloid
+ Rheinisches Halbformat
+
+
+
+
+ SA Broadsheet
+ SA Vollformat
+
+
+
+
+ Swiss Broadsheet
+ Schweizer Vollformat
+
+
+
+
+ UK Broadsheet
+ UK Vollformat
+
+
+
+
+ UK Tabloid
+ UK Halbformat
+
+
+
+
+ US Broadsheet
+ US Vollformat
+
+
+
+
+
diff --git a/resources/pagepresets/Others.xml b/resources/pagepresets/Others.xml
new file mode 100644
index 000000000..bb1f22f1d
--- /dev/null
+++ b/resources/pagepresets/Others.xml
@@ -0,0 +1,60 @@
+
+
+
+ Scribus
+ CC0
+
+ Others
+ Sonstiges
+
+
+
+
+
+
+
+
+
+ Cassette Cover (J-Card)
+ Kassetten-Cover (J-Card)
+
+
+
+
+ Cassette Cover (U-Card)
+ Kassetten-Cover (U-Card)
+
+
+
+
+ Compact Disc (Back)
+ CD (Rückseite)
+
+
+
+
+ Compact Disc (Front Double)
+ CD (Vorderseite doppelt)
+
+
+
+
+ Compact Disc (Front)
+ CD (Vorderseite)
+
+
+
+
+ DVD Cover Normal
+ DVD Cover Normal
+
+
+
+
+ DVD Cover Slim
+ DVD Cover Schmal
+
+
+
+
+
diff --git a/resources/pagepresets/Swedish.xml b/resources/pagepresets/Swedish.xml
new file mode 100644
index 000000000..f8bd7c95e
--- /dev/null
+++ b/resources/pagepresets/Swedish.xml
@@ -0,0 +1,57 @@
+
+
+
+ Scribus
+ CC0
+
+ Swedish
+ Schwedisch
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/pagepresets/Transitional.xml b/resources/pagepresets/Transitional.xml
new file mode 100644
index 000000000..de37b29de
--- /dev/null
+++ b/resources/pagepresets/Transitional.xml
@@ -0,0 +1,34 @@
+
+
+
+ Scribus
+ CC0
+
+ Transitional
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/pagepresets/US_Envelopes.xml b/resources/pagepresets/US_Envelopes.xml
new file mode 100644
index 000000000..d1a07b608
--- /dev/null
+++ b/resources/pagepresets/US_Envelopes.xml
@@ -0,0 +1,68 @@
+
+
+
+ Scribus
+ CC0
+
+ US Envelopes
+ US Briefumschläge
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/pagepresets/US_Paper.xml b/resources/pagepresets/US_Paper.xml
new file mode 100644
index 000000000..ebe12137c
--- /dev/null
+++ b/resources/pagepresets/US_Paper.xml
@@ -0,0 +1,34 @@
+
+
+
+ Scribus
+ CC0
+
+ US Paper
+ US Papier
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/pagepresets/US_Press.xml b/resources/pagepresets/US_Press.xml
new file mode 100644
index 000000000..3601482ab
--- /dev/null
+++ b/resources/pagepresets/US_Press.xml
@@ -0,0 +1,25 @@
+
+
+
+ Scribus
+ CC0
+
+ US Press
+ US Druck
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/pagepresets/index.xml b/resources/pagepresets/index.xml
new file mode 100644
index 000000000..9e3c8ac75
--- /dev/null
+++ b/resources/pagepresets/index.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/pagepresets/install.targets b/resources/pagepresets/install.targets
new file mode 100644
index 000000000..179e1bcc8
--- /dev/null
+++ b/resources/pagepresets/install.targets
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+ $(AfterBuildDependsOn);
+ Install_resources_pagepresets;
+
+
+
+
+
+
+
diff --git a/scribus/CMakeLists_Sources.txt b/scribus/CMakeLists_Sources.txt
index 0c2fe667b..0dacfd208 100644
--- a/scribus/CMakeLists_Sources.txt
+++ b/scribus/CMakeLists_Sources.txt
@@ -267,6 +267,7 @@ set(SCRIBUS_SOURCES
imagedataloaders/scimgdataloader_tiff.cpp
imagedataloaders/scimgdataloader_wpg.cpp
manager/dock_manager.cpp
+ manager/pagepreset_manager.cpp
manager/widget_manager.cpp
models/gradientlistmodel.cpp
palettes/cxfcolor.cpp
diff --git a/scribus/localemgr.cpp b/scribus/localemgr.cpp
index 7057a7be7..4baa2d796 100644
--- a/scribus/localemgr.cpp
+++ b/scribus/localemgr.cpp
@@ -32,7 +32,7 @@ for which a new license (GPL+exception) is in place.
#include "scribuscore.h"
#include "localemgr.h"
#include "scpaths.h"
-#include "pagesize.h"
+#include "manager/pagepreset_manager.h"
LocaleManager& LocaleManager::instance()
{
@@ -61,13 +61,13 @@ void LocaleManager::generateLocaleList()
//Build table;
//No, we don't translate these, they are internal use that don't get to the GUI
m_localeTable.clear();
- m_localeTable.append(LocaleDef("default","mm", PageSize::defaultSizesList().at(1)));
- m_localeTable.append(LocaleDef("en", "in", PageSize::defaultSizesList().at(4)));
- m_localeTable.append(LocaleDef("en_AU", "mm", PageSize::defaultSizesList().at(1)));
- m_localeTable.append(LocaleDef("en_GB", "mm", PageSize::defaultSizesList().at(1)));
- m_localeTable.append(LocaleDef("en_US", "in", PageSize::defaultSizesList().at(4)));
- m_localeTable.append(LocaleDef("fr", "mm", PageSize::defaultSizesList().at(1)));
- m_localeTable.append(LocaleDef("fr_QC", "pica", PageSize::defaultSizesList().at(4)));
+ m_localeTable.append(LocaleDef("default","mm", PagePresetManager::defaultSizesList().at(1)));
+ m_localeTable.append(LocaleDef("en", "in", PagePresetManager::defaultSizesList().at(4)));
+ m_localeTable.append(LocaleDef("en_AU", "mm", PagePresetManager::defaultSizesList().at(1)));
+ m_localeTable.append(LocaleDef("en_GB", "mm", PagePresetManager::defaultSizesList().at(1)));
+ m_localeTable.append(LocaleDef("en_US", "in", PagePresetManager::defaultSizesList().at(4)));
+ m_localeTable.append(LocaleDef("fr", "mm", PagePresetManager::defaultSizesList().at(1)));
+ m_localeTable.append(LocaleDef("fr_QC", "pica", PagePresetManager::defaultSizesList().at(4)));
}
void LocaleManager::printSelectedForLocale(const QString& locale)
@@ -105,8 +105,8 @@ QString LocaleManager::pageSizeForLocale(const QString& locale)
//qDebug()<<"No definition for locale: "<
+#include
+#include
+#include
+#include
+#include
+#include
+#include "api/api_application.h"
+#include "commonstrings.h"
+#include "langmgr.h"
+#include "prefsmanager.h"
+#include "scpaths.h"
+#include "scribusapp.h"
+#include "units.h"
+#include "util.h"
+
+PagePresetManager *PagePresetManager::m_instance = nullptr;
+
+PagePresetManager &PagePresetManager::instance()
+{
+ static PagePresetManager m_instance;
+ return m_instance;
+}
+
+PagePresetManager::PagePresetManager(QObject *parent)
+ : QObject(parent)
+{
+ reloadAllPresets();
+ connect(ScQApp, &ScribusQApp::localeChanged, this, &PagePresetManager::localeChange);
+}
+
+
+void PagePresetManager::reloadAllPresets()
+{
+ m_pageSizeList.clear();
+ m_categoryList.clear();
+ m_categoryOrderList.clear();
+
+ // Add Scribus page presets
+ loadAllPresets(systemIndexFile(), PageSizeType::Preset);
+
+ // Add users page presets
+ loadAllPresets(userIndexFile(), PageSizeType::User);
+}
+
+QStringList PagePresetManager::defaultSizesList()
+{
+ // A3, A4, A5, A6, US letter
+ static const QStringList list = {"FzlMfpPelK5894hHnoLDC_00007", "FzlMfpPelK5894hHnoLDC_00009", "FzlMfpPelK5894hHnoLDC_00010", "FzlMfpPelK5894hHnoLDC_00011", "6w0FSR1dcD7Lh6qfbD3QvD_00019"};
+ return list;
+}
+
+PageCollectionInfo PagePresetManager::categoryInfoById(const QString &id)
+{
+ return m_categoryList.value(id);
+}
+
+PageCollectionInfo PagePresetManager::categoryInfoCustom()
+{
+ PageCollectionInfo pciCustom;
+ pciCustom.id = CommonStrings::customPageSize;
+ pciCustom.displayName = CommonStrings::trCustomPageSize;
+ return pciCustom;
+}
+
+PageCollectionInfo PagePresetManager::categoryInfoPreferred()
+{
+ PageCollectionInfo pciPreferred;
+ pciPreferred.id = QStringLiteral("Preferred");
+ pciPreferred.displayName = tr("Preferred");
+ return pciPreferred;
+}
+
+PageSizeInfoMap PagePresetManager::activePageSizes() const
+{
+ const auto &activeList = PrefsManager::instance().appPrefs.activePageSizes;
+
+ if (activeList.isEmpty())
+ return m_pageSizeList;
+
+ PageSizeInfoMap map;
+
+ for (const QString &id : activeList)
+ {
+ auto it = m_pageSizeList.find(id);
+ if (it != m_pageSizeList.end())
+ map.insert(id, *it);
+
+ // This is an alternative way to find a page size, but needs more time
+ // PageSizeInfo psi = pageInfoByName(id);
+ // map.insert(psi.id, psi);
+ }
+ return map;
+}
+
+PageSizeInfoMap PagePresetManager::sizesByCategory(QString categoryId) const
+{
+ PageSizeInfoMap map;
+ for (auto it = m_pageSizeList.constBegin(); it != m_pageSizeList.constEnd(); ++it)
+ if (it.value().categoryId == categoryId)
+ map.insert(it.key(), it.value());
+ return map;
+}
+
+PageSizeInfoMap PagePresetManager::sizesByDimensions(QSizeF sizePt) const
+{
+ PageSizeInfoMap map;
+ for (auto it = m_pageSizeList.constBegin(); it != m_pageSizeList.constEnd(); ++it)
+ if (isSizeMatch(it.value(), sizePt))
+ map.insert(it.key(), it.value());
+ return map;
+}
+
+PageSizeInfo PagePresetManager::pageInfoByDimensions(QSizeF sizePt) const
+{
+ for (auto it = m_pageSizeList.constBegin(); it != m_pageSizeList.constEnd(); ++it)
+ if (isSizeMatch(it.value(), sizePt))
+ return it.value();
+
+ PageSizeInfo psi = pageInfoCustom();
+ psi.width = sizePt.width();
+ psi.height = sizePt.height();
+ return psi;
+}
+
+PageSizeInfo PagePresetManager::pageInfoByName(const QString &name) const
+{
+ auto it = m_pageSizeList.find(name);
+ if (it != m_pageSizeList.end())
+ return it.value();
+
+ for (auto it2 = m_pageSizeList.constBegin(); it2 != m_pageSizeList.constEnd(); ++it2)
+ if (it2.value().displayName == name || it2.value().lagacyNames.contains(name))
+ return it2.value();
+
+ return pageInfoCustom();
+}
+
+PageSizeInfo PagePresetManager::pageInfoCustom() const
+{
+ PageCollectionInfo pci = PagePresetManager::instance().categoryInfoCustom();
+ PageSizeInfo psi;
+ psi.width = 0.0;
+ psi.height = 0.0;
+ psi.pageUnitIndex = 0; //pt
+ psi.id = CommonStrings::customPageSize;
+ psi.name = CommonStrings::trCustomPageSize;
+ psi.displayName = CommonStrings::trCustomPageSize;
+ psi.categoryId = pci.id;
+
+ return psi;
+}
+
+bool PagePresetManager::isSizeMatch(const PageSizeInfo &info, const QSizeF &size)
+{
+ const double epsilon = 0.01;
+
+ return (qAbs(info.width - size.width()) <= epsilon && qAbs(info.height - size.height()) <= epsilon)
+ || (qAbs(info.width - size.height()) <= epsilon && qAbs(info.height - size.width()) <= epsilon);
+}
+
+void PagePresetManager::addPageSize(const PageSizeInfo &info)
+{
+ PageSizeInfo pinfo = info;
+ pinfo.width = value2pts(info.width, info.pageUnitIndex);
+ pinfo.height = value2pts(info.height, info.pageUnitIndex);
+ pinfo.label = QStringLiteral("%1 x %2 %3").arg(info.width).arg(info.height).arg(unitGetStrFromIndex(info.pageUnitIndex));
+
+ m_pageSizeList.insert(pinfo.id, std::move(pinfo));
+}
+
+void PagePresetManager::addCategory(const PageCollectionInfo &collection)
+{
+ m_categoryList.insert(collection.id, collection);
+}
+
+void PagePresetManager::loadAllPresets(const QString &indexFilePath, PageSizeType type)
+{
+ QFile file(indexFilePath);
+ if (!file.open(QIODevice::ReadOnly))
+ {
+ if (type == PageSizeType::Preset)
+ qWarning() << "Could not open index file:" << indexFilePath;
+ return;
+ }
+
+ QString basePath = QFileInfo(indexFilePath).path();
+ if (!basePath.endsWith(u'/'))
+ basePath += u'/';
+
+ QXmlStreamReader xml(&file);
+
+ while (!xml.atEnd() && !xml.hasError())
+ {
+ if (xml.readNext() == QXmlStreamReader::StartElement)
+ {
+ const auto tagName = xml.name();
+
+ if (tagName == u"collections")
+ {
+ const auto minVer = xml.attributes().value(u"minVersion");
+ if (!hasValidVersion(minVer.toString()))
+ qWarning() << "The index file is newer than the current version:" << indexFilePath;
+ }
+ else if (tagName == u"collection")
+ {
+ const auto fileNameView = xml.attributes().value(u"name");
+ if (!fileNameView.isEmpty())
+ parseCollectionFile(basePath % fileNameView, type);
+ }
+ else if (tagName == u"separator")
+ {
+ m_categoryOrderList.append(QStringLiteral("-"));
+ }
+ }
+ }
+
+ if (xml.hasError())
+ qWarning() << "XML error in index:" << xml.errorString();
+}
+
+void PagePresetManager::parseCollectionFile(const QString &filePath, PageSizeType type)
+{
+ QFile file(filePath);
+ if (!file.open(QIODevice::ReadOnly))
+ {
+ qWarning() << "Could not open collection file:" << filePath;
+ return;
+ }
+
+ PrefsManager &prefsManager = PrefsManager::instance();
+
+ QXmlStreamReader xml(&file);
+ PageCollectionInfo currentMeta;
+ currentMeta.type = type;
+ currentMeta.filePath = filePath;
+
+ bool collectingPages = false;
+
+ while (!xml.atEnd() && !xml.hasError())
+ {
+ const auto token = xml.readNext();
+
+ if (token == QXmlStreamReader::StartElement)
+ {
+ const auto tagName = xml.name();
+
+ if (tagName == u"collection")
+ {
+ const auto &attrs = xml.attributes();
+ if (!hasValidVersion(attrs.value(u"minVersion").toString()))
+ {
+ qWarning() << "Skipped newer version preset:" << filePath;
+ return;
+ }
+
+ currentMeta.id = attrs.value(u"id").toString();
+ currentMeta.name = attrs.value(u"name").toString();
+ currentMeta.displayName = currentMeta.name;
+
+ m_categoryOrderList.append(currentMeta.id);
+ }
+ else if (tagName == u"metadata")
+ {
+ while (!xml.atEnd())
+ {
+ const auto metaToken = xml.readNext();
+ if (metaToken == QXmlStreamReader::EndElement && xml.name() == u"metadata")
+ break;
+
+ if (metaToken == QXmlStreamReader::StartElement)
+ {
+ const auto metaTag = xml.name();
+ if (metaTag == u"author")
+ currentMeta.author = xml.readElementText();
+ else if (metaTag == u"license")
+ currentMeta.license = xml.readElementText();
+ else if (metaTag == u"names")
+ {
+ currentMeta.localizedNames = parseNamesBlock(xml);
+ updateDisplayName(currentMeta);
+ }
+ else
+ xml.skipCurrentElement();
+ }
+ }
+ addCategory(currentMeta);
+ }
+ else if (tagName == u"pages")
+ {
+ collectingPages = true;
+ }
+ else if (collectingPages && tagName == u"page")
+ {
+ PageSizeInfo info;
+ const auto &attrs = xml.attributes();
+
+ info.id = currentMeta.id % u'_' % attrs.value(u"id");
+ info.width = attrs.value(u"width").toDouble();
+ info.height = attrs.value(u"height").toDouble();
+ info.categoryId = currentMeta.id;
+ info.name = attrs.value(u"name").toString();
+ info.displayName = info.name;
+ info.pageUnitIndex = unitIndexFromString(attrs.value(u"unit").toString());
+ info.type = type;
+
+ const auto layoutVal = attrs.value(u"layout");
+ if (!layoutVal.isEmpty())
+ info.layout = attrs.value(u"layout").toInt();
+ // else
+ // info.layout = prefsManager.appPrefs.docSetupPrefs.pagePositioning;
+
+ const auto bindingDirectionVal = attrs.value(u"bindingDirection");
+ if (!bindingDirectionVal.isEmpty())
+ info.bindingDirection = attrs.value(u"bindingDirection").toInt();
+ // else
+ // info.bindingDirection = prefsManager.appPrefs.docSetupPrefs.bindingDirection;
+
+ const auto firstPageVal = attrs.value(u"firstPage");
+ if (!firstPageVal.isEmpty())
+ info.firstPage = attrs.value(u"firstPage").toInt();
+ // else
+ // info.firstPage = prefsManager.appPrefs.docSetupPrefs.pagePositioning;
+
+ const auto legacyVal = attrs.value(u"legacyNames");
+ if (!legacyVal.isEmpty())
+ info.lagacyNames = legacyVal.toString().split(u';');
+
+ while (!xml.atEnd())
+ {
+ const auto pageToken = xml.readNext();
+ if (pageToken == QXmlStreamReader::EndElement && xml.name() == u"page")
+ break;
+
+ if (pageToken == QXmlStreamReader::StartElement)
+ {
+ const auto childName = xml.name();
+
+ if (childName == u"names")
+ {
+ info.localizedNames = parseNamesBlock(xml);
+ updateDisplayName(info);
+ }
+ else if (childName == u"margins")
+ {
+ const auto &attrs = xml.attributes();
+ MarginStruct margins;
+ margins.setLeft(value2pts(attrs.value(u"left").toDouble(), info.pageUnitIndex));
+ margins.setTop(value2pts(attrs.value(u"top").toDouble(), info.pageUnitIndex));
+ margins.setRight(value2pts(attrs.value(u"right").toDouble(), info.pageUnitIndex));
+ margins.setBottom(value2pts(attrs.value(u"bottom").toDouble(), info.pageUnitIndex));
+
+ info.margins = margins;
+ info.marginPreset = attrs.value(u"preset").toInt();
+
+ xml.skipCurrentElement();
+ }
+ else if (childName == u"bleeds")
+ {
+ const auto &attrs = xml.attributes();
+ MarginStruct margins;
+ margins.setLeft(value2pts(attrs.value(u"left").toDouble(), info.pageUnitIndex));
+ margins.setTop(value2pts(attrs.value(u"top").toDouble(), info.pageUnitIndex));
+ margins.setRight(value2pts(attrs.value(u"right").toDouble(), info.pageUnitIndex));
+ margins.setBottom(value2pts(attrs.value(u"bottom").toDouble(), info.pageUnitIndex));
+
+ info.bleeds = margins;
+
+ xml.skipCurrentElement();
+ }
+ else if (childName == u"textFrame")
+ {
+ const auto &attrs = xml.attributes();
+ QList values;
+ values.append(attrs.value(u"columns").toInt());
+ values.append(value2pts(attrs.value(u"gap").toDouble(), info.pageUnitIndex));
+
+ info.textFrame = values;
+
+ xml.skipCurrentElement();
+ }
+ else
+ xml.skipCurrentElement();
+ }
+ }
+ addPageSize(std::move(info));
+ }
+ }
+ else if (token == QXmlStreamReader::EndElement)
+ {
+ if (xml.name() == u"pages")
+ collectingPages = false;
+ }
+ }
+
+ if (xml.hasError())
+ qWarning() << "XML error in collection" << filePath << ":" << xml.errorString();
+}
+
+template
+void PagePresetManager::updateDisplayName(T &info)
+{
+ if (!info.localizedNames.empty())
+ {
+ const QString language = PrefsManager::instance().appPrefs.uiPrefs.language;
+ const QString normalizeLanguage = LanguageManager::instance()->getShortAbbrevFromAbbrevDecomposition(language);
+ info.displayName = info.localizedNames.value(normalizeLanguage, info.name);
+ }
+}
+
+void PagePresetManager::localeChange()
+{
+ for (auto &col : m_categoryList)
+ updateDisplayName(col);
+
+ for (auto &page : m_pageSizeList)
+ updateDisplayName(page);
+}
+
+LocalizedStringsMap PagePresetManager::parseNamesBlock(QXmlStreamReader &xml)
+{
+ LocalizedStringsMap namesMap;
+
+ while (!xml.atEnd())
+ {
+ const auto token = xml.readNext();
+ if (token == QXmlStreamReader::EndElement && xml.name() == u"names")
+ break;
+
+ if (token == QXmlStreamReader::StartElement)
+ {
+ if (xml.name() == u"name")
+ {
+ const auto langView = xml.attributes().value(u"lang").toString();
+ if (!langView.isEmpty())
+ {
+ QString val = xml.readElementText();
+ if (!val.isEmpty())
+ namesMap.insert(langView, std::move(val));
+ }
+ else
+ xml.skipCurrentElement();
+ }
+ else
+ xml.skipCurrentElement();
+ }
+ }
+ return namesMap;
+}
+
+const QString PagePresetManager::systemIndexFile()
+{
+ return QDir::toNativeSeparators(ScPaths::instance().pagePresetsDir()) + QStringLiteral("index.xml");
+}
+
+const QString PagePresetManager::userIndexFile()
+{
+ return QDir::toNativeSeparators(ScPaths::userPagePresetsDir(true)) + QStringLiteral("index.xml");
+}
+
+bool PagePresetManager::hasValidVersion(const QString &version)
+{
+ const int curr_major = version.section(".", 0, 0).toInt();
+ const int curr_minor = version.section(".", 1, 1).toInt();
+ const int curr_patch = version.section(".", 2, 2).toInt();
+ const int curr_fullver = curr_major * 10000 + curr_minor * 100 + curr_patch;
+
+ const int ver_major = ScribusAPI::getVersionMajor();
+ const int ver_minor = ScribusAPI::getVersionMinor();
+ const int ver_patch = ScribusAPI::getVersionPatch();
+ const int ver_fullver = ver_major * 10000 + ver_minor * 100 + ver_patch;
+
+ return curr_fullver <= ver_fullver;
+}
+
+// =======================
+// Custom preset functions
+// =======================
+
+bool PagePresetManager::updateIndexFile(const QString &collectionFilePath, IndexAction action)
+{
+ QFileInfo colInfo(collectionFilePath);
+ const QString fileName = colInfo.fileName();
+ const QString indexFilePath = colInfo.dir().filePath(QStringLiteral("index.xml"));
+
+ QDomDocument doc;
+
+ if (!loadDocument(indexFilePath, doc))
+ {
+ if (action == IndexAction::Remove)
+ return true;
+
+ doc.clear();
+ doc.appendChild(doc.createProcessingInstruction(QStringLiteral("xml"), QStringLiteral("version=\"1.0\" encoding=\"utf-8\"")));
+ QDomElement root = doc.createElement(QStringLiteral("collections"));
+ root.setAttribute(QStringLiteral("minVersion"), ScribusAPI::getVersion());
+ root.setAttribute(QStringLiteral("version"), ScribusAPI::getVersion());
+ doc.appendChild(root);
+ }
+
+ QDomElement root = doc.documentElement();
+ if (root.tagName() != u"collections")
+ return false;
+
+ // Find collection
+ QDomElement foundElem;
+ bool found = false;
+ QDomElement elem = root.firstChildElement(QStringLiteral("collection"));
+
+ while (!elem.isNull())
+ {
+ if (elem.attribute(QStringLiteral("name")) == fileName)
+ {
+ foundElem = elem;
+ found = true;
+ break;
+ }
+ elem = elem.nextSiblingElement(QStringLiteral("collection"));
+ }
+
+ bool changed = false;
+
+ if (action == IndexAction::Add && !found)
+ {
+ QDomElement newCol = doc.createElement(QStringLiteral("collection"));
+ newCol.setAttribute(QStringLiteral("name"), fileName);
+ root.appendChild(newCol);
+ changed = true;
+ }
+ else if (action == IndexAction::Remove && found)
+ {
+ root.removeChild(foundElem);
+ changed = true;
+ }
+
+ return changed ? saveDocument(indexFilePath, doc) : true;
+}
+
+bool PagePresetManager::createOrUpdateCollection(const QString &filePath, const PageCollectionInfo &meta, QString &outUuid)
+{
+ QDomDocument doc;
+ bool exists = loadDocument(filePath, doc);
+ QDomElement root;
+
+ if (!exists)
+ {
+ doc.appendChild(doc.createProcessingInstruction(QStringLiteral("xml"), QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")));
+ root = doc.createElement(QStringLiteral("collection"));
+ doc.appendChild(root);
+
+ QString newId = getShortUuidFromUuid(QUuid::createUuid());
+ root.setAttribute(QStringLiteral("id"), newId);
+ root.appendChild(doc.createElement(QStringLiteral("pages")));
+ outUuid = newId;
+ }
+ else
+ {
+ root = doc.documentElement();
+ if (root.tagName() != u"collection")
+ return false;
+
+ outUuid = root.attribute(QStringLiteral("id"));
+ if (outUuid.isEmpty())
+ {
+ outUuid = getShortUuidFromUuid(QUuid::createUuid());
+ root.setAttribute(QStringLiteral("id"), outUuid);
+ }
+ }
+
+ root.setAttribute(QStringLiteral("name"), meta.name);
+ root.setAttribute(QStringLiteral("minVersion"), ScribusAPI::getVersion());
+ root.setAttribute(QStringLiteral("version"), ScribusAPI::getVersion());
+
+ QDomElement metaNode = root.firstChildElement(QStringLiteral("metadata"));
+ if (metaNode.isNull())
+ {
+ metaNode = doc.createElement(QStringLiteral("metadata"));
+ QDomElement pagesNode = root.firstChildElement(QStringLiteral("pages"));
+ if (!pagesNode.isNull())
+ root.insertBefore(metaNode, pagesNode);
+ else
+ root.appendChild(metaNode);
+ }
+
+ setChildText(metaNode, QStringLiteral("author"), meta.author);
+ setChildText(metaNode, QStringLiteral("license"), meta.license);
+
+ if (!saveDocument(filePath, doc))
+ return false;
+
+ if (!updateIndexFile(filePath, IndexAction::Add))
+ qWarning() << "Index update failed:" << filePath;
+
+ return true;
+}
+
+bool PagePresetManager::removeCollection(const QString &filePath)
+{
+ if (!updateIndexFile(filePath, IndexAction::Remove))
+ qWarning() << "Index update failed (removal):" << filePath;
+
+ return QFile::remove(filePath);
+}
+
+bool PagePresetManager::isCollectionsEmpty(const QString &filePath)
+{
+ QDomDocument doc;
+ if (!loadDocument(filePath, doc))
+ return false;
+
+ QDomNodeList pagesNodes = doc.elementsByTagName("pages");
+
+ if (pagesNodes.isEmpty())
+ return true;
+
+ QDomElement pagesElement = pagesNodes.at(0).toElement();
+ QDomNode child = pagesElement.firstChild();
+ while (!child.isNull())
+ {
+ if (child.isElement())
+ {
+ if (child.toElement().tagName() == "page")
+ return false;
+ }
+ child = child.nextSibling();
+ }
+
+ return true;
+}
+
+bool PagePresetManager::addCollectionPage(const QString &filePath, const PageSizeInfo &pageInfo)
+{
+ QDomDocument doc;
+ if (!loadDocument(filePath, doc))
+ {
+ qWarning() << "File not found:" << filePath;
+ return false;
+ }
+
+ QDomElement root = doc.documentElement();
+ QDomElement pagesNode = root.firstChildElement(QStringLiteral("pages"));
+
+ if (pagesNode.isNull())
+ {
+ pagesNode = doc.createElement(QStringLiteral("pages"));
+ root.appendChild(pagesNode);
+ }
+
+ int nextIdVal = 0;
+ QDomElement pageElem = pagesNode.firstChildElement(QStringLiteral("page"));
+ while (!pageElem.isNull())
+ {
+ bool ok;
+ int currentId = pageElem.attribute(QStringLiteral("id")).toInt(&ok);
+ if (ok && currentId >= nextIdVal)
+ nextIdVal = currentId + 1;
+ pageElem = pageElem.nextSiblingElement(QStringLiteral("page"));
+ }
+
+ QString newIdString = QStringLiteral("%1").arg(nextIdVal, 5, 10, QChar('0'));
+
+ // Page tag
+ QDomElement newPage = doc.createElement(QStringLiteral("page"));
+ newPage.setAttribute(QStringLiteral("id"), newIdString);
+ newPage.setAttribute(QStringLiteral("unit"), unitGetUntranslatedStrFromIndex(pageInfo.pageUnitIndex));
+ newPage.setAttribute(QStringLiteral("width"), QString::number(pts2value(pageInfo.width, pageInfo.pageUnitIndex)));
+ newPage.setAttribute(QStringLiteral("height"), QString::number(pts2value(pageInfo.height, pageInfo.pageUnitIndex)));
+ newPage.setAttribute(QStringLiteral("name"), pageInfo.name);
+ newPage.setAttribute(QStringLiteral("layout"), QString::number(pageInfo.layout));
+ newPage.setAttribute(QStringLiteral("firstPage"), QString::number(pageInfo.firstPage));
+ newPage.setAttribute(QStringLiteral("bindingDirection"), QString::number(pageInfo.bindingDirection));
+
+ // Margin tag
+ if (!pageInfo.margins.isNull())
+ {
+ QDomElement element = doc.createElement(QStringLiteral("margins"));
+ element.setAttribute(QStringLiteral("left"), QString::number(pts2value(pageInfo.margins.left(), pageInfo.pageUnitIndex)));
+ element.setAttribute(QStringLiteral("right"), QString::number(pts2value(pageInfo.margins.right(), pageInfo.pageUnitIndex)));
+ element.setAttribute(QStringLiteral("top"), QString::number(pts2value(pageInfo.margins.top(), pageInfo.pageUnitIndex)));
+ element.setAttribute(QStringLiteral("bottom"), QString::number(pts2value(pageInfo.margins.bottom(), pageInfo.pageUnitIndex)));
+ element.setAttribute(QStringLiteral("preset"), QString::number(pageInfo.marginPreset));
+ newPage.appendChild(element);
+ }
+
+ // Bleed tag
+ if (!pageInfo.bleeds.isNull())
+ {
+ QDomElement element = doc.createElement(QStringLiteral("bleeds"));
+ element.setAttribute(QStringLiteral("left"), QString::number(pts2value(pageInfo.bleeds.left(), pageInfo.pageUnitIndex)));
+ element.setAttribute(QStringLiteral("right"), QString::number(pts2value(pageInfo.bleeds.right(), pageInfo.pageUnitIndex)));
+ element.setAttribute(QStringLiteral("top"), QString::number(pts2value(pageInfo.bleeds.top(), pageInfo.pageUnitIndex)));
+ element.setAttribute(QStringLiteral("bottom"), QString::number(pts2value(pageInfo.bleeds.bottom(), pageInfo.pageUnitIndex)));
+ newPage.appendChild(element);
+ }
+
+ // Text frame
+ if (!pageInfo.textFrame.isEmpty())
+ {
+ QDomElement element = doc.createElement(QStringLiteral("textFrame"));
+ element.setAttribute(QStringLiteral("columns"), QString::number(pageInfo.textFrame.at(0)));
+ element.setAttribute(QStringLiteral("gap"), QString::number(pts2value(pageInfo.textFrame.at(1), pageInfo.pageUnitIndex)));
+ newPage.appendChild(element);
+ }
+
+ pagesNode.appendChild(newPage);
+
+ return saveDocument(filePath, doc);
+}
+
+bool PagePresetManager::updateCollectionPage(const QString &filePath, const PageSizeInfo &pageInfo)
+{
+ const int separatorIdx = pageInfo.id.lastIndexOf(u'_');
+ if (separatorIdx == -1)
+ return false;
+
+ const QString collectionId = pageInfo.id.left(separatorIdx);
+ const QString pageId = pageInfo.id.mid(separatorIdx + 1);
+
+ QDomDocument doc;
+ if (!loadDocument(filePath, doc))
+ return false;
+
+ QDomElement root = doc.documentElement();
+ if (root.attribute(QStringLiteral("id")) != collectionId)
+ return false;
+
+ QDomElement pagesNode = root.firstChildElement(QStringLiteral("pages"));
+ QDomElement pageElem = pagesNode.firstChildElement(QStringLiteral("page"));
+
+ while (!pageElem.isNull())
+ {
+ if (pageElem.attribute(QStringLiteral("id")) == pageId)
+ {
+ pageElem.setAttribute(QStringLiteral("unit"), unitGetUntranslatedStrFromIndex(pageInfo.pageUnitIndex));
+ pageElem.setAttribute(QStringLiteral("width"), QString::number(pts2value(pageInfo.width, pageInfo.pageUnitIndex)));
+ pageElem.setAttribute(QStringLiteral("height"), QString::number(pts2value(pageInfo.height, pageInfo.pageUnitIndex)));
+ pageElem.setAttribute(QStringLiteral("name"), pageInfo.name);
+ pageElem.setAttribute(QStringLiteral("layout"), QString::number(pageInfo.layout));
+ pageElem.setAttribute(QStringLiteral("firstPage"), QString::number(pageInfo.firstPage));
+ pageElem.setAttribute(QStringLiteral("bindingDirection"), QString::number(pageInfo.bindingDirection));
+
+ // Margin tag
+ QDomElement marginsElem = pageElem.firstChildElement(QStringLiteral("margins"));
+
+ if (pageInfo.margins.isNull())
+ {
+ if (!marginsElem.isNull())
+ pageElem.removeChild(marginsElem);
+ }
+ else
+ {
+ if (marginsElem.isNull())
+ {
+ marginsElem = doc.createElement(QStringLiteral("margins"));
+ pageElem.appendChild(marginsElem);
+ }
+
+ marginsElem.setAttribute(QStringLiteral("left"), QString::number(pts2value(pageInfo.margins.left(), pageInfo.pageUnitIndex)));
+ marginsElem.setAttribute(QStringLiteral("top"), QString::number(pts2value(pageInfo.margins.top(), pageInfo.pageUnitIndex)));
+ marginsElem.setAttribute(QStringLiteral("right"), QString::number(pts2value(pageInfo.margins.right(), pageInfo.pageUnitIndex)));
+ marginsElem.setAttribute(QStringLiteral("bottom"), QString::number(pts2value(pageInfo.margins.bottom(), pageInfo.pageUnitIndex)));
+ marginsElem.setAttribute(QStringLiteral("preset"), QString::number(pageInfo.marginPreset));
+ }
+
+ // Bleed tag
+ QDomElement bleedsElem = pageElem.firstChildElement(QStringLiteral("bleeds"));
+
+ if (pageInfo.bleeds.isNull())
+ {
+ if (!bleedsElem.isNull())
+ pageElem.removeChild(bleedsElem);
+ }
+ else
+ {
+ if (bleedsElem.isNull())
+ {
+ bleedsElem = doc.createElement(QStringLiteral("bleeds"));
+ pageElem.appendChild(bleedsElem);
+ }
+
+ bleedsElem.setAttribute(QStringLiteral("left"), QString::number(pts2value(pageInfo.bleeds.left(), pageInfo.pageUnitIndex)));
+ bleedsElem.setAttribute(QStringLiteral("top"), QString::number(pts2value(pageInfo.bleeds.top(), pageInfo.pageUnitIndex)));
+ bleedsElem.setAttribute(QStringLiteral("right"), QString::number(pts2value(pageInfo.bleeds.right(), pageInfo.pageUnitIndex)));
+ bleedsElem.setAttribute(QStringLiteral("bottom"), QString::number(pts2value(pageInfo.bleeds.bottom(), pageInfo.pageUnitIndex)));
+ }
+
+ // Text frame
+ QDomElement textFrameElem = pageElem.firstChildElement(QStringLiteral("textFrame"));
+
+ if (pageInfo.textFrame.isEmpty())
+ {
+ if (!textFrameElem.isNull())
+ pageElem.removeChild(textFrameElem);
+ }
+ else
+ {
+ if (textFrameElem.isNull())
+ {
+ textFrameElem = doc.createElement(QStringLiteral("bleeds"));
+ pageElem.appendChild(textFrameElem);
+ }
+
+ textFrameElem.setAttribute(QStringLiteral("columns"), QString::number(pageInfo.textFrame.at(0)));
+ textFrameElem.setAttribute(QStringLiteral("gap"), QString::number(pts2value(pageInfo.textFrame.at(1), pageInfo.pageUnitIndex)));
+ }
+
+ return saveDocument(filePath, doc);
+ }
+ pageElem = pageElem.nextSiblingElement(QStringLiteral("page"));
+ }
+ return false;
+}
+
+bool PagePresetManager::removeCollectionPage(const QString &filePath, const QString &compositeId)
+{
+ const int separatorIdx = compositeId.lastIndexOf(u'_');
+ if (separatorIdx == -1)
+ return false;
+
+ const QString collectionId = compositeId.left(separatorIdx);
+ const QString pageId = compositeId.mid(separatorIdx + 1);
+
+ QDomDocument doc;
+ if (!loadDocument(filePath, doc))
+ return false;
+
+ QDomElement root = doc.documentElement();
+ if (root.attribute(QStringLiteral("id")) != collectionId)
+ return false;
+
+ QDomElement pagesNode = root.firstChildElement(QStringLiteral("pages"));
+ QDomElement pageElem = pagesNode.firstChildElement(QStringLiteral("page"));
+
+ while (!pageElem.isNull())
+ {
+ if (pageElem.attribute(QStringLiteral("id")) == pageId)
+ {
+ pagesNode.removeChild(pageElem);
+ return saveDocument(filePath, doc);
+ }
+ pageElem = pageElem.nextSiblingElement(QStringLiteral("page"));
+ }
+ return false;
+}
+
+bool PagePresetManager::loadDocument(const QString &filePath, QDomDocument &doc)
+{
+ QFile file(filePath);
+ if (!file.exists() || !file.open(QIODevice::ReadOnly | QIODevice::Text))
+ return false;
+
+ return doc.setContent(&file) ? true : false;
+}
+
+bool PagePresetManager::saveDocument(const QString &filePath, const QDomDocument &doc)
+{
+ QFileInfo fi(filePath);
+ if (!fi.dir().exists())
+ fi.dir().mkpath(QStringLiteral("."));
+
+ QSaveFile saveFile(filePath);
+ if (saveFile.open(QIODevice::WriteOnly | QIODevice::Text))
+ {
+ QTextStream out(&saveFile);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ out.setEncoding(QStringConverter::Utf8);
+#else
+ out.setCodec("UTF-8");
+#endif
+ doc.save(out, 4);
+ return saveFile.commit();
+ }
+ return false;
+}
+
+void PagePresetManager::setChildText(QDomElement &parent, const QString &tagName, const QString &text)
+{
+ QDomElement element = parent.firstChildElement(tagName);
+
+ if (element.isNull())
+ {
+ element = parent.ownerDocument().createElement(tagName);
+ parent.appendChild(element);
+ }
+
+ while (element.hasChildNodes())
+ element.removeChild(element.firstChild());
+
+ element.appendChild(parent.ownerDocument().createTextNode(text));
+}
diff --git a/scribus/manager/pagepreset_manager.h b/scribus/manager/pagepreset_manager.h
new file mode 100644
index 000000000..aa5c8e349
--- /dev/null
+++ b/scribus/manager/pagepreset_manager.h
@@ -0,0 +1,152 @@
+/***************************************************************************
+ * *
+ * This program 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 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+/*
+For general Scribus copyright and licensing information please refer
+to the COPYING file provided with the program.
+*/
+#ifndef PAGEPRESET_MANAGER_H
+#define PAGEPRESET_MANAGER_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include "margins.h"
+#include "ui/marginpresetlayout.h"
+
+using LocalizedStringsMap = QMap;
+
+enum PageSizeType
+{
+ Undefined = 0,
+ Preset,
+ User
+};
+
+struct PageCollectionInfo
+{
+ QString id;
+ QString displayName {"undefined"};
+ QString name {"undefined"}; // original name
+ QString author;
+ QString license;
+ QString filePath;
+ LocalizedStringsMap localizedNames;
+ PageSizeType type {PageSizeType::Undefined};
+};
+
+struct PageSizeInfo
+{
+ int pageUnitIndex {-1};
+ int layout {-1}; // -1 = undefinded, 0 = single, 1 = double
+ int firstPage {-1}; // -1 = undefinded, 0 = left, 1 = right
+ double width {0.0};
+ double height {0.0};
+ int bindingDirection {-1}; // -1 = undefinded, 0 = LTR, 1 = RTL
+ QString displayName {"undefined"};
+ QString name {"undefined"}; // original name
+ QString id;
+ QString label;
+ QString categoryId;
+ QList lagacyNames; // fallback names for Scribus < 1.7.2
+ QList textFrame;
+ LocalizedStringsMap localizedNames;
+ int marginPreset {PresetLayout::none};
+ MarginStruct margins;
+ MarginStruct bleeds;
+ PageSizeType type {PageSizeType::Undefined};
+};
+
+using PageCollectionInfoMap = QMap;
+using PageSizeInfoMap = QMap;
+
+class PagePresetManager : public QObject
+{
+ Q_OBJECT
+public:
+
+ PagePresetManager(PagePresetManager const &) = delete;
+ void operator=(PagePresetManager const &) = delete;
+ static PagePresetManager &instance();
+
+ static QStringList defaultSizesList();
+
+ QList categoriesOrder() const { return m_categoryOrderList; }
+
+ PageCollectionInfoMap categories() const { return m_categoryList; }
+
+ PageCollectionInfo categoryInfoById(const QString &id);
+ PageCollectionInfo categoryInfoCustom();
+ PageCollectionInfo categoryInfoPreferred();
+
+ const PageSizeInfoMap &pageSizes() const { return m_pageSizeList; }
+
+ PageSizeInfoMap activePageSizes() const;
+ PageSizeInfoMap sizesByCategory(QString categoryId) const;
+ PageSizeInfoMap sizesByDimensions(QSizeF sizePt) const;
+
+ PageSizeInfo pageInfoByDimensions(double width, double height) const { return pageInfoByDimensions(QSizeF(width, height)); }
+ PageSizeInfo pageInfoByDimensions(QSizeF sizePt) const;
+ PageSizeInfo pageInfoByName(const QString &name) const;
+ PageSizeInfo pageInfoCustom() const;
+
+ void reloadAllPresets();
+
+ // Custom preset functions
+ static bool createOrUpdateCollection(const QString &filePath, const PageCollectionInfo &meta, QString &outUuid);
+ static bool removeCollection(const QString &filePath);
+ static bool isCollectionsEmpty(const QString &filePath);
+ static bool addCollectionPage(const QString &filePath, const PageSizeInfo &pageInfo);
+ static bool updateCollectionPage(const QString &filePath, const PageSizeInfo &pageInfo);
+ static bool removeCollectionPage(const QString &filePath, const QString &compositeId);
+
+private:
+ enum class IndexAction
+ {
+ Add,
+ Remove
+ };
+
+ PagePresetManager(QObject *parent = nullptr);
+ ~PagePresetManager() = default;
+
+ static PagePresetManager *m_instance;
+
+ PageSizeInfoMap m_pageSizeList;
+ PageCollectionInfoMap m_categoryList;
+ QList m_categoryOrderList;
+
+ LocalizedStringsMap parseNamesBlock(QXmlStreamReader &xml);
+ const QString systemIndexFile();
+ const QString userIndexFile();
+ bool hasValidVersion(const QString &version);
+
+ void addCategory(const PageCollectionInfo &collection);
+ void addPageSize(const PageSizeInfo &info);
+ void loadAllPresets(const QString &indexFilePath, PageSizeType type);
+ void parseCollectionFile(const QString &filePath, PageSizeType type);
+
+ template
+ void updateDisplayName(T &info);
+
+ // Custom preset functions
+ static bool isSizeMatch(const PageSizeInfo &info, const QSizeF &size);
+ static bool updateIndexFile(const QString &collectionFilePath, IndexAction action);
+ static bool loadDocument(const QString &filePath, QDomDocument &doc);
+ static bool saveDocument(const QString &filePath, const QDomDocument &doc);
+ static void setChildText(QDomElement &parent, const QString &tagName, const QString &text);
+
+private slots:
+ void localeChange();
+};
+
+#endif // PAGEPRESET_MANAGER_H
diff --git a/scribus/pagesize.cpp b/scribus/pagesize.cpp
index 166637ac2..fc3395e2c 100644
--- a/scribus/pagesize.cpp
+++ b/scribus/pagesize.cpp
@@ -19,738 +19,22 @@ for which a new license (GPL+exception) is in place.
* *
***************************************************************************/
-#include "commonstrings.h"
#include "pagesize.h"
-#include "prefsmanager.h"
#include
#include
PageSize::PageSize(const QString& sizeName)
{
- init(sizeName);
+ m_pageInfo = PagePresetManager::instance().pageInfoByName(sizeName);
}
PageSize::PageSize(double w, double h)
- : m_width(w),
- m_height(h)
{
- m_pageSizeName = CommonStrings::customPageSize;
- m_trPageSizeName = CommonStrings::trCustomPageSize;
+ m_pageInfo = PagePresetManager::instance().pageInfoByDimensions(QSizeF(w, h));
}
PageSize& PageSize::operator=(const PageSize& other)
{
- init(other.name());
+ m_pageInfo = PagePresetManager::instance().pageInfoByDimensions(QSizeF(other.width(), other.height()));
return *this;
-}
-
-void PageSize::init(const QString& sizeName)
-{
- m_width = 0.0;
- m_height = 0.0;
- m_pageUnitIndex = -1;
- m_pageSizeName.clear();
- m_trPageSizeName.clear();
-
- bool valuesSet = false;
- generateSizeList();
- //Build based on untranslated key value
- if (m_pageSizeList.contains(sizeName))
- {
- auto it = m_pageSizeList.constFind(sizeName);
- m_pageSizeName = it.key();
- m_width = it.value().width;
- m_height = it.value().height;
- m_pageUnitIndex = it.value().pageUnitIndex;
- m_trPageSizeName = it.value().trSizeName;
- m_category = it.value().category;
- valuesSet = true;
- }
- else //build based on translated value.
- {
- for (auto it = m_pageSizeList.cbegin(); it != m_pageSizeList.cend() && !valuesSet; ++it)
- {
- if (sizeName == it.value().trSizeName)
- {
- m_pageSizeName = it.key();
- m_width = it.value().width;
- m_height = it.value().height;
- m_pageUnitIndex = it.value().pageUnitIndex;
- m_trPageSizeName = it.value().trSizeName;
- m_category = it.value().category;
- valuesSet = true;
- }
- }
- }
-
- if (!valuesSet)
- {
- //qDebug("Non-existent page size selected");
- m_width = 0.0;
- m_height = 0.0;
- m_pageUnitIndex = -1;
- m_pageSizeName = CommonStrings::customPageSize;
- m_trPageSizeName = CommonStrings::trCustomPageSize;
- m_category = PageSizeInfo::Custom;
- }
-}
-
-QStringList PageSize::defaultSizesList()
-{
- return { "IsoA_A03", "IsoA_A04", "IsoA_A05", "IsoA_A06", "US_Letter" };
-}
-
-PageSizeCategoriesMap PageSize::categories() const
-{
- PageSizeCategoriesMap map;
-
- for (auto it = m_pageSizeList.begin(); it != m_pageSizeList.end(); ++it)
- map.insert(it.value().category, categoryToString(it.value().category));
-
- return map;
-}
-
-PageSizeInfoMap PageSize::sizesByCategory(PageSizeInfo::Category category) const
-{
- PageSizeInfoMap map;
-
- for (auto it = m_pageSizeList.begin(); it != m_pageSizeList.end(); ++it)
- {
- if (it.value().category == category)
- map.insert(it.value().sizeName, it.value());
- }
-
- return map;
-}
-
-PageSizeInfoMap PageSize::sizesByDimensions(QSize sizePt) const
-{
- PageSizeInfoMap map;
-
- for (auto it = m_pageSizeList.begin(); it != m_pageSizeList.end(); ++it)
- {
- if (it.value().width == sizePt.width() && it.value().height == sizePt.height())
- map.insert(it.value().sizeName, it.value());
- }
-
- return map;
-}
-
-PageSizeInfoMap PageSize::activePageSizes() const
-{
- PageSizeInfoMap map;
- if (PrefsManager::instance().appPrefs.activePageSizes.count() == 0)
- return pageSizes();
-
- QStringList activeList(PrefsManager::instance().appPrefs.activePageSizes);
-
- for (auto it = m_pageSizeList.begin(); it != m_pageSizeList.end(); ++it)
- {
- if (activeList.contains(it.value().sizeName))
- map.insert(it.value().sizeName, it.value());
- }
-
- return map;
-}
-
-void PageSize::addPageSize(const QString id, const QString name, double width, double height, int unitIndex, PageSizeInfo::Category category)
-{
-
- struct PageSizeInfo info;
- QString unit;
-
- switch (unitIndex)
- {
- case SC_C: // cicero
- info.width = c2pts(width);
- info.height = c2pts(height);
- unit = "c";
- break;
- case SC_CM: // centimeter
- info.width = cm2pts(width);
- info.height = cm2pts(height);
- unit = "cm";
- break;
- case SC_IN: // inch
- info.width = in2pts(width);
- info.height = in2pts(height);
- unit = "in";
- break;
- case SC_MM: // millimeter
- default:
- info.width = mm2pts(width);
- info.height = mm2pts(height);
- unit = "mm";
- break;
- case SC_P: // picas
- info.width = p2pts(width);
- info.height = p2pts(height);
- unit = "p";
- break;
- }
-
- info.pageUnitIndex = unitIndex;
- info.sizeName = id;
- info.trSizeName = name;
- info.category = category;
- info.sizeLabel = QString("%1 x %2 %3").arg(width).arg(height).arg(unit);
- m_pageSizeList.insert(info.sizeName, info);
-}
-
-void PageSize::addPageSize(const QString id, double width, double height, int unitIndex, PageSizeInfo::Category category)
-{
- addPageSize(id, id, width, height, unitIndex, category);
-}
-
-QString PageSize::categoryToString(PageSizeInfo::Category category) const
-{
- switch (category)
- {
- case PageSizeInfo::Preferred:
- return QObject::tr("Preferred");
- case PageSizeInfo::Custom:
- return CommonStrings::trCustomPageSize;
- case PageSizeInfo::Book:
- return QObject::tr("Books");
- case PageSizeInfo::BusinessCards:
- return QObject::tr("Business Cards");
- case PageSizeInfo::Canadian:
- return QObject::tr("Canadian");
- case PageSizeInfo::Chinese:
- return QObject::tr("Chinese");
- case PageSizeInfo::Colombian:
- return QObject::tr("Colombian");
- case PageSizeInfo::French:
- return QObject::tr("French");
- case PageSizeInfo::German:
- return QObject::tr("German");
- case PageSizeInfo::Imperial:
- return QObject::tr("Imperial");
- case PageSizeInfo::IsoA:
- return QObject::tr("ISO A Paper");
- case PageSizeInfo::IsoB:
- return QObject::tr("ISO B Paper");
- case PageSizeInfo::IsoC:
- return QObject::tr("ISO C Envelope");
- case PageSizeInfo::IsoEnvelope:
- return QObject::tr("International Envelopes");
- case PageSizeInfo::Japanese:
- return QObject::tr("Japanese");
- case PageSizeInfo::Newspaper:
- return QObject::tr("Newspapers");
- case PageSizeInfo::Other:
- return QObject::tr("Others");
- case PageSizeInfo::Swedish:
- return QObject::tr("Swedish");
- case PageSizeInfo::Transitional:
- return QObject::tr("Transitional");
- case PageSizeInfo::USStandard:
- return QObject::tr("US Paper");
- case PageSizeInfo::USPress:
- return QObject::tr("US Press");
- case PageSizeInfo::USEnvelope:
- return QObject::tr("US Envelopes");
- default:
- return "undefined";
- break;
- }
-}
-
-
-void PageSize::generateSizeList()
-{
- // Books
- // https://papersizes.io/books/
- // https://paper-size.com/size/12mo-books-sizes.html
- // https://en.wikipedia.org/wiki/Book_size
- // https://blissetts.com/sizes-stocks-more
- PageSizeInfo::Category catBooks = PageSizeInfo::Book;
- QString prefix = "Book_";
- addPageSize(prefix + "Folio", QObject::tr("Folio"), 12.0, 19.0, SC_IN, catBooks);
- addPageSize(prefix + "4to Quarto", QObject::tr("4to (Quarto)"), 9.5, 12.0, SC_IN, catBooks);
- addPageSize(prefix + "8vo Imperial Octavo", QObject::tr("8vo (Imperial Octavo)"), 8.25, 11.5, SC_IN, catBooks);
- addPageSize(prefix + "8vo Super Octavo", QObject::tr("8vo (Super Octavo)"), 7.0, 11.0, SC_IN, catBooks);
- addPageSize(prefix + "8vo Royal Octavo", QObject::tr("8vo (Royal Octavo)"), 6.25, 10.0, SC_IN, catBooks);
- addPageSize(prefix + "8vo Medium Octavo", QObject::tr("8vo (Medium Octavo)"), 6.5, 9.25, SC_IN, catBooks);
- addPageSize(prefix + "8vo Octavo", QObject::tr("8vo (Octavo)"), 6.0, 9.0, SC_IN, catBooks);
- addPageSize(prefix + "8vo Crown Octavo", QObject::tr("8vo (Crown Octavo)"), 5.375, 8.0, SC_IN, catBooks);
- addPageSize(prefix + "12mo", QObject::tr("12mo (Duodecimo)"), 5.0, 7.375, SC_IN, catBooks);
- addPageSize(prefix + "16mo", QObject::tr("16mo (Sextodecimo)"), 4.0, 6.75, SC_IN, catBooks);
- addPageSize(prefix + "18mo", QObject::tr("18mo (Octodecimo)"), 4.0, 6.5, SC_IN, catBooks);
- addPageSize(prefix + "32mo", QObject::tr("32mo (Tricesimo Secondo)"), 3.5, 5.5, SC_IN, catBooks);
- addPageSize(prefix + "48mo", QObject::tr("48mo (Quadragesimo Octavo)"), 2.5, 4.0, SC_IN, catBooks);
- addPageSize(prefix + "64mo", QObject::tr("64mo (Sexagesimo Quarto)"), 2.0, 3.0, SC_IN, catBooks);
- addPageSize(prefix + "A Format", QObject::tr("A Format"), 4.25, 7.0, SC_IN, catBooks);
- addPageSize(prefix + "B Format", QObject::tr("B Format"), 5.1, 7.75, SC_IN, catBooks);
- addPageSize(prefix + "C Format", QObject::tr("C Format"), 5.25, 8.5, SC_IN, catBooks);
- addPageSize(prefix + "Comic Book", QObject::tr("Comic Book"), 6.63, 10.25, SC_IN, catBooks);
- addPageSize(prefix + "Crown Quarto", QObject::tr("Crown Quarto"), 189, 246, SC_MM, catBooks);
-
- // Business Cards
- // https://papersizes.io/business-card/
- PageSizeInfo::Category catBusinessCards = PageSizeInfo::BusinessCards;
- prefix = "Cards_";
- addPageSize(prefix + "Europe", QObject::tr("Europe"), 55.0, 85.0, SC_MM, catBusinessCards);
- addPageSize(prefix + "ISO 7810 ID-1", QObject::tr("ISO 7810 ID-1"), 54.0, 85.6, SC_MM, catBusinessCards);
- addPageSize(prefix + "US/Canada", QObject::tr("US/Canada"), 2.0, 3.5, SC_IN, catBusinessCards);
- addPageSize(prefix + "China", QObject::tr("China"), 54.0, 90.0, SC_MM, catBusinessCards);
- addPageSize(prefix + "Scandinavia", QObject::tr("Scandinavia"), 55.0, 90.0, SC_MM, catBusinessCards);
- addPageSize(prefix + "Japan", QObject::tr("Japan"), 55.0, 91.0, SC_MM, catBusinessCards);
- addPageSize(prefix + "Hungary", QObject::tr("Hungary"), 50.0, 90.0, SC_MM, catBusinessCards);
- addPageSize(prefix + "Iran", QObject::tr("Iran"), 48.0, 85.0, SC_MM, catBusinessCards);
- addPageSize(prefix + "ISO 216", QObject::tr("ISO 216"), 52.0, 74.0, SC_MM, catBusinessCards);
-
- // Canadian
- // https://papersizes.io/canadian/
- PageSizeInfo::Category catCanadian = PageSizeInfo::Canadian;
- prefix = "CA_";
- addPageSize(prefix + "P1", "P1", 560.0, 860.0, SC_MM, catCanadian);
- addPageSize(prefix + "P2", "P2", 430.0, 560.0, SC_MM, catCanadian);
- addPageSize(prefix + "P3", "P3", 280.0, 430.0, SC_MM, catCanadian);
- addPageSize(prefix + "P4", "P4", 215.0, 280.0, SC_MM, catCanadian);
- addPageSize(prefix + "P5", "P5", 140.0, 215.0, SC_MM, catCanadian);
- addPageSize(prefix + "P6", "P6", 107.0, 140.0, SC_MM, catCanadian);
-
- // Chinese
- // https://papersizes.io/chinese/
- PageSizeInfo::Category catChinese = PageSizeInfo::Chinese;
- prefix = "CN_";
- addPageSize(prefix + "D0", "D0", 764.0, 1064.0, SC_MM, catChinese);
- addPageSize(prefix + "D1", "D1", 532.0, 760.0, SC_MM, catChinese);
- addPageSize(prefix + "D2", "D2", 380.0, 528.0, SC_MM, catChinese);
- addPageSize(prefix + "D3", "D3", 264.0, 375.0, SC_MM, catChinese);
- addPageSize(prefix + "D4", "D4", 188.0, 260.0, SC_MM, catChinese);
- addPageSize(prefix + "D5", "D5", 130.0, 184.0, SC_MM, catChinese);
- addPageSize(prefix + "D6", "D6", 92.0, 126.0, SC_MM, catChinese);
- addPageSize(prefix + "RD0", "RD0", 787.0, 1092.0, SC_MM, catChinese);
- addPageSize(prefix + "RD1", "RD1", 546.0, 787.0, SC_MM, catChinese);
- addPageSize(prefix + "RD2", "RD2", 393.0, 546.0, SC_MM, catChinese);
- addPageSize(prefix + "RD3", "RD3", 273.0, 393.0, SC_MM, catChinese);
- addPageSize(prefix + "RD4", "RD4", 196.0, 273.0, SC_MM, catChinese);
- addPageSize(prefix + "RD5", "RD5", 136.0, 196.0, SC_MM, catChinese);
- addPageSize(prefix + "RD6", "RD6", 98.0, 136.0, SC_MM, catChinese);
-
- // Colombian
- // https://papersizes.io/colombian/
- PageSizeInfo::Category catColombian = PageSizeInfo::Colombian;
- prefix = "CO_";
- addPageSize(prefix + "Carta", "Carta", 216.0, 279.0, SC_MM, catColombian);
- addPageSize(prefix + "Extra Tabloide", "Extra Tabloide", 304.0, 457.2, SC_MM, catColombian);
- addPageSize(prefix + "Oficio", "Oficio", 216.0, 330.0, SC_MM, catColombian);
- addPageSize(prefix + "Pliego", "Pliego", 700.0, 1000.0, SC_MM, catColombian);
- addPageSize(prefix + "1/2 Pliego", "1/2 Pliego", 500.0, 700.0, SC_MM, catColombian);
- addPageSize(prefix + "1/4 Pliego", "1/4 Pliego", 350.0, 500.0, SC_MM, catColombian);
- addPageSize(prefix + "1/8 Pliego", "1/8 Pliego", 250.0, 350.0, SC_MM, catColombian);
-
- // French
- // https://papersizes.io/french/
- PageSizeInfo::Category catFrench = PageSizeInfo::French;
- prefix = "FR_";
- addPageSize(prefix + "Cloche", "Cloche", 300.0, 400.0, SC_MM, catFrench);
- addPageSize(prefix + "Pot ecolier", "Pot, écolier", 310.0, 400.0, SC_MM, catFrench);
- addPageSize(prefix + "Telliere", "Tellière", 340.0, 440.0, SC_MM, catFrench);
- addPageSize(prefix + "Couronne ecriture", "Couronne écriture", 360.0, 360.0, SC_MM, catFrench);
- addPageSize(prefix + "Couronne edition", "Couronne édition", 370.0, 470.0, SC_MM, catFrench);
- addPageSize(prefix + "Roberto", "Roberto", 390.0, 500.0, SC_MM, catFrench);
- addPageSize(prefix + "Ecu", "Écu", 400.0, 520.0, SC_MM, catFrench);
- addPageSize(prefix + "Coquille", "Coquille", 440.0, 560.0, SC_MM, catFrench);
- addPageSize(prefix + "Carre", "Carré", 450.0, 560.0, SC_MM, catFrench);
- addPageSize(prefix + "Cavalier", "Cavalier", 460.0, 620.0, SC_MM, catFrench);
- addPageSize(prefix + "Demi-raisin", "Demi-raisin", 325.0, 500.0, SC_MM, catFrench);
- addPageSize(prefix + "Raisin", "Raisin", 500.0, 650.0, SC_MM, catFrench);
- addPageSize(prefix + "Double Raisin", "Double Raisin", 650.0, 1000.0, SC_MM, catFrench);
- addPageSize(prefix + "Jesus", "Jésus", 560.0, 760.0, SC_MM, catFrench);
- addPageSize(prefix + "Soleil", "Soleil", 600.0, 800.0, SC_MM, catFrench);
- addPageSize(prefix + "Colombier affiche", "Colombier affiche", 600.0, 800.0, SC_MM, catFrench);
- addPageSize(prefix + "Colombier commercial", "Colombier commercial", 630.0, 900.0, SC_MM, catFrench);
- addPageSize(prefix + "Petit Aigle", "Petit Aigle", 700.0, 940.0, SC_MM, catFrench);
- addPageSize(prefix + "Grand Aigle", "Grand Aigle", 750.0, 1050.0, SC_MM, catFrench);
- addPageSize(prefix + "Grand Monde", "Grand Monde", 900.0, 1260.0, SC_MM, catFrench);
- addPageSize(prefix + "Univers", "Univers", 1000.0, 1130.0, SC_MM, catFrench);
-
- // German
- // https://papersizes.io/german/
- // https://www.saxoprint.de/blog/papier/papierformate
- PageSizeInfo::Category catGerman = PageSizeInfo::German;
- prefix = "DE_";
- addPageSize(prefix + "DIN D00", "DIN D0", 771.0, 1090.0, SC_MM, catGerman);
- addPageSize(prefix + "DIN D01", "DIN D1", 545.0, 771.0, SC_MM, catGerman);
- addPageSize(prefix + "DIN D02", "DIN D2", 385.0, 545.0, SC_MM, catGerman);
- addPageSize(prefix + "DIN D03", "DIN D3", 272.0, 385.0, SC_MM, catGerman);
- addPageSize(prefix + "DIN D04", "DIN D4", 192.0, 272.0, SC_MM, catGerman);
- addPageSize(prefix + "DIN D05", "DIN D5", 136.0, 192.0, SC_MM, catGerman);
- addPageSize(prefix + "DIN D06", "DIN D6", 96.0, 136.0, SC_MM, catGerman);
- addPageSize(prefix + "DIN D07", "DIN D7", 68.0, 96.0, SC_MM, catGerman);
- addPageSize(prefix + "DIN D08", "DIN D8", 48.0, 68.0, SC_MM, catGerman);
- addPageSize(prefix + "DIN D09", "DIN D9", 34.0, 48.0, SC_MM, catGerman);
- addPageSize(prefix + "DIN D10", "DIN D10", 24.0, 34.0, SC_MM, catGerman);
-
- // Imperial
- // https://papersdb.com/imperial
- // https://en.wikipedia.org/wiki/Paper_size#Traditional_inch-based_paper_sizes
- PageSizeInfo::Category catImperial = PageSizeInfo::Imperial;
- prefix = "Imp_";
- addPageSize(prefix + "Quarto", QObject::tr("Quarto"), 8.0, 10.0, SC_IN, catImperial); // from 1.6.2
- addPageSize(prefix + "Foolscap", QObject::tr("Foolscap"), 8.0, 13.0, SC_IN, catImperial); // from 1.6.2
- addPageSize(prefix + "Executive", QObject::tr("Executive"), 7.25, 10.5, SC_IN, catImperial); // from 1.6.2
- addPageSize(prefix + "Post", QObject::tr("Post"), 15.5, 19.25, SC_IN, catImperial); // from 1.6.2
- addPageSize(prefix + "Crown", QObject::tr("Crown"), 15.0, 20.0, SC_IN, catImperial); // from 1.6.2
- addPageSize(prefix + "Large Post", QObject::tr("Large Post"), 16.5, 21.0, SC_IN, catImperial); // from 1.6.2
- addPageSize(prefix + "Demy", QObject::tr("Demy"), 17.5, 22.5, SC_IN, catImperial); // from 1.6.2
- addPageSize(prefix + "Medium", QObject::tr("Medium"), 18.0, 23.0, SC_IN, catImperial); // from 1.6.2
- addPageSize(prefix + "Royal", QObject::tr("Royal"), 20.0, 25.0, SC_IN, catImperial); // from 1.6.2
- addPageSize(prefix + "Elephant", QObject::tr("Elephant"), 23.0, 28.0, SC_IN, catImperial); // from 1.6.2
- addPageSize(prefix + "Double Demy", QObject::tr("Double Demy"), 22.5, 35.0, SC_IN, catImperial); // from 1.6.2
- addPageSize(prefix + "Quad Demy", QObject::tr("Quad Demy"), 35.0, 45.0, SC_IN, catImperial); // from 1.6.2
- addPageSize(prefix + "STMT", QObject::tr("STMT"), 5.5, 8.5, SC_IN, catImperial); // from 1.6.2
-
- // ISO A series
- // https://papersizes.io/a/
- PageSizeInfo::Category catIsoA = PageSizeInfo::IsoA;
- prefix = "IsoA_";
- addPageSize(prefix + "2A0", "2A0", 1189.0, 1682.0, SC_MM, catIsoA); // from 1.6.2
- addPageSize(prefix + "4A0", "4A0", 1682.0, 2378.0, SC_MM, catIsoA); // from 1.6.2
- addPageSize(prefix + "A00+", "A0+", 914.0, 1292.0, SC_MM, catIsoA);
- addPageSize(prefix + "A00", "A0", 841.0, 1189.0, SC_MM, catIsoA); // from 1.6.2
- addPageSize(prefix + "A01+", "A1+", 609.0, 914.0, SC_MM, catIsoA);
- addPageSize(prefix + "A01", "A1", 594.0, 841.0, SC_MM, catIsoA); // from 1.6.2
- addPageSize(prefix + "A02", "A2", 420.0, 594.0, SC_MM, catIsoA); // from 1.6.2
- addPageSize(prefix + "A03+", "A3+", 329.0, 483.0, SC_MM, catIsoA);
- addPageSize(prefix + "A03", "A3", 297.0, 420.0, SC_MM, catIsoA); // from 1.6.2
- addPageSize(prefix + "A04", "A4", 210.0, 297.0, SC_MM, catIsoA); // from 1.6.2
- addPageSize(prefix + "A05", "A5", 148.0, 210.0, SC_MM, catIsoA); // from 1.6.2
- addPageSize(prefix + "A06", "A6", 105.0, 148.0, SC_MM, catIsoA); // from 1.6.2
- addPageSize(prefix + "A07", "A7", 74.0, 105.0, SC_MM, catIsoA); // from 1.6.2
- addPageSize(prefix + "A08", "A8", 52.0, 74.0, SC_MM, catIsoA); // from 1.6.2
- addPageSize(prefix + "A09", "A9", 37.0, 52.0, SC_MM, catIsoA); // from 1.6.2
- addPageSize(prefix + "A10", "A10", 26.0, 37.0, SC_MM, catIsoA); // from 1.6.2
-
- // ISO B series
- // https://papersizes.io/b/
- PageSizeInfo::Category catIsoB = PageSizeInfo::IsoB;
- prefix = "IsoB_";
- addPageSize(prefix + "B00+", "B0+", 1118.0, 1580.0, SC_MM, catIsoB);
- addPageSize(prefix + "B00", "B0", 1000.0, 1414.0, SC_MM, catIsoB); // from 1.6.2
- addPageSize(prefix + "B01+", "B1+", 720.0, 1020.0, SC_MM, catIsoB);
- addPageSize(prefix + "B01", "B1", 707.0, 1000.0, SC_MM, catIsoB); // from 1.6.2
- addPageSize(prefix + "B02+", "B2+", 520.0, 720.0, SC_MM, catIsoB);
- addPageSize(prefix + "B02", "B2", 500.0, 707.0, SC_MM, catIsoB); // from 1.6.2
- addPageSize(prefix + "B03", "B3", 353.0, 500.0, SC_MM, catIsoB); // from 1.6.2
- addPageSize(prefix + "B04", "B4", 250.0, 353.0, SC_MM, catIsoB); // from 1.6.2
- addPageSize(prefix + "B05", "B5", 176.0, 250.0, SC_MM, catIsoB); // from 1.6.2
- addPageSize(prefix + "B06", "B6", 125.0, 176.0, SC_MM, catIsoB); // from 1.6.2
- addPageSize(prefix + "B07", "B7", 88.0, 125.0, SC_MM, catIsoB); // from 1.6.2
- addPageSize(prefix + "B08", "B8", 62.0, 88.0, SC_MM, catIsoB); // from 1.6.2
- addPageSize(prefix + "B09", "B9", 44.0, 62.0, SC_MM, catIsoB); // from 1.6.2
- addPageSize(prefix + "B10", "B10", 31.0, 44.0, SC_MM, catIsoB); // from 1.6.2
-
- // ISO C series
- // https://papersizes.io/c-envelope/
- PageSizeInfo::Category catIsoC = PageSizeInfo::IsoC;
- prefix = "IsoC_";
- addPageSize(prefix + "C00", "C0", 917.0, 1297.0, SC_MM, catIsoC); // from 1.6.2
- addPageSize(prefix + "C01", "C1", 648.0, 917.0, SC_MM, catIsoC); // from 1.6.2
- addPageSize(prefix + "C02", "C2", 458.0, 648.0, SC_MM, catIsoC); // from 1.6.2
- addPageSize(prefix + "C03", "C3", 324.0, 458.0, SC_MM, catIsoC); // from 1.6.2
- addPageSize(prefix + "C04", "C4", 229.0, 324.0, SC_MM, catIsoC); // from 1.6.2
- addPageSize(prefix + "C05", "C5", 162.0, 229.0, SC_MM, catIsoC); // from 1.6.2
- addPageSize(prefix + "C06", "C6", 114.0, 162.0, SC_MM, catIsoC); // from 1.6.2
- addPageSize(prefix + "C07", "C7", 81.0, 114.0, SC_MM, catIsoC); // from 1.6.2
- addPageSize(prefix + "C08", "C8", 57.0, 81.0, SC_MM, catIsoC); // from 1.6.2
- addPageSize(prefix + "C09", "C9", 40.0, 57.0, SC_MM, catIsoC); // from 1.6.2
- addPageSize(prefix + "C10", "C10", 28.0, 40.0, SC_MM, catIsoC); // from 1.6.2
-
- // ISO Envelopes
- // https://papersizes.io/international-envelope/
- PageSizeInfo::Category catIsoEnvelope = PageSizeInfo::IsoEnvelope;
- prefix = "IsoEnv_";
- addPageSize(prefix + "DL/E65", "DL, E65", 110.0, 220.0, SC_MM, catIsoEnvelope); // from 1.6.2
- // addPageSize(prefix + "B4", "B4", 250.0, 353.0, SC_MM, catIsoEnvelope);
- // addPageSize(prefix + "B5", "B5", 176.0, 250.0, SC_MM, catIsoEnvelope);
- // addPageSize(prefix + "B6", "B6", 125.0, 176.0, SC_MM, catIsoEnvelope);
- // addPageSize(prefix + "C3", "C3", 324.0, 458.0, SC_MM, catIsoEnvelope);
- // addPageSize(prefix + "C4", "C4", 229.0, 324.0, SC_MM, catIsoEnvelope);
- addPageSize(prefix + "C4M", "C4M", 229.0, 318.0, SC_MM, catIsoEnvelope);
- // addPageSize(prefix + "C5", "C5", 162.0, 229.0, SC_MM, catIsoEnvelope);
- addPageSize(prefix + "C6/C5", "C6/C5", 114.0, 229.0, SC_MM, catIsoEnvelope);
- // addPageSize(prefix + "C6", "C6", 114.0, 162.0, SC_MM, catIsoEnvelope);
- addPageSize(prefix + "C64M", "C64M", 114.0, 318.0, SC_MM, catIsoEnvelope);
- // addPageSize(prefix + "C7", "C7", 81.0, 114.0, SC_MM, catIsoEnvelope);
- addPageSize(prefix + "C7/C6", "C7/C6", 81.0, 162.0, SC_MM, catIsoEnvelope);
- addPageSize(prefix + "B6/C4", "B6/C4", 125.0, 324.0, SC_MM, catIsoEnvelope);
- addPageSize(prefix + "E4", "E4", 220.0, 312.0, SC_MM, catIsoEnvelope);
- addPageSize(prefix + "E5", "E5", 115.0, 220.0, SC_MM, catIsoEnvelope);
- addPageSize(prefix + "E56", "E56", 115.0, 115.0, SC_MM, catIsoEnvelope);
- addPageSize(prefix + "E6", "E6", 110.0, 155.0, SC_MM, catIsoEnvelope);
- addPageSize(prefix + "EC45", "EC45", 220.0, 229.0, SC_MM, catIsoEnvelope);
- addPageSize(prefix + "EC5", "EC5", 155.0, 229.0, SC_MM, catIsoEnvelope);
- addPageSize(prefix + "R7", "R7", 120.0, 135.0, SC_MM, catIsoEnvelope);
- addPageSize(prefix + "S4", "S4", 250.0, 330.0, SC_MM, catIsoEnvelope);
- addPageSize(prefix + "S5", "S5", 185.0, 255.0, SC_MM, catIsoEnvelope);
- addPageSize(prefix + "S65", "S65", 110.0, 225.0, SC_MM, catIsoEnvelope);
- addPageSize(prefix + "X5", "X5", 105.0, 216.0, SC_MM, catIsoEnvelope);
- addPageSize(prefix + "EX5", "EX5", 115.0, 216.0, SC_MM, catIsoEnvelope);
-
- // Japanese
- // https://papersizes.io/japanese/
- PageSizeInfo::Category catJapanese = PageSizeInfo::Japanese;
- prefix = "JP_";
- addPageSize(prefix + "JB00", "JB0", 1030.0, 1456.0, SC_MM, catJapanese);
- addPageSize(prefix + "JB01", "JB1", 728.0, 1030.0, SC_MM, catJapanese);
- addPageSize(prefix + "JB02", "JB2", 515.0, 728.0, SC_MM, catJapanese);
- addPageSize(prefix + "JB03", "JB3", 364.0, 515.0, SC_MM, catJapanese);
- addPageSize(prefix + "JB04", "JB4", 257.0, 364.0, SC_MM, catJapanese);
- addPageSize(prefix + "JB05", "JB5", 182.0, 257.0, SC_MM, catJapanese);
- addPageSize(prefix + "JB06", "JB6", 128.0, 182.0, SC_MM, catJapanese);
- addPageSize(prefix + "JB07", "JB7", 91.0, 128.0, SC_MM, catJapanese);
- addPageSize(prefix + "JB08", "JB8", 64.0, 91.0, SC_MM, catJapanese);
- addPageSize(prefix + "JB09", "JB9", 45.0, 64.0, SC_MM, catJapanese);
- addPageSize(prefix + "JB10", "JB10", 32.0, 45.0, SC_MM, catJapanese);
- addPageSize(prefix + "JB11", "JB11", 22.0, 32.0, SC_MM, catJapanese);
- addPageSize(prefix + "JB12", "JB12", 16.0, 22.0, SC_MM, catJapanese);
- addPageSize(prefix + "Shiroku ban 4", "Shiroku ban 4", 264.0, 379.0, SC_MM, catJapanese);
- addPageSize(prefix + "Shiroku ban 5", "Shiroku ban 5", 189.0, 262.0, SC_MM, catJapanese);
- addPageSize(prefix + "Shiroku ban 6", "Shiroku ban 6", 127.0, 188.0, SC_MM, catJapanese);
- addPageSize(prefix + "Kiku 4", "Kiku 4", 227.0, 306.0, SC_MM, catJapanese);
- addPageSize(prefix + "Kiku 5", "Kiku 5", 151.0, 227.0, SC_MM, catJapanese);
-
- // Newspaper
- // https://papersizes.io/newspaper/
- // https://en.wikipedia.org/wiki/Broadsheet
- // https://www.papersizes.org/
- PageSizeInfo::Category catNewspaper = PageSizeInfo::Newspaper;
- prefix = "News_";
- // Broadsheet
- addPageSize(prefix + "AU/NZ Broadsheet", QObject::tr("AU/NZ Broadsheet"), 420.0, 594.0, SC_MM, catNewspaper);
- addPageSize(prefix + "Berliner Broadsheet", QObject::tr("Berliner Broadsheet"), 315.0, 470.0, SC_MM, catNewspaper);
- addPageSize(prefix + "Ciner", QObject::tr("Ciner"), 350.0, 500.0, SC_MM, catNewspaper);
- addPageSize(prefix + "New York Times", QObject::tr("New York Times"), 12.0, 22.0, SC_IN, catNewspaper);
- addPageSize(prefix + "Nordisch Broadsheet", QObject::tr("Nordisch Broadsheet"), 400.0, 570.0, SC_MM, catNewspaper);
- addPageSize(prefix + "Rhenish Broadsheet", QObject::tr("Rhenish Broadsheet"), 350.0, 520.0, SC_MM, catNewspaper);
- addPageSize(prefix + "SA Broadsheet", QObject::tr("SA Broadsheet"), 410.0, 578.0, SC_MM, catNewspaper);
- addPageSize(prefix + "Swiss Broadsheet", QObject::tr("Swiss Broadsheet"), 320.0, 475.0, SC_MM, catNewspaper);
- addPageSize(prefix + "UK Broadsheet", QObject::tr("UK Broadsheet"), 375.0, 597.0, SC_MM, catNewspaper);
- addPageSize(prefix + "US Broadsheet", QObject::tr("US Broadsheet"), 15.0, 22.75, SC_IN, catNewspaper);
- addPageSize(prefix + "Wall Street Journal", QObject::tr("Wall Street Journal"), 12.0, 22.75, SC_IN, catNewspaper);
- // Tabloids
- addPageSize(prefix + "Berliner Tabloid", QObject::tr("Berliner Tabloid"), 235.0, 315.0, SC_MM, catNewspaper);
- addPageSize(prefix + "Canadian Tabloid", QObject::tr("Canadian Tabloid"), 260.0, 368.0, SC_MM, catNewspaper);
- addPageSize(prefix + "Canadian Tall Tabloid", QObject::tr("Canadian Tall Tabloid"), 260.0, 413.0, SC_MM, catNewspaper);
- addPageSize(prefix + "Nordisch Tabloid", QObject::tr("Nordisch Tabloid"), 285.0, 400.0, SC_MM, catNewspaper);
- addPageSize(prefix + "Norwegian Tabloid", QObject::tr("Norwegian Tabloid"), 280.0, 400.0, SC_MM, catNewspaper);
- addPageSize(prefix + "Rhenish Tabloid", QObject::tr("Rhenish Tabloid"), 260.0, 350.0, SC_MM, catNewspaper);
- addPageSize(prefix + "UK Tabloid", QObject::tr("UK Tabloid"), 280.0, 430.0, SC_MM, catNewspaper);
- addPageSize(prefix + "Compact", QObject::tr("Compact"), 280.0, 430.0, SC_MM, catNewspaper);
-
- // Swedish
- // https://papersizes.io/swedish/
- PageSizeInfo::Category catSwedish = PageSizeInfo::Swedish;
- prefix = "SE_";
- addPageSize(prefix + "SIS D00", "SIS D0", 1091.0, 1542.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS D01", "SIS D1", 771.0, 1091.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS D02", "SIS D2", 545.0, 771.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS D03", "SIS D3", 386.0, 545.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS D04", "SIS D4", 273.0, 386.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS D05", "SIS D5", 193.0, 273.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS D06", "SIS D6", 136.0, 193.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS D07", "SIS D7", 96.0, 136.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS D08", "SIS D8", 68.0, 96.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS D09", "SIS D9", 48.0, 68.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS D10", "SIS D10", 34.0, 48.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS E00", "SIS E0", 878.0, 1242.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS E01", "SIS E1", 621.0, 878.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS E02", "SIS E2", 439.0, 621.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS E03", "SIS E3", 310.0, 439.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS E04", "SIS E4", 220.0, 310.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS E05", "SIS E5", 155.0, 220.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS E06", "SIS E6", 110.0, 155.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS E07", "SIS E7", 78.0, 110.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS E08", "SIS E8", 55.0, 78.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS E09", "SIS E9", 39.0, 55.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS E10", "SIS E10", 27.0, 39.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS F00", "SIS F0", 958.0, 1354.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS F01", "SIS F1", 677.0, 958.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS F02", "SIS F2", 479.0, 677.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS F03", "SIS F3", 339.0, 479.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS F04", "SIS F4", 239.0, 339.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS F05", "SIS F5", 169.0, 239.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS F06", "SIS F6", 120.0, 169.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS F07", "SIS F7", 85.0, 120.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS F08", "SIS F8", 60.0, 85.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS F09", "SIS F9", 42.0, 60.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS F10", "SIS F10", 30.0, 42.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS G00", "SIS G0", 1044.0, 1477.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS G01", "SIS G1", 738.0, 1044.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS G02", "SIS G2", 522.0, 738.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS G03", "SIS G3", 369.0, 522.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS G04", "SIS G4", 261.0, 369.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS G05", "SIS G5", 185.0, 261.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS G06", "SIS G6", 131.0, 185.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS G07", "SIS G7", 92.0, 131.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS G08", "SIS G8", 65.0, 92.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS G09", "SIS G9", 46.0, 65.0, SC_MM, catSwedish);
- addPageSize(prefix + "SIS G10", "SIS G10", 33.0, 46.0, SC_MM, catSwedish);
-
- // Transitional
- PageSizeInfo::Category catTransitional = PageSizeInfo::Transitional;
- prefix = "Trans_";
- addPageSize(prefix + "F00", "F0", 841.0, 1321.0, SC_MM, catTransitional);
- addPageSize(prefix + "F01", "F1", 660.0, 841.0, SC_MM, catTransitional);
- addPageSize(prefix + "F02", "F2", 420.0, 660.0, SC_MM, catTransitional);
- addPageSize(prefix + "F03", "F3", 330.0, 420.0, SC_MM, catTransitional);
- addPageSize(prefix + "F04", "F4", 210.0, 330.0, SC_MM, catTransitional);
- addPageSize(prefix + "F05", "F5", 165.0, 210.0, SC_MM, catTransitional);
- addPageSize(prefix + "F06", "F6", 105.0, 165.0, SC_MM, catTransitional);
- addPageSize(prefix + "F07", "F7", 82.0, 105.0, SC_MM, catTransitional);
- addPageSize(prefix + "F08", "F8", 52.0, 82.0, SC_MM, catTransitional);
- addPageSize(prefix + "F09", "F9", 41.0, 52.0, SC_MM, catTransitional);
- addPageSize(prefix + "F10", "F10", 26.0, 41.0, SC_MM, catTransitional);
- addPageSize(prefix + "PA00", "PA0", 840.0, 1120.0, SC_MM, catTransitional); // from 1.6.2
- addPageSize(prefix + "PA01", "PA1", 560.0, 840.0, SC_MM, catTransitional); // from 1.6.2
- addPageSize(prefix + "PA02", "PA2", 420.0, 560.0, SC_MM, catTransitional); // from 1.6.2
- addPageSize(prefix + "PA03", "PA3", 280.0, 420.0, SC_MM, catTransitional); // from 1.6.2
- addPageSize(prefix + "PA04", "PA4", 210.0, 280.0, SC_MM, catTransitional); // from 1.6.2
- addPageSize(prefix + "PA05", "PA5", 140.0, 210.0, SC_MM, catTransitional); // from 1.6.2
- addPageSize(prefix + "PA06", "PA6", 105.0, 140.0, SC_MM, catTransitional); // from 1.6.2
- addPageSize(prefix + "PA07", "PA7", 70.0, 105.0, SC_MM, catTransitional); // from 1.6.2
- addPageSize(prefix + "PA08", "PA8", 52.0, 70.0, SC_MM, catTransitional); // from 1.6.2
- addPageSize(prefix + "PA09", "PA9", 35.0, 52.0, SC_MM, catTransitional); // from 1.6.2
- addPageSize(prefix + "PA10", "PA10", 26.0, 35.0, SC_MM, catTransitional); // from 1.6.2
-
-
- // US Paper Size
- // https://papersizes.io/us/
- PageSizeInfo::Category catUSStandard = PageSizeInfo::USStandard;
- prefix = "US_";
- addPageSize(prefix + "Government Legal", "Government Legal", 8.5, 13.0, SC_IN, catUSStandard);
- addPageSize(prefix + "Legal", "Legal", 8.5, 14.0, SC_IN, catUSStandard); // from 1.6.2
- addPageSize(prefix + "Legal Half", "Legal Half", 7.0, 8.5, SC_IN, catUSStandard);
- addPageSize(prefix + "Junior Legal", "Junior Legal", 5.0, 8.0, SC_IN, catUSStandard);
- addPageSize(prefix + "Letter", "Letter", 8.5, 11.0, SC_IN, catUSStandard); // from 1.6.2
- addPageSize(prefix + "Letter Half", "Letter Half", 5.5, 8.5, SC_IN, catUSStandard); // from 1.6.2
- addPageSize(prefix + "Government Letter", "Government Letter", 8.0, 10.5, SC_IN, catUSStandard); // from 1.6.2
- addPageSize(prefix + "Ledger", "Ledger, Tabloid", 11.0, 17.0, SC_IN, catUSStandard); // from 1.6.2
- addPageSize(prefix + "ANSI A", "ANSI A", 8.5, 11.0, SC_IN, catUSStandard); // from 1.6.2
- addPageSize(prefix + "ANSI B", "ANSI B", 11.0, 17.0, SC_IN, catUSStandard); // from 1.6.2
- addPageSize(prefix + "ANSI C", "ANSI C", 17.0, 22.0, SC_IN, catUSStandard); // from 1.6.2
- addPageSize(prefix + "ANSI D", "ANSI D", 22.0, 34.0, SC_IN, catUSStandard); // from 1.6.2
- addPageSize(prefix + "ANSI E", "ANSI E", 34.0, 44.0, SC_IN, catUSStandard); // from 1.6.2
- addPageSize(prefix + "Arch A", "Arch A", 9.0, 12.0, SC_IN, catUSStandard); // from 1.6.2
- addPageSize(prefix + "Arch B", "Arch B", 12.0, 18.0, SC_IN, catUSStandard); // from 1.6.2
- addPageSize(prefix + "Arch C", "Arch C", 18.0, 24.0, SC_IN, catUSStandard); // from 1.6.2
- addPageSize(prefix + "Arch D", "Arch D", 24.0, 36.0, SC_IN, catUSStandard); // from 1.6.2
- addPageSize(prefix + "Arch E", "Arch E", 36.0, 48.0, SC_IN, catUSStandard); // from 1.6.2
- addPageSize(prefix + "Arch E1", "Arch E1", 30.0, 42.0, SC_IN, catUSStandard); // from 1.6.2
- addPageSize(prefix + "Arch E2", "Arch E2", 26.0, 38.0, SC_IN, catUSStandard); // from 1.6.2
- addPageSize(prefix + "Arch E3", "Arch E3", 27.0, 39.0, SC_IN, catUSStandard); // from 1.6.2
-
- // US Common Press
- // https://papersdb.com/common-us-press-sheet
- PageSizeInfo::Category catUSPress = PageSizeInfo::USPress;
- prefix = "USPress_";
- addPageSize(prefix + "11x17", "11x17", 11.0, 17.0, SC_IN, catUSPress); // from 1.6.2
- addPageSize(prefix + "12x18", "12x18", 12.0, 18.0, SC_IN, catUSPress);
- addPageSize(prefix + "17x22", "17x22", 17.0, 22.0, SC_IN, catUSPress);
- addPageSize(prefix + "19x25", "19x25", 19.0, 25.0, SC_IN, catUSPress);
- addPageSize(prefix + "20x26", "20x26", 20.0, 26.0, SC_IN, catUSPress);
- addPageSize(prefix + "23x29", "23x29", 23.0, 29.0, SC_IN, catUSPress);
- addPageSize(prefix + "23x35", "23x35", 23.0, 35.0, SC_IN, catUSPress);
-// addPageSize(prefix + "24x36", "24x36", 24.0, 36.0, SC_IN, catUSPress);
- addPageSize(prefix + "25x38", "25x38", 25.0, 38.0, SC_IN, catUSPress);
- addPageSize(prefix + "26x40", "26x40", 26.0, 40.0, SC_IN, catUSPress);
- addPageSize(prefix + "28x40", "28x40", 28.0, 40.0, SC_IN, catUSPress);
- addPageSize(prefix + "35x45", "38x45", 35.0, 45.0, SC_IN, catUSPress);
- addPageSize(prefix + "38x50", "38x50", 38.0, 50.0, SC_IN, catUSPress);
-
- // US Envelope
- // https://papersdb.com/us-baronial-envelope
- // https://www.wsel.com/envelopes/standard-sizes
- PageSizeInfo::Category catUSEnvelope = PageSizeInfo::USEnvelope;
- prefix = "USEnv_";
- addPageSize(prefix + "A01", "A-1", 3.625, 5.125, SC_IN, catUSEnvelope);
- addPageSize(prefix + "A02", "A-2 (Lady Grey)", 4.375, 5.75, SC_IN, catUSEnvelope);
- addPageSize(prefix + "A04", "A-4", 4.25, 6.25, SC_IN, catUSEnvelope);
- addPageSize(prefix + "A06", "A-6 (Thompson Standard)", 4.75, 6.5, SC_IN, catUSEnvelope);
- addPageSize(prefix + "A07", "A-7 (Besselheim)", 5.25, 7.25, SC_IN, catUSEnvelope);
- addPageSize(prefix + "A08", "A-8 (Carrs)", 5.5, 8.125, SC_IN, catUSEnvelope);
- addPageSize(prefix + "A09", "A-9 (Diplomat)", 5.75, 8.75, SC_IN, catUSEnvelope);
- addPageSize(prefix + "A10", "A-10 (Willow)", 6.0, 9.5, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Baronial 04", "Baronial 4", 3.625, 5.125, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Baronial 05 1/2", "Baronial 5 1/2", 4.375, 5.75, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Baronial 06", "Baronial 6", 4.75, 6.5, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Baronial Lee", "Lee", 5.25, 7.25, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Booklet 03", "Booklet 3", 4.75, 6.0, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Booklet 04 1/2", "Booklet 4 1/2", 5.5, 7.5, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Booklet 06", "Booklet 6", 5.75, 8.875, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Booklet 06 1/2", "Booklet 6 1/2", 6.0, 9.0, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Booklet 06 7/8", "Booklet 6 7/8", 6.0, 9.5, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Booklet 06 3/4", "Booklet 6 3/4", 6.5, 9.5, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Booklet 07 1/2", "Booklet 7 1/2", 7.5, 10.5, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Booklet 09", "Booklet 9", 8.75, 11.5, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Booklet 09 1/2", "Booklet 9 1/2", 9.0, 12.0, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Booklet 10", "Booklet 10", 9.5, 12.625, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Booklet 13", "Booklet 13", 10.0, 13.0, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Catalog 01", "Catalog 1", 6.0, 9.0, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Catalog 01 3/4", "Catalog 1 3/4", 6.5, 9.5, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Catalog 03", "Catalog 3", 7.0, 10.0, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Catalog 06", "Catalog 6", 7.5, 10.5, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Catalog 08", "Catalog 8", 8.25, 11.25, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Catalog 09 3/4", "Catalog 9 3/4", 8.75, 11.25, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Catalog 10 1/2", "Catalog 10 1/2", 9.0, 12.0, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Catalog 12 1/5", "Catalog 12 1/5", 9.5, 12.5, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Catalog 13 1/2", "Catalog 13 1/2", 10.0, 13.0, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Catalog 14 1/2", "Catalog 14 1/2", 11.5, 14.5, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Catalog 15", "Catalog 15", 10.0, 15.0, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Catalog 15 1/2", "Catalog 15 1/2", 12.0, 15.5, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Commerical 05", "Commerical 5", 3.125, 5.5, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Commerical 06 1/4", "Commerical 6 1/4", 3.5, 6.0, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Commerical 06 3/4", "Commerical 6 3/4", 3.625, 6.5, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Commerical 07", "Commerical 7", 3.75, 6.75, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Commerical 07 1/2", "Commerical 7 1/2", 3.9375, 7.5, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Commerical 08 5/8", "Commerical 8 5/8", 3.625, 8.625, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Commerical 09", "Commerical 9", 3.875, 8.875, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Commerical 10", "Commerical 10", 4.125, 9.5, SC_IN, catUSEnvelope); // from 1.6.2
- addPageSize(prefix + "Commerical 11", "Commerical 11", 4.5, 10.375, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Commerical 12", "Commerical 12", 4.75, 11, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Commerical 14", "Commerical 14", 5.0, 11.5, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Square 06", "Square 6", 6.0, 6.0, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Square 06 1/2", "Square 6 1/2", 6.5, 6.5, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Square 07", "Square 7", 7.0, 7.0, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Square 07 1/2", "Square 7 1/2", 7.5, 7.5, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Square 08", "Square 8", 8.0, 8.0, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Square 08 1/2", "Square 8 1/2", 8.5, 8.5, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Square 09", "Square 9", 9.0, 9.0, SC_IN, catUSEnvelope);
- addPageSize(prefix + "Square 09 1/2", "Square 9 1/2", 9.5, 9.5, SC_IN, catUSEnvelope);
-
- // Other Formats
- // https://www.template.net/graphic-design/album-cover-sizes/
- // https://print.dvdcover.com/dvd-blu-ray-cover-size.php
- // https://www.duplication.com/printspecs/k7insertspecs.htm
- // https://tapemuzik.de/shop/paper-products/cover-without-flap/?lang=en
- PageSizeInfo::Category catOther = PageSizeInfo::Other;
- prefix = "Other_";
- addPageSize(prefix + "Blu-Ray Cover (5 mm)", QObject::tr("Blu-Ray Cover (5 mm)"), 148.0, 257.0, SC_MM, catOther);
- addPageSize(prefix + "Blu-Ray Cover (12 mm)", QObject::tr("Blu-Ray Cover (12 mm)"), 148.0, 264.0, SC_MM, catOther);
- addPageSize(prefix + "Blu-Ray Cover (14 mm)", QObject::tr("Blu-Ray Cover (14 mm)"), 148.0, 266.0, SC_MM, catOther);
- addPageSize(prefix + "Blu-Ray Cover (24 mm)", QObject::tr("Blu-Ray Cover (24 mm)"), 148.0, 276.0, SC_MM, catOther);
- addPageSize(prefix + "Cassette Cover (J-Card)", QObject::tr("Cassette Cover (J-Card)"), 101.5, 105.0, SC_MM, catOther);
- addPageSize(prefix + "Cassette Cover (U-Card)", QObject::tr("Cassette Cover (U-Card)"), 101.5, 140.9, SC_MM, catOther);
- addPageSize(prefix + "Compact Disc (Front)", QObject::tr("Compact Disc (Front)"), 120.0, 120.0, SC_MM, catOther); // from 1.6.2
- addPageSize(prefix + "Compact Disc (Back)", QObject::tr("Compact Disc (Back)"), 118.0, 151.0, SC_MM, catOther);
- addPageSize(prefix + "Compact Disc (Front Double)", QObject::tr("Compact Disc (Front Double)"), 120.0, 240.0, SC_MM, catOther);
- addPageSize(prefix + "Vinyl LP", QObject::tr("Vinyl LP"), 314.3, 314.3, SC_MM, catOther);
- addPageSize(prefix + "DVD Cover Normal", QObject::tr("DVD Cover Normal"), 183.0, 273.0, SC_MM, catOther);
- addPageSize(prefix + "DVD Cover Slim", QObject::tr("DVD Cover Slim"), 183.0, 266.0, SC_MM, catOther);
-}
-
-void PageSize::printSizeList() const
-{
- for (auto it = m_pageSizeList.begin(); it != m_pageSizeList.end(); ++it)
- {
- std::cout << it.key().leftJustified(6).toStdString() << ": ";
- std::cout << it.value().width << " x " << it.value().height << ", ";
- std::cout << it.value().width * unitGetRatioFromIndex(it.value().pageUnitIndex) << " x " << it.value().height * unitGetRatioFromIndex(it.value().pageUnitIndex) << ", ";
- std::cout << it.value().trSizeName.toStdString() << categoryToString(it.value().category).toStdString() << std::endl;
- }
-}
-
+}
\ No newline at end of file
diff --git a/scribus/pagesize.h b/scribus/pagesize.h
index 1507212f2..91963da8e 100644
--- a/scribus/pagesize.h
+++ b/scribus/pagesize.h
@@ -27,51 +27,7 @@ for which a new license (GPL+exception) is in place.
#include
#include "scribusapi.h"
#include "units.h"
-
-struct PageSizeInfo
-{
- enum Category {
-
- Custom = 0, // don't use for presets, it is reserved for custom sizes
- Preferred = 1, // don't use for presets, it is reserved for user favorite sizes
-
- IsoA = 10,
- IsoB = 11,
- IsoC = 12,
- IsoEnvelope = 13,
-
- USStandard = 20,
- USPress = 21,
- USEnvelope = 22,
-
- Book = 30,
- BusinessCards = 31,
- Newspaper = 32,
- Transitional = 33,
-
- Other = 40,
-
- Canadian = 50,
- Chinese = 51,
- Colombian = 52,
- French = 53,
- German = 54,
- Imperial = 55,
- Japanese = 56,
- Swedish = 57,
- };
-
- double width;
- double height;
- QString trSizeName;
- QString sizeName;
- QString sizeLabel;
- int pageUnitIndex;
- Category category;
-};
-
-using PageSizeInfoMap = QMap;
-using PageSizeCategoriesMap = QMap;
+#include "manager/pagepreset_manager.h"
class SCRIBUS_API PageSize
{
@@ -80,36 +36,17 @@ public:
PageSize(double, double);
PageSize& operator=(const PageSize& other);
- void init(const QString&);
- const QString& name() const { return m_pageSizeName; }
- const QString& nameTR() const { return m_trPageSizeName; }
- PageSizeInfo::Category category() const { return m_category; };
- QString categoryToString(PageSizeInfo::Category category) const;
- double width() const { return m_width; }
- double height() const { return m_height; }
- double originalWidth() const { return m_width * unitGetRatioFromIndex(m_pageUnitIndex); }
- double originalHeight() const { return m_height * unitGetRatioFromIndex(m_pageUnitIndex); }
- QString originalUnit() const { return unitGetSuffixFromIndex(m_pageUnitIndex); }
- static QStringList defaultSizesList();
- PageSizeCategoriesMap categories() const;
- PageSizeInfoMap sizesByCategory(PageSizeInfo::Category category) const;
- PageSizeInfoMap sizesByDimensions(QSize sizePt) const;
- PageSizeInfoMap activePageSizes() const;
- const PageSizeInfoMap& pageSizes() const { return m_pageSizeList; };
- void printSizeList() const;
+ const QString& name() const { return m_pageInfo.id; }
+ const QString& nameTR() const { return m_pageInfo.displayName; }
+ QString categoryId() const { return m_pageInfo.categoryId; }
+ double width() const { return m_pageInfo.width; }
+ double height() const { return m_pageInfo.height; }
+ double originalWidth() const { return width() * unitGetRatioFromIndex(m_pageInfo.pageUnitIndex); }
+ double originalHeight() const { return height() * unitGetRatioFromIndex(m_pageInfo.pageUnitIndex); }
+ QString originalUnit() const { return unitGetSuffixFromIndex(m_pageInfo.pageUnitIndex); }
private:
- PageSizeInfoMap m_pageSizeList;
- double m_width { 0.0 };
- double m_height { 0.0 };
- int m_pageUnitIndex { -1 };
- QString m_pageSizeName;
- QString m_trPageSizeName;
- PageSizeInfo::Category m_category {PageSizeInfo::Custom};
-
- void generateSizeList();
- void addPageSize(const QString id, double width, double height, int unitIndex, PageSizeInfo::Category category);
- void addPageSize(const QString id, const QString name, double width, double height, int unitIndex, PageSizeInfo::Category category);
+ PageSizeInfo m_pageInfo;
};
#endif
diff --git a/scribus/plugins/fileloader/scribus171format/scribus171format.cpp b/scribus/plugins/fileloader/scribus171format/scribus171format.cpp
index 039f0dea8..b0147de70 100644
--- a/scribus/plugins/fileloader/scribus171format/scribus171format.cpp
+++ b/scribus/plugins/fileloader/scribus171format/scribus171format.cpp
@@ -2529,7 +2529,7 @@ void Scribus171Format::readDocAttributes(ScribusDoc* doc, const ScXmlStreamAttri
//Remove uppercase in 1.8
if (attrs.hasAttribute("PAGESIZE"))
{
- m_Doc->setPageSize(attrs.valueAsString("PAGESIZE"));
+ // m_Doc->setPageSize(attrs.valueAsString("PAGESIZE"));
m_Doc->setPageOrientation(attrs.valueAsInt("ORIENTATION", 0));
m_Doc->FirstPnum = attrs.valueAsInt("FIRSTNUM", 1);
m_Doc->setPagePositioning(attrs.valueAsInt("BOOK", 0));
@@ -2570,6 +2570,9 @@ void Scribus171Format::readDocAttributes(ScribusDoc* doc, const ScXmlStreamAttri
m_Doc->setHyphAutoCheck(attrs.valueAsBool("AUTOCHECK", false));
m_Doc->GuideLock = attrs.valueAsBool("GUIDELOCK", false);
+ PageSize ps = PageSize(m_Doc->pageWidth(), m_Doc->pageHeight());
+ m_Doc->setPageSize(ps.name());
+
m_Doc->rulerXoffset = attrs.valueAsDouble("rulerXoffset", 0.0);
m_Doc->rulerYoffset = attrs.valueAsDouble("rulerYoffset", 0.0);
m_Doc->SnapGuides = attrs.valueAsBool("SnapToGuides", false);
@@ -2596,7 +2599,7 @@ void Scribus171Format::readDocAttributes(ScribusDoc* doc, const ScXmlStreamAttri
}
else
{
- m_Doc->setPageSize(attrs.valueAsString("PageSize"));
+ // m_Doc->setPageSize(attrs.valueAsString("PageSize"));
m_Doc->setPageOrientation(attrs.valueAsInt("PageOrientation", 0));
m_Doc->FirstPnum = attrs.valueAsInt("FirstPageNumber", 1);
m_Doc->setPagePositioning(attrs.valueAsInt("PagePositioning", 0));
@@ -4733,8 +4736,6 @@ bool Scribus171Format::readPage(ScribusDoc* doc, ScXmlStreamReader& reader)
else
mpName = attrs.valueAsString("MasterPageName", "Normal");
newPage->setMasterPageName(m_Doc->masterPageMode() ? QString() : mpName);
- if (attrs.hasAttribute("Size"))
- newPage->setSize(attrs.valueAsString("Size"));
if (attrs.hasAttribute("Orientation"))
newPage->setOrientation(attrs.valueAsInt("Orientation"));
@@ -4762,16 +4763,8 @@ bool Scribus171Format::readPage(ScribusDoc* doc, ScXmlStreamReader& reader)
else
newPage->setHeight(attrs.valueAsDouble("PageHeight"));
- //14704: Double check the page size should not be Custom in case the size doesn't match a standard size
- if (attrs.hasAttribute("Size"))
- {
- QString pageSize(attrs.valueAsString("Size"));
- PageSize ps(pageSize);
- if (!compareDouble(ps.width(), newPage->width()) || !compareDouble(ps.height(), newPage->height()))
- newPage->setSize(CommonStrings::customPageSize);
- else
- newPage->setSize(pageSize);
- }
+ PageSize ps(newPage->width(), newPage->height());
+ newPage->setSize(ps.name());
newPage->setInitialHeight(newPage->height());
newPage->setInitialWidth(newPage->width());
diff --git a/scribus/plugins/fileloader/scribus171format/scribus171format_save.cpp b/scribus/plugins/fileloader/scribus171format/scribus171format_save.cpp
index 58eedbb8a..bf53e2482 100644
--- a/scribus/plugins/fileloader/scribus171format/scribus171format_save.cpp
+++ b/scribus/plugins/fileloader/scribus171format/scribus171format_save.cpp
@@ -333,7 +333,7 @@ bool Scribus171Format::saveFile(const QString & fileName, const FileFormat & /*
docu.writeAttribute("BleedRight", m_Doc->bleeds()->right());
docu.writeAttribute("BleedBottom", m_Doc->bleeds()->bottom());
docu.writeAttribute("PageOrientation", m_Doc->pageOrientation());
- docu.writeAttribute("PageSize", m_Doc->pageSize());
+ // docu.writeAttribute("PageSize", m_Doc->pageSize());
docu.writeAttribute("FirstPageNumber", m_Doc->FirstPnum);
docu.writeAttribute("PagePositioning", m_Doc->pagePositioning());
docu.writeAttribute("BindingDirection", m_Doc->bindingDirection());
@@ -1722,7 +1722,7 @@ void Scribus171Format::WritePages(ScribusDoc *doc, ScXmlStreamWriter& docu, QPro
docu.writeAttribute("PageNumber",page->pageNr());
docu.writeAttribute("PageName",page->pageName());
docu.writeAttribute("MasterPageName",page->masterPageName());
- docu.writeAttribute("Size", page->size());
+ // docu.writeAttribute("Size", page->size());
docu.writeAttribute("Orientation", page->orientation());
docu.writeAttribute("LeftPage", page->LeftPg);
docu.writeAttribute("Preset", page->marginPreset);
diff --git a/scribus/plugins/import/ai/importai.cpp b/scribus/plugins/import/ai/importai.cpp
index 8c7436750..ba982cb4b 100644
--- a/scribus/plugins/import/ai/importai.cpp
+++ b/scribus/plugins/import/ai/importai.cpp
@@ -137,7 +137,7 @@ QImage AIPlug::readThumbnail(const QString& fNameIn)
baseX = 0;
baseY = 0;
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -239,7 +239,7 @@ bool AIPlug::readColors(const QString& fileName, ColorList & colors)
docWidth = b - x;
docHeight = h - y;
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -375,7 +375,7 @@ bool AIPlug::importFile(const QString& fNameIn, const TransactionSettings& trSet
}
else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(b - x, h - y, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(b - x, h - y, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
ret = true;
baseX = 0;
diff --git a/scribus/plugins/import/cdr/importcdr.cpp b/scribus/plugins/import/cdr/importcdr.cpp
index 865639883..10acec2a6 100644
--- a/scribus/plugins/import/cdr/importcdr.cpp
+++ b/scribus/plugins/import/cdr/importcdr.cpp
@@ -50,7 +50,7 @@ QImage CdrPlug::readThumbnail(const QString& fName)
docHeight = PrefsManager::instance().appPrefs.docSetupPrefs.pageHeight;
progressDialog = nullptr;
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -154,7 +154,7 @@ bool CdrPlug::importFile(const QString& fNameIn, const TransactionSettings& trSe
}
else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
ret = true;
baseX = 0;
diff --git a/scribus/plugins/import/cgm/importcgm.cpp b/scribus/plugins/import/cgm/importcgm.cpp
index c286e0b28..62a4db1c0 100644
--- a/scribus/plugins/import/cgm/importcgm.cpp
+++ b/scribus/plugins/import/cgm/importcgm.cpp
@@ -96,7 +96,7 @@ QImage CgmPlug::readThumbnail(const QString& fName)
docHeight = h;
progressDialog = nullptr;
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -198,7 +198,7 @@ bool CgmPlug::importFile(const QString& fNameIn, const TransactionSettings& trSe
}
else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
ret = true;
baseX = 0;
diff --git a/scribus/plugins/import/cvg/importcvg.cpp b/scribus/plugins/import/cvg/importcvg.cpp
index 3eff126c1..a80283b36 100644
--- a/scribus/plugins/import/cvg/importcvg.cpp
+++ b/scribus/plugins/import/cvg/importcvg.cpp
@@ -56,7 +56,7 @@ QImage CvgPlug::readThumbnail(const QString& fName)
docHeight = h;
progressDialog = nullptr;
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -163,7 +163,7 @@ bool CvgPlug::importFile(const QString& fNameIn, const TransactionSettings& trSe
}
else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
ret = true;
baseX = 0;
diff --git a/scribus/plugins/import/drw/importdrw.cpp b/scribus/plugins/import/drw/importdrw.cpp
index df1b52b77..492efa826 100644
--- a/scribus/plugins/import/drw/importdrw.cpp
+++ b/scribus/plugins/import/drw/importdrw.cpp
@@ -62,7 +62,7 @@ QImage DrwPlug::readThumbnail(const QString& fName)
docHeight = h;
progressDialog = nullptr;
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -174,7 +174,7 @@ bool DrwPlug::importFile(const QString& fNameIn, const TransactionSettings& trSe
}
else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
ret = true;
baseX = 0;
diff --git a/scribus/plugins/import/emf/importemf.cpp b/scribus/plugins/import/emf/importemf.cpp
index 56d273689..ebb11a096 100644
--- a/scribus/plugins/import/emf/importemf.cpp
+++ b/scribus/plugins/import/emf/importemf.cpp
@@ -438,7 +438,7 @@ QImage EmfPlug::readThumbnail(const QString& fName)
baseY = 0;
progressDialog = nullptr;
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -580,7 +580,7 @@ bool EmfPlug::importFile(const QString& fNameIn, const TransactionSettings& trSe
}
else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
m_Doc->setPageHeight(docHeight);
m_Doc->setPageWidth(docWidth);
diff --git a/scribus/plugins/import/fh/importfh.cpp b/scribus/plugins/import/fh/importfh.cpp
index 692ed705e..18016062d 100644
--- a/scribus/plugins/import/fh/importfh.cpp
+++ b/scribus/plugins/import/fh/importfh.cpp
@@ -56,7 +56,7 @@ QImage FhPlug::readThumbnail(const QString& fName)
docHeight = h;
progressDialog = nullptr;
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -160,7 +160,7 @@ bool FhPlug::importFile(const QString& fNameIn, const TransactionSettings& trSet
}
else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
ret = true;
baseX = 0;
diff --git a/scribus/plugins/import/idml/importidml.cpp b/scribus/plugins/import/idml/importidml.cpp
index c11605736..41030bb0f 100644
--- a/scribus/plugins/import/idml/importidml.cpp
+++ b/scribus/plugins/import/idml/importidml.cpp
@@ -152,7 +152,7 @@ QImage IdmlPlug::readThumbnail(const QString& fName)
docWidth = PrefsManager::instance().appPrefs.docSetupPrefs.pageWidth;
docHeight = PrefsManager::instance().appPrefs.docSetupPrefs.pageHeight;
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -236,7 +236,7 @@ bool IdmlPlug::readColors(const QString& fileName, ColorList & colors)
}
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(1, 1, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -333,7 +333,7 @@ bool IdmlPlug::importFile(const QString& fNameIn, const TransactionSettings& trS
}
else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
ret = true;
baseX = 0;
diff --git a/scribus/plugins/import/odg/importodg.cpp b/scribus/plugins/import/odg/importodg.cpp
index a4d50919d..5abe11a3c 100644
--- a/scribus/plugins/import/odg/importodg.cpp
+++ b/scribus/plugins/import/odg/importodg.cpp
@@ -172,7 +172,7 @@ bool OdgPlug::importFile(const QString& fNameIn, const TransactionSettings& trSe
}
else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
ret = true;
baseX = 0;
diff --git a/scribus/plugins/import/oodraw/oodrawimp.cpp b/scribus/plugins/import/oodraw/oodrawimp.cpp
index 564c65614..5d3d420ef 100644
--- a/scribus/plugins/import/oodraw/oodrawimp.cpp
+++ b/scribus/plugins/import/oodraw/oodrawimp.cpp
@@ -292,7 +292,7 @@ QImage OODPlug::readThumbnail(const QString& fileName)
double width = !properties.attribute( "fo:page-width" ).isEmpty() ? parseUnit(properties.attribute( "fo:page-width" ) ) : 550.0;
double height = !properties.attribute( "fo:page-height" ).isEmpty() ? parseUnit(properties.attribute( "fo:page-height" ) ) : 841.0;
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(width, height, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -438,7 +438,7 @@ bool OODPlug::convert(const TransactionSettings& trSettings, int flags)
{
if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(width, height, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(width, height, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
ret = true;
}
diff --git a/scribus/plugins/import/pages/importpages.cpp b/scribus/plugins/import/pages/importpages.cpp
index 6da51f793..f899a44b4 100644
--- a/scribus/plugins/import/pages/importpages.cpp
+++ b/scribus/plugins/import/pages/importpages.cpp
@@ -236,7 +236,7 @@ bool PagesPlug::importFile(const QString& fNameIn, const TransactionSettings& tr
}
else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
ret = true;
baseX = 0;
diff --git a/scribus/plugins/import/pct/importpct.cpp b/scribus/plugins/import/pct/importpct.cpp
index 743996832..f0233977b 100644
--- a/scribus/plugins/import/pct/importpct.cpp
+++ b/scribus/plugins/import/pct/importpct.cpp
@@ -62,7 +62,7 @@ QImage PctPlug::readThumbnail(const QString& fName)
docHeight = h;
progressDialog = nullptr;
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -176,7 +176,7 @@ bool PctPlug::importFile(const QString& fNameIn, const TransactionSettings& trSe
}
else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
m_Doc->setPageHeight(docHeight);
m_Doc->setPageWidth(docWidth);
diff --git a/scribus/plugins/import/pdf/importpdf.cpp b/scribus/plugins/import/pdf/importpdf.cpp
index 8b52ef75f..12967f229 100644
--- a/scribus/plugins/import/pdf/importpdf.cpp
+++ b/scribus/plugins/import/pdf/importpdf.cpp
@@ -166,7 +166,7 @@ bool PdfPlug::importFile(const QString& fNameIn, const TransactionSettings& trSe
}
else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, 0, 0, 0, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, 0, 0, 0, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
ret = true;
}
diff --git a/scribus/plugins/import/pm/importpm.cpp b/scribus/plugins/import/pm/importpm.cpp
index a822b4ff4..69bd07fab 100644
--- a/scribus/plugins/import/pm/importpm.cpp
+++ b/scribus/plugins/import/pm/importpm.cpp
@@ -49,7 +49,7 @@ QImage PmPlug::readThumbnail(const QString& fName)
docHeight = PrefsManager::instance().appPrefs.docSetupPrefs.pageHeight;
progressDialog = nullptr;
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -153,7 +153,7 @@ bool PmPlug::importFile(const QString& fNameIn, const TransactionSettings& trSet
}
else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
ret = true;
baseX = 0;
diff --git a/scribus/plugins/import/pub/importpub.cpp b/scribus/plugins/import/pub/importpub.cpp
index 78c366ab7..85811f4b2 100644
--- a/scribus/plugins/import/pub/importpub.cpp
+++ b/scribus/plugins/import/pub/importpub.cpp
@@ -53,7 +53,7 @@ QImage PubPlug::readThumbnail(const QString& fName)
docHeight = PrefsManager::instance().appPrefs.docSetupPrefs.pageHeight;
progressDialog = nullptr;
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -157,7 +157,7 @@ bool PubPlug::importFile(const QString& fNameIn, const TransactionSettings& trSe
}
else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
ret = true;
baseX = 0;
diff --git a/scribus/plugins/import/qxp/importqxp.cpp b/scribus/plugins/import/qxp/importqxp.cpp
index a60b0077e..ff96fb046 100644
--- a/scribus/plugins/import/qxp/importqxp.cpp
+++ b/scribus/plugins/import/qxp/importqxp.cpp
@@ -67,7 +67,7 @@ QImage QxpPlug::readThumbnail(const QString& fName)
docHeight = h;
progressDialog = nullptr;
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -174,7 +174,7 @@ bool QxpPlug::importFile(const QString& fNameIn, const TransactionSettings& trSe
}
else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
ret = true;
baseX = 0;
diff --git a/scribus/plugins/import/shape/importshape.cpp b/scribus/plugins/import/shape/importshape.cpp
index ace2abc44..510621f2f 100644
--- a/scribus/plugins/import/shape/importshape.cpp
+++ b/scribus/plugins/import/shape/importshape.cpp
@@ -62,7 +62,7 @@ QImage ShapePlug::readThumbnail(const QString& fName)
docHeight = h;
progressDialog = nullptr;
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -168,7 +168,7 @@ bool ShapePlug::importFile(const QString& fNameIn, const TransactionSettings& tr
}
else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
ret = true;
baseX = 0;
diff --git a/scribus/plugins/import/sml/importsml.cpp b/scribus/plugins/import/sml/importsml.cpp
index e990fe854..e2dd155a2 100644
--- a/scribus/plugins/import/sml/importsml.cpp
+++ b/scribus/plugins/import/sml/importsml.cpp
@@ -68,7 +68,7 @@ QImage SmlPlug::readThumbnail(const QString& fName)
docHeight = h;
progressDialog = nullptr;
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -174,7 +174,7 @@ bool SmlPlug::importFile(const QString& fNameIn, const TransactionSettings& trSe
}
else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
ret = true;
baseX = 0;
diff --git a/scribus/plugins/import/svg/svgplugin.cpp b/scribus/plugins/import/svg/svgplugin.cpp
index 6544929c7..c5da3d372 100644
--- a/scribus/plugins/import/svg/svgplugin.cpp
+++ b/scribus/plugins/import/svg/svgplugin.cpp
@@ -244,7 +244,7 @@ QImage SVGPlug::readThumbnail(const QString& fName)
QDomElement docElem = inpdoc.documentElement();
QSizeF wh = parseWidthHeight(docElem);
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(wh.width(), wh.height(), 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -424,7 +424,7 @@ void SVGPlug::convert(const TransactionSettings& trSettings, int flags)
{
if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(width, height, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(width, height, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
ret = true;
}
diff --git a/scribus/plugins/import/svm/importsvm.cpp b/scribus/plugins/import/svm/importsvm.cpp
index 98a7292e1..d049b3d11 100644
--- a/scribus/plugins/import/svm/importsvm.cpp
+++ b/scribus/plugins/import/svm/importsvm.cpp
@@ -308,7 +308,7 @@ QImage SvmPlug::readThumbnail(const QString& fName)
baseY = 0;
progressDialog = nullptr;
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -451,7 +451,7 @@ bool SvmPlug::importFile(const QString& fNameIn, const TransactionSettings& trSe
}
else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
m_Doc->setPageHeight(docHeight);
m_Doc->setPageWidth(docWidth);
diff --git a/scribus/plugins/import/viva/importviva.cpp b/scribus/plugins/import/viva/importviva.cpp
index 409179e92..ca4e999e6 100644
--- a/scribus/plugins/import/viva/importviva.cpp
+++ b/scribus/plugins/import/viva/importviva.cpp
@@ -112,7 +112,7 @@ QImage VivaPlug::readThumbnail(const QString& fName)
docWidth = PrefsManager::instance().appPrefs.docSetupPrefs.pageWidth;
docHeight = PrefsManager::instance().appPrefs.docSetupPrefs.pageHeight;
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -162,7 +162,7 @@ bool VivaPlug::readColors(const QString& fileName, ColorList & colors)
{
bool success = false;
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(1, 1, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -247,7 +247,7 @@ bool VivaPlug::importFile(const QString& fNameIn, const TransactionSettings& trS
}
else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
ret = true;
baseX = 0;
diff --git a/scribus/plugins/import/vsd/importvsd.cpp b/scribus/plugins/import/vsd/importvsd.cpp
index 982853b1b..4472c71c5 100644
--- a/scribus/plugins/import/vsd/importvsd.cpp
+++ b/scribus/plugins/import/vsd/importvsd.cpp
@@ -62,7 +62,7 @@ QImage VsdPlug::readThumbnail(const QString& fName)
docHeight = h;
progressDialog = nullptr;
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -166,7 +166,7 @@ bool VsdPlug::importFile(const QString& fNameIn, const TransactionSettings& trSe
}
else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
ret = true;
baseX = 0;
diff --git a/scribus/plugins/import/wmf/wmfimport.cpp b/scribus/plugins/import/wmf/wmfimport.cpp
index efd975563..4f868e6dd 100644
--- a/scribus/plugins/import/wmf/wmfimport.cpp
+++ b/scribus/plugins/import/wmf/wmfimport.cpp
@@ -301,7 +301,7 @@ QImage WMFImport::readThumbnail(const QString& fname)
double width = m_BBox.width() * scale;
double height = m_BBox.height() * scale;
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(width, height, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -564,7 +564,7 @@ bool WMFImport::importWMF(const TransactionSettings& trSettings, int flags)
}
else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(fabs(width), fabs(height), 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(fabs(width), fabs(height), 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
ret = true;
}
diff --git a/scribus/plugins/import/wpg/importwpg.cpp b/scribus/plugins/import/wpg/importwpg.cpp
index 63a43d37c..fdc631a4f 100644
--- a/scribus/plugins/import/wpg/importwpg.cpp
+++ b/scribus/plugins/import/wpg/importwpg.cpp
@@ -416,7 +416,7 @@ QImage WpgPlug::readThumbnail(const QString& fName)
docHeight = PrefsManager::instance().appPrefs.docSetupPrefs.pageHeight;
progressDialog = nullptr;
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -520,7 +520,7 @@ bool WpgPlug::importFile(const QString& fNameIn, const TransactionSettings& trSe
}
else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
ret = true;
baseX = 0;
diff --git a/scribus/plugins/import/xar/importxar.cpp b/scribus/plugins/import/xar/importxar.cpp
index 1f2a17ba5..c2d706317 100644
--- a/scribus/plugins/import/xar/importxar.cpp
+++ b/scribus/plugins/import/xar/importxar.cpp
@@ -78,7 +78,7 @@ bool XarPlug::readColors(const QString& fileName, ColorList & colors)
return false;
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -283,7 +283,7 @@ bool XarPlug::importFile(const QString& fNameIn, const TransactionSettings& trSe
}
else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
ret = true;
baseX = m_Doc->currentPage()->xOffset() - x;
diff --git a/scribus/plugins/import/xfig/importxfig.cpp b/scribus/plugins/import/xfig/importxfig.cpp
index ed2175a08..e944d6a6d 100644
--- a/scribus/plugins/import/xfig/importxfig.cpp
+++ b/scribus/plugins/import/xfig/importxfig.cpp
@@ -67,7 +67,7 @@ QImage XfigPlug::readThumbnail(const QString& fName)
docHeight = h - y;
progressDialog = nullptr;
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -304,7 +304,7 @@ bool XfigPlug::importFile(const QString& fNameIn, const TransactionSettings& trS
}
else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(b - x, h - y, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(b - x, h - y, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
ret = true;
baseX = 0;
diff --git a/scribus/plugins/import/xps/importxps.cpp b/scribus/plugins/import/xps/importxps.cpp
index 2c115b1f1..bb308c522 100644
--- a/scribus/plugins/import/xps/importxps.cpp
+++ b/scribus/plugins/import/xps/importxps.cpp
@@ -120,7 +120,7 @@ QImage XpsPlug::readThumbnail(const QString& fName)
docWidth = PrefsManager::instance().appPrefs.docSetupPrefs.pageWidth;
docHeight = PrefsManager::instance().appPrefs.docSetupPrefs.pageHeight;
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -237,7 +237,7 @@ bool XpsPlug::importFile(const QString& fNameIn, const TransactionSettings& trSe
}
else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
ret = true;
baseX = 0;
diff --git a/scribus/plugins/import/zmf/importzmf.cpp b/scribus/plugins/import/zmf/importzmf.cpp
index b0786172b..94ae57b1d 100644
--- a/scribus/plugins/import/zmf/importzmf.cpp
+++ b/scribus/plugins/import/zmf/importzmf.cpp
@@ -59,7 +59,7 @@ QImage ZmfPlug::readThumbnail(const QString& fName)
docHeight = h;
progressDialog = nullptr;
m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
@@ -166,7 +166,7 @@ bool ZmfPlug::importFile(const QString& fNameIn, const TransactionSettings& trSe
}
else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
{
- m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
ScCore->primaryMainWindow()->HaveNewDoc();
ret = true;
baseX = 0;
diff --git a/scribus/plugins/scriptplugin/cmddoc.cpp b/scribus/plugins/scriptplugin/cmddoc.cpp
index f016824bc..4849a09d1 100644
--- a/scribus/plugins/scriptplugin/cmddoc.cpp
+++ b/scribus/plugins/scriptplugin/cmddoc.cpp
@@ -65,7 +65,7 @@ PyObject *scribus_newdocument(PyObject* /* self */, PyObject* args)
// columnDistance, numberCols, autoframes,
0, 1, false,
pagesType, unit, firstPageOrder,
- orientation, firstPageNr, "Custom", true,
+ orientation, firstPageNr, QSizeF(), true,
numPages, true, 0, bindingDirection);
ScCore->primaryMainWindow()->doc->setPageSetFirstPage(pagesType, firstPageOrder);
@@ -102,7 +102,7 @@ PyObject *scribus_newdoc(PyObject* /* self */, PyObject* args)
lr = value2pts(lr, unit);
rr = value2pts(rr, unit);
btr = value2pts(btr, unit);
- bool ret = ScCore->primaryMainWindow()->doFileNew(b, h, tpr, lr, rr, btr, 0, 1, false, ds, unit, fsl, ori, fNr, "Custom", true);
+ bool ret = ScCore->primaryMainWindow()->doFileNew(b, h, tpr, lr, rr, btr, 0, 1, false, ds, unit, fsl, ori, fNr, QSizeF(), true);
// qApp->processEvents();
return PyLong_FromLong(static_cast(ret));
}
diff --git a/scribus/plugins/shapes/shapepalette.cpp b/scribus/plugins/shapes/shapepalette.cpp
index d230204b2..cf0dfa5ed 100644
--- a/scribus/plugins/shapes/shapepalette.cpp
+++ b/scribus/plugins/shapes/shapepalette.cpp
@@ -217,7 +217,7 @@ void ShapeView::startDrag(Qt::DropActions supportedActions)
int w = shapes.value(key).width;
int h = shapes.value(key).height;
ScribusDoc *m_Doc = new ScribusDoc();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(w, h, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, scMW, nullptr);
diff --git a/scribus/prefsmanager.cpp b/scribus/prefsmanager.cpp
index ffe3a3a00..d7626af75 100644
--- a/scribus/prefsmanager.cpp
+++ b/scribus/prefsmanager.cpp
@@ -42,6 +42,7 @@ for which a new license (GPL+exception) is in place.
#include "latexhelpers.h"
#include "langmgr.h"
#include "localemgr.h"
+#include "manager/pagepreset_manager.h"
#include "pagesize.h"
#include "pagestructs.h"
#include "pdfoptions.h"
@@ -325,9 +326,9 @@ void PrefsManager::initDefaults()
appPrefs.docSetupPrefs.language = "en_GB";
appPrefs.docSetupPrefs.pageSize = LocaleManager::instance().pageSizeForLocale(ScQApp->currGUILanguage());
appPrefs.docSetupPrefs.pageOrientation = 0;
- PageSize defaultPageSize(appPrefs.docSetupPrefs.pageSize);
- appPrefs.docSetupPrefs.pageWidth = defaultPageSize.width();
- appPrefs.docSetupPrefs.pageHeight = defaultPageSize.height();
+ PageSizeInfo psi = PagePresetManager::instance().pageInfoByName(appPrefs.docSetupPrefs.pageSize);
+ appPrefs.docSetupPrefs.pageWidth = psi.width;
+ appPrefs.docSetupPrefs.pageHeight = psi.height;
appPrefs.docSetupPrefs.margins.set(40, 40, 40, 40);
appPrefs.docSetupPrefs.marginPreset = 0;
appPrefs.docSetupPrefs.bleeds.set(0, 0, 0, 0);
@@ -538,7 +539,7 @@ void PrefsManager::initDefaults()
appPrefs.imageCachePrefs.maxCacheEntries = 1000;
appPrefs.imageCachePrefs.compressionLevel = 1;
appPrefs.activePageSizes.clear();
- appPrefs.activePageSizes = PageSize::defaultSizesList();
+ appPrefs.activePageSizes = PagePresetManager::defaultSizesList();
//Attribute setup
appPrefs.itemAttrPrefs.defaultItemAttributes.clear();
@@ -1383,8 +1384,8 @@ bool PrefsManager::writePref(const QString& filePath)
deDocumentSetup.setAttribute("UnitIndex", appPrefs.docSetupPrefs.docUnitIndex);
deDocumentSetup.setAttribute("PageSize", appPrefs.docSetupPrefs.pageSize);
deDocumentSetup.setAttribute("PageOrientation", appPrefs.docSetupPrefs.pageOrientation);
- deDocumentSetup.setAttribute("PageWidth", ScCLocale::toQStringC(appPrefs.docSetupPrefs.pageWidth));
- deDocumentSetup.setAttribute("PageHeight", ScCLocale::toQStringC(appPrefs.docSetupPrefs.pageHeight));
+ deDocumentSetup.setAttribute("PageWidth", appPrefs.docSetupPrefs.pageWidth);
+ deDocumentSetup.setAttribute("PageHeight", appPrefs.docSetupPrefs.pageHeight);
deDocumentSetup.setAttribute("MarginTop", ScCLocale::toQStringC(appPrefs.docSetupPrefs.margins.top()));
deDocumentSetup.setAttribute("MarginBottom", ScCLocale::toQStringC(appPrefs.docSetupPrefs.margins.bottom()));
deDocumentSetup.setAttribute("MarginLeft", ScCLocale::toQStringC(appPrefs.docSetupPrefs.margins.left()));
@@ -2083,11 +2084,11 @@ bool PrefsManager::readPref(const QString& filePath)
if (appPrefs.docSetupPrefs.language.isEmpty())
appPrefs.docSetupPrefs.language = "en_GB";
appPrefs.docSetupPrefs.docUnitIndex = dc.attribute("UnitIndex", "0").toInt();
- PageSize ps( dc.attribute("PageSize", PageSize::defaultSizesList().at(1)) );
- appPrefs.docSetupPrefs.pageSize = (ps.name() == CommonStrings::customPageSize ) ? PageSize::defaultSizesList().at(1) : ps.name();
+ PageSizeInfo psi = PagePresetManager::instance().pageInfoByName(dc.attribute("PageSize", PagePresetManager::defaultSizesList().at(1)));
+ appPrefs.docSetupPrefs.pageSize = (psi.id.isEmpty() || psi.id == CommonStrings::customPageSize ) ? PagePresetManager::defaultSizesList().at(1) : psi.id;
appPrefs.docSetupPrefs.pageOrientation = dc.attribute("PageOrientation", "0").toInt();
- appPrefs.docSetupPrefs.pageWidth = ScCLocale::toDoubleC(dc.attribute("PageWidth"), 595.0);
- appPrefs.docSetupPrefs.pageHeight = ScCLocale::toDoubleC(dc.attribute("PageHeight"), 842.0);
+ appPrefs.docSetupPrefs.pageWidth = ScCLocale::toDoubleC(dc.attribute("PageWidth"), mm2pts(210));
+ appPrefs.docSetupPrefs.pageHeight = ScCLocale::toDoubleC(dc.attribute("PageHeight"), mm2pts(297));
appPrefs.docSetupPrefs.margins.setTop(ScCLocale::toDoubleC(dc.attribute("MarginTop"), 9.0));
appPrefs.docSetupPrefs.margins.setBottom(ScCLocale::toDoubleC(dc.attribute("MarginBottom"), 40.0));
appPrefs.docSetupPrefs.margins.setLeft(ScCLocale::toDoubleC(dc.attribute("MarginLeft"), 9.0));
@@ -2819,12 +2820,12 @@ bool PrefsManager::readPref(const QString& filePath)
// check if page sizes existing
for (const auto& item : std::as_const(appPrefs.activePageSizes))
{
- PageSize ps(item);
- if (ps.name() != CommonStrings::customPageSize)
- checkedPageSizes.append(ps.name());
+ PageSizeInfo psi = PagePresetManager::instance().pageInfoByName(item);
+ if (!psi.id.isEmpty() || psi.id != CommonStrings::customPageSize)
+ checkedPageSizes.append(psi.id);
}
- appPrefs.activePageSizes = (checkedPageSizes.count() == 0) ? PageSize::defaultSizesList() : checkedPageSizes;
+ appPrefs.activePageSizes = (checkedPageSizes.count() == 0) ? PagePresetManager::defaultSizesList() : checkedPageSizes;
}
// experimental features
diff --git a/scribus/sampleitem.cpp b/scribus/sampleitem.cpp
index 691994b08..807b34f88 100644
--- a/scribus/sampleitem.cpp
+++ b/scribus/sampleitem.cpp
@@ -28,7 +28,7 @@ SampleItem::SampleItem()
if (!m_Doc)
return;
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(1, 1, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
diff --git a/scribus/scpaths.cpp b/scribus/scpaths.cpp
index 4addf4af1..ac9fe8f5a 100644
--- a/scribus/scpaths.cpp
+++ b/scribus/scpaths.cpp
@@ -80,6 +80,7 @@ ScPaths::ScPaths()
m_docDir = appPath + "/../" + QString(DOCDIR);
m_iconDir = appPath + "/../" + QString(ICONDIR);
m_libDir = appPath + "/../" + QString(LIBDIR);
+ m_pagePresetsDir = appPath + "/../" + QString(PAGEPRESETSDIR);
m_pluginDir = appPath + "/../" + QString(PLUGINDIR);
m_qmlDir = appPath + "/../" + QString(QMLDIR);
m_sampleScriptDir = appPath + "/../" + QString(SAMPLESDIR);
@@ -90,6 +91,7 @@ ScPaths::ScPaths()
m_docDir = QString(DOCDIR);
m_iconDir = QString(ICONDIR);
m_libDir = QString(LIBDIR);
+ m_pagePresetsDir = QString(PAGEPRESETSDIR);
m_pluginDir = QString(PLUGINDIR);
m_qmlDir = QString(QMLDIR);
m_sampleScriptDir = QString(SAMPLESDIR);
@@ -111,6 +113,7 @@ ScPaths::ScPaths()
m_scriptDir = QString("%1/Contents/share/scribus/scripts/").arg(pathPtr);
m_templateDir = QString("%1/Contents/share/scribus/templates/").arg(pathPtr);
m_libDir = QString("%1/Contents/lib/").arg(pathPtr);
+ m_pagePresetsDir = QString("%1/Contents/share/scribus/pagepresets/").arg(pathPtr);
m_pluginDir = QString("%1/Contents/lib/").arg(pathPtr);
m_qmlDir = QString("%1/Contents/share/scribus/qml/").arg(pathPtr);
//QApplication::setLibraryPaths(QStringList(QString("%1/Contents/lib/qtplugins/").arg(pathPtr)));
@@ -123,6 +126,7 @@ ScPaths::ScPaths()
qDebug() << QString("scpaths: script dir=%1").arg(m_scriptDir);
qDebug() << QString("scpaths: template dir=%1").arg(m_templateDir);
qDebug() << QString("scpaths: lib dir=%1").arg(m_libDir);
+ qDebug() << QString("scpaths: pagepresets dir=%1").arg(m_pagePresetsDir);
qDebug() << QString("scpaths: plugin dir=%1").arg(m_pluginDir);
qDebug() << QString("scpaths: QML dir=%1").arg(m_qmlDir);
qDebug() << QString("scpaths: qtplugins=%1").arg(QApplication::libraryPaths().join(":"));
@@ -142,6 +146,7 @@ ScPaths::ScPaths()
m_scriptDir = QString("%1/share/scripts/").arg(appPath);
m_templateDir = QString("%1/share/templates/").arg(appPath);
m_libDir = QString("%1/libs/").arg(appPath);
+ m_pagePresetsDir = QString("%1/share/pagepresets/").arg(appPath);
m_pluginDir = QString("%1/plugins/").arg(appPath);
m_qmlDir = QString("%1/share/qml/").arg(appPath);
@@ -249,6 +254,11 @@ const QString& ScPaths::libDir() const
return m_libDir;
}
+const QString& ScPaths::pagePresetsDir() const
+{
+ return m_pagePresetsDir;
+}
+
const QString& ScPaths::pluginDir() const
{
return m_pluginDir;
@@ -618,6 +628,14 @@ QString ScPaths::userHelpFilesDir(bool createIfNotExists)
return useFilesDirectory.absolutePath() + "/";
}
+QString ScPaths::userPagePresetsDir(bool createIfNotExists)
+{
+ QDir useFilesDirectory(applicationDataDir() + "pagepresets/");
+ if (createIfNotExists && !useFilesDirectory.exists())
+ useFilesDirectory.mkpath(useFilesDirectory.absolutePath());
+ return useFilesDirectory.absolutePath() + "/";
+}
+
QString ScPaths::userPaletteFilesDir(bool createIfNotExists)
{
QDir useFilesDirectory(applicationDataDir() + "palettes/");
diff --git a/scribus/scpaths.h b/scribus/scpaths.h
index e4f1f918b..053ea7049 100644
--- a/scribus/scpaths.h
+++ b/scribus/scpaths.h
@@ -39,6 +39,8 @@ public:
const QString& fontDir() const;
/** @brief Return path to lib directory containing translations, keysets, etc. */
const QString& libDir() const;
+ /** @brief Return path to page preset directory containing page presets */
+ const QString& pagePresetsDir() const;
/** @brief Return path to dir containing plugins. */
const QString& pluginDir() const;
/** @brief Return path to dir containing sample Python scripts */
@@ -81,6 +83,8 @@ public:
static QString userFontDir(bool createIfNotExists);
/** @brief Return path to application data dir for downloaded docs*/
static QString userHelpFilesDir(bool createIfNotExists);
+ /** @brief Return path to page preset dir for custom page presets */
+ static QString userPagePresetsDir(bool createIfNotExists);
/** @brief Return path to application data dir for downloaded palettes */
static QString userPaletteFilesDir(bool createIfNotExists);
/** @brief Return path to user template dir */
@@ -121,6 +125,7 @@ protected:
QString m_fontDir;
QString m_iconDir;
QString m_libDir;
+ QString m_pagePresetsDir;
QString m_pluginDir;
QString m_qmlDir;
QString m_sampleScriptDir;
diff --git a/scribus/scpreview.cpp b/scribus/scpreview.cpp
index 31ff1db79..01799cef2 100644
--- a/scribus/scpreview.cpp
+++ b/scribus/scpreview.cpp
@@ -48,7 +48,7 @@ QImage ScPreview::createPreview(const QString& data)
}
auto m_Doc = std::make_unique();
- m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
m_Doc->setPage(gw, gh, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, ScCore->primaryMainWindow(), nullptr);
diff --git a/scribus/scribus.cpp b/scribus/scribus.cpp
index c31325027..29a746ed0 100644
--- a/scribus/scribus.cpp
+++ b/scribus/scribus.cpp
@@ -113,6 +113,7 @@ for which a new license (GPL+exception) is in place.
#include "langmgr.h"
#include "localemgr.h"
#include "loadsaveplugin.h"
+#include "manager/pagepreset_manager.h"
#include "marks.h"
#include "nfttemplate.h"
#include "notesstyles.h"
@@ -121,7 +122,6 @@ for which a new license (GPL+exception) is in place.
#include "pageitem_latexframe.h"
#include "pageitem_table.h"
#include "pageitem_textframe.h"
-#include "pagesize.h"
#include "pdflib.h"
#include "pdfoptions.h"
#include "pluginmanager.h"
@@ -340,7 +340,7 @@ int ScribusMainWindow::initScMW(bool primaryMainWindow)
internalCopy = false;
internalCopyBuffer.clear();
m_doc = new ScribusDoc();
- m_doc->setup(0, 1, 1, 1, 1, "Custom", "Custom", 0);
+ m_doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom", 0);
m_doc->setPage(100, 100, 0, 0, 0, 0, 0, 0, false, false);
m_doc->addPage(0);
m_doc->setGUI(false, this, nullptr);
@@ -415,6 +415,11 @@ int ScribusMainWindow::initScMW(bool primaryMainWindow)
if (primaryMainWindow)
ScCore->setSplashStatus( tr("Reading Scrapbook") );
initScrapbook();
+
+ if (primaryMainWindow)
+ ScCore->setSplashStatus( tr("Initializing Page Presets") );
+ PagePresetManager::instance();
+
scrActions["helpTooltips"]->setChecked(m_prefsManager.appPrefs.displayPrefs.showToolTips);
scrActions["showMouseCoordinates"]->setChecked(m_prefsManager.appPrefs.displayPrefs.showMouseCoordinates);
scrActions["stickyTools"]->setChecked(m_prefsManager.appPrefs.uiPrefs.stickyTools);
@@ -2037,10 +2042,10 @@ void ScribusMainWindow::startUpDialog()
int firstPage = dia->layoutFirstPage();
int bindingDirection = dia->bindingDirection();
docSet = dia->startDocSetup->isChecked();
- double topMargin = dia->marginGroup->margins().top();
- double bottomMargin = dia->marginGroup->margins().bottom();
- double leftMargin = dia->marginGroup->margins().left();
- double rightMargin = dia->marginGroup->margins().right();
+ double topMargin = dia->margins().top();
+ double bottomMargin = dia->margins().bottom();
+ double leftMargin = dia->margins().left();
+ double rightMargin = dia->margins().right();
double columnDistance = dia->distance();
double pageWidth = dia->pageWidth();
double pageHeight = dia->pageHeight();
@@ -2048,14 +2053,14 @@ void ScribusMainWindow::startUpDialog()
bool autoframes = dia->autoTextFrame->isChecked();
int orientation = dia->orientation();
int pageCount = dia->pageCountSpinBox->value();
- QString pagesize = dia->pageSizeName();
+ QSizeF pagesize(dia->pageWidth(), dia->pageHeight());
doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin,
columnDistance, numberCols, autoframes, facingPages, dia->unitOfMeasureComboBox->currentIndex(),
firstPage, orientation, 1, pagesize, true, pageCount, true, dia->marginGroup->marginPreset(),
bindingDirection
);
doc->setPageSetFirstPage(facingPages, firstPage);
- doc->bleeds()->set(dia->bleedTop(), dia->bleedLeft(), dia->bleedBottom(), dia->bleedRight());
+ doc->bleeds()->set(dia->bleeds().top(), dia->bleeds().left(), dia->bleeds().bottom(), dia->bleeds().right());
HaveNewDoc();
doc->reformPages(true);
// Don's disturb user with "save?" dialog just after new doc
@@ -2118,10 +2123,10 @@ bool ScribusMainWindow::slotFileNew()
int firstPage = dia->layoutFirstPage();
int bindingDirection = dia->bindingDirection();
bool docSet = dia->startDocSetup->isChecked();
- double topMargin = dia->marginGroup->margins().top();
- double bottomMargin = dia->marginGroup->margins().bottom();
- double leftMargin = dia->marginGroup->margins().left();
- double rightMargin = dia->marginGroup->margins().right();
+ double topMargin = dia->margins().top();
+ double bottomMargin = dia->margins().bottom();
+ double leftMargin = dia->margins().left();
+ double rightMargin = dia->margins().right();
double columnDistance = dia->distance();
double pageWidth = dia->pageWidth();
double pageHeight = dia->pageHeight();
@@ -2129,14 +2134,14 @@ bool ScribusMainWindow::slotFileNew()
bool autoframes = dia->autoTextFrame->isChecked();
int orientation = dia->orientation();
int pageCount = dia->pageCountSpinBox->value();
- QString pagesize = dia->pageSizeName();
+ QSizeF pagesize(dia->pageWidth(), dia->pageHeight());
if (doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, numberCols,
autoframes, facingPages, dia->unitOfMeasureComboBox->currentIndex(), firstPage, orientation, 1,
pagesize, true, pageCount, true, dia->marginGroup->marginPreset(), bindingDirection))
{
doc->setPageSetFirstPage(facingPages, firstPage);
- doc->bleeds()->set(dia->bleedTop(), dia->bleedLeft(), dia->bleedBottom(), dia->bleedRight());
+ doc->bleeds()->set(dia->bleeds().top(), dia->bleeds().left(), dia->bleeds().bottom(), dia->bleeds().right());
m_mainWindowStatusLabel->setText( tr("Ready"));
HaveNewDoc();
doc->reformPages(true);
@@ -2154,7 +2159,7 @@ bool ScribusMainWindow::slotFileNew()
ScribusDoc *ScribusMainWindow::doFileNew(double width, double height, double topMargin, double leftMargin, double rightMargin, double bottomMargin,
double columnDistance, double columnCount, bool autoTextFrames, int pageArrangement, int unitIndex, int firstPageLocation, int orientation,
- int firstPageNumber, const QString& defaultPageSize, bool requiresGUI, int pageCount, bool showView, int marginPreset, int bindingDirection)
+ int firstPageNumber, QSizeF defaultPageSize, bool requiresGUI, int pageCount, bool showView, int marginPreset, int bindingDirection)
{
if (HaveDoc)
outlinePalette->buildReopenVals();
@@ -8685,7 +8690,7 @@ void ScribusMainWindow::dropEvent ( QDropEvent * e)
ScriXmlDoc ss;
if (ss.readElemHeader(data, false, &gx, &gy, &gw, &gh))
{
- doFileNew(gw, gh, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ doFileNew(gw, gh, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
HaveNewDoc();
doc->reformPages(true);
slotElemRead(data, doc->currentPage()->xOffset(), doc->currentPage()->yOffset(), false, false, doc, view);
@@ -8723,7 +8728,7 @@ void ScribusMainWindow::dropEvent ( QDropEvent * e)
ScriXmlDoc ss;
if (ss.readElemHeader(text, false, &gx, &gy, &gw, &gh))
{
- doFileNew(gw, gh, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+ doFileNew(gw, gh, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, QSizeF(), true);
HaveNewDoc();
doc->reformPages(true);
slotElemRead(text, doc->currentPage()->xOffset(), doc->currentPage()->yOffset(), false, false, doc, view);
@@ -9237,7 +9242,7 @@ void ScribusMainWindow::manageColorsAndFills()
if (fmt)
{
ScribusDoc *s_doc = new ScribusDoc();
- s_doc->setup(0, 1, 1, 1, 1, "Custom", "Custom", 0);
+ s_doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom", 0);
s_doc->setPage(100, 100, 0, 0, 0, 0, 0, 0, false, false);
s_doc->addPage(0);
s_doc->setGUI(false, this, nullptr);
diff --git a/scribus/scribus.h b/scribus/scribus.h
index 85f7b4034..706665d16 100644
--- a/scribus/scribus.h
+++ b/scribus/scribus.h
@@ -156,8 +156,9 @@ public:
ScribusDoc* doFileNew(double width, double height, double topMargin, double leftMargin, double rightMargin,
double bottomMargin, double columnDistance, double columnCount, bool autoTextFrames, int pageArrangement,
- int unitIndex, int firstPageLocation, int orientation, int firstPageNumber, const QString& defaultPageSize,
+ int unitIndex, int firstPageLocation, int orientation, int firstPageNumber, QSizeF defaultPageSize,
bool requiresGUI, int pageCount = 1, bool showView = true, int marginPreset = 0, int bindingDirection = 0);
+
bool DoFileSave(const QString& fileName, QString* savedFileName = nullptr, uint formatID = FORMATID_CURRENTEXPORT);
void changeEvent(QEvent *e) override;
diff --git a/scribus/scribusdoc.cpp b/scribus/scribusdoc.cpp
index 39542bfda..d89e522df 100644
--- a/scribus/scribusdoc.cpp
+++ b/scribus/scribusdoc.cpp
@@ -56,6 +56,7 @@ for which a new license (GPL+exception) is in place.
#include "filewatcher.h"
#include "fpoint.h"
#include "hyphenator.h"
+#include "manager/pagepreset_manager.h"
#include "notesstyles.h"
#include "numeration.h"
#include "pageitem.h"
@@ -234,7 +235,7 @@ ScribusDoc::ScribusDoc() : UndoObject( tr("Document")), Observable(n
}
-ScribusDoc::ScribusDoc(const QString& docName, int unitindex, const PageSize& pagesize, const MarginStruct& margins, const DocPagesSetup& pagesSetup) : UndoObject( tr("Document")),
+ScribusDoc::ScribusDoc(const QString& docName, int unitindex, const PageSizeInfo& pagesize, const MarginStruct& margins, const DocPagesSetup& pagesSetup) : UndoObject( tr("Document")),
m_appPrefsData(PrefsManager::instance().appPrefs),
m_docPrefsData(PrefsManager::instance().appPrefs),
m_undoManager(UndoManager::instance()),
@@ -254,9 +255,9 @@ ScribusDoc::ScribusDoc(const QString& docName, int unitindex, const PageSize& pa
m_alignTransaction(nullptr)
{
m_docPrefsData.docSetupPrefs.docUnitIndex = unitindex;
- m_docPrefsData.docSetupPrefs.pageHeight = pagesize.height();
- m_docPrefsData.docSetupPrefs.pageWidth = pagesize.width();
- m_docPrefsData.docSetupPrefs.pageSize = pagesize.name();
+ m_docPrefsData.docSetupPrefs.pageHeight = pagesize.height;
+ m_docPrefsData.docSetupPrefs.pageWidth = pagesize.width;
+ m_docPrefsData.docSetupPrefs.pageSize = pagesize.id;
m_docPrefsData.docSetupPrefs.margins = margins;
maxCanvasCoordinate = FPoint(m_docPrefsData.displayPrefs.scratch.left() + m_docPrefsData.displayPrefs.scratch.right(), m_docPrefsData.displayPrefs.scratch.top() + m_docPrefsData.displayPrefs.scratch.bottom());
setPageSetFirstPage(pagesSetup.pageArrangement, pagesSetup.firstPageLocation);
@@ -681,12 +682,13 @@ QList *ScribusDoc::parentGroup(PageItem* item, QList *list
return retList;
}
-void ScribusDoc::setup(int unitIndex, int fp, int firstLeft, int orientation, int firstPageNumber, const QString& defaultPageSize, const QString& documentName, int bindingDirection)
+void ScribusDoc::setup(int unitIndex, int fp, int firstLeft, int orientation, int firstPageNumber, QSizeF pageSize, const QString& documentName, int bindingDirection)
{
m_docPrefsData.docSetupPrefs.docUnitIndex = unitIndex;
setPageSetFirstPage(fp, firstLeft);
m_docPrefsData.docSetupPrefs.pageOrientation = orientation;
- m_docPrefsData.docSetupPrefs.pageSize = defaultPageSize;
+ PageSizeInfo psi = PagePresetManager::instance().pageInfoByDimensions(pageSize.width(), pageSize.height());
+ m_docPrefsData.docSetupPrefs.pageSize = psi.id;
FirstPnum = firstPageNumber;
m_docPrefsData.docSetupPrefs.pagePositioning = fp;
m_docPrefsData.docSetupPrefs.bindingDirection = bindingDirection;
diff --git a/scribus/scribusdoc.h b/scribus/scribusdoc.h
index c627a2707..a3912b39d 100644
--- a/scribus/scribusdoc.h
+++ b/scribus/scribusdoc.h
@@ -80,7 +80,7 @@ class Selection;
class ScribusView;
class ScribusMainWindow;
class ResourceCollection;
-class PageSize;
+struct PageSizeInfo;
class ScPattern;
class Serializer;
class QProgressBar;
@@ -98,7 +98,7 @@ class SCRIBUS_API ScribusDoc : public QObject, public UndoObject, public Observa
public:
ScribusDoc();
- ScribusDoc(const QString& docName, int unitIndex, const PageSize& pagesize, const MarginStruct& margins, const DocPagesSetup& pagesSetup);
+ ScribusDoc(const QString& docName, int unitIndex, const PageSizeInfo& pagesize, const MarginStruct& margins, const DocPagesSetup& pagesSetup);
~ScribusDoc();
void init();
@@ -110,7 +110,7 @@ public:
/**
* @param bindingDirection Defaults to 0 for all the one page temporary documents Scribus creates
*/
- void setup(int unitIndex, int fp, int firstLeft, int orientation, int firstPageNumber, const QString& defaultPageSize, const QString& documentName, int bindingDirection = 0);
+ void setup(int unitIndex, int fp, int firstLeft, int orientation, int firstPageNumber, const QSizeF pageSize, const QString& documentName, int bindingDirection = 0);
void setLoading(bool);
bool isLoading() const;
void setModified(bool);
@@ -227,10 +227,10 @@ public:
double pageHeight() const { return m_docPrefsData.docSetupPrefs.pageHeight; }
double pageWidth() const { return m_docPrefsData.docSetupPrefs.pageWidth; }
- const QString& pageSize() const { return m_docPrefsData.docSetupPrefs.pageSize; }
+ const QString& pageSize() const { return m_docPrefsData.docSetupPrefs.pageSize; } // legacy support for < 1.7.1
void setPageHeight(double h) { m_docPrefsData.docSetupPrefs.pageHeight = h; }
void setPageWidth(double w) { m_docPrefsData.docSetupPrefs.pageWidth = w; }
- void setPageSize(const QString& s) { m_docPrefsData.docSetupPrefs.pageSize = s; }
+ void setPageSize(const QString& s) { m_docPrefsData.docSetupPrefs.pageSize = s; } // legacy support for < 1.7.1
int marginPreset() const { return m_docPrefsData.docSetupPrefs.marginPreset; }
void setMarginPreset(int mp) { m_docPrefsData.docSetupPrefs.marginPreset = mp; }
diff --git a/scribus/ui/colorsandfills.cpp b/scribus/ui/colorsandfills.cpp
index dd378b34a..9a5df1f1e 100644
--- a/scribus/ui/colorsandfills.cpp
+++ b/scribus/ui/colorsandfills.cpp
@@ -1951,7 +1951,7 @@ void ColorsAndFillsDialog::doSaveDefaults(const QString& name, bool changed)
if (fmt)
{
std::unique_ptr s_doc(new ScribusDoc());
- s_doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ s_doc->setup(0, 1, 1, 1, 1, QSizeF(), "Custom");
s_doc->setPage(100, 100, 0, 0, 0, 0, 0, 0, false, false);
s_doc->addPage(0);
s_doc->setGUI(false, mainWin, nullptr);
diff --git a/scribus/ui/delegates/sclistitemdelegate.cpp b/scribus/ui/delegates/sclistitemdelegate.cpp
index 83efe7fdd..015057bab 100644
--- a/scribus/ui/delegates/sclistitemdelegate.cpp
+++ b/scribus/ui/delegates/sclistitemdelegate.cpp
@@ -6,6 +6,9 @@
#include
#include
#include
+#include "iconmanager.h"
+#include "manager/pagepreset_manager.h"
+#include "ui/widgets/pagesizelist.h"
ScListItemDelegate::ScListItemDelegate(QListView::ViewMode mode, QSize iconSize, TextPosition textPosition, Style style, QObject *parent) : QItemDelegate (parent)
@@ -84,7 +87,8 @@ void ScListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
// Item Data
QIcon ic = qvariant_cast(index.data(Qt::DecorationRole));
QString title = index.data(Qt::DisplayRole).toString();
- QString subTitle = index.data(Qt::UserRole).toString();
+ QString subTitle = index.data(PageSizeList::ItemData::SizeLabel).toString();
+ PageSizeType type = qvariant_cast(index.data(PageSizeList::ItemData::Type));
switch (m_textPosition)
{
@@ -144,7 +148,8 @@ void ScListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
QTextLayout textLayout(title, painter->font());
textLayout.beginLayout();
- while (++lineCount < rText.height() / fm.lineSpacing()) {
+ while (++lineCount < rText.height() / fm.lineSpacing())
+ {
QTextLine line = textLayout.createLine();
if (!line.isValid())
break;
@@ -162,6 +167,15 @@ void ScListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
}
+ // User Marker
+ if (type == PageSizeType::User)
+ {
+ QRect rMarker(0, 0, 16, 16);
+ rMarker.moveTop(rSaveArea.top() + 4);
+ rMarker.moveRight(rSaveArea.right() - 4);
+ painter->drawPixmap(rMarker, IconManager::instance().loadPixmap("user-page-preset"));
+ }
+
painter->restore();
}
diff --git a/scribus/ui/inspage.cpp b/scribus/ui/inspage.cpp
index 87c3b3d77..c1cb27749 100644
--- a/scribus/ui/inspage.cpp
+++ b/scribus/ui/inspage.cpp
@@ -17,7 +17,7 @@ for which a new license (GPL+exception) is in place.
#include "commonstrings.h"
#include "iconmanager.h"
-#include "pagesize.h"
+#include "manager/pagepreset_manager.h"
#include "scpage.h"
#include "scribusdoc.h"
#include "scrspinbox.h"
@@ -225,17 +225,8 @@ InsPage::InsPage( QWidget* parent, ScribusDoc* currentDoc, int currentPage, int
}
}
- QScopedPointer ps(new PageSize(m_doc->pageSize()));
-
- // try to find corresponding page size by dimensions
- if (ps->name() == CommonStrings::customPageSize)
- {
- PageSizeInfoMap pages = ps->sizesByDimensions(QSize(m_doc->pageWidth(), m_doc->pageHeight()));
- if (pages.count() > 0)
- prefsPageSizeName = pages.firstKey();
- }
- else
- prefsPageSizeName = ps->name();
+ PageSizeInfo psi = PagePresetManager::instance().pageInfoByDimensions(QSize(m_doc->pageWidth(), m_doc->pageHeight()));
+ prefsPageSizeName = psi.id;
dialogLayout->addWidget(masterPageGroup);
overrideMPSizingCheckBox = new QCheckBox( tr("Override Master Page Sizing"));
@@ -248,7 +239,7 @@ InsPage::InsPage( QWidget* parent, ScribusDoc* currentDoc, int currentPage, int
textLabel1 = new QLabel( tr( "&Size:" ), dsGroupBox7);
dsGroupBox7Layout->addWidget(textLabel1, 0, 0, Qt::AlignTop | Qt::AlignRight);
pageSizeSelector = new PageSizeSelector(dsGroupBox7);
- pageSizeSelector->setPageSize(m_doc->pageSize());
+ pageSizeSelector->setPageSize(m_doc->pageWidth(), m_doc->pageHeight());
textLabel1->setBuddy(pageSizeSelector);
dsGroupBox7Layout->addWidget(pageSizeSelector, 0, 1);
textLabel2 = new QLabel( tr( "Orie&ntation:" ), dsGroupBox7);
@@ -282,7 +273,7 @@ InsPage::InsPage( QWidget* parent, ScribusDoc* currentDoc, int currentPage, int
dialogLayout->addWidget(dsGroupBox7);
dsGroupBox7->setEnabled(false);
- bool b = (pageSizeSelector->pageSizeTR() == CommonStrings::trCustomPageSize);
+ bool b = (pageSizeSelector->pageSize() == CommonStrings::customPageSize);
heightSpinBox->setEnabled(b);
widthSpinBox->setEnabled(b);
@@ -302,20 +293,19 @@ InsPage::InsPage( QWidget* parent, ScribusDoc* currentDoc, int currentPage, int
void InsPage::setSize(const QString & gr)
{
- PageSize ps2(gr);
- prefsPageSizeName = ps2.name();
- if (gr == CommonStrings::trCustomPageSize)
+ PageSizeInfo psi = PagePresetManager::instance().pageInfoByName(gr);
+ prefsPageSizeName = psi.id;
+ if (psi.id == CommonStrings::customPageSize)
{
widthSpinBox->setEnabled(true);
heightSpinBox->setEnabled(true);
- prefsPageSizeName = CommonStrings::customPageSize;
}
else
{
widthSpinBox->setEnabled(false);
heightSpinBox->setEnabled(false);
- double w = ps2.width() * m_unitRatio;
- double h = ps2.height() * m_unitRatio;
+ double w = psi.width * m_unitRatio;
+ double h = psi.height * m_unitRatio;
if (orientationQComboBox->currentIndex() == 1)
{
double t = h;
diff --git a/scribus/ui/inspage.h b/scribus/ui/inspage.h
index 2a8e9d581..2999bbfec 100644
--- a/scribus/ui/inspage.h
+++ b/scribus/ui/inspage.h
@@ -73,7 +73,6 @@ private:
QLabel* textLabel1 { nullptr };
QLabel* textLabel2 { nullptr };
PageSizeSelector* pageSizeSelector { nullptr };
-// QComboBox* sizeQComboBox { nullptr };
QComboBox* orientationQComboBox { nullptr };
QCheckBox* moveObjectsCheckBox { nullptr };
QCheckBox* overrideMPSizingCheckBox { nullptr };
diff --git a/scribus/ui/newdocdialog.cpp b/scribus/ui/newdocdialog.cpp
index 09d2086ca..4a77fe59c 100644
--- a/scribus/ui/newdocdialog.cpp
+++ b/scribus/ui/newdocdialog.cpp
@@ -38,10 +38,11 @@ for which a new license (GPL+exception) is in place.
#include "fileloader.h"
#include "iconmanager.h"
#include "newmarginwidget.h"
-#include "pagesize.h"
#include "pagestructs.h"
#include "prefsfile.h"
#include "prefsmanager.h"
+#include "scmessagebox.h"
+#include "scpaths.h"
#include "scrspinbox.h"
#include "units.h"
#include "ui/widgets/pagesizelist.h"
@@ -64,6 +65,8 @@ NewDocDialog::NewDocDialog(QWidget* parent, const QStringList& recentDocs, bool
m_unitSuffix = unitGetSuffixFromIndex(m_unitIndex);
m_orientation = prefsManager.appPrefs.docSetupPrefs.pageOrientation;
m_bindingDirection = prefsManager.appPrefs.docSetupPrefs.bindingDirection;
+ m_choosenLayout = prefsManager.appPrefs.docSetupPrefs.pagePositioning;
+ m_layoutFirstPage = prefsManager.appPrefs.pageSets.at(m_choosenLayout).FirstPage;
buttonVertical->setIcon(iconManager.loadIcon("page-orientation-vertical"));
buttonHorizontal->setIcon(iconManager.loadIcon("page-orientation-horizontal"));
@@ -74,9 +77,12 @@ NewDocDialog::NewDocDialog(QWidget* parent, const QStringList& recentDocs, bool
pageBindingIcon.addPixmap(iconManager.loadPixmap("page-binding-left"), QIcon::Normal, QIcon::Off);
pageBindingIcon.addPixmap(iconManager.loadPixmap("page-binding-right"), QIcon::Normal, QIcon::On);
buttonBindingDirection->setIcon(pageBindingIcon);
+ buttonSavePagePreset->setIcon(iconManager.loadIcon("save"));
labelColumns->setPixmap(iconManager.loadPixmap("paragraph-columns"));
+ labelName->setPixmap(iconManager.loadPixmap("name"));
createNewDocPage();
+
if (startUp)
{
nftGui->setupSettings(lang);
@@ -92,7 +98,6 @@ NewDocDialog::NewDocDialog(QWidget* parent, const QStringList& recentDocs, bool
tabWidget->removeTab(1);
}
-
tabWidget->setCurrentIndex(0);
startUpDialog->setVisible(startUp);
@@ -119,15 +124,17 @@ NewDocDialog::NewDocDialog(QWidget* parent, const QStringList& recentDocs, bool
connect(pageOrientationButtons, &QButtonGroup::idClicked, this, &NewDocDialog::setOrientation);
connect(pageLayoutButtons, &QButtonGroup::idClicked, this, &NewDocDialog::setLayout);
connect(buttonBindingDirection, &QToolButton::toggled, this, &NewDocDialog::setBindingDirection);
- connect(unitOfMeasureComboBox, SIGNAL(activated(int)), this, SLOT(setUnit(int)));
- connect(Distance, SIGNAL(valueChanged(double)), this, SLOT(setDistance(double)));
- connect(autoTextFrame, SIGNAL(clicked()), this, SLOT(handleAutoFrame()));
+ connect(unitOfMeasureComboBox, &QComboBox::activated, this, &NewDocDialog::setUnit);
+ connect(Distance, &ScrSpinBox::valueChanged, this, &NewDocDialog::setDistance);
+ connect(autoTextFrame, &QCheckBox::checkStateChanged, this, &NewDocDialog::handleAutoFrame);
connect(listPageFormats, &PageSizeList::clicked, this, &NewDocDialog::changePageSize);
+ connect(listPageFormats, &PageSizeList::changedCategories, this, &NewDocDialog::updateCategorySelector);
connect(pageSizeSelector, &PageSizeSelector::pageCategoryChanged, this, &NewDocDialog::changeCategory);
- connect(marginGroup, &NewMarginWidget::marginChanged, this, &NewDocDialog::changeMargin);
- connect(bleedGroup, &NewMarginWidget::marginChanged, this, &NewDocDialog::changeBleed);
+ connect(marginGroup, &NewMarginWidget::valuesChanged, this, &NewDocDialog::changeMargin);
connect(bleedGroup, &NewMarginWidget::valuesChanged, this, &NewDocDialog::changeBleed);
connect(comboSortSizes, &QComboBox::currentIndexChanged, this, &NewDocDialog::changeSortMode);
+ connect(buttonSavePagePreset, &QToolButton::clicked, this, &NewDocDialog::savePagePreset);
+
if (startUp)
{
connect(nftGui, SIGNAL(leaveOK()), this, SLOT(ExitOK()));
@@ -138,9 +145,6 @@ NewDocDialog::NewDocDialog(QWidget* parent, const QStringList& recentDocs, bool
void NewDocDialog::createNewDocPage()
{
- int orientation = prefsManager.appPrefs.docSetupPrefs.pageOrientation;
- int pagePositioning = prefsManager.appPrefs.docSetupPrefs.pagePositioning;
- QString pageSize = prefsManager.appPrefs.docSetupPrefs.pageSize;
double pageHeight = prefsManager.appPrefs.docSetupPrefs.pageHeight;
double pageWidth = prefsManager.appPrefs.docSetupPrefs.pageWidth;
@@ -153,18 +157,18 @@ void NewDocDialog::createNewDocPage()
pageOrientationButtons = new QButtonGroup();
pageOrientationButtons->addButton(buttonVertical, 0);
pageOrientationButtons->addButton(buttonHorizontal, 1);
- pageOrientationButtons->button(orientation)->setChecked(true);
+ pageOrientationButtons->button(m_orientation)->setChecked(true);
pageLayoutButtons = new QButtonGroup();
pageLayoutButtons->addButton(buttonSinglePage, 0);
pageLayoutButtons->addButton(buttonDoublePageLeft, 1);
pageLayoutButtons->addButton(buttonDoublePageRight, 2);
- if (pagePositioning == singlePage)
+ if (m_choosenLayout == singlePage)
{
pageLayoutButtons->button(0)->setChecked(true);
buttonBindingDirection->setDisabled(true);
}
- else if (prefsManager.appPrefs.pageSets.at(pagePositioning).FirstPage == 0)
+ else if (prefsManager.appPrefs.pageSets.at(m_choosenLayout).FirstPage == 0)
{
pageLayoutButtons->button(1)->setChecked(true);
buttonBindingDirection->setDisabled(false);
@@ -177,12 +181,14 @@ void NewDocDialog::createNewDocPage()
buttonBindingDirection->setChecked(m_bindingDirection);
- listPageFormats->setValues(pageSize, orientation, PageSizeInfo::Preferred, PageSizeList::NameAsc);
+ PageCollectionInfo pciPreferred = PagePresetManager::instance().categoryInfoPreferred();
+
+ listPageFormats->setValues(QSizeF(pageWidth, pageHeight), m_orientation, pciPreferred.id, PageSizeList::NameAsc);
pageSizeSelector->setHasFormatSelector(false);
pageSizeSelector->setHasCustom(false);
- pageSizeSelector->setPageSize(pageSize);
- pageSizeSelector->setCurrentCategory(PageSizeInfo::Preferred);
+ pageSizeSelector->setPageSize(pageWidth, pageHeight);
+ pageSizeSelector->setCurrentCategory(pciPreferred.id);
widthSpinBox->setMinimum(pts2value(1.0, m_unitIndex));
widthSpinBox->setMaximum(16777215);
@@ -201,22 +207,19 @@ void NewDocDialog::createNewDocPage()
unitOfMeasureComboBox->setEditable(false);
MarginStruct marg(prefsManager.appPrefs.docSetupPrefs.margins);
- marginGroup->setup(marg, !(pagePositioning == singlePage), m_unitIndex, NewMarginWidget::MarginWidgetFlags);
+ marginGroup->setup(marg, !(m_choosenLayout == singlePage), m_unitIndex, NewMarginWidget::MarginWidgetFlags);
marginGroup->toggleLabelVisibility(false);
marginGroup->setPageHeight(pageHeight);
marginGroup->setPageWidth(pageWidth);
- marginGroup->setFacingPages(!(pagePositioning == singlePage));
- marginGroup->setPageSize(pageSize);
+ marginGroup->setFacingPages(!(m_choosenLayout == singlePage));
marginGroup->setMarginPreset(prefsManager.appPrefs.docSetupPrefs.marginPreset);
- MarginStruct bleed;
- bleed.resetToZero();
- bleedGroup->setup(bleed, !(pagePositioning == singlePage), m_unitIndex, NewMarginWidget::BleedWidgetFlags);
+ MarginStruct bleed(prefsManager.appPrefs.docSetupPrefs.bleeds);
+ bleedGroup->setup(bleed, !(m_choosenLayout == singlePage), m_unitIndex, NewMarginWidget::BleedWidgetFlags);
bleedGroup->toggleLabelVisibility(false);
bleedGroup->setPageHeight(pageHeight);
bleedGroup->setPageWidth(pageWidth);
- bleedGroup->setFacingPages(!(pagePositioning == singlePage));
- bleedGroup->setPageSize(pageSize);
+ bleedGroup->setFacingPages(!(m_choosenLayout == singlePage));
bleedGroup->setMarginPreset(prefsManager.appPrefs.docSetupPrefs.marginPreset);
pageCountSpinBox->setMaximum( 10000 );
@@ -225,9 +228,9 @@ void NewDocDialog::createNewDocPage()
IconManager &iconManager = IconManager::instance();
pageCountLabel->setPixmap(iconManager.loadPixmap("panel-page"));
- setDocLayout(pagePositioning);
- setSize(pageSize);
- setOrientation(orientation);
+ setDocLayout(m_choosenLayout);
+ setSize(QSizeF(pageWidth, pageHeight));
+ setOrientation(m_orientation);
numberOfCols->setButtonSymbols( QSpinBox::UpDownArrows );
numberOfCols->setMinimum( 1 );
@@ -353,8 +356,8 @@ void NewDocDialog::setWidth(double)
marginGroup->setPageWidth(m_pageWidth);
bleedGroup->setPageWidth(m_pageWidth);
listPageFormats->clearSelection();
- m_pageSize = CommonStrings::customPageSize;
- pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_pageSize, m_choosenLayout, m_layoutFirstPage);
+ listPageFormats->setDimensions(m_pageWidth, m_pageHeight);
+ pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_choosenLayout, m_layoutFirstPage);
int newOrientation = (widthSpinBox->value() > heightSpinBox->value()) ? landscapePage : portraitPage;
if (newOrientation != m_orientation)
@@ -363,8 +366,6 @@ void NewDocDialog::setWidth(double)
QSignalBlocker sigOri(pageOrientationButtons);
pageOrientationButtons->button(newOrientation)->setChecked(true);
- QSignalBlocker sigFormats(listPageFormats);
- listPageFormats->setOrientation(m_orientation);
}
}
@@ -375,8 +376,8 @@ void NewDocDialog::setHeight(double)
marginGroup->setPageHeight(m_pageHeight);
bleedGroup->setPageHeight(m_pageHeight);
listPageFormats->clearSelection();
- m_pageSize = CommonStrings::customPageSize;
- pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_pageSize, m_choosenLayout, m_layoutFirstPage);
+ listPageFormats->setDimensions(m_pageWidth, m_pageHeight);
+ pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_choosenLayout, m_layoutFirstPage);
int newOrientation = (widthSpinBox->value() > heightSpinBox->value()) ? landscapePage : portraitPage;
if (newOrientation != m_orientation)
@@ -385,22 +386,83 @@ void NewDocDialog::setHeight(double)
QSignalBlocker sigOri(pageOrientationButtons);
pageOrientationButtons->button(newOrientation)->setChecked(true);
- QSignalBlocker sigFormats(listPageFormats);
- listPageFormats->setOrientation(m_orientation);
}
}
void NewDocDialog::changePageSize(const QModelIndex &ic)
{
int unit = ic.data(PageSizeList::Unit).toInt();
- QString sizeName = ic.data(PageSizeList::Name).toString();
+ int layout = ic.data(PageSizeList::Layout).toInt();
+ layout = layout > -1 ? layout : m_choosenLayout;//prefsManager.appPrefs.docSetupPrefs.pagePositioning;
+ int firstPage = ic.data(PageSizeList::FirstPage).toInt();
+ firstPage = firstPage > -1 ? firstPage : m_layoutFirstPage;//prefsManager.appPrefs.pageSets.at(layout).FirstPage;
+ double width = ic.data(PageSizeList::Width).toDouble();
+ double height = ic.data(PageSizeList::Height).toDouble();
+ int bDirection = ic.data(PageSizeList::BindingDirection).toInt();
+ bool bindingDirection = bDirection > -1 ? bDirection : m_bindingDirection;//prefsManager.appPrefs.docSetupPrefs.bindingDirection;
+ textPagePresetName->setText(ic.data(Qt::DisplayRole).toString());
+
+ // Margins
+ MarginStruct margins(prefsManager.appPrefs.docSetupPrefs.margins);
+ marginGroup->setPageWidth(width);
+ marginGroup->setPageHeight(height);
+ marginGroup->setMarginPreset(prefsManager.appPrefs.docSetupPrefs.marginPreset);
+ QVariant dataMargins = ic.data(PageSizeList::Margins);
+ if (dataMargins.canConvert>())
+ {
+ QList m = dataMargins.value>();
+ if (!QVariant(m.at(0)).toBool())
+ {
+ margins.set(m.at(1), m.at(2), m.at(3), m.at(4));
+ marginGroup->setMarginPreset(ic.data(PageSizeList::MarginPreset).toInt());
+ }
+ }
+ marginGroup->setNewValues(margins);
+
+ // Bleeds
+ MarginStruct bleeds(prefsManager.appPrefs.docSetupPrefs.bleeds);
+ QVariant dataBleeds = ic.data(PageSizeList::Bleeds);
+ if (dataBleeds.canConvert>())
+ {
+ QList m = dataBleeds.value>();
+ if (!QVariant(m.at(0)).toBool())
+ bleeds.set(m.at(1), m.at(2), m.at(3), m.at(4));
+ }
+ bleedGroup->setNewValues(bleeds);
+
+ // Text Frame
+ autoTextFrame->setChecked(false);
+ numberOfCols->setValue( 1 );
+ Distance->setValue(11 * m_unitRatio);
+ QVariant dataTextFrame = ic.data(PageSizeList::TextFrame);
+ if (dataTextFrame.canConvert>())
+ {
+ QList tf = dataTextFrame.value>();
+ if (!tf.isEmpty())
+ {
+ autoTextFrame->setChecked(true);
+ numberOfCols->setValue(QVariant(tf.at(0)).toInt());
+ setDistance(QVariant(tf.at(1)).toDouble() * m_unitRatio);
+ }
+ }
+ setPageSize(QSizeF(width, height));
setUnit(unit);
- setPageSize(sizeName);
- QSignalBlocker sig(unitOfMeasureComboBox);
- unitOfMeasureComboBox->setCurrentIndex(unit);
+ // Layout + First Page
+ if (layout == 0)
+ setLayout(0);
+ else
+ {
+ if (firstPage == 0)
+ setLayout(1);
+ else
+ setLayout(2);
+ }
+ // BindingDirection
+ buttonBindingDirection->setChecked(bindingDirection);
+ setBindingDirection(bindingDirection);
}
void NewDocDialog::changeSortMode(int ic)
@@ -409,6 +471,66 @@ void NewDocDialog::changeSortMode(int ic)
listPageFormats->setSortMode(static_cast(comboSortSizes->currentData().toInt()));
}
+void NewDocDialog::savePagePreset()
+{
+ if (textPagePresetName->text().isEmpty())
+ {
+ ScMessageBox::warning(this, tr("Empty Preset Name"), tr("The preset name must not be empty!\nEnter a preset name."), QMessageBox::Ok);
+ return;
+ }
+
+ const QString presetUserFolder = QDir::toNativeSeparators(ScPaths::userPagePresetsDir(true));
+
+ QString uuid;
+
+ // Collection
+ // If another user collection should be updated change the collection information here:
+ PageCollectionInfo pci;
+ pci.author = tr("User");
+ pci.license = tr("Copyright by user");
+ pci.name = tr("User");
+ pci.filePath = presetUserFolder % u"user.xml";
+
+ PagePresetManager::instance().createOrUpdateCollection(pci.filePath, pci, uuid);
+
+ // Page Preset
+ PageSizeInfo psi;
+ psi.pageUnitIndex = m_unitIndex;
+ psi.name = textPagePresetName->text();
+ psi.width = m_pageWidth;
+ psi.height = m_pageHeight;
+ psi.margins = marginGroup->margins();
+ psi.bleeds = bleedGroup->margins();
+ psi.layout = m_choosenLayout;
+ psi.firstPage = m_layoutFirstPage;
+ psi.marginPreset = marginGroup->marginPreset();
+ psi.bindingDirection = m_bindingDirection;
+
+ QList textFrame;
+ if (autoTextFrame->isChecked())
+ {
+ textFrame.append(numberOfCols->value());
+ textFrame.append(m_distance);
+ }
+ psi.textFrame = textFrame;
+
+ PagePresetManager::instance().addCollectionPage(pci.filePath, psi);
+
+ // Refresh UI
+ PagePresetManager::instance().reloadAllPresets();
+ pageSizeSelector->setPageSize(m_pageWidth, m_pageHeight);
+ pageSizeSelector->setCurrentCategory(uuid);
+ updateCategory(uuid, true);
+}
+
+void NewDocDialog::updateCategorySelector()
+{
+ PageCollectionInfo pciPreferred = PagePresetManager::instance().categoryInfoPreferred();
+ pageSizeSelector->setPageSize(m_pageWidth, m_pageHeight);
+ pageSizeSelector->setCurrentCategory(pciPreferred.id);
+ updateCategory(pciPreferred.id, true);
+}
+
bool NewDocDialog::eventFilter(QObject *object, QEvent *event)
{
if (object->objectName() == "scrollAreaWidgetContents" && event->type() == QEvent::Resize)
@@ -429,13 +551,19 @@ void NewDocDialog::handleAutoFrame()
numberOfCols->setEnabled(setter);
}
-void NewDocDialog::setDistance(double)
+void NewDocDialog::setDistance(double value)
{
- m_distance = Distance->value() / m_unitRatio;
+ QSignalBlocker sig(Distance);
+ Distance->setValue(value);
+
+ m_distance = value / m_unitRatio;
}
void NewDocDialog::setUnit(int newUnitIndex)
{
+ QSignalBlocker sig(unitOfMeasureComboBox);
+ unitOfMeasureComboBox->setCurrentIndex(newUnitIndex);
+
disconnect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double)));
disconnect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double)));
widthSpinBox->setNewUnit(newUnitIndex);
@@ -508,24 +636,23 @@ void NewDocDialog::setOrientation(int ori)
{
disconnect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double)));
disconnect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double)));
- if (ori != m_orientation)
- {
- double w = widthSpinBox->value(), h = heightSpinBox->value();
- double pw = m_pageWidth, ph = m_pageHeight;
- widthSpinBox->setValue((ori == portraitPage) ? qMin(w, h) : qMax(w, h));
- heightSpinBox->setValue((ori == portraitPage) ? qMax(w, h) : qMin(w, h));
- m_pageWidth = (ori == portraitPage) ? qMin(pw, ph) : qMax(pw, ph);
- m_pageHeight = (ori == portraitPage) ? qMax(pw, ph) : qMin(pw, ph);
- listPageFormats->setOrientation(ori);
- }
- // #869 pv - defined constants added + code repeat (check w/h)
- (ori == portraitPage) ? m_orientation = portraitPage : m_orientation = landscapePage;
- // end of #869
+
+ bool isPortrait = ori == portraitPage;
+ double w = widthSpinBox->value(), h = heightSpinBox->value();
+ double pw = m_pageWidth, ph = m_pageHeight;
+ widthSpinBox->setValue(isPortrait ? qMin(w, h) : qMax(w, h));
+ heightSpinBox->setValue(isPortrait ? qMax(w, h) : qMin(w, h));
+
+ m_pageWidth = isPortrait ? qMin(pw, ph) : qMax(pw, ph);
+ m_pageHeight = isPortrait ? qMax(pw, ph) : qMin(pw, ph);
+
+ m_orientation = ori;
+
marginGroup->setPageHeight(m_pageHeight);
marginGroup->setPageWidth(m_pageWidth);
bleedGroup->setPageHeight(m_pageHeight);
bleedGroup->setPageWidth(m_pageWidth);
- pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_pageSize, m_choosenLayout, m_layoutFirstPage);
+ pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_choosenLayout, m_layoutFirstPage);
connect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double)));
connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double)));
@@ -538,18 +665,21 @@ void NewDocDialog::setLayout(int layoutId)
case 0:
setDocLayout(0);
buttonBindingDirection->setDisabled(true);
+ pageLayoutButtons->button(0)->setChecked(true); // single page
break;
case 1:
setDocLayout(1);
pagePreview->setFirstPage(0);
setDocFirstPage(0);
buttonBindingDirection->setDisabled(false);
+ pageLayoutButtons->button(1)->setChecked(true); // double page + first page left
break;
case 2:
setDocLayout(1);
pagePreview->setFirstPage(1);
setDocFirstPage(1);
buttonBindingDirection->setDisabled(false);
+ pageLayoutButtons->button(2)->setChecked(true); // double page + first page right
break;
}
}
@@ -559,52 +689,34 @@ void NewDocDialog::setBindingDirection(bool checked)
m_bindingDirection = int(checked);
}
-void NewDocDialog::setPageSize(const QString &size)
+void NewDocDialog::setPageSize(QSizeF size)
{
- setSize(size);
-
- if (size != CommonStrings::customPageSize)
- setOrientation(pageOrientationButtons->checkedId());
-
- marginGroup->setPageSize(size);
- bleedGroup->setPageSize(size);
+ if (size.width() < size.height())
+ pageOrientationButtons->button(portraitPage)->setChecked(true);
+ else
+ pageOrientationButtons->button(landscapePage)->setChecked(true);
+ setSize(size);
}
-void NewDocDialog::setSize(const QString& gr)
+void NewDocDialog::setSize(QSizeF size)
{
m_pageWidth = widthSpinBox->value() / m_unitRatio;
m_pageHeight = heightSpinBox->value() / m_unitRatio;
- m_pageSize = gr;
disconnect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double)));
disconnect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double)));
- if (m_pageSize == CommonStrings::trCustomPageSize || m_pageSize == CommonStrings::customPageSize)
- {
- widthSpinBox->setEnabled(true);
- heightSpinBox->setEnabled(true);
- }
- else
- {
- PageSize ps2(m_pageSize);
- if (pageOrientationButtons->checkedId() == portraitPage)
- {
- m_pageWidth = ps2.width();
- m_pageHeight = ps2.height();
- }
- else
- {
- m_pageWidth = ps2.height();
- m_pageHeight = ps2.width();
- }
- }
+
+ m_pageWidth = size.width();
+ m_pageHeight = size.height();
+
widthSpinBox->setValue(m_pageWidth * m_unitRatio);
heightSpinBox->setValue(m_pageHeight * m_unitRatio);
marginGroup->setPageHeight(m_pageHeight);
marginGroup->setPageWidth(m_pageWidth);
bleedGroup->setPageHeight(m_pageHeight);
bleedGroup->setPageWidth(m_pageWidth);
- pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_pageSize, m_choosenLayout, m_layoutFirstPage);
+ pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_choosenLayout, m_layoutFirstPage);
connect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double)));
connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double)));
@@ -617,7 +729,7 @@ void NewDocDialog::setDocLayout(int layout)
bleedGroup->setFacingPages(layout != singlePage);
m_choosenLayout = layout;
m_layoutFirstPage = prefsManager.appPrefs.pageSets.at(m_choosenLayout).FirstPage;
- pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_pageSize, m_choosenLayout, m_layoutFirstPage);
+ pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_choosenLayout, m_layoutFirstPage);
}
void NewDocDialog::setDocFirstPage(int firstPage)
@@ -709,11 +821,13 @@ void NewDocDialog::changeBleed(MarginStruct bleed)
pagePreview->setBleeds(bleed);
}
-void NewDocDialog::changeCategory(PageSizeInfo::Category category)
+void NewDocDialog::changeCategory(const QString &category)
{
- if (listPageFormats->category() == category)
- return;
+ updateCategory(category);
+}
- listPageFormats->setFormat(m_pageSize);
- listPageFormats->setCategory(category);
+void NewDocDialog::updateCategory(const QString &category, bool forceUpdate)
+{
+ if (listPageFormats->category() != category || forceUpdate)
+ listPageFormats->setValues(QSizeF(m_pageWidth, m_pageHeight), listPageFormats->orientation(), category, listPageFormats->sortMode());
}
diff --git a/scribus/ui/newdocdialog.h b/scribus/ui/newdocdialog.h
index 14a5ad202..82476e675 100644
--- a/scribus/ui/newdocdialog.h
+++ b/scribus/ui/newdocdialog.h
@@ -61,8 +61,7 @@ public:
void createNewDocPage();
void createOpenDocPage();
void createRecentDocPage();
- void setSize(const QString& gr);
- QString pageSizeName() const { return m_pageSize; };
+ void setSize(QSizeF size);
QFileDialog *fileDialog {nullptr};
@@ -81,10 +80,8 @@ public:
double pageWidth() const { return m_pageWidth;}
double pageHeight() const { return m_pageHeight;}
double distance() const { return m_distance;}
- double bleedBottom() const { return m_bleedBottom;}
- double bleedTop() const { return m_bleedTop;}
- double bleedLeft() const { return m_bleedLeft;}
- double bleedRight() const { return m_bleedRight;}
+ MarginStruct margins() const { return marginGroup->margins(); }
+ MarginStruct bleeds() const { return bleedGroup->margins(); }
public slots:
void setHeight(double v);
@@ -96,7 +93,7 @@ public slots:
void setOrientation(int ori);
void setLayout(int layoutId);
void setBindingDirection(bool checked);
- void setPageSize(const QString &);
+ void setPageSize(QSizeF size);
void setDocLayout(int layout);
void setDocFirstPage(int firstPage);
/*! Opens document on doubleclick
@@ -115,9 +112,11 @@ public slots:
private slots:
void changeMargin(MarginStruct margin);
void changeBleed(MarginStruct bleed);
- void changeCategory(PageSizeInfo::Category category);
+ void changeCategory(const QString& category);
void changePageSize(const QModelIndex &ic);
void changeSortMode(int ic);
+ void savePagePreset();
+ void updateCategorySelector();
protected:
PrefsManager& prefsManager;
@@ -135,7 +134,6 @@ protected:
double m_distance { 11.0 };
QString m_unitSuffix;
QString m_selectedFile;
- QString m_pageSize;
int m_unitIndex { 0 };
int m_tabSelected { 0 };
bool m_onStartup { false };
@@ -146,6 +144,7 @@ protected:
bool m_labelVisibity {true};
bool eventFilter(QObject *object, QEvent *event);
+ void updateCategory(const QString& category, bool forceUpdate = false);
};
#endif // NEWDOC_H
diff --git a/scribus/ui/newdocdialog.ui b/scribus/ui/newdocdialog.ui
index d9312efd6..696619110 100644
--- a/scribus/ui/newdocdialog.ui
+++ b/scribus/ui/newdocdialog.ui
@@ -123,8 +123,8 @@
0
0
- 267
- 564
+ 319
+ 620
@@ -201,6 +201,60 @@
8
+ -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+ Qt::Orientation::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
-
-
@@ -430,6 +484,9 @@
Layout
+
+ 4
+
0
diff --git a/scribus/ui/newmarginwidget.cpp b/scribus/ui/newmarginwidget.cpp
index 9f92cbf97..a5d42b3af 100644
--- a/scribus/ui/newmarginwidget.cpp
+++ b/scribus/ui/newmarginwidget.cpp
@@ -6,419 +6,463 @@ for which a new license (GPL+exception) is in place.
*/
#include "newmarginwidget.h"
-#include "iconmanager.h"
+#include "iconmanager.h"
+#include "manager/pagepreset_manager.h"
+#include "scribusapp.h"
#include "scrspinbox.h"
-#include "units.h"
#include "ui/marginpresetlayout.h"
#include "ui/useprintermarginsdialog.h"
-#include "scribusapp.h"
+#include "units.h"
-NewMarginWidget::NewMarginWidget(QWidget* parent)
- : QWidget(parent)
+NewMarginWidget::NewMarginWidget(QWidget* parent) : QWidget(parent)
{
setupUi(this);
}
void NewMarginWidget::setup(const MarginStruct& margs, int layoutType, int unitIndex, int flags)
{
- m_marginData = m_savedMarginData = margs;
m_unitIndex = unitIndex;
m_unitRatio = unitGetRatioFromIndex(unitIndex);
m_flags = flags;
- leftMarginSpinBox->setMaximum(1000);
- rightMarginSpinBox->setMaximum(1000);
- topMarginSpinBox->setMaximum(1000);
- bottomMarginSpinBox->setMaximum(1000);
+ m_marginData = margs;
+ m_savedMarginData = margs;
+
leftMarginSpinBox->init(unitIndex);
rightMarginSpinBox->init(unitIndex);
topMarginSpinBox->init(unitIndex);
bottomMarginSpinBox->init(unitIndex);
- updateMarginSpinValues();
- if ((m_flags & ShowPreset) == 0)
+
+ if (!(m_flags & ShowPreset))
{
- presetLayoutComboBox->blockSignals(true);
- presetLayoutComboBox->resize(0,0);
- presetLayoutLabel->resize(0,0);
presetLayoutComboBox->hide();
presetLayoutLabel->hide();
- horizontalLayout->removeWidget(presetLayoutComboBox);
- horizontalLayout->removeWidget(presetLayoutLabel);
}
- if ((m_flags & ShowPrinterMargins) == 0)
- {
- printerMarginsPushButton->blockSignals(true);
- printerMarginsPushButton->resize(0,0);
+
+ if (!(m_flags & ShowPrinterMargins))
printerMarginsPushButton->hide();
- horizontalLayout->removeWidget(printerMarginsPushButton);
- }
+
setFacingPages(!(layoutType == singlePage));
+ disconnect(topMarginSpinBox, &ScrSpinBox::valueChanged, this, &NewMarginWidget::onSpinBoxChanged);
+ disconnect(bottomMarginSpinBox, &ScrSpinBox::valueChanged, this, &NewMarginWidget::onSpinBoxChanged);
+ disconnect(leftMarginSpinBox, &ScrSpinBox::valueChanged, this, &NewMarginWidget::onSpinBoxChanged);
+ disconnect(rightMarginSpinBox, &ScrSpinBox::valueChanged, this, &NewMarginWidget::onSpinBoxChanged);
+
+ updateUIFromState();
+
+ connect(ScQApp, &ScribusQApp::iconSetChanged, this, &NewMarginWidget::iconSetChange);
+ connect(topMarginSpinBox, &ScrSpinBox::valueChanged, this, &NewMarginWidget::onSpinBoxChanged);
+ connect(bottomMarginSpinBox, &ScrSpinBox::valueChanged, this, &NewMarginWidget::onSpinBoxChanged);
+ connect(leftMarginSpinBox, &ScrSpinBox::valueChanged, this, &NewMarginWidget::onSpinBoxChanged);
+ connect(rightMarginSpinBox, &ScrSpinBox::valueChanged, this, &NewMarginWidget::onSpinBoxChanged);
+ connect(presetLayoutComboBox, &QComboBox::activated, this, &NewMarginWidget::setPreset);
+ connect(marginLinkButton, &QToolButton::clicked, this, &NewMarginWidget::onLinkMarginsClicked);
+ connect(printerMarginsPushButton, &QPushButton::clicked, this, &NewMarginWidget::onPrinterMarginsClicked);
+
languageChange();
- iconSetChange();
- toggleLabelVisibility(true);
-
- connect(ScQApp, SIGNAL(iconSetChanged()), this, SLOT(iconSetChange()));
-// connect(ScQApp, SIGNAL(labelVisibilityChanged(bool)), this, SLOT(toggleLabelVisibility(bool)));
- connect(topMarginSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setTop()));
- connect(bottomMarginSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setBottom()));
- connect(leftMarginSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setLeft()));
- connect(rightMarginSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setRight()));
- connect(presetLayoutComboBox, SIGNAL(activated(int)), this, SLOT(setPreset()));
- connect(marginLinkButton, SIGNAL(clicked()), this, SLOT(slotLinkMargins()));
- connect(printerMarginsPushButton, SIGNAL(clicked()), this, SLOT(setMarginsToPrinterMargins()));
+ iconSetChange();
+ toggleLabelVisibility(true);
}
-void NewMarginWidget::languageChange()
+void NewMarginWidget::blockSpinBoxSignals(bool block)
{
- if (m_flags & MarginWidgetFlags)
+ leftMarginSpinBox->blockSignals(block);
+ rightMarginSpinBox->blockSignals(block);
+ topMarginSpinBox->blockSignals(block);
+ bottomMarginSpinBox->blockSignals(block);
+ presetLayoutComboBox->blockSignals(block);
+ marginLinkButton->blockSignals(block);
+}
+
+MarginStruct NewMarginWidget::calculateMarginsForPreset(int preset, double w, double h, double refLeft) const
+{
+ if (preset != PresetLayout::none && (m_flags & ShowPreset))
+ return presetLayoutComboBox->getMargins(preset, w, h, refLeft);
+
+ return m_marginData;
+}
+
+MarginStruct NewMarginWidget::sanitizeMargins(const MarginStruct& margins, double w, double h) const
+{
+ MarginStruct safe = margins;
+ bool validW = w > 0.001;
+ bool validH = h > 0.001;
+
+ if (!validW && !validH)
+ return safe;
+
+ if (marginLinkButton->isChecked() && !m_facingPages)
{
- topMarginSpinBox->setToolTip( "" + tr( "Distance between the top margin guide and the edge of the page" ) + "");
- bottomMarginSpinBox->setToolTip( "" + tr( "Distance between the bottom margin guide and the edge of the page" ) + "");
- leftMarginSpinBox->setToolTip( "" + tr( "Distance between the left margin guide and the edge of the page. If a double-sided layout is selected, this margin space can be used to achieve the correct margins for binding.") + "");
- rightMarginSpinBox->setToolTip( "" + tr( "Distance between the right margin guide and the edge of the page. If a double-sided layout is selected, this margin space can be used to achieve the correct margins for binding.") + "");
- marginLinkButton->setToolTip( "" + tr( "Ensure all margins have the same value" ) + "");
+ double limit = (validW && validH) ? qMin(w, h) : (validW ? w : h);
+ double maxVal = limit / 2.0;
+ double val = qMin(safe.left(), maxVal);
+ safe.set(val, val, val, val);
+ return safe;
}
- else if (m_flags & BleedWidgetFlags)
+
+ auto adjustDimension = [](double val1, double val2, double maxDim, double& out1, double& out2)
{
- topMarginSpinBox->setToolTip( "" + tr( "Distance for bleed from the top of the physical page" ) + "" );
- bottomMarginSpinBox->setToolTip( "" + tr( "Distance for bleed from the bottom of the physical page" ) + "" );
- leftMarginSpinBox->setToolTip( "" + tr( "Distance for bleed from the left of the physical page" ) + "" );
- rightMarginSpinBox->setToolTip( "" + tr( "Distance for bleed from the right of the physical page" ) + "");
- marginLinkButton->setToolTip( "" + tr( "Ensure all bleeds have the same value" ) + "");
- }
- else
- {
- topMarginSpinBox->setToolTip( "" + tr( "Distance from the top" ) + "" );
- bottomMarginSpinBox->setToolTip( "" + tr( "Distance from the bottom" ) + "" );
- leftMarginSpinBox->setToolTip( "" + tr( "Distance from the left" ) + "" );
- rightMarginSpinBox->setToolTip( "" + tr( "Distance from the right" ) + "");
- marginLinkButton->setToolTip( "" + tr( "Ensure all distances have the same value" ) + "");
- }
- printerMarginsPushButton->setToolTip( "" + tr( "Import the margins for the selected page size from the available printers" ) + "");
-
- leftMarginLabel->setText( m_facingPages ? tr("Inside") : tr("Left"));
- rightMarginLabel->setText( m_facingPages ? tr("Outside") : tr("Right"));
+ if (val1 + val2 > maxDim)
+ {
+ if (val1 > maxDim)
+ {
+ out1 = maxDim;
+ out2 = 0.0;
+ }
+ else
+ {
+ out1 = val1;
+ out2 = maxDim - val1;
+ }
+ }
+ else
+ {
+ out1 = val1;
+ out2 = val2;
+ }
+ };
+
+ double l = safe.left(), r = safe.right(), t = safe.top(), b = safe.bottom();
+ if (validW)
+ adjustDimension(l, r, w, l, r);
+ if (validH)
+ adjustDimension(t, b, h, t, b);
+ safe.set(t, l, b, r);
+
+ return safe;
}
-void NewMarginWidget::iconSetChange()
-{
- IconManager &im = IconManager::instance();
-
- leftMarginLabel->setPixmap(im.loadPixmap(m_facingPages ? "border-inside" : "border-left"));
- rightMarginLabel->setPixmap(im.loadPixmap(m_facingPages ? "border-outside" : "border-right"));
- topMarginLabel->setPixmap(im.loadPixmap("border-top"));
- bottomMarginLabel->setPixmap(im.loadPixmap("border-bottom"));
-}
-
-void NewMarginWidget::toggleLabelVisibility(bool v)
-{
- formWidget->setLabelVisibility(v);
- leftMarginLabel->setLabelVisibility(v);
- rightMarginLabel->setLabelVisibility(v);
- topMarginLabel->setLabelVisibility(v);
- bottomMarginLabel->setLabelVisibility(v);
-
- leftMarginLabel->setIconVisibility(!v);
- rightMarginLabel->setIconVisibility(!v);
- topMarginLabel->setIconVisibility(!v);
- bottomMarginLabel->setIconVisibility(!v);
-
-}
-
-void NewMarginWidget::setNewValues(const MarginStruct& margs)
+void NewMarginWidget::setPageWidth(double newWidth)
{
- m_marginData = m_savedMarginData = margs;
- updateMarginSpinValues();
+ MarginStruct targetMargins = m_marginData;
+
+ if ((m_flags & ShowPreset) && m_savedPresetItem != PresetLayout::none)
+ {
+ double currentLeft = leftMarginSpinBox->value() / m_unitRatio;
+ targetMargins = calculateMarginsForPreset(m_savedPresetItem, newWidth, m_pageHeight, currentLeft);
+ }
+
+ setInternalState(newWidth, m_pageHeight, targetMargins, m_savedPresetItem);
}
-void NewMarginWidget::setPageWidth(double newWidth)
+void NewMarginWidget::setPageHeight(double newHeight)
{
- // if ((m_flags & MarginWidgetFlags) == 0 || (m_flags & BleedWidgetFlags) == 0)
- // {
- leftMarginSpinBox->setMaximum(qMax(0.0, newWidth * m_unitRatio - rightMarginSpinBox->value()));
- rightMarginSpinBox->setMaximum(qMax(0.0, newWidth * m_unitRatio - leftMarginSpinBox->value()));
-// }
- m_pageWidth = newWidth;
- setPreset();
- emit valuesChanged(m_marginData);
-
+ MarginStruct targetMargins = m_marginData;
+
+ if ((m_flags & ShowPreset) && m_savedPresetItem != PresetLayout::none)
+ {
+ double currentLeft = leftMarginSpinBox->value() / m_unitRatio;
+ targetMargins = calculateMarginsForPreset(m_savedPresetItem, m_pageWidth, newHeight, currentLeft);
+ }
+
+ setInternalState(m_pageWidth, newHeight, targetMargins, m_savedPresetItem);
}
-void NewMarginWidget::setPageHeight(double newHeight)
+void NewMarginWidget::setNewValues(const MarginStruct& margs)
{
- // if ((m_flags & MarginWidgetFlags) == 0 || (m_flags & BleedWidgetFlags) == 0)
- // {
- topMarginSpinBox->setMaximum(qMax(0.0, newHeight * m_unitRatio - bottomMarginSpinBox->value()));
- bottomMarginSpinBox->setMaximum(qMax(0.0,newHeight * m_unitRatio - topMarginSpinBox->value()));
-// }
- m_pageHeight = newHeight;
- setPreset();
- emit valuesChanged(m_marginData);
-
+ setInternalState(m_pageWidth, m_pageHeight, margs, m_savedPresetItem);
}
-void NewMarginWidget::setTop()
+void NewMarginWidget::setNewUnit(int unitIndex)
{
- double newVal = topMarginSpinBox->value() / m_unitRatio;
-// if ((m_flags & MarginWidgetFlags) == 0 || (m_flags & BleedWidgetFlags) == 0)
- bottomMarginSpinBox->setMaximum(qMax(0.0, m_pageHeight * m_unitRatio - topMarginSpinBox->value()));
- if (marginLinkButton->isChecked() && m_savedPresetItem == PresetLayout::none)
- {
- m_marginData.set(newVal, newVal, newVal, newVal);
- updateMarginSpinValues();
- }
- else
- m_marginData.setTop(newVal);
- setPreset();
- emit valuesChanged(m_marginData);
-
+ m_unitIndex = unitIndex;
+ m_unitRatio = unitGetRatioFromIndex(unitIndex);
+
+ blockSpinBoxSignals(true);
+ leftMarginSpinBox->setNewUnit(unitIndex);
+ rightMarginSpinBox->setNewUnit(unitIndex);
+ topMarginSpinBox->setNewUnit(unitIndex);
+ bottomMarginSpinBox->setNewUnit(unitIndex);
+ blockSpinBoxSignals(false);
+
+ setInternalState(m_pageWidth, m_pageHeight, m_marginData, m_savedPresetItem);
}
-void NewMarginWidget::setBottom()
+void NewMarginWidget::setMarginPreset(int p)
{
- double newVal = bottomMarginSpinBox->value() / m_unitRatio;
-// if ((m_flags & MarginWidgetFlags) == 0 || (m_flags & BleedWidgetFlags) == 0)
- topMarginSpinBox->setMaximum(qMax(0.0, m_pageHeight * m_unitRatio - bottomMarginSpinBox->value()));
- if (marginLinkButton->isChecked() && m_savedPresetItem == PresetLayout::none)
+ if (!(m_flags & ShowPreset))
+ return;
+
+ MarginStruct targetMargins = m_marginData;
+
+ if (p == PresetLayout::none || m_facingPages == false)
{
- m_marginData.set(newVal, newVal, newVal, newVal);
- updateMarginSpinValues();
+ if (m_savedPresetItem != PresetLayout::none)
+ targetMargins = m_savedMarginData;
}
else
- m_marginData.setBottom(newVal);
- setPreset();
- emit valuesChanged(m_marginData);
-
+ {
+ if (m_savedPresetItem == PresetLayout::none)
+ m_savedMarginData = m_marginData;
+
+ double currentLeft = leftMarginSpinBox->value() / m_unitRatio;
+ targetMargins = calculateMarginsForPreset(p, m_pageWidth, m_pageHeight, currentLeft);
+ }
+
+ setInternalState(m_pageWidth, m_pageHeight, targetMargins, p);
}
-void NewMarginWidget::setLeft()
+void NewMarginWidget::setFacingPages(bool facing, int pageType)
{
- double newVal = leftMarginSpinBox->value() / m_unitRatio;
-// if ((m_flags & MarginWidgetFlags) == 0 || (m_flags & BleedWidgetFlags) == 0)
- rightMarginSpinBox->setMaximum(qMax(0.0, m_pageWidth * m_unitRatio - leftMarginSpinBox->value()));
- if (marginLinkButton->isChecked() && m_savedPresetItem == PresetLayout::none)
+ m_facingPages = facing;
+ m_pageType = pageType;
+
+ iconSetChange();
+ languageChange();
+
+ if (m_flags & ShowPreset)
{
- m_marginData.set(newVal, newVal, newVal, newVal);
- updateMarginSpinValues();
+ presetLayoutComboBox->setEnabled(m_facingPages);
+
+ if (m_facingPages)
+ setPreset();
+ else
+ setInternalState(m_pageWidth, m_pageHeight, m_marginData, m_savedPresetItem);
}
- else
- m_marginData.setLeft(newVal);
- setPreset();
- emit valuesChanged(m_marginData);
-
}
-void NewMarginWidget::setRight()
+void NewMarginWidget::setInternalState(double width, double height, const MarginStruct& margins, int presetIndex)
{
- double newVal = rightMarginSpinBox->value() / m_unitRatio;
-// if ((m_flags & MarginWidgetFlags) == 0 || (m_flags & BleedWidgetFlags) == 0)
- leftMarginSpinBox->setMaximum(qMax(0.0, m_pageWidth * m_unitRatio - rightMarginSpinBox->value()));
- if (marginLinkButton->isChecked() && m_savedPresetItem == PresetLayout::none)
+ blockSpinBoxSignals(true);
+
+ m_pageWidth = width;
+ m_pageHeight = height;
+ m_marginData = sanitizeMargins(margins, width, height);
+ m_savedPresetItem = presetIndex;
+
+ bool noPreset = presetIndex == PresetLayout::none || m_facingPages == false;
+
+ if (noPreset)
+ m_savedMarginData = margins;
+
+ if (m_flags & ShowPreset)
{
- m_marginData.set(newVal, newVal, newVal, newVal);
- updateMarginSpinValues();
+ presetLayoutComboBox->setCurrentIndex(presetIndex);
+ marginLinkButton->setEnabled(noPreset);
+ if (presetIndex != PresetLayout::none && m_facingPages)
+ marginLinkButton->setChecked(false);
}
- else
- m_marginData.setRight(newVal);
- setPreset();
- emit valuesChanged(m_marginData);
-
+
+ updateUIFromState();
+ updateSpinBoxLimits();
+
+ blockSpinBoxSignals(false);
+
+ emit valuesChanged(m_marginData);
}
-void NewMarginWidget::setNewUnit(int newUnitIndex)
+void NewMarginWidget::updateUIFromState()
{
- bool leftSigBlocked = leftMarginSpinBox->blockSignals(true);
- bool rightSigBlocked = rightMarginSpinBox->blockSignals(true);
- bool topSigBlocked = topMarginSpinBox->blockSignals(true);
- bool bottomSigBlocked = bottomMarginSpinBox->blockSignals(true);
-
- m_unitIndex = newUnitIndex;
- m_unitRatio = unitGetRatioFromIndex(newUnitIndex);
- topMarginSpinBox->setNewUnit(newUnitIndex);
- bottomMarginSpinBox->setNewUnit(newUnitIndex);
- leftMarginSpinBox->setNewUnit(newUnitIndex);
- rightMarginSpinBox->setNewUnit(newUnitIndex);
-
- leftMarginSpinBox->blockSignals(leftSigBlocked);
- rightMarginSpinBox->blockSignals(rightSigBlocked);
- topMarginSpinBox->blockSignals(topSigBlocked);
- bottomMarginSpinBox->blockSignals(bottomSigBlocked);
+ double maxVal = qMax(m_pageWidth, m_pageHeight) * m_unitRatio;
+ if (maxVal <= 0) maxVal = 99999;
+
+ leftMarginSpinBox->setMaximum(maxVal);
+ rightMarginSpinBox->setMaximum(maxVal);
+ topMarginSpinBox->setMaximum(maxVal);
+ bottomMarginSpinBox->setMaximum(maxVal);
+
+ leftMarginSpinBox->setValue(m_marginData.left() * m_unitRatio);
+ topMarginSpinBox->setValue(m_marginData.top() * m_unitRatio);
+ rightMarginSpinBox->setValue(m_marginData.right() * m_unitRatio);
+ bottomMarginSpinBox->setValue(m_marginData.bottom() * m_unitRatio);
+
+ bool hasPreset = (m_savedPresetItem != PresetLayout::none) && (m_flags & ShowPreset) && (m_facingPages == true);
+ bool isNineParts = (m_savedPresetItem == PresetLayout::nineparts) && (m_facingPages == true);
+
+ leftMarginSpinBox->setEnabled(!(hasPreset && isNineParts));
+ topMarginSpinBox->setEnabled(!hasPreset);
+ bottomMarginSpinBox->setEnabled(!hasPreset);
+ rightMarginSpinBox->setEnabled(!hasPreset);
+
+ marginLinkButton->setEnabled(!hasPreset);
+ if (hasPreset) marginLinkButton->setChecked(false);
}
-void NewMarginWidget::setPreset()
+void NewMarginWidget::updateSpinBoxLimits()
{
- if ((m_flags & ShowPreset) == 0)
- return;
- leftMarginSpinBox->blockSignals(true);
- rightMarginSpinBox->blockSignals(true);
- topMarginSpinBox->blockSignals(true);
- bottomMarginSpinBox->blockSignals(true);
- if (m_savedPresetItem == PresetLayout::none)
- m_savedMarginData = m_marginData;
- int item = presetLayoutComboBox->currentIndex();
-
- MarginStruct marg = presetLayoutComboBox->getMargins(item, m_pageWidth, m_pageHeight, leftMarginSpinBox->value() / m_unitRatio);
- presetLayoutComboBox->setEnabled(m_facingPages);
-
- bool restoringValues = false;
- if (item == PresetLayout::none && m_savedPresetItem != PresetLayout::none)
- {
- marg = m_savedMarginData;
- restoringValues = true;
- }
- if (restoringValues || (presetLayoutComboBox->needUpdate() && m_facingPages))
+ double h = m_pageHeight * m_unitRatio;
+ double w = m_pageWidth * m_unitRatio;
+
+ bool validW = w > 0.001;
+ bool validH = h > 0.001;
+
+ double fallbackMax = 99999.0;
+
+ if (marginLinkButton->isChecked())
{
- m_marginData.set(qMax(0.0, marg.top()), qMax(0.0, marg.left()), qMax(0.0, marg.bottom()), qMax(0.0, marg.right()));
- updateMarginSpinValues();
-
- bottomMarginSpinBox->setMaximum(qMax(0.0, m_pageHeight * m_unitRatio - topMarginSpinBox->value()));
- topMarginSpinBox->setMaximum(qMax(0.0, m_pageHeight * m_unitRatio - bottomMarginSpinBox->value()));
- rightMarginSpinBox->setMaximum(qMax(0.0, m_pageWidth * m_unitRatio - leftMarginSpinBox->value()));
- leftMarginSpinBox->setMaximum(qMax(0.0, m_pageWidth * m_unitRatio - rightMarginSpinBox->value()));
- rightMarginSpinBox->setEnabled(restoringValues);
- topMarginSpinBox->setEnabled(restoringValues);
- bottomMarginSpinBox->setEnabled(restoringValues);
+ double limit = fallbackMax;
+ if (validW && validH)
+ limit = qMin(w, h);
+ else if (validW)
+ limit = w;
+ else if (validH)
+ limit = h;
+
+ double maxAllowed = (validW || validH) ? (limit / 2.0) : fallbackMax;
+
+ topMarginSpinBox->setMaximum(maxAllowed);
+ bottomMarginSpinBox->setMaximum(maxAllowed);
+ leftMarginSpinBox->setMaximum(maxAllowed);
+ rightMarginSpinBox->setMaximum(maxAllowed);
}
else
{
- rightMarginSpinBox->setEnabled(true);
- topMarginSpinBox->setEnabled(true);
- bottomMarginSpinBox->setEnabled(true);
+ if (validH)
+ {
+ topMarginSpinBox->setMaximum(qMax(0.0, h - bottomMarginSpinBox->value()));
+ bottomMarginSpinBox->setMaximum(qMax(0.0, h - topMarginSpinBox->value()));
+ }
+ else
+ {
+ topMarginSpinBox->setMaximum(fallbackMax);
+ bottomMarginSpinBox->setMaximum(fallbackMax);
+ }
+
+ if (validW)
+ {
+ leftMarginSpinBox->setMaximum(qMax(0.0, w - rightMarginSpinBox->value()));
+ rightMarginSpinBox->setMaximum(qMax(0.0, w - leftMarginSpinBox->value()));
+ }
+ else
+ {
+ leftMarginSpinBox->setMaximum(fallbackMax);
+ rightMarginSpinBox->setMaximum(fallbackMax);
+ }
}
- if (m_pageType == 1)
- rightMarginSpinBox->setEnabled(false);
- leftMarginSpinBox->setEnabled(item != PresetLayout::nineparts);
- if (item != PresetLayout::none)
- marginLinkButton->setChecked(false);
- marginLinkButton->setEnabled(item == PresetLayout::none || !presetLayoutComboBox->isEnabled());
- leftMarginSpinBox->blockSignals(false);
- rightMarginSpinBox->blockSignals(false);
- topMarginSpinBox->blockSignals(false);
- bottomMarginSpinBox->blockSignals(false);
- m_savedPresetItem = item;
-
- emit marginChanged(m_marginData);
}
-void NewMarginWidget::setPageSize(const QString& pageSize)
+void NewMarginWidget::setPreset()
{
- m_pageSize = pageSize;
+ setMarginPreset(presetLayoutComboBox->currentIndex());
}
-
-void NewMarginWidget::updateMarginSpinValues()
+void NewMarginWidget::onSpinBoxChanged()
{
- bool leftBlocked = leftMarginSpinBox->blockSignals(true);
- bool rightBlocked = rightMarginSpinBox->blockSignals(true);
- bool topBlocked = topMarginSpinBox->blockSignals(true);
- bool bottomBlocked = bottomMarginSpinBox->blockSignals(true);
+ double val = 0.0;
- topMarginSpinBox->setValue(m_marginData.top() * m_unitRatio);
- rightMarginSpinBox->setValue(m_marginData.right() * m_unitRatio);
- bottomMarginSpinBox->setValue(m_marginData.bottom() * m_unitRatio);
- leftMarginSpinBox->setValue(m_marginData.left() * m_unitRatio);
+ QObject* s = sender();
+ if (s == topMarginSpinBox) val = topMarginSpinBox->value();
+ else if (s == bottomMarginSpinBox) val = bottomMarginSpinBox->value();
+ else if (s == rightMarginSpinBox) val = rightMarginSpinBox->value();
+ else val = leftMarginSpinBox->value();
- leftMarginSpinBox->blockSignals(leftBlocked);
- rightMarginSpinBox->blockSignals(rightBlocked);
- topMarginSpinBox->blockSignals(topBlocked);
- bottomMarginSpinBox->blockSignals(bottomBlocked);
+ double valInPoints = val / m_unitRatio;
+
+ if ((m_flags & ShowPreset) && m_savedPresetItem != PresetLayout::none && m_facingPages)
+ {
+ MarginStruct newMargins = calculateMarginsForPreset(m_savedPresetItem, m_pageWidth, m_pageHeight, valInPoints);
+ setInternalState(m_pageWidth, m_pageHeight, newMargins, m_savedPresetItem);
+ }
+ else
+ {
+ MarginStruct newM;
+
+ if (marginLinkButton->isChecked())
+ {
+ double maxAllowed = qMin(m_pageWidth, m_pageHeight) / 2.0;
+ valInPoints = qMin(maxAllowed, valInPoints);
+
+ newM.set(valInPoints, valInPoints, valInPoints, valInPoints);
+ }
+ else
+ {
+ double t = topMarginSpinBox->value() / m_unitRatio;
+ double b = bottomMarginSpinBox->value() / m_unitRatio;
+ double l = leftMarginSpinBox->value() / m_unitRatio;
+ double r = rightMarginSpinBox->value() / m_unitRatio;
+
+ if (s == topMarginSpinBox) t = valInPoints;
+ else if (s == bottomMarginSpinBox) b = valInPoints;
+ else if (s == leftMarginSpinBox) l = valInPoints;
+ else if (s == rightMarginSpinBox) r = valInPoints;
+
+ newM.set(t, l, b, r);
+ }
+
+ m_savedMarginData = newM;
+ setInternalState(m_pageWidth, m_pageHeight, newM, m_savedPresetItem);
+ }
}
-void NewMarginWidget::slotLinkMargins()
+void NewMarginWidget::onLinkMarginsClicked()
{
- bool leftBlocked = leftMarginSpinBox->blockSignals(true);
- bool rightBlocked = rightMarginSpinBox->blockSignals(true);
- bool topBlocked = topMarginSpinBox->blockSignals(true);
- bool bottomBlocked = bottomMarginSpinBox->blockSignals(true);
-
if (marginLinkButton->isChecked())
{
- bottomMarginSpinBox->setValue(leftMarginSpinBox->value());
- topMarginSpinBox->setValue(leftMarginSpinBox->value());
- rightMarginSpinBox->setValue(leftMarginSpinBox->value());
- double newVal = leftMarginSpinBox->value() / m_unitRatio;
- m_marginData.set(newVal, newVal, newVal, newVal);
-
- emit marginChanged(m_marginData);
+
+ double maxAllowed = qMin(m_pageWidth, m_pageHeight) / 2.0;
+ double val = qMin(maxAllowed, leftMarginSpinBox->value() / m_unitRatio);
+
+ MarginStruct newM(val, val, val, val);
+ setInternalState(m_pageWidth, m_pageHeight, newM, m_savedPresetItem);
}
+ else
+ updateSpinBoxLimits();
- leftMarginSpinBox->blockSignals(leftBlocked);
- rightMarginSpinBox->blockSignals(rightBlocked);
- topMarginSpinBox->blockSignals(topBlocked);
- bottomMarginSpinBox->blockSignals(bottomBlocked);
}
-void NewMarginWidget::setMarginPreset(int p)
+void NewMarginWidget::languageChange()
{
- if ((m_flags & ShowPreset) == 0)
- return;
- presetLayoutComboBox->blockSignals(true);
- m_savedPresetItem = p;
- presetLayoutComboBox->setCurrentIndex(p);
- if (m_savedPresetItem == PresetLayout::none)
- m_savedMarginData = m_marginData;
- int item = presetLayoutComboBox->currentIndex();
- presetLayoutComboBox->setEnabled(m_facingPages);
-
- bool restoringValues = false;
- if ((item == PresetLayout::none) && (m_savedPresetItem != PresetLayout::none))
+ if (m_flags & MarginWidgetFlags)
{
- restoringValues = true;
+ topMarginSpinBox->setToolTip("" + tr("Distance between the top margin guide and the edge of the page") + "");
+ bottomMarginSpinBox->setToolTip("" + tr("Distance between the bottom margin guide and the edge of the page") + "");
+ leftMarginSpinBox->setToolTip("" + tr("Distance between the left margin guide and the edge of the page. If a double-sided layout is selected, this margin space can be used to achieve the correct margins for binding.") + "");
+ rightMarginSpinBox->setToolTip("" + tr("Distance between the right margin guide and the edge of the page. If a double-sided layout is selected, this margin space can be used to achieve the correct margins for binding.") + "");
+ marginLinkButton->setToolTip("" + tr("Ensure all margins have the same value") + "");
}
- if (restoringValues || (presetLayoutComboBox->needUpdate() && m_facingPages))
+ else if (m_flags & BleedWidgetFlags)
{
- rightMarginSpinBox->setEnabled(restoringValues);
- topMarginSpinBox->setEnabled(restoringValues);
- bottomMarginSpinBox->setEnabled(restoringValues);
+ topMarginSpinBox->setToolTip("" + tr("Distance for bleed from the top of the physical page") + "");
+ bottomMarginSpinBox->setToolTip("" + tr("Distance for bleed from the bottom of the physical page") + "");
+ leftMarginSpinBox->setToolTip("" + tr("Distance for bleed from the left of the physical page") + "");
+ rightMarginSpinBox->setToolTip("" + tr("Distance for bleed from the right of the physical page") + "");
+ marginLinkButton->setToolTip("" + tr("Ensure all bleeds have the same value") + "");
}
else
{
- rightMarginSpinBox->setEnabled(true);
- topMarginSpinBox->setEnabled(true);
- bottomMarginSpinBox->setEnabled(true);
+ topMarginSpinBox->setToolTip("" + tr("Distance from the top") + "");
+ bottomMarginSpinBox->setToolTip("" + tr("Distance from the bottom") + "");
+ leftMarginSpinBox->setToolTip("" + tr("Distance from the left") + "");
+ rightMarginSpinBox->setToolTip("" + tr("Distance from the right") + "");
+ marginLinkButton->setToolTip("" + tr("Ensure all distances have the same value") + "");
}
- if (m_pageType == 1)
- rightMarginSpinBox->setEnabled(false);
- leftMarginSpinBox->setEnabled(item != PresetLayout::nineparts);
- if (item != PresetLayout::none)
- marginLinkButton->setChecked(false);
- marginLinkButton->setEnabled(item == PresetLayout::none);
- presetLayoutComboBox->blockSignals(false);
+ printerMarginsPushButton->setToolTip("" + tr("Import the margins for the selected page size from the available printers") + "");
+
+ leftMarginLabel->setText(m_facingPages ? tr("Inside") : tr("Left"));
+ rightMarginLabel->setText(m_facingPages ? tr("Outside") : tr("Right"));
}
-void NewMarginWidget::setFacingPages(bool facing, int pageType)
+void NewMarginWidget::iconSetChange()
{
- m_facingPages = facing;
- m_pageType = pageType;
-
- leftMarginLabel->setText( m_facingPages ? tr("Inside") : tr("Left"));
- rightMarginLabel->setText( m_facingPages ? tr("Outside") : tr("Right"));
-
- iconSetChange();
- setPreset();
+ IconManager& im = IconManager::instance();
+
+ leftMarginLabel->setPixmap(im.loadPixmap(m_facingPages ? "border-inside" : "border-left"));
+ rightMarginLabel->setPixmap(im.loadPixmap(m_facingPages ? "border-outside" : "border-right"));
+ topMarginLabel->setPixmap(im.loadPixmap("border-top"));
+ bottomMarginLabel->setPixmap(im.loadPixmap("border-bottom"));
}
-void NewMarginWidget::setMarginsToPrinterMargins()
+void NewMarginWidget::toggleLabelVisibility(bool v)
{
- QSizeF pageDimensions(m_pageWidth, m_pageHeight);
- UsePrinterMarginsDialog upm(parentWidget(), pageDimensions, m_pageSize, unitGetRatioFromIndex(m_unitIndex), unitGetSuffixFromIndex(m_unitIndex));
- if (upm.exec() != QDialog::Accepted)
- return;
-
- double t, b, l, r;
- upm.getNewPrinterMargins(t, b, l, r);
- presetLayoutComboBox->setCurrentIndex(PresetLayout::none);
- m_marginData.set(t, l, b, r);
+ formWidget->setLabelVisibility(v);
+ leftMarginLabel->setLabelVisibility(v);
+ rightMarginLabel->setLabelVisibility(v);
+ topMarginLabel->setLabelVisibility(v);
+ bottomMarginLabel->setLabelVisibility(v);
+}
- updateMarginSpinValues();
+void NewMarginWidget::onPrinterMarginsClicked()
+{
+ QSizeF pageDimensions(m_pageWidth, m_pageHeight);
+ PageSizeInfo psi = PagePresetManager::instance().pageInfoByDimensions(m_pageWidth, m_pageHeight);
- bottomMarginSpinBox->setMaximum((qMax(0.0, m_pageHeight - t) * m_unitRatio));
- topMarginSpinBox->setMaximum((qMax(0.0, m_pageHeight - b) * m_unitRatio));
- rightMarginSpinBox->setMaximum((qMax(0.0, m_pageWidth - l) * m_unitRatio));
- leftMarginSpinBox->setMaximum((qMax(0.0, m_pageWidth - r) * m_unitRatio));
+ UsePrinterMarginsDialog upm(this, pageDimensions, psi.displayName, m_unitRatio, unitGetSuffixFromIndex(m_unitIndex));
- rightMarginSpinBox->setEnabled(true);
- topMarginSpinBox->setEnabled(true);
- bottomMarginSpinBox->setEnabled(true);
+ if (upm.exec() == QDialog::Accepted)
+ {
+ double t, b, l, r;
+ upm.getNewPrinterMargins(t, b, l, r);
+ MarginStruct newMargins(t, l, b, r);
+ setInternalState(m_pageWidth, m_pageHeight, newMargins, PresetLayout::none);
+ }
}
-
diff --git a/scribus/ui/newmarginwidget.h b/scribus/ui/newmarginwidget.h
index e778c444b..6b186da61 100644
--- a/scribus/ui/newmarginwidget.h
+++ b/scribus/ui/newmarginwidget.h
@@ -10,76 +10,76 @@ for which a new license (GPL+exception) is in place.
#include "ui_newmarginwidgetbase.h"
#include "scribusapi.h"
-#include "scribusstructs.h"
class SCRIBUS_API NewMarginWidget : public QWidget, Ui::NewMarginWidget
{
Q_OBJECT
- public:
- NewMarginWidget(QWidget* parent = nullptr);
- ~NewMarginWidget() = default;
-
- enum SetupFlags
- {
- DistanceWidgetFlags = 0,
- ShowPreset = 1,
- ShowPrinterMargins = 2,
- MarginWidgetFlags = 3,
- BleedWidgetFlags = 4
- };
-
- void setup(const MarginStruct& margs, int layoutType, int unitIndex, int flags = MarginWidgetFlags);
- /*! \brief Setup the labels by facing pages option */
- void setFacingPages(bool facing, int pageType = 0);
- /*! \brief Setup the spinboxes properties (min/max value etc.) by width */
- void setPageWidth(double);
- /*! \brief Setup the spinboxes properties (min/max value etc.) by height */
- void setPageHeight(double);
- /*! \brief Set the page size for margin getting from cups */
- void setPageSize(const QString&);
- void setNewUnit(int unitIndex);
- void setNewValues(const MarginStruct& margs);
- /*! \brief Setup the presetCombo without changing the margin values, only used by tabdocument */
- void setMarginPreset(int p);
- int marginPreset() { return m_savedPresetItem; };
- const MarginStruct & margins() const { return m_marginData; };
-
- public slots:
- void languageChange();
- void iconSetChange();
- void toggleLabelVisibility(bool v);
- void setTop();
- void setBottom();
- void setLeft();
- void setRight();
- void slotLinkMargins();
- void setPreset();
-
- protected slots:
- void setMarginsToPrinterMargins();
-
- protected:
- void updateMarginSpinValues();
-
- MarginStruct m_marginData;
- MarginStruct m_savedMarginData;
- QString m_pageSize;
- bool m_facingPages {false};
- double m_pageHeight {0.0};
- double m_pageWidth {0.0};
- double m_unitRatio {1.0};
- int m_flags {MarginWidgetFlags};
- int m_pageType {0};
- int m_savedPresetItem {PresetLayout::none};
- int m_unitIndex {0};
+public:
+ NewMarginWidget(QWidget* parent = nullptr);
+ ~NewMarginWidget() = default;
-signals:
- void marginChanged(MarginStruct);
- void valuesChanged(MarginStruct);
-};
+ enum SetupFlags
+ {
+ DistanceWidgetFlags = 0,
+ ShowPreset = 1,
+ ShowPrinterMargins = 2,
+ MarginWidgetFlags = 3,
+ BleedWidgetFlags = 4
+ };
-#endif // NEWMARGINWIDGET_H
+ void setup(const MarginStruct& margs, int layoutType, int unitIndex, int flags = MarginWidgetFlags);
+ /*! \brief Setup the labels by facing pages option */
+ void setFacingPages(bool facing, int pageType = 0);
+ /*! \brief Setup the spinboxes properties (min/max value etc.) by width */
+ void setPageWidth(double width);
+ /*! \brief Setup the spinboxes properties (min/max value etc.) by height */
+ void setPageHeight(double height);
+ void setNewUnit(int unitIndex);
+ void setNewValues(const MarginStruct& margs);
+ /*! \brief Setup the presetCombo without changing the margin values */
+ void setMarginPreset(int p);
+
+ int marginPreset() const { return m_savedPresetItem; };
+
+ const MarginStruct& margins() const { return m_marginData; };
+
+public slots:
+ void languageChange();
+ void iconSetChange();
+ void toggleLabelVisibility(bool v);
+
+protected slots:
+
+ void onSpinBoxChanged();
+ void onLinkMarginsClicked();
+ void onPrinterMarginsClicked();
+ void setPreset();
+protected:
+ bool m_facingPages {false};
+ double m_pageHeight {0.0};
+ double m_pageWidth {0.0};
+ double m_unitRatio {1.0};
+ int m_flags {MarginWidgetFlags};
+ int m_pageType {0};
+ int m_savedPresetItem {PresetLayout::none};
+ int m_unitIndex {0};
+ MarginStruct m_marginData;
+ MarginStruct m_savedMarginData;
+
+ MarginStruct calculateMarginsForPreset(int preset, double w, double h, double refLeft) const;
+ MarginStruct sanitizeMargins(const MarginStruct& margins, double w, double h) const;
+
+ void setInternalState(double width, double height, const MarginStruct& margins, int presetIndex);
+ void updateUIFromState();
+ void updateSpinBoxLimits();
+ void blockSpinBoxSignals(bool block);
+
+signals:
+ void valuesChanged(MarginStruct);
+};
+
+#endif // NEWMARGINWIDGET_H
diff --git a/scribus/ui/newmarginwidgetbase.ui b/scribus/ui/newmarginwidgetbase.ui
index f903fd3be..87603be2f 100644
--- a/scribus/ui/newmarginwidgetbase.ui
+++ b/scribus/ui/newmarginwidgetbase.ui
@@ -37,6 +37,9 @@
-
+
+ 4
+
-
@@ -206,6 +209,9 @@
-
+
+ 4
+
-
@@ -324,7 +330,7 @@
ScrSpinBox
QDoubleSpinBox
-
+
LinkButton
diff --git a/scribus/ui/pagepropertiesdialog.cpp b/scribus/ui/pagepropertiesdialog.cpp
index d35a7cd77..3a5da68d8 100644
--- a/scribus/ui/pagepropertiesdialog.cpp
+++ b/scribus/ui/pagepropertiesdialog.cpp
@@ -19,7 +19,7 @@ for which a new license (GPL+exception) is in place.
#include "iconmanager.h"
#include "newmarginwidget.h"
#include "pagepropertiesdialog.h"
-#include "pagesize.h"
+#include "manager/pagepreset_manager.h"
#include "pagestructs.h"
#include "scpage.h"
#include "scribusdoc.h"
@@ -38,17 +38,8 @@ PagePropertiesDialog::PagePropertiesDialog( QWidget* parent, ScribusDoc* doc )
dialogLayout->setContentsMargins(9, 9, 9, 9);
dialogLayout->setSpacing(4);
- PageSize ps(doc->currentPage()->size());
-
- // try to find corresponding page size by dimensions
- if (ps.name() == CommonStrings::customPageSize)
- {
- PageSizeInfoMap pages = ps.sizesByDimensions(QSize(doc->currentPage()->width(), doc->currentPage()->height()));
- if (pages.count() > 0)
- prefsPageSizeName = pages.firstKey();
- }
- else
- prefsPageSizeName = ps.name();
+ PageSizeInfo psi = PagePresetManager::instance().pageInfoByDimensions(QSize(doc->currentPage()->width(), doc->currentPage()->height()));
+ prefsPageSizeName = psi.id;
dsGroupBox7 = new QGroupBox(this);
dsGroupBox7->setTitle( tr( "Page Size" ) );
@@ -59,7 +50,7 @@ PagePropertiesDialog::PagePropertiesDialog( QWidget* parent, ScribusDoc* doc )
TextLabel1 = new QLabel( tr( "&Size:" ), dsGroupBox7 );
dsGroupBox7Layout->addWidget( TextLabel1, 0, 0, Qt::AlignTop | Qt::AlignRight);
pageSizeSelector = new PageSizeSelector(dsGroupBox7);
- pageSizeSelector->setPageSize(doc->currentPage()->size());
+ pageSizeSelector->setPageSize(doc->currentPage()->width(), doc->currentPage()->height());
TextLabel1->setBuddy(pageSizeSelector);
dsGroupBox7Layout->addWidget(pageSizeSelector, 0, 1);
TextLabel2 = new QLabel( tr( "Orie&ntation:" ), dsGroupBox7 );
@@ -111,13 +102,11 @@ PagePropertiesDialog::PagePropertiesDialog( QWidget* parent, ScribusDoc* doc )
}
dialogLayout->addWidget( dsGroupBox7 );
-// marginWidget = new MarginWidget(this, tr( "Margin Guides" ), &doc->currentPage()->initialMargins, doc->unitIndex(), false, false);
marginWidget = new NewMarginWidget();
- marginWidget->setup(doc->currentPage()->initialMargins, doc->currentPage()->marginPreset, doc->unitIndex(), NewMarginWidget::MarginWidgetFlags );
+ marginWidget->setup(doc->currentPage()->initialMargins, !(doc->pagePositioning() == singlePage), doc->unitIndex(), NewMarginWidget::MarginWidgetFlags );
marginWidget->setPageHeight(doc->currentPage()->height());
marginWidget->setPageWidth(doc->currentPage()->width());
- marginWidget->setFacingPages(!(doc->pagePositioning() == singlePage), doc->locationOfPage(doc->currentPage()->pageNr()));
-// marginWidget->setMarginPreset(doc->currentPage()->marginPreset);
+ marginWidget->setMarginPreset(doc->currentPage()->marginPreset);
dialogLayout->addWidget( marginWidget );
groupMaster = new QGroupBox( this );
@@ -165,7 +154,7 @@ PagePropertiesDialog::PagePropertiesDialog( QWidget* parent, ScribusDoc* doc )
m_pageWidth = widthSpinBox->value() / m_unitRatio;
m_pageHeight = heightSpinBox->value() / m_unitRatio;
- bool isCustom = (pageSizeSelector->pageSizeTR() == CommonStrings::trCustomPageSize);
+ bool isCustom = (pageSizeSelector->pageSize() == CommonStrings::customPageSize);
heightSpinBox->setEnabled(isCustom);
widthSpinBox->setEnabled(isCustom);
// signals and slots connections
@@ -219,7 +208,7 @@ void PagePropertiesDialog::setPageHeight(double)
void PagePropertiesDialog::setPageSize()
{
- if (pageSizeSelector->pageSizeTR() != CommonStrings::trCustomPageSize)
+ if (pageSizeSelector->pageSize() != CommonStrings::customPageSize)
oldOri++;
setOrientation(orientationQComboBox->currentIndex());
}
@@ -230,18 +219,19 @@ void PagePropertiesDialog::setSize(const QString & gr)
m_pageHeight = heightSpinBox->value() / m_unitRatio;
widthSpinBox->setEnabled(false);
heightSpinBox->setEnabled(false);
- PageSize ps2(gr);
- prefsPageSizeName = ps2.name();
- if (gr == CommonStrings::trCustomPageSize)
+
+ PageSizeInfo psi = PagePresetManager::instance().pageInfoByName(gr);
+
+ prefsPageSizeName = psi.id;
+ if (gr == CommonStrings::customPageSize)
{
widthSpinBox->setEnabled(true);
heightSpinBox->setEnabled(true);
- prefsPageSizeName = CommonStrings::customPageSize;
}
else
{
- m_pageWidth = ps2.width();
- m_pageHeight = ps2.height();
+ m_pageWidth = psi.width;
+ m_pageHeight = psi.height;
}
disconnect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setPageWidth(double)));
disconnect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setPageHeight(double)));
@@ -249,17 +239,16 @@ void PagePropertiesDialog::setSize(const QString & gr)
heightSpinBox->setValue(m_pageHeight * m_unitRatio);
marginWidget->setPageHeight(m_pageHeight);
marginWidget->setPageWidth(m_pageWidth);
- marginWidget->setPageSize(gr);
connect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setPageWidth(double)));
connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setPageHeight(double)));
}
void PagePropertiesDialog::setOrientation(int ori)
{
- setSize(pageSizeSelector->pageSizeTR());
+ setSize(pageSizeSelector->pageSize());
disconnect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setPageWidth(double)));
disconnect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setPageHeight(double)));
- if ((pageSizeSelector->pageSizeTR() == CommonStrings::trCustomPageSize) && (ori != oldOri))
+ if ((pageSizeSelector->pageSize() == CommonStrings::customPageSize) && (ori != oldOri))
{
double w = widthSpinBox->value(), h = heightSpinBox->value();
widthSpinBox->setValue((ori == portraitPage) ? qMin(w, h) : qMax(w, h));
diff --git a/scribus/ui/preferences/prefs_documentsetup.cpp b/scribus/ui/preferences/prefs_documentsetup.cpp
index eb238fbca..b80dbb1c8 100644
--- a/scribus/ui/preferences/prefs_documentsetup.cpp
+++ b/scribus/ui/preferences/prefs_documentsetup.cpp
@@ -11,7 +11,7 @@ for which a new license (GPL+exception) is in place.
#include "commonstrings.h"
#include "langmgr.h"
-#include "pagesize.h"
+#include "manager/pagepreset_manager.h"
#include "prefsfile.h"
#include "prefsmanager.h"
#include "prefsstructs.h"
@@ -197,12 +197,10 @@ void Prefs_DocumentSetup::restoreDefaults(struct ApplicationPrefs *prefsData)
marginsWidget->setup(prefsData->docSetupPrefs.margins, prefsData->docSetupPrefs.pagePositioning, prefsData->docSetupPrefs.docUnitIndex, NewMarginWidget::MarginWidgetFlags);
marginsWidget->setPageWidth(prefsData->docSetupPrefs.pageWidth);
marginsWidget->setPageHeight(prefsData->docSetupPrefs.pageHeight);
-// marginsWidget->setPageSize(prefsPageSizeName);
marginsWidget->setMarginPreset(prefsData->docSetupPrefs.marginPreset);
bleedsWidget->setup(prefsData->docSetupPrefs.bleeds, prefsData->docSetupPrefs.pagePositioning, prefsData->docSetupPrefs.docUnitIndex, NewMarginWidget::BleedWidgetFlags);
bleedsWidget->setPageWidth(prefsData->docSetupPrefs.pageWidth);
bleedsWidget->setPageHeight(prefsData->docSetupPrefs.pageHeight);
-// bleedsWidget->setPageSize(prefsPageSizeName);
bleedsWidget->setMarginPreset(prefsData->docSetupPrefs.marginPreset);
saveCompressedCheckBox->setChecked(prefsData->docSetupPrefs.saveCompressed);
emergencyCheckBox->setChecked(prefsData->miscPrefs.saveEmergencyFile);
@@ -285,21 +283,12 @@ void Prefs_DocumentSetup::setupPageSets()
void Prefs_DocumentSetup::setupPageSizes(struct ApplicationPrefs *prefsData)
{
- prefsPageSizeName = prefsData->docSetupPrefs.pageSize;
+ double width = prefsData->docSetupPrefs.pageWidth;
+ double height = prefsData->docSetupPrefs.pageHeight;
- PageSize ps(prefsPageSizeName);
+ pageSizeSelector->setPageSize(width, height);
+ prefsPageSizeName = pageSizeSelector->pageSize();
- // try to find coresponding page size by dimensions
- if (ps.name() == CommonStrings::customPageSize)
- {
- PageSizeInfoMap pages = ps.sizesByDimensions(QSize(prefsData->docSetupPrefs.pageWidth, prefsData->docSetupPrefs.pageHeight));
- if (pages.count() > 0)
- prefsPageSizeName = pages.firstKey();
- }
-
- pageSizeSelector->setPageSize(prefsPageSizeName);
- marginsWidget->setPageSize(prefsPageSizeName);
- bleedsWidget->setPageSize(prefsPageSizeName);
}
void Prefs_DocumentSetup::pageLayoutChanged(int i)
@@ -313,9 +302,9 @@ void Prefs_DocumentSetup::setPageWidth(double w)
{
pageW = pageWidthSpinBox->value() / unitRatio;
marginsWidget->setPageWidth(pageW);
- QString psText = pageSizeSelector->pageSizeTR();
- if (psText != CommonStrings::trCustomPageSize && psText != CommonStrings::customPageSize)
- pageSizeSelector->setPageSize(CommonStrings::customPageSize);
+
+ pageSizeSelector->setPageSize(pageW, pageH);
+
int newOrientation = (pageWidthSpinBox->value() > pageHeightSpinBox->value()) ? landscapePage : portraitPage;
if (newOrientation != pageOrientationComboBox->currentIndex())
{
@@ -329,9 +318,9 @@ void Prefs_DocumentSetup::setPageHeight(double h)
{
pageH = pageHeightSpinBox->value() / unitRatio;
marginsWidget->setPageHeight(pageH);
- QString psText = pageSizeSelector->pageSizeTR();
- if (psText != CommonStrings::trCustomPageSize && psText != CommonStrings::customPageSize)
- pageSizeSelector->setPageSize(CommonStrings::customPageSize);
+
+ pageSizeSelector->setPageSize(pageW, pageH);
+
int newOrientation = (pageWidthSpinBox->value() > pageHeightSpinBox->value()) ? landscapePage : portraitPage;
if (newOrientation != pageOrientationComboBox->currentIndex())
{
@@ -346,7 +335,7 @@ void Prefs_DocumentSetup::setPageOrientation(int orientation)
setSize(pageSizeSelector->pageSize());
pageWidthSpinBox->blockSignals(true);
pageHeightSpinBox->blockSignals(true);
- if ((orientation==0 && pageSizeSelector->pageSizeTR() == CommonStrings::trCustomPageSize) || orientation!=0)
+ if ((orientation == 0 && pageSizeSelector->pageSize() == CommonStrings::customPageSize) || orientation != 0)
{
double w = pageWidthSpinBox->value(), h = pageHeightSpinBox->value();
pageWidthSpinBox->setValue((orientation == portraitPage) ? qMin(w, h) : qMax(w, h));
@@ -368,15 +357,14 @@ void Prefs_DocumentSetup::setSize(const QString &newSize)
pageW = pageWidthSpinBox->value() / unitRatio;
pageH = pageHeightSpinBox->value() / unitRatio;
- PageSize ps2(newSize);
- prefsPageSizeName = ps2.name();
- if (newSize != CommonStrings::customPageSize && newSize != CommonStrings::trCustomPageSize)
+ PageSizeInfo psi = PagePresetManager::instance().pageInfoByName(newSize);
+
+ prefsPageSizeName = psi.id;
+ if (psi.id != CommonStrings::customPageSize)
{
- pageW = ps2.width();
- pageH = ps2.height();
+ pageW = psi.width;
+ pageH = psi.height;
}
- else
- prefsPageSizeName = CommonStrings::customPageSize;
pageWidthSpinBox->blockSignals(true);
pageHeightSpinBox->blockSignals(true);
@@ -384,7 +372,6 @@ void Prefs_DocumentSetup::setSize(const QString &newSize)
pageHeightSpinBox->setValue(pageH * unitRatio);
marginsWidget->setPageHeight(pageH);
marginsWidget->setPageWidth(pageW);
- marginsWidget->setPageSize(newSize);
pageWidthSpinBox->blockSignals(false);
pageHeightSpinBox->blockSignals(false);
}
diff --git a/scribus/ui/preferences/prefs_pagesizes.cpp b/scribus/ui/preferences/prefs_pagesizes.cpp
index d0f7ccef4..cffe85543 100644
--- a/scribus/ui/preferences/prefs_pagesizes.cpp
+++ b/scribus/ui/preferences/prefs_pagesizes.cpp
@@ -9,9 +9,9 @@ for which a new license (GPL+exception) is in place.
#include
#include "iconmanager.h"
-#include "pagesize.h"
#include "prefsstructs.h"
#include "scribusdoc.h"
+#include "manager/pagepreset_manager.h"
#include "ui/preferences/prefs_pagesizes.h"
@@ -41,20 +41,28 @@ void Prefs_PageSizes::languageChange()
QString textSize = tr("Page Format");
QString textDimension = tr("Dimension");
- if(QTreeWidgetItem* header = treeAvailableSizes->headerItem()) {
+ if(QTreeWidgetItem* header = treeAvailableSizes->headerItem())
+ {
header->setText(0, textSize);
if (header->columnCount() > 1)
header->setText(1, textDimension);
+
+ treeAvailableSizes->resizeColumnToContents(0);
+ treeAvailableSizes->resizeColumnToContents(1);
}
else
treeAvailableSizes->setHeaderLabel( textSize );
- if(QTreeWidgetItem* header = treeActiveSizes->headerItem()) {
+ if(QTreeWidgetItem* header = treeActiveSizes->headerItem())
+ {
header->setText(0, textSize);
if (header->columnCount() > 1)
header->setText(1, textDimension);
+
+ treeActiveSizes->resizeColumnToContents(0);
+ treeActiveSizes->resizeColumnToContents(1);
}
else
treeActiveSizes->setHeaderLabel( textSize );
@@ -63,66 +71,51 @@ void Prefs_PageSizes::languageChange()
void Prefs_PageSizes::restoreDefaults(struct ApplicationPrefs *prefsData)
{
- PageSize ps(prefsData->docSetupPrefs.pageSize);
-
treeAvailableSizes->clear();
treeActiveSizes->clear();
- auto cats = ps.categories();
+ auto& ppm = PagePresetManager::instance();
+ auto categories = ppm.categoriesOrder();
+ auto activeSizesMap = ppm.activePageSizes();
- // Available Page Sizes
- for (auto it = cats.begin(); it != cats.end(); ++it)
+ for (int i = 0; i < categories.size(); i++)
{
- QTreeWidgetItem* tlItem = new QTreeWidgetItem();
- tlItem->setText(0, it.value());
- tlItem->setData(0, Qt::UserRole, it.key());
+ QString id = categories.at(i);
+ if (id == "-")
+ continue;
- treeAvailableSizes->addTopLevelItem(tlItem);
+ PageCollectionInfo pci = ppm.categoryInfoById(id);
- PageSizeInfoMap sizes = ps.sizesByCategory(it.key());
+ QTreeWidgetItem* tlItemAvailable = new QTreeWidgetItem();
+ tlItemAvailable->setText(0, pci.displayName);
+ tlItemAvailable->setData(0, Qt::UserRole, id);
+ treeAvailableSizes->addTopLevelItem(tlItemAvailable);
- for (auto s = sizes.begin(); s != sizes.end(); ++s)
- {
- if (!ps.activePageSizes().contains(s.key()))
- {
- QTreeWidgetItem* sItem = new QTreeWidgetItem();
- sItem->setText(0, s.value().trSizeName);
- sItem->setText(1, s.value().sizeLabel);
- sItem->setData(0, Qt::UserRole, s.key());
+ QTreeWidgetItem* tlItemActive = new QTreeWidgetItem();
+ tlItemActive->setText(0, pci.displayName);
+ tlItemActive->setData(0, Qt::UserRole, id);
+ treeActiveSizes->addTopLevelItem(tlItemActive);
- tlItem->addChild(sItem);
- }
- }
- }
+ PageSizeInfoMap catSizes = ppm.sizesByCategory(id);
- // Active page Sizes
- for (auto it = cats.begin(); it != cats.end(); ++it)
- {
- PageSizeInfo::Category cat = it.key();
-
- QTreeWidgetItem* tlItem = new QTreeWidgetItem();
- tlItem->setText(0, it.value());
- tlItem->setData(0, Qt::UserRole, cat);
-
- treeActiveSizes->addTopLevelItem(tlItem);
-
- PageSizeInfoMap sizes = ps.activePageSizes();
-
- for (auto s = sizes.begin(); s != sizes.end(); ++s)
+ for (auto s = catSizes.begin(); s != catSizes.end(); ++s)
{
- if (s.value().category == cat)
- {
- QTreeWidgetItem* sItem = new QTreeWidgetItem();
- sItem->setText(0, s.value().trSizeName);
- sItem->setText(1, s.value().sizeLabel);
- sItem->setData(0, Qt::UserRole, s.key());
-
- tlItem->addChild(sItem);
- }
-
+ QTreeWidgetItem* sItem = new QTreeWidgetItem();
+ sItem->setText(0, s.value().displayName);
+ sItem->setText(1, s.value().label);
+ sItem->setData(0, Qt::UserRole, s.key());
+
+ if (activeSizesMap.contains(s.key()))
+ tlItemActive->addChild(sItem);
+ else
+ tlItemAvailable->addChild(sItem);
}
}
+ treeAvailableSizes->resizeColumnToContents(0);
+ treeAvailableSizes->resizeColumnToContents(1);
+ treeActiveSizes->resizeColumnToContents(0);
+ treeActiveSizes->resizeColumnToContents(1);
}
void Prefs_PageSizes::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const
@@ -131,7 +124,7 @@ void Prefs_PageSizes::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const
for (int i = 0; i < treeActiveSizes->topLevelItemCount(); ++i)
{
- QTreeWidgetItem* item = treeActiveSizes->takeTopLevelItem(i);
+ QTreeWidgetItem* item = treeActiveSizes->topLevelItem(i);
for (int j = 0; j < item->childCount(); ++j)
newActivePageSizes << item->child(j)->data(0, Qt::UserRole).toString();
diff --git a/scribus/ui/preferences/prefs_pdfexport.cpp b/scribus/ui/preferences/prefs_pdfexport.cpp
index e3fad1438..e98e956a7 100644
--- a/scribus/ui/preferences/prefs_pdfexport.cpp
+++ b/scribus/ui/preferences/prefs_pdfexport.cpp
@@ -411,13 +411,12 @@ void Prefs_PDFExport::restoreDefaults(struct ApplicationPrefs *prefsData, const
}
convertSpotsToProcessCheckBox->setChecked(!prefsData->pdfPrefs.UseSpotColors);
- bleedsWidget->setup(prefsData->pdfPrefs.bleeds, prefsData->docSetupPrefs.pagePositioning, prefsData->docSetupPrefs.docUnitIndex, NewMarginWidget::BleedWidgetFlags);
- bleedsWidget->setPageWidth(prefsData->docSetupPrefs.pageWidth);
- bleedsWidget->setPageHeight(prefsData->docSetupPrefs.pageHeight);
- bleedsWidget->setPageSize(prefsData->docSetupPrefs.pageSize);
- bleedsWidget->setMarginPreset(prefsData->docSetupPrefs.marginPreset);
-//
- useCustomRenderingCheckBox->setChecked(prefsData->pdfPrefs.UseLPI);
+ bleedsWidget->setup(prefsData->pdfPrefs.bleeds, prefsData->docSetupPrefs.pagePositioning, prefsData->docSetupPrefs.docUnitIndex, NewMarginWidget::BleedWidgetFlags);
+ bleedsWidget->setPageWidth(prefsData->docSetupPrefs.pageWidth);
+ bleedsWidget->setPageHeight(prefsData->docSetupPrefs.pageHeight);
+ bleedsWidget->setMarginPreset(prefsData->docSetupPrefs.marginPreset);
+//
+ useCustomRenderingCheckBox->setChecked(prefsData->pdfPrefs.UseLPI);
customRenderingColorComboBox->clear();
for (auto itlp = prefsData->pdfPrefs.LPISettings.cbegin(); itlp != prefsData->pdfPrefs.LPISettings.cend(); ++itlp)
customRenderingColorComboBox->addItem( itlp.key() );
diff --git a/scribus/ui/widgets/pagesizelist.cpp b/scribus/ui/widgets/pagesizelist.cpp
index cf40f7102..776be9682 100644
--- a/scribus/ui/widgets/pagesizelist.cpp
+++ b/scribus/ui/widgets/pagesizelist.cpp
@@ -7,9 +7,9 @@ for which a new license (GPL+exception) is in place.
#include
#include
-#include "pagesize.h"
#include "pagesizelist.h"
#include "prefsmanager.h"
+#include "manager/pagepreset_manager.h"
#include "ui/delegates/sclistitemdelegate.h"
@@ -37,25 +37,28 @@ PageSizeList::PageSizeList(QWidget* parent) :
#endif
setItemDelegate(new ScListItemDelegate(QListWidget::IconMode, iconSize()));
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
+ setContextMenuPolicy(Qt::CustomContextMenu);
+
+ connect(this, &QListView::customContextMenuRequested, this, &PageSizeList::showContextMenu);
}
-void PageSizeList::setFormat(QString format)
+void PageSizeList::setDimensions(double width, double height)
{
- loadPageSizes(format, m_orientation, m_category);
- m_name = format;
+ loadPageSizes(QSizeF(width, height), m_orientation, m_category);
+ m_dimensions = QSizeF(width, height);
setSortMode(m_sortMode);
}
void PageSizeList::setOrientation(int orientation)
{
- loadPageSizes(m_name, orientation, m_category);
+ loadPageSizes(m_dimensions, orientation, m_category);
m_orientation = orientation;
setSortMode(m_sortMode);
}
-void PageSizeList::setCategory(PageSizeInfo::Category category)
+void PageSizeList::setCategory(const QString& category)
{
- loadPageSizes(m_name, m_orientation, category);
+ loadPageSizes(m_dimensions, m_orientation, category);
m_category = category;
setSortMode(m_sortMode);
}
@@ -87,21 +90,23 @@ void PageSizeList::setSortMode(SortMode sortMode)
}
}
-void PageSizeList::setValues(QString format, int orientation, PageSizeInfo::Category category, SortMode sortMode)
+void PageSizeList::setValues(QSizeF dimensions, int orientation, const QString& category, SortMode sortMode)
{
- loadPageSizes(format, orientation, category);
- m_name = format;
+ loadPageSizes(dimensions, orientation, category);
+ m_dimensions = dimensions;
m_orientation = orientation;
m_category = category;
setSortMode(sortMode);
}
-void PageSizeList::loadPageSizes(QString name, int orientation, PageSizeInfo::Category category)
+void PageSizeList::loadPageSizes(QSizeF dimensions, int orientation, const QString& category)
{
QSignalBlocker sig(this);
- PageSize ps(name);
- PageSize pref(PrefsManager::instance().appPrefs.docSetupPrefs.pageSize);
+ auto &ppm = PagePresetManager::instance();
+
+ PageSizeInfo pref = ppm.pageInfoByDimensions(PrefsManager::instance().appPrefs.docSetupPrefs.pageWidth, PrefsManager::instance().appPrefs.docSetupPrefs.pageHeight);
+ PageSizeInfo ps = ppm.pageInfoByDimensions(dimensions.width(), dimensions.height());
int sel = -1;
@@ -109,35 +114,66 @@ void PageSizeList::loadPageSizes(QString name, int orientation, PageSizeInfo::Ca
m_model->setSortRole(ItemData::Name);
m_model->sort(0, Qt::AscendingOrder);
- if (m_category == category && this->selectionModel()->currentIndex().isValid())
- sel = this->selectionModel()->currentIndex().row();
+ // enable if list selection should be remembered
+ // if (m_category == category && this->selectionModel()->currentIndex().isValid())
+ // sel = this->selectionModel()->currentIndex().row();
m_model->clear();
- foreach (auto item, ps.pageSizes())
+ PageCollectionInfo pciPreferred = ppm.categoryInfoPreferred();
+
+ foreach (auto item, ppm.pageSizes())
{
QSize size;
size.setWidth(orientation == 0 ? item.width : item.height);
size.setHeight(orientation == 0 ? item.height : item.width);
// Add items of selected category or all preferred and defaults
- if (item.category == category ||
- (category == PageSizeInfo::Preferred && ps.activePageSizes().contains(item.sizeName)) ||
- (category == PageSizeInfo::Preferred && item.sizeName == pref.name()))
+ if (item.categoryId == category ||
+ (category == pciPreferred.id && ppm.activePageSizes().contains(item.id)) ||
+ (category == pciPreferred.id && item.id == pref.id))
{
+ QList margins;
+ margins.append(item.margins.isNull());
+ margins.append(item.margins.top());
+ margins.append(item.margins.left());
+ margins.append(item.margins.bottom());
+ margins.append(item.margins.right());
+
+ QList bleeds;
+ bleeds.append(item.bleeds.isNull());
+ bleeds.append(item.bleeds.top());
+ bleeds.append(item.bleeds.left());
+ bleeds.append(item.bleeds.bottom());
+ bleeds.append(item.bleeds.right());
+
QStandardItem* itemA = new QStandardItem();
- itemA->setText(item.trSizeName);
+ itemA->setText(item.displayName);
itemA->setEditable(false);
- itemA->setIcon(sizePreview(this->iconSize(), size));
- itemA->setData(QVariant(item.sizeLabel), ItemData::SizeLabel);
+ itemA->setIcon(sizePreview(this->iconSize(), size, margins));
+ itemA->setData(QVariant(item.label), ItemData::SizeLabel);
itemA->setData(QVariant(item.pageUnitIndex), ItemData::Unit);
- itemA->setData(QVariant(item.category), ItemData::Category);
- itemA->setData(QVariant(item.sizeName), ItemData::Name);
+ itemA->setData(QVariant(item.categoryId), ItemData::Category);
+ itemA->setData(QVariant(item.id), ItemData::ID);
itemA->setData(QVariant(item.width * item.height), ItemData::Dimension);
+ itemA->setData(QVariant(item.width), ItemData::Width);
+ itemA->setData(QVariant(item.height), ItemData::Height);
+ itemA->setData(QVariant(item.type), ItemData::Type);
+ itemA->setData(QVariant(item.displayName), ItemData::Name);
+ itemA->setData(QVariant(item.marginPreset), ItemData::MarginPreset);
+ itemA->setData(QVariant::fromValue(margins), ItemData::Margins);
+ itemA->setData(QVariant::fromValue(bleeds), ItemData::Bleeds);
+ itemA->setData(QVariant(item.layout), ItemData::Layout);
+ itemA->setData(QVariant(item.firstPage), ItemData::FirstPage);
+ itemA->setData(QVariant::fromValue(item.textFrame), ItemData::TextFrame);
+ itemA->setData(QVariant(item.bindingDirection), ItemData::BindingDirection);
+
m_model->appendRow(itemA);
- if (sel == -1 && item.sizeName == ps.name())
+ // select item with name match OR equal size
+ if (sel == -1 && (item.id == ps.id || (item.width == ps.width && item.height == ps.height)))
sel = itemA->row();
+
}
}
@@ -151,7 +187,7 @@ void PageSizeList::updateGeometries()
verticalScrollBar()->setSingleStep(10);
}
-QIcon PageSizeList::sizePreview(QSize iconSize, QSize pageSize) const
+QIcon PageSizeList::sizePreview(QSize iconSize, QSize pageSize, QList dataMargins) const
{
double devicePixelRatio = qApp->devicePixelRatio();
double max = mm2pts(500 * devicePixelRatio); // reference for scale: large side of B3
@@ -193,7 +229,71 @@ QIcon PageSizeList::sizePreview(QSize iconSize, QSize pageSize) const
painter.setPen(QPen(palette().text().color()));
painter.setBrush(m_gradient);
painter.drawRect(page.adjusted(0, 0, -1, -1));
+
+ if (!QVariant(dataMargins.at(0)).toBool())
+ {
+
+ int t = ceil(dataMargins.at(1) / height * devicePixelRatio);
+ int l = ceil(dataMargins.at(2) / width * devicePixelRatio);
+ int b = ceil(dataMargins.at(3) / height * devicePixelRatio);
+ int r = ceil(dataMargins.at(4) / width * devicePixelRatio);
+
+ QColor colMargin = PrefsManager::instance().appPrefs.guidesPrefs.marginColor;
+ painter.setPen(colMargin);
+ painter.setBrush(Qt::NoBrush);
+ painter.drawRect(page.adjusted(l, t, -r - 1, -b - 1));
+ }
+
painter.end();
return QIcon(pix);
}
+
+void PageSizeList::showContextMenu(const QPoint &pos)
+{
+ QModelIndex index = indexAt(pos);
+
+ if (!index.isValid())
+ return;
+
+ m_modelIndex = index;
+
+ int itemType = index.data(ItemData::Type).toInt();
+
+ QMenu contextMenu(this);
+ QAction *deleteAction = contextMenu.addAction(tr("Delete Preset"));
+
+ if (itemType == PageSizeType::User)
+ deleteAction->setEnabled(true);
+ else
+ {
+ deleteAction->setEnabled(false);
+ deleteAction->setToolTip("This preset cannot be deleted");
+ }
+
+ connect(deleteAction, &QAction::triggered, this, &PageSizeList::deleteItem);
+
+ contextMenu.exec(mapToGlobal(pos));
+}
+
+void PageSizeList::deleteItem()
+{
+ if (m_modelIndex.isValid())
+ {
+ QString categoryId = m_modelIndex.data(PageSizeList::Category).toString();
+ QString pageId = m_modelIndex.data(PageSizeList::ID).toString();
+ PageCollectionInfo pci = PagePresetManager::instance().categoryInfoById(categoryId);
+
+ PagePresetManager::instance().removeCollectionPage(pci.filePath, pageId);
+ model()->removeRow(m_modelIndex.row());
+
+ bool isEmpty = PagePresetManager::instance().isCollectionsEmpty(pci.filePath);
+ if (isEmpty)
+ PagePresetManager::instance().removeCollection(pci.filePath);
+
+ PagePresetManager::instance().reloadAllPresets();
+
+ if (isEmpty)
+ emit changedCategories();
+ }
+}
diff --git a/scribus/ui/widgets/pagesizelist.h b/scribus/ui/widgets/pagesizelist.h
index 8f2bd8b7a..2b5f38596 100644
--- a/scribus/ui/widgets/pagesizelist.h
+++ b/scribus/ui/widgets/pagesizelist.h
@@ -11,7 +11,6 @@ for which a new license (GPL+exception) is in place.
#include
#include
-#include "pagesize.h"
#include "scribusapi.h"
class SCRIBUS_API PageSizeList : public QListView
@@ -20,49 +19,70 @@ class SCRIBUS_API PageSizeList : public QListView
public:
- enum SortMode {
+ enum SortMode
+ {
NameAsc = 0,
NameDesc = 1,
DimensionAsc = 2,
DimensionDesc = 3
};
- enum ItemData {
+ enum ItemData
+ {
SizeLabel = Qt::UserRole,
- Unit = Qt::UserRole + 1,
- Category = Qt::UserRole + 2,
- Name = Qt::UserRole + 3,
- Dimension = Qt::UserRole + 4,
+ Type = Qt::UserRole + 1,
+ Unit = Qt::UserRole + 2,
+ Category = Qt::UserRole + 3,
+ ID = Qt::UserRole + 4,
+ Dimension = Qt::UserRole + 5,
+ Width = Qt::UserRole + 6,
+ Height = Qt::UserRole + 7,
+ Name = Qt::UserRole + 8,
+ MarginPreset = Qt::UserRole + 9,
+ Margins = Qt::UserRole + 10,
+ Bleeds = Qt::UserRole + 11,
+ Layout = Qt::UserRole + 12,
+ FirstPage = Qt::UserRole + 13,
+ TextFrame = Qt::UserRole + 14,
+ BindingDirection = Qt::UserRole + 15
};
PageSizeList(QWidget* parent);
~PageSizeList() = default;
- void setFormat(QString format);
- const QString& format() const { return m_name; };
+ void setDimensions(double width, double height);
void setOrientation(int orientation);
int orientation() const { return m_orientation; };
- void setCategory(PageSizeInfo::Category category);
- PageSizeInfo::Category category() const { return m_category; };
+ void setCategory(const QString& category);
+ const QString& category() const { return m_category; };
void setSortMode(SortMode sortMode);
SortMode sortMode() const { return m_sortMode; };
- void setValues(QString format, int orientation, PageSizeInfo::Category category, SortMode sortMode);
+ void setValues(QSizeF dimensions, int orientation, const QString& category, SortMode sortMode);
void updateGeometries() override;
+private slots:
+
+ void showContextMenu(const QPoint &pos);
+ void deleteItem();
+
private:
- QString m_name {PageSize::defaultSizesList().at(1)};
+ QSizeF m_dimensions;
int m_orientation {0};
- PageSizeInfo::Category m_category {PageSizeInfo::Preferred};
+ QString m_category;
SortMode m_sortMode {SortMode::NameAsc};
QStandardItemModel* m_model { nullptr };
+ QModelIndex m_modelIndex;
+
+ QIcon sizePreview(QSize iconSize, QSize pageSize, QList dataMargins) const;
+ void loadPageSizes(QSizeF dimensions, int orientation, const QString& category);
- QIcon sizePreview(QSize iconSize, QSize pageSize) const;
- void loadPageSizes(QString name, int orientation, PageSizeInfo::Category category);
+signals:
+ void changedCategories();
};
diff --git a/scribus/ui/widgets/pagesizepreview.cpp b/scribus/ui/widgets/pagesizepreview.cpp
index ab0f86682..72b31bb62 100644
--- a/scribus/ui/widgets/pagesizepreview.cpp
+++ b/scribus/ui/widgets/pagesizepreview.cpp
@@ -41,32 +41,32 @@ void PageSizePreview::paintEvent(QPaintEvent *event)
// Left Page
if (i == 0 && count > 1)
{
- rMargin.setLeft(rPage.left() + m_margins.right() * ratio);
- rMargin.setRight(rPage.right() - m_margins.left() * ratio);
- rBleed.setLeft(rPage.left() - m_bleeds.left() * ratio);
+ rMargin.setLeft(rPage.left() + ceil(m_margins.right() * ratio));
+ rMargin.setRight(rPage.right() - ceil(m_margins.left() * ratio));
+ rBleed.setLeft(rPage.left() - ceil(m_bleeds.left() * ratio));
rBleed.setRight(rPage.right());
}
// Right Page
else if (i == 1 && count > 1)
{
- rMargin.setLeft(rPage.left() + m_margins.left() * ratio);
- rMargin.setRight(rPage.right() - m_margins.right() * ratio);
+ rMargin.setLeft(rPage.left() + ceil(m_margins.left() * ratio));
+ rMargin.setRight(rPage.right() - ceil(m_margins.right() * ratio));
rBleed.setLeft(rPage.left());
- rBleed.setRight(rPage.right() + m_bleeds.right() * ratio);
+ rBleed.setRight(rPage.right() + ceil(m_bleeds.right() * ratio));
}
// Single Page
else
{
- rMargin.setLeft(rPage.left() + m_margins.left() * ratio);
- rMargin.setRight(rPage.right() - m_margins.right() * ratio);
- rBleed.setLeft(rPage.left() - m_bleeds.left() * ratio);
- rBleed.setRight(rPage.right() + m_bleeds.right() * ratio);
+ rMargin.setLeft(rPage.left() + ceil(m_margins.left() * ratio));
+ rMargin.setRight(rPage.right() - ceil(m_margins.right() * ratio));
+ rBleed.setLeft(rPage.left() - ceil(m_bleeds.left() * ratio));
+ rBleed.setRight(rPage.right() + ceil(m_bleeds.right() * ratio));
}
- rMargin.setTop(rPage.top() + m_margins.top() * ratio);
- rMargin.setBottom(rPage.bottom() - m_margins.bottom() * ratio);
- rBleed.setTop(rPage.top() - m_bleeds.top() * ratio);
- rBleed.setBottom(rPage.bottom() + m_bleeds.bottom() * ratio);
+ rMargin.setTop(rPage.top() + ceil(m_margins.top() * ratio));
+ rMargin.setBottom(rPage.bottom() - ceil(m_margins.bottom() * ratio));
+ rBleed.setTop(rPage.top() - ceil(m_bleeds.top() * ratio));
+ rBleed.setBottom(rPage.bottom() + ceil(m_bleeds.bottom() * ratio));
// Draw Bleeds
painter.setBrush( colPage );
diff --git a/scribus/ui/widgets/pagesizepreview.h b/scribus/ui/widgets/pagesizepreview.h
index 665f39df0..7fcbb19a4 100644
--- a/scribus/ui/widgets/pagesizepreview.h
+++ b/scribus/ui/widgets/pagesizepreview.h
@@ -4,7 +4,7 @@
#include
#include "margins.h"
-#include "pagesize.h"
+#include "manager/pagepreset_manager.h"
class PageSizePreview : public QWidget
{
@@ -13,26 +13,27 @@ class PageSizePreview : public QWidget
public:
explicit PageSizePreview(QWidget *parent = nullptr);
- void setPageHeight(double height) { m_height = height; update(); };
+ void setPageHeight(double height)
+ {
+ PageSizeInfo psi = PagePresetManager::instance().pageInfoByDimensions(QSizeF(m_width, height));
+ m_name = psi.displayName;
+ m_height = height;
+ update();
+ };
void setPageWidth(double width) { m_width = width; update(); };
void setMargins(const MarginStruct& margins) { m_margins = margins; update(); };
void setBleeds(const MarginStruct& bleeds) { m_bleeds = bleeds; update(); };
- void setPageName(const QString& name) {
- PageSize ps(name);
- m_name = ps.nameTR();
- update();
- };
void setLayout(int layout) { m_layout = layout; update(); };
void setFirstPage(int firstPage) { m_firstPage = firstPage; update(); };
- void setPage(double height, double width, const MarginStruct& margins, const MarginStruct& bleeds, QString name, int layout, int firstPage)
+ void setPage(double height, double width, const MarginStruct& margins, const MarginStruct& bleeds, int layout, int firstPage)
{
- PageSize ps(name);
+ PageSizeInfo psi = PagePresetManager::instance().pageInfoByDimensions(QSizeF(width, height));
m_height = height;
m_width = width;
m_margins = margins;
m_bleeds = bleeds;
- m_name = ps.nameTR();
+ m_name = psi.displayName;
m_layout = layout;
m_firstPage = firstPage;
update();
diff --git a/scribus/ui/widgets/pagesizeselector.cpp b/scribus/ui/widgets/pagesizeselector.cpp
index 5ca25c57f..1cddfc849 100644
--- a/scribus/ui/widgets/pagesizeselector.cpp
+++ b/scribus/ui/widgets/pagesizeselector.cpp
@@ -17,8 +17,6 @@ for which a new license (GPL+exception) is in place.
#include
#include "pagesizeselector.h"
-#include "pagesize.h"
-#include "commonstrings.h"
PageSizeSelector::PageSizeSelector(QWidget *parent)
: QWidget{parent}
@@ -49,23 +47,21 @@ void PageSizeSelector::setHasCustom(bool hasCustom)
m_hasCustom = hasCustom;
if (!m_sizeName.isEmpty())
- setPageSize(m_sizeName);
+ setPageSize(m_size.width(), m_size.height());
}
-void PageSizeSelector::setCurrentCategory(PageSizeInfo::Category category)
+void PageSizeSelector::setCurrentCategory(const QString &categoryId)
{
- int index = comboCategory->findData(category);
+ int index = comboCategory->findData(categoryId);
if (index != -1)
comboCategory->setCurrentIndex(index);
}
-void PageSizeSelector::setPageSize(QString name)
+void PageSizeSelector::setup(PageSizeInfo psi)
{
- PageSize ps(name);
-
- m_sizeName = ps.name();
- m_sizeCategory = ps.category();
- m_trSizeName = ps.nameTR();
+ m_sizeName = psi.id;
+ m_sizeCategory = psi.categoryId;
+ m_trSizeName = psi.displayName;
// Load category list
int index = -1;
@@ -75,34 +71,48 @@ void PageSizeSelector::setPageSize(QString name)
// Add Custom
if (hasCustom())
{
- comboCategory->addItem(CommonStrings::trCustomPageSize, PageSizeInfo::Custom);
- if (m_sizeName == CommonStrings::customPageSize || m_sizeName == CommonStrings::trCustomPageSize)
+ PageCollectionInfo pciCustom = PagePresetManager::instance().categoryInfoCustom();
+ comboCategory->addItem(pciCustom.displayName, pciCustom.id);
+ if (m_sizeName == pciCustom.id || m_sizeName == pciCustom.displayName)
index = comboCategory->count() - 1;
}
// Add Preferred
- comboCategory->addItem(ps.categoryToString(PageSizeInfo::Preferred), PageSizeInfo::Preferred);
+ PageCollectionInfo pciPreferred = PagePresetManager::instance().categoryInfoPreferred();
+ comboCategory->addItem(pciPreferred.displayName, pciPreferred.id);
+ comboCategory->insertSeparator(comboCategory->count());
// Add all available categories
- PageSizeCategoriesMap categories = ps.categories();
- for (auto it = categories.begin(); it != categories.end(); ++it)
+ QList orderList = PagePresetManager::instance().categoriesOrder();
+ for (int i = 0; i < orderList.size(); i++)
{
- comboCategory->addItem(it.value(), it.key());
- if (it.key() == m_sizeCategory)
- index = comboCategory->count() - 1;
+ QString item = orderList.at(i);
+ if (item == "-")
+ comboCategory->insertSeparator(comboCategory->count());
+ else
+ {
+ PageCollectionInfo pci = PagePresetManager::instance().categoryInfoById(item);
+ comboCategory->addItem(pci.displayName, pci.id);
+ if (pci.id == m_sizeCategory)
+ index = comboCategory->count() - 1;
+ }
+
}
comboCategory->setCurrentIndex(index);
- comboCategory->insertSeparator(comboCategory->findData(PageSizeInfo::Preferred) + 1);
- comboCategory->insertSeparator(comboCategory->findData(PageSizeInfo::IsoEnvelope) + 1);
- comboCategory->insertSeparator(comboCategory->findData(PageSizeInfo::USEnvelope) + 1);
- comboCategory->insertSeparator(comboCategory->findData(PageSizeInfo::Other) + 1);
// Load size format list
setFormat(m_sizeCategory, m_sizeName);
}
-void PageSizeSelector::setFormat(PageSizeInfo::Category category, QString name)
+void PageSizeSelector::setPageSize(double width, double height)
+{
+ m_size = QSizeF(width, height);
+ PageSizeInfo psi = PagePresetManager::instance().pageInfoByDimensions(m_size);
+ setup(psi);
+}
+
+void PageSizeSelector::setFormat(const QString& categoryId, QString name)
{
if (!hasFormatSelector())
return;
@@ -110,11 +120,13 @@ void PageSizeSelector::setFormat(PageSizeInfo::Category category, QString name)
QSignalBlocker sigFormat(comboFormat);
comboFormat->clear();
- if (category == PageSizeInfo::Custom)
+ PageCollectionInfo pciCustom = PagePresetManager::instance().categoryInfoCustom();
+
+ if (categoryId == pciCustom.id)
{
comboFormat->setEnabled(false);
- m_sizeName = CommonStrings::customPageSize;
- m_trSizeName = CommonStrings::trCustomPageSize;
+ m_sizeName = pciCustom.id;
+ m_trSizeName = pciCustom.displayName;
return;
}
else
@@ -122,14 +134,15 @@ void PageSizeSelector::setFormat(PageSizeInfo::Category category, QString name)
comboFormat->setEnabled(true);
}
- PageSize ps(name);
+ // PageSize ps(name);
+ PageCollectionInfo pciPreferred = PagePresetManager::instance().categoryInfoPreferred();
int index = -1;
- for (const auto &item : ps.pageSizes())
+ for (const auto &item : PagePresetManager::instance().pageSizes())
{
- if (item.category == category || (category == PageSizeInfo::Preferred && ps.activePageSizes().contains(item.sizeName)))
+ if (item.categoryId == categoryId || (categoryId == pciPreferred.id && PagePresetManager::instance().activePageSizes().contains(item.id)))
{
- comboFormat->addItem(item.trSizeName, item.sizeName);
- if (item.sizeName == name)
+ comboFormat->addItem(item.displayName, item.id);
+ if (item.id == name)
index = comboFormat->count() - 1;
}
}
@@ -145,7 +158,7 @@ void PageSizeSelector::setFormat(PageSizeInfo::Category category, QString name)
void PageSizeSelector::categorySelected(int index)
{
- m_sizeCategory = static_cast(comboCategory->itemData(index).toInt());
+ m_sizeCategory = comboCategory->itemData(index).toString();
setFormat(m_sizeCategory, m_sizeName);
emit pageCategoryChanged(m_sizeCategory);
diff --git a/scribus/ui/widgets/pagesizeselector.h b/scribus/ui/widgets/pagesizeselector.h
index 8c9b99624..f527cfbc2 100644
--- a/scribus/ui/widgets/pagesizeselector.h
+++ b/scribus/ui/widgets/pagesizeselector.h
@@ -20,7 +20,7 @@ for which a new license (GPL+exception) is in place.
#include
#include
-#include "pagesize.h"
+#include "manager/pagepreset_manager.h"
class PageSizeSelector : public QWidget
{
@@ -29,14 +29,14 @@ class PageSizeSelector : public QWidget
public:
explicit PageSizeSelector(QWidget *parent = nullptr);
- void setPageSize(QString name);
+ void setPageSize(double width, double height);
void setHasFormatSelector(bool isVisble );
void setHasCustom(bool hasCustom);
bool hasCustom() const { return m_hasCustom; };
bool hasFormatSelector() const { return m_hasFormatSelector; };
- void setCurrentCategory(PageSizeInfo::Category category);
+ void setCurrentCategory(const QString& categoryId);
- PageSizeInfo::Category category() const { return m_sizeCategory; };
+ const QString& category() const { return m_sizeCategory; };
QString pageSize() const { return m_sizeName; };
QString pageSizeTR() const { return m_trSizeName; };
@@ -46,15 +46,17 @@ private:
QString m_sizeName;
QString m_trSizeName;
- PageSizeInfo::Category m_sizeCategory;
+ QSizeF m_size;
+ QString m_sizeCategory;
bool m_hasFormatSelector {true};
bool m_hasCustom {true};
- void setFormat(PageSizeInfo::Category category, QString name);
+ void setup(PageSizeInfo psi);
+ void setFormat(const QString& category, QString name);
signals:
void pageSizeChanged(QString);
- void pageCategoryChanged(PageSizeInfo::Category);
+ void pageCategoryChanged(QString);
private slots:
void categorySelected(int index);
diff --git a/scribus/util.cpp b/scribus/util.cpp
index 72fb6a290..daaf687ca 100644
--- a/scribus/util.cpp
+++ b/scribus/util.cpp
@@ -1457,3 +1457,65 @@ QString digitSubstitution(int num, QChar zeroDigit)
}
return result;
}
+
+static const char* BASE62_ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+QString getShortUuidFromUuid(const QUuid& uuid)
+{
+ if (uuid.isNull())
+ return QString();
+
+ int length = 62;
+ QByteArray bytes = uuid.toRfc4122();
+ QByteArray result;
+ result.reserve(22);
+
+ bool isZero = false;
+ while (!isZero)
+ {
+ int remainder = 0;
+ isZero = true;
+
+ for (int i = 0; i < 16; ++i)
+ {
+ int val = ((unsigned char) bytes[i]) + (remainder << 8);
+
+ bytes[i] = val / length;
+ remainder = val % length;
+
+ if (bytes[i] != 0)
+ isZero = false;
+ }
+ result.append(BASE62_ALPHABET[remainder]);
+ }
+
+ std::reverse(result.begin(), result.end());
+ return QString::fromLatin1(result);
+}
+
+QUuid getUuidFromShortUuid(const QString& shortId)
+{
+ if (shortId.isEmpty())
+ return QUuid();
+
+ QByteArray bytes(16, 0);
+ int length = 62;
+
+ for (const QChar& c : shortId)
+ {
+ const char* p = strchr(BASE62_ALPHABET, c.toLatin1());
+ if (!p)
+ return QUuid();
+ int value = p - BASE62_ALPHABET;
+
+ int carry = value;
+ for (int i = 15; i >= 0; --i)
+ {
+ int val = ((unsigned char) bytes[i] * length) + carry;
+ bytes[i] = val & 0xFF;
+ carry = val >> 8;
+ }
+ }
+
+ return QUuid::fromRfc4122(bytes);
+}
diff --git a/scribus/util.h b/scribus/util.h
index f6b1131fd..ebaa23002 100644
--- a/scribus/util.h
+++ b/scribus/util.h
@@ -40,11 +40,6 @@ class ScribusView;
*/
QString cleanupLang(const QString& lang);
-/*! \brief Compare double values by pre-multiplying by 10000 and converting to long if possible.
-If premultiplication does not allow to store result in a long value, perform a standard comparison.
-*/
-bool SCRIBUS_API compareDouble(double a, double b);
-
/*! \brief Returns a sorted list of QStrings - sorted by locale specific rules!
Uses compareQStrings() as rule. There is STL used!
\author Petr Vanek
@@ -214,4 +209,8 @@ void SCRIBUS_API getUniqueName(QString &name, const QStringList& list, const QSt
*/
bool SCRIBUS_API inRange(unsigned min, unsigned value, unsigned max);
+
+QString SCRIBUS_API getShortUuidFromUuid(const QUuid &uuid);
+QUuid SCRIBUS_API getUuidFromShortUuid(const QString &shortId);
+
#endif