View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0017247 | Scribus | User Interface | public | 2024-07-16 19:08 | 2024-09-13 21:37 |
Reporter | nitramr | Assigned To | nitramr | ||
Priority | normal | Severity | feature | Reproducibility | N/A |
Status | assigned | Resolution | open | ||
Platform | Desktop PC | OS | Ubuntu | OS Version | 23.10 64-bit |
Target Version | 1.7.0 | ||||
Summary | 0017247: Indigo UI: New Document Dialog | ||||
Description | I made a new design of the "new document" dialog. What's new? - Dialog has a ui file for editing in Designer - Separation of margin and bleed - Replacing of MarginWidget with NewMarginWidget that is used already on many other places. - New layout of margin + bleed input | ||||
Tags | No tags attached. | ||||
Patch | Yes | ||||
|
|
|
Patch newdocdialog_2024-07-16_01.patch (101,706 bytes)
Index: Scribus.pro =================================================================== --- Scribus.pro (Revision 26196) +++ Scribus.pro (Arbeitskopie) @@ -481,8 +481,7 @@ scribus/ui/linecombo.h \ scribus/ui/linkbutton.h \ scribus/ui/loremipsum.h \ - scribus/ui/marginpresetlayout.h \ - scribus/ui/marginwidget.h \ + scribus/ui/marginpresetlayout.h \ scribus/ui/mark2item.h \ scribus/ui/mark2mark.h \ scribus/ui/markanchor.h \ @@ -1083,6 +1082,7 @@ scribus/ui/measurementsbase.ui \ scribus/ui/multipleduplicate.ui \ scribus/ui/multiprogressdialog.ui \ + scribus/ui/newdocdialog.ui \ scribus/ui/newmarginwidgetbase.ui \ scribus/ui/nftdialog.ui \ scribus/ui/nftwidget.ui \ @@ -1627,8 +1627,7 @@ scribus/ui/linecombo.cpp \ scribus/ui/linkbutton.cpp \ scribus/ui/loremipsum.cpp \ - scribus/ui/marginpresetlayout.cpp \ - scribus/ui/marginwidget.cpp \ + scribus/ui/marginpresetlayout.cpp \ scribus/ui/mark2item.cpp \ scribus/ui/mark2mark.cpp \ scribus/ui/markanchor.cpp \ Index: resources/iconsets/1_7_0/16/action-minimize.svg =================================================================== --- resources/iconsets/1_7_0/16/action-minimize.svg (nicht existent) +++ resources/iconsets/1_7_0/16/action-minimize.svg (Arbeitskopie) @@ -0,0 +1,3 @@ +<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><style>@import '../colors.css';</style> +<rect x="2" y="12" width="12" height="2"/> +</svg> Index: resources/iconsets/1_7_0/16/action-pin.svg =================================================================== --- resources/iconsets/1_7_0/16/action-pin.svg (nicht existent) +++ resources/iconsets/1_7_0/16/action-pin.svg (Arbeitskopie) @@ -0,0 +1,3 @@ +<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><style>@import '../colors.css';</style> +<path fill-rule="evenodd" clip-rule="evenodd" d="M6 3V2H11V3L10 4L11 8L12 9V10H9V14H8V10H5V9L6 8L7 4L6 3Z"/> +</svg> Index: resources/iconsets/1_7_0/16/border-bottom.svg =================================================================== --- resources/iconsets/1_7_0/16/border-bottom.svg (nicht existent) +++ resources/iconsets/1_7_0/16/border-bottom.svg (Arbeitskopie) @@ -0,0 +1,4 @@ +<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><style>@import '../colors.css';</style> +<rect x="1" y="13" width="14" height="2" class="error"/> +<path d="M1 1V12H2V2H14V12H15V1H1Z"/> +</svg> Index: resources/iconsets/1_7_0/16/border-inside.svg =================================================================== --- resources/iconsets/1_7_0/16/border-inside.svg (nicht existent) +++ resources/iconsets/1_7_0/16/border-inside.svg (Arbeitskopie) @@ -0,0 +1,5 @@ +<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><style>@import '../colors.css';</style> +<rect x="7" y="1" width="2" height="14" class="error"/> +<path d="M6 15H1V1H6V2H2V14H6V15Z"/> +<path d="M10 1H15V15H10V14H14V2H10V1Z"/> +</svg> Index: resources/iconsets/1_7_0/16/border-left.svg =================================================================== --- resources/iconsets/1_7_0/16/border-left.svg (nicht existent) +++ resources/iconsets/1_7_0/16/border-left.svg (Arbeitskopie) @@ -0,0 +1,4 @@ +<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><style>@import '../colors.css';</style> +<rect x="1" y="1" width="2" height="14" class="error"/> +<path d="M15 1H4V2H14V14H4V15H15V1Z"/> +</svg> Index: resources/iconsets/1_7_0/16/border-outside.svg =================================================================== --- resources/iconsets/1_7_0/16/border-outside.svg (nicht existent) +++ resources/iconsets/1_7_0/16/border-outside.svg (Arbeitskopie) @@ -0,0 +1,6 @@ +<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><style>@import '../colors.css';</style> +<path d="M3 1H1V15H3V1Z" class="error"/> +<path d="M15 1H13V15H15V1Z" class="error"/> +<path d="M12 1H4V2H12V1Z"/> +<path d="M12 14H4V15H12V14Z"/> +</svg> Index: resources/iconsets/1_7_0/16/border-right.svg =================================================================== --- resources/iconsets/1_7_0/16/border-right.svg (nicht existent) +++ resources/iconsets/1_7_0/16/border-right.svg (Arbeitskopie) @@ -0,0 +1,4 @@ +<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><style>@import '../colors.css';</style> +<rect x="13" y="1" width="2" height="14" class="error"/> +<path d="M1 15H12V14H2V2H12V1H1V15Z"/> +</svg> Index: resources/iconsets/1_7_0/16/border-top.svg =================================================================== --- resources/iconsets/1_7_0/16/border-top.svg (nicht existent) +++ resources/iconsets/1_7_0/16/border-top.svg (Arbeitskopie) @@ -0,0 +1,4 @@ +<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><style>@import '../colors.css';</style> +<rect x="1" y="1" width="14" height="2" class="error"/> +<path d="M15 15V4H14V14H2V4H1V15H15Z"/> +</svg> Index: resources/iconsets/1_7_0/1_7_0.xml =================================================================== --- resources/iconsets/1_7_0/1_7_0.xml (Revision 26196) +++ resources/iconsets/1_7_0/1_7_0.xml (Arbeitskopie) @@ -385,6 +385,12 @@ <icon id="page-import" file="16/page-import.svg" /> <icon id="layer-move-down" file="16/object-level-down.svg" /> <icon id="layer-move-up" file="16/object-level-up.svg" /> + <icon id="border-outside" file="16/border-outside.svg" /> + <icon id="border-inside" file="16/border-inside.svg" /> + <icon id="border-left" file="16/border-left.svg" /> + <icon id="border-top" file="16/border-top.svg" /> + <icon id="border-right" file="16/border-right.svg" /> + <icon id="border-bottom" file="16/border-bottom.svg" /> <!-- PDF Tools --> <icon id="16/insert-button.png" file="16/pdf-button.svg" /> Index: scribus/CMakeLists_Sources.txt =================================================================== --- scribus/CMakeLists_Sources.txt (Revision 26196) +++ scribus/CMakeLists_Sources.txt (Arbeitskopie) @@ -362,7 +362,6 @@ ui/marksmanager.cpp ui/markvariabletext.cpp ui/marginpresetlayout.cpp - ui/marginwidget.cpp ui/newmarginwidget.cpp ui/mergedoc.cpp ui/missing.cpp @@ -559,6 +558,7 @@ ui/widgets/floatingwindow.cpp ui/widgets/form_widget.cpp ui/widgets/gradientlistbox.cpp + ui/widgets/pagelayoutswidget.cpp ui/widgets/popup_menu.cpp ui/widgets/section_container.cpp ui/widgets/stacked_container.cpp Index: scribus/scribus.cpp =================================================================== --- scribus/scribus.cpp (Revision 26196) +++ scribus/scribus.cpp (Arbeitskopie) @@ -183,7 +183,6 @@ #include "ui/javadocs.h" #include "ui/layers.h" #include "ui/loremipsum.h" -#include "ui/marginwidget.h" #include "ui/mark2item.h" #include "ui/mark2mark.h" #include "ui/markanchor.h" @@ -2016,10 +2015,10 @@ int facingPages = dia->choosenLayout(); int firstPage = dia->firstPage->currentIndex(); docSet = dia->startDocSetup->isChecked(); - double topMargin = dia->marginGroup->top(); - double bottomMargin = dia->marginGroup->bottom(); - double leftMargin = dia->marginGroup->left(); - double rightMargin = dia->marginGroup->right(); + 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 columnDistance = dia->distance(); double pageWidth = dia->pageWidth(); double pageHeight = dia->pageHeight(); @@ -2035,7 +2034,7 @@ PageSize ps2(dia->pageSizeComboBox->currentText()); pagesize = ps2.name(); } - doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, numberCols, autoframes, facingPages, dia->unitOfMeasureComboBox->currentIndex(), firstPage, orientation, 1, pagesize, true, pageCount, true, dia->marginGroup->getMarginPreset()); + doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, numberCols, autoframes, facingPages, dia->unitOfMeasureComboBox->currentIndex(), firstPage, orientation, 1, pagesize, true, pageCount, true, dia->marginGroup->marginPreset()); doc->setPageSetFirstPage(facingPages, firstPage); doc->bleeds()->set(dia->bleedTop(), dia->bleedLeft(), dia->bleedBottom(), dia->bleedRight()); HaveNewDoc(); @@ -2099,10 +2098,10 @@ int facingPages = dia->choosenLayout(); int firstPage = dia->firstPage->currentIndex(); bool docSet = dia->startDocSetup->isChecked(); - double topMargin = dia->marginGroup->top(); - double bottomMargin = dia->marginGroup->bottom(); - double leftMargin = dia->marginGroup->left(); - double rightMargin = dia->marginGroup->right(); + 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 columnDistance = dia->distance(); double pageWidth = dia->pageWidth(); double pageHeight = dia->pageHeight(); @@ -2118,7 +2117,7 @@ PageSize ps2(dia->pageSizeComboBox->currentText()); pagesize = ps2.name(); } - if (doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, numberCols, autoframes, facingPages, dia->unitOfMeasureComboBox->currentIndex(), firstPage, orientation, 1, pagesize, true, pageCount, true, dia->marginGroup->getMarginPreset())) + 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())) { doc->setPageSetFirstPage(facingPages, firstPage); doc->bleeds()->set(dia->bleedTop(), dia->bleedLeft(), dia->bleedBottom(), dia->bleedRight()); Index: scribus/ui/marginwidget.cpp =================================================================== --- scribus/ui/marginwidget.cpp (Revision 26196) +++ scribus/ui/marginwidget.cpp (nicht existent) @@ -1,623 +0,0 @@ -/* -For general Scribus (>=1.3.2) copyright and licensing information please refer -to the COPYING file provided with the program. Following this notice may exist -a copyright and/or license notice that predates the release of Scribus 1.3.2 -for which a new license (GPL+exception) is in place. -*/ -#include "marginwidget.h" - -#include <QHBoxLayout> -#include <QGridLayout> -#include <QLabel> -#include <QToolTip> -#include <QCheckBox> -#include <QLabel> -#include <QPushButton> - -#include "scrspinbox.h" -#include "units.h" -#include "ui/useprintermarginsdialog.h" - - -MarginWidget::MarginWidget( QWidget* parent, const QString& /*title*/, const MarginStruct* margs, int unitIndex, bool showChangeAll, bool showBleeds) : QTabWidget(parent), - m_useBleeds(showBleeds) -{ - marginData = *margs; - m_savedMargins = *margs; - m_savedPresetItem = PresetLayout::none; //we don't recheck if we are using a layout but always start at none - marginPage = new QWidget(this); - - presetCombo = new PresetLayout(marginPage); - presetLabel = new QLabel( tr("Preset Layouts:"), marginPage); - presetLabel->setBuddy(presetCombo); - m_unitIndex = unitIndex; - m_unitRatio = unitGetRatioFromIndex(unitIndex); - leftR = new ScrSpinBox( 0, 1000, marginPage, unitIndex ); - rightR = new ScrSpinBox( 0, 1000, marginPage, unitIndex ); - topR = new ScrSpinBox( 0, 1000, marginPage, unitIndex ); - bottomR = new ScrSpinBox( 0, 1000, marginPage, unitIndex ); - updateMarginSpinValues(); - - bText = new QLabel( tr( "&Bottom:" ), marginPage); - bText->setBuddy(bottomR); - tText = new QLabel( tr( "&Top:" ), marginPage); - tText->setBuddy(topR); - rText = new QLabel( tr( "&Right:" ), marginPage); - rText->setBuddy(rightR); - lText = new QLabel( tr( "&Left:" ), marginPage); - lText->setBuddy(leftR); - - linkMargins = new LinkButton( marginPage ); - linkMargins->setCheckable( true ); - linkMargins->setChecked(false); - linkMargins->setAutoRaise( true ); - linkMargins->setMinimumSize( QSize( 15, 0 ) ); - linkMargins->setMaximumSize( QSize( 15, 32767 ) ); - - // layout - GroupLayout = new QGridLayout( marginPage ); - GroupLayout->setSpacing(6); - GroupLayout->setContentsMargins(9, 9, 9, 9); - GroupLayout->addWidget(presetLabel, 0, 0); - GroupLayout->addWidget(presetCombo, 0, 1); - GroupLayout->addWidget( leftR, 1, 1 ); - GroupLayout->addWidget( rightR, 2, 1 ); - GroupLayout->addWidget( topR, 3, 1 ); - GroupLayout->addWidget( bottomR, 4, 1 ); - GroupLayout->addWidget( lText, 1, 0 ); - GroupLayout->addWidget( rText, 2, 0 ); - GroupLayout->addWidget( tText, 3, 0 ); - GroupLayout->addWidget( bText, 4, 0 ); - GroupLayout->addWidget( linkMargins, 1, 2, 4, 1 ); - if (showChangeAll) - { - marginsForPagesLayout = new QHBoxLayout; - marginsForPagesLayout->setContentsMargins(9, 9, 9, 9); - marginsForPagesLayout->setSpacing(6); - marginsForPages = new QLabel( tr( "Apply settings to:" ), marginPage ); - marginsForPagesLayout->addWidget(marginsForPages); - marginsForAllPages = new QCheckBox( marginPage ); - marginsForAllPages->setText( tr( "All Document Pages" ) ); - marginsForAllPages->setChecked( false ); - marginsForPagesLayout->addWidget(marginsForAllPages); - marginsForAllMasterPages = new QCheckBox( marginPage ); - marginsForAllMasterPages->setText( tr( "All Master Pages" ) ); - marginsForAllMasterPages->setChecked( false ); - marginsForPagesLayout->addWidget(marginsForAllMasterPages); - GroupLayout->addLayout( marginsForPagesLayout, 6, 0, 1, 2 ); - marginsForAllPages->setToolTip( "<qt>" + tr( "Apply the margin changes to all existing pages in the document" ) + "</qt>" ); - marginsForAllMasterPages->setToolTip( "<qt>" + tr( "Apply the margin changes to all existing master pages in the document" ) + "</qt>" ); - } - - usePrinterMarginsButton = nullptr; - usePrinterMarginsButton = new QPushButton( tr("Printer Margins..."),marginPage ); - GroupLayout->addWidget( usePrinterMarginsButton, 5, 1 ); - usePrinterMarginsButton->setToolTip( "<qt>" + tr( "Import the margins for the selected page size from the available printers" ) + "</qt>"); - connect(usePrinterMarginsButton, SIGNAL(clicked()), this, SLOT(setMarginsToPrinterMargins())); - - addTab(marginPage, tr("Margin Guides")); - - if (m_useBleeds) - { - bleedPage = new QWidget(this); - BleedGroupLayout = new QGridLayout( bleedPage ); - BleedGroupLayout->setSpacing(6); - BleedGroupLayout->setContentsMargins(9, 9, 9, 9); - BleedGroupLayout->setAlignment( Qt::AlignTop ); - BleedTxt3 = new QLabel( bleedPage ); - BleedGroupLayout->addWidget( BleedTxt3, 0, 0 ); - BleedLeft = new ScrSpinBox( 0, 3000*m_unitRatio, bleedPage, unitIndex ); - BleedGroupLayout->addWidget( BleedLeft, 0, 1 ); - BleedTxt4 = new QLabel( bleedPage ); - BleedGroupLayout->addWidget( BleedTxt4, 1, 0 ); - BleedRight = new ScrSpinBox( 0, 3000*m_unitRatio, bleedPage, unitIndex ); - BleedGroupLayout->addWidget( BleedRight, 1, 1 ); - BleedTxt1 = new QLabel( bleedPage ); - BleedTxt1->setText( tr( "Top:" ) ); - BleedGroupLayout->addWidget( BleedTxt1, 2, 0 ); - BleedTop = new ScrSpinBox( 0, 3000*m_unitRatio, bleedPage, unitIndex ); - BleedGroupLayout->addWidget( BleedTop, 2, 1 ); - BleedTxt2 = new QLabel( bleedPage ); - BleedTxt2->setText( tr( "Bottom:" ) ); - BleedGroupLayout->addWidget( BleedTxt2, 3, 0 ); - BleedBottom = new ScrSpinBox( 0, 3000*m_unitRatio, bleedPage, unitIndex ); - BleedGroupLayout->addWidget( BleedBottom, 3, 1 ); - linkBleeds = new LinkButton( bleedPage ); -/** Fix Me to move this to the prefsmanager.cpp someday */ - linkBleeds->setCheckable( true ); - linkBleeds->setChecked(true); - linkBleeds->setAutoRaise( true ); - linkBleeds->setMinimumSize( QSize( 15, 0 ) ); - linkBleeds->setMaximumSize( QSize( 15, 32767 ) ); - BleedGroupLayout->addWidget( linkBleeds, 0, 2, 4, 1 ); - BleedTop->setToolTip( "<qt>" + tr( "Distance for bleed from the top of the physical page" ) + "</qt>" ); - BleedBottom->setToolTip( "<qt>" + tr( "Distance for bleed from the bottom of the physical page" ) + "</qt>" ); - BleedLeft->setToolTip( "<qt>" + tr( "Distance for bleed from the left of the physical page" ) + "</qt>" ); - BleedRight->setToolTip( "<qt>" + tr( "Distance for bleed from the right of the physical page" ) + "</qt>"); - linkBleeds->setToolTip( "<qt>" + tr( "Ensure all bleeds have the same value" ) + "</qt>"); - connect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(linkBleeds, SIGNAL(clicked()), this, SLOT(slotLinkBleeds())); - addTab(bleedPage, tr("Bleeds")); - } - - // hints - topR->setToolTip( "<qt>" + tr( "Distance between the top margin guide and the edge of the page" ) + "</qt>"); - bottomR->setToolTip( "<qt>" + tr( "Distance between the bottom margin guide and the edge of the page" ) + "</qt>"); - leftR->setToolTip( "<qt>" + tr( "Distance between the left margin guide and the edge of the page. If a double-sided, 3 or 4-fold layout is selected, this margin space can be used to achieve the correct margins for binding.") + "</qt>"); - rightR->setToolTip( "<qt>" + tr( "Distance between the right margin guide and the edge of the page. If a double-sided, 3 or 4-fold layout is selected, this margin space can be used to achieve the correct margins for binding.") + "</qt>"); - linkMargins->setToolTip( "<qt>" + tr( "Ensure all margins have the same value") + "</qt>"); - - // signals&slots - connect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - connect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - connect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - connect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - connect(presetCombo, SIGNAL(activated(int)), this, SLOT(setPreset())); - connect(linkMargins, SIGNAL(clicked()), this, SLOT(slotLinkMargins())); -} - -void MarginWidget::slotLinkBleeds() -{ - disconnect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - - double bleedValue = BleedLeft->value(); - if (BleedLeft->hasFocus()) - { - BleedLeft->clearFocus(); - bleedValue = BleedLeft->value(); - } - if (BleedRight->hasFocus()) - { - BleedRight->clearFocus(); - bleedValue = BleedRight->value(); - } - if (BleedTop->hasFocus()) - { - BleedTop->clearFocus(); - bleedValue = BleedTop->value(); - } - if (BleedBottom->hasFocus()) - { - BleedBottom->clearFocus(); - bleedValue = BleedBottom->value(); - } - - if (linkBleeds->isChecked()) - { - BleedLeft->setValue(bleedValue); - BleedTop->setValue(bleedValue); - BleedBottom->setValue(bleedValue); - BleedRight->setValue(bleedValue); - } - - connect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); -} - -void MarginWidget::changeBleeds() -{ - if (linkBleeds->isChecked()) - { - double val = 0.0; - if (BleedTop == sender()) - val = BleedTop->value(); - else if (BleedBottom == sender()) - val = BleedBottom->value(); - else if (BleedLeft == sender()) - val = BleedLeft->value(); - else if (BleedRight == sender()) - val = BleedRight->value(); - val = val / m_unitRatio; - MarginStruct v(val,val,val,val); - setNewBleeds(v); - } -} - -void MarginWidget::setFacingPages(bool facing, int pagetype) -{ - m_facingPages = facing; - m_pageType = pagetype; - lText->setText(facing ? tr( "&Inside:" ) : tr( "&Left:" )); - rText->setText(facing ? tr( "O&utside:" ) : tr( "&Right:" )); - if (m_useBleeds) - { - if (facing) - { - BleedTxt3->setText( tr( "Inside:" ) ); - BleedTxt4->setText( tr( "Outside:" ) ); - } - else - { - BleedTxt3->setText( tr( "Left:" ) ); - BleedTxt4->setText( tr( "Right:" ) ); - } - } - setPreset(); -} - -void MarginWidget::setPageWidthHeight(double width, double height) -{ - rightR->setMaximum(qMax(0.0, width * m_unitRatio - leftR->value())); - leftR->setMaximum(qMax(0.0, width * m_unitRatio - rightR->value())); - m_pageWidth = width; - topR->setMaximum(qMax(0.0, height * m_unitRatio - bottomR->value())); - bottomR->setMaximum(qMax(0.0, height * m_unitRatio - topR->value())); - m_pageHeight = height; - setPreset(); -} - -void MarginWidget::setPageWidth(double width) -{ - rightR->setMaximum(qMax(0.0, width * m_unitRatio - leftR->value())); - leftR->setMaximum(qMax(0.0,width * m_unitRatio - rightR->value())); - m_pageWidth = width; - setPreset(); -} - -void MarginWidget::setPageHeight(double height) -{ - topR->setMaximum(qMax(0.0, height * m_unitRatio - bottomR->value())); - bottomR->setMaximum(qMax(0.0,height * m_unitRatio - topR->value())); - m_pageHeight = height; - setPreset(); -} - -void MarginWidget::setTop() -{ - double newVal = topR->value() / m_unitRatio; - bottomR->setMaximum(qMax(0.0, m_pageHeight * m_unitRatio - topR->value())); - if (linkMargins->isChecked() && m_savedPresetItem == PresetLayout::none) - { - marginData.set(newVal, newVal, newVal, newVal); - updateMarginSpinValues(); - } - else - marginData.setTop(newVal); - setPreset(); -} - -void MarginWidget::setBottom() -{ - double newVal = bottomR->value() / m_unitRatio; - topR->setMaximum(qMax(0.0, m_pageHeight * m_unitRatio - bottomR->value())); - if (linkMargins->isChecked() && m_savedPresetItem == PresetLayout::none) - { - marginData.set(newVal, newVal, newVal, newVal); - updateMarginSpinValues(); - } - else - marginData.setBottom(newVal); - setPreset(); -} - -void MarginWidget::setLeft() -{ - double newVal = leftR->value() / m_unitRatio; - rightR->setMaximum(qMax(0.0, m_pageWidth * m_unitRatio - leftR->value())); - if (linkMargins->isChecked() && m_savedPresetItem == PresetLayout::none) - { - marginData.set(newVal, newVal, newVal, newVal); - updateMarginSpinValues(); - } - else - marginData.setLeft(newVal); - setPreset(); -} - -void MarginWidget::setRight() -{ - double newVal = rightR->value() / m_unitRatio; - leftR->setMaximum(qMax(0.0, m_pageWidth * m_unitRatio - rightR->value())); - if (linkMargins->isChecked() && m_savedPresetItem == PresetLayout::none) - { - marginData.set(newVal, newVal, newVal, newVal); - updateMarginSpinValues(); - } - else - marginData.setRight(newVal); - setPreset(); -} - -void MarginWidget::setNewUnit(int newUnitIndex) -{ - disconnect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - disconnect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - disconnect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - disconnect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - m_unitIndex = newUnitIndex; - m_unitRatio = unitGetRatioFromIndex(newUnitIndex); - topR->setNewUnit(newUnitIndex); - bottomR->setNewUnit(newUnitIndex); - leftR->setNewUnit(newUnitIndex); - rightR->setNewUnit(newUnitIndex); - - if (m_useBleeds) - { - disconnect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - BleedBottom->setNewUnit(newUnitIndex); - BleedTop->setNewUnit(newUnitIndex); - BleedRight->setNewUnit(newUnitIndex); - BleedLeft->setNewUnit(newUnitIndex); - connect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - } - connect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - connect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - connect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - connect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); -} - -void MarginWidget::setPreset() -{ - disconnect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - disconnect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - disconnect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - disconnect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - if (m_savedPresetItem == PresetLayout::none) - m_savedMargins = marginData; - int item = presetCombo->currentIndex(); - - MarginStruct marg = presetCombo->getMargins(item, m_pageWidth, m_pageHeight, leftR->value() / m_unitRatio); - presetCombo->setEnabled(m_facingPages); - - bool restoringValues = false; - if ((item == PresetLayout::none) && (m_savedPresetItem != PresetLayout::none)) - { - marg = m_savedMargins; - restoringValues = true; - } - if (restoringValues || (presetCombo->needUpdate() && m_facingPages)) - { - marginData.set(qMax(0.0, marg.top()), qMax(0.0, marg.left()), qMax(0.0, marg.bottom()), qMax(0.0, marg.right())); - updateMarginSpinValues(); - - bottomR->setMaximum(qMax(0.0, m_pageHeight * m_unitRatio - topR->value())); - topR->setMaximum(qMax(0.0, m_pageHeight * m_unitRatio - bottomR->value())); - rightR->setMaximum(qMax(0.0, m_pageWidth * m_unitRatio - leftR->value())); - leftR->setMaximum(qMax(0.0, m_pageWidth * m_unitRatio - rightR->value())); - rightR->setEnabled(restoringValues); - topR->setEnabled(restoringValues); - bottomR->setEnabled(restoringValues); - } - else - { - rightR->setEnabled(true); - topR->setEnabled(true); - bottomR->setEnabled(true); - } - if (m_pageType == 1) - rightR->setEnabled(false); - leftR->setEnabled(item != PresetLayout::nineparts); - if (item != PresetLayout::none) - linkMargins->setChecked(false); - linkMargins->setEnabled(item == PresetLayout::none || !presetCombo->isEnabled()); - connect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - connect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - connect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - connect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - m_savedPresetItem = item; -} - -void MarginWidget::setPageSize(const QString& pageSize) -{ - m_pageSize = pageSize; -} - -void MarginWidget::setMarginsToPrinterMargins() -{ - 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); - presetCombo->setCurrentIndex(PresetLayout::none); - - marginData.setTop(t); - marginData.setBottom(b); - marginData.setLeft(l); - marginData.setRight(r); - updateMarginSpinValues(); - - bottomR->setMaximum((qMax(0.0, m_pageHeight - t) * m_unitRatio)); - topR->setMaximum((qMax(0.0, m_pageHeight - b) * m_unitRatio)); - rightR->setMaximum((qMax(0.0, m_pageWidth - l) * m_unitRatio)); - leftR->setMaximum((qMax(0.0, m_pageWidth - r) * m_unitRatio)); - - rightR->setEnabled(true); - topR->setEnabled(true); - bottomR->setEnabled(true); -} - -double MarginWidget::top() const -{ - return marginData.top(); -} - -double MarginWidget::bottom() const -{ - return marginData.bottom(); -} - -double MarginWidget::left() const -{ - return marginData.left(); -} - -double MarginWidget::right() const -{ - return marginData.right(); -} - -void MarginWidget::setNewMargins(MarginStruct &m) -{ - disconnect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - disconnect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - disconnect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - disconnect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - marginData = m; - updateMarginSpinValues(); - connect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - connect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - connect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - connect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); -} - -void MarginWidget::setMarginPreset(int p) -{ - disconnect(presetCombo, SIGNAL(activated(int)), this, SLOT(setPreset())); - m_savedPresetItem = p; - presetCombo->setCurrentIndex(p); - if (m_savedPresetItem == PresetLayout::none) - m_savedMargins = marginData; - int item = presetCombo->currentIndex(); - presetCombo->setEnabled(m_facingPages); - bool restoringValues = false; - if ((item == PresetLayout::none) && (m_savedPresetItem != PresetLayout::none)) - { - restoringValues = true; - } - if (restoringValues || (presetCombo->needUpdate() && m_facingPages)) - { - rightR->setEnabled(restoringValues); - topR->setEnabled(restoringValues); - bottomR->setEnabled(restoringValues); - } - else - { - rightR->setEnabled(true); - topR->setEnabled(true); - bottomR->setEnabled(true); - } - if (m_pageType == 1) - rightR->setEnabled(false); - leftR->setEnabled(item != PresetLayout::nineparts); - if (item != PresetLayout::none) - linkMargins->setChecked(false); - linkMargins->setEnabled(item == PresetLayout::none); - connect(presetCombo, SIGNAL(activated(int)), this, SLOT(setPreset())); -} - -int MarginWidget::getMarginPreset() -{ - return presetCombo->currentIndex(); -} - -bool MarginWidget::getMarginsForAllPages() const -{ - return marginsForAllPages->isChecked(); -} - -bool MarginWidget::getMarginsForAllMasterPages() const -{ - return marginsForAllMasterPages->isChecked(); -} - -void MarginWidget::setNewBleeds(MarginStruct& b) -{ - disconnect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - BleedTop->setValue(b.top() * m_unitRatio); - BleedBottom->setValue(b.bottom() * m_unitRatio); - BleedLeft->setValue(b.left() * m_unitRatio); - BleedRight->setValue(b.right() * m_unitRatio); - connect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); -} - -double MarginWidget::topBleed() const -{ - return BleedTop->value() / m_unitRatio; -} - -double MarginWidget::bottomBleed() const -{ - return BleedBottom->value() / m_unitRatio; -} - -double MarginWidget::leftBleed() const -{ - return BleedLeft->value() / m_unitRatio; -} - -double MarginWidget::rightBleed() const -{ - return BleedRight->value() / m_unitRatio; -} - -const MarginStruct & MarginWidget::margins() const -{ - return marginData; -} - -void MarginWidget::slotLinkMargins() -{ - disconnect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - disconnect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - disconnect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - disconnect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - - double marginValue = leftR->value(); - if (leftR->hasFocus()) - { - leftR->clearFocus(); - marginValue = leftR->value(); - } - if (rightR->hasFocus()) - { - rightR->clearFocus(); - marginValue = rightR->value(); - } - if (topR->hasFocus()) - { - topR->clearFocus(); - marginValue = topR->value(); - } - if (bottomR->hasFocus()) - { - bottomR->clearFocus(); - marginValue = bottomR->value(); - } - - if (linkMargins->isChecked()) - { - leftR->setValue(marginValue); - bottomR->setValue(marginValue); - topR->setValue(marginValue); - rightR->setValue(marginValue); - double newVal = marginValue / m_unitRatio; - marginData.set(newVal, newVal, newVal, newVal); - } - - connect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - connect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - connect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - connect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - -} - -void MarginWidget::updateMarginSpinValues() -{ - topR->setValue(marginData.top() * m_unitRatio); - rightR->setValue(marginData.right() * m_unitRatio); - bottomR->setValue(marginData.bottom() * m_unitRatio); - leftR->setValue(marginData.left() * m_unitRatio); -} Property changes on: scribus/ui/marginwidget.cpp ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Author Date Id Revision \ No newline at end of property Index: scribus/ui/marginwidget.h =================================================================== --- scribus/ui/marginwidget.h (Revision 26196) +++ scribus/ui/marginwidget.h (nicht existent) @@ -1,178 +0,0 @@ -/* -For general Scribus (>=1.3.2) copyright and licensing information please refer -to the COPYING file provided with the program. Following this notice may exist -a copyright and/or license notice that predates the release of Scribus 1.3.2 -for which a new license (GPL+exception) is in place. -*/ -#ifndef MARGINWIDGET_H -#define MARGINWIDGET_H - -#include "scribusapi.h" -#include "scribusstructs.h" - -#include <QComboBox> -#include <QTabWidget> -#include "linkbutton.h" -#include "marginpresetlayout.h" - -class QCheckBox; -class QPushButton; -class QLabel; -class QGridLayout; -class QHBoxLayout; -class ScrSpinBox; - - -/*! \brief Widget for Margins setting. -Used e.g. in "New Doc Dialog" or "Preferences". -*/ -class SCRIBUS_API MarginWidget : public QTabWidget -{ - Q_OBJECT - -public: - /*! \brief It creates an user interface for base margin settings for the document. - \param parent Parent widget (used as standard in Qt) - \param title Title of the Group box - \param margs A reference to the margins in the preferences. - \param unitIndex and index of the unit combobox - \param showChangeAll show "apply to all pages" related items - */ - MarginWidget(QWidget* parent, const QString& title, const MarginStruct* margs, int unitIndex, bool showChangeAll = false, bool showBleeds = true); - ~MarginWidget() {} - /*! \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 and height */ - void setPageWidthHeight(double width, double height); - /*! \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); - /*! \brief Setup the widgets by new options */ - void setNewUnit(int newUnitIndex); - /*! \brief Set the page size for margin getting from cups */ - void setPageSize(const QString& pageSize); - - /*! \brief Margins - \retval MarginStruct data */ - const MarginStruct& margins() const; - /*! \brief Top Margin - \retval double margin size */ - double top() const; - /*! \brief Bottom Margin - \retval double margin size */ - double bottom() const; - /*! \brief Left Margin - \retval double margin size */ - double left() const; - /*! \brief Right Margin - \retval double margin size */ - double right() const; - - /*! \brief set new margin values for the dialog - It calls overridden setTop(), setBottom() etc. slots itself - via signals emitted from spinboxes. - \param m MarginStruct - */ - void setNewMargins(MarginStruct& m); - - /*! \brief Setup the presetCombo without changing the margin values, only used by tabdocument */ - void setMarginPreset(int p); - int getMarginPreset(); - - /*! \brief Top Bleed - \retval double bleed size */ - double topBleed() const; - /*! \brief Bottom Bleed - \retval double bleed size */ - double bottomBleed() const; - /*! \brief Left Bleed - \retval double bleed size */ - double leftBleed() const; - /*! \brief Right Bleed - \retval double bleed size */ - double rightBleed() const; - - /*! \brief set new bleed values for the dialog - \param b MarginStruct - */ - void setNewBleeds(MarginStruct& b); - - /*! \brief Return marginsForAllPages property - \retval bool true to apply for all pages */ - bool getMarginsForAllPages() const; - bool getMarginsForAllMasterPages() const; - -private: - /*! Tabs */ - QWidget *marginPage { nullptr }; - QWidget* bleedPage { nullptr }; - /*! Spinboxes */ - ScrSpinBox* topR { nullptr }; - ScrSpinBox* bottomR { nullptr }; - ScrSpinBox* rightR { nullptr }; - ScrSpinBox* leftR { nullptr }; - ScrSpinBox* BleedBottom { nullptr }; - ScrSpinBox* BleedLeft { nullptr }; - ScrSpinBox* BleedRight { nullptr }; - ScrSpinBox* BleedTop { nullptr }; - PresetLayout* presetCombo { nullptr }; - /*! Labels */ - QLabel* lText { nullptr }; - QLabel* rText { nullptr }; - QLabel* tText { nullptr }; - QLabel* bText { nullptr }; - QLabel* presetLabel { nullptr }; - QLabel* marginsForPages { nullptr }; - QLabel* BleedTxt1 { nullptr }; - QLabel* BleedTxt2 { nullptr }; - QLabel* BleedTxt3 { nullptr }; - QLabel* BleedTxt4 { nullptr }; - QCheckBox* marginsForAllPages { nullptr }; - QCheckBox* marginsForAllMasterPages { nullptr }; - QPushButton* usePrinterMarginsButton { nullptr }; - LinkButton* linkBleeds { nullptr }; - LinkButton* linkMargins { nullptr }; - - /*! \brief Margin values converted by unitRatio */ - MarginStruct marginData; - - /*! \brief Internally used page width */ - double m_pageWidth { 0.0 }; - /*! \brief Internally used page height */ - double m_pageHeight { 0.0 }; - -public slots: - /*! \brief Recompute the values after spinbox change */ - void setTop(); - void setBottom(); - void setLeft(); - void setRight(); - /*! \brief Recompute margins in PresetLayout combobox and disable/enable widgets. */ - void setPreset(); - void slotLinkBleeds(); - void slotLinkMargins(); - void changeBleeds(); - -protected slots: - virtual void setMarginsToPrinterMargins(); - -protected: - void updateMarginSpinValues(); - - QGridLayout* GroupLayout { nullptr }; - QHBoxLayout* marginsForPagesLayout { nullptr }; - QGridLayout* BleedGroupLayout { nullptr }; - - QString m_pageSize; - int m_unitIndex { 0 }; - double m_unitRatio { 1.0 }; - //! \brief if the outer facing palette points to the facing pages item - bool m_facingPages { false }; - bool m_useBleeds { false }; - int m_pageType { 0 }; - MarginStruct m_savedMargins; - int m_savedPresetItem { PresetLayout::none }; -}; - -#endif Property changes on: scribus/ui/marginwidget.h ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Author Date Id Revision \ No newline at end of property Index: scribus/ui/newdocdialog.cpp =================================================================== --- scribus/ui/newdocdialog.cpp (Revision 26196) +++ scribus/ui/newdocdialog.cpp (Arbeitskopie) @@ -29,6 +29,7 @@ #include <QStringList> #include <QTabWidget> #include <QToolTip> +#include <QVBoxLayout> #include "scconfig.h" @@ -36,7 +37,7 @@ #include "filedialogeventcatcher.h" #include "fileloader.h" #include "iconmanager.h" -#include "marginwidget.h" +#include "newmarginwidget.h" #include "pagesize.h" #include "pagestructs.h" #include "prefsfile.h" @@ -43,60 +44,15 @@ #include "prefsmanager.h" #include "scrspinbox.h" #include "units.h" -#include "ui/delegates/sclistitemdelegate.h" +#include "ui/widgets/pagelayoutswidget.h" -PageLayoutsWidget::PageLayoutsWidget(QWidget* parent) : - QListWidget(parent) -{ - setDragEnabled(false); - setViewMode(QListView::IconMode); - setFlow(QListView::LeftToRight); - setSortingEnabled(false); - setWrapping(false); - setWordWrap(true); - setAcceptDrops(false); - setDropIndicatorShown(false); - setDragDropMode(QAbstractItemView::NoDragDrop); - setResizeMode(QListView::Adjust); - setSelectionMode(QAbstractItemView::SingleSelection); - setFocusPolicy(Qt::NoFocus); - setIconSize(QSize(32, 32)); - clear(); - setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); - setGridSize(QSize(96, 96)); - setItemDelegate(new ScListItemDelegate(QListWidget::IconMode, QSize(32,32))); -} -void PageLayoutsWidget::arrangeIcons() -{ - int startY = 5; - int startX = 5; - int maxSizeY = 0; - - setResizeMode(QListView::Fixed); - - for (int i = 0; i < count(); ++i) - { - QListWidgetItem* itemWidget = item(i); - QRect itemRect = visualItemRect(itemWidget); - setPositionForIndex(QPoint(startX, startY), indexFromItem(itemWidget)); - startX += itemRect.width() + 5; - maxSizeY = qMax(maxSizeY, itemRect.height()); - } - - maxX = startX; - maxY = maxSizeY + 10; -} - -QSize PageLayoutsWidget::minimumSizeHint() const -{ - return QSize(maxX, maxY); -} - NewDocDialog::NewDocDialog(QWidget* parent, const QStringList& recentDocs, bool startUp, const QString& lang) : QDialog(parent), prefsManager(PrefsManager::instance()), m_onStartup(startUp) { + setupUi(this); + setObjectName(QString::fromLocal8Bit("NewDocumentWindow")); setModal(true); @@ -107,54 +63,27 @@ setWindowTitle( tr( "New Document" ) ); setWindowIcon(IconManager::instance().loadIcon("AppIcon.png")); - if (startUp) - setContentsMargins(0, 0, 0, 0); - else - setContentsMargins(9, 9, 9, 9); - TabbedNewDocLayout = new QVBoxLayout( this ); - if (startUp) - TabbedNewDocLayout->setContentsMargins(9, 9, 9, 9); - else - TabbedNewDocLayout->setContentsMargins(0, 0, 0, 0); - TabbedNewDocLayout->setSpacing(6); + createNewDocPage(); if (startUp) { - tabWidget = new QTabWidget( this ); - tabWidget->addTab(newDocFrame, tr("&New Document")); - createNewFromTempPage(); nftGui->setupSettings(lang); - tabWidget->addTab(newFromTempFrame, tr("New &from Template")); createOpenDocPage(); - tabWidget->addTab(openDocFrame, tr("Open &Existing Document")); recentDocList = recentDocs; - createRecentDocPage(); - tabWidget->addTab(recentDocFrame, tr("Open Recent &Document")); - TabbedNewDocLayout->addWidget(tabWidget); + createRecentDocPage(); + startUpDialog->setChecked(!prefsManager.appPrefs.uiPrefs.showStartupDialog); } else - TabbedNewDocLayout->addWidget(newDocFrame); - - Layout1 = new QHBoxLayout; - Layout1->setContentsMargins(0, 0, 0, 0); - Layout1->setSpacing(6); - if (startUp) { - startUpDialog = new QCheckBox( tr( "Do not show this dialog again" ), this ); - startUpDialog->setChecked(!prefsManager.appPrefs.uiPrefs.showStartupDialog); - Layout1->addWidget( startUpDialog ); + tabWidget->removeTab(3); + tabWidget->removeTab(2); + tabWidget->removeTab(1); } - QSpacerItem* spacer = new QSpacerItem( 2, 2, QSizePolicy::Expanding, QSizePolicy::Minimum ); - Layout1->addItem( spacer ); - buttonBox = new QDialogButtonBox(); - Layout1->addWidget(buttonBox); - okButton = new QPushButton( CommonStrings::tr_OK, this ); - okButton->setDefault( true ); - buttonBox->addButton(okButton, QDialogButtonBox::AcceptRole); - cancelButton = new QPushButton( CommonStrings::tr_Cancel, this ); - cancelButton->setAutoDefault( false ); - buttonBox->addButton(cancelButton, QDialogButtonBox::RejectRole); - TabbedNewDocLayout->addLayout( Layout1 ); + + + tabWidget->setCurrentIndex(0); + startUpDialog->setVisible(startUp); + //tooltips pageSizeComboBox->setToolTip( tr( "Document page size, either a standard size or a custom size" ) ); pageOrientationComboBox->setToolTip( tr( "Orientation of the document's pages" ) ); @@ -189,16 +118,6 @@ void NewDocDialog::createNewDocPage() { - newDocFrame = new QFrame(this); - - pageSizeGroupBox = new QGroupBox(newDocFrame ); - pageSizeGroupBox->setTitle( tr( "Document Layout" ) ); - pageSizeGroupBoxLayout = new QGridLayout( pageSizeGroupBox ); - pageSizeGroupBoxLayout->setContentsMargins(9, 9, 9, 9); - pageSizeGroupBoxLayout->setSpacing(6); - pageSizeGroupBoxLayout->setAlignment( Qt::AlignTop ); - - layoutsView = new PageLayoutsWidget( pageSizeGroupBox ); layoutsView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); for (int i = 0; i < prefsManager.appPrefs.pageSets.count(); ++i) { @@ -214,66 +133,62 @@ ic = new QListWidgetItem( IconManager::instance().loadIcon("32/page-doublesided.png"), psname, layoutsView ); ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); } - else if (i == 2 && prefsManager.appPrefs.docSetupPrefs.pagePositioning == 2) - { - ic = new QListWidgetItem( IconManager::instance().loadIcon("32/page-3fold.png"), psname, layoutsView ); - ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - } - else if (i == 3 && prefsManager.appPrefs.docSetupPrefs.pagePositioning == 3) - { - ic = new QListWidgetItem( IconManager::instance().loadIcon("32/page-4fold.png"), psname, layoutsView ); - ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - } + // else if (i == 2 && prefsManager.appPrefs.docSetupPrefs.pagePositioning == 2) + // { + // ic = new QListWidgetItem( IconManager::instance().loadIcon("32/page-3fold.png"), psname, layoutsView ); + // ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + // } + // else if (i == 3 && prefsManager.appPrefs.docSetupPrefs.pagePositioning == 3) + // { + // ic = new QListWidgetItem( IconManager::instance().loadIcon("32/page-4fold.png"), psname, layoutsView ); + // ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + // } } layoutsView->arrangeIcons(); - pageSizeGroupBoxLayout->addWidget( layoutsView, 0, 0, 5, 1 ); - layoutsView->arrangeIcons(); - TextLabel1 = new QLabel( tr( "&Size:" ), pageSizeGroupBox ); - pageSizeGroupBoxLayout->addWidget( TextLabel1, 0, 1 ); PageSize ps(prefsManager.appPrefs.docSetupPrefs.pageSize); - pageSizeComboBox = new QComboBox( pageSizeGroupBox ); + pageSizeComboBox->addItems(ps.activeSizeTRList()); pageSizeComboBox->addItem( CommonStrings::trCustomPageSize ); pageSizeComboBox->setEditable(false); TextLabel1->setBuddy(pageSizeComboBox); - pageSizeGroupBoxLayout->addWidget(pageSizeComboBox, 0, 2 ); - TextLabel2 = new QLabel( tr( "Orie&ntation:" ), pageSizeGroupBox ); - pageSizeGroupBoxLayout->addWidget( TextLabel2, 1, 1 ); - pageOrientationComboBox = new QComboBox( pageSizeGroupBox ); + pageOrientationComboBox->addItem( tr( "Portrait" ) ); pageOrientationComboBox->addItem( tr( "Landscape" ) ); pageOrientationComboBox->setEditable(false); pageOrientationComboBox->setCurrentIndex(prefsManager.appPrefs.docSetupPrefs.pageOrientation); TextLabel2->setBuddy(pageOrientationComboBox); - pageSizeGroupBoxLayout->addWidget( pageOrientationComboBox, 1, 2 ); - TextLabel1_2 = new QLabel( tr( "&Width:" ), pageSizeGroupBox ); - pageSizeGroupBoxLayout->addWidget(TextLabel1_2, 2, 1 ); - widthSpinBox = new ScrSpinBox(pts2value(1.0, m_unitIndex), 16777215, pageSizeGroupBox, m_unitIndex ); + widthSpinBox->setMinimum(pts2value(1.0, m_unitIndex)); + widthSpinBox->setMaximum(16777215); + widthSpinBox->setNewUnit(m_unitIndex); widthSpinBox->setSuffix(m_unitSuffix); TextLabel1_2->setBuddy(widthSpinBox); - pageSizeGroupBoxLayout->addWidget(widthSpinBox, 2, 2 ); - TextLabel2_2 = new QLabel( tr( "&Height:" ), pageSizeGroupBox ); - pageSizeGroupBoxLayout->addWidget(TextLabel2_2, 3, 1 ); - heightSpinBox = new ScrSpinBox( pts2value(1.0, m_unitIndex), 16777215, pageSizeGroupBox, m_unitIndex ); + + heightSpinBox->setMinimum(pts2value(1.0, m_unitIndex)); + heightSpinBox->setMaximum(16777215); + heightSpinBox->setNewUnit(m_unitIndex); heightSpinBox->setSuffix(m_unitSuffix); TextLabel2_2->setBuddy(heightSpinBox); - pageSizeGroupBoxLayout->addWidget(heightSpinBox, 3, 2 ); - unitOfMeasureLabel = new QLabel( tr( "&Default Unit:" ), pageSizeGroupBox ); - unitOfMeasureComboBox = new QComboBox( pageSizeGroupBox ); unitOfMeasureComboBox->addItems(unitGetTextUnitList()); unitOfMeasureComboBox->setCurrentIndex(m_unitIndex); unitOfMeasureComboBox->setEditable(false); unitOfMeasureLabel->setBuddy(unitOfMeasureComboBox); - pageSizeGroupBoxLayout->addWidget( unitOfMeasureLabel, 4, 1 ); - pageSizeGroupBoxLayout->addWidget( unitOfMeasureComboBox, 4, 2 ); MarginStruct marg(prefsManager.appPrefs.docSetupPrefs.margins); - marginGroup = new MarginWidget(newDocFrame, tr( "Margin Guides" ), &marg, m_unitIndex ); - marginGroup->setPageWidthHeight(prefsManager.appPrefs.docSetupPrefs.pageWidth, prefsManager.appPrefs.docSetupPrefs.pageHeight); + marginGroup->setup(marg, !(prefsManager.appPrefs.docSetupPrefs.pagePositioning == singlePage), m_unitIndex, NewMarginWidget::MarginWidgetFlags); + marginGroup->setPageHeight(prefsManager.appPrefs.docSetupPrefs.pageHeight); + marginGroup->setPageWidth(prefsManager.appPrefs.docSetupPrefs.pageWidth); marginGroup->setFacingPages(!(prefsManager.appPrefs.docSetupPrefs.pagePositioning == singlePage)); + + MarginStruct bleed; + bleed.resetToZero(); + + bleedGroup->setup(bleed, !(prefsManager.appPrefs.docSetupPrefs.pagePositioning == singlePage), m_unitIndex, NewMarginWidget::BleedWidgetFlags); + bleedGroup->setPageHeight(prefsManager.appPrefs.docSetupPrefs.pageHeight); + bleedGroup->setPageWidth(prefsManager.appPrefs.docSetupPrefs.pageWidth); + bleedGroup->setFacingPages(!(prefsManager.appPrefs.docSetupPrefs.pagePositioning == singlePage)); widthSpinBox->setValue(prefsManager.appPrefs.docSetupPrefs.pageWidth * m_unitRatio); heightSpinBox->setValue(prefsManager.appPrefs.docSetupPrefs.pageHeight * m_unitRatio); QStringList pageSizes = ps.activeSizeTRList(); @@ -283,31 +198,16 @@ else pageSizeComboBox->setCurrentIndex(pageSizeComboBox->count() - 1); marginGroup->setPageSize(pageSizeComboBox->currentText()); - marginGroup->setNewBleeds(prefsManager.appPrefs.docSetupPrefs.bleeds); marginGroup->setMarginPreset(prefsManager.appPrefs.docSetupPrefs.marginPreset); + bleedGroup->setPageSize(pageSizeComboBox->currentText()); + bleedGroup->setMarginPreset(prefsManager.appPrefs.docSetupPrefs.marginPreset); - optionsGroupBox = new QGroupBox( newDocFrame ); - optionsGroupBox->setTitle( tr( "Options" ) ); - optionsGroupBoxLayout = new QGridLayout( optionsGroupBox ); - optionsGroupBoxLayout->setSpacing(6); - optionsGroupBoxLayout->setContentsMargins(9, 9, 9, 9); - optionsGroupBoxLayout->setAlignment( Qt::AlignTop ); - pageCountLabel = new QLabel( tr( "N&umber of Pages:" ), optionsGroupBox ); - - pageCountSpinBox = new QSpinBox( optionsGroupBox ); pageCountSpinBox->setMaximum( 10000 ); pageCountSpinBox->setMinimum( 1 ); - pageCountLabel->setBuddy(pageCountSpinBox); - optionsGroupBoxLayout->addWidget(pageCountLabel, 0, 0, Qt::AlignLeft); - optionsGroupBoxLayout->addWidget(pageCountSpinBox, 0, 1); - layoutLabel1 = new QLabel( optionsGroupBox ); - layoutLabel1->setText( tr( "First Page is:" ) ); - firstPage = new QComboBox( optionsGroupBox ); + layoutLabel1->setText( tr( "First Page" ) ); firstPage->clear(); selectItem(prefsManager.appPrefs.docSetupPrefs.pagePositioning); - optionsGroupBoxLayout->addWidget(layoutLabel1, 1, 0, Qt::AlignLeft); - optionsGroupBoxLayout->addWidget(firstPage, 1, 1); firstPage->setCurrentIndex(prefsManager.appPrefs.pageSets[prefsManager.appPrefs.docSetupPrefs.pagePositioning].FirstPage); setDocLayout(prefsManager.appPrefs.docSetupPrefs.pagePositioning); @@ -314,25 +214,16 @@ setSize(prefsManager.appPrefs.docSetupPrefs.pageSize); setOrientation(prefsManager.appPrefs.docSetupPrefs.pageOrientation); - autoTextFrame = new QCheckBox( optionsGroupBox ); - autoTextFrame->setText( tr( "&Automatic Text Frames" ) ); - optionsGroupBoxLayout->addWidget(autoTextFrame, 2, 0, 1, 2, Qt::AlignLeft); + autoTextFrame->setTitle(tr( "&Automatic Text Frames" ) ); - TextLabel3 = new QLabel( tr( "Colu&mns:" ), optionsGroupBox ); - numberOfCols = new QSpinBox( optionsGroupBox ); numberOfCols->setButtonSymbols( QSpinBox::UpDownArrows ); numberOfCols->setMinimum( 1 ); numberOfCols->setValue( 1 ); - TextLabel3->setBuddy(numberOfCols); - optionsGroupBoxLayout->addWidget(TextLabel3, 3, 0, Qt::AlignLeft); - optionsGroupBoxLayout->addWidget(numberOfCols, 3, 1); - TextLabel4 = new QLabel( tr( "&Gap:" ), optionsGroupBox ); - Distance = new ScrSpinBox( 0, 1000, optionsGroupBox, m_unitIndex ); + Distance->setMinimum(0); + Distance->setMaximum(1000); + Distance->setNewUnit(m_unitIndex); Distance->setValue(11 * m_unitRatio); - TextLabel4->setBuddy(Distance); - optionsGroupBoxLayout->addWidget(TextLabel4, 4, 0, Qt::AlignLeft); - optionsGroupBoxLayout->addWidget(Distance, 4, 1); firstPage->setMinimumWidth(Distance->width()); @@ -340,31 +231,12 @@ TextLabel4->setEnabled(false); Distance->setEnabled(false); numberOfCols->setEnabled(false); - startDocSetup = new QCheckBox( optionsGroupBox ); + startDocSetup->setText( tr( "Show Document Settings After Creation" ) ); startDocSetup->setChecked(false); - optionsGroupBoxLayout->addWidget(startDocSetup, 5, 0, 1, 2, Qt::AlignLeft); - NewDocLayout = new QGridLayout( newDocFrame ); - if (m_onStartup) - NewDocLayout->setContentsMargins(9, 9, 9, 9); - else - NewDocLayout->setContentsMargins(0, 0, 0, 0); - NewDocLayout->setSpacing(6); - NewDocLayout->addWidget( marginGroup, 1, 0 ); - NewDocLayout->addWidget( optionsGroupBox, 1, 1 ); - NewDocLayout->addWidget( pageSizeGroupBox, 0, 0, 1, 2); } -void NewDocDialog::createNewFromTempPage() -{ - newFromTempFrame = new QFrame(this); - verticalLayout = new QVBoxLayout(newFromTempFrame); - verticalLayout->setContentsMargins(9, 9, 9, 9); - nftGui = new nftwidget(newFromTempFrame); - verticalLayout->addWidget(nftGui); -} - void NewDocDialog::createOpenDocPage() { PrefsContext* docContext = prefsManager.prefsFile->getContext("docdirs", false); @@ -376,10 +248,9 @@ docDir = docContext->get("docsopen", "."); QString formats(FileLoader::getLoadFilterString()); // formats.remove("PDF (*.pdf *.PDF);;"); - openDocFrame = new QFrame(this); - openDocLayout = new QVBoxLayout(openDocFrame); + QVBoxLayout *openDocLayout = new QVBoxLayout(tab_3); openDocLayout->setContentsMargins(0, 0, 0, 0); - openDocLayout->setSpacing(6); + openDocLayout->setSpacing(4); m_selectedFile = ""; // With Qt 5.15 we have to be in careful so that new document dialog doesn't display too large on startup. @@ -386,7 +257,7 @@ // To avoid this we have to use QFileDialog(QWidget *parent, Qt::WindowFlags flags) constructor, then // set the QFileDialog::DontUseNativeDialog option as early as possible, and nonetheless set again // the Qt::Widget window flag before adding the widget to layout. - fileDialog = new QFileDialog(openDocFrame, Qt::Widget); + fileDialog = new QFileDialog(tab_3, Qt::Widget); fileDialog->setOption(QFileDialog::DontUseNativeDialog); fileDialog->setWindowTitle(tr("Open")); fileDialog->setDirectory(docDir); @@ -404,6 +275,7 @@ fileDialog->setWindowFlags(Qt::Widget); openDocLayout->addWidget(fileDialog); + FileDialogEventCatcher* keyCatcher = new FileDialogEventCatcher(this); QList<QListView *> listViews = fileDialog->findChildren<QListView *>(); for (auto listView : std::as_const(listViews)) @@ -426,12 +298,6 @@ void NewDocDialog::createRecentDocPage() { - recentDocFrame = new QFrame(this); - recentDocLayout = new QVBoxLayout(recentDocFrame); - recentDocLayout->setContentsMargins(9, 9, 9, 9); - recentDocLayout->setSpacing(6); - recentDocListBox = new QListWidget(recentDocFrame); - recentDocLayout->addWidget(recentDocListBox); int max = qMin(prefsManager.appPrefs.uiPrefs.recentDocCount, recentDocList.count()); for (int i = 0; i < max; ++i) recentDocListBox->addItem(QDir::toNativeSeparators(recentDocList[i])); @@ -443,6 +309,7 @@ { m_pageWidth = widthSpinBox->value() / m_unitRatio; marginGroup->setPageWidth(m_pageWidth); + bleedGroup->setPageWidth(m_pageWidth); QString psText = pageSizeComboBox->currentText(); if (psText != CommonStrings::trCustomPageSize && psText != CommonStrings::customPageSize) pageSizeComboBox->setCurrentIndex(pageSizeComboBox->count() - 1); @@ -460,6 +327,7 @@ { m_pageHeight = heightSpinBox->value() / m_unitRatio; marginGroup->setPageHeight(m_pageHeight); + bleedGroup->setPageHeight(m_pageHeight); QString psText = pageSizeComboBox->currentText(); if (psText != CommonStrings::trCustomPageSize && psText != CommonStrings::customPageSize) pageSizeComboBox->setCurrentIndex(pageSizeComboBox->count() - 1); @@ -547,6 +415,9 @@ marginGroup->setNewUnit(m_unitIndex); marginGroup->setPageHeight(m_pageHeight); marginGroup->setPageWidth(m_pageWidth); + bleedGroup->setNewUnit(m_unitIndex); + bleedGroup->setPageHeight(m_pageHeight); + bleedGroup->setPageWidth(m_pageWidth); connect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double))); connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double))); } @@ -555,10 +426,10 @@ { m_pageWidth = widthSpinBox->value() / m_unitRatio; m_pageHeight = heightSpinBox->value() / m_unitRatio; - m_bleedBottom = marginGroup->bottomBleed(); - m_bleedTop = marginGroup->topBleed(); - m_bleedLeft = marginGroup->leftBleed(); - m_bleedRight = marginGroup->rightBleed(); + m_bleedBottom = bleedGroup->margins().bottom(); + m_bleedTop = bleedGroup->margins().top(); + m_bleedLeft = bleedGroup->margins().left(); + m_bleedRight = bleedGroup->margins().right(); if (m_onStartup) { m_tabSelected = tabWidget->currentIndex(); @@ -622,6 +493,8 @@ // end of #869 marginGroup->setPageHeight(m_pageHeight); marginGroup->setPageWidth(m_pageWidth); + bleedGroup->setPageHeight(m_pageHeight); + bleedGroup->setPageWidth(m_pageWidth); connect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double))); connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double))); } @@ -636,6 +509,7 @@ setOrientation(pageOrientationComboBox->currentIndex()); } marginGroup->setPageSize(size); + bleedGroup->setPageSize(size); } void NewDocDialog::setSize(const QString& gr) @@ -668,6 +542,8 @@ heightSpinBox->setValue(m_pageHeight * m_unitRatio); marginGroup->setPageHeight(m_pageHeight); marginGroup->setPageWidth(m_pageWidth); + bleedGroup->setPageHeight(m_pageHeight); + bleedGroup->setPageWidth(m_pageWidth); connect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double))); connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double))); } @@ -675,6 +551,7 @@ void NewDocDialog::setDocLayout(int layout) { marginGroup->setFacingPages(layout != singlePage); + bleedGroup->setFacingPages(layout != singlePage); m_choosenLayout = layout; firstPage->setCurrentIndex(prefsManager.appPrefs.pageSets[m_choosenLayout].FirstPage); } @@ -698,7 +575,7 @@ setWindowTitle(tr("Open Recent Document")); else setWindowTitle(tr("New Document")); - okButton->setEnabled(tab!=2); + //okButton->setEnabled(tab!=2); } void NewDocDialog::locationDropped(const QString& fileUrl) @@ -750,5 +627,5 @@ void NewDocDialog::openFileDialogFileClicked(const QString& path) { - okButton->setEnabled(!path.isEmpty()); + //okButton->setEnabled(!path.isEmpty()); } Index: scribus/ui/newdocdialog.h =================================================================== --- scribus/ui/newdocdialog.h (Revision 26196) +++ scribus/ui/newdocdialog.h (Arbeitskopie) @@ -33,31 +33,19 @@ #include "ui/customfdialog.h" #include "ui/nftwidget.h" +#include "ui_newdocdialog.h" + class PrefsManager; -class MarginWidget; +class NewMarginWidget; class ScrSpinBox; class QFileDialog; -class SCRIBUS_API PageLayoutsWidget : public QListWidget +class SCRIBUS_API NewDocDialog : public QDialog, public Ui::newDocDialog { Q_OBJECT public: - PageLayoutsWidget(QWidget* parent); - ~PageLayoutsWidget() = default; - void arrangeIcons(); - QSize minimumSizeHint() const override; - int maxX {0}; - int maxY {0}; -}; - -class SCRIBUS_API NewDocDialog : public QDialog -{ - Q_OBJECT - -public: - //! \brief Indexes of the dialog's tabs. enum { NewDocumentTab = 0, @@ -70,48 +58,11 @@ ~NewDocDialog() = default; void createNewDocPage(); - void createNewFromTempPage(); void createOpenDocPage(); void createRecentDocPage(); void setSize(const QString& gr); - QTabWidget* tabWidget {nullptr}; - QFrame* newDocFrame {nullptr}; - PageLayoutsWidget* layoutsView {nullptr}; - QLabel* layoutLabel1 {nullptr}; - QComboBox* firstPage {nullptr}; - QGroupBox* pageSizeGroupBox {nullptr}; - MarginWidget* marginGroup {nullptr}; - QGroupBox* optionsGroupBox {nullptr}; - QLabel* TextLabel1 {nullptr}; - QLabel* TextLabel2 {nullptr}; - QLabel* TextLabel3 {nullptr}; - QLabel* TextLabel4 {nullptr}; - QLabel* TextLabel1_2 {nullptr}; - QLabel* TextLabel1_3 {nullptr}; - QLabel* pageCountLabel {nullptr}; - QLabel* TextLabel2_2 {nullptr}; - QLabel* unitOfMeasureLabel {nullptr}; - QComboBox* pageSizeComboBox {nullptr}; - QComboBox* pageOrientationComboBox {nullptr}; - QComboBox* unitOfMeasureComboBox {nullptr}; - QCheckBox* startUpDialog {nullptr}; - QCheckBox* autoTextFrame {nullptr}; - QCheckBox* startDocSetup {nullptr}; - ScrSpinBox* Distance {nullptr}; - QSpinBox* numberOfCols {nullptr}; - QSpinBox* pageCountSpinBox {nullptr}; - ScrSpinBox* widthSpinBox {nullptr}; - ScrSpinBox* heightSpinBox {nullptr}; - QFrame* openDocFrame {nullptr}; QFileDialog *fileDialog {nullptr}; - QFrame* newFromTempFrame {nullptr}; - nftwidget *nftGui {nullptr}; - QFrame* recentDocFrame {nullptr}; - QListWidget* recentDocListBox {nullptr}; - QDialogButtonBox* buttonBox {nullptr}; - QPushButton* okButton {nullptr}; - QPushButton* cancelButton {nullptr}; bool onStartup() const { return m_onStartup;} int tabSelected() const { return m_tabSelected;} @@ -157,14 +108,6 @@ void openFileDialogFileClicked(const QString &path); protected: - QVBoxLayout* TabbedNewDocLayout {nullptr}; - QHBoxLayout* Layout1 {nullptr}; - QGridLayout* NewDocLayout {nullptr}; - QGridLayout* pageSizeGroupBoxLayout {nullptr}; - QGridLayout* optionsGroupBoxLayout {nullptr}; - QVBoxLayout* openDocLayout {nullptr}; - QVBoxLayout* recentDocLayout {nullptr}; - QVBoxLayout *verticalLayout {nullptr}; PrefsManager& prefsManager; QStringList recentDocList; Index: scribus/ui/newdocdialog.ui =================================================================== --- scribus/ui/newdocdialog.ui (nicht existent) +++ scribus/ui/newdocdialog.ui (Arbeitskopie) @@ -0,0 +1,565 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>newDocDialog</class> + <widget class="QDialog" name="newDocDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>721</width> + <height>528</height> + </rect> + </property> + <property name="windowTitle"> + <string>Dialog</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QTabWidget" name="tabWidget"> + <property name="currentIndex"> + <number>0</number> + </property> + <property name="documentMode"> + <bool>true</bool> + </property> + <property name="tabBarAutoHide"> + <bool>true</bool> + </property> + <widget class="QWidget" name="tab"> + <attribute name="title"> + <string>New Document</string> + </attribute> + <layout class="QGridLayout" name="gridLayout"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>8</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <property name="spacing"> + <number>4</number> + </property> + <item row="2" column="1"> + <widget class="QGroupBox" name="groupBox_5"> + <property name="title"> + <string>Bleeds</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_5"> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="NewMarginWidget" name="bleedGroup" native="true"/> + </item> + </layout> + </widget> + </item> + <item row="0" column="0" colspan="2"> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>Document Layout</string> + </property> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="0" column="2"> + <widget class="QLabel" name="TextLabel1"> + <property name="text"> + <string>&Size:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="1" column="3"> + <widget class="QComboBox" name="pageOrientationComboBox"/> + </item> + <item row="2" column="3"> + <widget class="ScrSpinBox" name="widthSpinBox"/> + </item> + <item row="2" column="2"> + <widget class="QLabel" name="TextLabel1_2"> + <property name="text"> + <string>&Width:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="0" column="3"> + <widget class="QComboBox" name="pageSizeComboBox"/> + </item> + <item row="3" column="2"> + <widget class="QLabel" name="TextLabel2_2"> + <property name="text"> + <string>&Height:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QLabel" name="TextLabel2"> + <property name="text"> + <string>Orie&ntation:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="0" column="0" rowspan="5"> + <widget class="PageLayoutsWidget" name="layoutsView"/> + </item> + <item row="3" column="3"> + <widget class="ScrSpinBox" name="heightSpinBox"/> + </item> + <item row="4" column="3"> + <widget class="QComboBox" name="unitOfMeasureComboBox"/> + </item> + <item row="4" column="2"> + <widget class="QLabel" name="unitOfMeasureLabel"> + <property name="text"> + <string>&Default Unit:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="0" column="1"> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>16</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + <item row="1" column="1"> + <widget class="QGroupBox" name="autoTextFrame"> + <property name="title"> + <string>Automatic Text Frame</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>false</bool> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_7"> + <item> + <widget class="FormWidget" name="TextLabel3"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Columns</string> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_5"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QSpinBox" name="numberOfCols"/> + </item> + </layout> + </widget> + </item> + <item> + <widget class="FormWidget" name="TextLabel4"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Gap</string> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_6"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="ScrSpinBox" name="Distance"/> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + <item row="2" column="0"> + <widget class="QGroupBox" name="groupBox_4"> + <property name="title"> + <string>Margins</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <item> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="NewMarginWidget" name="marginGroup" native="true"/> + </item> + </layout> + </widget> + </item> + <item row="1" column="0"> + <widget class="QGroupBox" name="groupBox_2"> + <property name="title"> + <string>Pages</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="FormWidget" name="pageCountLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Number of Pages</string> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QSpinBox" name="pageCountSpinBox"/> + </item> + </layout> + </widget> + </item> + <item> + <widget class="FormWidget" name="layoutLabel1"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>First Page</string> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QComboBox" name="firstPage"/> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + <item row="3" column="0" colspan="2"> + <widget class="QCheckBox" name="startDocSetup"> + <property name="text"> + <string>Show Document Settings After Creation</string> + </property> + </widget> + </item> + <item row="4" column="0"> + <spacer name="verticalSpacer_3"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab_2"> + <attribute name="title"> + <string>New from Template</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <property name="spacing"> + <number>4</number> + </property> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>8</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="nftwidget" name="nftGui" native="true"/> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab_3"> + <attribute name="title"> + <string>Open Existing Document</string> + </attribute> + </widget> + <widget class="QWidget" name="tab_4"> + <attribute name="title"> + <string>Open Recent Document</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <property name="spacing"> + <number>4</number> + </property> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>8</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QListWidget" name="recentDocListBox"/> + </item> + </layout> + </widget> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QCheckBox" name="startUpDialog"> + <property name="text"> + <string>Do not show this dialog again</string> + </property> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>FormWidget</class> + <extends>QWidget</extends> + <header>ui/widgets/form_widget.h</header> + <container>1</container> + </customwidget> + <customwidget> + <class>PageLayoutsWidget</class> + <extends>QListWidget</extends> + <header>ui/widgets/pagelayoutswidget.h</header> + </customwidget> + <customwidget> + <class>nftwidget</class> + <extends>QWidget</extends> + <header>ui/nftwidget.h</header> + <container>1</container> + </customwidget> + <customwidget> + <class>ScrSpinBox</class> + <extends>QDoubleSpinBox</extends> + <header>ui/scrspinbox.h</header> + </customwidget> + <customwidget> + <class>NewMarginWidget</class> + <extends>QWidget</extends> + <header>ui/newmarginwidget.h</header> + <container>1</container> + </customwidget> + </customwidgets> + <tabstops> + <tabstop>layoutsView</tabstop> + <tabstop>pageSizeComboBox</tabstop> + <tabstop>pageOrientationComboBox</tabstop> + <tabstop>widthSpinBox</tabstop> + <tabstop>heightSpinBox</tabstop> + <tabstop>unitOfMeasureComboBox</tabstop> + <tabstop>pageCountSpinBox</tabstop> + <tabstop>firstPage</tabstop> + <tabstop>autoTextFrame</tabstop> + <tabstop>numberOfCols</tabstop> + <tabstop>Distance</tabstop> + <tabstop>startDocSetup</tabstop> + <tabstop>startUpDialog</tabstop> + <tabstop>recentDocListBox</tabstop> + <tabstop>tabWidget</tabstop> + </tabstops> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>newDocDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>newDocDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> Index: scribus/ui/newmarginwidget.cpp =================================================================== --- scribus/ui/newmarginwidget.cpp (Revision 26196) +++ scribus/ui/newmarginwidget.cpp (Arbeitskopie) @@ -10,6 +10,8 @@ #include "units.h" #include "ui/marginpresetlayout.h" #include "ui/useprintermarginsdialog.h" +#include "iconmanager.h" +#include "scribusapp.h" NewMarginWidget::NewMarginWidget(QWidget* parent) : QWidget(parent) @@ -39,8 +41,8 @@ presetLayoutLabel->resize(0,0); presetLayoutComboBox->hide(); presetLayoutLabel->hide(); - gridLayout->removeWidget(presetLayoutComboBox); - gridLayout->removeWidget(presetLayoutLabel); + horizontalLayout->removeWidget(presetLayoutComboBox); + horizontalLayout->removeWidget(presetLayoutLabel); } if ((m_flags & ShowPrinterMargins) == 0) { @@ -47,14 +49,16 @@ printerMarginsPushButton->blockSignals(true); printerMarginsPushButton->resize(0,0); printerMarginsPushButton->hide(); - gridLayout->removeWidget(printerMarginsPushButton); + horizontalLayout->removeWidget(printerMarginsPushButton); } setFacingPages(!(layoutType == singlePage)); - gridLayout->invalidate(); +// gridLayout->invalidate(); languageChange(); + iconSetChange(); + connect(ScQApp, SIGNAL(iconSetChanged()), this, SLOT(iconSetChange())); connect(topMarginSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setTop())); connect(bottomMarginSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); connect(leftMarginSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); @@ -85,6 +89,16 @@ printerMarginsPushButton->setToolTip( "<qt>" + tr( "Import the margins for the selected page size from the available printers" ) + "</qt>"); } +void NewMarginWidget::iconSetChange() +{ + IconManager &iconManager = IconManager::instance(); + + topMarginLabel->setPixmap( iconManager.loadPixmap("border-top")); + bottomMarginLabel->setPixmap( iconManager.loadPixmap("border-bottom")); + leftMarginLabel->setPixmap( m_facingPages ? iconManager.loadPixmap("border-inside") : iconManager.loadPixmap("border-left")); + rightMarginLabel->setPixmap( m_facingPages ? iconManager.loadPixmap("border-outside") : iconManager.loadPixmap("border-right")); +} + void NewMarginWidget::setNewValues(const MarginStruct& margs) { m_marginData = m_savedMarginData = margs; @@ -324,8 +338,11 @@ { m_facingPages = facing; m_pageType = pageType; - leftMarginLabel->setText(facing ? tr( "&Inside:" ) : tr( "&Left:" )); - rightMarginLabel->setText(facing ? tr( "O&utside:" ) : tr( "&Right:" )); + + IconManager &iconManager = IconManager::instance(); + leftMarginLabel->setPixmap( m_facingPages ? iconManager.loadPixmap("border-inside") : iconManager.loadPixmap("border-left")); + rightMarginLabel->setPixmap( m_facingPages ? iconManager.loadPixmap("border-outside") : iconManager.loadPixmap("border-right")); + setPreset(); } Index: scribus/ui/newmarginwidget.h =================================================================== --- scribus/ui/newmarginwidget.h (Revision 26196) +++ scribus/ui/newmarginwidget.h (Arbeitskopie) @@ -41,10 +41,12 @@ 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 setTop(); void setBottom(); void setLeft(); Index: scribus/ui/newmarginwidgetbase.ui =================================================================== --- scribus/ui/newmarginwidgetbase.ui (Revision 26196) +++ scribus/ui/newmarginwidgetbase.ui (Arbeitskopie) @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>308</width> - <height>230</height> + <width>301</width> + <height>152</height> </rect> </property> <property name="sizePolicy"> @@ -16,45 +16,35 @@ <verstretch>0</verstretch> </sizepolicy> </property> - <layout class="QGridLayout" name="gridLayout_2"> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="spacing"> + <number>4</number> + </property> <property name="leftMargin"> - <number>0</number> + <number>8</number> </property> <property name="topMargin"> - <number>0</number> + <number>8</number> </property> <property name="rightMargin"> - <number>0</number> + <number>8</number> </property> <property name="bottomMargin"> - <number>0</number> + <number>8</number> </property> - <item row="0" column="0"> - <layout class="QGridLayout" name="gridLayout"> - <item row="4" column="0"> - <widget class="QLabel" name="bottomMarginLabel"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="presetLayoutLabel"> <property name="text"> - <string>Bottom:</string> + <string>Preset:</string> </property> - <property name="buddy"> - <cstring>bottomMarginSpinBox</cstring> - </property> </widget> </item> - <item row="1" column="0"> - <widget class="QLabel" name="leftMarginLabel"> - <property name="text"> - <string>Left:</string> - </property> - <property name="buddy"> - <cstring>leftMarginSpinBox</cstring> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="ScrSpinBox" name="bottomMarginSpinBox"> + <item> + <widget class="PresetLayout" name="presetLayoutComboBox"> <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> @@ -61,108 +51,286 @@ </property> </widget> </item> - <item row="2" column="0"> - <widget class="QLabel" name="rightMarginLabel"> + <item> + <widget class="QPushButton" name="printerMarginsPushButton"> <property name="text"> - <string>Right:</string> + <string>Printer Margins...</string> </property> - <property name="buddy"> - <cstring>rightMarginSpinBox</cstring> - </property> </widget> </item> - <item row="0" column="0"> - <widget class="QLabel" name="presetLayoutLabel"> - <property name="text"> - <string>Preset Layouts:</string> + <item> + <spacer name="horizontalSpacer_5"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> </property> - </widget> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> </item> - <item row="3" column="0"> - <widget class="QLabel" name="topMarginLabel"> - <property name="text"> - <string>Top:</string> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> </property> - <property name="buddy"> - <cstring>topMarginSpinBox</cstring> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> </property> - </widget> + </spacer> </item> - <item row="1" column="1"> - <widget class="ScrSpinBox" name="leftMarginSpinBox"> + <item> + <widget class="FormWidget" name="topMarginLabel"> <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> + <property name="label" stdset="0"> + <string/> + </property> + <property name="direction"> + <enum>FormWidget::Left</enum> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="ScrSpinBox" name="topMarginSpinBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> </widget> </item> - <item row="2" column="1"> - <widget class="ScrSpinBox" name="rightMarginSpinBox"> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <item> + <widget class="FormWidget" name="leftMarginLabel"> <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> + <property name="label" stdset="0"> + <string/> + </property> + <property name="direction"> + <enum>FormWidget::Left</enum> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_5"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="ScrSpinBox" name="leftMarginSpinBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> </widget> </item> - <item row="3" column="1"> - <widget class="ScrSpinBox" name="topMarginSpinBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <item> + <widget class="LinkButton" name="marginLinkButton"> + <property name="text"> + <string/> </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonIconOnly</enum> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> </widget> </item> - <item row="0" column="1"> - <widget class="PresetLayout" name="presetLayoutComboBox"> + <item> + <widget class="FormWidget" name="rightMarginLabel"> <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> + <property name="label" stdset="0"> + <string/> + </property> + <property name="direction"> + <enum>FormWidget::Right</enum> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_6"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="ScrSpinBox" name="rightMarginSpinBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> </widget> </item> - <item row="5" column="1"> - <widget class="QPushButton" name="printerMarginsPushButton"> - <property name="text"> - <string>Printer Margins...</string> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_7"> + <item> + <spacer name="horizontalSpacer_4"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> </property> - </widget> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> </item> - <item row="1" column="2" rowspan="4"> - <widget class="LinkButton" name="marginLinkButton"> + <item> + <widget class="FormWidget" name="bottomMarginLabel"> <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="minimumSize"> - <size> - <width>15</width> - <height>0</height> - </size> - </property> - <property name="text"> + <property name="label" stdset="0"> <string/> </property> - <property name="checkable"> - <bool>true</bool> + <property name="direction"> + <enum>FormWidget::Left</enum> </property> - <property name="toolButtonStyle"> - <enum>Qt::ToolButtonIconOnly</enum> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> </property> - <property name="autoRaise"> - <bool>true</bool> - </property> + <layout class="QHBoxLayout" name="horizontalLayout_8"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="ScrSpinBox" name="bottomMarginSpinBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> </widget> </item> + <item> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> </layout> </item> </layout> @@ -169,6 +337,12 @@ </widget> <customwidgets> <customwidget> + <class>FormWidget</class> + <extends>QWidget</extends> + <header>ui/widgets/form_widget.h</header> + <container>1</container> + </customwidget> + <customwidget> <class>ScrSpinBox</class> <extends>QDoubleSpinBox</extends> <header>ui/scrspinbox.h</header> @@ -186,12 +360,12 @@ </customwidgets> <tabstops> <tabstop>presetLayoutComboBox</tabstop> + <tabstop>printerMarginsPushButton</tabstop> + <tabstop>topMarginSpinBox</tabstop> <tabstop>leftMarginSpinBox</tabstop> + <tabstop>marginLinkButton</tabstop> <tabstop>rightMarginSpinBox</tabstop> - <tabstop>topMarginSpinBox</tabstop> <tabstop>bottomMarginSpinBox</tabstop> - <tabstop>marginLinkButton</tabstop> - <tabstop>printerMarginsPushButton</tabstop> </tabstops> <resources/> <connections/> Index: scribus/ui/pagepropertiesdialog.cpp =================================================================== --- scribus/ui/pagepropertiesdialog.cpp (Revision 26196) +++ scribus/ui/pagepropertiesdialog.cpp (Arbeitskopie) @@ -17,7 +17,7 @@ #include "commonstrings.h" #include "iconmanager.h" -#include "marginwidget.h" +#include "newmarginwidget.h" #include "pagepropertiesdialog.h" #include "pagesize.h" #include "pagestructs.h" @@ -112,10 +112,13 @@ } dialogLayout->addWidget( dsGroupBox7 ); - marginWidget = new MarginWidget(this, tr( "Margin Guides" ), &doc->currentPage()->initialMargins, doc->unitIndex(), false, false); - marginWidget->setPageWidthHeight(doc->currentPage()->width(), doc->currentPage()->height()); +// 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->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 ); @@ -320,22 +323,22 @@ double PagePropertiesDialog::top() const { - return marginWidget->top(); + return marginWidget->margins().top(); } double PagePropertiesDialog::bottom() const { - return marginWidget->bottom(); + return marginWidget->margins().bottom(); } double PagePropertiesDialog::left() const { - return marginWidget->left(); + return marginWidget->margins().left(); } double PagePropertiesDialog::right() const { - return marginWidget->right(); + return marginWidget->margins().right(); } QString PagePropertiesDialog::masterPage() const @@ -347,5 +350,5 @@ int PagePropertiesDialog::getMarginPreset() const { - return marginWidget->getMarginPreset(); + return marginWidget->marginPreset(); } Index: scribus/ui/pagepropertiesdialog.h =================================================================== --- scribus/ui/pagepropertiesdialog.h (Revision 26196) +++ scribus/ui/pagepropertiesdialog.h (Arbeitskopie) @@ -20,7 +20,7 @@ class QHBoxLayout; class QVBoxLayout; class ScrSpinBox; -class MarginWidget; +class NewMarginWidget; class ScribusDoc; /*! \brief A dialog to setup the existing document margins. @@ -90,7 +90,7 @@ void setPageHeight(double v); private: - MarginWidget* marginWidget { nullptr }; + NewMarginWidget* marginWidget { nullptr }; QGroupBox* dsGroupBox7 { nullptr }; QGroupBox* groupMaster { nullptr }; QLabel* masterPageLabel { nullptr }; |
|
New patch includes missing files and a fixes for macOS. newdocdialog_2024-07-19_01.patch (109,615 bytes)
Index: Scribus.pro =================================================================== --- Scribus.pro (Revision 26196) +++ Scribus.pro (Arbeitskopie) @@ -481,8 +481,7 @@ scribus/ui/linecombo.h \ scribus/ui/linkbutton.h \ scribus/ui/loremipsum.h \ - scribus/ui/marginpresetlayout.h \ - scribus/ui/marginwidget.h \ + scribus/ui/marginpresetlayout.h \ scribus/ui/mark2item.h \ scribus/ui/mark2mark.h \ scribus/ui/markanchor.h \ @@ -1083,6 +1082,7 @@ scribus/ui/measurementsbase.ui \ scribus/ui/multipleduplicate.ui \ scribus/ui/multiprogressdialog.ui \ + scribus/ui/newdocdialog.ui \ scribus/ui/newmarginwidgetbase.ui \ scribus/ui/nftdialog.ui \ scribus/ui/nftwidget.ui \ @@ -1627,8 +1627,7 @@ scribus/ui/linecombo.cpp \ scribus/ui/linkbutton.cpp \ scribus/ui/loremipsum.cpp \ - scribus/ui/marginpresetlayout.cpp \ - scribus/ui/marginwidget.cpp \ + scribus/ui/marginpresetlayout.cpp \ scribus/ui/mark2item.cpp \ scribus/ui/mark2mark.cpp \ scribus/ui/markanchor.cpp \ Index: resources/iconsets/1_7_0/16/action-minimize.svg =================================================================== --- resources/iconsets/1_7_0/16/action-minimize.svg (nicht existent) +++ resources/iconsets/1_7_0/16/action-minimize.svg (Arbeitskopie) @@ -0,0 +1,3 @@ +<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><style>@import '../colors.css';</style> +<rect x="2" y="12" width="12" height="2"/> +</svg> Index: resources/iconsets/1_7_0/16/action-pin.svg =================================================================== --- resources/iconsets/1_7_0/16/action-pin.svg (nicht existent) +++ resources/iconsets/1_7_0/16/action-pin.svg (Arbeitskopie) @@ -0,0 +1,3 @@ +<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><style>@import '../colors.css';</style> +<path fill-rule="evenodd" clip-rule="evenodd" d="M6 3V2H11V3L10 4L11 8L12 9V10H9V14H8V10H5V9L6 8L7 4L6 3Z"/> +</svg> Index: resources/iconsets/1_7_0/16/border-bottom.svg =================================================================== --- resources/iconsets/1_7_0/16/border-bottom.svg (nicht existent) +++ resources/iconsets/1_7_0/16/border-bottom.svg (Arbeitskopie) @@ -0,0 +1,4 @@ +<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><style>@import '../colors.css';</style> +<rect x="1" y="13" width="14" height="2" class="error"/> +<path d="M1 1V12H2V2H14V12H15V1H1Z"/> +</svg> Index: resources/iconsets/1_7_0/16/border-inside.svg =================================================================== --- resources/iconsets/1_7_0/16/border-inside.svg (nicht existent) +++ resources/iconsets/1_7_0/16/border-inside.svg (Arbeitskopie) @@ -0,0 +1,5 @@ +<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><style>@import '../colors.css';</style> +<rect x="7" y="1" width="2" height="14" class="error"/> +<path d="M6 15H1V1H6V2H2V14H6V15Z"/> +<path d="M10 1H15V15H10V14H14V2H10V1Z"/> +</svg> Index: resources/iconsets/1_7_0/16/border-left.svg =================================================================== --- resources/iconsets/1_7_0/16/border-left.svg (nicht existent) +++ resources/iconsets/1_7_0/16/border-left.svg (Arbeitskopie) @@ -0,0 +1,4 @@ +<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><style>@import '../colors.css';</style> +<rect x="1" y="1" width="2" height="14" class="error"/> +<path d="M15 1H4V2H14V14H4V15H15V1Z"/> +</svg> Index: resources/iconsets/1_7_0/16/border-outside.svg =================================================================== --- resources/iconsets/1_7_0/16/border-outside.svg (nicht existent) +++ resources/iconsets/1_7_0/16/border-outside.svg (Arbeitskopie) @@ -0,0 +1,6 @@ +<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><style>@import '../colors.css';</style> +<path d="M3 1H1V15H3V1Z" class="error"/> +<path d="M15 1H13V15H15V1Z" class="error"/> +<path d="M12 1H4V2H12V1Z"/> +<path d="M12 14H4V15H12V14Z"/> +</svg> Index: resources/iconsets/1_7_0/16/border-right.svg =================================================================== --- resources/iconsets/1_7_0/16/border-right.svg (nicht existent) +++ resources/iconsets/1_7_0/16/border-right.svg (Arbeitskopie) @@ -0,0 +1,4 @@ +<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><style>@import '../colors.css';</style> +<rect x="13" y="1" width="2" height="14" class="error"/> +<path d="M1 15H12V14H2V2H12V1H1V15Z"/> +</svg> Index: resources/iconsets/1_7_0/16/border-top.svg =================================================================== --- resources/iconsets/1_7_0/16/border-top.svg (nicht existent) +++ resources/iconsets/1_7_0/16/border-top.svg (Arbeitskopie) @@ -0,0 +1,4 @@ +<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><style>@import '../colors.css';</style> +<rect x="1" y="1" width="14" height="2" class="error"/> +<path d="M15 15V4H14V14H2V4H1V15H15Z"/> +</svg> Index: resources/iconsets/1_7_0/1_7_0.xml =================================================================== --- resources/iconsets/1_7_0/1_7_0.xml (Revision 26196) +++ resources/iconsets/1_7_0/1_7_0.xml (Arbeitskopie) @@ -385,6 +385,12 @@ <icon id="page-import" file="16/page-import.svg" /> <icon id="layer-move-down" file="16/object-level-down.svg" /> <icon id="layer-move-up" file="16/object-level-up.svg" /> + <icon id="border-outside" file="16/border-outside.svg" /> + <icon id="border-inside" file="16/border-inside.svg" /> + <icon id="border-left" file="16/border-left.svg" /> + <icon id="border-top" file="16/border-top.svg" /> + <icon id="border-right" file="16/border-right.svg" /> + <icon id="border-bottom" file="16/border-bottom.svg" /> <!-- PDF Tools --> <icon id="16/insert-button.png" file="16/pdf-button.svg" /> Index: scribus/CMakeLists_Sources.txt =================================================================== --- scribus/CMakeLists_Sources.txt (Revision 26196) +++ scribus/CMakeLists_Sources.txt (Arbeitskopie) @@ -362,7 +362,6 @@ ui/marksmanager.cpp ui/markvariabletext.cpp ui/marginpresetlayout.cpp - ui/marginwidget.cpp ui/newmarginwidget.cpp ui/mergedoc.cpp ui/missing.cpp @@ -559,6 +558,7 @@ ui/widgets/floatingwindow.cpp ui/widgets/form_widget.cpp ui/widgets/gradientlistbox.cpp + ui/widgets/pagelayoutswidget.cpp ui/widgets/popup_menu.cpp ui/widgets/section_container.cpp ui/widgets/stacked_container.cpp Index: scribus/scribus.cpp =================================================================== --- scribus/scribus.cpp (Revision 26196) +++ scribus/scribus.cpp (Arbeitskopie) @@ -183,7 +183,6 @@ #include "ui/javadocs.h" #include "ui/layers.h" #include "ui/loremipsum.h" -#include "ui/marginwidget.h" #include "ui/mark2item.h" #include "ui/mark2mark.h" #include "ui/markanchor.h" @@ -2016,10 +2015,10 @@ int facingPages = dia->choosenLayout(); int firstPage = dia->firstPage->currentIndex(); docSet = dia->startDocSetup->isChecked(); - double topMargin = dia->marginGroup->top(); - double bottomMargin = dia->marginGroup->bottom(); - double leftMargin = dia->marginGroup->left(); - double rightMargin = dia->marginGroup->right(); + 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 columnDistance = dia->distance(); double pageWidth = dia->pageWidth(); double pageHeight = dia->pageHeight(); @@ -2035,7 +2034,7 @@ PageSize ps2(dia->pageSizeComboBox->currentText()); pagesize = ps2.name(); } - doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, numberCols, autoframes, facingPages, dia->unitOfMeasureComboBox->currentIndex(), firstPage, orientation, 1, pagesize, true, pageCount, true, dia->marginGroup->getMarginPreset()); + doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, numberCols, autoframes, facingPages, dia->unitOfMeasureComboBox->currentIndex(), firstPage, orientation, 1, pagesize, true, pageCount, true, dia->marginGroup->marginPreset()); doc->setPageSetFirstPage(facingPages, firstPage); doc->bleeds()->set(dia->bleedTop(), dia->bleedLeft(), dia->bleedBottom(), dia->bleedRight()); HaveNewDoc(); @@ -2099,10 +2098,10 @@ int facingPages = dia->choosenLayout(); int firstPage = dia->firstPage->currentIndex(); bool docSet = dia->startDocSetup->isChecked(); - double topMargin = dia->marginGroup->top(); - double bottomMargin = dia->marginGroup->bottom(); - double leftMargin = dia->marginGroup->left(); - double rightMargin = dia->marginGroup->right(); + 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 columnDistance = dia->distance(); double pageWidth = dia->pageWidth(); double pageHeight = dia->pageHeight(); @@ -2118,7 +2117,7 @@ PageSize ps2(dia->pageSizeComboBox->currentText()); pagesize = ps2.name(); } - if (doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, numberCols, autoframes, facingPages, dia->unitOfMeasureComboBox->currentIndex(), firstPage, orientation, 1, pagesize, true, pageCount, true, dia->marginGroup->getMarginPreset())) + 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())) { doc->setPageSetFirstPage(facingPages, firstPage); doc->bleeds()->set(dia->bleedTop(), dia->bleedLeft(), dia->bleedBottom(), dia->bleedRight()); Index: scribus/ui/marginwidget.cpp =================================================================== --- scribus/ui/marginwidget.cpp (Revision 26196) +++ scribus/ui/marginwidget.cpp (nicht existent) @@ -1,623 +0,0 @@ -/* -For general Scribus (>=1.3.2) copyright and licensing information please refer -to the COPYING file provided with the program. Following this notice may exist -a copyright and/or license notice that predates the release of Scribus 1.3.2 -for which a new license (GPL+exception) is in place. -*/ -#include "marginwidget.h" - -#include <QHBoxLayout> -#include <QGridLayout> -#include <QLabel> -#include <QToolTip> -#include <QCheckBox> -#include <QLabel> -#include <QPushButton> - -#include "scrspinbox.h" -#include "units.h" -#include "ui/useprintermarginsdialog.h" - - -MarginWidget::MarginWidget( QWidget* parent, const QString& /*title*/, const MarginStruct* margs, int unitIndex, bool showChangeAll, bool showBleeds) : QTabWidget(parent), - m_useBleeds(showBleeds) -{ - marginData = *margs; - m_savedMargins = *margs; - m_savedPresetItem = PresetLayout::none; //we don't recheck if we are using a layout but always start at none - marginPage = new QWidget(this); - - presetCombo = new PresetLayout(marginPage); - presetLabel = new QLabel( tr("Preset Layouts:"), marginPage); - presetLabel->setBuddy(presetCombo); - m_unitIndex = unitIndex; - m_unitRatio = unitGetRatioFromIndex(unitIndex); - leftR = new ScrSpinBox( 0, 1000, marginPage, unitIndex ); - rightR = new ScrSpinBox( 0, 1000, marginPage, unitIndex ); - topR = new ScrSpinBox( 0, 1000, marginPage, unitIndex ); - bottomR = new ScrSpinBox( 0, 1000, marginPage, unitIndex ); - updateMarginSpinValues(); - - bText = new QLabel( tr( "&Bottom:" ), marginPage); - bText->setBuddy(bottomR); - tText = new QLabel( tr( "&Top:" ), marginPage); - tText->setBuddy(topR); - rText = new QLabel( tr( "&Right:" ), marginPage); - rText->setBuddy(rightR); - lText = new QLabel( tr( "&Left:" ), marginPage); - lText->setBuddy(leftR); - - linkMargins = new LinkButton( marginPage ); - linkMargins->setCheckable( true ); - linkMargins->setChecked(false); - linkMargins->setAutoRaise( true ); - linkMargins->setMinimumSize( QSize( 15, 0 ) ); - linkMargins->setMaximumSize( QSize( 15, 32767 ) ); - - // layout - GroupLayout = new QGridLayout( marginPage ); - GroupLayout->setSpacing(6); - GroupLayout->setContentsMargins(9, 9, 9, 9); - GroupLayout->addWidget(presetLabel, 0, 0); - GroupLayout->addWidget(presetCombo, 0, 1); - GroupLayout->addWidget( leftR, 1, 1 ); - GroupLayout->addWidget( rightR, 2, 1 ); - GroupLayout->addWidget( topR, 3, 1 ); - GroupLayout->addWidget( bottomR, 4, 1 ); - GroupLayout->addWidget( lText, 1, 0 ); - GroupLayout->addWidget( rText, 2, 0 ); - GroupLayout->addWidget( tText, 3, 0 ); - GroupLayout->addWidget( bText, 4, 0 ); - GroupLayout->addWidget( linkMargins, 1, 2, 4, 1 ); - if (showChangeAll) - { - marginsForPagesLayout = new QHBoxLayout; - marginsForPagesLayout->setContentsMargins(9, 9, 9, 9); - marginsForPagesLayout->setSpacing(6); - marginsForPages = new QLabel( tr( "Apply settings to:" ), marginPage ); - marginsForPagesLayout->addWidget(marginsForPages); - marginsForAllPages = new QCheckBox( marginPage ); - marginsForAllPages->setText( tr( "All Document Pages" ) ); - marginsForAllPages->setChecked( false ); - marginsForPagesLayout->addWidget(marginsForAllPages); - marginsForAllMasterPages = new QCheckBox( marginPage ); - marginsForAllMasterPages->setText( tr( "All Master Pages" ) ); - marginsForAllMasterPages->setChecked( false ); - marginsForPagesLayout->addWidget(marginsForAllMasterPages); - GroupLayout->addLayout( marginsForPagesLayout, 6, 0, 1, 2 ); - marginsForAllPages->setToolTip( "<qt>" + tr( "Apply the margin changes to all existing pages in the document" ) + "</qt>" ); - marginsForAllMasterPages->setToolTip( "<qt>" + tr( "Apply the margin changes to all existing master pages in the document" ) + "</qt>" ); - } - - usePrinterMarginsButton = nullptr; - usePrinterMarginsButton = new QPushButton( tr("Printer Margins..."),marginPage ); - GroupLayout->addWidget( usePrinterMarginsButton, 5, 1 ); - usePrinterMarginsButton->setToolTip( "<qt>" + tr( "Import the margins for the selected page size from the available printers" ) + "</qt>"); - connect(usePrinterMarginsButton, SIGNAL(clicked()), this, SLOT(setMarginsToPrinterMargins())); - - addTab(marginPage, tr("Margin Guides")); - - if (m_useBleeds) - { - bleedPage = new QWidget(this); - BleedGroupLayout = new QGridLayout( bleedPage ); - BleedGroupLayout->setSpacing(6); - BleedGroupLayout->setContentsMargins(9, 9, 9, 9); - BleedGroupLayout->setAlignment( Qt::AlignTop ); - BleedTxt3 = new QLabel( bleedPage ); - BleedGroupLayout->addWidget( BleedTxt3, 0, 0 ); - BleedLeft = new ScrSpinBox( 0, 3000*m_unitRatio, bleedPage, unitIndex ); - BleedGroupLayout->addWidget( BleedLeft, 0, 1 ); - BleedTxt4 = new QLabel( bleedPage ); - BleedGroupLayout->addWidget( BleedTxt4, 1, 0 ); - BleedRight = new ScrSpinBox( 0, 3000*m_unitRatio, bleedPage, unitIndex ); - BleedGroupLayout->addWidget( BleedRight, 1, 1 ); - BleedTxt1 = new QLabel( bleedPage ); - BleedTxt1->setText( tr( "Top:" ) ); - BleedGroupLayout->addWidget( BleedTxt1, 2, 0 ); - BleedTop = new ScrSpinBox( 0, 3000*m_unitRatio, bleedPage, unitIndex ); - BleedGroupLayout->addWidget( BleedTop, 2, 1 ); - BleedTxt2 = new QLabel( bleedPage ); - BleedTxt2->setText( tr( "Bottom:" ) ); - BleedGroupLayout->addWidget( BleedTxt2, 3, 0 ); - BleedBottom = new ScrSpinBox( 0, 3000*m_unitRatio, bleedPage, unitIndex ); - BleedGroupLayout->addWidget( BleedBottom, 3, 1 ); - linkBleeds = new LinkButton( bleedPage ); -/** Fix Me to move this to the prefsmanager.cpp someday */ - linkBleeds->setCheckable( true ); - linkBleeds->setChecked(true); - linkBleeds->setAutoRaise( true ); - linkBleeds->setMinimumSize( QSize( 15, 0 ) ); - linkBleeds->setMaximumSize( QSize( 15, 32767 ) ); - BleedGroupLayout->addWidget( linkBleeds, 0, 2, 4, 1 ); - BleedTop->setToolTip( "<qt>" + tr( "Distance for bleed from the top of the physical page" ) + "</qt>" ); - BleedBottom->setToolTip( "<qt>" + tr( "Distance for bleed from the bottom of the physical page" ) + "</qt>" ); - BleedLeft->setToolTip( "<qt>" + tr( "Distance for bleed from the left of the physical page" ) + "</qt>" ); - BleedRight->setToolTip( "<qt>" + tr( "Distance for bleed from the right of the physical page" ) + "</qt>"); - linkBleeds->setToolTip( "<qt>" + tr( "Ensure all bleeds have the same value" ) + "</qt>"); - connect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(linkBleeds, SIGNAL(clicked()), this, SLOT(slotLinkBleeds())); - addTab(bleedPage, tr("Bleeds")); - } - - // hints - topR->setToolTip( "<qt>" + tr( "Distance between the top margin guide and the edge of the page" ) + "</qt>"); - bottomR->setToolTip( "<qt>" + tr( "Distance between the bottom margin guide and the edge of the page" ) + "</qt>"); - leftR->setToolTip( "<qt>" + tr( "Distance between the left margin guide and the edge of the page. If a double-sided, 3 or 4-fold layout is selected, this margin space can be used to achieve the correct margins for binding.") + "</qt>"); - rightR->setToolTip( "<qt>" + tr( "Distance between the right margin guide and the edge of the page. If a double-sided, 3 or 4-fold layout is selected, this margin space can be used to achieve the correct margins for binding.") + "</qt>"); - linkMargins->setToolTip( "<qt>" + tr( "Ensure all margins have the same value") + "</qt>"); - - // signals&slots - connect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - connect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - connect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - connect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - connect(presetCombo, SIGNAL(activated(int)), this, SLOT(setPreset())); - connect(linkMargins, SIGNAL(clicked()), this, SLOT(slotLinkMargins())); -} - -void MarginWidget::slotLinkBleeds() -{ - disconnect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - - double bleedValue = BleedLeft->value(); - if (BleedLeft->hasFocus()) - { - BleedLeft->clearFocus(); - bleedValue = BleedLeft->value(); - } - if (BleedRight->hasFocus()) - { - BleedRight->clearFocus(); - bleedValue = BleedRight->value(); - } - if (BleedTop->hasFocus()) - { - BleedTop->clearFocus(); - bleedValue = BleedTop->value(); - } - if (BleedBottom->hasFocus()) - { - BleedBottom->clearFocus(); - bleedValue = BleedBottom->value(); - } - - if (linkBleeds->isChecked()) - { - BleedLeft->setValue(bleedValue); - BleedTop->setValue(bleedValue); - BleedBottom->setValue(bleedValue); - BleedRight->setValue(bleedValue); - } - - connect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); -} - -void MarginWidget::changeBleeds() -{ - if (linkBleeds->isChecked()) - { - double val = 0.0; - if (BleedTop == sender()) - val = BleedTop->value(); - else if (BleedBottom == sender()) - val = BleedBottom->value(); - else if (BleedLeft == sender()) - val = BleedLeft->value(); - else if (BleedRight == sender()) - val = BleedRight->value(); - val = val / m_unitRatio; - MarginStruct v(val,val,val,val); - setNewBleeds(v); - } -} - -void MarginWidget::setFacingPages(bool facing, int pagetype) -{ - m_facingPages = facing; - m_pageType = pagetype; - lText->setText(facing ? tr( "&Inside:" ) : tr( "&Left:" )); - rText->setText(facing ? tr( "O&utside:" ) : tr( "&Right:" )); - if (m_useBleeds) - { - if (facing) - { - BleedTxt3->setText( tr( "Inside:" ) ); - BleedTxt4->setText( tr( "Outside:" ) ); - } - else - { - BleedTxt3->setText( tr( "Left:" ) ); - BleedTxt4->setText( tr( "Right:" ) ); - } - } - setPreset(); -} - -void MarginWidget::setPageWidthHeight(double width, double height) -{ - rightR->setMaximum(qMax(0.0, width * m_unitRatio - leftR->value())); - leftR->setMaximum(qMax(0.0, width * m_unitRatio - rightR->value())); - m_pageWidth = width; - topR->setMaximum(qMax(0.0, height * m_unitRatio - bottomR->value())); - bottomR->setMaximum(qMax(0.0, height * m_unitRatio - topR->value())); - m_pageHeight = height; - setPreset(); -} - -void MarginWidget::setPageWidth(double width) -{ - rightR->setMaximum(qMax(0.0, width * m_unitRatio - leftR->value())); - leftR->setMaximum(qMax(0.0,width * m_unitRatio - rightR->value())); - m_pageWidth = width; - setPreset(); -} - -void MarginWidget::setPageHeight(double height) -{ - topR->setMaximum(qMax(0.0, height * m_unitRatio - bottomR->value())); - bottomR->setMaximum(qMax(0.0,height * m_unitRatio - topR->value())); - m_pageHeight = height; - setPreset(); -} - -void MarginWidget::setTop() -{ - double newVal = topR->value() / m_unitRatio; - bottomR->setMaximum(qMax(0.0, m_pageHeight * m_unitRatio - topR->value())); - if (linkMargins->isChecked() && m_savedPresetItem == PresetLayout::none) - { - marginData.set(newVal, newVal, newVal, newVal); - updateMarginSpinValues(); - } - else - marginData.setTop(newVal); - setPreset(); -} - -void MarginWidget::setBottom() -{ - double newVal = bottomR->value() / m_unitRatio; - topR->setMaximum(qMax(0.0, m_pageHeight * m_unitRatio - bottomR->value())); - if (linkMargins->isChecked() && m_savedPresetItem == PresetLayout::none) - { - marginData.set(newVal, newVal, newVal, newVal); - updateMarginSpinValues(); - } - else - marginData.setBottom(newVal); - setPreset(); -} - -void MarginWidget::setLeft() -{ - double newVal = leftR->value() / m_unitRatio; - rightR->setMaximum(qMax(0.0, m_pageWidth * m_unitRatio - leftR->value())); - if (linkMargins->isChecked() && m_savedPresetItem == PresetLayout::none) - { - marginData.set(newVal, newVal, newVal, newVal); - updateMarginSpinValues(); - } - else - marginData.setLeft(newVal); - setPreset(); -} - -void MarginWidget::setRight() -{ - double newVal = rightR->value() / m_unitRatio; - leftR->setMaximum(qMax(0.0, m_pageWidth * m_unitRatio - rightR->value())); - if (linkMargins->isChecked() && m_savedPresetItem == PresetLayout::none) - { - marginData.set(newVal, newVal, newVal, newVal); - updateMarginSpinValues(); - } - else - marginData.setRight(newVal); - setPreset(); -} - -void MarginWidget::setNewUnit(int newUnitIndex) -{ - disconnect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - disconnect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - disconnect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - disconnect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - m_unitIndex = newUnitIndex; - m_unitRatio = unitGetRatioFromIndex(newUnitIndex); - topR->setNewUnit(newUnitIndex); - bottomR->setNewUnit(newUnitIndex); - leftR->setNewUnit(newUnitIndex); - rightR->setNewUnit(newUnitIndex); - - if (m_useBleeds) - { - disconnect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - BleedBottom->setNewUnit(newUnitIndex); - BleedTop->setNewUnit(newUnitIndex); - BleedRight->setNewUnit(newUnitIndex); - BleedLeft->setNewUnit(newUnitIndex); - connect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - } - connect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - connect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - connect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - connect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); -} - -void MarginWidget::setPreset() -{ - disconnect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - disconnect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - disconnect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - disconnect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - if (m_savedPresetItem == PresetLayout::none) - m_savedMargins = marginData; - int item = presetCombo->currentIndex(); - - MarginStruct marg = presetCombo->getMargins(item, m_pageWidth, m_pageHeight, leftR->value() / m_unitRatio); - presetCombo->setEnabled(m_facingPages); - - bool restoringValues = false; - if ((item == PresetLayout::none) && (m_savedPresetItem != PresetLayout::none)) - { - marg = m_savedMargins; - restoringValues = true; - } - if (restoringValues || (presetCombo->needUpdate() && m_facingPages)) - { - marginData.set(qMax(0.0, marg.top()), qMax(0.0, marg.left()), qMax(0.0, marg.bottom()), qMax(0.0, marg.right())); - updateMarginSpinValues(); - - bottomR->setMaximum(qMax(0.0, m_pageHeight * m_unitRatio - topR->value())); - topR->setMaximum(qMax(0.0, m_pageHeight * m_unitRatio - bottomR->value())); - rightR->setMaximum(qMax(0.0, m_pageWidth * m_unitRatio - leftR->value())); - leftR->setMaximum(qMax(0.0, m_pageWidth * m_unitRatio - rightR->value())); - rightR->setEnabled(restoringValues); - topR->setEnabled(restoringValues); - bottomR->setEnabled(restoringValues); - } - else - { - rightR->setEnabled(true); - topR->setEnabled(true); - bottomR->setEnabled(true); - } - if (m_pageType == 1) - rightR->setEnabled(false); - leftR->setEnabled(item != PresetLayout::nineparts); - if (item != PresetLayout::none) - linkMargins->setChecked(false); - linkMargins->setEnabled(item == PresetLayout::none || !presetCombo->isEnabled()); - connect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - connect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - connect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - connect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - m_savedPresetItem = item; -} - -void MarginWidget::setPageSize(const QString& pageSize) -{ - m_pageSize = pageSize; -} - -void MarginWidget::setMarginsToPrinterMargins() -{ - 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); - presetCombo->setCurrentIndex(PresetLayout::none); - - marginData.setTop(t); - marginData.setBottom(b); - marginData.setLeft(l); - marginData.setRight(r); - updateMarginSpinValues(); - - bottomR->setMaximum((qMax(0.0, m_pageHeight - t) * m_unitRatio)); - topR->setMaximum((qMax(0.0, m_pageHeight - b) * m_unitRatio)); - rightR->setMaximum((qMax(0.0, m_pageWidth - l) * m_unitRatio)); - leftR->setMaximum((qMax(0.0, m_pageWidth - r) * m_unitRatio)); - - rightR->setEnabled(true); - topR->setEnabled(true); - bottomR->setEnabled(true); -} - -double MarginWidget::top() const -{ - return marginData.top(); -} - -double MarginWidget::bottom() const -{ - return marginData.bottom(); -} - -double MarginWidget::left() const -{ - return marginData.left(); -} - -double MarginWidget::right() const -{ - return marginData.right(); -} - -void MarginWidget::setNewMargins(MarginStruct &m) -{ - disconnect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - disconnect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - disconnect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - disconnect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - marginData = m; - updateMarginSpinValues(); - connect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - connect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - connect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - connect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); -} - -void MarginWidget::setMarginPreset(int p) -{ - disconnect(presetCombo, SIGNAL(activated(int)), this, SLOT(setPreset())); - m_savedPresetItem = p; - presetCombo->setCurrentIndex(p); - if (m_savedPresetItem == PresetLayout::none) - m_savedMargins = marginData; - int item = presetCombo->currentIndex(); - presetCombo->setEnabled(m_facingPages); - bool restoringValues = false; - if ((item == PresetLayout::none) && (m_savedPresetItem != PresetLayout::none)) - { - restoringValues = true; - } - if (restoringValues || (presetCombo->needUpdate() && m_facingPages)) - { - rightR->setEnabled(restoringValues); - topR->setEnabled(restoringValues); - bottomR->setEnabled(restoringValues); - } - else - { - rightR->setEnabled(true); - topR->setEnabled(true); - bottomR->setEnabled(true); - } - if (m_pageType == 1) - rightR->setEnabled(false); - leftR->setEnabled(item != PresetLayout::nineparts); - if (item != PresetLayout::none) - linkMargins->setChecked(false); - linkMargins->setEnabled(item == PresetLayout::none); - connect(presetCombo, SIGNAL(activated(int)), this, SLOT(setPreset())); -} - -int MarginWidget::getMarginPreset() -{ - return presetCombo->currentIndex(); -} - -bool MarginWidget::getMarginsForAllPages() const -{ - return marginsForAllPages->isChecked(); -} - -bool MarginWidget::getMarginsForAllMasterPages() const -{ - return marginsForAllMasterPages->isChecked(); -} - -void MarginWidget::setNewBleeds(MarginStruct& b) -{ - disconnect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - BleedTop->setValue(b.top() * m_unitRatio); - BleedBottom->setValue(b.bottom() * m_unitRatio); - BleedLeft->setValue(b.left() * m_unitRatio); - BleedRight->setValue(b.right() * m_unitRatio); - connect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); -} - -double MarginWidget::topBleed() const -{ - return BleedTop->value() / m_unitRatio; -} - -double MarginWidget::bottomBleed() const -{ - return BleedBottom->value() / m_unitRatio; -} - -double MarginWidget::leftBleed() const -{ - return BleedLeft->value() / m_unitRatio; -} - -double MarginWidget::rightBleed() const -{ - return BleedRight->value() / m_unitRatio; -} - -const MarginStruct & MarginWidget::margins() const -{ - return marginData; -} - -void MarginWidget::slotLinkMargins() -{ - disconnect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - disconnect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - disconnect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - disconnect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - - double marginValue = leftR->value(); - if (leftR->hasFocus()) - { - leftR->clearFocus(); - marginValue = leftR->value(); - } - if (rightR->hasFocus()) - { - rightR->clearFocus(); - marginValue = rightR->value(); - } - if (topR->hasFocus()) - { - topR->clearFocus(); - marginValue = topR->value(); - } - if (bottomR->hasFocus()) - { - bottomR->clearFocus(); - marginValue = bottomR->value(); - } - - if (linkMargins->isChecked()) - { - leftR->setValue(marginValue); - bottomR->setValue(marginValue); - topR->setValue(marginValue); - rightR->setValue(marginValue); - double newVal = marginValue / m_unitRatio; - marginData.set(newVal, newVal, newVal, newVal); - } - - connect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - connect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - connect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - connect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - -} - -void MarginWidget::updateMarginSpinValues() -{ - topR->setValue(marginData.top() * m_unitRatio); - rightR->setValue(marginData.right() * m_unitRatio); - bottomR->setValue(marginData.bottom() * m_unitRatio); - leftR->setValue(marginData.left() * m_unitRatio); -} Property changes on: scribus/ui/marginwidget.cpp ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Author Date Id Revision \ No newline at end of property Index: scribus/ui/marginwidget.h =================================================================== --- scribus/ui/marginwidget.h (Revision 26196) +++ scribus/ui/marginwidget.h (nicht existent) @@ -1,178 +0,0 @@ -/* -For general Scribus (>=1.3.2) copyright and licensing information please refer -to the COPYING file provided with the program. Following this notice may exist -a copyright and/or license notice that predates the release of Scribus 1.3.2 -for which a new license (GPL+exception) is in place. -*/ -#ifndef MARGINWIDGET_H -#define MARGINWIDGET_H - -#include "scribusapi.h" -#include "scribusstructs.h" - -#include <QComboBox> -#include <QTabWidget> -#include "linkbutton.h" -#include "marginpresetlayout.h" - -class QCheckBox; -class QPushButton; -class QLabel; -class QGridLayout; -class QHBoxLayout; -class ScrSpinBox; - - -/*! \brief Widget for Margins setting. -Used e.g. in "New Doc Dialog" or "Preferences". -*/ -class SCRIBUS_API MarginWidget : public QTabWidget -{ - Q_OBJECT - -public: - /*! \brief It creates an user interface for base margin settings for the document. - \param parent Parent widget (used as standard in Qt) - \param title Title of the Group box - \param margs A reference to the margins in the preferences. - \param unitIndex and index of the unit combobox - \param showChangeAll show "apply to all pages" related items - */ - MarginWidget(QWidget* parent, const QString& title, const MarginStruct* margs, int unitIndex, bool showChangeAll = false, bool showBleeds = true); - ~MarginWidget() {} - /*! \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 and height */ - void setPageWidthHeight(double width, double height); - /*! \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); - /*! \brief Setup the widgets by new options */ - void setNewUnit(int newUnitIndex); - /*! \brief Set the page size for margin getting from cups */ - void setPageSize(const QString& pageSize); - - /*! \brief Margins - \retval MarginStruct data */ - const MarginStruct& margins() const; - /*! \brief Top Margin - \retval double margin size */ - double top() const; - /*! \brief Bottom Margin - \retval double margin size */ - double bottom() const; - /*! \brief Left Margin - \retval double margin size */ - double left() const; - /*! \brief Right Margin - \retval double margin size */ - double right() const; - - /*! \brief set new margin values for the dialog - It calls overridden setTop(), setBottom() etc. slots itself - via signals emitted from spinboxes. - \param m MarginStruct - */ - void setNewMargins(MarginStruct& m); - - /*! \brief Setup the presetCombo without changing the margin values, only used by tabdocument */ - void setMarginPreset(int p); - int getMarginPreset(); - - /*! \brief Top Bleed - \retval double bleed size */ - double topBleed() const; - /*! \brief Bottom Bleed - \retval double bleed size */ - double bottomBleed() const; - /*! \brief Left Bleed - \retval double bleed size */ - double leftBleed() const; - /*! \brief Right Bleed - \retval double bleed size */ - double rightBleed() const; - - /*! \brief set new bleed values for the dialog - \param b MarginStruct - */ - void setNewBleeds(MarginStruct& b); - - /*! \brief Return marginsForAllPages property - \retval bool true to apply for all pages */ - bool getMarginsForAllPages() const; - bool getMarginsForAllMasterPages() const; - -private: - /*! Tabs */ - QWidget *marginPage { nullptr }; - QWidget* bleedPage { nullptr }; - /*! Spinboxes */ - ScrSpinBox* topR { nullptr }; - ScrSpinBox* bottomR { nullptr }; - ScrSpinBox* rightR { nullptr }; - ScrSpinBox* leftR { nullptr }; - ScrSpinBox* BleedBottom { nullptr }; - ScrSpinBox* BleedLeft { nullptr }; - ScrSpinBox* BleedRight { nullptr }; - ScrSpinBox* BleedTop { nullptr }; - PresetLayout* presetCombo { nullptr }; - /*! Labels */ - QLabel* lText { nullptr }; - QLabel* rText { nullptr }; - QLabel* tText { nullptr }; - QLabel* bText { nullptr }; - QLabel* presetLabel { nullptr }; - QLabel* marginsForPages { nullptr }; - QLabel* BleedTxt1 { nullptr }; - QLabel* BleedTxt2 { nullptr }; - QLabel* BleedTxt3 { nullptr }; - QLabel* BleedTxt4 { nullptr }; - QCheckBox* marginsForAllPages { nullptr }; - QCheckBox* marginsForAllMasterPages { nullptr }; - QPushButton* usePrinterMarginsButton { nullptr }; - LinkButton* linkBleeds { nullptr }; - LinkButton* linkMargins { nullptr }; - - /*! \brief Margin values converted by unitRatio */ - MarginStruct marginData; - - /*! \brief Internally used page width */ - double m_pageWidth { 0.0 }; - /*! \brief Internally used page height */ - double m_pageHeight { 0.0 }; - -public slots: - /*! \brief Recompute the values after spinbox change */ - void setTop(); - void setBottom(); - void setLeft(); - void setRight(); - /*! \brief Recompute margins in PresetLayout combobox and disable/enable widgets. */ - void setPreset(); - void slotLinkBleeds(); - void slotLinkMargins(); - void changeBleeds(); - -protected slots: - virtual void setMarginsToPrinterMargins(); - -protected: - void updateMarginSpinValues(); - - QGridLayout* GroupLayout { nullptr }; - QHBoxLayout* marginsForPagesLayout { nullptr }; - QGridLayout* BleedGroupLayout { nullptr }; - - QString m_pageSize; - int m_unitIndex { 0 }; - double m_unitRatio { 1.0 }; - //! \brief if the outer facing palette points to the facing pages item - bool m_facingPages { false }; - bool m_useBleeds { false }; - int m_pageType { 0 }; - MarginStruct m_savedMargins; - int m_savedPresetItem { PresetLayout::none }; -}; - -#endif Property changes on: scribus/ui/marginwidget.h ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Author Date Id Revision \ No newline at end of property Index: scribus/ui/newdocdialog.cpp =================================================================== --- scribus/ui/newdocdialog.cpp (Revision 26196) +++ scribus/ui/newdocdialog.cpp (Arbeitskopie) @@ -29,6 +29,7 @@ #include <QStringList> #include <QTabWidget> #include <QToolTip> +#include <QVBoxLayout> #include "scconfig.h" @@ -36,7 +37,7 @@ #include "filedialogeventcatcher.h" #include "fileloader.h" #include "iconmanager.h" -#include "marginwidget.h" +#include "newmarginwidget.h" #include "pagesize.h" #include "pagestructs.h" #include "prefsfile.h" @@ -43,60 +44,15 @@ #include "prefsmanager.h" #include "scrspinbox.h" #include "units.h" -#include "ui/delegates/sclistitemdelegate.h" +#include "ui/widgets/pagelayoutswidget.h" -PageLayoutsWidget::PageLayoutsWidget(QWidget* parent) : - QListWidget(parent) -{ - setDragEnabled(false); - setViewMode(QListView::IconMode); - setFlow(QListView::LeftToRight); - setSortingEnabled(false); - setWrapping(false); - setWordWrap(true); - setAcceptDrops(false); - setDropIndicatorShown(false); - setDragDropMode(QAbstractItemView::NoDragDrop); - setResizeMode(QListView::Adjust); - setSelectionMode(QAbstractItemView::SingleSelection); - setFocusPolicy(Qt::NoFocus); - setIconSize(QSize(32, 32)); - clear(); - setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); - setGridSize(QSize(96, 96)); - setItemDelegate(new ScListItemDelegate(QListWidget::IconMode, QSize(32,32))); -} -void PageLayoutsWidget::arrangeIcons() -{ - int startY = 5; - int startX = 5; - int maxSizeY = 0; - - setResizeMode(QListView::Fixed); - - for (int i = 0; i < count(); ++i) - { - QListWidgetItem* itemWidget = item(i); - QRect itemRect = visualItemRect(itemWidget); - setPositionForIndex(QPoint(startX, startY), indexFromItem(itemWidget)); - startX += itemRect.width() + 5; - maxSizeY = qMax(maxSizeY, itemRect.height()); - } - - maxX = startX; - maxY = maxSizeY + 10; -} - -QSize PageLayoutsWidget::minimumSizeHint() const -{ - return QSize(maxX, maxY); -} - NewDocDialog::NewDocDialog(QWidget* parent, const QStringList& recentDocs, bool startUp, const QString& lang) : QDialog(parent), prefsManager(PrefsManager::instance()), m_onStartup(startUp) { + setupUi(this); + setObjectName(QString::fromLocal8Bit("NewDocumentWindow")); setModal(true); @@ -107,54 +63,27 @@ setWindowTitle( tr( "New Document" ) ); setWindowIcon(IconManager::instance().loadIcon("AppIcon.png")); - if (startUp) - setContentsMargins(0, 0, 0, 0); - else - setContentsMargins(9, 9, 9, 9); - TabbedNewDocLayout = new QVBoxLayout( this ); - if (startUp) - TabbedNewDocLayout->setContentsMargins(9, 9, 9, 9); - else - TabbedNewDocLayout->setContentsMargins(0, 0, 0, 0); - TabbedNewDocLayout->setSpacing(6); + createNewDocPage(); if (startUp) { - tabWidget = new QTabWidget( this ); - tabWidget->addTab(newDocFrame, tr("&New Document")); - createNewFromTempPage(); nftGui->setupSettings(lang); - tabWidget->addTab(newFromTempFrame, tr("New &from Template")); createOpenDocPage(); - tabWidget->addTab(openDocFrame, tr("Open &Existing Document")); recentDocList = recentDocs; - createRecentDocPage(); - tabWidget->addTab(recentDocFrame, tr("Open Recent &Document")); - TabbedNewDocLayout->addWidget(tabWidget); + createRecentDocPage(); + startUpDialog->setChecked(!prefsManager.appPrefs.uiPrefs.showStartupDialog); } else - TabbedNewDocLayout->addWidget(newDocFrame); - - Layout1 = new QHBoxLayout; - Layout1->setContentsMargins(0, 0, 0, 0); - Layout1->setSpacing(6); - if (startUp) { - startUpDialog = new QCheckBox( tr( "Do not show this dialog again" ), this ); - startUpDialog->setChecked(!prefsManager.appPrefs.uiPrefs.showStartupDialog); - Layout1->addWidget( startUpDialog ); + tabWidget->removeTab(3); + tabWidget->removeTab(2); + tabWidget->removeTab(1); } - QSpacerItem* spacer = new QSpacerItem( 2, 2, QSizePolicy::Expanding, QSizePolicy::Minimum ); - Layout1->addItem( spacer ); - buttonBox = new QDialogButtonBox(); - Layout1->addWidget(buttonBox); - okButton = new QPushButton( CommonStrings::tr_OK, this ); - okButton->setDefault( true ); - buttonBox->addButton(okButton, QDialogButtonBox::AcceptRole); - cancelButton = new QPushButton( CommonStrings::tr_Cancel, this ); - cancelButton->setAutoDefault( false ); - buttonBox->addButton(cancelButton, QDialogButtonBox::RejectRole); - TabbedNewDocLayout->addLayout( Layout1 ); + + + tabWidget->setCurrentIndex(0); + startUpDialog->setVisible(startUp); + //tooltips pageSizeComboBox->setToolTip( tr( "Document page size, either a standard size or a custom size" ) ); pageOrientationComboBox->setToolTip( tr( "Orientation of the document's pages" ) ); @@ -189,16 +118,6 @@ void NewDocDialog::createNewDocPage() { - newDocFrame = new QFrame(this); - - pageSizeGroupBox = new QGroupBox(newDocFrame ); - pageSizeGroupBox->setTitle( tr( "Document Layout" ) ); - pageSizeGroupBoxLayout = new QGridLayout( pageSizeGroupBox ); - pageSizeGroupBoxLayout->setContentsMargins(9, 9, 9, 9); - pageSizeGroupBoxLayout->setSpacing(6); - pageSizeGroupBoxLayout->setAlignment( Qt::AlignTop ); - - layoutsView = new PageLayoutsWidget( pageSizeGroupBox ); layoutsView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); for (int i = 0; i < prefsManager.appPrefs.pageSets.count(); ++i) { @@ -214,66 +133,62 @@ ic = new QListWidgetItem( IconManager::instance().loadIcon("32/page-doublesided.png"), psname, layoutsView ); ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); } - else if (i == 2 && prefsManager.appPrefs.docSetupPrefs.pagePositioning == 2) - { - ic = new QListWidgetItem( IconManager::instance().loadIcon("32/page-3fold.png"), psname, layoutsView ); - ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - } - else if (i == 3 && prefsManager.appPrefs.docSetupPrefs.pagePositioning == 3) - { - ic = new QListWidgetItem( IconManager::instance().loadIcon("32/page-4fold.png"), psname, layoutsView ); - ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - } + // else if (i == 2 && prefsManager.appPrefs.docSetupPrefs.pagePositioning == 2) + // { + // ic = new QListWidgetItem( IconManager::instance().loadIcon("32/page-3fold.png"), psname, layoutsView ); + // ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + // } + // else if (i == 3 && prefsManager.appPrefs.docSetupPrefs.pagePositioning == 3) + // { + // ic = new QListWidgetItem( IconManager::instance().loadIcon("32/page-4fold.png"), psname, layoutsView ); + // ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + // } } layoutsView->arrangeIcons(); - pageSizeGroupBoxLayout->addWidget( layoutsView, 0, 0, 5, 1 ); - layoutsView->arrangeIcons(); - TextLabel1 = new QLabel( tr( "&Size:" ), pageSizeGroupBox ); - pageSizeGroupBoxLayout->addWidget( TextLabel1, 0, 1 ); PageSize ps(prefsManager.appPrefs.docSetupPrefs.pageSize); - pageSizeComboBox = new QComboBox( pageSizeGroupBox ); + pageSizeComboBox->addItems(ps.activeSizeTRList()); pageSizeComboBox->addItem( CommonStrings::trCustomPageSize ); pageSizeComboBox->setEditable(false); TextLabel1->setBuddy(pageSizeComboBox); - pageSizeGroupBoxLayout->addWidget(pageSizeComboBox, 0, 2 ); - TextLabel2 = new QLabel( tr( "Orie&ntation:" ), pageSizeGroupBox ); - pageSizeGroupBoxLayout->addWidget( TextLabel2, 1, 1 ); - pageOrientationComboBox = new QComboBox( pageSizeGroupBox ); + pageOrientationComboBox->addItem( tr( "Portrait" ) ); pageOrientationComboBox->addItem( tr( "Landscape" ) ); pageOrientationComboBox->setEditable(false); pageOrientationComboBox->setCurrentIndex(prefsManager.appPrefs.docSetupPrefs.pageOrientation); TextLabel2->setBuddy(pageOrientationComboBox); - pageSizeGroupBoxLayout->addWidget( pageOrientationComboBox, 1, 2 ); - TextLabel1_2 = new QLabel( tr( "&Width:" ), pageSizeGroupBox ); - pageSizeGroupBoxLayout->addWidget(TextLabel1_2, 2, 1 ); - widthSpinBox = new ScrSpinBox(pts2value(1.0, m_unitIndex), 16777215, pageSizeGroupBox, m_unitIndex ); + widthSpinBox->setMinimum(pts2value(1.0, m_unitIndex)); + widthSpinBox->setMaximum(16777215); + widthSpinBox->setNewUnit(m_unitIndex); widthSpinBox->setSuffix(m_unitSuffix); TextLabel1_2->setBuddy(widthSpinBox); - pageSizeGroupBoxLayout->addWidget(widthSpinBox, 2, 2 ); - TextLabel2_2 = new QLabel( tr( "&Height:" ), pageSizeGroupBox ); - pageSizeGroupBoxLayout->addWidget(TextLabel2_2, 3, 1 ); - heightSpinBox = new ScrSpinBox( pts2value(1.0, m_unitIndex), 16777215, pageSizeGroupBox, m_unitIndex ); + + heightSpinBox->setMinimum(pts2value(1.0, m_unitIndex)); + heightSpinBox->setMaximum(16777215); + heightSpinBox->setNewUnit(m_unitIndex); heightSpinBox->setSuffix(m_unitSuffix); TextLabel2_2->setBuddy(heightSpinBox); - pageSizeGroupBoxLayout->addWidget(heightSpinBox, 3, 2 ); - unitOfMeasureLabel = new QLabel( tr( "&Default Unit:" ), pageSizeGroupBox ); - unitOfMeasureComboBox = new QComboBox( pageSizeGroupBox ); unitOfMeasureComboBox->addItems(unitGetTextUnitList()); unitOfMeasureComboBox->setCurrentIndex(m_unitIndex); unitOfMeasureComboBox->setEditable(false); unitOfMeasureLabel->setBuddy(unitOfMeasureComboBox); - pageSizeGroupBoxLayout->addWidget( unitOfMeasureLabel, 4, 1 ); - pageSizeGroupBoxLayout->addWidget( unitOfMeasureComboBox, 4, 2 ); MarginStruct marg(prefsManager.appPrefs.docSetupPrefs.margins); - marginGroup = new MarginWidget(newDocFrame, tr( "Margin Guides" ), &marg, m_unitIndex ); - marginGroup->setPageWidthHeight(prefsManager.appPrefs.docSetupPrefs.pageWidth, prefsManager.appPrefs.docSetupPrefs.pageHeight); + marginGroup->setup(marg, !(prefsManager.appPrefs.docSetupPrefs.pagePositioning == singlePage), m_unitIndex, NewMarginWidget::MarginWidgetFlags); + marginGroup->setPageHeight(prefsManager.appPrefs.docSetupPrefs.pageHeight); + marginGroup->setPageWidth(prefsManager.appPrefs.docSetupPrefs.pageWidth); marginGroup->setFacingPages(!(prefsManager.appPrefs.docSetupPrefs.pagePositioning == singlePage)); + + MarginStruct bleed; + bleed.resetToZero(); + + bleedGroup->setup(bleed, !(prefsManager.appPrefs.docSetupPrefs.pagePositioning == singlePage), m_unitIndex, NewMarginWidget::BleedWidgetFlags); + bleedGroup->setPageHeight(prefsManager.appPrefs.docSetupPrefs.pageHeight); + bleedGroup->setPageWidth(prefsManager.appPrefs.docSetupPrefs.pageWidth); + bleedGroup->setFacingPages(!(prefsManager.appPrefs.docSetupPrefs.pagePositioning == singlePage)); widthSpinBox->setValue(prefsManager.appPrefs.docSetupPrefs.pageWidth * m_unitRatio); heightSpinBox->setValue(prefsManager.appPrefs.docSetupPrefs.pageHeight * m_unitRatio); QStringList pageSizes = ps.activeSizeTRList(); @@ -283,31 +198,16 @@ else pageSizeComboBox->setCurrentIndex(pageSizeComboBox->count() - 1); marginGroup->setPageSize(pageSizeComboBox->currentText()); - marginGroup->setNewBleeds(prefsManager.appPrefs.docSetupPrefs.bleeds); marginGroup->setMarginPreset(prefsManager.appPrefs.docSetupPrefs.marginPreset); + bleedGroup->setPageSize(pageSizeComboBox->currentText()); + bleedGroup->setMarginPreset(prefsManager.appPrefs.docSetupPrefs.marginPreset); - optionsGroupBox = new QGroupBox( newDocFrame ); - optionsGroupBox->setTitle( tr( "Options" ) ); - optionsGroupBoxLayout = new QGridLayout( optionsGroupBox ); - optionsGroupBoxLayout->setSpacing(6); - optionsGroupBoxLayout->setContentsMargins(9, 9, 9, 9); - optionsGroupBoxLayout->setAlignment( Qt::AlignTop ); - pageCountLabel = new QLabel( tr( "N&umber of Pages:" ), optionsGroupBox ); - - pageCountSpinBox = new QSpinBox( optionsGroupBox ); pageCountSpinBox->setMaximum( 10000 ); pageCountSpinBox->setMinimum( 1 ); - pageCountLabel->setBuddy(pageCountSpinBox); - optionsGroupBoxLayout->addWidget(pageCountLabel, 0, 0, Qt::AlignLeft); - optionsGroupBoxLayout->addWidget(pageCountSpinBox, 0, 1); - layoutLabel1 = new QLabel( optionsGroupBox ); - layoutLabel1->setText( tr( "First Page is:" ) ); - firstPage = new QComboBox( optionsGroupBox ); + layoutLabel1->setText( tr( "First Page" ) ); firstPage->clear(); selectItem(prefsManager.appPrefs.docSetupPrefs.pagePositioning); - optionsGroupBoxLayout->addWidget(layoutLabel1, 1, 0, Qt::AlignLeft); - optionsGroupBoxLayout->addWidget(firstPage, 1, 1); firstPage->setCurrentIndex(prefsManager.appPrefs.pageSets[prefsManager.appPrefs.docSetupPrefs.pagePositioning].FirstPage); setDocLayout(prefsManager.appPrefs.docSetupPrefs.pagePositioning); @@ -314,25 +214,16 @@ setSize(prefsManager.appPrefs.docSetupPrefs.pageSize); setOrientation(prefsManager.appPrefs.docSetupPrefs.pageOrientation); - autoTextFrame = new QCheckBox( optionsGroupBox ); - autoTextFrame->setText( tr( "&Automatic Text Frames" ) ); - optionsGroupBoxLayout->addWidget(autoTextFrame, 2, 0, 1, 2, Qt::AlignLeft); + autoTextFrame->setTitle(tr( "&Automatic Text Frames" ) ); - TextLabel3 = new QLabel( tr( "Colu&mns:" ), optionsGroupBox ); - numberOfCols = new QSpinBox( optionsGroupBox ); numberOfCols->setButtonSymbols( QSpinBox::UpDownArrows ); numberOfCols->setMinimum( 1 ); numberOfCols->setValue( 1 ); - TextLabel3->setBuddy(numberOfCols); - optionsGroupBoxLayout->addWidget(TextLabel3, 3, 0, Qt::AlignLeft); - optionsGroupBoxLayout->addWidget(numberOfCols, 3, 1); - TextLabel4 = new QLabel( tr( "&Gap:" ), optionsGroupBox ); - Distance = new ScrSpinBox( 0, 1000, optionsGroupBox, m_unitIndex ); + Distance->setMinimum(0); + Distance->setMaximum(1000); + Distance->setNewUnit(m_unitIndex); Distance->setValue(11 * m_unitRatio); - TextLabel4->setBuddy(Distance); - optionsGroupBoxLayout->addWidget(TextLabel4, 4, 0, Qt::AlignLeft); - optionsGroupBoxLayout->addWidget(Distance, 4, 1); firstPage->setMinimumWidth(Distance->width()); @@ -340,31 +231,12 @@ TextLabel4->setEnabled(false); Distance->setEnabled(false); numberOfCols->setEnabled(false); - startDocSetup = new QCheckBox( optionsGroupBox ); + startDocSetup->setText( tr( "Show Document Settings After Creation" ) ); startDocSetup->setChecked(false); - optionsGroupBoxLayout->addWidget(startDocSetup, 5, 0, 1, 2, Qt::AlignLeft); - NewDocLayout = new QGridLayout( newDocFrame ); - if (m_onStartup) - NewDocLayout->setContentsMargins(9, 9, 9, 9); - else - NewDocLayout->setContentsMargins(0, 0, 0, 0); - NewDocLayout->setSpacing(6); - NewDocLayout->addWidget( marginGroup, 1, 0 ); - NewDocLayout->addWidget( optionsGroupBox, 1, 1 ); - NewDocLayout->addWidget( pageSizeGroupBox, 0, 0, 1, 2); } -void NewDocDialog::createNewFromTempPage() -{ - newFromTempFrame = new QFrame(this); - verticalLayout = new QVBoxLayout(newFromTempFrame); - verticalLayout->setContentsMargins(9, 9, 9, 9); - nftGui = new nftwidget(newFromTempFrame); - verticalLayout->addWidget(nftGui); -} - void NewDocDialog::createOpenDocPage() { PrefsContext* docContext = prefsManager.prefsFile->getContext("docdirs", false); @@ -376,10 +248,9 @@ docDir = docContext->get("docsopen", "."); QString formats(FileLoader::getLoadFilterString()); // formats.remove("PDF (*.pdf *.PDF);;"); - openDocFrame = new QFrame(this); - openDocLayout = new QVBoxLayout(openDocFrame); + QVBoxLayout *openDocLayout = new QVBoxLayout(tab_3); openDocLayout->setContentsMargins(0, 0, 0, 0); - openDocLayout->setSpacing(6); + openDocLayout->setSpacing(4); m_selectedFile = ""; // With Qt 5.15 we have to be in careful so that new document dialog doesn't display too large on startup. @@ -386,7 +257,7 @@ // To avoid this we have to use QFileDialog(QWidget *parent, Qt::WindowFlags flags) constructor, then // set the QFileDialog::DontUseNativeDialog option as early as possible, and nonetheless set again // the Qt::Widget window flag before adding the widget to layout. - fileDialog = new QFileDialog(openDocFrame, Qt::Widget); + fileDialog = new QFileDialog(tab_3, Qt::Widget); fileDialog->setOption(QFileDialog::DontUseNativeDialog); fileDialog->setWindowTitle(tr("Open")); fileDialog->setDirectory(docDir); @@ -404,6 +275,7 @@ fileDialog->setWindowFlags(Qt::Widget); openDocLayout->addWidget(fileDialog); + FileDialogEventCatcher* keyCatcher = new FileDialogEventCatcher(this); QList<QListView *> listViews = fileDialog->findChildren<QListView *>(); for (auto listView : std::as_const(listViews)) @@ -426,12 +298,6 @@ void NewDocDialog::createRecentDocPage() { - recentDocFrame = new QFrame(this); - recentDocLayout = new QVBoxLayout(recentDocFrame); - recentDocLayout->setContentsMargins(9, 9, 9, 9); - recentDocLayout->setSpacing(6); - recentDocListBox = new QListWidget(recentDocFrame); - recentDocLayout->addWidget(recentDocListBox); int max = qMin(prefsManager.appPrefs.uiPrefs.recentDocCount, recentDocList.count()); for (int i = 0; i < max; ++i) recentDocListBox->addItem(QDir::toNativeSeparators(recentDocList[i])); @@ -443,6 +309,7 @@ { m_pageWidth = widthSpinBox->value() / m_unitRatio; marginGroup->setPageWidth(m_pageWidth); + bleedGroup->setPageWidth(m_pageWidth); QString psText = pageSizeComboBox->currentText(); if (psText != CommonStrings::trCustomPageSize && psText != CommonStrings::customPageSize) pageSizeComboBox->setCurrentIndex(pageSizeComboBox->count() - 1); @@ -460,6 +327,7 @@ { m_pageHeight = heightSpinBox->value() / m_unitRatio; marginGroup->setPageHeight(m_pageHeight); + bleedGroup->setPageHeight(m_pageHeight); QString psText = pageSizeComboBox->currentText(); if (psText != CommonStrings::trCustomPageSize && psText != CommonStrings::customPageSize) pageSizeComboBox->setCurrentIndex(pageSizeComboBox->count() - 1); @@ -547,6 +415,9 @@ marginGroup->setNewUnit(m_unitIndex); marginGroup->setPageHeight(m_pageHeight); marginGroup->setPageWidth(m_pageWidth); + bleedGroup->setNewUnit(m_unitIndex); + bleedGroup->setPageHeight(m_pageHeight); + bleedGroup->setPageWidth(m_pageWidth); connect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double))); connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double))); } @@ -555,10 +426,10 @@ { m_pageWidth = widthSpinBox->value() / m_unitRatio; m_pageHeight = heightSpinBox->value() / m_unitRatio; - m_bleedBottom = marginGroup->bottomBleed(); - m_bleedTop = marginGroup->topBleed(); - m_bleedLeft = marginGroup->leftBleed(); - m_bleedRight = marginGroup->rightBleed(); + m_bleedBottom = bleedGroup->margins().bottom(); + m_bleedTop = bleedGroup->margins().top(); + m_bleedLeft = bleedGroup->margins().left(); + m_bleedRight = bleedGroup->margins().right(); if (m_onStartup) { m_tabSelected = tabWidget->currentIndex(); @@ -622,6 +493,8 @@ // end of #869 marginGroup->setPageHeight(m_pageHeight); marginGroup->setPageWidth(m_pageWidth); + bleedGroup->setPageHeight(m_pageHeight); + bleedGroup->setPageWidth(m_pageWidth); connect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double))); connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double))); } @@ -636,6 +509,7 @@ setOrientation(pageOrientationComboBox->currentIndex()); } marginGroup->setPageSize(size); + bleedGroup->setPageSize(size); } void NewDocDialog::setSize(const QString& gr) @@ -668,6 +542,8 @@ heightSpinBox->setValue(m_pageHeight * m_unitRatio); marginGroup->setPageHeight(m_pageHeight); marginGroup->setPageWidth(m_pageWidth); + bleedGroup->setPageHeight(m_pageHeight); + bleedGroup->setPageWidth(m_pageWidth); connect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double))); connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double))); } @@ -675,6 +551,7 @@ void NewDocDialog::setDocLayout(int layout) { marginGroup->setFacingPages(layout != singlePage); + bleedGroup->setFacingPages(layout != singlePage); m_choosenLayout = layout; firstPage->setCurrentIndex(prefsManager.appPrefs.pageSets[m_choosenLayout].FirstPage); } @@ -698,7 +575,7 @@ setWindowTitle(tr("Open Recent Document")); else setWindowTitle(tr("New Document")); - okButton->setEnabled(tab!=2); + //okButton->setEnabled(tab!=2); } void NewDocDialog::locationDropped(const QString& fileUrl) @@ -750,5 +627,5 @@ void NewDocDialog::openFileDialogFileClicked(const QString& path) { - okButton->setEnabled(!path.isEmpty()); + //okButton->setEnabled(!path.isEmpty()); } Index: scribus/ui/newdocdialog.h =================================================================== --- scribus/ui/newdocdialog.h (Revision 26196) +++ scribus/ui/newdocdialog.h (Arbeitskopie) @@ -33,31 +33,19 @@ #include "ui/customfdialog.h" #include "ui/nftwidget.h" +#include "ui_newdocdialog.h" + class PrefsManager; -class MarginWidget; +class NewMarginWidget; class ScrSpinBox; class QFileDialog; -class SCRIBUS_API PageLayoutsWidget : public QListWidget +class SCRIBUS_API NewDocDialog : public QDialog, public Ui::newDocDialog { Q_OBJECT public: - PageLayoutsWidget(QWidget* parent); - ~PageLayoutsWidget() = default; - void arrangeIcons(); - QSize minimumSizeHint() const override; - int maxX {0}; - int maxY {0}; -}; - -class SCRIBUS_API NewDocDialog : public QDialog -{ - Q_OBJECT - -public: - //! \brief Indexes of the dialog's tabs. enum { NewDocumentTab = 0, @@ -70,48 +58,11 @@ ~NewDocDialog() = default; void createNewDocPage(); - void createNewFromTempPage(); void createOpenDocPage(); void createRecentDocPage(); void setSize(const QString& gr); - QTabWidget* tabWidget {nullptr}; - QFrame* newDocFrame {nullptr}; - PageLayoutsWidget* layoutsView {nullptr}; - QLabel* layoutLabel1 {nullptr}; - QComboBox* firstPage {nullptr}; - QGroupBox* pageSizeGroupBox {nullptr}; - MarginWidget* marginGroup {nullptr}; - QGroupBox* optionsGroupBox {nullptr}; - QLabel* TextLabel1 {nullptr}; - QLabel* TextLabel2 {nullptr}; - QLabel* TextLabel3 {nullptr}; - QLabel* TextLabel4 {nullptr}; - QLabel* TextLabel1_2 {nullptr}; - QLabel* TextLabel1_3 {nullptr}; - QLabel* pageCountLabel {nullptr}; - QLabel* TextLabel2_2 {nullptr}; - QLabel* unitOfMeasureLabel {nullptr}; - QComboBox* pageSizeComboBox {nullptr}; - QComboBox* pageOrientationComboBox {nullptr}; - QComboBox* unitOfMeasureComboBox {nullptr}; - QCheckBox* startUpDialog {nullptr}; - QCheckBox* autoTextFrame {nullptr}; - QCheckBox* startDocSetup {nullptr}; - ScrSpinBox* Distance {nullptr}; - QSpinBox* numberOfCols {nullptr}; - QSpinBox* pageCountSpinBox {nullptr}; - ScrSpinBox* widthSpinBox {nullptr}; - ScrSpinBox* heightSpinBox {nullptr}; - QFrame* openDocFrame {nullptr}; QFileDialog *fileDialog {nullptr}; - QFrame* newFromTempFrame {nullptr}; - nftwidget *nftGui {nullptr}; - QFrame* recentDocFrame {nullptr}; - QListWidget* recentDocListBox {nullptr}; - QDialogButtonBox* buttonBox {nullptr}; - QPushButton* okButton {nullptr}; - QPushButton* cancelButton {nullptr}; bool onStartup() const { return m_onStartup;} int tabSelected() const { return m_tabSelected;} @@ -157,14 +108,6 @@ void openFileDialogFileClicked(const QString &path); protected: - QVBoxLayout* TabbedNewDocLayout {nullptr}; - QHBoxLayout* Layout1 {nullptr}; - QGridLayout* NewDocLayout {nullptr}; - QGridLayout* pageSizeGroupBoxLayout {nullptr}; - QGridLayout* optionsGroupBoxLayout {nullptr}; - QVBoxLayout* openDocLayout {nullptr}; - QVBoxLayout* recentDocLayout {nullptr}; - QVBoxLayout *verticalLayout {nullptr}; PrefsManager& prefsManager; QStringList recentDocList; Index: scribus/ui/newdocdialog.ui =================================================================== --- scribus/ui/newdocdialog.ui (nicht existent) +++ scribus/ui/newdocdialog.ui (Arbeitskopie) @@ -0,0 +1,565 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>newDocDialog</class> + <widget class="QDialog" name="newDocDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>721</width> + <height>516</height> + </rect> + </property> + <property name="windowTitle"> + <string>Dialog</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QTabWidget" name="tabWidget"> + <property name="currentIndex"> + <number>0</number> + </property> + <property name="tabBarAutoHide"> + <bool>true</bool> + </property> + <widget class="QWidget" name="tab"> + <attribute name="title"> + <string>New Document</string> + </attribute> + <layout class="QGridLayout" name="gridLayout"> + <property name="leftMargin"> + <number>8</number> + </property> + <property name="topMargin"> + <number>8</number> + </property> + <property name="rightMargin"> + <number>8</number> + </property> + <property name="bottomMargin"> + <number>8</number> + </property> + <property name="spacing"> + <number>4</number> + </property> + <item row="2" column="1"> + <widget class="QGroupBox" name="groupBox_5"> + <property name="title"> + <string>Bleeds</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_5"> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="NewMarginWidget" name="bleedGroup" native="true"/> + </item> + </layout> + </widget> + </item> + <item row="0" column="0" colspan="2"> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>Document Layout</string> + </property> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="0" column="2"> + <widget class="QLabel" name="TextLabel1"> + <property name="text"> + <string>&Size:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="1" column="3"> + <widget class="QComboBox" name="pageOrientationComboBox"/> + </item> + <item row="2" column="3"> + <widget class="ScrSpinBox" name="widthSpinBox"/> + </item> + <item row="2" column="2"> + <widget class="QLabel" name="TextLabel1_2"> + <property name="text"> + <string>&Width:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="0" column="3"> + <widget class="QComboBox" name="pageSizeComboBox"/> + </item> + <item row="3" column="2"> + <widget class="QLabel" name="TextLabel2_2"> + <property name="text"> + <string>&Height:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QLabel" name="TextLabel2"> + <property name="text"> + <string>Orie&ntation:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="0" column="0" rowspan="5"> + <widget class="PageLayoutsWidget" name="layoutsView"/> + </item> + <item row="3" column="3"> + <widget class="ScrSpinBox" name="heightSpinBox"/> + </item> + <item row="4" column="3"> + <widget class="QComboBox" name="unitOfMeasureComboBox"/> + </item> + <item row="4" column="2"> + <widget class="QLabel" name="unitOfMeasureLabel"> + <property name="text"> + <string>&Default Unit:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="0" column="1"> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>16</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + <item row="1" column="1"> + <widget class="QGroupBox" name="autoTextFrame"> + <property name="title"> + <string>Automatic Text Frame</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>false</bool> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_7"> + <item> + <widget class="FormWidget" name="TextLabel3"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Columns</string> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_5"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QSpinBox" name="numberOfCols"/> + </item> + </layout> + </widget> + </item> + <item> + <widget class="FormWidget" name="TextLabel4"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Gap</string> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_6"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="ScrSpinBox" name="Distance"/> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + <item row="2" column="0"> + <widget class="QGroupBox" name="groupBox_4"> + <property name="title"> + <string>Margins</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <item> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="NewMarginWidget" name="marginGroup" native="true"/> + </item> + </layout> + </widget> + </item> + <item row="1" column="0"> + <widget class="QGroupBox" name="groupBox_2"> + <property name="title"> + <string>Pages</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="FormWidget" name="pageCountLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Number of Pages</string> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QSpinBox" name="pageCountSpinBox"/> + </item> + </layout> + </widget> + </item> + <item> + <widget class="FormWidget" name="layoutLabel1"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>First Page</string> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QComboBox" name="firstPage"/> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + <item row="3" column="0" colspan="2"> + <widget class="QCheckBox" name="startDocSetup"> + <property name="text"> + <string>Show Document Settings After Creation</string> + </property> + </widget> + </item> + <item row="4" column="0"> + <spacer name="verticalSpacer_3"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab_2"> + <attribute name="title"> + <string>New from Template</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <property name="spacing"> + <number>4</number> + </property> + <property name="leftMargin"> + <number>8</number> + </property> + <property name="topMargin"> + <number>8</number> + </property> + <property name="rightMargin"> + <number>8</number> + </property> + <property name="bottomMargin"> + <number>8</number> + </property> + <item> + <widget class="nftwidget" name="nftGui" native="true"/> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab_3"> + <attribute name="title"> + <string>Open Existing Document</string> + </attribute> + </widget> + <widget class="QWidget" name="tab_4"> + <attribute name="title"> + <string>Open Recent Document</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <property name="spacing"> + <number>4</number> + </property> + <property name="leftMargin"> + <number>8</number> + </property> + <property name="topMargin"> + <number>8</number> + </property> + <property name="rightMargin"> + <number>8</number> + </property> + <property name="bottomMargin"> + <number>8</number> + </property> + <item> + <widget class="QListWidget" name="recentDocListBox"/> + </item> + </layout> + </widget> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="leftMargin"> + <number>8</number> + </property> + <item> + <widget class="QCheckBox" name="startUpDialog"> + <property name="text"> + <string>Do not show this dialog again</string> + </property> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>FormWidget</class> + <extends>QWidget</extends> + <header>ui/widgets/form_widget.h</header> + <container>1</container> + </customwidget> + <customwidget> + <class>ScrSpinBox</class> + <extends>QDoubleSpinBox</extends> + <header>ui/scrspinbox.h</header> + </customwidget> + <customwidget> + <class>PageLayoutsWidget</class> + <extends>QListWidget</extends> + <header>ui/widgets/pagelayoutswidget.h</header> + </customwidget> + <customwidget> + <class>nftwidget</class> + <extends>QWidget</extends> + <header>ui/nftwidget.h</header> + <container>1</container> + </customwidget> + <customwidget> + <class>NewMarginWidget</class> + <extends>QWidget</extends> + <header>ui/newmarginwidget.h</header> + <container>1</container> + </customwidget> + </customwidgets> + <tabstops> + <tabstop>layoutsView</tabstop> + <tabstop>pageSizeComboBox</tabstop> + <tabstop>pageOrientationComboBox</tabstop> + <tabstop>widthSpinBox</tabstop> + <tabstop>heightSpinBox</tabstop> + <tabstop>unitOfMeasureComboBox</tabstop> + <tabstop>pageCountSpinBox</tabstop> + <tabstop>firstPage</tabstop> + <tabstop>autoTextFrame</tabstop> + <tabstop>numberOfCols</tabstop> + <tabstop>Distance</tabstop> + <tabstop>startDocSetup</tabstop> + <tabstop>startUpDialog</tabstop> + <tabstop>recentDocListBox</tabstop> + <tabstop>tabWidget</tabstop> + </tabstops> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>newDocDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>newDocDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> Index: scribus/ui/newmarginwidget.cpp =================================================================== --- scribus/ui/newmarginwidget.cpp (Revision 26196) +++ scribus/ui/newmarginwidget.cpp (Arbeitskopie) @@ -10,6 +10,8 @@ #include "units.h" #include "ui/marginpresetlayout.h" #include "ui/useprintermarginsdialog.h" +#include "iconmanager.h" +#include "scribusapp.h" NewMarginWidget::NewMarginWidget(QWidget* parent) : QWidget(parent) @@ -39,8 +41,8 @@ presetLayoutLabel->resize(0,0); presetLayoutComboBox->hide(); presetLayoutLabel->hide(); - gridLayout->removeWidget(presetLayoutComboBox); - gridLayout->removeWidget(presetLayoutLabel); + horizontalLayout->removeWidget(presetLayoutComboBox); + horizontalLayout->removeWidget(presetLayoutLabel); } if ((m_flags & ShowPrinterMargins) == 0) { @@ -47,14 +49,16 @@ printerMarginsPushButton->blockSignals(true); printerMarginsPushButton->resize(0,0); printerMarginsPushButton->hide(); - gridLayout->removeWidget(printerMarginsPushButton); + horizontalLayout->removeWidget(printerMarginsPushButton); } setFacingPages(!(layoutType == singlePage)); - gridLayout->invalidate(); +// gridLayout->invalidate(); languageChange(); + iconSetChange(); + connect(ScQApp, SIGNAL(iconSetChanged()), this, SLOT(iconSetChange())); connect(topMarginSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setTop())); connect(bottomMarginSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); connect(leftMarginSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); @@ -85,6 +89,16 @@ printerMarginsPushButton->setToolTip( "<qt>" + tr( "Import the margins for the selected page size from the available printers" ) + "</qt>"); } +void NewMarginWidget::iconSetChange() +{ + IconManager &iconManager = IconManager::instance(); + + topMarginLabel->setPixmap( iconManager.loadPixmap("border-top")); + bottomMarginLabel->setPixmap( iconManager.loadPixmap("border-bottom")); + leftMarginLabel->setPixmap( m_facingPages ? iconManager.loadPixmap("border-inside") : iconManager.loadPixmap("border-left")); + rightMarginLabel->setPixmap( m_facingPages ? iconManager.loadPixmap("border-outside") : iconManager.loadPixmap("border-right")); +} + void NewMarginWidget::setNewValues(const MarginStruct& margs) { m_marginData = m_savedMarginData = margs; @@ -324,8 +338,11 @@ { m_facingPages = facing; m_pageType = pageType; - leftMarginLabel->setText(facing ? tr( "&Inside:" ) : tr( "&Left:" )); - rightMarginLabel->setText(facing ? tr( "O&utside:" ) : tr( "&Right:" )); + + IconManager &iconManager = IconManager::instance(); + leftMarginLabel->setPixmap( m_facingPages ? iconManager.loadPixmap("border-inside") : iconManager.loadPixmap("border-left")); + rightMarginLabel->setPixmap( m_facingPages ? iconManager.loadPixmap("border-outside") : iconManager.loadPixmap("border-right")); + setPreset(); } Index: scribus/ui/newmarginwidget.h =================================================================== --- scribus/ui/newmarginwidget.h (Revision 26196) +++ scribus/ui/newmarginwidget.h (Arbeitskopie) @@ -41,10 +41,12 @@ 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 setTop(); void setBottom(); void setLeft(); Index: scribus/ui/newmarginwidgetbase.ui =================================================================== --- scribus/ui/newmarginwidgetbase.ui (Revision 26196) +++ scribus/ui/newmarginwidgetbase.ui (Arbeitskopie) @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>308</width> - <height>230</height> + <width>301</width> + <height>152</height> </rect> </property> <property name="sizePolicy"> @@ -16,45 +16,35 @@ <verstretch>0</verstretch> </sizepolicy> </property> - <layout class="QGridLayout" name="gridLayout_2"> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="spacing"> + <number>4</number> + </property> <property name="leftMargin"> - <number>0</number> + <number>8</number> </property> <property name="topMargin"> - <number>0</number> + <number>8</number> </property> <property name="rightMargin"> - <number>0</number> + <number>8</number> </property> <property name="bottomMargin"> - <number>0</number> + <number>8</number> </property> - <item row="0" column="0"> - <layout class="QGridLayout" name="gridLayout"> - <item row="4" column="0"> - <widget class="QLabel" name="bottomMarginLabel"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="presetLayoutLabel"> <property name="text"> - <string>Bottom:</string> + <string>Preset:</string> </property> - <property name="buddy"> - <cstring>bottomMarginSpinBox</cstring> - </property> </widget> </item> - <item row="1" column="0"> - <widget class="QLabel" name="leftMarginLabel"> - <property name="text"> - <string>Left:</string> - </property> - <property name="buddy"> - <cstring>leftMarginSpinBox</cstring> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="ScrSpinBox" name="bottomMarginSpinBox"> + <item> + <widget class="PresetLayout" name="presetLayoutComboBox"> <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> @@ -61,108 +51,286 @@ </property> </widget> </item> - <item row="2" column="0"> - <widget class="QLabel" name="rightMarginLabel"> + <item> + <widget class="QPushButton" name="printerMarginsPushButton"> <property name="text"> - <string>Right:</string> + <string>Printer Margins...</string> </property> - <property name="buddy"> - <cstring>rightMarginSpinBox</cstring> - </property> </widget> </item> - <item row="0" column="0"> - <widget class="QLabel" name="presetLayoutLabel"> - <property name="text"> - <string>Preset Layouts:</string> + <item> + <spacer name="horizontalSpacer_5"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> </property> - </widget> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> </item> - <item row="3" column="0"> - <widget class="QLabel" name="topMarginLabel"> - <property name="text"> - <string>Top:</string> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> </property> - <property name="buddy"> - <cstring>topMarginSpinBox</cstring> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> </property> - </widget> + </spacer> </item> - <item row="1" column="1"> - <widget class="ScrSpinBox" name="leftMarginSpinBox"> + <item> + <widget class="FormWidget" name="topMarginLabel"> <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> + <property name="label" stdset="0"> + <string/> + </property> + <property name="direction"> + <enum>FormWidget::Left</enum> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="ScrSpinBox" name="topMarginSpinBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> </widget> </item> - <item row="2" column="1"> - <widget class="ScrSpinBox" name="rightMarginSpinBox"> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <item> + <widget class="FormWidget" name="leftMarginLabel"> <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> + <property name="label" stdset="0"> + <string/> + </property> + <property name="direction"> + <enum>FormWidget::Left</enum> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_5"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="ScrSpinBox" name="leftMarginSpinBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> </widget> </item> - <item row="3" column="1"> - <widget class="ScrSpinBox" name="topMarginSpinBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <item> + <widget class="LinkButton" name="marginLinkButton"> + <property name="text"> + <string/> </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonIconOnly</enum> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> </widget> </item> - <item row="0" column="1"> - <widget class="PresetLayout" name="presetLayoutComboBox"> + <item> + <widget class="FormWidget" name="rightMarginLabel"> <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> + <property name="label" stdset="0"> + <string/> + </property> + <property name="direction"> + <enum>FormWidget::Right</enum> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_6"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="ScrSpinBox" name="rightMarginSpinBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> </widget> </item> - <item row="5" column="1"> - <widget class="QPushButton" name="printerMarginsPushButton"> - <property name="text"> - <string>Printer Margins...</string> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_7"> + <item> + <spacer name="horizontalSpacer_4"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> </property> - </widget> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> </item> - <item row="1" column="2" rowspan="4"> - <widget class="LinkButton" name="marginLinkButton"> + <item> + <widget class="FormWidget" name="bottomMarginLabel"> <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="minimumSize"> - <size> - <width>15</width> - <height>0</height> - </size> - </property> - <property name="text"> + <property name="label" stdset="0"> <string/> </property> - <property name="checkable"> - <bool>true</bool> + <property name="direction"> + <enum>FormWidget::Left</enum> </property> - <property name="toolButtonStyle"> - <enum>Qt::ToolButtonIconOnly</enum> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> </property> - <property name="autoRaise"> - <bool>true</bool> - </property> + <layout class="QHBoxLayout" name="horizontalLayout_8"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="ScrSpinBox" name="bottomMarginSpinBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> </widget> </item> + <item> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> </layout> </item> </layout> @@ -169,6 +337,12 @@ </widget> <customwidgets> <customwidget> + <class>FormWidget</class> + <extends>QWidget</extends> + <header>ui/widgets/form_widget.h</header> + <container>1</container> + </customwidget> + <customwidget> <class>ScrSpinBox</class> <extends>QDoubleSpinBox</extends> <header>ui/scrspinbox.h</header> @@ -186,12 +360,12 @@ </customwidgets> <tabstops> <tabstop>presetLayoutComboBox</tabstop> + <tabstop>printerMarginsPushButton</tabstop> + <tabstop>topMarginSpinBox</tabstop> <tabstop>leftMarginSpinBox</tabstop> + <tabstop>marginLinkButton</tabstop> <tabstop>rightMarginSpinBox</tabstop> - <tabstop>topMarginSpinBox</tabstop> <tabstop>bottomMarginSpinBox</tabstop> - <tabstop>marginLinkButton</tabstop> - <tabstop>printerMarginsPushButton</tabstop> </tabstops> <resources/> <connections/> Index: scribus/ui/pagepropertiesdialog.cpp =================================================================== --- scribus/ui/pagepropertiesdialog.cpp (Revision 26196) +++ scribus/ui/pagepropertiesdialog.cpp (Arbeitskopie) @@ -17,7 +17,7 @@ #include "commonstrings.h" #include "iconmanager.h" -#include "marginwidget.h" +#include "newmarginwidget.h" #include "pagepropertiesdialog.h" #include "pagesize.h" #include "pagestructs.h" @@ -112,10 +112,13 @@ } dialogLayout->addWidget( dsGroupBox7 ); - marginWidget = new MarginWidget(this, tr( "Margin Guides" ), &doc->currentPage()->initialMargins, doc->unitIndex(), false, false); - marginWidget->setPageWidthHeight(doc->currentPage()->width(), doc->currentPage()->height()); +// 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->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 ); @@ -320,22 +323,22 @@ double PagePropertiesDialog::top() const { - return marginWidget->top(); + return marginWidget->margins().top(); } double PagePropertiesDialog::bottom() const { - return marginWidget->bottom(); + return marginWidget->margins().bottom(); } double PagePropertiesDialog::left() const { - return marginWidget->left(); + return marginWidget->margins().left(); } double PagePropertiesDialog::right() const { - return marginWidget->right(); + return marginWidget->margins().right(); } QString PagePropertiesDialog::masterPage() const @@ -347,5 +350,5 @@ int PagePropertiesDialog::getMarginPreset() const { - return marginWidget->getMarginPreset(); + return marginWidget->marginPreset(); } Index: scribus/ui/pagepropertiesdialog.h =================================================================== --- scribus/ui/pagepropertiesdialog.h (Revision 26196) +++ scribus/ui/pagepropertiesdialog.h (Arbeitskopie) @@ -20,7 +20,7 @@ class QHBoxLayout; class QVBoxLayout; class ScrSpinBox; -class MarginWidget; +class NewMarginWidget; class ScribusDoc; /*! \brief A dialog to setup the existing document margins. @@ -90,7 +90,7 @@ void setPageHeight(double v); private: - MarginWidget* marginWidget { nullptr }; + NewMarginWidget* marginWidget { nullptr }; QGroupBox* dsGroupBox7 { nullptr }; QGroupBox* groupMaster { nullptr }; QLabel* masterPageLabel { nullptr }; Index: scribus/ui/widgets/form_widget.cpp =================================================================== --- scribus/ui/widgets/form_widget.cpp (Revision 26196) +++ scribus/ui/widgets/form_widget.cpp (Arbeitskopie) @@ -11,6 +11,7 @@ { QSizePolicy policy(QSizePolicy::Preferred, QSizePolicy::Minimum); m_font = this->font(); + m_devicePixelRatio = qApp->devicePixelRatio(); setSizePolicy(policy); calculateFrame(); @@ -43,7 +44,7 @@ int w, h; labelSize(w,h); - switch(m_position) + switch (m_position) { case Left: setContentsMargins(w, 0, 0, 0); @@ -67,7 +68,7 @@ m_shortcutId = 0; m_hasShortcut = false; - if(hasPixmap() || m_label.isEmpty() || m_labelVisibility == false) + if (hasPixmap() || m_label.isEmpty() || m_labelVisibility == false) return; if (!m_label.contains(QLatin1Char('&'))) @@ -89,7 +90,7 @@ { QWidget::paintEvent(e); - if(!labelVisibility()) return; + if (!labelVisibility()) return; QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing, true); @@ -103,18 +104,19 @@ painter.setPen(pen); painter.setFont(m_font); - QRect r = rect(); QPixmap pix = m_pixmap; - if(hasPixmap()) pix = pix.scaled(m_pixmapSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); + if (hasPixmap() && pix.size() != m_pixmapSize) + pix = pix.scaled(m_pixmapSize * m_devicePixelRatio, Qt::KeepAspectRatio, Qt::SmoothTransformation); + if (!isEnabled()) - pix = style->generatedIconPixmap(QIcon::Disabled, pix, &opt); + pix = style->generatedIconPixmap(QIcon::Disabled, pix, &opt); - switch(m_position){ + switch (m_position){ case Left: - if(hasPixmap()) + if (hasPixmap()) { r= QRect (0, (height() - m_pixmap.height()) / 2, m_pixmap.width(), m_pixmap.height()); style->drawItemPixmap(&painter, r, align, pix); @@ -125,7 +127,7 @@ break; case Right: - if(hasPixmap()) + if (hasPixmap()) { r= QRect (width() - m_pixmap.width(), (height() - m_pixmap.height()) / 2, m_pixmap.width(), m_pixmap.height()); style->drawItemPixmap(&painter, r, align, pix); @@ -135,7 +137,7 @@ break; case Top: - if(hasPixmap()) + if (hasPixmap()) { r= QRect ((width() - m_pixmap.width()) / 2, 0, m_pixmap.width(), m_pixmap.height()); style->drawItemPixmap(&painter, r, align, pix); @@ -145,7 +147,7 @@ break; case Bottom: - if(hasPixmap()) + if (hasPixmap()) { r= QRect ((width() - m_pixmap.width()) / 2, height() - m_pixmap.height(), m_pixmap.width(), m_pixmap.height()); style->drawItemPixmap(&painter, r, align, pix); @@ -177,29 +179,29 @@ QLayoutItem * li = this->layout()->itemAt(i); QWidget *child = li->widget(); - if(!child) + if (!child) continue; - if(child->hasFocus()) + if (child->hasFocus()) { focus = i; continue; } - if(child->focusPolicy() != Qt::NoFocus) + if (child->focusPolicy() != Qt::NoFocus) widgets.append(i); } // Get new focus ID - foreach( int i, widgets ) + foreach ( int i, widgets ) { - if( focus == -1 || i > focus) + if ( focus == -1 || i > focus) { newFocus = i; break; } - if(i == widgets.last()) + if (i == widgets.last()) { newFocus = widgets.first(); break; @@ -206,13 +208,13 @@ } } - if( newFocus < 0 || newFocus > this->layout()->count()) + if ( newFocus < 0 || newFocus > this->layout()->count()) return QWidget::event(e); // Set focus on new item QWidget * wdgFocus = this->layout()->itemAt(newFocus)->widget(); - if(wdgFocus) + if (wdgFocus) { wdgFocus->setFocus(Qt::ShortcutFocusReason); window()->setAttribute(Qt::WA_KeyboardFocusChange); @@ -239,15 +241,15 @@ w = 0; h = 0; - if(hasPixmap()) + if (hasPixmap()) { - w = m_pixmapSize.width() + m_space; - h = m_pixmapSize.height() + m_space; + w = m_pixmapSize.width() * m_devicePixelRatio + m_space; + h = m_pixmapSize.height() * m_devicePixelRatio + m_space; } else { - if((m_label.isEmpty() && m_preserveLabelSpace == false) || m_labelVisibility == false) + if ((m_label.isEmpty() && m_preserveLabelSpace == false) || m_labelVisibility == false) { w = 0; h = 0; @@ -265,7 +267,7 @@ { int index = label.indexOf(QLatin1String("&"), pos); - if(pos == index) + if (pos == index) label = label.replace(index, 1, ""); pos++; @@ -282,7 +284,7 @@ void FormWidget::setText(const QString &text) { - if(m_label != text) + if (m_label != text) { m_label = text; updateShortcut(); @@ -297,7 +299,7 @@ void FormWidget::setLabelVisibility(bool visible) { - if(m_labelVisibility != visible) + if (m_labelVisibility != visible) { m_labelVisibility = visible; updateShortcut(); Index: scribus/ui/widgets/form_widget.h =================================================================== --- scribus/ui/widgets/form_widget.h (Revision 26196) +++ scribus/ui/widgets/form_widget.h (Arbeitskopie) @@ -77,6 +77,7 @@ bool m_labelVisibility {true}; bool m_hasShortcut {false}; int m_shortcutId {0}; + qreal m_devicePixelRatio {1.0}; void calculateFrame(); void updateShortcut(); Index: scribus/ui/widgets/pagelayoutswidget.cpp =================================================================== --- scribus/ui/widgets/pagelayoutswidget.cpp (nicht existent) +++ scribus/ui/widgets/pagelayoutswidget.cpp (Arbeitskopie) @@ -0,0 +1,51 @@ +#include "pagelayoutswidget.h" + +#include "ui/delegates/sclistitemdelegate.h" + +PageLayoutsWidget::PageLayoutsWidget(QWidget* parent) : + QListWidget(parent) +{ + setDragEnabled(false); + setViewMode(QListView::IconMode); + setFlow(QListView::LeftToRight); + setSortingEnabled(false); + setWrapping(false); + setWordWrap(true); + setAcceptDrops(false); + setDropIndicatorShown(false); + setDragDropMode(QAbstractItemView::NoDragDrop); + setResizeMode(QListView::Adjust); + setSelectionMode(QAbstractItemView::SingleSelection); + setFocusPolicy(Qt::NoFocus); + setIconSize(QSize(32, 32)); + clear(); + setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); + setGridSize(QSize(96, 96)); + setItemDelegate(new ScListItemDelegate(QListWidget::IconMode, QSize(32,32))); +} + +void PageLayoutsWidget::arrangeIcons() +{ + int startY = 5; + int startX = 5; + int maxSizeY = 0; + + setResizeMode(QListView::Fixed); + + for (int i = 0; i < count(); ++i) + { + QListWidgetItem* itemWidget = item(i); + QRect itemRect = visualItemRect(itemWidget); + setPositionForIndex(QPoint(startX, startY), indexFromItem(itemWidget)); + startX += itemRect.width() + 5; + maxSizeY = qMax(maxSizeY, itemRect.height()); + } + + maxX = startX; + maxY = maxSizeY + 10; +} + +QSize PageLayoutsWidget::minimumSizeHint() const +{ + return QSize(maxX, maxY); +} Index: scribus/ui/widgets/pagelayoutswidget.h =================================================================== --- scribus/ui/widgets/pagelayoutswidget.h (nicht existent) +++ scribus/ui/widgets/pagelayoutswidget.h (Arbeitskopie) @@ -0,0 +1,27 @@ +/* +For general Scribus (>=1.3.2) copyright and licensing information please refer +to the COPYING file provided with the program. Following this notice may exist +a copyright and/or license notice that predates the release of Scribus 1.3.2 +for which a new license (GPL+exception) is in place. +*/ +#ifndef PAGELAYOUTSWIDGET_H +#define PAGELAYOUTSWIDGET_H + +#include <QListWidget> +#include "scribusapi.h" + +class SCRIBUS_API PageLayoutsWidget : public QListWidget +{ + Q_OBJECT + +public: + PageLayoutsWidget(QWidget* parent); + ~PageLayoutsWidget() = default; + void arrangeIcons(); + QSize minimumSizeHint() const override; + int maxX {0}; + int maxY {0}; +}; + + +#endif // PAGELAYOUTSWIDGET_H |
|
i'm not a fan of this patch. there is no clear focus on which are the important things that one will mostly will tweak on a per document basis. i have no specific improvements to suggest, but here are some ideas: - use small icons for single / double page and for portrait / landscape. - the list of page sizes should be more prominent, its width and height are (for most people) values that are only tweaked in exceptional cases. - the default unit is not important (and can easily be changed in the status bar, once the document is created) - automatic text frames and columns are not important - displaying both the margins and bleeds is a good idea, but, for me, the cross layout with the link in the middle is hard to convert into a page layout. (i think i prefer a "Top Bottom Inner Outer" tabular view - first page left / right could also be a small icon (plus label, of course!) - why not already retain the color space (cmyk, rgb) and intent (print, screen) that should be added in the future? don't get me wrong, the changes in the screenshot are not bad, but if the dialog gets improved, i would expect more of them : - ) anyway, having an .ui file is for sure a good thing, so if you don't want to do any further changes, it's ok to push this patch. |
|
Hi ale, thanks for you feedback. What do you think about the idea to swap the single/double page with page size? The list on the left could show a small rendered version of the page format and the dropdown on the right side just switch between single and double page. (we use this dropdown already on arrange pages palette) BTW: I also thought about a "preview" of your document settings (size, single/double page, margin and bleed) >>> displaying both the margins and bleeds is a good idea, but, for me, the cross layout with the link in the middle is hard to convert into a page layout. (i think i prefer a "Top Bottom Inner Outer" tabular view Ok, I thought it is a better idea to visualize it on the right sides. |
|
Just an idea |
|
I like "Just an idea" much better : - ) Some direct feedback: - I like the idea of the preview (it's not really necessary, but nice for fast checking if everything is somehow ok. - the TBLR widget looks much better like this (i guess that different contexts can profit from different widgets...) - I still think that unit should not be there (now that i think of it: the unit should be attached to the page size: by default A-sizes get mm, the imperial ones inches; one can tweak the binding in the preferences, at the same place where one picks the sizes to be shown; for specific documents, the unit is so easy to change in the status bar...) - you are missing the orientation (but i have an idea there). (edit: ok, i see now that you have a ⇄ between the width the height: clever, but probably a bit too "decent"...) - for custom sizes, currently there is an "empty" entry, but i'm fine with no entry being selected when the user has modified the width or height of the page here are a few ideas of mine, based on your latest screenshot: - the preview of the sizes should be scaled according to the max width and height of the displayed sizes. - no need to show the size below the page size name: it's also displayed on the right side - concerning the orientation, i see two possible solutions: - create two icons for each page size, one portrait, one landscape, or - when a page size is selected, show a small icon on top of the big button to turn it; the button icon should then also turn (for custom page sizes i don't really see a need for this setting... except if the value is stored in the exported pdf) the attached screenshot is not meant to be a solution, it just visualizes what i wrote above |
|
I made some changes based on your feedback. The new layout is more consistent to the other tabs. But maybe everything looks too equal now, what do you think? I'm not sure if the icon scale will work from A1 to A6 if there is a visual size change for each icon. I still prefer to fit the biggest side into the tile. BTW: Affinity Publisher 2 has also a nice layout. https://affinity.serif.com/en-us/learn/photo/desktop/quickstart/ Fun fact, before I saw this, I had a similar idea to focus mainly on the document preview. |
|
|
|
the 'new layout' dialog looks good. but there are some questions: - is the meaning of the small red page as clear as it is with 'first page' in current scribus versions? - is 'layout' the correct title? currently it's 'document layout', which allows at least to call the standard margins 'preset layouts'. (i'm not sure about the best terminology. but the whole 'layout' of a document is much more than just the binding and the margins…) and there is one inconsistency in the 'new document' preview. as the document is set to 'facing pages', the margins should be 'inside' and 'outside' instead of 'left' and 'right'. |
|
General impression: Having the most important options shown as lists instead of dropdowns is a win. And with the layout you're proposing, I can go from left to right then from top to bottom and do the most important choices in the "right" order. Size preview: by default Scribus has A3, A4, A5, A6 and US Letter... it's a very sane list for most (non imperial) users and it should work OK with the preview. But I agree that A0 to A6 will probably not work. My suggestion would be to have a "do not scale preview" option in a context menu over the icons. This could work in two ways: - disable the scaled size preview for all sizes, or - disable it only for the size under cursor (so one could disable the preview for A0 and A1 and still get a preview for the sizes they use most). An alternative could be to have big (A3+), medium (A4, letter) and small (A5, A6) icons. For "ISO people" having only the proportions does not really help much all paper sizes have only two different : - ) But if it's too complex it's ok to have it as you proposed. And I agree with utnik, that the red coloring for the first page is not optimal (red is danger in my eyes)... I still would push for a "1", but it's likely that it's not really a nice solution when it's so small... and I, right now, I don't see a good alternative. |
|
i have opened a ticket that you might or not want to integrate in this patch: In the "New document" dialog, give access to the full list of page sizes. https://bugs.scribus.net/view.php?id=17257 |
|
Thanks for the valuable feedback. Below, an updated version. I think the new UI allow us to show all available page sizes on program start up. We could solve the icon scale dilemma if we just show a list with available formats instead of tiles. BTW: I plan to reuse the "page scheme" and "first page" dropdown (or what ever it will be) on the "arrange page" palette too. |
|
looks good to me. thank you for your work! |
|
NIce! I just would replace "All" by "Preferred". No need to show all of them at once. |
|
This is the first work in progress implementation. The properties part on the right side took more space as expected. To keep the layout clean, I replaced the category list on the left with a simple combo box. There you can select the category of different page sizes. The "favorite" selection show all preferred sized from Scribus page size settings. If you can't wait to test it, you can get a copy here: https://codeberg.org/Scribus/scribus I will provide a patch file later when I have a stable and optimized implementation. |
|
Looks clean. - Size type in a drop down is more than OK (most of the time I want one of the favorites anyway...) - I'm not sure about the placement of the small portrait / landscape buttons (in my use of Scribus, it's an important step in this dialog and I should not miss it). - I still think that the unit does not belong in this dialog (but we probably need feedback from somebody using it to decide if it should stay or not) |
|
The New Document dialog is in the final stages (just needs more testing). I also created a new page selector widget that replaces the single combo boxes in all places where you can select a page size. The new selector shows all available page sizes grouped by category. All "active" page sizes from the Scribus settings are grouped in the "Favorites" category. Favorites are also available in the new page selector. The default page size in the settings can now be selected from all available page sizes. If this default size is not already selected in the "active" pages, it will automatically appear in the favorites. What do you think? |
|
A patch is available. There is a change in the page size names. The active page sizes stored in the Scribus Prefs file no longer work. There is no migration function yet. So you either have to delete the file or reset the active pages via the settings. newdocdialog_2024-08-23_01.patch (260,706 bytes)
Index: Scribus.pro =================================================================== --- Scribus.pro (Revision 26264) +++ Scribus.pro (Arbeitskopie) @@ -481,8 +481,7 @@ scribus/ui/linecombo.h \ scribus/ui/linkbutton.h \ scribus/ui/loremipsum.h \ - scribus/ui/marginpresetlayout.h \ - scribus/ui/marginwidget.h \ + scribus/ui/marginpresetlayout.h \ scribus/ui/mark2item.h \ scribus/ui/mark2mark.h \ scribus/ui/markanchor.h \ @@ -1083,6 +1082,7 @@ scribus/ui/measurementsbase.ui \ scribus/ui/multipleduplicate.ui \ scribus/ui/multiprogressdialog.ui \ + scribus/ui/newdocdialog.ui \ scribus/ui/newmarginwidgetbase.ui \ scribus/ui/nftdialog.ui \ scribus/ui/nftwidget.ui \ @@ -1627,8 +1627,7 @@ scribus/ui/linecombo.cpp \ scribus/ui/linkbutton.cpp \ scribus/ui/loremipsum.cpp \ - scribus/ui/marginpresetlayout.cpp \ - scribus/ui/marginwidget.cpp \ + scribus/ui/marginpresetlayout.cpp \ scribus/ui/mark2item.cpp \ scribus/ui/mark2mark.cpp \ scribus/ui/markanchor.cpp \ Index: resources/iconsets/1_7_0/16/page-orientation-horizontal.svg =================================================================== --- resources/iconsets/1_7_0/16/page-orientation-horizontal.svg (nicht existent) +++ resources/iconsets/1_7_0/16/page-orientation-horizontal.svg (Arbeitskopie) @@ -0,0 +1,3 @@ +<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><style>@import '../colors.css';</style> +<path fill-rule="evenodd" clip-rule="evenodd" d="M5.41421 4L2 7.41421V12H14V4H5.41421ZM1 7L5 3H14H15V4V12V13H14H2H1V12V7Z"/> +</svg> Index: resources/iconsets/1_7_0/16/page-orientation-vertical.svg =================================================================== --- resources/iconsets/1_7_0/16/page-orientation-vertical.svg (nicht existent) +++ resources/iconsets/1_7_0/16/page-orientation-vertical.svg (Arbeitskopie) @@ -0,0 +1,3 @@ +<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><style>@import '../colors.css';</style> +<path fill-rule="evenodd" clip-rule="evenodd" d="M7.41421 2L4 5.41421V14H12V2H7.41421ZM3 5L7 1H12H13V2V14V15H12H4H3V14V5Z"/> +</svg> Index: resources/iconsets/1_7_0/1_7_0.xml =================================================================== --- resources/iconsets/1_7_0/1_7_0.xml (Revision 26264) +++ resources/iconsets/1_7_0/1_7_0.xml (Arbeitskopie) @@ -387,6 +387,8 @@ <icon id="layer-move-up" file="16/object-level-up.svg" /> <icon id="page-first-left" file="16/page-first-left.svg" /> <icon id="page-first-right" file="16/page-first-right.svg" /> + <icon id="page-orientation-horizontal" file="16/page-orientation-horizontal.svg" /> + <icon id="page-orientation-vertical" file="16/page-orientation-vertical.svg" /> <!-- PDF Tools --> <icon id="16/insert-button.png" file="16/pdf-button.svg" /> Index: scribus/CMakeLists_Sources.txt =================================================================== --- scribus/CMakeLists_Sources.txt (Revision 26264) +++ scribus/CMakeLists_Sources.txt (Arbeitskopie) @@ -363,7 +363,6 @@ ui/marksmanager.cpp ui/markvariabletext.cpp ui/marginpresetlayout.cpp - ui/marginwidget.cpp ui/newmarginwidget.cpp ui/mergedoc.cpp ui/missing.cpp @@ -383,7 +382,6 @@ ui/outputpreview_ps.cpp ui/outputpreviewbase.cpp ui/pageitemattributes.cpp - ui/pagelayout.cpp ui/pagepalette.cpp ui/pagepalette_pages.cpp ui/pagepalette_masterpages.cpp @@ -560,6 +558,10 @@ ui/widgets/floatingwindow.cpp ui/widgets/form_widget.cpp ui/widgets/gradientlistbox.cpp + ui/widgets/pagelayout.cpp + ui/widgets/pagesizelist.cpp + ui/widgets/pagesizepreview.cpp + ui/widgets/pagesizeselector.cpp ui/widgets/popup_menu.cpp ui/widgets/section_container.cpp ui/widgets/stacked_container.cpp Index: scribus/designer/formwidget_plugin.cpp =================================================================== --- scribus/designer/formwidget_plugin.cpp (Revision 26264) +++ scribus/designer/formwidget_plugin.cpp (Arbeitskopie) @@ -92,30 +92,25 @@ <ui language="c++" displayname="Form Widget"> <widget class="FormWidget" name="formWidget"> <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> - <property name="font"> - <font> - <pointsize>8</pointsize> - </font> - </property> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - </layout> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + </layout> </widget> <customwidgets> <customwidget> Index: scribus/designer/sectioncontainer_plugin.cpp =================================================================== --- scribus/designer/sectioncontainer_plugin.cpp (Revision 26264) +++ scribus/designer/sectioncontainer_plugin.cpp (Arbeitskopie) @@ -100,9 +100,9 @@ return QLatin1String(R"( <ui language="c++" displayname="Section Container"> <widget class="SectionContainer" name="sectionContainer"> - <widget class="QWidget" name="page"> - <layout class="QVBoxLayout" name="verticalLayout"/> - </widget> + <widget class="QWidget" name="page"> + <layout class="QVBoxLayout" name="verticalLayout"/> + </widget> </widget> <customwidgets> <customwidget> Index: scribus/localemgr.cpp =================================================================== --- scribus/localemgr.cpp (Revision 26264) +++ scribus/localemgr.cpp (Arbeitskopie) @@ -32,6 +32,7 @@ #include "scribuscore.h" #include "localemgr.h" #include "scpaths.h" +#include "pagesize.h" LocaleManager& LocaleManager::instance() { @@ -60,13 +61,13 @@ //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", "A4" )); - m_localeTable.append(LocaleDef("en", "in", "Letter")); - m_localeTable.append(LocaleDef("en_AU", "mm", "A4" )); - m_localeTable.append(LocaleDef("en_GB", "mm", "A4" )); - m_localeTable.append(LocaleDef("en_US", "in", "Letter")); - m_localeTable.append(LocaleDef("fr", "mm", "A4" )); - m_localeTable.append(LocaleDef("fr_QC", "pica", "Letter")); + m_localeTable.append(LocaleDef("default","mm", QString::number(PageSizeInfo::IsoA) + "_A4" )); + m_localeTable.append(LocaleDef("en", "in", QString::number(PageSizeInfo::USStandard) + "_Letter")); + m_localeTable.append(LocaleDef("en_AU", "mm", QString::number(PageSizeInfo::IsoA) + "_A4" )); + m_localeTable.append(LocaleDef("en_GB", "mm", QString::number(PageSizeInfo::IsoA) + "_A4" )); + m_localeTable.append(LocaleDef("en_US", "in", QString::number(PageSizeInfo::USStandard) + "_Letter")); + m_localeTable.append(LocaleDef("fr", "mm", QString::number(PageSizeInfo::IsoA) + "_A4" )); + m_localeTable.append(LocaleDef("fr_QC", "pica", QString::number(PageSizeInfo::USStandard) + "_Letter")); } void LocaleManager::printSelectedForLocale(const QString& locale) @@ -104,8 +105,8 @@ //qDebug()<<"No definition for locale: "<<selectedLocale; //No, we don't translate these, they are internal use that don't get to the GUI if (m_sysLocale.measurementSystem()==0) - return "A4"; - return "Letter"; + return QString::number(PageSizeInfo::IsoA) + "_A4"; + return QString::number(PageSizeInfo::USStandard) + "_Letter"; // qFatal("Page Size not found in LocaleManager"); // return ""; } Index: scribus/pagesize.cpp =================================================================== --- scribus/pagesize.cpp (Revision 26264) +++ scribus/pagesize.cpp (Arbeitskopie) @@ -19,17 +19,12 @@ * * ***************************************************************************/ +#include "commonstrings.h" #include "pagesize.h" #include "prefsmanager.h" - #include <QStringList> +#include <QObject> -#include <cmath> -#include <iostream> - -#include "commonstrings.h" - - PageSize::PageSize(const QString& sizeName) { init(sizeName); @@ -68,6 +63,7 @@ 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. @@ -82,6 +78,7 @@ m_height = it.value().height; m_pageUnitIndex = it.value().pageUnitIndex; m_trPageSizeName = it.value().trSizeName; + m_category = it.value().category; valuesSet = true; } } @@ -95,334 +92,530 @@ m_pageUnitIndex = -1; m_pageSizeName = CommonStrings::customPageSize; m_trPageSizeName = CommonStrings::trCustomPageSize; + m_category = PageSizeInfo::Custom; } } -QStringList PageSize::sizeList() const +QStringList PageSize::defaultSizesList() const { - QStringList pageSizes; + return { + QString::number(PageSizeInfo::IsoA) + "_A3", + QString::number(PageSizeInfo::IsoA) + "_A4", + QString::number(PageSizeInfo::IsoA) + "_A5", + QString::number(PageSizeInfo::IsoA) + "_A6", + QString::number(PageSizeInfo::USStandard) + "_Letter" + //"A3", "A4", "A5", "A6", "Letter" + }; +} + +PageSizeCategoriesMap PageSize::categories() +{ + PageSizeCategoriesMap map; + for (auto it = m_pageSizeList.begin(); it != m_pageSizeList.end(); ++it) - pageSizes.append(it.key()); - return QStringList(pageSizes); + map.insert(it.value().category, categoryToString(it.value().category)); + + return map; } -QStringList PageSize::sizeTRList() const +PageSizeInfoMap PageSize::sizesByCategory(PageSizeInfo::Category category) { - QStringList pageSizes; + PageSizeInfoMap map; + for (auto it = m_pageSizeList.begin(); it != m_pageSizeList.end(); ++it) - pageSizes.append(it.value().trSizeName); - return QStringList(pageSizes); + { + if (it.value().category == category) + map.insert(it.value().sizeName, it.value()); + } + + return map; } -QStringList PageSize::activeSizeList() const +PageSizeInfoMap PageSize::activePageSizes() { - QStringList pageSizes = sizeList(); + PageSizeInfoMap map; if (PrefsManager::instance().appPrefs.activePageSizes.count() == 0) - return QStringList(pageSizes); - QStringList activePageSizes(PrefsManager::instance().appPrefs.activePageSizes); - QStringList activeSizes; - for (int i = 0; i < activePageSizes.size(); ++i) + return pageSizes(); + + QStringList activeList(PrefsManager::instance().appPrefs.activePageSizes); + + for (auto it = m_pageSizeList.begin(); it != m_pageSizeList.end(); ++it) { - if (pageSizes.contains(activePageSizes.at(i))) - activeSizes << activePageSizes.at(i); + if (activeList.contains(it.value().sizeName)) + map.insert(it.value().sizeName, it.value()); } - return QStringList(activeSizes); + + return map; } -QStringList PageSize::activeSizeTRList() const +void PageSize::addPageSize(const QString name, double width, double height, int unitIndex, PageSizeInfo::Category category) { - QStringList pageTRSizes = sizeTRList(); - QStringList pageSizes = sizeList(); - if (PrefsManager::instance().appPrefs.activePageSizes.count() == 0) - return QStringList(pageTRSizes); - QStringList activePageSizes(PrefsManager::instance().appPrefs.activePageSizes); - QStringList activeTRSizes; - for (int i = 0; i < activePageSizes.size(); ++i) + + struct PageSizeInfo info; + QString unit; + + switch (unitIndex) { - int j = pageSizes.indexOf(activePageSizes.at(i)); - if (j != -1) - { - activeTRSizes << pageTRSizes.at(j); - } + 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; } - return QStringList(activeTRSizes); + + info.pageUnitIndex = unitIndex; + info.sizeName = QString::number(category) + "_" + name; + info.trSizeName = QObject::tr( name.toStdString().c_str() ); + info.category = category; + info.sizeLabel = QString("%1 x %2 %3").arg(width).arg(height).arg(unit); + m_pageSizeList.insert(info.sizeName, info); + } -QStringList PageSize::untransPageSizeList(const QStringList &transList) +QString PageSize::categoryToString(PageSizeInfo::Category category) const { - QStringList pageTRSizes = sizeTRList(); - QStringList pageSizes = sizeList(); - QStringList untranslatedList; - for (int i = 0; i < transList.size(); ++i) + switch (category) { - int j = pageTRSizes.indexOf(transList.at(i)); - if (j != -1) - { - untranslatedList << pageSizes.at(j); - } + case PageSizeInfo::Favorite: + return QObject::tr("Favorite"); + case PageSizeInfo::Custom: + return CommonStrings::trCustomPageSize; + case PageSizeInfo::Book: + return QObject::tr("Book"); + case PageSizeInfo::BusinessCards: + return QObject::tr("Business Cards"); + case PageSizeInfo::Canadian: + return QObject::tr("Candian"); + 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::IsoA: + return QObject::tr("ISO A Series"); + case PageSizeInfo::IsoB: + return QObject::tr("ISO B Series"); + case PageSizeInfo::IsoC: + return QObject::tr("ISO C Series"); + case PageSizeInfo::IsoEnvelop: + return QObject::tr("ISO Envelop"); + case PageSizeInfo::Japanese: + return QObject::tr("Japanese"); + case PageSizeInfo::Newspaper: + return QObject::tr("Newspaper"); + 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 Standard"); + case PageSizeInfo::USLoose: + return QObject::tr("US Loose"); + case PageSizeInfo::USEnvelop: + return QObject::tr("US Envelop"); + default: + return "undefined"; + break; } - return QStringList(untranslatedList); } void PageSize::generateSizeList() { - /* - {"A5", "A6", "A7", "A8", "A9", "B0", "B1", "B2", "B3", - "B4", "B5", "B6", "B7", "B8", "B9", "B10", "C5E", "Comm10E", "DLE", QObject::tr("Executive"), - QObject::tr("Folio"), QObject::tr("Ledger"), QObject::tr("Legal"), QObject::tr("Letter"), QObject::tr("Tabloid") - }; - */ + // https://papersizes.io/books/ + // Books + PageSizeInfo::Category catBooks = PageSizeInfo::Book; + addPageSize("Folio", 12.0, 19.0, SC_IN, catBooks); + addPageSize("Quarto", 9.5, 12.0, SC_IN, catBooks); + addPageSize("Imperial Octavo", 8.25, 11.5, SC_IN, catBooks); + addPageSize("Super Octavo", 7.0, 11.0, SC_IN, catBooks); + addPageSize("Royal Octavo", 6.5, 10.0, SC_IN, catBooks); + addPageSize("Medium Octavo", 6.5, 9.25, SC_IN, catBooks); + addPageSize("Octavo", 6.0, 9.0, SC_IN, catBooks); + addPageSize("Crown Octavo", 5.4, 8.0, SC_IN, catBooks); + addPageSize("12mo", 5.0, 7.4, SC_IN, catBooks); + addPageSize("16mo", 4.0, 6.75, SC_IN, catBooks); + addPageSize("18mo", 4.0, 6.5, SC_IN, catBooks); + addPageSize("32mo", 3.5, 5.5, SC_IN, catBooks); + addPageSize("48mo", 2.0, 3.0, SC_IN, catBooks); + addPageSize("A Format", 4.25, 7.0, SC_IN, catBooks); + addPageSize("B Format", 5.1, 7.75, SC_IN, catBooks); + addPageSize("C Format", 5.25, 8.5, SC_IN, catBooks); -// double width, height, tmp; - int format; - QString name; - struct PageSizeInfo info; - /* A series */ -// width = floor(1000.0 / sqrt(sqrt(2.0)) + 0.5); -// height = floor(sqrt(sqrt(2.0))*1000.0 + 0.5); - //4A0 - info.width = mm2pts(1682.0); - info.height = mm2pts(2378.0); - info.pageUnitIndex = SC_MM; - info.trSizeName = QObject::tr("4A0"); - m_pageSizeList.insert("4A0", info); - //2A0 - info.width = mm2pts(1189.0); - info.height = mm2pts(1682.0); - info.pageUnitIndex = SC_MM; - info.trSizeName = QObject::tr("2A0"); - m_pageSizeList.insert("2A0", info); - //Continue with rest of A series - // do not use the formula below, as it is correct in theory, - // but due to rounding errors it gives incorrect results. -/* for (format = 0; format <= 10; format++) { - info.width = mm2pts(width); - info.height = mm2pts(height); - info.pageUnitIndex = SC_MM; - name = QString("A%1").arg(format); - info.trSizeName = name; - pageSizeList.insert(name, info); - tmp = height; - height = width; - width = floor(tmp / 2.0); - } */ - // all of the following data is taken from the Ghostscript manual - // "Appendix: Paper sizes known to Ghostscript" - QList<double> Awidths; - QList<double> Aheights; - Awidths << 841.0 << 594.0 << 420.0 << 297.0 << 210.0 << 148.0 << 105.0 << 74.0 << 52.0 << 37.0 << 26.0; - Aheights << 1189.0 << 841.0 << 594.0 << 420.0 << 297.0 << 210.0 << 148.0 << 105.0 << 74.0 << 52.0 << 37.0; - for (format = 0; format < Awidths.count(); format++) - { - info.width = mm2pts(Awidths[format]); - info.height = mm2pts(Aheights[format]); - info.pageUnitIndex = SC_MM; - name = QString("A%1").arg(format); - info.trSizeName = name; - m_pageSizeList.insert(name, info); - } - - /* B series */ - Awidths.clear(); - Aheights.clear(); - Awidths << 1000.0 << 707.0 << 500.0 << 353.0 << 250.0 << 176.0 << 125.0 << 88.0 << 62.0 << 44.0 << 31.0; - Aheights << 1414.0 << 1000.0 << 707.0 << 500.0 << 353.0 << 250.0 << 176.0 << 125.0 << 88.0 << 62.0 << 44.0; - for (format = 0; format < Awidths.count(); format++) - { - info.width = mm2pts(Awidths[format]); - info.height = mm2pts(Aheights[format]); - info.pageUnitIndex = SC_MM; - name = QString("B%1").arg(format); - info.trSizeName = name; - m_pageSizeList.insert(name, info); - } - /* C series */ - Awidths.clear(); - Aheights.clear(); - Awidths << 917.0 << 648.0 << 458.0 << 324.0 << 229.0 << 162.0 << 114.0 << 81.0 << 57.0 << 40.0 << 28.0; - Aheights << 1297.0 << 917.0 << 648.0 << 458.0 << 324.0 << 229.0 << 162.0 << 114.0 << 81.0 << 57.0 << 40.0; - for (format = 0; format < Awidths.count(); format++) - { - info.width = mm2pts(Awidths[format]); - info.height = mm2pts(Aheights[format]); - info.pageUnitIndex = SC_MM; - name = QString("C%1").arg(format); - info.trSizeName = name; - m_pageSizeList.insert(name, info); - } -/* - width = 1000.0; - height = floor(sqrt(2.0)*1000.0 + 0.5); + // https://papersizes.io/business-card/ + // Business Cards + PageSizeInfo::Category catBusinessCards = PageSizeInfo::BusinessCards; + addPageSize("Europe", 55.0, 85.0, SC_MM, catBusinessCards); + addPageSize("ISO 7810 ID-1", 54.0, 85.6, SC_MM, catBusinessCards); + addPageSize("US/Canada", 2.0, 3.5, SC_IN, catBusinessCards); + addPageSize("China", 54.0, 90.0, SC_MM, catBusinessCards); + addPageSize("Scandinavia", 55.0, 90.0, SC_MM, catBusinessCards); + addPageSize("Japan", 55.0, 91.0, SC_MM, catBusinessCards); + addPageSize("Hungary", 50.0, 90.0, SC_MM, catBusinessCards); + addPageSize("Iran", 48.0, 85.0, SC_MM, catBusinessCards); + addPageSize("ISO 216", 52.0, 74.0, SC_MM, catBusinessCards); - for (format = 0; format <= 10; format++) { - info.width = mm2pts(width); - info.height = mm2pts(height); - info.pageUnitIndex = SC_MM; - name = QString("B%1").arg(format); - info.trSizeName = name; - pageSizeList.insert(name, info); + // https://papersizes.io/canadian/ + // Canadian + PageSizeInfo::Category catCanadian = PageSizeInfo::Canadian; + addPageSize("P1", 560.0, 860.0, SC_MM, catCanadian); + addPageSize("P2", 430.0, 560.0, SC_MM, catCanadian); + addPageSize("P3", 280.0, 430.0, SC_MM, catCanadian); + addPageSize("P4", 215.0, 280.0, SC_MM, catCanadian); + addPageSize("P5", 140.0, 215.0, SC_MM, catCanadian); + addPageSize("P6", 107.0, 140.0, SC_MM, catCanadian); - tmp = height; - height = width; - width = floor(tmp / 2.0); - } + // https://papersizes.io/chinese/ + // Chinese + PageSizeInfo::Category catChinese = PageSizeInfo::Chinese; + addPageSize("D0", 764.0, 1064.0, SC_MM, catChinese); + addPageSize("D1", 532.0, 760.0, SC_MM, catChinese); + addPageSize("D2", 380.0, 528.0, SC_MM, catChinese); + addPageSize("D3", 264.0, 375.0, SC_MM, catChinese); + addPageSize("D4", 188.0, 260.0, SC_MM, catChinese); + addPageSize("D5", 130.0, 184.0, SC_MM, catChinese); + addPageSize("D6", 92.0, 126.0, SC_MM, catChinese); + addPageSize("RD0", 787.0, 1092.0, SC_MM, catChinese); + addPageSize("RD1", 546.0, 787.0, SC_MM, catChinese); + addPageSize("RD2", 393.0, 546.0, SC_MM, catChinese); + addPageSize("RD3", 273.0, 393.0, SC_MM, catChinese); + addPageSize("RD4", 196.0, 273.0, SC_MM, catChinese); + addPageSize("RD5", 136.0, 196.0, SC_MM, catChinese); + addPageSize("RD6", 98.0, 136.0, SC_MM, catChinese); - // C series - width = floor(1000.0 / sqrt(sqrt(sqrt(2.0)))+0.5); - height = floor(sqrt(sqrt(sqrt(8.0)))*1000.0 + 0.5); + // https://papersizes.io/colombian/ + // Colombian + PageSizeInfo::Category catColombian = PageSizeInfo::Colombian; + addPageSize("Carta", 216.0, 279.0, SC_MM, catColombian); + addPageSize("Extra Tabloide", 304.0, 457.2, SC_MM, catColombian); + addPageSize("Oficio", 216.0, 330.0, SC_MM, catColombian); + addPageSize("Pliego", 700.0, 1000.0, SC_MM, catColombian); + addPageSize("1/2 Pliego", 500.0, 700.0, SC_MM, catColombian); + addPageSize("1/4 Pliego", 350.0, 500.0, SC_MM, catColombian); + addPageSize("1/8 Pliego", 250.0, 350.0, SC_MM, catColombian); - for (format = 0; format <= 10; format++) { - info.width = mm2pts(width); - info.height = mm2pts(height); - info.pageUnitIndex = SC_MM; - name = QString("C%1").arg(format); - info.trSizeName = name; - pageSizeList.insert(name, info); + // https://papersizes.io/french/ + // French + PageSizeInfo::Category catFrench = PageSizeInfo::French; + addPageSize("Cloche", 300.0, 400.0, SC_MM, catFrench); + addPageSize("Pot, écolier", 310.0, 400.0, SC_MM, catFrench); + addPageSize("Tellière", 340.0, 440.0, SC_MM, catFrench); + addPageSize("Couronne écriture", 360.0, 360.0, SC_MM, catFrench); + addPageSize("Couronne édition", 370.0, 470.0, SC_MM, catFrench); + addPageSize("Roberto", 390.0, 500.0, SC_MM, catFrench); + addPageSize("Écu", 400.0, 520.0, SC_MM, catFrench); + addPageSize("Coquille", 440.0, 560.0, SC_MM, catFrench); + addPageSize("Carré", 450.0, 560.0, SC_MM, catFrench); + addPageSize("Cavalier", 460.0, 620.0, SC_MM, catFrench); + addPageSize("Demi-raisin", 325.0, 500.0, SC_MM, catFrench); + addPageSize("Raisin", 500.0, 650.0, SC_MM, catFrench); + addPageSize("Double Raisin", 650.0, 1000.0, SC_MM, catFrench); + addPageSize("Jésus", 560.0, 760.0, SC_MM, catFrench); + addPageSize("Soleil", 600.0, 800.0, SC_MM, catFrench); + addPageSize("Colombier affiche", 600.0, 800.0, SC_MM, catFrench); + addPageSize("Colombier commercial", 630.0, 900.0, SC_MM, catFrench); + addPageSize("Petit Aigle", 700.0, 940.0, SC_MM, catFrench); + addPageSize("Grand Aigle", 750.0, 1050.0, SC_MM, catFrench); + addPageSize("Grand Monde", 900.0, 1260.0, SC_MM, catFrench); + addPageSize("Univers", 1000.0, 1130.0, SC_MM, catFrench); - tmp = height; - height = width; - width = floor(tmp / 2.0); - } -*/ - /* PA series */ - double tmp; - double width = 840; - double height = 1120; - for (format = 0; format <= 10; format++) - { - info.width = mm2pts(width); - info.height = mm2pts(height); - info.pageUnitIndex = SC_MM; - name = QString("PA%1").arg(format); - info.trSizeName = name; - m_pageSizeList.insert(name, info); - tmp = height; - height = width; - width = floor(tmp / 2.0); - } - - //Imperial - //http://en.wikipedia.org/wiki/Paper_sizes - double impWidths[]={8.0,8.0,8.5,8.0,8.5,11.0,7.25,15.5,15.0,16.5,17.5,18.0,20.0,23.0,23.5,35.0,5.5,8.5,11.0,17.0,22.0,34.0}; - double impHeights[]={10.0,13.0,11.0,10.5,14.0,17.0,10.5,19.25,20.0,21.0,22.5,23.0,25.0,28.0,35.0,45.0,8.5,11.0,17.0,22.0,34.0,44.0}; - QString impNames[]={"Quarto","Foolscap","Letter","Govt. Letter","Legal","Ledger","Executive","Post","Crown","Large Post","Demy","Medium","Royal","Elephant","Double Demy","Quad Demy","STMT","A","B","C","D","E"}; - QString impTrNames[]={QObject::tr("Quarto"), QObject::tr("Foolscap"), QObject::tr("Letter"), - QObject::tr("Govt. Letter"), QObject::tr("Legal"), QObject::tr("Ledger"), QObject::tr("Executive"), - QObject::tr("Post"), QObject::tr("Crown"), QObject::tr("Large Post"), QObject::tr("Demy"), - QObject::tr("Medium"), QObject::tr("Royal"), QObject::tr("Elephant"), QObject::tr("Double Demy"), - QObject::tr("Quad Demy"), QObject::tr("STMT"), QObject::tr("A"), QObject::tr("B"), QObject::tr("C"), - QObject::tr("D"), QObject::tr("E")}; - - size_t const num_mappings_widths = (sizeof impWidths)/(sizeof *impWidths); - - for (uint i = 0; i < num_mappings_widths; ++i) - { - info.width = in2pts(impWidths[i]); - info.height = in2pts(impHeights[i]); - info.pageUnitIndex = SC_IN; - info.trSizeName = impTrNames[i]; - m_pageSizeList.insert(impNames[i], info); - } - //Comm10E - info.width = in2pts(4.125); - info.height = in2pts(9.5); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("Comm10E"); - m_pageSizeList.insert("Comm10E", info); - //DLE - info.width = mm2pts(110); - info.height = mm2pts(220); - info.pageUnitIndex = SC_MM; - info.trSizeName = QObject::tr("DLE"); - m_pageSizeList.insert("DLE", info); - // additional page sizes used by Viva Designer - //Compact Disc - info.width = mm2pts(119.9); - info.height = mm2pts(120.7); - info.pageUnitIndex = SC_MM; - info.trSizeName = QObject::tr("Compact Disc"); - m_pageSizeList.insert("Compact Disc", info); - //Letter Half - info.width = mm2pts(139.7); - info.height = mm2pts(215.9); - info.pageUnitIndex = SC_MM; - info.trSizeName = QObject::tr("Letter Half"); - m_pageSizeList.insert("Letter Half", info); - //US Letter - info.width = mm2pts(215.9); - info.height = mm2pts(279.4); - info.pageUnitIndex = SC_MM; - info.trSizeName = QObject::tr("US Letter"); - m_pageSizeList.insert("US Letter", info); - //US Legal - info.width = mm2pts(215.9); - info.height = mm2pts(355.6); - info.pageUnitIndex = SC_MM; - info.trSizeName = QObject::tr("US Legal"); - m_pageSizeList.insert("US Legal", info); - //11x17 - info.width = in2pts(11); - info.height = in2pts(17); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("11x17"); - m_pageSizeList.insert("11x17", info); + // https://papersizes.io/german/ + // German + PageSizeInfo::Category catGerman = PageSizeInfo::German; + addPageSize("DIN D0", 771.0, 1090.0, SC_MM, catGerman); + addPageSize("DIN D1", 545.0, 771.0, SC_MM, catGerman); + addPageSize("DIN D2", 385.0, 545.0, SC_MM, catGerman); + addPageSize("DIN D3", 272.0, 385.0, SC_MM, catGerman); + addPageSize("DIN D4", 192.0, 272.0, SC_MM, catGerman); + addPageSize("DIN D5", 136.0, 192.0, SC_MM, catGerman); + addPageSize("DIN D6", 96.0, 136.0, SC_MM, catGerman); + addPageSize("DIN D7", 68.0, 96.0, SC_MM, catGerman); + addPageSize("DIN D8", 48.0, 68.0, SC_MM, catGerman); - // Arch A 9 × 12 - info.width = in2pts(9); - info.height = in2pts(12); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("9x12 (Arch A)"); - m_pageSizeList.insert("9x12 (Arch A)", info); - // Arch B 12 × 18 - info.width = in2pts(12); - info.height = in2pts(18); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("12x18 (Arch B)"); - m_pageSizeList.insert("12x18 (Arch B)", info); - // Arch C 18 × 24 - info.width = in2pts(18); - info.height = in2pts(24); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("18x24 (Arch C)"); - m_pageSizeList.insert("18x (Arch C)", info); - // Arch D 24 × 36 - info.width = in2pts(24); - info.height = in2pts(36); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("24x36 (Arch D)"); - m_pageSizeList.insert("24x36 (Arch D)", info); - // Arch E 36 × 48 - info.width = in2pts(36); - info.height = in2pts(48); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("36x48 (Arch E)"); - m_pageSizeList.insert("36x48 (Arch E)", info); - // Arch E1 30 × 42 - info.width = in2pts(30); - info.height = in2pts(42); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("30x42 (Arch E1)"); - m_pageSizeList.insert("30x42 (Arch E1)", info); - // Arch E2 26 × 38 - info.width = in2pts(26); - info.height = in2pts(38); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("26x38 (Arch E2)"); - m_pageSizeList.insert("26x38 (Arch E2)", info); - // Arch E3 27 × 39 - info.width = in2pts(27); - info.height = in2pts(39); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("27x39 (Arch E3)"); - m_pageSizeList.insert("27x39 (Arch E3)", info); + // https://papersizes.io/a/ + // ISO A series + PageSizeInfo::Category catIsoA = PageSizeInfo::IsoA; + addPageSize("A0", 841.0, 1189.0, SC_MM, catIsoA); + addPageSize("A1", 594.0, 841.0, SC_MM, catIsoA); + addPageSize("A2", 420.0, 594.0, SC_MM, catIsoA); + addPageSize("A3", 297.0, 420.0, SC_MM, catIsoA); + addPageSize("A4", 210.0, 297.0, SC_MM, catIsoA); + addPageSize("A5", 148.0, 210.0, SC_MM, catIsoA); + addPageSize("A6", 105.0, 148.0, SC_MM, catIsoA); + addPageSize("A7", 74.0, 105.0, SC_MM, catIsoA); + addPageSize("A8", 52.0, 74.0, SC_MM, catIsoA); + addPageSize("A9", 37.0, 52.0, SC_MM, catIsoA); + addPageSize("A10", 26.0, 37.0, SC_MM, catIsoA); + addPageSize("A11", 18.0, 26.0, SC_MM, catIsoA); + addPageSize("A12", 13.0, 18.0, SC_MM, catIsoA); + addPageSize("A13", 9.0, 13.0, SC_MM, catIsoA); + addPageSize("2A0", 1189.0, 1682.0, SC_MM, catIsoA); + addPageSize("4A0", 1682.0, 2378.0, SC_MM, catIsoA); + addPageSize("A0+", 914.0, 1292.0, SC_MM, catIsoA); + addPageSize("A1+", 609.0, 914.0, SC_MM, catIsoA); + addPageSize("A3+", 329.0, 483.0, SC_MM, catIsoA); - //Executive - //Folio - //Ledger - //Legal - //Letter - //Tabloid + + // https://papersizes.io/b/ + // ISO B series + PageSizeInfo::Category catIsoB = PageSizeInfo::IsoB; + addPageSize("B0", 1000.0, 1414.0, SC_MM, catIsoB); + addPageSize("B1", 707.0, 1000.0, SC_MM, catIsoB); + addPageSize("B2", 500.0, 707.0, SC_MM, catIsoB); + addPageSize("B3", 353.0, 500.0, SC_MM, catIsoB); + addPageSize("B4", 250.0, 353.0, SC_MM, catIsoB); + addPageSize("B5", 176.0, 250.0, SC_MM, catIsoB); + addPageSize("B6", 125.0, 176.0, SC_MM, catIsoB); + addPageSize("B7", 88.0, 125.0, SC_MM, catIsoB); + addPageSize("B8", 62.0, 88.0, SC_MM, catIsoB); + addPageSize("B9", 44.0, 62.0, SC_MM, catIsoB); + addPageSize("B10", 31.0, 44.0, SC_MM, catIsoB); + addPageSize("B11", 22.0, 31.0, SC_MM, catIsoB); + addPageSize("B12", 15.0, 22.0, SC_MM, catIsoB); + addPageSize("B13", 11.0, 15.0, SC_MM, catIsoB); + addPageSize("B0+", 1118.0, 1580.0, SC_MM, catIsoB); + addPageSize("B1+", 720.0, 1020.0, SC_MM, catIsoB); + addPageSize("B2+", 520.0, 720.0, SC_MM, catIsoB); + + // https://papersizes.io/c-envelope/ + // ISO C series + PageSizeInfo::Category catIsoC = PageSizeInfo::IsoC; + addPageSize("C0", 917.0, 1297.0, SC_MM, catIsoC); + addPageSize("C1", 648.0, 917.0, SC_MM, catIsoC); + addPageSize("C2", 458.0, 648.0, SC_MM, catIsoC); + addPageSize("C3", 324.0, 458.0, SC_MM, catIsoC); + addPageSize("C4", 229.0, 324.0, SC_MM, catIsoC); + addPageSize("C5", 162.0, 229.0, SC_MM, catIsoC); + addPageSize("C6", 114.0, 162.0, SC_MM, catIsoC); + addPageSize("C7", 81.0, 114.0, SC_MM, catIsoC); + addPageSize("C8", 57.0, 81.0, SC_MM, catIsoC); + addPageSize("C9", 40.0, 57.0, SC_MM, catIsoC); + addPageSize("C10", 28.0, 40.0, SC_MM, catIsoC); + + // https://papersizes.io/international-envelope/ + // ISO Envelopes + PageSizeInfo::Category catIsoEnvelop = PageSizeInfo::IsoEnvelop; + addPageSize("DL/E65", 110.0, 220.0, SC_MM, catIsoEnvelop); + addPageSize("B4", 250.0, 353.0, SC_MM, catIsoEnvelop); + addPageSize("B5", 176.0, 250.0, SC_MM, catIsoEnvelop); + addPageSize("B6", 125.0, 176.0, SC_MM, catIsoEnvelop); + addPageSize("C3", 324.0, 458.0, SC_MM, catIsoEnvelop); + addPageSize("C4", 229.0, 324.0, SC_MM, catIsoEnvelop); + addPageSize("C4M", 229.0, 318.0, SC_MM, catIsoEnvelop); + addPageSize("C5", 162.0, 229.0, SC_MM, catIsoEnvelop); + addPageSize("C6/C5", 114.0, 229.0, SC_MM, catIsoEnvelop); + addPageSize("C6", 114.0, 162.0, SC_MM, catIsoEnvelop); + addPageSize("C64M", 114.0, 318.0, SC_MM, catIsoEnvelop); + addPageSize("C7", 81.0, 114.0, SC_MM, catIsoEnvelop); + addPageSize("C7/C6", 81.0, 162.0, SC_MM, catIsoEnvelop); + addPageSize("B6/C4", 125.0, 324.0, SC_MM, catIsoEnvelop); + addPageSize("E4", 220.0, 312.0, SC_MM, catIsoEnvelop); + addPageSize("E5", 115.0, 220.0, SC_MM, catIsoEnvelop); + addPageSize("E56", 115.0, 115.0, SC_MM, catIsoEnvelop); + addPageSize("E6", 110.0, 155.0, SC_MM, catIsoEnvelop); + addPageSize("EC45", 220.0, 229.0, SC_MM, catIsoEnvelop); + addPageSize("EC5", 155.0, 229.0, SC_MM, catIsoEnvelop); + addPageSize("R7", 120.0, 135.0, SC_MM, catIsoEnvelop); + addPageSize("S4", 250.0, 330.0, SC_MM, catIsoEnvelop); + addPageSize("S5", 185.0, 255.0, SC_MM, catIsoEnvelop); + addPageSize("S65", 110.0, 225.0, SC_MM, catIsoEnvelop); + addPageSize("X5", 105.0, 216.0, SC_MM, catIsoEnvelop); + addPageSize("EX5", 115.0, 216.0, SC_MM, catIsoEnvelop); + + // https://papersizes.io/japanese/ + // Japanese + PageSizeInfo::Category catJapanese = PageSizeInfo::Japanese; + addPageSize("JB0", 1030.0, 1456.0, SC_MM, catJapanese); + addPageSize("JB1", 728.0, 1030.0, SC_MM, catJapanese); + addPageSize("JB2", 515.0, 728.0, SC_MM, catJapanese); + addPageSize("JB3", 364.0, 515.0, SC_MM, catJapanese); + addPageSize("JB4", 257.0, 364.0, SC_MM, catJapanese); + addPageSize("JB5", 182.0, 257.0, SC_MM, catJapanese); + addPageSize("JB6", 128.0, 182.0, SC_MM, catJapanese); + addPageSize("JB7", 91.0, 128.0, SC_MM, catJapanese); + addPageSize("JB8", 64.0, 91.0, SC_MM, catJapanese); + addPageSize("JB9", 45.0, 64.0, SC_MM, catJapanese); + addPageSize("JB10", 32.0, 45.0, SC_MM, catJapanese); + addPageSize("JB11", 22.0, 32.0, SC_MM, catJapanese); + addPageSize("JB12", 16.0, 22.0, SC_MM, catJapanese); + addPageSize("Shiroku ban 4", 264.0, 379.0, SC_MM, catJapanese); + addPageSize("Shiroku ban 5", 189.0, 262.0, SC_MM, catJapanese); + addPageSize("Shiroku ban 6", 127.0, 188.0, SC_MM, catJapanese); + addPageSize("Kiku 4", 227.0, 306.0, SC_MM, catJapanese); + addPageSize("Kiku 5", 151.0, 227.0, SC_MM, catJapanese); + + // https://papersizes.io/newspaper/ + // Newspaper + PageSizeInfo::Category catNewspaper = PageSizeInfo::Newspaper; + addPageSize("Berliner", 315.0, 470.0, SC_MM, catNewspaper); + addPageSize("Broadsheet", 597.0, 749.0, SC_MM, catNewspaper); + addPageSize("US Broadsheet", 15.0, 22.75, SC_IN, catNewspaper); + addPageSize("British Broadsheet", 375.0, 597.0, SC_MM, catNewspaper); + addPageSize("South African Broadsheet", 410.0, 578.0, SC_MM, catNewspaper); + addPageSize("Ciner", 350.0, 500.0, SC_MM, catNewspaper); + addPageSize("Compact", 280.0, 430.0, SC_MM, catNewspaper); + addPageSize("Nordisch", 400.0, 570.0, SC_MM, catNewspaper); + addPageSize("Rhenish", 350.0, 520.0, SC_MM, catNewspaper); + addPageSize("Swiss", 320.0, 475.0, SC_MM, catNewspaper); + addPageSize("Tabloid (Newspaper)", 280.0, 430.0, SC_MM, catNewspaper); + addPageSize("Canadian Tabloid", 260.0, 368.0, SC_MM, catNewspaper); + addPageSize("Norwegian Tabloid", 280.0, 400.0, SC_MM, catNewspaper); + addPageSize("New York Times", 12.0, 22.0, SC_IN, catNewspaper); + addPageSize("Wall Street Journal", 12.0, 22.75, SC_IN, catNewspaper); + + // https://papersizes.io/swedish/ + // Swedish + PageSizeInfo::Category catSwedish = PageSizeInfo::Swedish; + addPageSize("SIS D0", 1091.0, 1542.0, SC_MM, catSwedish); + addPageSize("SIS D1", 771.0, 1091.0, SC_MM, catSwedish); + addPageSize("SIS D2", 545.0, 771.0, SC_MM, catSwedish); + addPageSize("SIS D3", 386.0, 545.0, SC_MM, catSwedish); + addPageSize("SIS D4", 273.0, 386.0, SC_MM, catSwedish); + addPageSize("SIS D5", 193.0, 273.0, SC_MM, catSwedish); + addPageSize("SIS D6", 136.0, 193.0, SC_MM, catSwedish); + addPageSize("SIS D7", 96.0, 136.0, SC_MM, catSwedish); + addPageSize("SIS D8", 68.0, 96.0, SC_MM, catSwedish); + addPageSize("SIS D9", 48.0, 68.0, SC_MM, catSwedish); + addPageSize("SIS D10", 34.0, 48.0, SC_MM, catSwedish); + addPageSize("SIS E0", 878.0, 1242.0, SC_MM, catSwedish); + addPageSize("SIS E1", 621.0, 878.0, SC_MM, catSwedish); + addPageSize("SIS E2", 439.0, 621.0, SC_MM, catSwedish); + addPageSize("SIS E3", 310.0, 439.0, SC_MM, catSwedish); + addPageSize("SIS E4", 220.0, 310.0, SC_MM, catSwedish); + addPageSize("SIS E5", 155.0, 220.0, SC_MM, catSwedish); + addPageSize("SIS E6", 110.0, 155.0, SC_MM, catSwedish); + addPageSize("SIS E7", 78.0, 110.0, SC_MM, catSwedish); + addPageSize("SIS E8", 55.0, 78.0, SC_MM, catSwedish); + addPageSize("SIS E9", 39.0, 55.0, SC_MM, catSwedish); + addPageSize("SIS E10", 27.0, 39.0, SC_MM, catSwedish); + addPageSize("SIS F0", 958.0, 1354.0, SC_MM, catSwedish); + addPageSize("SIS F1", 677.0, 958.0, SC_MM, catSwedish); + addPageSize("SIS F2", 479.0, 677.0, SC_MM, catSwedish); + addPageSize("SIS F3", 339.0, 479.0, SC_MM, catSwedish); + addPageSize("SIS F4", 239.0, 339.0, SC_MM, catSwedish); + addPageSize("SIS F5", 169.0, 239.0, SC_MM, catSwedish); + addPageSize("SIS F6", 120.0, 169.0, SC_MM, catSwedish); + addPageSize("SIS F7", 85.0, 120.0, SC_MM, catSwedish); + addPageSize("SIS F8", 60.0, 85.0, SC_MM, catSwedish); + addPageSize("SIS F9", 42.0, 60.0, SC_MM, catSwedish); + addPageSize("SIS F10", 30.0, 42.0, SC_MM, catSwedish); + addPageSize("SIS G0", 1044.0, 1477.0, SC_MM, catSwedish); + addPageSize("SIS G1", 738.0, 1044.0, SC_MM, catSwedish); + addPageSize("SIS G2", 522.0, 738.0, SC_MM, catSwedish); + addPageSize("SIS G3", 369.0, 522.0, SC_MM, catSwedish); + addPageSize("SIS G4", 261.0, 369.0, SC_MM, catSwedish); + addPageSize("SIS G5", 185.0, 261.0, SC_MM, catSwedish); + addPageSize("SIS G6", 131.0, 185.0, SC_MM, catSwedish); + addPageSize("SIS G7", 92.0, 131.0, SC_MM, catSwedish); + addPageSize("SIS G8", 65.0, 92.0, SC_MM, catSwedish); + addPageSize("SIS G9", 46.0, 65.0, SC_MM, catSwedish); + addPageSize("SIS G10", 33.0, 46.0, SC_MM, catSwedish); + + // Transitional + PageSizeInfo::Category catTransitional = PageSizeInfo::Transitional; + addPageSize("F0", 841.0, 1321.0, SC_MM, catTransitional); + addPageSize("F1", 660.0, 841.0, SC_MM, catTransitional); + addPageSize("F2", 420.0, 660.0, SC_MM, catTransitional); + addPageSize("F3", 330.0, 420.0, SC_MM, catTransitional); + addPageSize("F4", 210.0, 330.0, SC_MM, catTransitional); + addPageSize("F5", 165.0, 210.0, SC_MM, catTransitional); + addPageSize("F6", 105.0, 165.0, SC_MM, catTransitional); + addPageSize("F7", 82.0, 105.0, SC_MM, catTransitional); + addPageSize("F8", 52.0, 82.0, SC_MM, catTransitional); + addPageSize("F9", 41.0, 52.0, SC_MM, catTransitional); + addPageSize("F10", 26.0, 41.0, SC_MM, catTransitional); + addPageSize("PA0", 840.0, 1120.0, SC_MM, catTransitional); + addPageSize("PA1", 560.0, 840.0, SC_MM, catTransitional); + addPageSize("PA2", 420.0, 560.0, SC_MM, catTransitional); + addPageSize("PA3", 280.0, 420.0, SC_MM, catTransitional); + addPageSize("PA4", 210.0, 280.0, SC_MM, catTransitional); + addPageSize("PA5", 140.0, 210.0, SC_MM, catTransitional); + addPageSize("PA6", 105.0, 140.0, SC_MM, catTransitional); + addPageSize("PA7", 70.0, 105.0, SC_MM, catTransitional); + addPageSize("PA8", 52.0, 70.0, SC_MM, catTransitional); + addPageSize("PA9", 35.0, 52.0, SC_MM, catTransitional); + addPageSize("PA10", 26.0, 35.0, SC_MM, catTransitional); + + + // US Paper Size + // https://papersizes.io/us/ + PageSizeInfo::Category catUSStandard = PageSizeInfo::USStandard; + addPageSize("Letter", 8.5, 11.0, SC_IN, catUSStandard); + addPageSize("Legal", 8.5, 14.0, SC_IN, catUSStandard); + addPageSize("Ledger, Tabloid", 11.0, 17.0, SC_IN, catUSStandard); + addPageSize("Junior Legal", 5.0, 8.0, SC_IN, catUSStandard); + addPageSize("Half Letter", 5.5, 8.5, SC_IN, catUSStandard); + addPageSize("Government Letter", 8.0, 10.5, SC_IN, catUSStandard); + addPageSize("Government Legal", 8.5, 13.0, SC_IN, catUSStandard); + addPageSize("ANSI A", 8.5, 11.0, SC_IN, catUSStandard); + addPageSize("ANSI B", 11.0, 17.0, SC_IN, catUSStandard); + addPageSize("ANSI C", 17.0, 22.0, SC_IN, catUSStandard); + addPageSize("ANSI D", 22.0, 34.0, SC_IN, catUSStandard); + addPageSize("ANSI E", 34.0, 44.0, SC_IN, catUSStandard); + addPageSize("Arch A", 9.0, 12.0, SC_IN, catUSStandard); + addPageSize("Arch B", 12.0, 18.0, SC_IN, catUSStandard); + addPageSize("Arch C", 18.0, 24.0, SC_IN, catUSStandard); + addPageSize("Arch D", 24.0, 36.0, SC_IN, catUSStandard); + addPageSize("Arch E", 36.0, 48.0, SC_IN, catUSStandard); + addPageSize("Arch E1", 30.0, 42.0, SC_IN, catUSStandard); + addPageSize("Arch E2", 26.0, 38.0, SC_IN, catUSStandard); + addPageSize("Arch E3", 27.0, 39.0, SC_IN, catUSStandard); + + // US Loose paper Sizes + PageSizeInfo::Category catUSLoose = PageSizeInfo::USLoose; + addPageSize("5x7", 5.0, 7.0, SC_IN, catUSLoose); + addPageSize("7x9", 7.0, 9.0, SC_IN, catUSLoose); + addPageSize("10x11", 10.0, 11.0, SC_IN, catUSLoose); + addPageSize("10x13", 10.0, 13.0, SC_IN, catUSLoose); + addPageSize("10x14", 10.0, 14.0, SC_IN, catUSLoose); + addPageSize("11x12", 11.0, 12.0, SC_IN, catUSLoose); + addPageSize("11x15", 11.0, 15.0, SC_IN, catUSLoose); + + // US Envelope + // https://www.wsel.com/envelopes/standard-sizes + PageSizeInfo::Category catUSEnvelop = PageSizeInfo::USEnvelop; + addPageSize("Commerical 5", 3.125, 5.5, SC_IN, catUSEnvelop); + addPageSize("Commerical 6 1/4", 3.5, 6.0, SC_IN, catUSEnvelop); + addPageSize("Commerical 6 3/4", 3.625, 6.5, SC_IN, catUSEnvelop); + addPageSize("Commerical 7", 3.75, 6.75, SC_IN, catUSEnvelop); + addPageSize("Commerical 7 1/2", 3.9375, 7.5, SC_IN, catUSEnvelop); + addPageSize("Commerical 8 5/8", 3.625, 8.625, SC_IN, catUSEnvelop); + addPageSize("Commerical 9", 3.875, 8.875, SC_IN, catUSEnvelop); + addPageSize("Commerical 10", 4.125, 9.5, SC_IN, catUSEnvelop); + addPageSize("Commerical 11", 4.5, 10.375, SC_IN, catUSEnvelop); + addPageSize("Commerical 12", 4.75, 11, SC_IN, catUSEnvelop); + addPageSize("Commerical 14", 5.0, 11.5, SC_IN, catUSEnvelop); + + // Other Formats + PageSizeInfo::Category catOther = PageSizeInfo::Other; + addPageSize("Compact Disc", 119.9, 120.7, SC_MM, catOther); + } void PageSize::printSizeList() const @@ -432,7 +625,7 @@ 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() << std::endl; + std::cout << it.value().trSizeName.toStdString() << categoryToString(it.value().category).toStdString() << std::endl; } } Index: scribus/pagesize.h =================================================================== --- scribus/pagesize.h (Revision 26264) +++ scribus/pagesize.h (Arbeitskopie) @@ -29,17 +29,50 @@ struct PageSizeInfo { + enum Category { + + Custom = 0, // don't use for presets, it is reserved for custom sizes + Favorite = 1, // don't use for presets, it is reserved for user favorite sizes + IsoA = 2, + IsoB = 3, + IsoC = 4, + IsoEnvelop = 5, + USStandard = 6, + USLoose = 7, + USEnvelop = 8, + + Book = 20, + BusinessCards = 21, + Newspaper = 22, + Transitional = 23, + + Other = 30, + + Canadian = 40, + Chinese = 41, + Colombian = 42, + French = 43, + German = 44, + Japanese = 45, + Swedish = 46, + }; + double width; double height; QString trSizeName; + QString sizeName; + QString sizeLabel; int pageUnitIndex; + Category category; }; using PageSizeInfoMap = QMap<QString, PageSizeInfo>; +using PageSizeCategoriesMap = QMap<PageSizeInfo::Category, QString>; class SCRIBUS_API PageSize { public: + PageSize(const QString&); PageSize(const double, const double); PageSize& operator=(const PageSize& other); @@ -46,18 +79,19 @@ void init(const QString&); QString name() const { return m_pageSizeName; } QString nameTR() const { return m_trPageSizeName; } + PageSizeInfo::Category category() { return m_category; }; 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); } - QStringList sizeList() const; - QStringList sizeTRList() const; - QStringList activeSizeList() const; - QStringList activeSizeTRList() const; - void generateSizeList(); + QStringList defaultSizesList() const; + PageSizeCategoriesMap categories(); + PageSizeInfoMap sizesByCategory(PageSizeInfo::Category category); + PageSizeInfoMap activePageSizes(); + PageSizeInfoMap pageSizes() const { return m_pageSizeList; }; void printSizeList() const; - QStringList untransPageSizeList(const QStringList &transList); + QString categoryToString(PageSizeInfo::Category category) const; private: PageSizeInfoMap m_pageSizeList; @@ -66,6 +100,11 @@ int m_pageUnitIndex { -1 }; QString m_pageSizeName; QString m_trPageSizeName; + PageSizeInfo::Category m_category {PageSizeInfo::Custom}; + + void generateSizeList(); + void addPageSize(const QString name, double width, double height, int unitIndex, PageSizeInfo::Category category); + }; #endif Index: scribus/prefsmanager.cpp =================================================================== --- scribus/prefsmanager.cpp (Revision 26264) +++ scribus/prefsmanager.cpp (Arbeitskopie) @@ -521,7 +521,7 @@ appPrefs.imageCachePrefs.maxCacheEntries = 1000; appPrefs.imageCachePrefs.compressionLevel = 1; appPrefs.activePageSizes.clear(); - appPrefs.activePageSizes << "A3" << "A4" << "A5" << "A6" << "Letter"; + appPrefs.activePageSizes = defaultPageSize.defaultSizesList(); //Attribute setup appPrefs.itemAttrPrefs.defaultItemAttributes.clear(); Index: scribus/scribus.cpp =================================================================== --- scribus/scribus.cpp (Revision 26264) +++ scribus/scribus.cpp (Arbeitskopie) @@ -183,7 +183,6 @@ #include "ui/javadocs.h" #include "ui/layers.h" #include "ui/loremipsum.h" -#include "ui/marginwidget.h" #include "ui/mark2item.h" #include "ui/mark2mark.h" #include "ui/markanchor.h" @@ -2016,12 +2015,12 @@ if (dia->tabSelected() == NewDocDialog::NewDocumentTab) { int facingPages = dia->choosenLayout(); - int firstPage = dia->firstPage->currentIndex(); + int firstPage = dia->pageLayouts->firstPage();//firstPage->currentIndex(); docSet = dia->startDocSetup->isChecked(); - double topMargin = dia->marginGroup->top(); - double bottomMargin = dia->marginGroup->bottom(); - double leftMargin = dia->marginGroup->left(); - double rightMargin = dia->marginGroup->right(); + 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 columnDistance = dia->distance(); double pageWidth = dia->pageWidth(); double pageHeight = dia->pageHeight(); @@ -2029,15 +2028,8 @@ bool autoframes = dia->autoTextFrame->isChecked(); int orientation = dia->orientation(); int pageCount = dia->pageCountSpinBox->value(); - QString pagesize; - if (dia->pageSizeComboBox->currentText() == CommonStrings::trCustomPageSize) - pagesize = CommonStrings::customPageSize; - else - { - PageSize ps2(dia->pageSizeComboBox->currentText()); - pagesize = ps2.name(); - } - doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, numberCols, autoframes, facingPages, dia->unitOfMeasureComboBox->currentIndex(), firstPage, orientation, 1, pagesize, true, pageCount, true, dia->marginGroup->getMarginPreset()); + QString pagesize = dia->pageSizeName(); + doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, numberCols, autoframes, facingPages, dia->unitOfMeasureComboBox->currentIndex(), firstPage, orientation, 1, pagesize, true, pageCount, true, dia->marginGroup->marginPreset()); doc->setPageSetFirstPage(facingPages, firstPage); doc->bleeds()->set(dia->bleedTop(), dia->bleedLeft(), dia->bleedBottom(), dia->bleedRight()); HaveNewDoc(); @@ -2099,12 +2091,12 @@ return false; int facingPages = dia->choosenLayout(); - int firstPage = dia->firstPage->currentIndex(); + int firstPage = dia->pageLayouts->firstPage(); bool docSet = dia->startDocSetup->isChecked(); - double topMargin = dia->marginGroup->top(); - double bottomMargin = dia->marginGroup->bottom(); - double leftMargin = dia->marginGroup->left(); - double rightMargin = dia->marginGroup->right(); + 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 columnDistance = dia->distance(); double pageWidth = dia->pageWidth(); double pageHeight = dia->pageHeight(); @@ -2112,16 +2104,10 @@ bool autoframes = dia->autoTextFrame->isChecked(); int orientation = dia->orientation(); int pageCount = dia->pageCountSpinBox->value(); - QString pagesize; - if (dia->pageSizeComboBox->currentText() == CommonStrings::trCustomPageSize) - pagesize = CommonStrings::customPageSize; - else + QString pagesize = dia->pageSizeName(); + + 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())) { - PageSize ps2(dia->pageSizeComboBox->currentText()); - pagesize = ps2.name(); - } - if (doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, numberCols, autoframes, facingPages, dia->unitOfMeasureComboBox->currentIndex(), firstPage, orientation, 1, pagesize, true, pageCount, true, dia->marginGroup->getMarginPreset())) - { doc->setPageSetFirstPage(facingPages, firstPage); doc->bleeds()->set(dia->bleedTop(), dia->bleedLeft(), dia->bleedBottom(), dia->bleedRight()); m_mainWindowStatusLabel->setText( tr("Ready")); Index: scribus/ui/delegates/sclistitemdelegate.cpp =================================================================== --- scribus/ui/delegates/sclistitemdelegate.cpp (Revision 26264) +++ scribus/ui/delegates/sclistitemdelegate.cpp (Arbeitskopie) @@ -33,6 +33,9 @@ cHighlight.setAlphaF(0.2f); QBrush fillSelected(cHighlight); + QFont subFont = QFont(); + subFont.setPointSize(8); + if(m_style == Style::Simple) { radius = 0; @@ -42,6 +45,7 @@ } QTextOption tOptions; + QTextOption sOptions; QRect rIcon = option.rect; QRect rText = option.rect; @@ -68,6 +72,7 @@ // Item Data QIcon ic = qvariant_cast<QIcon>(index.data(Qt::DecorationRole)); QString title = index.data(Qt::DisplayRole).toString(); + QString subTitle = index.data(Qt::UserRole).toString(); switch (m_textPosition) { @@ -80,7 +85,8 @@ rIcon = QRect(p.x() + hSpace, p.y() + vSpace, m_iconSize.width(), m_iconSize.height()); rText = option.rect.adjusted(padding, padding + m_iconSize.height(), -padding, -padding); - tOptions.setFlags(QFlag(Qt::AlignBottom|Qt::AlignHCenter|Qt::TextWordWrap)); + tOptions.setFlags(QFlag(Qt::AlignTop|Qt::AlignHCenter|Qt::TextWordWrap)); + sOptions.setFlags(QFlag(Qt::AlignBottom|Qt::AlignHCenter|Qt::TextWordWrap)); } break; case TextPosition::Right: @@ -89,7 +95,8 @@ rIcon = QRect(p.x() + padding, p.y() + padding, m_iconSize.width(), m_iconSize.height()); rText = option.rect.adjusted(padding * 2 + m_iconSize.width(), padding, -padding, -padding); - tOptions.setFlags(QFlag(Qt::AlignVCenter|Qt::AlignLeft|Qt::TextWordWrap)); + tOptions.setFlags(QFlag(Qt::AlignTop|Qt::AlignLeft|Qt::TextWordWrap)); + sOptions.setFlags(QFlag(Qt::AlignBottom|Qt::AlignLeft|Qt::TextWordWrap)); } break; } @@ -103,9 +110,15 @@ // Label if (!title.isEmpty()) { + QRect rectNorm = rText.normalized(); + painter->setPen(fontPen); + painter->setBrush(Qt::NoBrush); painter->setFont(QFont()); - painter->drawText(rText, tOptions.flags(), title, &rText); + painter->drawText(rText, tOptions.flags(), title, &rectNorm); + + painter->setFont(subFont); + painter->drawText(rText, sOptions.flags(), subTitle); } painter->restore(); Index: scribus/ui/inspage.cpp =================================================================== --- scribus/ui/inspage.cpp (Revision 26264) +++ scribus/ui/inspage.cpp (Arbeitskopie) @@ -34,11 +34,11 @@ setWindowIcon(IconManager::instance().loadIcon("AppIcon.png")); dialogLayout = new QVBoxLayout(this); - dialogLayout->setSpacing(6); - dialogLayout->setContentsMargins(9, 9, 9, 9); + dialogLayout->setSpacing(4); + dialogLayout->setContentsMargins(8, 8, 8, 8); whereLayout = new QGridLayout(); - whereLayout->setSpacing(6); + whereLayout->setSpacing(4); whereLayout->setContentsMargins(0, 0, 0, 0); insCountData = new QSpinBox(this); @@ -75,8 +75,8 @@ masterPageGroup->setTitle( tr( "Master Pages" ) ); masterPageLayout = new QGridLayout( masterPageGroup ); masterPageLayout->setAlignment(Qt::AlignTop); - masterPageLayout->setSpacing(6); - masterPageLayout->setContentsMargins(9, 9, 9, 9); + masterPageLayout->setSpacing(4); + masterPageLayout->setContentsMargins(8, 8, 8, 8); if (m_doc->pagePositioning() == 0) { QComboBox* pageData = new QComboBox(masterPageGroup); @@ -230,31 +230,18 @@ dsGroupBox7 = new QGroupBox( this ); dsGroupBox7->setTitle( tr( "Page Size" ) ); dsGroupBox7Layout = new QGridLayout(dsGroupBox7); - dsGroupBox7Layout->setSpacing(6); - dsGroupBox7Layout->setContentsMargins(9, 9, 9, 9); + dsGroupBox7Layout->setSpacing(4); + dsGroupBox7Layout->setContentsMargins(8, 8, 8, 8); textLabel1 = new QLabel( tr( "&Size:" ), dsGroupBox7); - dsGroupBox7Layout->addWidget(textLabel1, 0, 0); - + dsGroupBox7Layout->addWidget(textLabel1, 0, 0, Qt::AlignTop | Qt::AlignRight); QScopedPointer<PageSize> ps(new PageSize(m_doc->pageSize())); prefsPageSizeName = ps->name(); - sizeQComboBox = new QComboBox(dsGroupBox7); - QStringList insertList(ps->activeSizeTRList()); - if (insertList.indexOf(prefsPageSizeName) == -1) - insertList << prefsPageSizeName; - insertList.sort(); - insertList << CommonStrings::trCustomPageSize; - sizeQComboBox->addItems(insertList); - int sizeIndex = insertList.indexOf(ps->nameTR()); - if (sizeIndex != -1) - sizeQComboBox->setCurrentIndex(sizeIndex); - else - sizeQComboBox->setCurrentIndex(sizeQComboBox->count() - 1); - - textLabel1->setBuddy(sizeQComboBox); - dsGroupBox7Layout->addWidget(sizeQComboBox, 0, 1, 1, 3); - + pageSizeSelector = new PageSizeSelector(dsGroupBox7); + pageSizeSelector->setPageSize(m_doc->pageSize()); + textLabel1->setBuddy(pageSizeSelector); + dsGroupBox7Layout->addWidget(pageSizeSelector, 0, 1); textLabel2 = new QLabel( tr( "Orie&ntation:" ), dsGroupBox7); - dsGroupBox7Layout->addWidget(textLabel2, 1, 0); + dsGroupBox7Layout->addWidget(textLabel2, 1, 0, Qt::AlignRight); orientationQComboBox = new QComboBox(dsGroupBox7); orientationQComboBox->addItem( tr( "Portrait" ) ); @@ -261,13 +248,13 @@ orientationQComboBox->addItem( tr( "Landscape" ) ); orientationQComboBox->setCurrentIndex(m_doc->pageOrientation() ); textLabel2->setBuddy(orientationQComboBox); - dsGroupBox7Layout->addWidget(orientationQComboBox, 1, 1, 1, 3); + dsGroupBox7Layout->addWidget(orientationQComboBox, 1, 1); widthSpinBox = new ScrSpinBox(1, 10000, dsGroupBox7, m_doc->unitIndex()); widthQLabel = new QLabel( tr( "&Width:" ), dsGroupBox7); widthSpinBox->setValue(m_doc->pageWidth() * m_doc->unitRatio()); widthQLabel->setBuddy(widthSpinBox); - dsGroupBox7Layout->addWidget(widthQLabel, 2, 0); + dsGroupBox7Layout->addWidget(widthQLabel, 2, 0, Qt::AlignRight); dsGroupBox7Layout->addWidget(widthSpinBox, 2, 1); heightSpinBox = new ScrSpinBox(1, 10000, dsGroupBox7, m_doc->unitIndex()); @@ -274,17 +261,17 @@ heightSpinBox->setValue(m_doc->pageHeight() * m_doc->unitRatio()); heightQLabel = new QLabel( tr( "&Height:" ), dsGroupBox7); heightQLabel->setBuddy(heightSpinBox); - dsGroupBox7Layout->addWidget(heightQLabel, 3, 0); + dsGroupBox7Layout->addWidget(heightQLabel, 3, 0, Qt::AlignRight); dsGroupBox7Layout->addWidget(heightSpinBox, 3, 1); moveObjectsCheckBox = new QCheckBox( dsGroupBox7); moveObjectsCheckBox->setText( tr( "Move Objects with their Page" ) ); moveObjectsCheckBox->setChecked(true); - dsGroupBox7Layout->addWidget(moveObjectsCheckBox, 4, 0, 1, 4); + dsGroupBox7Layout->addWidget(moveObjectsCheckBox, 4, 0, 1, 2); dialogLayout->addWidget(dsGroupBox7); dsGroupBox7->setEnabled(false); - bool b = (sizeQComboBox->currentText() == CommonStrings::trCustomPageSize); + bool b = (pageSizeSelector->pageSizeTR() == CommonStrings::trCustomPageSize); heightSpinBox->setEnabled(b); widthSpinBox->setEnabled(b); @@ -298,7 +285,7 @@ connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); connect(orientationQComboBox, SIGNAL(activated(int)), this, SLOT(setOrientation(int))); - connect(sizeQComboBox, SIGNAL(textActivated(QString)), this, SLOT(setSize(QString))); + connect(pageSizeSelector, SIGNAL(pageSizeChanged(QString)), this, SLOT(setSize(QString))); connect(overrideMPSizingCheckBox, SIGNAL(stateChanged(int)), this, SLOT(enableSizingControls(int))); } @@ -325,10 +312,10 @@ void InsPage::setOrientation(int ori) { double br; - setSize(sizeQComboBox->currentText()); + setSize(pageSizeSelector->pageSizeTR()); if (ori == 0) { - if (sizeQComboBox->currentText() == CommonStrings::trCustomPageSize) + if (pageSizeSelector->pageSizeTR() == CommonStrings::trCustomPageSize) { br = widthSpinBox->value(); widthSpinBox->setValue(heightSpinBox->value()); Index: scribus/ui/inspage.h =================================================================== --- scribus/ui/inspage.h (Revision 26264) +++ scribus/ui/inspage.h (Arbeitskopie) @@ -8,6 +8,7 @@ #define INSPAGE_H #include "scribusapi.h" +#include "widgets/pagesizeselector.h" #include <QDialog> #include <QDialogButtonBox> #include <QList> @@ -71,7 +72,8 @@ QLabel* heightQLabel { nullptr }; QLabel* textLabel1 { nullptr }; QLabel* textLabel2 { nullptr }; - QComboBox* sizeQComboBox { nullptr }; + PageSizeSelector* pageSizeSelector { nullptr }; +// QComboBox* sizeQComboBox { nullptr }; QComboBox* orientationQComboBox { nullptr }; QCheckBox* moveObjectsCheckBox { nullptr }; QCheckBox* overrideMPSizingCheckBox { nullptr }; Index: scribus/ui/marginwidget.cpp =================================================================== --- scribus/ui/marginwidget.cpp (Revision 26264) +++ scribus/ui/marginwidget.cpp (nicht existent) @@ -1,623 +0,0 @@ -/* -For general Scribus (>=1.3.2) copyright and licensing information please refer -to the COPYING file provided with the program. Following this notice may exist -a copyright and/or license notice that predates the release of Scribus 1.3.2 -for which a new license (GPL+exception) is in place. -*/ -#include "marginwidget.h" - -#include <QHBoxLayout> -#include <QGridLayout> -#include <QLabel> -#include <QToolTip> -#include <QCheckBox> -#include <QLabel> -#include <QPushButton> - -#include "scrspinbox.h" -#include "units.h" -#include "ui/useprintermarginsdialog.h" - - -MarginWidget::MarginWidget( QWidget* parent, const QString& /*title*/, const MarginStruct* margs, int unitIndex, bool showChangeAll, bool showBleeds) : QTabWidget(parent), - m_useBleeds(showBleeds) -{ - marginData = *margs; - m_savedMargins = *margs; - m_savedPresetItem = PresetLayout::none; //we don't recheck if we are using a layout but always start at none - marginPage = new QWidget(this); - - presetCombo = new PresetLayout(marginPage); - presetLabel = new QLabel( tr("Preset Layouts:"), marginPage); - presetLabel->setBuddy(presetCombo); - m_unitIndex = unitIndex; - m_unitRatio = unitGetRatioFromIndex(unitIndex); - leftR = new ScrSpinBox( 0, 1000, marginPage, unitIndex ); - rightR = new ScrSpinBox( 0, 1000, marginPage, unitIndex ); - topR = new ScrSpinBox( 0, 1000, marginPage, unitIndex ); - bottomR = new ScrSpinBox( 0, 1000, marginPage, unitIndex ); - updateMarginSpinValues(); - - bText = new QLabel( tr( "&Bottom:" ), marginPage); - bText->setBuddy(bottomR); - tText = new QLabel( tr( "&Top:" ), marginPage); - tText->setBuddy(topR); - rText = new QLabel( tr( "&Right:" ), marginPage); - rText->setBuddy(rightR); - lText = new QLabel( tr( "&Left:" ), marginPage); - lText->setBuddy(leftR); - - linkMargins = new LinkButton( marginPage ); - linkMargins->setCheckable( true ); - linkMargins->setChecked(false); - linkMargins->setAutoRaise( true ); - linkMargins->setMinimumSize( QSize( 15, 0 ) ); - linkMargins->setMaximumSize( QSize( 15, 32767 ) ); - - // layout - GroupLayout = new QGridLayout( marginPage ); - GroupLayout->setSpacing(6); - GroupLayout->setContentsMargins(9, 9, 9, 9); - GroupLayout->addWidget(presetLabel, 0, 0); - GroupLayout->addWidget(presetCombo, 0, 1); - GroupLayout->addWidget( leftR, 1, 1 ); - GroupLayout->addWidget( rightR, 2, 1 ); - GroupLayout->addWidget( topR, 3, 1 ); - GroupLayout->addWidget( bottomR, 4, 1 ); - GroupLayout->addWidget( lText, 1, 0 ); - GroupLayout->addWidget( rText, 2, 0 ); - GroupLayout->addWidget( tText, 3, 0 ); - GroupLayout->addWidget( bText, 4, 0 ); - GroupLayout->addWidget( linkMargins, 1, 2, 4, 1 ); - if (showChangeAll) - { - marginsForPagesLayout = new QHBoxLayout; - marginsForPagesLayout->setContentsMargins(9, 9, 9, 9); - marginsForPagesLayout->setSpacing(6); - marginsForPages = new QLabel( tr( "Apply settings to:" ), marginPage ); - marginsForPagesLayout->addWidget(marginsForPages); - marginsForAllPages = new QCheckBox( marginPage ); - marginsForAllPages->setText( tr( "All Document Pages" ) ); - marginsForAllPages->setChecked( false ); - marginsForPagesLayout->addWidget(marginsForAllPages); - marginsForAllMasterPages = new QCheckBox( marginPage ); - marginsForAllMasterPages->setText( tr( "All Master Pages" ) ); - marginsForAllMasterPages->setChecked( false ); - marginsForPagesLayout->addWidget(marginsForAllMasterPages); - GroupLayout->addLayout( marginsForPagesLayout, 6, 0, 1, 2 ); - marginsForAllPages->setToolTip( "<qt>" + tr( "Apply the margin changes to all existing pages in the document" ) + "</qt>" ); - marginsForAllMasterPages->setToolTip( "<qt>" + tr( "Apply the margin changes to all existing master pages in the document" ) + "</qt>" ); - } - - usePrinterMarginsButton = nullptr; - usePrinterMarginsButton = new QPushButton( tr("Printer Margins..."),marginPage ); - GroupLayout->addWidget( usePrinterMarginsButton, 5, 1 ); - usePrinterMarginsButton->setToolTip( "<qt>" + tr( "Import the margins for the selected page size from the available printers" ) + "</qt>"); - connect(usePrinterMarginsButton, SIGNAL(clicked()), this, SLOT(setMarginsToPrinterMargins())); - - addTab(marginPage, tr("Margin Guides")); - - if (m_useBleeds) - { - bleedPage = new QWidget(this); - BleedGroupLayout = new QGridLayout( bleedPage ); - BleedGroupLayout->setSpacing(6); - BleedGroupLayout->setContentsMargins(9, 9, 9, 9); - BleedGroupLayout->setAlignment( Qt::AlignTop ); - BleedTxt3 = new QLabel( bleedPage ); - BleedGroupLayout->addWidget( BleedTxt3, 0, 0 ); - BleedLeft = new ScrSpinBox( 0, 3000*m_unitRatio, bleedPage, unitIndex ); - BleedGroupLayout->addWidget( BleedLeft, 0, 1 ); - BleedTxt4 = new QLabel( bleedPage ); - BleedGroupLayout->addWidget( BleedTxt4, 1, 0 ); - BleedRight = new ScrSpinBox( 0, 3000*m_unitRatio, bleedPage, unitIndex ); - BleedGroupLayout->addWidget( BleedRight, 1, 1 ); - BleedTxt1 = new QLabel( bleedPage ); - BleedTxt1->setText( tr( "Top:" ) ); - BleedGroupLayout->addWidget( BleedTxt1, 2, 0 ); - BleedTop = new ScrSpinBox( 0, 3000*m_unitRatio, bleedPage, unitIndex ); - BleedGroupLayout->addWidget( BleedTop, 2, 1 ); - BleedTxt2 = new QLabel( bleedPage ); - BleedTxt2->setText( tr( "Bottom:" ) ); - BleedGroupLayout->addWidget( BleedTxt2, 3, 0 ); - BleedBottom = new ScrSpinBox( 0, 3000*m_unitRatio, bleedPage, unitIndex ); - BleedGroupLayout->addWidget( BleedBottom, 3, 1 ); - linkBleeds = new LinkButton( bleedPage ); -/** Fix Me to move this to the prefsmanager.cpp someday */ - linkBleeds->setCheckable( true ); - linkBleeds->setChecked(true); - linkBleeds->setAutoRaise( true ); - linkBleeds->setMinimumSize( QSize( 15, 0 ) ); - linkBleeds->setMaximumSize( QSize( 15, 32767 ) ); - BleedGroupLayout->addWidget( linkBleeds, 0, 2, 4, 1 ); - BleedTop->setToolTip( "<qt>" + tr( "Distance for bleed from the top of the physical page" ) + "</qt>" ); - BleedBottom->setToolTip( "<qt>" + tr( "Distance for bleed from the bottom of the physical page" ) + "</qt>" ); - BleedLeft->setToolTip( "<qt>" + tr( "Distance for bleed from the left of the physical page" ) + "</qt>" ); - BleedRight->setToolTip( "<qt>" + tr( "Distance for bleed from the right of the physical page" ) + "</qt>"); - linkBleeds->setToolTip( "<qt>" + tr( "Ensure all bleeds have the same value" ) + "</qt>"); - connect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(linkBleeds, SIGNAL(clicked()), this, SLOT(slotLinkBleeds())); - addTab(bleedPage, tr("Bleeds")); - } - - // hints - topR->setToolTip( "<qt>" + tr( "Distance between the top margin guide and the edge of the page" ) + "</qt>"); - bottomR->setToolTip( "<qt>" + tr( "Distance between the bottom margin guide and the edge of the page" ) + "</qt>"); - leftR->setToolTip( "<qt>" + tr( "Distance between the left margin guide and the edge of the page. If a double-sided, 3 or 4-fold layout is selected, this margin space can be used to achieve the correct margins for binding.") + "</qt>"); - rightR->setToolTip( "<qt>" + tr( "Distance between the right margin guide and the edge of the page. If a double-sided, 3 or 4-fold layout is selected, this margin space can be used to achieve the correct margins for binding.") + "</qt>"); - linkMargins->setToolTip( "<qt>" + tr( "Ensure all margins have the same value") + "</qt>"); - - // signals&slots - connect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - connect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - connect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - connect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - connect(presetCombo, SIGNAL(activated(int)), this, SLOT(setPreset())); - connect(linkMargins, SIGNAL(clicked()), this, SLOT(slotLinkMargins())); -} - -void MarginWidget::slotLinkBleeds() -{ - disconnect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - - double bleedValue = BleedLeft->value(); - if (BleedLeft->hasFocus()) - { - BleedLeft->clearFocus(); - bleedValue = BleedLeft->value(); - } - if (BleedRight->hasFocus()) - { - BleedRight->clearFocus(); - bleedValue = BleedRight->value(); - } - if (BleedTop->hasFocus()) - { - BleedTop->clearFocus(); - bleedValue = BleedTop->value(); - } - if (BleedBottom->hasFocus()) - { - BleedBottom->clearFocus(); - bleedValue = BleedBottom->value(); - } - - if (linkBleeds->isChecked()) - { - BleedLeft->setValue(bleedValue); - BleedTop->setValue(bleedValue); - BleedBottom->setValue(bleedValue); - BleedRight->setValue(bleedValue); - } - - connect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); -} - -void MarginWidget::changeBleeds() -{ - if (linkBleeds->isChecked()) - { - double val = 0.0; - if (BleedTop == sender()) - val = BleedTop->value(); - else if (BleedBottom == sender()) - val = BleedBottom->value(); - else if (BleedLeft == sender()) - val = BleedLeft->value(); - else if (BleedRight == sender()) - val = BleedRight->value(); - val = val / m_unitRatio; - MarginStruct v(val,val,val,val); - setNewBleeds(v); - } -} - -void MarginWidget::setFacingPages(bool facing, int pagetype) -{ - m_facingPages = facing; - m_pageType = pagetype; - lText->setText(facing ? tr( "&Inside:" ) : tr( "&Left:" )); - rText->setText(facing ? tr( "O&utside:" ) : tr( "&Right:" )); - if (m_useBleeds) - { - if (facing) - { - BleedTxt3->setText( tr( "Inside:" ) ); - BleedTxt4->setText( tr( "Outside:" ) ); - } - else - { - BleedTxt3->setText( tr( "Left:" ) ); - BleedTxt4->setText( tr( "Right:" ) ); - } - } - setPreset(); -} - -void MarginWidget::setPageWidthHeight(double width, double height) -{ - rightR->setMaximum(qMax(0.0, width * m_unitRatio - leftR->value())); - leftR->setMaximum(qMax(0.0, width * m_unitRatio - rightR->value())); - m_pageWidth = width; - topR->setMaximum(qMax(0.0, height * m_unitRatio - bottomR->value())); - bottomR->setMaximum(qMax(0.0, height * m_unitRatio - topR->value())); - m_pageHeight = height; - setPreset(); -} - -void MarginWidget::setPageWidth(double width) -{ - rightR->setMaximum(qMax(0.0, width * m_unitRatio - leftR->value())); - leftR->setMaximum(qMax(0.0,width * m_unitRatio - rightR->value())); - m_pageWidth = width; - setPreset(); -} - -void MarginWidget::setPageHeight(double height) -{ - topR->setMaximum(qMax(0.0, height * m_unitRatio - bottomR->value())); - bottomR->setMaximum(qMax(0.0,height * m_unitRatio - topR->value())); - m_pageHeight = height; - setPreset(); -} - -void MarginWidget::setTop() -{ - double newVal = topR->value() / m_unitRatio; - bottomR->setMaximum(qMax(0.0, m_pageHeight * m_unitRatio - topR->value())); - if (linkMargins->isChecked() && m_savedPresetItem == PresetLayout::none) - { - marginData.set(newVal, newVal, newVal, newVal); - updateMarginSpinValues(); - } - else - marginData.setTop(newVal); - setPreset(); -} - -void MarginWidget::setBottom() -{ - double newVal = bottomR->value() / m_unitRatio; - topR->setMaximum(qMax(0.0, m_pageHeight * m_unitRatio - bottomR->value())); - if (linkMargins->isChecked() && m_savedPresetItem == PresetLayout::none) - { - marginData.set(newVal, newVal, newVal, newVal); - updateMarginSpinValues(); - } - else - marginData.setBottom(newVal); - setPreset(); -} - -void MarginWidget::setLeft() -{ - double newVal = leftR->value() / m_unitRatio; - rightR->setMaximum(qMax(0.0, m_pageWidth * m_unitRatio - leftR->value())); - if (linkMargins->isChecked() && m_savedPresetItem == PresetLayout::none) - { - marginData.set(newVal, newVal, newVal, newVal); - updateMarginSpinValues(); - } - else - marginData.setLeft(newVal); - setPreset(); -} - -void MarginWidget::setRight() -{ - double newVal = rightR->value() / m_unitRatio; - leftR->setMaximum(qMax(0.0, m_pageWidth * m_unitRatio - rightR->value())); - if (linkMargins->isChecked() && m_savedPresetItem == PresetLayout::none) - { - marginData.set(newVal, newVal, newVal, newVal); - updateMarginSpinValues(); - } - else - marginData.setRight(newVal); - setPreset(); -} - -void MarginWidget::setNewUnit(int newUnitIndex) -{ - disconnect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - disconnect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - disconnect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - disconnect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - m_unitIndex = newUnitIndex; - m_unitRatio = unitGetRatioFromIndex(newUnitIndex); - topR->setNewUnit(newUnitIndex); - bottomR->setNewUnit(newUnitIndex); - leftR->setNewUnit(newUnitIndex); - rightR->setNewUnit(newUnitIndex); - - if (m_useBleeds) - { - disconnect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - BleedBottom->setNewUnit(newUnitIndex); - BleedTop->setNewUnit(newUnitIndex); - BleedRight->setNewUnit(newUnitIndex); - BleedLeft->setNewUnit(newUnitIndex); - connect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - } - connect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - connect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - connect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - connect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); -} - -void MarginWidget::setPreset() -{ - disconnect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - disconnect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - disconnect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - disconnect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - if (m_savedPresetItem == PresetLayout::none) - m_savedMargins = marginData; - int item = presetCombo->currentIndex(); - - MarginStruct marg = presetCombo->getMargins(item, m_pageWidth, m_pageHeight, leftR->value() / m_unitRatio); - presetCombo->setEnabled(m_facingPages); - - bool restoringValues = false; - if ((item == PresetLayout::none) && (m_savedPresetItem != PresetLayout::none)) - { - marg = m_savedMargins; - restoringValues = true; - } - if (restoringValues || (presetCombo->needUpdate() && m_facingPages)) - { - marginData.set(qMax(0.0, marg.top()), qMax(0.0, marg.left()), qMax(0.0, marg.bottom()), qMax(0.0, marg.right())); - updateMarginSpinValues(); - - bottomR->setMaximum(qMax(0.0, m_pageHeight * m_unitRatio - topR->value())); - topR->setMaximum(qMax(0.0, m_pageHeight * m_unitRatio - bottomR->value())); - rightR->setMaximum(qMax(0.0, m_pageWidth * m_unitRatio - leftR->value())); - leftR->setMaximum(qMax(0.0, m_pageWidth * m_unitRatio - rightR->value())); - rightR->setEnabled(restoringValues); - topR->setEnabled(restoringValues); - bottomR->setEnabled(restoringValues); - } - else - { - rightR->setEnabled(true); - topR->setEnabled(true); - bottomR->setEnabled(true); - } - if (m_pageType == 1) - rightR->setEnabled(false); - leftR->setEnabled(item != PresetLayout::nineparts); - if (item != PresetLayout::none) - linkMargins->setChecked(false); - linkMargins->setEnabled(item == PresetLayout::none || !presetCombo->isEnabled()); - connect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - connect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - connect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - connect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - m_savedPresetItem = item; -} - -void MarginWidget::setPageSize(const QString& pageSize) -{ - m_pageSize = pageSize; -} - -void MarginWidget::setMarginsToPrinterMargins() -{ - 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); - presetCombo->setCurrentIndex(PresetLayout::none); - - marginData.setTop(t); - marginData.setBottom(b); - marginData.setLeft(l); - marginData.setRight(r); - updateMarginSpinValues(); - - bottomR->setMaximum((qMax(0.0, m_pageHeight - t) * m_unitRatio)); - topR->setMaximum((qMax(0.0, m_pageHeight - b) * m_unitRatio)); - rightR->setMaximum((qMax(0.0, m_pageWidth - l) * m_unitRatio)); - leftR->setMaximum((qMax(0.0, m_pageWidth - r) * m_unitRatio)); - - rightR->setEnabled(true); - topR->setEnabled(true); - bottomR->setEnabled(true); -} - -double MarginWidget::top() const -{ - return marginData.top(); -} - -double MarginWidget::bottom() const -{ - return marginData.bottom(); -} - -double MarginWidget::left() const -{ - return marginData.left(); -} - -double MarginWidget::right() const -{ - return marginData.right(); -} - -void MarginWidget::setNewMargins(MarginStruct &m) -{ - disconnect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - disconnect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - disconnect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - disconnect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - marginData = m; - updateMarginSpinValues(); - connect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - connect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - connect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - connect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); -} - -void MarginWidget::setMarginPreset(int p) -{ - disconnect(presetCombo, SIGNAL(activated(int)), this, SLOT(setPreset())); - m_savedPresetItem = p; - presetCombo->setCurrentIndex(p); - if (m_savedPresetItem == PresetLayout::none) - m_savedMargins = marginData; - int item = presetCombo->currentIndex(); - presetCombo->setEnabled(m_facingPages); - bool restoringValues = false; - if ((item == PresetLayout::none) && (m_savedPresetItem != PresetLayout::none)) - { - restoringValues = true; - } - if (restoringValues || (presetCombo->needUpdate() && m_facingPages)) - { - rightR->setEnabled(restoringValues); - topR->setEnabled(restoringValues); - bottomR->setEnabled(restoringValues); - } - else - { - rightR->setEnabled(true); - topR->setEnabled(true); - bottomR->setEnabled(true); - } - if (m_pageType == 1) - rightR->setEnabled(false); - leftR->setEnabled(item != PresetLayout::nineparts); - if (item != PresetLayout::none) - linkMargins->setChecked(false); - linkMargins->setEnabled(item == PresetLayout::none); - connect(presetCombo, SIGNAL(activated(int)), this, SLOT(setPreset())); -} - -int MarginWidget::getMarginPreset() -{ - return presetCombo->currentIndex(); -} - -bool MarginWidget::getMarginsForAllPages() const -{ - return marginsForAllPages->isChecked(); -} - -bool MarginWidget::getMarginsForAllMasterPages() const -{ - return marginsForAllMasterPages->isChecked(); -} - -void MarginWidget::setNewBleeds(MarginStruct& b) -{ - disconnect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - BleedTop->setValue(b.top() * m_unitRatio); - BleedBottom->setValue(b.bottom() * m_unitRatio); - BleedLeft->setValue(b.left() * m_unitRatio); - BleedRight->setValue(b.right() * m_unitRatio); - connect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); -} - -double MarginWidget::topBleed() const -{ - return BleedTop->value() / m_unitRatio; -} - -double MarginWidget::bottomBleed() const -{ - return BleedBottom->value() / m_unitRatio; -} - -double MarginWidget::leftBleed() const -{ - return BleedLeft->value() / m_unitRatio; -} - -double MarginWidget::rightBleed() const -{ - return BleedRight->value() / m_unitRatio; -} - -const MarginStruct & MarginWidget::margins() const -{ - return marginData; -} - -void MarginWidget::slotLinkMargins() -{ - disconnect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - disconnect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - disconnect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - disconnect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - - double marginValue = leftR->value(); - if (leftR->hasFocus()) - { - leftR->clearFocus(); - marginValue = leftR->value(); - } - if (rightR->hasFocus()) - { - rightR->clearFocus(); - marginValue = rightR->value(); - } - if (topR->hasFocus()) - { - topR->clearFocus(); - marginValue = topR->value(); - } - if (bottomR->hasFocus()) - { - bottomR->clearFocus(); - marginValue = bottomR->value(); - } - - if (linkMargins->isChecked()) - { - leftR->setValue(marginValue); - bottomR->setValue(marginValue); - topR->setValue(marginValue); - rightR->setValue(marginValue); - double newVal = marginValue / m_unitRatio; - marginData.set(newVal, newVal, newVal, newVal); - } - - connect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - connect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - connect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - connect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - -} - -void MarginWidget::updateMarginSpinValues() -{ - topR->setValue(marginData.top() * m_unitRatio); - rightR->setValue(marginData.right() * m_unitRatio); - bottomR->setValue(marginData.bottom() * m_unitRatio); - leftR->setValue(marginData.left() * m_unitRatio); -} Property changes on: scribus/ui/marginwidget.cpp ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Author Date Id Revision \ No newline at end of property Index: scribus/ui/marginwidget.h =================================================================== --- scribus/ui/marginwidget.h (Revision 26264) +++ scribus/ui/marginwidget.h (nicht existent) @@ -1,178 +0,0 @@ -/* -For general Scribus (>=1.3.2) copyright and licensing information please refer -to the COPYING file provided with the program. Following this notice may exist -a copyright and/or license notice that predates the release of Scribus 1.3.2 -for which a new license (GPL+exception) is in place. -*/ -#ifndef MARGINWIDGET_H -#define MARGINWIDGET_H - -#include "scribusapi.h" -#include "scribusstructs.h" - -#include <QComboBox> -#include <QTabWidget> -#include "linkbutton.h" -#include "marginpresetlayout.h" - -class QCheckBox; -class QPushButton; -class QLabel; -class QGridLayout; -class QHBoxLayout; -class ScrSpinBox; - - -/*! \brief Widget for Margins setting. -Used e.g. in "New Doc Dialog" or "Preferences". -*/ -class SCRIBUS_API MarginWidget : public QTabWidget -{ - Q_OBJECT - -public: - /*! \brief It creates an user interface for base margin settings for the document. - \param parent Parent widget (used as standard in Qt) - \param title Title of the Group box - \param margs A reference to the margins in the preferences. - \param unitIndex and index of the unit combobox - \param showChangeAll show "apply to all pages" related items - */ - MarginWidget(QWidget* parent, const QString& title, const MarginStruct* margs, int unitIndex, bool showChangeAll = false, bool showBleeds = true); - ~MarginWidget() {} - /*! \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 and height */ - void setPageWidthHeight(double width, double height); - /*! \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); - /*! \brief Setup the widgets by new options */ - void setNewUnit(int newUnitIndex); - /*! \brief Set the page size for margin getting from cups */ - void setPageSize(const QString& pageSize); - - /*! \brief Margins - \retval MarginStruct data */ - const MarginStruct& margins() const; - /*! \brief Top Margin - \retval double margin size */ - double top() const; - /*! \brief Bottom Margin - \retval double margin size */ - double bottom() const; - /*! \brief Left Margin - \retval double margin size */ - double left() const; - /*! \brief Right Margin - \retval double margin size */ - double right() const; - - /*! \brief set new margin values for the dialog - It calls overridden setTop(), setBottom() etc. slots itself - via signals emitted from spinboxes. - \param m MarginStruct - */ - void setNewMargins(MarginStruct& m); - - /*! \brief Setup the presetCombo without changing the margin values, only used by tabdocument */ - void setMarginPreset(int p); - int getMarginPreset(); - - /*! \brief Top Bleed - \retval double bleed size */ - double topBleed() const; - /*! \brief Bottom Bleed - \retval double bleed size */ - double bottomBleed() const; - /*! \brief Left Bleed - \retval double bleed size */ - double leftBleed() const; - /*! \brief Right Bleed - \retval double bleed size */ - double rightBleed() const; - - /*! \brief set new bleed values for the dialog - \param b MarginStruct - */ - void setNewBleeds(MarginStruct& b); - - /*! \brief Return marginsForAllPages property - \retval bool true to apply for all pages */ - bool getMarginsForAllPages() const; - bool getMarginsForAllMasterPages() const; - -private: - /*! Tabs */ - QWidget *marginPage { nullptr }; - QWidget* bleedPage { nullptr }; - /*! Spinboxes */ - ScrSpinBox* topR { nullptr }; - ScrSpinBox* bottomR { nullptr }; - ScrSpinBox* rightR { nullptr }; - ScrSpinBox* leftR { nullptr }; - ScrSpinBox* BleedBottom { nullptr }; - ScrSpinBox* BleedLeft { nullptr }; - ScrSpinBox* BleedRight { nullptr }; - ScrSpinBox* BleedTop { nullptr }; - PresetLayout* presetCombo { nullptr }; - /*! Labels */ - QLabel* lText { nullptr }; - QLabel* rText { nullptr }; - QLabel* tText { nullptr }; - QLabel* bText { nullptr }; - QLabel* presetLabel { nullptr }; - QLabel* marginsForPages { nullptr }; - QLabel* BleedTxt1 { nullptr }; - QLabel* BleedTxt2 { nullptr }; - QLabel* BleedTxt3 { nullptr }; - QLabel* BleedTxt4 { nullptr }; - QCheckBox* marginsForAllPages { nullptr }; - QCheckBox* marginsForAllMasterPages { nullptr }; - QPushButton* usePrinterMarginsButton { nullptr }; - LinkButton* linkBleeds { nullptr }; - LinkButton* linkMargins { nullptr }; - - /*! \brief Margin values converted by unitRatio */ - MarginStruct marginData; - - /*! \brief Internally used page width */ - double m_pageWidth { 0.0 }; - /*! \brief Internally used page height */ - double m_pageHeight { 0.0 }; - -public slots: - /*! \brief Recompute the values after spinbox change */ - void setTop(); - void setBottom(); - void setLeft(); - void setRight(); - /*! \brief Recompute margins in PresetLayout combobox and disable/enable widgets. */ - void setPreset(); - void slotLinkBleeds(); - void slotLinkMargins(); - void changeBleeds(); - -protected slots: - virtual void setMarginsToPrinterMargins(); - -protected: - void updateMarginSpinValues(); - - QGridLayout* GroupLayout { nullptr }; - QHBoxLayout* marginsForPagesLayout { nullptr }; - QGridLayout* BleedGroupLayout { nullptr }; - - QString m_pageSize; - int m_unitIndex { 0 }; - double m_unitRatio { 1.0 }; - //! \brief if the outer facing palette points to the facing pages item - bool m_facingPages { false }; - bool m_useBleeds { false }; - int m_pageType { 0 }; - MarginStruct m_savedMargins; - int m_savedPresetItem { PresetLayout::none }; -}; - -#endif Property changes on: scribus/ui/marginwidget.h ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Author Date Id Revision \ No newline at end of property Index: scribus/ui/newdocdialog.cpp =================================================================== --- scribus/ui/newdocdialog.cpp (Revision 26264) +++ scribus/ui/newdocdialog.cpp (Arbeitskopie) @@ -12,6 +12,7 @@ #include <QHBoxLayout> #include <QVBoxLayout> +#include <QButtonGroup> #include <QCheckBox> #include <QComboBox> #include <QDir> @@ -29,14 +30,13 @@ #include <QStringList> #include <QTabWidget> #include <QToolTip> +#include <QVBoxLayout> -#include "scconfig.h" - #include "commonstrings.h" #include "filedialogeventcatcher.h" #include "fileloader.h" #include "iconmanager.h" -#include "marginwidget.h" +#include "newmarginwidget.h" #include "pagesize.h" #include "pagestructs.h" #include "prefsfile.h" @@ -43,63 +43,20 @@ #include "prefsmanager.h" #include "scrspinbox.h" #include "units.h" -#include "ui/delegates/sclistitemdelegate.h" +#include "ui/widgets/pagesizelist.h" -PageLayoutsWidget::PageLayoutsWidget(QWidget* parent) : - QListWidget(parent) -{ - setDragEnabled(false); - setViewMode(QListView::IconMode); - setFlow(QListView::LeftToRight); - setSortingEnabled(false); - setWrapping(false); - setWordWrap(true); - setAcceptDrops(false); - setDropIndicatorShown(false); - setDragDropMode(QAbstractItemView::NoDragDrop); - setResizeMode(QListView::Adjust); - setSelectionMode(QAbstractItemView::SingleSelection); - setFocusPolicy(Qt::NoFocus); - setIconSize(QSize(32, 32)); - clear(); - setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); - setGridSize(QSize(96, 96)); - setItemDelegate(new ScListItemDelegate(QListWidget::IconMode, QSize(32,32))); -} -void PageLayoutsWidget::arrangeIcons() -{ - int startY = 5; - int startX = 5; - int maxSizeY = 0; - - setResizeMode(QListView::Fixed); - - for (int i = 0; i < count(); ++i) - { - QListWidgetItem* itemWidget = item(i); - QRect itemRect = visualItemRect(itemWidget); - setPositionForIndex(QPoint(startX, startY), indexFromItem(itemWidget)); - startX += itemRect.width() + 5; - maxSizeY = qMax(maxSizeY, itemRect.height()); - } - - maxX = startX; - maxY = maxSizeY + 10; -} - -QSize PageLayoutsWidget::minimumSizeHint() const -{ - return QSize(maxX, maxY); -} - NewDocDialog::NewDocDialog(QWidget* parent, const QStringList& recentDocs, bool startUp, const QString& lang) : QDialog(parent), prefsManager(PrefsManager::instance()), m_onStartup(startUp) { + setupUi(this); + setObjectName(QString::fromLocal8Bit("NewDocumentWindow")); setModal(true); + IconManager &iconManager = IconManager::instance(); + m_unitIndex = prefsManager.appPrefs.docSetupPrefs.docUnitIndex; m_unitRatio = unitGetRatioFromIndex(m_unitIndex); m_unitSuffix = unitGetSuffixFromIndex(m_unitIndex); @@ -106,58 +63,35 @@ m_orientation = prefsManager.appPrefs.docSetupPrefs.pageOrientation; setWindowTitle( tr( "New Document" ) ); - setWindowIcon(IconManager::instance().loadIcon("AppIcon.png")); - if (startUp) - setContentsMargins(0, 0, 0, 0); - else - setContentsMargins(9, 9, 9, 9); - TabbedNewDocLayout = new QVBoxLayout( this ); - if (startUp) - TabbedNewDocLayout->setContentsMargins(9, 9, 9, 9); - else - TabbedNewDocLayout->setContentsMargins(0, 0, 0, 0); - TabbedNewDocLayout->setSpacing(6); + setWindowIcon(iconManager.loadIcon("AppIcon.png")); + + buttonVertical->setIcon(iconManager.loadIcon("page-orientation-vertical")); + buttonHorizontal->setIcon(iconManager.loadIcon("page-orientation-horizontal")); + createNewDocPage(); if (startUp) { - tabWidget = new QTabWidget( this ); - tabWidget->addTab(newDocFrame, tr("&New Document")); - createNewFromTempPage(); nftGui->setupSettings(lang); - tabWidget->addTab(newFromTempFrame, tr("New &from Template")); createOpenDocPage(); - tabWidget->addTab(openDocFrame, tr("Open &Existing Document")); recentDocList = recentDocs; - createRecentDocPage(); - tabWidget->addTab(recentDocFrame, tr("Open Recent &Document")); - TabbedNewDocLayout->addWidget(tabWidget); + createRecentDocPage(); + startUpDialog->setChecked(!prefsManager.appPrefs.uiPrefs.showStartupDialog); } else - TabbedNewDocLayout->addWidget(newDocFrame); - - Layout1 = new QHBoxLayout; - Layout1->setContentsMargins(0, 0, 0, 0); - Layout1->setSpacing(6); - if (startUp) { - startUpDialog = new QCheckBox( tr( "Do not show this dialog again" ), this ); - startUpDialog->setChecked(!prefsManager.appPrefs.uiPrefs.showStartupDialog); - Layout1->addWidget( startUpDialog ); + tabWidget->removeTab(3); + tabWidget->removeTab(2); + tabWidget->removeTab(1); } - QSpacerItem* spacer = new QSpacerItem( 2, 2, QSizePolicy::Expanding, QSizePolicy::Minimum ); - Layout1->addItem( spacer ); - buttonBox = new QDialogButtonBox(); - Layout1->addWidget(buttonBox); - okButton = new QPushButton( CommonStrings::tr_OK, this ); - okButton->setDefault( true ); - buttonBox->addButton(okButton, QDialogButtonBox::AcceptRole); - cancelButton = new QPushButton( CommonStrings::tr_Cancel, this ); - cancelButton->setAutoDefault( false ); - buttonBox->addButton(cancelButton, QDialogButtonBox::RejectRole); - TabbedNewDocLayout->addLayout( Layout1 ); + + + tabWidget->setCurrentIndex(0); + startUpDialog->setVisible(startUp); + //tooltips - pageSizeComboBox->setToolTip( tr( "Document page size, either a standard size or a custom size" ) ); - pageOrientationComboBox->setToolTip( tr( "Orientation of the document's pages" ) ); + listPageFormats->setToolTip( tr( "Document page size, either a standard size or a custom size" ) ); + buttonVertical->setToolTip( tr( "Vertical orientation of the document's pages" ) ); + buttonHorizontal->setToolTip( tr( "Horizontal orientation of the document's pages" ) ); widthSpinBox->setToolTip( tr( "Width of the document's pages, editable if you have chosen a custom page size" ) ); heightSpinBox->setToolTip( tr( "Height of the document's pages, editable if you have chosen a custom page size" ) ); pageCountSpinBox->setToolTip( tr( "Initial number of pages of the document" ) ); @@ -170,15 +104,16 @@ connect(buttonBox, &QDialogButtonBox::accepted, this, &NewDocDialog::ExitOK); connect(buttonBox, &QDialogButtonBox::rejected, this, &NewDocDialog::reject); - connect(pageSizeComboBox, SIGNAL(textActivated(QString)), this, SLOT(setPageSize(QString))); - connect(pageOrientationComboBox, SIGNAL(activated(int)), this, SLOT(setOrientation(int))); + connect(pageOrientationButtons, &QButtonGroup::idClicked, this, &NewDocDialog::setOrientation); 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(layoutsView, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - connect(layoutsView, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - connect(layoutsView, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - connect(layoutsView, SIGNAL(itemPressed(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); + connect(listPageFormats, &PageSizeList::itemClicked, this, &NewDocDialog::changePageSize); + connect(pageSizeSelector, &PageSizeSelector::pageCategoryChanged, this, &NewDocDialog::changeCategory); + connect(pageLayouts, &PageLayouts::schemeChanged, this, &NewDocDialog::changeScheme); + connect(pageLayouts, &PageLayouts::firstPageChanged, this, &NewDocDialog::changeFirstPage); + connect(marginGroup, &NewMarginWidget::marginChanged, this, &NewDocDialog::changeMargin); + connect(bleedGroup, &NewMarginWidget::marginChanged, this, &NewDocDialog::changeMargin); if (startUp) { connect(nftGui, SIGNAL(leaveOK()), this, SLOT(ExitOK())); @@ -189,180 +124,90 @@ void NewDocDialog::createNewDocPage() { - newDocFrame = new QFrame(this); + 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; - pageSizeGroupBox = new QGroupBox(newDocFrame ); - pageSizeGroupBox->setTitle( tr( "Document Layout" ) ); - pageSizeGroupBoxLayout = new QGridLayout( pageSizeGroupBox ); - pageSizeGroupBoxLayout->setContentsMargins(9, 9, 9, 9); - pageSizeGroupBoxLayout->setSpacing(6); - pageSizeGroupBoxLayout->setAlignment( Qt::AlignTop ); + pageOrientationButtons = new QButtonGroup(); + pageOrientationButtons->addButton(buttonVertical, 0); + pageOrientationButtons->addButton(buttonHorizontal, 1); + pageOrientationButtons->button(orientation)->setChecked(true); - layoutsView = new PageLayoutsWidget( pageSizeGroupBox ); - layoutsView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); - for (int i = 0; i < prefsManager.appPrefs.pageSets.count(); ++i) - { - QListWidgetItem *ic; - QString psname = CommonStrings::translatePageSetString(prefsManager.appPrefs.pageSets[i].Name); - if (i == 0) - { - ic = new QListWidgetItem( IconManager::instance().loadIcon("32/page-simple.png"), psname, layoutsView ); - ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - } - else if (i == 1) - { - ic = new QListWidgetItem( IconManager::instance().loadIcon("32/page-doublesided.png"), psname, layoutsView ); - ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - } - else if (i == 2 && prefsManager.appPrefs.docSetupPrefs.pagePositioning == 2) - { - ic = new QListWidgetItem( IconManager::instance().loadIcon("32/page-3fold.png"), psname, layoutsView ); - ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - } - else if (i == 3 && prefsManager.appPrefs.docSetupPrefs.pagePositioning == 3) - { - ic = new QListWidgetItem( IconManager::instance().loadIcon("32/page-4fold.png"), psname, layoutsView ); - ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - } - } - layoutsView->arrangeIcons(); - pageSizeGroupBoxLayout->addWidget( layoutsView, 0, 0, 5, 1 ); - layoutsView->arrangeIcons(); + listPageFormats->setFormat(pageSize); + listPageFormats->setOrientation(orientation); + listPageFormats->setCategory(PageSizeInfo::Favorite); - TextLabel1 = new QLabel( tr( "&Size:" ), pageSizeGroupBox ); - pageSizeGroupBoxLayout->addWidget( TextLabel1, 0, 1 ); - PageSize ps(prefsManager.appPrefs.docSetupPrefs.pageSize); - pageSizeComboBox = new QComboBox( pageSizeGroupBox ); - pageSizeComboBox->addItems(ps.activeSizeTRList()); - pageSizeComboBox->addItem( CommonStrings::trCustomPageSize ); - pageSizeComboBox->setEditable(false); - TextLabel1->setBuddy(pageSizeComboBox); - pageSizeGroupBoxLayout->addWidget(pageSizeComboBox, 0, 2 ); - TextLabel2 = new QLabel( tr( "Orie&ntation:" ), pageSizeGroupBox ); - pageSizeGroupBoxLayout->addWidget( TextLabel2, 1, 1 ); - pageOrientationComboBox = new QComboBox( pageSizeGroupBox ); - pageOrientationComboBox->addItem( tr( "Portrait" ) ); - pageOrientationComboBox->addItem( tr( "Landscape" ) ); - pageOrientationComboBox->setEditable(false); - pageOrientationComboBox->setCurrentIndex(prefsManager.appPrefs.docSetupPrefs.pageOrientation); - TextLabel2->setBuddy(pageOrientationComboBox); - pageSizeGroupBoxLayout->addWidget( pageOrientationComboBox, 1, 2 ); + pageSizeSelector->setHasFormatSelector(false); + pageSizeSelector->setHasCustom(false); + pageSizeSelector->setPageSize(pageSize); + pageSizeSelector->setCurrentCategory(PageSizeInfo::Favorite); - TextLabel1_2 = new QLabel( tr( "&Width:" ), pageSizeGroupBox ); - pageSizeGroupBoxLayout->addWidget(TextLabel1_2, 2, 1 ); - widthSpinBox = new ScrSpinBox(pts2value(1.0, m_unitIndex), 16777215, pageSizeGroupBox, m_unitIndex ); + widthSpinBox->setMinimum(pts2value(1.0, m_unitIndex)); + widthSpinBox->setMaximum(16777215); + widthSpinBox->setNewUnit(m_unitIndex); widthSpinBox->setSuffix(m_unitSuffix); - TextLabel1_2->setBuddy(widthSpinBox); - pageSizeGroupBoxLayout->addWidget(widthSpinBox, 2, 2 ); - TextLabel2_2 = new QLabel( tr( "&Height:" ), pageSizeGroupBox ); - pageSizeGroupBoxLayout->addWidget(TextLabel2_2, 3, 1 ); - heightSpinBox = new ScrSpinBox( pts2value(1.0, m_unitIndex), 16777215, pageSizeGroupBox, m_unitIndex ); + + heightSpinBox->setMinimum(pts2value(1.0, m_unitIndex)); + heightSpinBox->setMaximum(16777215); + heightSpinBox->setNewUnit(m_unitIndex); heightSpinBox->setSuffix(m_unitSuffix); - TextLabel2_2->setBuddy(heightSpinBox); - pageSizeGroupBoxLayout->addWidget(heightSpinBox, 3, 2 ); - unitOfMeasureLabel = new QLabel( tr( "&Default Unit:" ), pageSizeGroupBox ); - unitOfMeasureComboBox = new QComboBox( pageSizeGroupBox ); unitOfMeasureComboBox->addItems(unitGetTextUnitList()); unitOfMeasureComboBox->setCurrentIndex(m_unitIndex); unitOfMeasureComboBox->setEditable(false); - unitOfMeasureLabel->setBuddy(unitOfMeasureComboBox); - pageSizeGroupBoxLayout->addWidget( unitOfMeasureLabel, 4, 1 ); - pageSizeGroupBoxLayout->addWidget( unitOfMeasureComboBox, 4, 2 ); MarginStruct marg(prefsManager.appPrefs.docSetupPrefs.margins); - marginGroup = new MarginWidget(newDocFrame, tr( "Margin Guides" ), &marg, m_unitIndex ); - marginGroup->setPageWidthHeight(prefsManager.appPrefs.docSetupPrefs.pageWidth, prefsManager.appPrefs.docSetupPrefs.pageHeight); - marginGroup->setFacingPages(!(prefsManager.appPrefs.docSetupPrefs.pagePositioning == singlePage)); - widthSpinBox->setValue(prefsManager.appPrefs.docSetupPrefs.pageWidth * m_unitRatio); - heightSpinBox->setValue(prefsManager.appPrefs.docSetupPrefs.pageHeight * m_unitRatio); - QStringList pageSizes = ps.activeSizeTRList(); - int sizeIndex = pageSizes.indexOf(ps.nameTR()); - if (sizeIndex != -1) - pageSizeComboBox->setCurrentIndex(sizeIndex); - else - pageSizeComboBox->setCurrentIndex(pageSizeComboBox->count() - 1); - marginGroup->setPageSize(pageSizeComboBox->currentText()); - marginGroup->setNewBleeds(prefsManager.appPrefs.docSetupPrefs.bleeds); + marginGroup->setup(marg, !(pagePositioning == singlePage), m_unitIndex, NewMarginWidget::MarginWidgetFlags); + marginGroup->setPageHeight(pageHeight); + marginGroup->setPageWidth(pageWidth); + marginGroup->setFacingPages(!(pagePositioning == singlePage)); + + MarginStruct bleed; + bleed.resetToZero(); + + bleedGroup->setup(bleed, !(pagePositioning == singlePage), m_unitIndex, NewMarginWidget::BleedWidgetFlags); + bleedGroup->setPageHeight(pageHeight); + bleedGroup->setPageWidth(pageWidth); + bleedGroup->setFacingPages(!(pagePositioning == singlePage)); + widthSpinBox->setValue(pageWidth * m_unitRatio); + heightSpinBox->setValue(pageHeight * m_unitRatio); + + marginGroup->setPageSize(pageSize); marginGroup->setMarginPreset(prefsManager.appPrefs.docSetupPrefs.marginPreset); + bleedGroup->setPageSize(pageSize); + bleedGroup->setMarginPreset(prefsManager.appPrefs.docSetupPrefs.marginPreset); - optionsGroupBox = new QGroupBox( newDocFrame ); - optionsGroupBox->setTitle( tr( "Options" ) ); - optionsGroupBoxLayout = new QGridLayout( optionsGroupBox ); - optionsGroupBoxLayout->setSpacing(6); - optionsGroupBoxLayout->setContentsMargins(9, 9, 9, 9); - optionsGroupBoxLayout->setAlignment( Qt::AlignTop ); - pageCountLabel = new QLabel( tr( "N&umber of Pages:" ), optionsGroupBox ); - - pageCountSpinBox = new QSpinBox( optionsGroupBox ); pageCountSpinBox->setMaximum( 10000 ); pageCountSpinBox->setMinimum( 1 ); - pageCountLabel->setBuddy(pageCountSpinBox); - optionsGroupBoxLayout->addWidget(pageCountLabel, 0, 0, Qt::AlignLeft); - optionsGroupBoxLayout->addWidget(pageCountSpinBox, 0, 1); - layoutLabel1 = new QLabel( optionsGroupBox ); - layoutLabel1->setText( tr( "First Page is:" ) ); - firstPage = new QComboBox( optionsGroupBox ); - firstPage->clear(); - selectItem(prefsManager.appPrefs.docSetupPrefs.pagePositioning); - optionsGroupBoxLayout->addWidget(layoutLabel1, 1, 0, Qt::AlignLeft); - optionsGroupBoxLayout->addWidget(firstPage, 1, 1); - firstPage->setCurrentIndex(prefsManager.appPrefs.pageSets[prefsManager.appPrefs.docSetupPrefs.pagePositioning].FirstPage); + pageLayouts->updateSchemeSelector(prefsManager.appPrefs.pageSets, prefsManager.appPrefs.pageSets[pagePositioning].FirstPage); - setDocLayout(prefsManager.appPrefs.docSetupPrefs.pagePositioning); - setSize(prefsManager.appPrefs.docSetupPrefs.pageSize); - setOrientation(prefsManager.appPrefs.docSetupPrefs.pageOrientation); + setDocLayout(pagePositioning); + setSize(pageSize); + setOrientation(orientation); - autoTextFrame = new QCheckBox( optionsGroupBox ); - autoTextFrame->setText( tr( "&Automatic Text Frames" ) ); - optionsGroupBoxLayout->addWidget(autoTextFrame, 2, 0, 1, 2, Qt::AlignLeft); - - TextLabel3 = new QLabel( tr( "Colu&mns:" ), optionsGroupBox ); - numberOfCols = new QSpinBox( optionsGroupBox ); numberOfCols->setButtonSymbols( QSpinBox::UpDownArrows ); numberOfCols->setMinimum( 1 ); numberOfCols->setValue( 1 ); - TextLabel3->setBuddy(numberOfCols); - optionsGroupBoxLayout->addWidget(TextLabel3, 3, 0, Qt::AlignLeft); - optionsGroupBoxLayout->addWidget(numberOfCols, 3, 1); - TextLabel4 = new QLabel( tr( "&Gap:" ), optionsGroupBox ); - Distance = new ScrSpinBox( 0, 1000, optionsGroupBox, m_unitIndex ); + Distance->setMinimum(0); + Distance->setMaximum(1000); + Distance->setNewUnit(m_unitIndex); Distance->setValue(11 * m_unitRatio); - TextLabel4->setBuddy(Distance); - optionsGroupBoxLayout->addWidget(TextLabel4, 4, 0, Qt::AlignLeft); - optionsGroupBoxLayout->addWidget(Distance, 4, 1); - firstPage->setMinimumWidth(Distance->width()); - - TextLabel3->setEnabled(false); - TextLabel4->setEnabled(false); + labelColumns->setEnabled(false); + labelGap->setEnabled(false); Distance->setEnabled(false); numberOfCols->setEnabled(false); - startDocSetup = new QCheckBox( optionsGroupBox ); + startDocSetup->setText( tr( "Show Document Settings After Creation" ) ); startDocSetup->setChecked(false); - optionsGroupBoxLayout->addWidget(startDocSetup, 5, 0, 1, 2, Qt::AlignLeft); - NewDocLayout = new QGridLayout( newDocFrame ); - if (m_onStartup) - NewDocLayout->setContentsMargins(9, 9, 9, 9); - else - NewDocLayout->setContentsMargins(0, 0, 0, 0); - NewDocLayout->setSpacing(6); - NewDocLayout->addWidget( marginGroup, 1, 0 ); - NewDocLayout->addWidget( optionsGroupBox, 1, 1 ); - NewDocLayout->addWidget( pageSizeGroupBox, 0, 0, 1, 2); -} + sectionBleeds->collapse(); + sectionTextFrame->collapse(); -void NewDocDialog::createNewFromTempPage() -{ - newFromTempFrame = new QFrame(this); - verticalLayout = new QVBoxLayout(newFromTempFrame); - verticalLayout->setContentsMargins(9, 9, 9, 9); - nftGui = new nftwidget(newFromTempFrame); - verticalLayout->addWidget(nftGui); } void NewDocDialog::createOpenDocPage() @@ -376,10 +221,9 @@ docDir = docContext->get("docsopen", "."); QString formats(FileLoader::getLoadFilterString()); // formats.remove("PDF (*.pdf *.PDF);;"); - openDocFrame = new QFrame(this); - openDocLayout = new QVBoxLayout(openDocFrame); + QVBoxLayout *openDocLayout = new QVBoxLayout(tab_3); openDocLayout->setContentsMargins(0, 0, 0, 0); - openDocLayout->setSpacing(6); + openDocLayout->setSpacing(4); m_selectedFile = ""; // With Qt 5.15 we have to be in careful so that new document dialog doesn't display too large on startup. @@ -386,7 +230,7 @@ // To avoid this we have to use QFileDialog(QWidget *parent, Qt::WindowFlags flags) constructor, then // set the QFileDialog::DontUseNativeDialog option as early as possible, and nonetheless set again // the Qt::Widget window flag before adding the widget to layout. - fileDialog = new QFileDialog(openDocFrame, Qt::Widget); + fileDialog = new QFileDialog(tab_3, Qt::Widget); fileDialog->setOption(QFileDialog::DontUseNativeDialog); fileDialog->setWindowTitle(tr("Open")); fileDialog->setDirectory(docDir); @@ -404,6 +248,7 @@ fileDialog->setWindowFlags(Qt::Widget); openDocLayout->addWidget(fileDialog); + FileDialogEventCatcher* keyCatcher = new FileDialogEventCatcher(this); QList<QListView *> listViews = fileDialog->findChildren<QListView *>(); for (auto listView : std::as_const(listViews)) @@ -426,12 +271,6 @@ void NewDocDialog::createRecentDocPage() { - recentDocFrame = new QFrame(this); - recentDocLayout = new QVBoxLayout(recentDocFrame); - recentDocLayout->setContentsMargins(9, 9, 9, 9); - recentDocLayout->setSpacing(6); - recentDocListBox = new QListWidget(recentDocFrame); - recentDocLayout->addWidget(recentDocListBox); int max = qMin(prefsManager.appPrefs.uiPrefs.recentDocCount, recentDocList.count()); for (int i = 0; i < max; ++i) recentDocListBox->addItem(QDir::toNativeSeparators(recentDocList[i])); @@ -443,16 +282,20 @@ { m_pageWidth = widthSpinBox->value() / m_unitRatio; marginGroup->setPageWidth(m_pageWidth); - QString psText = pageSizeComboBox->currentText(); - if (psText != CommonStrings::trCustomPageSize && psText != CommonStrings::customPageSize) - pageSizeComboBox->setCurrentIndex(pageSizeComboBox->count() - 1); + bleedGroup->setPageWidth(m_pageWidth); + listPageFormats->clearSelection(); + m_pageSize = CommonStrings::customPageSize; + pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_pageSize, m_choosenLayout, pageLayouts->firstPage()); + int newOrientation = (widthSpinBox->value() > heightSpinBox->value()) ? landscapePage : portraitPage; if (newOrientation != m_orientation) { - pageOrientationComboBox->blockSignals(true); - pageOrientationComboBox->setCurrentIndex(newOrientation); - pageOrientationComboBox->blockSignals(false); m_orientation = newOrientation; + + QSignalBlocker sigOri(pageOrientationButtons); + pageOrientationButtons->button(newOrientation)->setChecked(true); + QSignalBlocker sigFormats(listPageFormats); + listPageFormats->setOrientation(m_orientation); } } @@ -460,68 +303,64 @@ { m_pageHeight = heightSpinBox->value() / m_unitRatio; marginGroup->setPageHeight(m_pageHeight); - QString psText = pageSizeComboBox->currentText(); - if (psText != CommonStrings::trCustomPageSize && psText != CommonStrings::customPageSize) - pageSizeComboBox->setCurrentIndex(pageSizeComboBox->count() - 1); + bleedGroup->setPageHeight(m_pageHeight); + listPageFormats->clearSelection(); + m_pageSize = CommonStrings::customPageSize; + pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_pageSize, m_choosenLayout, pageLayouts->firstPage()); + int newOrientation = (widthSpinBox->value() > heightSpinBox->value()) ? landscapePage : portraitPage; if (newOrientation != m_orientation) { - pageOrientationComboBox->blockSignals(true); - pageOrientationComboBox->setCurrentIndex(newOrientation); - pageOrientationComboBox->blockSignals(false); m_orientation = newOrientation; + + QSignalBlocker sigOri(pageOrientationButtons); + pageOrientationButtons->button(newOrientation)->setChecked(true); + QSignalBlocker sigFormats(listPageFormats); + listPageFormats->setOrientation(m_orientation); } } void NewDocDialog::selectItem(uint nr) { - disconnect(layoutsView, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - disconnect(layoutsView, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - disconnect(layoutsView, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - disconnect(layoutsView, SIGNAL(itemPressed(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - if (nr > 0) - { - const QStringList& pageNames = prefsManager.appPrefs.pageSets[nr].pageNames; - firstPage->setEnabled(true); - firstPage->clear(); - for (auto pNames = pageNames.begin(); pNames != pageNames.end(); ++pNames) - firstPage->addItem(CommonStrings::translatePageSetLocString((*pNames))); - } - else - { - firstPage->clear(); - firstPage->addItem(" "); - firstPage->setEnabled(false); - } - layoutsView->setCurrentRow(nr); - layoutsView->item(nr)->setSelected(true); - connect(layoutsView, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - connect(layoutsView, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - connect(layoutsView, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - connect(layoutsView, SIGNAL(itemPressed(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); + pageLayouts->setScheme(nr); + pageLayouts->setFirstPage(nr); } -void NewDocDialog::itemSelected(QListWidgetItem* ic) +void NewDocDialog::changePageSize(QListWidgetItem *ic) { if (ic == nullptr) return; - selectItem(layoutsView->row(ic)); - setDocLayout(layoutsView->row(ic)); + + int unit = ic->data(Qt::UserRole + 1).toInt(); + QString size = ic->data(Qt::UserRole + 3).toString(); + + setUnit(unit); + setPageSize(size); + + QSignalBlocker sig(unitOfMeasureComboBox); + unitOfMeasureComboBox->setCurrentIndex(unit); + } +void NewDocDialog::changeScheme(int ic) +{ + selectItem(ic); + setDocLayout(ic); +} + void NewDocDialog::handleAutoFrame() { if (autoTextFrame->isChecked()) { - TextLabel3->setEnabled(true); - TextLabel4->setEnabled(true); + labelColumns->setEnabled(true); + labelGap->setEnabled(true); Distance->setEnabled(true); numberOfCols->setEnabled(true); } else { - TextLabel3->setEnabled(false); - TextLabel4->setEnabled(false); + labelColumns->setEnabled(false); + labelGap->setEnabled(false); Distance->setEnabled(false); numberOfCols->setEnabled(false); } @@ -547,6 +386,9 @@ marginGroup->setNewUnit(m_unitIndex); marginGroup->setPageHeight(m_pageHeight); marginGroup->setPageWidth(m_pageWidth); + bleedGroup->setNewUnit(m_unitIndex); + bleedGroup->setPageHeight(m_pageHeight); + bleedGroup->setPageWidth(m_pageWidth); connect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double))); connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double))); } @@ -555,10 +397,10 @@ { m_pageWidth = widthSpinBox->value() / m_unitRatio; m_pageHeight = heightSpinBox->value() / m_unitRatio; - m_bleedBottom = marginGroup->bottomBleed(); - m_bleedTop = marginGroup->topBleed(); - m_bleedLeft = marginGroup->leftBleed(); - m_bleedRight = marginGroup->rightBleed(); + m_bleedBottom = bleedGroup->margins().bottom(); + m_bleedTop = bleedGroup->margins().top(); + m_bleedLeft = bleedGroup->margins().left(); + m_bleedRight = bleedGroup->margins().right(); if (m_onStartup) { m_tabSelected = tabWidget->currentIndex(); @@ -612,16 +454,14 @@ } // #869 pv - defined constants added + code repeat (check w/h) (ori == portraitPage) ? m_orientation = portraitPage : m_orientation = landscapePage; - if (pageSizeComboBox->currentText() == CommonStrings::trCustomPageSize) - { - if (widthSpinBox->value() > heightSpinBox->value()) - pageOrientationComboBox->setCurrentIndex(landscapePage); - else - pageOrientationComboBox->setCurrentIndex(portraitPage); - } + listPageFormats->setOrientation(ori); // end of #869 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, pageLayouts->firstPage()); + connect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double))); connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double))); } @@ -628,14 +468,13 @@ void NewDocDialog::setPageSize(const QString &size) { - if (size == CommonStrings::trCustomPageSize) - setSize(size); - else - { - setSize(size); - setOrientation(pageOrientationComboBox->currentIndex()); - } + setSize(size); + + if (size != CommonStrings::customPageSize) + setOrientation(pageOrientationButtons->checkedId()); + marginGroup->setPageSize(size); + bleedGroup->setPageSize(size); } void NewDocDialog::setSize(const QString& gr) @@ -642,6 +481,7 @@ { 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))); @@ -653,7 +493,7 @@ else { PageSize ps2(gr); - if (pageOrientationComboBox->currentIndex() == portraitPage) + if (pageOrientationButtons->checkedId() == portraitPage) { m_pageWidth = ps2.width(); m_pageHeight = ps2.height(); @@ -668,15 +508,23 @@ 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, pageLayouts->firstPage()); + connect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double))); connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double))); + } void NewDocDialog::setDocLayout(int layout) { marginGroup->setFacingPages(layout != singlePage); + bleedGroup->setFacingPages(layout != singlePage); m_choosenLayout = layout; - firstPage->setCurrentIndex(prefsManager.appPrefs.pageSets[m_choosenLayout].FirstPage); + pageLayouts->setScheme(m_choosenLayout); + pageLayouts->setFirstPage(prefsManager.appPrefs.pageSets[m_choosenLayout].FirstPage); + pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_pageSize, m_choosenLayout, pageLayouts->firstPage()); } void NewDocDialog::recentDocListBox_doubleClicked() @@ -698,7 +546,7 @@ setWindowTitle(tr("Open Recent Document")); else setWindowTitle(tr("New Document")); - okButton->setEnabled(tab!=2); + //okButton->setEnabled(tab!=2); } void NewDocDialog::locationDropped(const QString& fileUrl) @@ -750,5 +598,29 @@ void NewDocDialog::openFileDialogFileClicked(const QString& path) { - okButton->setEnabled(!path.isEmpty()); + //okButton->setEnabled(!path.isEmpty()); } + +void NewDocDialog::changeMargin(MarginStruct margin) +{ + pagePreview->setMargins(margin); +} + +void NewDocDialog::changeBleed(MarginStruct bleed) +{ + pagePreview->setBleeds(bleed); +} + +void NewDocDialog::changeFirstPage(int firstPage) +{ + pagePreview->setFirstPage(firstPage); +} + +void NewDocDialog::changeCategory(PageSizeInfo::Category category) +{ + if (listPageFormats->category() == category) + return; + + listPageFormats->setFormat(m_pageSize); + listPageFormats->setCategory(category); +} Index: scribus/ui/newdocdialog.h =================================================================== --- scribus/ui/newdocdialog.h (Revision 26264) +++ scribus/ui/newdocdialog.h (Arbeitskopie) @@ -33,31 +33,19 @@ #include "ui/customfdialog.h" #include "ui/nftwidget.h" +#include "ui_newdocdialog.h" + class PrefsManager; -class MarginWidget; +class NewMarginWidget; class ScrSpinBox; class QFileDialog; -class SCRIBUS_API PageLayoutsWidget : public QListWidget +class SCRIBUS_API NewDocDialog : public QDialog, public Ui::newDocDialog { Q_OBJECT public: - PageLayoutsWidget(QWidget* parent); - ~PageLayoutsWidget() = default; - void arrangeIcons(); - QSize minimumSizeHint() const override; - int maxX {0}; - int maxY {0}; -}; - -class SCRIBUS_API NewDocDialog : public QDialog -{ - Q_OBJECT - -public: - //! \brief Indexes of the dialog's tabs. enum { NewDocumentTab = 0, @@ -70,48 +58,12 @@ ~NewDocDialog() = default; void createNewDocPage(); - void createNewFromTempPage(); void createOpenDocPage(); void createRecentDocPage(); void setSize(const QString& gr); + QString pageSizeName() { return m_pageSize; }; - QTabWidget* tabWidget {nullptr}; - QFrame* newDocFrame {nullptr}; - PageLayoutsWidget* layoutsView {nullptr}; - QLabel* layoutLabel1 {nullptr}; - QComboBox* firstPage {nullptr}; - QGroupBox* pageSizeGroupBox {nullptr}; - MarginWidget* marginGroup {nullptr}; - QGroupBox* optionsGroupBox {nullptr}; - QLabel* TextLabel1 {nullptr}; - QLabel* TextLabel2 {nullptr}; - QLabel* TextLabel3 {nullptr}; - QLabel* TextLabel4 {nullptr}; - QLabel* TextLabel1_2 {nullptr}; - QLabel* TextLabel1_3 {nullptr}; - QLabel* pageCountLabel {nullptr}; - QLabel* TextLabel2_2 {nullptr}; - QLabel* unitOfMeasureLabel {nullptr}; - QComboBox* pageSizeComboBox {nullptr}; - QComboBox* pageOrientationComboBox {nullptr}; - QComboBox* unitOfMeasureComboBox {nullptr}; - QCheckBox* startUpDialog {nullptr}; - QCheckBox* autoTextFrame {nullptr}; - QCheckBox* startDocSetup {nullptr}; - ScrSpinBox* Distance {nullptr}; - QSpinBox* numberOfCols {nullptr}; - QSpinBox* pageCountSpinBox {nullptr}; - ScrSpinBox* widthSpinBox {nullptr}; - ScrSpinBox* heightSpinBox {nullptr}; - QFrame* openDocFrame {nullptr}; QFileDialog *fileDialog {nullptr}; - QFrame* newFromTempFrame {nullptr}; - nftwidget *nftGui {nullptr}; - QFrame* recentDocFrame {nullptr}; - QListWidget* recentDocListBox {nullptr}; - QDialogButtonBox* buttonBox {nullptr}; - QPushButton* okButton {nullptr}; - QPushButton* cancelButton {nullptr}; bool onStartup() const { return m_onStartup;} int tabSelected() const { return m_tabSelected;} @@ -134,8 +86,7 @@ public slots: void setHeight(double v); void setWidth(double v); - void selectItem(uint nr); - void itemSelected(QListWidgetItem* ic); + void selectItem(uint nr); void handleAutoFrame(); void setDistance(double v); void setUnit(int u); @@ -156,17 +107,18 @@ void gotoHomeDirectory(); void openFileDialogFileClicked(const QString &path); +private slots: + void changeMargin(MarginStruct margin); + void changeBleed(MarginStruct bleed); + void changeFirstPage(int firstPage); + void changeCategory(PageSizeInfo::Category category); + void changePageSize(QListWidgetItem* ic); + void changeScheme(int ic); + protected: - QVBoxLayout* TabbedNewDocLayout {nullptr}; - QHBoxLayout* Layout1 {nullptr}; - QGridLayout* NewDocLayout {nullptr}; - QGridLayout* pageSizeGroupBoxLayout {nullptr}; - QGridLayout* optionsGroupBoxLayout {nullptr}; - QVBoxLayout* openDocLayout {nullptr}; - QVBoxLayout* recentDocLayout {nullptr}; - QVBoxLayout *verticalLayout {nullptr}; PrefsManager& prefsManager; QStringList recentDocList; + QButtonGroup* pageOrientationButtons; double m_unitRatio { 1.0 }; int m_orientation { 0 }; @@ -176,6 +128,7 @@ 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 }; Index: scribus/ui/newdocdialog.ui =================================================================== --- scribus/ui/newdocdialog.ui (nicht existent) +++ scribus/ui/newdocdialog.ui (Arbeitskopie) @@ -0,0 +1,755 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>newDocDialog</class> + <widget class="QDialog" name="newDocDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>938</width> + <height>606</height> + </rect> + </property> + <property name="windowTitle"> + <string>Dialog</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QTabWidget" name="tabWidget"> + <property name="currentIndex"> + <number>0</number> + </property> + <property name="tabBarAutoHide"> + <bool>true</bool> + </property> + <widget class="QWidget" name="tab"> + <attribute name="title"> + <string>New Document</string> + </attribute> + <layout class="QGridLayout" name="gridLayout" columnstretch="1,0,0"> + <property name="leftMargin"> + <number>8</number> + </property> + <property name="topMargin"> + <number>8</number> + </property> + <property name="rightMargin"> + <number>8</number> + </property> + <property name="bottomMargin"> + <number>8</number> + </property> + <property name="spacing"> + <number>4</number> + </property> + <item row="1" column="0"> + <widget class="PageSizeList" name="listPageFormats"/> + </item> + <item row="3" column="0"> + <widget class="QCheckBox" name="startDocSetup"> + <property name="text"> + <string>Show Document Settings After Creation</string> + </property> + </widget> + </item> + <item row="0" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_8"> + <property name="spacing"> + <number>4</number> + </property> + <item> + <widget class="PageSizeSelector" name="pageSizeSelector" native="true"/> + </item> + <item> + <spacer name="horizontalSpacer_4"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>16</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QComboBox" name="unitOfMeasureComboBox"/> + </item> + </layout> + </item> + <item row="0" column="1" rowspan="3" colspan="2"> + <widget class="QScrollArea" name="scrollArea"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>380</width> + <height>0</height> + </size> + </property> + <property name="frameShape"> + <enum>QFrame::Shape::NoFrame</enum> + </property> + <property name="widgetResizable"> + <bool>true</bool> + </property> + <property name="alignment"> + <set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set> + </property> + <widget class="QWidget" name="scrollAreaWidgetContents"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>366</width> + <height>531</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout_7"> + <property name="spacing"> + <number>0</number> + </property> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="SectionContainer" name="sectionPreview"> + <property name="title" stdset="0"> + <string>Preview</string> + </property> + <widget class="QWidget" name="page_5"> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <property name="spacing"> + <number>0</number> + </property> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="PageSizePreview" name="pagePreview" native="true"> + <property name="minimumSize"> + <size> + <width>120</width> + <height>120</height> + </size> + </property> + </widget> + </item> + </layout> + </widget> + </widget> + </item> + <item> + <widget class="SectionContainer" name="sectionDocument"> + <property name="title" stdset="0"> + <string>Document</string> + </property> + <widget class="QWidget" name="page"> + <layout class="QVBoxLayout" name="verticalLayout_6"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_10"> + <item> + <widget class="FormWidget" name="labelPageWidth"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Width</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_9"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="ScrSpinBox" name="widthSpinBox"/> + </item> + </layout> + </widget> + </item> + <item> + <widget class="FormWidget" name="labelPageHeight"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Height</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_11"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="ScrSpinBox" name="heightSpinBox"/> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_5"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_12" stretch="0,0,0,0,0,1"> + <item> + <widget class="FormWidget" name="pageCountLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Pages</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QSpinBox" name="pageCountSpinBox"/> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_7"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Policy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>16</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="FormWidget" name="formWidget"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Orientation</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <property name="spacing"> + <number>4</number> + </property> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QToolButton" name="buttonVertical"> + <property name="text"> + <string/> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="autoExclusive"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="buttonHorizontal"> + <property name="text"> + <string/> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="autoExclusive"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_8"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Policy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>16</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="PageLayouts" name="pageLayouts" native="true"/> + </item> + <item> + <spacer name="horizontalSpacer_6"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </widget> + </widget> + </item> + <item> + <widget class="SectionContainer" name="sectionMargins"> + <property name="title" stdset="0"> + <string>Margins</string> + </property> + <widget class="QWidget" name="page_2"> + <layout class="QVBoxLayout" name="verticalLayout_8"> + <item> + <widget class="NewMarginWidget" name="marginGroup" native="true"/> + </item> + </layout> + </widget> + </widget> + </item> + <item> + <widget class="SectionContainer" name="sectionBleeds"> + <property name="title" stdset="0"> + <string>Bleeds</string> + </property> + <widget class="QWidget" name="page_3"> + <layout class="QVBoxLayout" name="verticalLayout_9"> + <item> + <widget class="NewMarginWidget" name="bleedGroup" native="true"/> + </item> + </layout> + </widget> + </widget> + </item> + <item> + <widget class="SectionContainer" name="sectionTextFrame"> + <property name="title" stdset="0"> + <string>Text Frame</string> + </property> + <property name="isCollapsed"> + <bool>false</bool> + </property> + <widget class="QWidget" name="page_4"> + <layout class="QVBoxLayout" name="verticalLayout_10"> + <item> + <widget class="QCheckBox" name="autoTextFrame"> + <property name="text"> + <string>&Automatic Text Frame</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="FormWidget" name="labelColumns"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Columns</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_5"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QSpinBox" name="numberOfCols"/> + </item> + </layout> + </widget> + </item> + <item> + <widget class="FormWidget" name="labelGap"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Gap</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_6"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="ScrSpinBox" name="Distance"/> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </widget> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Orientation::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab_2"> + <attribute name="title"> + <string>New from Template</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <property name="spacing"> + <number>4</number> + </property> + <property name="leftMargin"> + <number>8</number> + </property> + <property name="topMargin"> + <number>8</number> + </property> + <property name="rightMargin"> + <number>8</number> + </property> + <property name="bottomMargin"> + <number>8</number> + </property> + <item> + <widget class="nftwidget" name="nftGui" native="true"/> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab_3"> + <attribute name="title"> + <string>Open Existing Document</string> + </attribute> + </widget> + <widget class="QWidget" name="tab_4"> + <attribute name="title"> + <string>Open Recent Document</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <property name="spacing"> + <number>4</number> + </property> + <property name="leftMargin"> + <number>8</number> + </property> + <property name="topMargin"> + <number>8</number> + </property> + <property name="rightMargin"> + <number>8</number> + </property> + <property name="bottomMargin"> + <number>8</number> + </property> + <item> + <widget class="QListWidget" name="recentDocListBox"/> + </item> + </layout> + </widget> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="leftMargin"> + <number>8</number> + </property> + <item> + <widget class="QCheckBox" name="startUpDialog"> + <property name="text"> + <string>Do not show this dialog again</string> + </property> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>FormWidget</class> + <extends>QWidget</extends> + <header>ui/widgets/form_widget.h</header> + <container>1</container> + </customwidget> + <customwidget> + <class>SectionContainer</class> + <extends>QWidget</extends> + <header>ui/widgets/section_container.h</header> + <addpagemethod>setWidget</addpagemethod> + <container>1</container> + </customwidget> + <customwidget> + <class>ScrSpinBox</class> + <extends>QDoubleSpinBox</extends> + <header location="global">ui/scrspinbox.h</header> + </customwidget> + <customwidget> + <class>NewMarginWidget</class> + <extends>QWidget</extends> + <header location="global">ui/newmarginwidget.h</header> + <container>1</container> + </customwidget> + <customwidget> + <class>PageLayouts</class> + <extends>QWidget</extends> + <header location="global">ui/widgets/pagelayout.h</header> + <container>1</container> + </customwidget> + <customwidget> + <class>PageSizeList</class> + <extends>QListWidget</extends> + <header>ui/widgets/pagesizelist.h</header> + </customwidget> + <customwidget> + <class>nftwidget</class> + <extends>QWidget</extends> + <header>ui/nftwidget.h</header> + <container>1</container> + </customwidget> + <customwidget> + <class>PageSizePreview</class> + <extends>QWidget</extends> + <header>ui/widgets/pagesizepreview.h</header> + <container>1</container> + </customwidget> + <customwidget> + <class>PageSizeSelector</class> + <extends>QWidget</extends> + <header>ui/widgets/pagesizeselector.h</header> + <container>1</container> + </customwidget> + </customwidgets> + <tabstops> + <tabstop>tabWidget</tabstop> + <tabstop>listPageFormats</tabstop> + <tabstop>unitOfMeasureComboBox</tabstop> + <tabstop>scrollArea</tabstop> + <tabstop>widthSpinBox</tabstop> + <tabstop>heightSpinBox</tabstop> + <tabstop>pageCountSpinBox</tabstop> + <tabstop>buttonVertical</tabstop> + <tabstop>buttonHorizontal</tabstop> + <tabstop>autoTextFrame</tabstop> + <tabstop>numberOfCols</tabstop> + <tabstop>Distance</tabstop> + <tabstop>startDocSetup</tabstop> + <tabstop>startUpDialog</tabstop> + <tabstop>recentDocListBox</tabstop> + </tabstops> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>newDocDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>newDocDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> Index: scribus/ui/newmarginwidget.cpp =================================================================== --- scribus/ui/newmarginwidget.cpp (Revision 26264) +++ scribus/ui/newmarginwidget.cpp (Arbeitskopie) @@ -10,6 +10,7 @@ #include "units.h" #include "ui/marginpresetlayout.h" #include "ui/useprintermarginsdialog.h" +#include "scribusapp.h" NewMarginWidget::NewMarginWidget(QWidget* parent) : QWidget(parent) @@ -39,8 +40,8 @@ presetLayoutLabel->resize(0,0); presetLayoutComboBox->hide(); presetLayoutLabel->hide(); - gridLayout->removeWidget(presetLayoutComboBox); - gridLayout->removeWidget(presetLayoutLabel); + horizontalLayout->removeWidget(presetLayoutComboBox); + horizontalLayout->removeWidget(presetLayoutLabel); } if ((m_flags & ShowPrinterMargins) == 0) { @@ -47,14 +48,14 @@ printerMarginsPushButton->blockSignals(true); printerMarginsPushButton->resize(0,0); printerMarginsPushButton->hide(); - gridLayout->removeWidget(printerMarginsPushButton); + horizontalLayout->removeWidget(printerMarginsPushButton); } setFacingPages(!(layoutType == singlePage)); - gridLayout->invalidate(); - languageChange(); + iconSetChange(); + connect(ScQApp, SIGNAL(iconSetChanged()), this, SLOT(iconSetChange())); connect(topMarginSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setTop())); connect(bottomMarginSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); connect(leftMarginSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); @@ -83,8 +84,15 @@ marginLinkButton->setToolTip( "<qt>" + tr( "Ensure all bleeds have the same value" ) + "</qt>"); } printerMarginsPushButton->setToolTip( "<qt>" + tr( "Import the margins for the selected page size from the available printers" ) + "</qt>"); + + leftMarginLabel->setText( m_facingPages ? tr("Inside") : tr("Left")); + rightMarginLabel->setText( m_facingPages ? tr("Outside") : tr("Right")); } +void NewMarginWidget::iconSetChange() +{ +} + void NewMarginWidget::setNewValues(const MarginStruct& margs) { m_marginData = m_savedMarginData = margs; @@ -234,6 +242,8 @@ topMarginSpinBox->blockSignals(false); bottomMarginSpinBox->blockSignals(false); m_savedPresetItem = item; + + emit marginChanged(m_marginData); } void NewMarginWidget::setPageSize(const QString& pageSize) @@ -274,6 +284,8 @@ rightMarginSpinBox->setValue(leftMarginSpinBox->value()); double newVal = leftMarginSpinBox->value() / m_unitRatio; m_marginData.set(newVal, newVal, newVal, newVal); + + emit marginChanged(m_marginData); } leftMarginSpinBox->blockSignals(leftBlocked); @@ -324,8 +336,10 @@ { m_facingPages = facing; m_pageType = pageType; - leftMarginLabel->setText(facing ? tr( "&Inside:" ) : tr( "&Left:" )); - rightMarginLabel->setText(facing ? tr( "O&utside:" ) : tr( "&Right:" )); + + leftMarginLabel->setText( m_facingPages ? tr("Inside") : tr("Left")); + rightMarginLabel->setText( m_facingPages ? tr("Outside") : tr("Right")); + setPreset(); } Index: scribus/ui/newmarginwidget.h =================================================================== --- scribus/ui/newmarginwidget.h (Revision 26264) +++ scribus/ui/newmarginwidget.h (Arbeitskopie) @@ -41,10 +41,12 @@ 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 setTop(); void setBottom(); void setLeft(); @@ -69,6 +71,9 @@ int m_pageType {0}; int m_savedPresetItem {PresetLayout::none}; int m_unitIndex {0}; + +signals: + void marginChanged(MarginStruct); }; #endif // NEWMARGINWIDGET_H Index: scribus/ui/newmarginwidgetbase.ui =================================================================== --- scribus/ui/newmarginwidgetbase.ui (Revision 26264) +++ scribus/ui/newmarginwidgetbase.ui (Arbeitskopie) @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>308</width> - <height>230</height> + <width>180</width> + <height>186</height> </rect> </property> <property name="sizePolicy"> @@ -16,82 +16,35 @@ <verstretch>0</verstretch> </sizepolicy> </property> - <layout class="QGridLayout" name="gridLayout_2"> + <layout class="QGridLayout" name="gridLayout"> <property name="leftMargin"> - <number>0</number> + <number>8</number> </property> <property name="topMargin"> - <number>0</number> + <number>8</number> </property> <property name="rightMargin"> - <number>0</number> + <number>8</number> </property> <property name="bottomMargin"> - <number>0</number> + <number>8</number> </property> - <item row="0" column="0"> - <layout class="QGridLayout" name="gridLayout"> - <item row="4" column="0"> - <widget class="QLabel" name="bottomMarginLabel"> - <property name="text"> - <string>Bottom:</string> - </property> - <property name="buddy"> - <cstring>bottomMarginSpinBox</cstring> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="leftMarginLabel"> - <property name="text"> - <string>Left:</string> - </property> - <property name="buddy"> - <cstring>leftMarginSpinBox</cstring> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="ScrSpinBox" name="bottomMarginSpinBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="rightMarginLabel"> - <property name="text"> - <string>Right:</string> - </property> - <property name="buddy"> - <cstring>rightMarginSpinBox</cstring> - </property> - </widget> - </item> - <item row="0" column="0"> + <property name="spacing"> + <number>4</number> + </property> + <item row="0" column="1" colspan="3"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> <widget class="QLabel" name="presetLayoutLabel"> <property name="text"> - <string>Preset Layouts:</string> + <string>Preset:</string> </property> </widget> </item> - <item row="3" column="0"> - <widget class="QLabel" name="topMarginLabel"> - <property name="text"> - <string>Top:</string> - </property> - <property name="buddy"> - <cstring>topMarginSpinBox</cstring> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="ScrSpinBox" name="leftMarginSpinBox"> + <item> + <widget class="PresetLayout" name="presetLayoutComboBox"> <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> @@ -98,37 +51,159 @@ </property> </widget> </item> - <item row="2" column="1"> - <widget class="ScrSpinBox" name="rightMarginSpinBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <item> + <spacer name="horizontalSpacer_5"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="ScrSpinBox" name="topMarginSpinBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> </property> - </widget> + </spacer> </item> - <item row="0" column="1"> - <widget class="PresetLayout" name="presetLayoutComboBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - <item row="5" column="1"> + </layout> + </item> + <item row="1" column="2" rowspan="2"> + <widget class="FormWidget" name="formWidget"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string/> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <property name="preserveLabelSpace"> + <bool>true</bool> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="LinkButton" name="marginLinkButton"> + <property name="text"> + <string/> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonStyle::ToolButtonIconOnly</enum> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="1" column="1"> + <widget class="FormWidget" name="leftMarginLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Left</string> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_5"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="ScrSpinBox" name="leftMarginSpinBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="2" column="1"> + <widget class="FormWidget" name="topMarginLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Top</string> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="ScrSpinBox" name="topMarginSpinBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="4" column="1" colspan="3"> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <item> <widget class="QPushButton" name="printerMarginsPushButton"> <property name="text"> <string>Printer Margins...</string> @@ -135,43 +210,118 @@ </property> </widget> </item> - <item row="1" column="2" rowspan="4"> - <widget class="LinkButton" name="marginLinkButton"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> </property> - <property name="minimumSize"> + <property name="sizeHint" stdset="0"> <size> - <width>15</width> + <width>0</width> <height>0</height> </size> </property> - <property name="text"> - <string/> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="toolButtonStyle"> - <enum>Qt::ToolButtonIconOnly</enum> - </property> - <property name="autoRaise"> - <bool>true</bool> - </property> - </widget> + </spacer> </item> </layout> </item> + <item row="2" column="3"> + <widget class="FormWidget" name="bottomMarginLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Bottom</string> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_8"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="ScrSpinBox" name="bottomMarginSpinBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="1" column="3"> + <widget class="FormWidget" name="rightMarginLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Right</string> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_6"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="ScrSpinBox" name="rightMarginSpinBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> + </widget> + </item> </layout> </widget> <customwidgets> <customwidget> + <class>FormWidget</class> + <extends>QWidget</extends> + <header>ui/widgets/form_widget.h</header> + <container>1</container> + </customwidget> + <customwidget> <class>ScrSpinBox</class> <extends>QDoubleSpinBox</extends> - <header>ui/scrspinbox.h</header> + <header location="global">ui/scrspinbox.h</header> </customwidget> <customwidget> <class>LinkButton</class> @@ -189,8 +339,8 @@ <tabstop>leftMarginSpinBox</tabstop> <tabstop>rightMarginSpinBox</tabstop> <tabstop>topMarginSpinBox</tabstop> + <tabstop>marginLinkButton</tabstop> <tabstop>bottomMarginSpinBox</tabstop> - <tabstop>marginLinkButton</tabstop> <tabstop>printerMarginsPushButton</tabstop> </tabstops> <resources/> Index: scribus/ui/pagelayout.cpp =================================================================== --- scribus/ui/pagelayout.cpp (Revision 26264) +++ scribus/ui/pagelayout.cpp (nicht existent) @@ -1,209 +0,0 @@ -/* -For general Scribus (>=1.3.2) copyright and licensing information please refer -to the COPYING file provided with the program. Following this notice may exist -a copyright and/or license notice that predates the release of Scribus 1.3.2 -for which a new license (GPL+exception) is in place. -*/ -#include "pagelayout.h" - -#include <QComboBox> -#include <QToolButton> -#include <QVBoxLayout> -#include <QListWidgetItem> -#include <QLabel> -#include <QPixmap> -#include <QList> - -#include "commonstrings.h" -#include "iconmanager.h" -#include "scribusapp.h" -#include "ui/widgets/form_widget.h" - -PageLayouts::PageLayouts(QWidget* parent) : QWidget( parent ) -{ - struct PageSet pageS; - pageS.Name = CommonStrings::trPageSet2; - pageS.FirstPage = 0; - pageS.Rows = 1; - pageS.Columns = 1; - pageS.pageNames.clear(); - pageS.pageNames.append(CommonStrings::trPageLocMiddleRight); - pageSets.append(pageS); - - layoutGroupLayout = new QHBoxLayout(this); - layoutGroupLayout->setSpacing(4); - layoutGroupLayout->setContentsMargins(0, 0, 0, 0); - - QFont layFont(this->font()); - layFont.setPointSize(8); - - menuScheme = new QMenu(); - - buttonScheme = new QToolButton(this); - buttonScheme->setPopupMode(QToolButton::InstantPopup); - buttonScheme->setMenu(menuScheme); - - labelScheme = new FormWidget(); - labelScheme->setFont(layFont); - labelScheme->addWidget(buttonScheme); - labelScheme->setLabelVisibility(!m_hideLabels); - layoutGroupLayout->addWidget( labelScheme ); - - menuFirstPage = new QMenu(); - - buttonFirstPage = new QToolButton(this); - buttonFirstPage->setPopupMode(QToolButton::InstantPopup); - buttonFirstPage->setMenu(menuFirstPage); - - labelPages = new FormWidget(); - labelPages->setFont(layFont); - labelPages->addWidget( buttonFirstPage ); - labelPages->setLabelVisibility(!m_hideLabels); - layoutGroupLayout->addWidget( labelPages ); - - languageChange(); - - connect(ScQApp, SIGNAL(labelVisibilityChanged(bool)), this, SLOT(toggleLabelVisibility(bool))); - connect(menuScheme, &QMenu::triggered, this, &PageLayouts::schemeChanged); - connect(menuFirstPage, &QMenu::triggered, this, &PageLayouts::firstPageChanged); -} - -void PageLayouts::updateSchemeSelector(const ScribusDoc* doc) -{ - pageSets = doc->pageSets(); - docPagePositioning = doc->pagePositioning(); - labelPages->setVisible( docPagePositioning > 0 ); - - reloadScheme(); -} - -void PageLayouts::selectFirstPage(int nr) -{ - if (menuFirstPage->actions().count() == 0) - return; - - m_firstPage = qBound(0, nr, menuFirstPage->actions().count()); - buttonFirstPage->setIcon(menuFirstPage->actions().at(m_firstPage)->icon()); -} - -void PageLayouts::selectScheme(int nr) -{ - if (menuScheme->actions().count() == 0) - return; - - m_scheme = qBound(0, nr, menuScheme->actions().count()); - buttonScheme->setIcon(menuScheme->actions().at(m_scheme)->icon()); - - reloadFirstPage(m_scheme); - -} - -void PageLayouts::setHideLabelsPermanently(bool hide) -{ - m_hideLabels = hide; - toggleLabelVisibility(!hide); -} - -void PageLayouts::reloadScheme() -{ - disconnect(menuScheme, &QMenu::triggered, this, &PageLayouts::schemeChanged); - - menuScheme->clear(); - - for (int pg = 0; pg < pageSets.count(); ++pg) - { - //Leave the code in for 3-/4- fold but exclude from UI in case we bring it back. - if (pg > 1 && docPagePositioning < 2) - continue; - - QString psname = CommonStrings::translatePageSetString(pageSets[pg].Name); - if (pg == 0) - menuScheme->addAction(IconManager::instance().loadIcon("16/page-simple.png"), psname)->setData(QVariant(pg)); - else if (pg == 1) - menuScheme->addAction(IconManager::instance().loadIcon("16/page-doublesided.png"), psname)->setData(QVariant(pg)); - else if (pg == 2) - menuScheme->addAction(IconManager::instance().loadIcon("16/page-3fold.png"), psname)->setData(QVariant(pg)); - else if (pg == 3) - menuScheme->addAction(IconManager::instance().loadIcon("16/page-4fold.png"), psname)->setData(QVariant(pg)); - else - menuScheme->addAction(IconManager::instance().loadIcon("16/page-simple.png"), psname)->setData(QVariant(pg)); - } - - connect(menuScheme, &QMenu::triggered, this, &PageLayouts::schemeChanged); - - -} - -void PageLayouts::reloadFirstPage(int scheme) -{ - disconnect(menuFirstPage, &QMenu::triggered, this, &PageLayouts::firstPageChanged); - - menuFirstPage->clear(); - - // We have to add the other cases if want to support them again - // CommonStrings::trPageLocLeft - // CommonStrings::trPageLocMiddle - // CommonStrings::trPageLocMiddleLeft - // CommonStrings::trPageLocMiddleRight - // CommonStrings::trPageLocRight - - for (int pg = 0; pg < pageSets[scheme].pageNames.count(); ++pg) - { - QString psname = CommonStrings::translatePageSetString(pageSets[scheme].pageNames[pg]); - - if (psname == CommonStrings::trPageLocLeft) - menuFirstPage->addAction(IconManager::instance().loadIcon("page-first-left"), psname)->setData(QVariant(pg)); - else if (psname == CommonStrings::trPageLocRight) - menuFirstPage->addAction(IconManager::instance().loadIcon("page-first-right"), psname)->setData(QVariant(pg)); - else - menuFirstPage->addAction(IconManager::instance().loadIcon("page-first-left"), psname)->setData(QVariant(pg)); - } - - connect(menuFirstPage, &QMenu::triggered, this, &PageLayouts::firstPageChanged); - - -} - -void PageLayouts::schemeSelected(int ic) -{ - reloadFirstPage(ic); - labelPages->setVisible( ic > 0 ); - emit selectedScheme(ic); -} - -void PageLayouts::toggleLabelVisibility(bool visibility) -{ - // hide labels always if flag is false - if (m_hideLabels) - visibility = false; - - labelScheme->setLabelVisibility(visibility); - labelPages->setLabelVisibility(visibility); -} - -void PageLayouts::languageChange() -{ - - reloadScheme(); - reloadFirstPage(m_scheme); - - labelScheme->setText( tr( "Scheme" ) ); - labelPages->setText( tr( "First Page" ) ); - - buttonScheme->setToolTip( tr( "Number of pages to show side-by-side on the canvas. Often used for allowing items to be placed across page spreads." ) ); - buttonFirstPage->setToolTip( tr( "Location on the canvas where the first page of the document is placed" ) ); -} - -void PageLayouts::schemeChanged(QAction *action) -{ - buttonScheme->setIcon(action->icon()); - m_scheme = action->data().toInt(); - schemeSelected(m_scheme); -} - -void PageLayouts::firstPageChanged(QAction *action) -{ - buttonFirstPage->setIcon(action->icon()); - m_firstPage = action->data().toInt(); - emit selectedFirstPage(m_firstPage); -} Property changes on: scribus/ui/pagelayout.cpp ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Author Date Id Revision \ No newline at end of property Index: scribus/ui/pagelayout.h =================================================================== --- scribus/ui/pagelayout.h (Revision 26264) +++ scribus/ui/pagelayout.h (nicht existent) @@ -1,76 +0,0 @@ -/* -For general Scribus (>=1.3.2) copyright and licensing information please refer -to the COPYING file provided with the program. Following this notice may exist -a copyright and/or license notice that predates the release of Scribus 1.3.2 -for which a new license (GPL+exception) is in place. -*/ -#ifndef PAGELAYOUT_H -#define PAGELAYOUT_H - -#include <QGroupBox> -#include <QListWidget> -#include <QList> - -class QToolButton; -class QLabel; -class QHBoxLayout; -class FormWidget; -class QMenu; - -#include "scribusapi.h" -#include "scribusstructs.h" -#include "scribusdoc.h" - -/*! \brief A widget for changing pages layout. -User can change layouts on-the-fly changing widget's -comboboxes. */ -class SCRIBUS_API PageLayouts : public QWidget -{ - Q_OBJECT - -public: - PageLayouts(QWidget* parent); - ~PageLayouts() {}; - - void updateSchemeSelector(const ScribusDoc* doc); - void selectFirstPage(int nr); - void selectScheme(int nr); - - void setHideLabelsPermanently(bool hide); - bool hideLabelsPermanently() { return m_hideLabels; }; - -public slots: - void schemeSelected(int ic); - void toggleLabelVisibility(bool visibility); - -signals: - void selectedScheme(int); - void selectedFirstPage(int); - -private: - - int m_scheme {0}; - int m_firstPage {0}; - bool m_hideLabels {false}; - int docPagePositioning {0}; - - FormWidget* labelScheme; - FormWidget* labelPages; - QList<PageSet> pageSets; - QToolButton* buttonScheme; - QToolButton* buttonFirstPage; - QMenu* menuScheme; - QMenu* menuFirstPage; - QHBoxLayout* layoutGroupLayout; - - void reloadScheme(); - void reloadFirstPage(int scheme); - -protected slots: - void languageChange(); - void schemeChanged(QAction* action); - void firstPageChanged(QAction* action); - -}; - -#endif // PAGELAYOUT_H Property changes on: scribus/ui/pagelayout.h ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Author Date Id Revision \ No newline at end of property Index: scribus/ui/pagepalette_pages.cpp =================================================================== --- scribus/ui/pagepalette_pages.cpp (Revision 26264) +++ scribus/ui/pagepalette_pages.cpp (Arbeitskopie) @@ -22,7 +22,7 @@ #include "commonstrings.h" #include "iconmanager.h" -#include "pagelayout.h" +#include "ui/widgets/pagelayout.h" #include "pagepalette_pages.h" #include "pagepalette_widgets.h" #include "qobjectdefs.h" @@ -45,11 +45,11 @@ masterPageList->m_thumb = true; masterPageList->setIconSize(QSize(60, 60)); - pageLayout->setHideLabelsPermanently(true); + pageLayout->setHideLabelsPermanently(true); - trash->setMinimumSize(QSize(24, 24)); - trash->setMaximumSize(QSize(24, 24)); - + trash->setMinimumSize(QSize(24, 24)); + trash->setMaximumSize(QSize(24, 24)); + PageGrid *pageGrid = pageViewWidget->pageGrid(); rebuild(); @@ -62,8 +62,8 @@ connect(masterPageList, SIGNAL(thumbnailChanged()), this, SLOT(rebuildMasters())); connect(masterPageList, SIGNAL(delMasterRequest(QString)), this, SLOT(deleteMasterPage(QString))); - connect(pageLayout, SIGNAL(selectedScheme(int)), this, SLOT(handlePageLayout(int))); - connect(pageLayout, SIGNAL(selectedFirstPage(int)), this, SLOT(handleFirstPage(int))); + connect(pageLayout, SIGNAL(schemeChanged(int)), this, SLOT(handlePageLayout(int))); + connect(pageLayout, SIGNAL(firstPageChanged(int)), this, SLOT(handleFirstPage(int))); connect(pageGrid, SIGNAL(click(int, int)), this, SLOT(pageView_gotoPage(int, int))); connect(pageGrid, SIGNAL(movePage(int, int)), this, SLOT(pageView_movePage(int, int))); @@ -137,8 +137,8 @@ double pageRatio = page.width() / page.height(); PageCell *pc = pageViewWidget->pageGrid()->getPageItem(pageIndex); - pc->pageName = masterpageName; - pc->pageRatio = pageRatio; + pc->pageName = masterpageName; + pc->pageRatio = pageRatio; } @@ -205,8 +205,8 @@ QPixmap pix = ( previews.contains(i) ) ? QPixmap::fromImage( previews.value(i) ) : QPixmap(); PageCell *pc = pageViewWidget->pageGrid()->pageList.at(i); - pc->pagePreview = pix; - pc->pageRatio = pageRatio; + pc->pagePreview = pix; + pc->pageRatio = pageRatio; } } @@ -283,7 +283,7 @@ void PagePalette_Pages::handlePageLayout(int layout) { - pageLayout->selectFirstPage(currView->m_doc->pageSets()[layout].FirstPage); + pageLayout->setFirstPage(currView->m_doc->pageSets()[layout].FirstPage); currView->m_doc->setPagePositioning(layout); currView->reformPages(); currView->DrawNew(); @@ -333,21 +333,21 @@ if (m_scMW->scriptIsRunning()) return; - disconnect(pageLayout, SIGNAL(selectedScheme(int)), this, SLOT(handlePageLayout(int))); - disconnect(pageLayout, SIGNAL(selectedFirstPage(int)), this, SLOT(handleFirstPage(int))); + disconnect(pageLayout, SIGNAL(schemeChanged(int)), this, SLOT(handlePageLayout(int))); + disconnect(pageLayout, SIGNAL(firstPageChanged(int)), this, SLOT(handleFirstPage(int))); pageViewWidget->pageGrid()->clear(); if (currView == nullptr) { - connect(pageLayout, SIGNAL(selectedScheme(int)), this, SLOT(handlePageLayout(int))); - connect(pageLayout, SIGNAL(selectedFirstPage(int)), this, SLOT(handleFirstPage(int))); + connect(pageLayout, SIGNAL(schemeChanged(int)), this, SLOT(handlePageLayout(int))); + connect(pageLayout, SIGNAL(firstPageChanged(int)), this, SLOT(handleFirstPage(int))); return; } const PageSet ¤tPageSet = currView->m_doc->pageSets()[currView->m_doc->pagePositioning()]; - pageLayout->updateSchemeSelector(currView->m_doc); - pageLayout->selectScheme(currView->m_doc->pagePositioning()); - pageLayout->selectFirstPage(currentPageSet.FirstPage); + pageLayout->updateSchemeSelector(currView->m_doc->pageSets(), currView->m_doc->pagePositioning()); + pageLayout->setScheme(currView->m_doc->pagePositioning()); + pageLayout->setFirstPage(currentPageSet.FirstPage); int counter = currentPageSet.FirstPage; int cols = currentPageSet.Columns; @@ -391,8 +391,8 @@ { markPage(currView->m_doc->currentPageNumber()); } - connect(pageLayout, SIGNAL(selectedScheme(int)), this, SLOT(handlePageLayout(int))); - connect(pageLayout, SIGNAL(selectedFirstPage(int)), this, SLOT(handleFirstPage(int))); + connect(pageLayout, SIGNAL(schemeChanged(int)), this, SLOT(handlePageLayout(int))); + connect(pageLayout, SIGNAL(firstPageChanged(int)), this, SLOT(handleFirstPage(int))); } void PagePalette_Pages::rebuild() Index: scribus/ui/pagepalette_pagesbase.ui =================================================================== --- scribus/ui/pagepalette_pagesbase.ui (Revision 26264) +++ scribus/ui/pagepalette_pagesbase.ui (Arbeitskopie) @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>235</width> - <height>498</height> + <width>235</width> + <height>498</height> </rect> </property> <property name="windowTitle"> @@ -14,45 +14,45 @@ <string>Arrange Pages</string> </property> <layout class="QVBoxLayout" name="verticalLayout"> - <property name="spacing"> - <number>4</number> - </property> + <property name="spacing"> + <number>4</number> + </property> <property name="leftMargin"> - <number>8</number> + <number>8</number> </property> <property name="topMargin"> - <number>8</number> + <number>8</number> </property> <property name="rightMargin"> - <number>8</number> + <number>8</number> </property> <property name="bottomMargin"> - <number>8</number> + <number>8</number> </property> <item> <widget class="QSplitter" name="splitter"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="orientation"> - <enum>Qt::Orientation::Vertical</enum> + <enum>Qt::Orientation::Vertical</enum> </property> <property name="childrenCollapsible"> <bool>false</bool> </property> <widget class="QWidget" name="widget" native="true"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <layout class="QVBoxLayout" name="verticalLayout_3"> <property name="spacing"> - <number>4</number> + <number>4</number> </property> <property name="leftMargin"> <number>0</number> @@ -89,15 +89,15 @@ </layout> </widget> <widget class="QWidget" name="widget_2" native="true"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>1</verstretch> - </sizepolicy> - </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>1</verstretch> + </sizepolicy> + </property> <layout class="QVBoxLayout" name="verticalLayout_4"> <property name="spacing"> - <number>4</number> + <number>4</number> </property> <property name="leftMargin"> <number>0</number> @@ -119,104 +119,104 @@ </widget> </item> <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <property name="spacing"> - <number>4</number> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="spacing"> + <number>4</number> </property> - <item> - <widget class="QToolButton" name="buttonPageInsert"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="buttonPageImport"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="buttonPageDuplicate"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="buttonPageMove"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Orientation::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Policy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>16</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="PageLayouts" name="pageLayout" native="true"/> - </item> - <item> - <spacer name="horizontalSpacer_2"> - <property name="orientation"> - <enum>Qt::Orientation::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Policy::MinimumExpanding</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>16</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="TrashBin" name="trash"> - <property name="minimumSize"> - <size> - <width>32</width> - <height>32</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>32</width> - <height>32</height> - </size> - </property> - <property name="toolTip"> - <string><qt>Drag pages or master pages onto the trash to delete them</qt></string> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="PageViewer" name="pageViewWidget" native="true"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <item> + <widget class="QToolButton" name="buttonPageInsert"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="buttonPageImport"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="buttonPageDuplicate"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="buttonPageMove"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Policy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>16</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="PageLayouts" name="pageLayout" native="true"/> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Policy::MinimumExpanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>16</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="TrashBin" name="trash"> + <property name="minimumSize"> + <size> + <width>32</width> + <height>32</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>32</width> + <height>32</height> + </size> + </property> + <property name="toolTip"> + <string><qt>Drag pages or master pages onto the trash to delete them</qt></string> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="PageViewer" name="pageViewWidget" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> </widget> </item> @@ -233,20 +233,20 @@ <header>ui/pagepalette_widgets.h</header> </customwidget> <customwidget> - <class>TrashBin</class> - <extends>QLabel</extends> - <header>ui/pagepalette_widgets.h</header> - </customwidget> - <customwidget> - <class>PageViewer</class> - <extends>QWidget</extends> - <header>ui/pagepalette_widgets.h</header> - <container>1</container> - </customwidget> - <customwidget> + <class>TrashBin</class> + <extends>QLabel</extends> + <header>ui/pagepalette_widgets.h</header> + </customwidget> + <customwidget> + <class>PageViewer</class> + <extends>QWidget</extends> + <header>ui/pagepalette_widgets.h</header> + <container>1</container> + </customwidget> + <customwidget> <class>PageLayouts</class> - <extends>QWidget</extends> - <header>ui/pagelayout.h</header> + <extends>QWidget</extends> + <header location="global">ui/widgets/pagelayout.h</header> <container>1</container> </customwidget> </customwidgets> Index: scribus/ui/pagepropertiesdialog.cpp =================================================================== --- scribus/ui/pagepropertiesdialog.cpp (Revision 26264) +++ scribus/ui/pagepropertiesdialog.cpp (Arbeitskopie) @@ -17,7 +17,7 @@ #include "commonstrings.h" #include "iconmanager.h" -#include "marginwidget.h" +#include "newmarginwidget.h" #include "pagepropertiesdialog.h" #include "pagesize.h" #include "pagestructs.h" @@ -25,6 +25,7 @@ #include "scribusdoc.h" #include "scrspinbox.h" #include "units.h" +#include "widgets/pagesizeselector.h" PagePropertiesDialog::PagePropertiesDialog( QWidget* parent, ScribusDoc* doc ) : QDialog( parent), @@ -35,36 +36,25 @@ setWindowIcon(IconManager::instance().loadIcon("AppIcon.png")); dialogLayout = new QVBoxLayout(this); dialogLayout->setContentsMargins(9, 9, 9, 9); - dialogLayout->setSpacing(6); + dialogLayout->setSpacing(4); + PageSize ps(doc->currentPage()->size()); + prefsPageSizeName = ps.name(); + dsGroupBox7 = new QGroupBox(this); dsGroupBox7->setTitle( tr( "Page Size" ) ); dsGroupBox7Layout = new QGridLayout(dsGroupBox7); dsGroupBox7Layout->setAlignment( Qt::AlignTop ); - dsGroupBox7Layout->setSpacing(6); + dsGroupBox7Layout->setSpacing(4); dsGroupBox7Layout->setContentsMargins(9, 9, 9, 9); TextLabel1 = new QLabel( tr( "&Size:" ), dsGroupBox7 ); - dsGroupBox7Layout->addWidget( TextLabel1, 0, 0, 1, 2 ); - - PageSize ps(doc->currentPage()->size()); - prefsPageSizeName = ps.name(); - sizeQComboBox = new QComboBox(dsGroupBox7); - QStringList insertList(ps.activeSizeTRList()); - if (insertList.indexOf(prefsPageSizeName) == -1 && prefsPageSizeName != CommonStrings::customPageSize) - insertList << prefsPageSizeName; - insertList.sort(); - insertList << CommonStrings::trCustomPageSize; - sizeQComboBox->addItems(insertList); - int sizeIndex = insertList.indexOf(ps.nameTR()); - if (sizeIndex != -1) - sizeQComboBox->setCurrentIndex(sizeIndex); - else - sizeQComboBox->setCurrentIndex(sizeQComboBox->count()-1); - - TextLabel1->setBuddy(sizeQComboBox); - dsGroupBox7Layout->addWidget(sizeQComboBox, 0, 2, 1, 2); + dsGroupBox7Layout->addWidget( TextLabel1, 0, 0, Qt::AlignTop | Qt::AlignRight); + pageSizeSelector = new PageSizeSelector(dsGroupBox7); + pageSizeSelector->setPageSize(doc->currentPage()->size()); + TextLabel1->setBuddy(pageSizeSelector); + dsGroupBox7Layout->addWidget(pageSizeSelector, 0, 1); TextLabel2 = new QLabel( tr( "Orie&ntation:" ), dsGroupBox7 ); - dsGroupBox7Layout->addWidget( TextLabel2, 1, 0, 1, 2 ); + dsGroupBox7Layout->addWidget( TextLabel2, 1, 0, Qt::AlignRight); orientationQComboBox = new QComboBox( dsGroupBox7 ); orientationQComboBox->addItem( tr( "Portrait" ) ); orientationQComboBox->addItem( tr( "Landscape" ) ); @@ -72,28 +62,28 @@ orientationQComboBox->setCurrentIndex(doc->currentPage()->orientation() ); oldOri = doc->currentPage()->orientation(); TextLabel2->setBuddy(orientationQComboBox); - dsGroupBox7Layout->addWidget( orientationQComboBox, 1, 2, 1, 2 ); + dsGroupBox7Layout->addWidget( orientationQComboBox, 1, 1 ); widthSpinBox = new ScrSpinBox(pts2value(1.0, doc->unitIndex()), 16777215, dsGroupBox7, doc->unitIndex()); widthQLabel = new QLabel( tr( "&Width:" ), dsGroupBox7 ); widthSpinBox->setValue(doc->currentPage()->width() * doc->unitRatio()); widthQLabel->setBuddy(widthSpinBox); - dsGroupBox7Layout->addWidget( widthQLabel, 2, 0 ); + dsGroupBox7Layout->addWidget( widthQLabel, 2, 0, Qt::AlignRight); dsGroupBox7Layout->addWidget( widthSpinBox, 2, 1 ); heightSpinBox = new ScrSpinBox(pts2value(1.0, doc->unitIndex()), 16777215, dsGroupBox7, doc->unitIndex()); heightSpinBox->setValue(doc->currentPage()->height() * doc->unitRatio()); heightQLabel = new QLabel( tr( "&Height:" ), dsGroupBox7 ); heightQLabel->setBuddy(heightSpinBox); - dsGroupBox7Layout->addWidget( heightQLabel, 2, 2 ); - dsGroupBox7Layout->addWidget( heightSpinBox, 2, 3 ); + dsGroupBox7Layout->addWidget( heightQLabel, 3, 0, Qt::AlignRight ); + dsGroupBox7Layout->addWidget( heightSpinBox, 3, 1 ); moveObjects = new QCheckBox( dsGroupBox7 ); moveObjects->setText( tr( "Move Objects with their Page" ) ); moveObjects->setChecked( true ); - dsGroupBox7Layout->addWidget( moveObjects, 3, 0, 1, 4 ); + dsGroupBox7Layout->addWidget( moveObjects, 4, 0, 1, 2 ); Links = nullptr; if ((doc->pagePositioning() != singlePage) && (doc->masterPageMode())) { TextLabel3 = new QLabel( tr( "Type:" ), dsGroupBox7 ); - dsGroupBox7Layout->addWidget( TextLabel3, 4, 0, 1, 2 ); + dsGroupBox7Layout->addWidget( TextLabel3, 5, 0, Qt::AlignRight); Links = new QComboBox( dsGroupBox7 ); QList<PageSet> pageSet(doc->pageSets()); const QStringList& pageNames = pageSet.at(doc->pagePositioning()).pageNames; @@ -102,7 +92,7 @@ Links->addItem(CommonStrings::translatePageSetLocString((*pNames))); } Links->setEditable(false); - dsGroupBox7Layout->addWidget( Links, 4, 2, 1, 2 ); + dsGroupBox7Layout->addWidget( Links, 5, 1); if (doc->currentPage()->LeftPg == 0) Links->setCurrentIndex(Links->count()-1); else if (doc->currentPage()->LeftPg == 1) @@ -112,17 +102,20 @@ } dialogLayout->addWidget( dsGroupBox7 ); - marginWidget = new MarginWidget(this, tr( "Margin Guides" ), &doc->currentPage()->initialMargins, doc->unitIndex(), false, false); - marginWidget->setPageWidthHeight(doc->currentPage()->width(), doc->currentPage()->height()); +// 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->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 ); groupMaster->setTitle( tr( "Other Settings" ) ); masterLayout = new QHBoxLayout( groupMaster ); - masterLayout->setSpacing(6); - masterLayout->setContentsMargins(9, 9, 9, 9); + masterLayout->setSpacing(4); + masterLayout->setContentsMargins(8, 8, 8, 8); masterPageLabel = new QLabel( groupMaster ); masterLayout->addWidget( masterPageLabel ); if (!doc->masterPageMode()) @@ -163,7 +156,7 @@ m_pageWidth = widthSpinBox->value() / m_unitRatio; m_pageHeight = heightSpinBox->value() / m_unitRatio; - bool isCustom = (sizeQComboBox->currentText() == CommonStrings::trCustomPageSize); + bool isCustom = (pageSizeSelector->pageSizeTR() == CommonStrings::trCustomPageSize); heightSpinBox->setEnabled(isCustom); widthSpinBox->setEnabled(isCustom); // signals and slots connections @@ -170,12 +163,12 @@ connect(okButton, SIGNAL(clicked()), this, SLOT(accept())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject())); connect(orientationQComboBox, SIGNAL(activated(int)), this, SLOT(setOrientation(int))); - connect(sizeQComboBox, SIGNAL(textActivated(QString)), this, SLOT(setPageSize())); + connect(pageSizeSelector, SIGNAL(pageSizeChanged(QString)), this, SLOT(setPageSize())); connect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setPageWidth(double))); connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setPageHeight(double))); //tooltips - sizeQComboBox->setToolTip( tr( "Size of the inserted pages, either a standard or custom size" ) ); + pageSizeSelector->setToolTip( tr( "Size of the inserted pages, either a standard or custom size" ) ); orientationQComboBox->setToolTip( tr( "Orientation of the page(s) to be inserted" ) ); widthSpinBox->setToolTip( tr( "Width of the page(s) to be inserted" ) ); heightSpinBox->setToolTip( tr( "Height of the page(s) to be inserted" ) ); @@ -217,7 +210,7 @@ void PagePropertiesDialog::setPageSize() { - if (sizeQComboBox->currentText() != CommonStrings::trCustomPageSize) + if (pageSizeSelector->pageSizeTR() != CommonStrings::trCustomPageSize) oldOri++; setOrientation(orientationQComboBox->currentIndex()); } @@ -254,10 +247,10 @@ void PagePropertiesDialog::setOrientation(int ori) { - setSize(sizeQComboBox->currentText()); + setSize(pageSizeSelector->pageSizeTR()); disconnect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setPageWidth(double))); disconnect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setPageHeight(double))); - if ((sizeQComboBox->currentText() == CommonStrings::trCustomPageSize) && (ori != oldOri)) + if ((pageSizeSelector->pageSizeTR() == CommonStrings::trCustomPageSize) && (ori != oldOri)) { double w = widthSpinBox->value(), h = heightSpinBox->value(); widthSpinBox->setValue((ori == portraitPage) ? qMin(w, h) : qMax(w, h)); @@ -320,22 +313,22 @@ double PagePropertiesDialog::top() const { - return marginWidget->top(); + return marginWidget->margins().top(); } double PagePropertiesDialog::bottom() const { - return marginWidget->bottom(); + return marginWidget->margins().bottom(); } double PagePropertiesDialog::left() const { - return marginWidget->left(); + return marginWidget->margins().left(); } double PagePropertiesDialog::right() const { - return marginWidget->right(); + return marginWidget->margins().right(); } QString PagePropertiesDialog::masterPage() const @@ -347,5 +340,5 @@ int PagePropertiesDialog::getMarginPreset() const { - return marginWidget->getMarginPreset(); + return marginWidget->marginPreset(); } Index: scribus/ui/pagepropertiesdialog.h =================================================================== --- scribus/ui/pagepropertiesdialog.h (Revision 26264) +++ scribus/ui/pagepropertiesdialog.h (Arbeitskopie) @@ -10,6 +10,8 @@ #include "scribusapi.h" #include <QDialog> +#include "widgets/pagesizeselector.h" + class QGroupBox; class QLabel; class QPushbutton; @@ -20,7 +22,7 @@ class QHBoxLayout; class QVBoxLayout; class ScrSpinBox; -class MarginWidget; +class NewMarginWidget; class ScribusDoc; /*! \brief A dialog to setup the existing document margins. @@ -90,7 +92,7 @@ void setPageHeight(double v); private: - MarginWidget* marginWidget { nullptr }; + NewMarginWidget* marginWidget { nullptr }; QGroupBox* dsGroupBox7 { nullptr }; QGroupBox* groupMaster { nullptr }; QLabel* masterPageLabel { nullptr }; @@ -101,7 +103,7 @@ QLabel* heightQLabel { nullptr }; QLabel* TextLabel1 { nullptr }; QLabel* TextLabel2 { nullptr }; - QComboBox* sizeQComboBox { nullptr }; + PageSizeSelector* pageSizeSelector { nullptr }; QComboBox* orientationQComboBox { nullptr }; QComboBox* Links { nullptr }; QLabel* TextLabel3 { nullptr }; Index: scribus/ui/prefs_documentsetup.cpp =================================================================== --- scribus/ui/prefs_documentsetup.cpp (Revision 26264) +++ scribus/ui/prefs_documentsetup.cpp (Arbeitskopie) @@ -68,7 +68,7 @@ pageHeightSpinBox->setMaximum(16777215); languageChange(); - connect(pageSizeComboBox, SIGNAL(activated(int)), this, SLOT(setPageSize())); + connect(pageSizeSelector, SIGNAL(pageSizeChanged(QString)), this, SLOT(setPageSize())); connect(pageOrientationComboBox, SIGNAL(activated(int)), this, SLOT(setPageOrientation(int))); connect(pageWidthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setPageWidth(double))); connect(pageHeightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setPageHeight(double))); @@ -121,7 +121,7 @@ pageWidthSpinBox->setToolTip( "<qt>" + tr( "Width of document pages, editable if you have chosen a custom page size" ) + "</qt>" ); pageHeightSpinBox->setToolTip( "<qt>" + tr( "Height of document pages, editable if you have chosen a custom page size" ) + "</qt>" ); - pageSizeComboBox->setToolTip( "<qt>" + tr( "Default page size, either a standard size or a custom size. More page sizes can be made visible by activating them in Preferences." ) + "</qt>" ); + pageSizeSelector->setToolTip( "<qt>" + tr( "Default page size, either a standard size or a custom size. More page sizes can be made visible by activating them in Preferences." ) + "</qt>" ); pageSizeLinkToolButton->setToolTip( "<qt>" + tr( "Enable or disable more page sizes by jumping to Page Size preferences" ) + "</qt>" ); pageOrientationComboBox->setToolTip( "<qt>" + tr( "Default orientation of document pages" ) + "</qt>" ); pageUnitsComboBox->setToolTip( "<qt>" + tr( "Default unit of measurement for document editing" ) + "</qt>" ); @@ -138,7 +138,7 @@ pageWidthSpinBox->blockSignals(true); pageHeightSpinBox->blockSignals(true); pageOrientationComboBox->blockSignals(true); - pageSizeComboBox->blockSignals(true); + pageSizeSelector->blockSignals(true); setCurrentComboItem(languageComboBox, LanguageManager::instance()->getLangFromAbbrev(prefsData->docSetupPrefs.language, true)); @@ -179,7 +179,7 @@ pageWidthSpinBox->blockSignals(false); pageHeightSpinBox->blockSignals(false); pageOrientationComboBox->blockSignals(false); - pageSizeComboBox->blockSignals(false); + pageSizeSelector->blockSignals(false); marginsWidget->setup(prefsData->docSetupPrefs.margins, prefsData->docSetupPrefs.pagePositioning, prefsData->docSetupPrefs.docUnitIndex, NewMarginWidget::MarginWidgetFlags); marginsWidget->setPageWidth(prefsData->docSetupPrefs.pageWidth); @@ -271,42 +271,9 @@ void Prefs_DocumentSetup::setupPageSizes(struct ApplicationPrefs *prefsData) { - PageSize ps(prefsData->docSetupPrefs.pageSize); - QStringList insertList(ps.activeSizeList()); - QStringList insertTrList(ps.activeSizeTRList()); - prefsPageSizeName = prefsData->docSetupPrefs.pageSize; - if (prefsPageSizeName == CommonStrings::trCustomPageSize) - prefsPageSizeName = CommonStrings::customPageSize; - if ((prefsPageSizeName != CommonStrings::customPageSize) && - (prefsPageSizeName != CommonStrings::trCustomPageSize) && - (insertList.indexOf(prefsPageSizeName) == -1)) - { - insertList << prefsPageSizeName; - insertTrList << prefsPageSizeName; - } - QMap<QString, QString> insertMap; - for (int i = 0; i < insertTrList.count(); ++i) - { - const QString& key = insertTrList.at(i); - insertMap[key] = insertList.at(i); - } - insertTrList.sort(); - - pageSizeComboBox->clear(); - for (int i = 0; i < insertList.count(); ++i) - { - const QString& key = insertTrList.at(i); - pageSizeComboBox->addItem(key, insertMap[key]); - } - pageSizeComboBox->addItem(CommonStrings::trCustomPageSize, CommonStrings::customPageSize); - - QString pageSizeName = CommonStrings::trCustomPageSize; - int index = pageSizeComboBox->findData(prefsPageSizeName); - if (index >= 0) - pageSizeName = pageSizeComboBox->itemText(index); - setCurrentComboItem(pageSizeComboBox, pageSizeName); + pageSizeSelector->setPageSize(prefsPageSizeName); marginsWidget->setPageSize(prefsPageSizeName); bleedsWidget->setPageSize(prefsPageSizeName); } @@ -322,9 +289,9 @@ { pageW = pageWidthSpinBox->value() / unitRatio; marginsWidget->setPageWidth(pageW); - QString psText = pageSizeComboBox->currentText(); + QString psText = pageSizeSelector->pageSizeTR(); if (psText != CommonStrings::trCustomPageSize && psText != CommonStrings::customPageSize) - pageSizeComboBox->setCurrentIndex(pageSizeComboBox->count() - 1); + pageSizeSelector->setPageSize(CommonStrings::customPageSize); int newOrientation = (pageWidthSpinBox->value() > pageHeightSpinBox->value()) ? landscapePage : portraitPage; if (newOrientation != pageOrientationComboBox->currentIndex()) { @@ -338,9 +305,9 @@ { pageH = pageHeightSpinBox->value() / unitRatio; marginsWidget->setPageHeight(pageH); - QString psText = pageSizeComboBox->currentText(); + QString psText = pageSizeSelector->pageSizeTR(); if (psText != CommonStrings::trCustomPageSize && psText != CommonStrings::customPageSize) - pageSizeComboBox->setCurrentIndex(pageSizeComboBox->count() - 1); + pageSizeSelector->setPageSize(CommonStrings::customPageSize); int newOrientation = (pageWidthSpinBox->value() > pageHeightSpinBox->value()) ? landscapePage : portraitPage; if (newOrientation != pageOrientationComboBox->currentIndex()) { @@ -352,10 +319,10 @@ void Prefs_DocumentSetup::setPageOrientation(int orientation) { - setSize(pageSizeComboBox->currentText()); + setSize(pageSizeSelector->pageSize()); pageWidthSpinBox->blockSignals(true); pageHeightSpinBox->blockSignals(true); - if ((orientation==0 && pageSizeComboBox->currentText() == CommonStrings::trCustomPageSize) || orientation!=0) + if ((orientation==0 && pageSizeSelector->pageSizeTR() == CommonStrings::trCustomPageSize) || orientation!=0) { double w = pageWidthSpinBox->value(), h = pageHeightSpinBox->value(); pageWidthSpinBox->setValue((orientation == portraitPage) ? qMin(w, h) : qMax(w, h)); @@ -379,7 +346,7 @@ PageSize ps2(newSize); prefsPageSizeName = ps2.name(); - if (newSize != CommonStrings::trCustomPageSize) + if (newSize != CommonStrings::customPageSize && newSize != CommonStrings::trCustomPageSize) { pageW = ps2.width(); pageH = ps2.height(); Index: scribus/ui/prefs_documentsetupbase.ui =================================================================== --- scribus/ui/prefs_documentsetupbase.ui (Revision 26264) +++ scribus/ui/prefs_documentsetupbase.ui (Arbeitskopie) @@ -28,7 +28,6 @@ <property name="font"> <font> <pointsize>14</pointsize> - <weight>75</weight> <bold>true</bold> </font> </property> @@ -40,7 +39,7 @@ <item> <widget class="Line" name="line"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Orientation::Horizontal</enum> </property> </widget> </item> @@ -69,7 +68,7 @@ <item> <spacer name="horizontalSpacer_3"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Orientation::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -84,10 +83,10 @@ <item> <spacer name="verticalSpacer"> <property name="orientation"> - <enum>Qt::Vertical</enum> + <enum>Qt::Orientation::Vertical</enum> </property> <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> + <enum>QSizePolicy::Policy::Fixed</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -101,7 +100,6 @@ <widget class="QLabel" name="pageSizeTitleLabel"> <property name="font"> <font> - <weight>75</weight> <bold>true</bold> </font> </property> @@ -113,7 +111,7 @@ <item> <widget class="Line" name="line_2"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Orientation::Horizontal</enum> </property> </widget> </item> @@ -124,20 +122,17 @@ <property name="text"> <string>Size:</string> </property> - <property name="buddy"> - <cstring>pageSizeComboBox</cstring> - </property> </widget> </item> <item row="0" column="1"> <layout class="QHBoxLayout" name="pageSizeLayout"> <item> - <widget class="QComboBox" name="pageSizeComboBox"/> + <widget class="PageSizeSelector" name="pageSizeSelector" native="true"/> </item> <item> <widget class="QToolButton" name="pageSizeLinkToolButton"> <property name="arrowType"> - <enum>Qt::NoArrow</enum> + <enum>Qt::ArrowType::NoArrow</enum> </property> </widget> </item> @@ -214,7 +209,7 @@ <item> <spacer name="verticalSpacer_5"> <property name="orientation"> - <enum>Qt::Vertical</enum> + <enum>Qt::Orientation::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -235,7 +230,6 @@ <widget class="QLabel" name="pageLayoutTitleLabel"> <property name="font"> <font> - <weight>75</weight> <bold>true</bold> </font> </property> @@ -247,7 +241,7 @@ <item> <widget class="Line" name="line_3"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Orientation::Horizontal</enum> </property> </widget> </item> @@ -266,7 +260,7 @@ <item row="4" column="1"> <widget class="QComboBox" name="layoutFirstPageIsComboBox"> <property name="sizeAdjustPolicy"> - <enum>QComboBox::AdjustToContents</enum> + <enum>QComboBox::SizeAdjustPolicy::AdjustToContents</enum> </property> </widget> </item> @@ -318,7 +312,7 @@ <item> <spacer name="verticalSpacer_8"> <property name="orientation"> - <enum>Qt::Vertical</enum> + <enum>Qt::Orientation::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -350,10 +344,10 @@ <item> <widget class="QScrollArea" name="scrollArea"> <property name="frameShape"> - <enum>QFrame::NoFrame</enum> + <enum>QFrame::Shape::NoFrame</enum> </property> <property name="frameShadow"> - <enum>QFrame::Plain</enum> + <enum>QFrame::Shadow::Plain</enum> </property> <property name="lineWidth"> <number>0</number> @@ -366,8 +360,8 @@ <rect> <x>0</x> <y>0</y> - <width>458</width> - <height>540</height> + <width>494</width> + <height>575</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_5"> @@ -375,7 +369,6 @@ <widget class="QLabel" name="marginsTitleLabel"> <property name="font"> <font> - <weight>75</weight> <bold>true</bold> </font> </property> @@ -387,7 +380,7 @@ <item> <widget class="Line" name="line_5"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Orientation::Horizontal</enum> </property> </widget> </item> @@ -411,7 +404,7 @@ <item> <spacer name="horizontalSpacer_6"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Orientation::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -440,10 +433,10 @@ <item> <spacer name="verticalSpacer_3"> <property name="orientation"> - <enum>Qt::Vertical</enum> + <enum>Qt::Orientation::Vertical</enum> </property> <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> + <enum>QSizePolicy::Policy::Fixed</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -457,7 +450,6 @@ <widget class="QLabel" name="bleedsTitleLabel"> <property name="font"> <font> - <weight>75</weight> <bold>true</bold> </font> </property> @@ -469,7 +461,7 @@ <item> <widget class="Line" name="line_4"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Orientation::Horizontal</enum> </property> </widget> </item> @@ -493,7 +485,7 @@ <item> <spacer name="horizontalSpacer_7"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Orientation::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -508,7 +500,7 @@ <item> <spacer name="verticalSpacer_4"> <property name="orientation"> - <enum>Qt::Vertical</enum> + <enum>Qt::Orientation::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -546,10 +538,10 @@ <item> <spacer name="verticalSpacer_6"> <property name="orientation"> - <enum>Qt::Vertical</enum> + <enum>Qt::Orientation::Vertical</enum> </property> <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> + <enum>QSizePolicy::Policy::Fixed</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -563,7 +555,6 @@ <widget class="QLabel" name="autosaveTitleLable"> <property name="font"> <font> - <weight>75</weight> <bold>true</bold> </font> </property> @@ -575,7 +566,7 @@ <item> <widget class="Line" name="line_6"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Orientation::Horizontal</enum> </property> </widget> </item> @@ -626,7 +617,7 @@ <item> <spacer name="horizontalSpacer_2"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Orientation::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -689,10 +680,10 @@ <item> <spacer name="verticalSpacer_7"> <property name="orientation"> - <enum>Qt::Vertical</enum> + <enum>Qt::Orientation::Vertical</enum> </property> <property name="sizeType"> - <enum>QSizePolicy::Maximum</enum> + <enum>QSizePolicy::Policy::Maximum</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -706,7 +697,6 @@ <widget class="QLabel" name="undoRedoTitleLabel"> <property name="font"> <font> - <weight>75</weight> <bold>true</bold> </font> </property> @@ -718,7 +708,7 @@ <item> <widget class="Line" name="line_7"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Orientation::Horizontal</enum> </property> </widget> </item> @@ -744,7 +734,7 @@ <item> <spacer name="horizontalSpacer"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Orientation::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -759,7 +749,7 @@ <item> <spacer name="verticalSpacer_2"> <property name="orientation"> - <enum>Qt::Vertical</enum> + <enum>Qt::Orientation::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -787,11 +777,16 @@ <header location="global">ui/newmarginwidget.h</header> <container>1</container> </customwidget> + <customwidget> + <class>PageSizeSelector</class> + <extends>QWidget</extends> + <header>ui/widgets/pagesizeselector.h</header> + <container>1</container> + </customwidget> </customwidgets> <tabstops> <tabstop>tabWidget</tabstop> <tabstop>languageComboBox</tabstop> - <tabstop>pageSizeComboBox</tabstop> <tabstop>pageSizeLinkToolButton</tabstop> <tabstop>pageOrientationComboBox</tabstop> <tabstop>pageUnitsComboBox</tabstop> Index: scribus/ui/prefs_pagesizes.cpp =================================================================== --- scribus/ui/prefs_pagesizes.cpp (Revision 26264) +++ scribus/ui/prefs_pagesizes.cpp (Arbeitskopie) @@ -19,11 +19,15 @@ : Prefs_Pane(parent) { setupUi(this); - languageChange(); m_caption = tr("Page Sizes"); m_icon = "16/page-simple.png"; + treeAvailableSizes->setColumnCount(2); + treeActiveSizes->setColumnCount(2); + + languageChange(); + toActiveButton->setIcon(IconManager::instance().loadIcon("22/go-next.png")); fromActiveButton->setIcon(IconManager::instance().loadIcon("22/go-previous.png")); connect(toActiveButton, SIGNAL(clicked()), this, SLOT(moveToActive())); @@ -34,68 +38,162 @@ void Prefs_PageSizes::languageChange() { - // No need to do anything here, the UI language cannot change while prefs dialog is opened + QString textSize = tr("Page Format"); + QString textDimension = tr("Dimension"); + + if(QTreeWidgetItem* header = treeAvailableSizes->headerItem()) { + header->setText(0, textSize); + + qDebug() << treeAvailableSizes->columnCount(); + if (header->columnCount() > 1) + header->setText(1, textDimension); + } + else + treeAvailableSizes->setHeaderLabel( textSize ); + + + if(QTreeWidgetItem* header = treeActiveSizes->headerItem()) { + header->setText(0, textSize); + if (header->columnCount() > 1) + header->setText(1, textDimension); + } + else + treeActiveSizes->setHeaderLabel( textSize ); + } void Prefs_PageSizes::restoreDefaults(struct ApplicationPrefs *prefsData) { PageSize ps(prefsData->docSetupPrefs.pageSize); - QStringList sizeList(ps.sizeList()); - QStringList activeSizeList(ps.activeSizeList()); - activeSizesListWidget->clear(); - availableSizesListWidget->clear(); - for (int i = 0; i < activeSizeList.count(); ++i) + treeAvailableSizes->clear(); + treeActiveSizes->clear(); + + auto cats = ps.categories(); + + // Available Page Sizes + for (auto it = cats.begin(); it != cats.end(); ++it) { - QListWidgetItem* lwi = new QListWidgetItem(); - PageSize ps2(activeSizeList.at(i)); - lwi->setText(ps2.nameTR()); - lwi->setToolTip(QString("%1 x %2 %3").arg(ps2.originalWidth()).arg(ps2.originalHeight()).arg(ps2.originalUnit())); - activeSizesListWidget->addItem(lwi); + QTreeWidgetItem* tlItem = new QTreeWidgetItem(); + tlItem->setText(0, it.value()); + tlItem->setData(0, Qt::UserRole, it.key()); + + treeAvailableSizes->addTopLevelItem(tlItem); + + PageSizeInfoMap sizes = ps.sizesByCategory(it.key()); + + 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()); + + tlItem->addChild(sItem); + } + } } - for (int i = 0; i < sizeList.count(); ++i) + // Active page Sizes + for (auto it = cats.begin(); it != cats.end(); ++it) { - if (!activeSizeList.contains(sizeList.at(i))) + 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) { - QListWidgetItem* lwi = new QListWidgetItem(); - PageSize ps2(sizeList.at(i)); - lwi->setText(ps2.nameTR()); - lwi->setToolTip(QString("%1 x %2 %3").arg(ps2.originalWidth()).arg(ps2.originalHeight()).arg(ps2.originalUnit())); - availableSizesListWidget->addItem(lwi); + 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); + } + } } + } void Prefs_PageSizes::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const { QStringList newActivePageSizes; - for (int i = 0; i < activeSizesListWidget->count(); ++i) - newActivePageSizes << activeSizesListWidget->item(i)->text(); - PageSize ps(prefsData->docSetupPrefs.pageSize); - prefsData->activePageSizes = ps.untransPageSizeList(newActivePageSizes); + + for (int i = 0; i < treeActiveSizes->topLevelItemCount(); ++i) + { + QTreeWidgetItem* item = treeActiveSizes->takeTopLevelItem(i); + + for (int j = 0; j < item->childCount(); ++j) + newActivePageSizes << item->child(j)->data(0, Qt::UserRole).toString(); + } + + prefsData->activePageSizes = newActivePageSizes; + } void Prefs_PageSizes::moveToActive() { - QList<QListWidgetItem *> si(availableSizesListWidget->selectedItems()); - for (int i = 0; i < si.count(); ++i) - { - QListWidgetItem* it = availableSizesListWidget->takeItem(availableSizesListWidget->row(si.at(i))); - activeSizesListWidget->addItem(it); - } + moveItems(treeAvailableSizes, treeActiveSizes); } void Prefs_PageSizes::moveFromActive() { - QList<QListWidgetItem *> si(activeSizesListWidget->selectedItems()); + int childrenCount = 0; + + for (int i = 0; i < treeActiveSizes->topLevelItemCount(); ++i) + childrenCount += treeActiveSizes->topLevelItem(i)->childCount(); + + if (childrenCount > 1) + moveItems(treeActiveSizes, treeAvailableSizes); +} + +void Prefs_PageSizes::moveItems(QTreeWidget *fromList, QTreeWidget *toList) +{ + QList<QTreeWidgetItem *> si(fromList->selectedItems()); + + if (si.count() != 1) + return; + for (int i = 0; i < si.count(); ++i) { - if (activeSizesListWidget->count()>1) + QTreeWidgetItem* currentItem = si.at(i); + QTreeWidgetItem* currentParent = currentItem->parent(); + + if (currentParent) { - QListWidgetItem* it = activeSizesListWidget->takeItem(activeSizesListWidget->row(si.at(i))); - availableSizesListWidget->addItem(it); + int index = fromList->indexOfTopLevelItem(currentParent); + + QTreeWidgetItem* exItem = currentParent->takeChild(currentParent->indexOfChild(currentItem)); + if (exItem) + { + QTreeWidgetItem* newParentItem = toList->topLevelItem(index); + newParentItem->addChild(exItem); + newParentItem->sortChildren(0, Qt::AscendingOrder); + } } + else + { + int index = fromList->indexOfTopLevelItem(currentItem); + + QList<QTreeWidgetItem*> exItems = currentItem->takeChildren(); + if (exItems.count() > 0) + { + QTreeWidgetItem* newParentItem = toList->topLevelItem(index); + newParentItem->addChildren(exItems); + newParentItem->sortChildren(0, Qt::AscendingOrder); + } + } } } Index: scribus/ui/prefs_pagesizes.h =================================================================== --- scribus/ui/prefs_pagesizes.h (Revision 26264) +++ scribus/ui/prefs_pagesizes.h (Arbeitskopie) @@ -31,6 +31,9 @@ protected slots: void moveToActive(); void moveFromActive(); + +private: + void moveItems(QTreeWidget* fromList, QTreeWidget* toList); }; #endif // PREFS_PAGESIZES_H Index: scribus/ui/prefs_pagesizesbase.ui =================================================================== --- scribus/ui/prefs_pagesizesbase.ui (Revision 26264) +++ scribus/ui/prefs_pagesizesbase.ui (Arbeitskopie) @@ -7,28 +7,27 @@ <x>0</x> <y>0</y> <width>657</width> - <height>358</height> - </rect> - </property> - <layout class="QVBoxLayout" name="verticalLayout_4"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="label"> - <property name="font"> - <font> - <pointsize>14</pointsize> - <weight>75</weight> + <height>358</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QLabel" name="label"> + <property name="font"> + <font> + <pointsize>14</pointsize> <bold>true</bold> </font> </property> @@ -40,7 +39,7 @@ <item> <widget class="Line" name="line"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Orientation::Horizontal</enum> </property> </widget> </item> @@ -56,16 +55,15 @@ </widget> </item> <item> - <widget class="QListWidget" name="availableSizesListWidget"> - <property name="alternatingRowColors"> - <bool>false</bool> - </property> + <widget class="QTreeWidget" name="treeAvailableSizes"> <property name="selectionMode"> - <enum>QAbstractItemView::ExtendedSelection</enum> + <enum>QAbstractItemView::SelectionMode::SingleSelection</enum> </property> - <property name="sortingEnabled"> - <bool>true</bool> - </property> + <column> + <property name="text"> + <string notr="true">1</string> + </property> + </column> </widget> </item> </layout> @@ -75,7 +73,7 @@ <item> <spacer name="verticalSpacer"> <property name="orientation"> - <enum>Qt::Vertical</enum> + <enum>Qt::Orientation::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -102,7 +100,7 @@ <item> <spacer name="verticalSpacer_2"> <property name="orientation"> - <enum>Qt::Vertical</enum> + <enum>Qt::Orientation::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -124,13 +122,15 @@ </widget> </item> <item> - <widget class="QListWidget" name="activeSizesListWidget"> + <widget class="QTreeWidget" name="treeActiveSizes"> <property name="selectionMode"> - <enum>QAbstractItemView::ExtendedSelection</enum> + <enum>QAbstractItemView::SelectionMode::SingleSelection</enum> </property> - <property name="sortingEnabled"> - <bool>true</bool> - </property> + <column> + <property name="text"> + <string notr="true">1</string> + </property> + </column> </widget> </item> </layout> Index: scribus/ui/widgets/pagelayout.cpp =================================================================== --- scribus/ui/widgets/pagelayout.cpp (nicht existent) +++ scribus/ui/widgets/pagelayout.cpp (Arbeitskopie) @@ -0,0 +1,205 @@ +/* +For general Scribus (>=1.3.2) copyright and licensing information please refer +to the COPYING file provided with the program. Following this notice may exist +a copyright and/or license notice that predates the release of Scribus 1.3.2 +for which a new license (GPL+exception) is in place. +*/ +#include "pagelayout.h" + +#include <QComboBox> +#include <QToolButton> +#include <QVBoxLayout> +#include <QListWidgetItem> +#include <QLabel> +#include <QPixmap> +#include <QList> + +#include "commonstrings.h" +#include "iconmanager.h" +#include "scribusapp.h" +#include "ui/widgets/form_widget.h" + +PageLayouts::PageLayouts(QWidget* parent) : QWidget( parent ) +{ + struct PageSet pageS; + pageS.Name = CommonStrings::trPageSet2; + pageS.FirstPage = 0; + pageS.Rows = 1; + pageS.Columns = 1; + pageS.pageNames.clear(); + pageS.pageNames.append(CommonStrings::trPageLocMiddleRight); + m_pageSets.append(pageS); + + layoutGroupLayout = new QHBoxLayout(this); + layoutGroupLayout->setSpacing(4); + layoutGroupLayout->setContentsMargins(0, 0, 0, 0); + + QFont layFont(this->font()); + layFont.setPointSize(8); + + menuScheme = new QMenu(); + + buttonScheme = new QToolButton(this); + buttonScheme->setPopupMode(QToolButton::InstantPopup); + buttonScheme->setMenu(menuScheme); + + labelScheme = new FormWidget(); + labelScheme->setFont(layFont); + labelScheme->addWidget(buttonScheme); + labelScheme->setLabelVisibility(!m_hideLabels); + layoutGroupLayout->addWidget( labelScheme ); + + menuFirstPage = new QMenu(); + + buttonFirstPage = new QToolButton(this); + buttonFirstPage->setPopupMode(QToolButton::InstantPopup); + buttonFirstPage->setMenu(menuFirstPage); + + labelPages = new FormWidget(); + labelPages->setFont(layFont); + labelPages->addWidget( buttonFirstPage ); + labelPages->setLabelVisibility(!m_hideLabels); + layoutGroupLayout->addWidget( labelPages ); + + languageChange(); + + connect(ScQApp, SIGNAL(labelVisibilityChanged(bool)), this, SLOT(toggleLabelVisibility(bool))); + connect(menuScheme, &QMenu::triggered, this, &PageLayouts::changeScheme); + connect(menuFirstPage, &QMenu::triggered, this, &PageLayouts::changeFirstPage); +} + +void PageLayouts::updateSchemeSelector(QList<PageSet> pageSets, int pagePositioning) +{ + m_pageSets = pageSets; + docPagePositioning = pagePositioning; + labelPages->setVisible( docPagePositioning > 0 ); + + reloadScheme(); +} + +void PageLayouts::setFirstPage(int nr) +{ + if (menuFirstPage->actions().count() == 0) + return; + + m_firstPage = qBound(0, nr, menuFirstPage->actions().count()); + buttonFirstPage->setIcon(menuFirstPage->actions().at(m_firstPage)->icon()); +} + +void PageLayouts::setScheme(int nr) +{ + if (menuScheme->actions().count() == 0) + return; + + m_scheme = qBound(0, nr, menuScheme->actions().count()); + buttonScheme->setIcon(menuScheme->actions().at(m_scheme)->icon()); + + reloadFirstPage(m_scheme); + +} + +void PageLayouts::setHideLabelsPermanently(bool hide) +{ + m_hideLabels = hide; + toggleLabelVisibility(!hide); +} + +void PageLayouts::reloadScheme() +{ + disconnect(menuScheme, &QMenu::triggered, this, &PageLayouts::changeScheme); + + menuScheme->clear(); + + for (int pg = 0; pg < m_pageSets.count(); ++pg) + { + //Leave the code in for 3-/4- fold but exclude from UI in case we bring it back. + if (pg > 1 && docPagePositioning < 2) + continue; + + QString psname = CommonStrings::translatePageSetString(m_pageSets[pg].Name); + if (pg == 0) + menuScheme->addAction(IconManager::instance().loadIcon("16/page-simple.png"), psname)->setData(QVariant(pg)); + else if (pg == 1) + menuScheme->addAction(IconManager::instance().loadIcon("16/page-doublesided.png"), psname)->setData(QVariant(pg)); + else if (pg == 2) + menuScheme->addAction(IconManager::instance().loadIcon("16/page-3fold.png"), psname)->setData(QVariant(pg)); + else if (pg == 3) + menuScheme->addAction(IconManager::instance().loadIcon("16/page-4fold.png"), psname)->setData(QVariant(pg)); + else + menuScheme->addAction(IconManager::instance().loadIcon("16/page-simple.png"), psname)->setData(QVariant(pg)); + } + + connect(menuScheme, &QMenu::triggered, this, &PageLayouts::changeScheme); + + +} + +void PageLayouts::reloadFirstPage(int scheme) +{ + disconnect(menuFirstPage, &QMenu::triggered, this, &PageLayouts::changeFirstPage); + + menuFirstPage->clear(); + + // We have to add the other cases if want to support them again + // CommonStrings::trPageLocLeft + // CommonStrings::trPageLocMiddle + // CommonStrings::trPageLocMiddleLeft + // CommonStrings::trPageLocMiddleRight + // CommonStrings::trPageLocRight + + for (int pg = 0; pg < m_pageSets[scheme].pageNames.count(); ++pg) + { + QString psname = CommonStrings::translatePageSetString(m_pageSets[scheme].pageNames[pg]); + + if (psname == CommonStrings::trPageLocLeft) + menuFirstPage->addAction(IconManager::instance().loadIcon("page-first-left"), psname)->setData(QVariant(pg)); + else if (psname == CommonStrings::trPageLocRight) + menuFirstPage->addAction(IconManager::instance().loadIcon("page-first-right"), psname)->setData(QVariant(pg)); + else + menuFirstPage->addAction(IconManager::instance().loadIcon("page-first-left"), psname)->setData(QVariant(pg)); + } + + connect(menuFirstPage, &QMenu::triggered, this, &PageLayouts::changeFirstPage); + + +} + +void PageLayouts::toggleLabelVisibility(bool visibility) +{ + // hide labels always if flag is false + if (m_hideLabels) + visibility = false; + + labelScheme->setLabelVisibility(visibility); + labelPages->setLabelVisibility(visibility); +} + +void PageLayouts::languageChange() +{ + + reloadScheme(); + reloadFirstPage(m_scheme); + + labelScheme->setText( tr( "Scheme" ) ); + labelPages->setText( tr( "First Page" ) ); + + buttonScheme->setToolTip( tr( "Number of pages to show side-by-side on the canvas. Often used for allowing items to be placed across page spreads." ) ); + buttonFirstPage->setToolTip( tr( "Location on the canvas where the first page of the document is placed" ) ); +} + +void PageLayouts::changeScheme(QAction *action) +{ + buttonScheme->setIcon(action->icon()); + int ic = action->data().toInt(); +// setScheme(ic); + reloadFirstPage(ic); + labelPages->setVisible( ic > 0 ); + emit schemeChanged(ic); +} + +void PageLayouts::changeFirstPage(QAction *action) +{ + buttonFirstPage->setIcon(action->icon()); + m_firstPage = action->data().toInt(); + emit firstPageChanged(m_firstPage); +} Index: scribus/ui/widgets/pagelayout.h =================================================================== --- scribus/ui/widgets/pagelayout.h (nicht existent) +++ scribus/ui/widgets/pagelayout.h (Arbeitskopie) @@ -0,0 +1,77 @@ +/* +For general Scribus (>=1.3.2) copyright and licensing information please refer +to the COPYING file provided with the program. Following this notice may exist +a copyright and/or license notice that predates the release of Scribus 1.3.2 +for which a new license (GPL+exception) is in place. +*/ +#ifndef PAGELAYOUT_H +#define PAGELAYOUT_H + +#include <QGroupBox> +#include <QListWidget> +#include <QList> + +class QToolButton; +class QLabel; +class QHBoxLayout; +class FormWidget; +class QMenu; + +#include "scribusapi.h" +#include "scribusstructs.h" +#include "scribusdoc.h" + +/*! \brief A widget for changing pages layout. +User can change layouts on-the-fly changing widget's +comboboxes. */ +class SCRIBUS_API PageLayouts : public QWidget +{ + Q_OBJECT + +public: + PageLayouts(QWidget* parent); + ~PageLayouts() {}; + + void updateSchemeSelector(QList<PageSet> pageSets, int pagePositioning); + void setFirstPage(int nr); + int firstPage() { return m_firstPage; }; + void setScheme(int nr); + int scheme() { return m_scheme; }; + + void setHideLabelsPermanently(bool hide); + bool hideLabelsPermanently() { return m_hideLabels; }; + +public slots: + void toggleLabelVisibility(bool visibility); + +signals: + void schemeChanged(int); + void firstPageChanged(int); + +private: + + int m_scheme {0}; + int m_firstPage {0}; + bool m_hideLabels {false}; + int docPagePositioning {0}; + + FormWidget* labelScheme; + FormWidget* labelPages; + QList<PageSet> m_pageSets; + QToolButton* buttonScheme; + QToolButton* buttonFirstPage; + QMenu* menuScheme; + QMenu* menuFirstPage; + QHBoxLayout* layoutGroupLayout; + + void reloadScheme(); + void reloadFirstPage(int scheme); + +protected slots: + void languageChange(); + void changeScheme(QAction* action); + void changeFirstPage(QAction* action); + +}; + +#endif // PAGELAYOUT_H Index: scribus/ui/widgets/pagesizelist.cpp =================================================================== --- scribus/ui/widgets/pagesizelist.cpp (nicht existent) +++ scribus/ui/widgets/pagesizelist.cpp (Arbeitskopie) @@ -0,0 +1,133 @@ +/* +For general Scribus (>=1.3.2) copyright and licensing information please refer +to the COPYING file provided with the program. Following this notice may exist +a copyright and/or license notice that predates the release of Scribus 1.3.2 +for which a new license (GPL+exception) is in place. +*/ + +#include "pagesizelist.h" +#include "ui/delegates/sclistitemdelegate.h" +#include "pagesize.h" +#include "prefsmanager.h" +#include <QPainter> + +PageSizeList::PageSizeList(QWidget* parent) : + QListWidget(parent) +{ + setDragEnabled(false); + setViewMode(QListView::IconMode); + setFlow(QListView::LeftToRight); + setSortingEnabled(false); +// setWrapping(false); + setWordWrap(true); + setAcceptDrops(false); + setDropIndicatorShown(false); + setDragDropMode(QAbstractItemView::NoDragDrop); + setResizeMode(QListView::Adjust); + setSelectionMode(QAbstractItemView::SingleSelection); + setFocusPolicy(Qt::NoFocus); + setIconSize(QSize(48, 48)); + setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + setGridSize(QSize(128, 128)); + setItemDelegate(new ScListItemDelegate(QListWidget::IconMode, QSize(48,48))); + setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); +} + +void PageSizeList::setFormat(QString format) +{ + loadPageSizes(format, m_orientation, m_category); + m_name = format; +} + +void PageSizeList::setOrientation(int orientation) +{ + loadPageSizes(m_name, orientation, m_category); + m_orientation = orientation; +} + +void PageSizeList::setCategory(PageSizeInfo::Category category) +{ + loadPageSizes(m_name, m_orientation, category); + m_category = category; +} + +void PageSizeList::loadPageSizes(QString name, int orientation, PageSizeInfo::Category category) +{ + PageSize ps(name); + PageSize pref(PrefsManager::instance().appPrefs.docSetupPrefs.pageSize); + + int selection = -1; + + if (m_category == category && this->selectedItems().size() > 0) + selection = this->row(this->selectedItems().first()); + + QSignalBlocker sig(this); + this->clear(); + + foreach (auto item, ps.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 favorites and defaults + if (item.category == category || + (category == PageSizeInfo::Favorite && ps.activePageSizes().contains(item.sizeName)) || + (category == PageSizeInfo::Favorite && item.sizeName == pref.name())) + { + QListWidgetItem *lstItem = new QListWidgetItem(item.trSizeName); + lstItem->setIcon(sizePreview(this->iconSize(), size)); + lstItem->setData(Qt::UserRole, QVariant(item.sizeLabel)); + lstItem->setData(Qt::UserRole + 1, QVariant(item.pageUnitIndex)); + lstItem->setData(Qt::UserRole + 2, QVariant(item.category)); + lstItem->setData(Qt::UserRole + 3, QVariant(item.sizeName)); + this->addItem(lstItem); + + if (selection == -1 && item.sizeName == ps.name()) + lstItem->setSelected(true); + } + } + + if (selection > -1) + this->item(selection)->setSelected(true); + +} + +void PageSizeList::updateGeometries() +{ + QListWidget::updateGeometries(); + verticalScrollBar()->setSingleStep(10); +} + +QIcon PageSizeList::sizePreview(QSize iconSize, QSize pageSize) +{ + QPixmap pix(iconSize); + pix.fill(Qt::transparent); + + bool isVertical = pageSize.width() < pageSize.height(); + double ratio = (double)pageSize.width() / (double)pageSize.height(); + int height = iconSize.height(); + int width = height * ratio; + int x = iconSize.width() / 2 - width / 2; + int y = 0; + + if (!isVertical) + { + ratio = (double)pageSize.height() / (double)pageSize.width(); + width = iconSize.width(); + height = width * ratio; + x = 0; + y = iconSize.height() / 2 - height / 2; + + } + + QRect page(x, y, width, height); + QPainter painter(&pix); + painter.setPen(QPen(palette().text().color())); + painter.setBrush(Qt::white); + painter.drawRect(page.adjusted(0, 0, -1, -1)); + painter.end(); + + return QIcon(pix); + +} Index: scribus/ui/widgets/pagesizelist.h =================================================================== --- scribus/ui/widgets/pagesizelist.h (nicht existent) +++ scribus/ui/widgets/pagesizelist.h (Arbeitskopie) @@ -0,0 +1,45 @@ +/* +For general Scribus (>=1.3.2) copyright and licensing information please refer +to the COPYING file provided with the program. Following this notice may exist +a copyright and/or license notice that predates the release of Scribus 1.3.2 +for which a new license (GPL+exception) is in place. +*/ +#ifndef PAGESIZELIST_H +#define PAGESIZELIST_H + +#include <QListWidget> +#include <QScrollBar> +#include "scribusapi.h" +#include "pagesize.h" + +class SCRIBUS_API PageSizeList : public QListWidget +{ + Q_OBJECT + +public: + PageSizeList(QWidget* parent); + ~PageSizeList() = default; + + void setFormat(QString format); + QString format() { return m_name; }; + + void setOrientation(int orientation); + int orientation() { return m_orientation; }; + + void setCategory(PageSizeInfo::Category category); + PageSizeInfo::Category category() { return m_category; }; + + void updateGeometries() override; + +private: + + QString m_name {QString::number(PageSizeInfo::IsoA) + "_A4"}; + int m_orientation {0}; + PageSizeInfo::Category m_category {PageSizeInfo::Favorite}; + + QIcon sizePreview(QSize iconSize, QSize pageSize); + void loadPageSizes(QString name, int orientation, PageSizeInfo::Category category); +}; + + +#endif // PAGESIZELIST_H Index: scribus/ui/widgets/pagesizepreview.cpp =================================================================== --- scribus/ui/widgets/pagesizepreview.cpp (nicht existent) +++ scribus/ui/widgets/pagesizepreview.cpp (Arbeitskopie) @@ -0,0 +1,79 @@ +#include "pagesizepreview.h" +#include "prefsmanager.h" + +#include <QFontMetrics> + +PageSizePreview::PageSizePreview(QWidget *parent) : QWidget{parent} +{ + setMinimumSize(120, 120); +} + +void PageSizePreview::paintEvent(QPaintEvent *event) +{ + QColor colPage = PrefsManager::instance().appPrefs.displayPrefs.paperColor; + QColor colBackground = PrefsManager::instance().appPrefs.displayPrefs.scratchColor; + QColor colMargin(Qt::blue); + QColor colFrame(Qt::black); + QColor colLabel(Qt::white); + QColor colLabelBackground(QColor(0, 0, 0, 128)); + + + int count = m_layout + 1; + int space = 8; + QRect saveArea(rect().adjusted(space, space, -space, -space)); + double ratio = qMin( saveArea.height() / m_height, saveArea.width() / (m_width * count) ); + double pageWidth = m_width * ratio; + double pageHeight = m_height * ratio; + QSize pageSize(pageWidth, pageHeight); + QRect rectPaper(0, 0, pageSize.width() * count, pageSize.height()); + rectPaper.setLeft( space + (saveArea.width() - rectPaper.width()) / 2 ); + rectPaper.setTop( space + (saveArea.height() - rectPaper.height()) / 2 ); + + QPainter painter(this); + painter.fillRect( rect(), QBrush(colBackground) ); + + for (int i = 0; i < count; i++) + { + QRect rPage(rectPaper.x() + pageSize.width() * i , rectPaper.y(), pageSize.width(), pageSize.height()); + QRect rMargin; + + // Left Page + if (i == 0 && count > 1) + { + rMargin.setLeft(rPage.left() + m_margins.right() * ratio); + rMargin.setRight(rPage.right() - m_margins.left() * ratio); + } + // Right and Single Page + else + { + rMargin.setLeft(rPage.left() + m_margins.left() * ratio); + rMargin.setRight(rPage.right() - m_margins.right() * ratio); + } + + rMargin.setTop(rPage.top() + m_margins.top() * ratio); + rMargin.setBottom(rPage.bottom() - m_margins.bottom() * ratio); + + + // Draw Pages + painter.setBrush( colPage ); + painter.setPen( QPen(colFrame) ); + painter.drawRect( rPage ); + + // Draw Margins + painter.setBrush( Qt::NoBrush ); + painter.setPen( QPen(colMargin) ); + painter.drawRect( rMargin ); + + painter.setPen( QPen(colFrame) ); + if (m_firstPage == i && count > 1) + painter.drawText(rPage, Qt::AlignCenter | Qt::AlignVCenter, QString::number(1)); + + } + + // Draw label + painter.setBackgroundMode(Qt::OpaqueMode); + painter.setBackground(colLabelBackground); + painter.setPen(QPen(colLabel)); + painter.drawText(saveArea, Qt::AlignRight | Qt::AlignBottom |Qt::TextWordWrap, " " + m_name + " "); + +} Index: scribus/ui/widgets/pagesizepreview.h =================================================================== --- scribus/ui/widgets/pagesizepreview.h (nicht existent) +++ scribus/ui/widgets/pagesizepreview.h (Arbeitskopie) @@ -0,0 +1,54 @@ +#ifndef PAGESIZEPREVIEW_H +#define PAGESIZEPREVIEW_H + +#include "margins.h" +#include "pagesize.h" +#include <QWidget> + +class PageSizePreview : public QWidget +{ + Q_OBJECT +public: + explicit PageSizePreview(QWidget *parent = nullptr); + + void setPageHeight(double height) { m_height = height; update(); }; + void setPageWidth(double width) { m_width = width; update(); }; + void setMargins(MarginStruct margins) { m_margins = margins; update(); }; + void setBleeds(MarginStruct bleeds) { m_bleeds = bleeds; update(); }; + void setPageName(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, MarginStruct margins, MarginStruct bleeds, QString name, int layout, int firstPage) + { + PageSize ps(name); + + m_height = height; + m_width = width; + m_margins = margins; + m_bleeds = bleeds; + m_name = ps.nameTR(); + m_layout = layout; + m_firstPage = firstPage; + update(); + } + +private: + MarginStruct m_margins; + MarginStruct m_bleeds; + double m_height; + double m_width; + QString m_name; + int m_layout; + int m_firstPage; + + void paintEvent(QPaintEvent *event) override; + +signals: + +}; + +#endif // PAGESIZEPREVIEW_H Index: scribus/ui/widgets/pagesizeselector.cpp =================================================================== --- scribus/ui/widgets/pagesizeselector.cpp (nicht existent) +++ scribus/ui/widgets/pagesizeselector.cpp (Arbeitskopie) @@ -0,0 +1,161 @@ +/* +For general Scribus (>=1.3.2) copyright and licensing information please refer +to the COPYING file provided with the program. Following this notice may exist +a copyright and/or license notice that predates the release of Scribus 1.3.2 +for which a new license (GPL+exception) is in place. +*/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include <QVBoxLayout> + +#include "pagesizeselector.h" +#include "pagesize.h" +#include "commonstrings.h" + +PageSizeSelector::PageSizeSelector(QWidget *parent) + : QWidget{parent} +{ + comboCategory = new QComboBox(); + comboFormat = new QComboBox(); + + QVBoxLayout* lytMain = new QVBoxLayout(); + lytMain->setContentsMargins(0, 0, 0, 0); + lytMain->setSpacing(4); + lytMain->addWidget(comboCategory); + lytMain->addWidget(comboFormat); + this->setLayout(lytMain); + + connect(comboCategory, &QComboBox::currentIndexChanged, this, &PageSizeSelector::categorySelected); + connect(comboFormat, &QComboBox::currentIndexChanged, this, &PageSizeSelector::formatSelected); +} + + +void PageSizeSelector::setHasFormatSelector(bool isVisble) +{ + m_hasFormatSelector = isVisble; + comboFormat->setVisible(isVisble); +} + +void PageSizeSelector::setHasCustom(bool hasCustom) +{ + m_hasCustom = hasCustom; + + if (!m_sizeName.isEmpty()) + setPageSize(m_sizeName); +} + +void PageSizeSelector::setCurrentCategory(PageSizeInfo::Category category) +{ + int index = comboCategory->findData(category); + if (index != -1) + comboCategory->setCurrentIndex(index); +} + +void PageSizeSelector::setPageSize(QString name) +{ + PageSize ps(name); + + m_sizeName = ps.name(); + m_sizeCategory = ps.category(); + m_trSizeName = ps.nameTR(); + + // Load category list + int index = -1; + QSignalBlocker sigCat(comboCategory); + comboCategory->clear(); + + // Add Custom + if (hasCustom()) + { + comboCategory->addItem(CommonStrings::trCustomPageSize, PageSizeInfo::Custom); + if (m_sizeName == CommonStrings::customPageSize || m_sizeName == CommonStrings::trCustomPageSize) + index = comboCategory->count() - 1; + } + + // Add Favorite + comboCategory->addItem(ps.categoryToString(PageSizeInfo::Favorite), PageSizeInfo::Favorite); + + // Add all available categories + PageSizeCategoriesMap categories = ps.categories(); + for (auto it = categories.begin(); it != categories.end(); ++it) + { + comboCategory->addItem(it.value(), it.key()); + if (it.key() == m_sizeCategory) + index = comboCategory->count() - 1; + } + + comboCategory->setCurrentIndex(index); + comboCategory->insertSeparator(comboCategory->findData(PageSizeInfo::Favorite) + 1); + comboCategory->insertSeparator(comboCategory->findData(PageSizeInfo::USEnvelop) + 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) +{ + if (!hasFormatSelector()) + return; + + PageSize ps(name); + + int index = -1; + QSignalBlocker sigFormat(comboFormat); + comboFormat->clear(); + + if (category == PageSizeInfo::Custom) + { + comboFormat->setEnabled(false); + m_sizeName = CommonStrings::customPageSize; + m_trSizeName = CommonStrings::trCustomPageSize; + return; + } + else + { + comboFormat->setEnabled(true); + } + + foreach (auto item, ps.pageSizes()) { + if (item.category == category || (category == PageSizeInfo::Favorite && ps.activePageSizes().contains(item.sizeName))) + { + comboFormat->addItem(item.trSizeName, item.sizeName); + if (item.sizeName == name) + index = comboFormat->count() - 1; + } + } + + if (index == -1) + index = 0; + + comboFormat->setCurrentIndex(index); + + m_sizeName = static_cast<QString>(comboFormat->currentData().toString()); + m_trSizeName = comboFormat->currentText(); + +} + +void PageSizeSelector::categorySelected(int index) +{ + m_sizeCategory = static_cast<PageSizeInfo::Category>(comboCategory->itemData(index).toInt()); + + setFormat(m_sizeCategory, m_sizeName); + emit pageCategoryChanged(m_sizeCategory); + emit pageSizeChanged(m_trSizeName); +} + +void PageSizeSelector::formatSelected(int index) +{ + m_sizeName = static_cast<QString>(comboFormat->itemData(index).toString()); + m_trSizeName = comboFormat->itemText(index); + + emit pageSizeChanged(m_trSizeName); +} Index: scribus/ui/widgets/pagesizeselector.h =================================================================== --- scribus/ui/widgets/pagesizeselector.h (nicht existent) +++ scribus/ui/widgets/pagesizeselector.h (Arbeitskopie) @@ -0,0 +1,64 @@ +/* +For general Scribus (>=1.3.2) copyright and licensing information please refer +to the COPYING file provided with the program. Following this notice may exist +a copyright and/or license notice that predates the release of Scribus 1.3.2 +for which a new license (GPL+exception) is in place. +*/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef PAGESIZESELECTOR_H +#define PAGESIZESELECTOR_H + +#include <QWidget> +#include <QComboBox> + +#include "pagesize.h" + +class PageSizeSelector : public QWidget +{ + Q_OBJECT +public: + explicit PageSizeSelector(QWidget *parent = nullptr); + + void setPageSize(QString name); + void setHasFormatSelector(bool isVisble ); + void setHasCustom(bool hasCustom); + bool hasCustom() { return m_hasCustom; }; + bool hasFormatSelector() { return m_hasFormatSelector; }; + void setCurrentCategory(PageSizeInfo::Category category); + + PageSizeInfo::Category category() { return m_sizeCategory; }; + QString pageSize() { return m_sizeName; }; + QString pageSizeTR() { return m_trSizeName; }; + +private: + QComboBox* comboCategory; + QComboBox* comboFormat; + + QString m_sizeName; + QString m_trSizeName; + PageSizeInfo::Category m_sizeCategory; + bool m_hasFormatSelector {true}; + bool m_hasCustom {true}; + + void setFormat(PageSizeInfo::Category category, QString name); + +signals: + void pageSizeChanged(QString); + void pageCategoryChanged(PageSizeInfo::Category); + +private slots: + void categorySelected(int index); + void formatSelected(int index); + +}; + +#endif // PAGESIZESELECTOR_H Index: scribus/ui/widgets/section_container.cpp =================================================================== --- scribus/ui/widgets/section_container.cpp (Revision 26264) +++ scribus/ui/widgets/section_container.cpp (Arbeitskopie) @@ -22,7 +22,7 @@ */ SectionContainer::SectionContainer(QWidget *parent) - : SectionContainer("Title", "", true, parent) {} + : SectionContainer("Title", "", true, true, parent) {} SectionContainer::SectionContainer(QString title, QString objectName, bool isCollapsible, bool isExpanded, QWidget *parent) @@ -36,11 +36,12 @@ m_isCollapsed = !isExpanded; // Main Layout - mainLayout = new QVBoxLayout(this); + mainLayout = new QVBoxLayout(); mainLayout->setSpacing(0); mainLayout->setContentsMargins(0, 0, 0, 0); mainLayout->addWidget(header); mainLayout->addWidget(body); + QWidget::setLayout(mainLayout); // Size Policy QSizePolicy sizePol(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum); @@ -241,7 +242,7 @@ QSize SectionContainer::calculateSize() { - QSize s = minimumSizeHint(); + QSize s = SectionContainer::minimumSizeHint(); s.setWidth(this->width()); return s; @@ -435,7 +436,7 @@ SectionContainerHeader::SectionContainerHeader(QWidget *parent) : SectionContainerHeader("Title", parent) {} -SectionContainerHeader::SectionContainerHeader(QString title, QWidget *parent) +SectionContainerHeader::SectionContainerHeader(QString title, QWidget *parent) : QWidget(parent) { int padding = 6; m_hasStyle = true; @@ -490,6 +491,8 @@ void SectionContainerHeader::paintEvent(QPaintEvent *event) { + Q_UNUSED(event) + if (!m_hasStyle) return; |
|
@nitramr, just a small suggestion: I think it would be better to give the area indicated in the picture still to the scrollable area. |
|
Thanks for the feedback. The "show Document..." checkbox is now at the end of the scroll area. Now you can sort the presets by name or page size. In addition, I add a lot more page sizes. Please let me know if you think this is useful or overwhelming. The page icon for page size formats below B3 have a relative size scale to B3 format. In that way, you can see which page size is smaller or bigger than the other. |
|
newdocdialog_2024-08-29_01.patch (291,462 bytes)
Index: Scribus.pro =================================================================== --- Scribus.pro (Revision 26264) +++ Scribus.pro (Arbeitskopie) @@ -481,8 +481,7 @@ scribus/ui/linecombo.h \ scribus/ui/linkbutton.h \ scribus/ui/loremipsum.h \ - scribus/ui/marginpresetlayout.h \ - scribus/ui/marginwidget.h \ + scribus/ui/marginpresetlayout.h \ scribus/ui/mark2item.h \ scribus/ui/mark2mark.h \ scribus/ui/markanchor.h \ @@ -1083,6 +1082,7 @@ scribus/ui/measurementsbase.ui \ scribus/ui/multipleduplicate.ui \ scribus/ui/multiprogressdialog.ui \ + scribus/ui/newdocdialog.ui \ scribus/ui/newmarginwidgetbase.ui \ scribus/ui/nftdialog.ui \ scribus/ui/nftwidget.ui \ @@ -1627,8 +1627,7 @@ scribus/ui/linecombo.cpp \ scribus/ui/linkbutton.cpp \ scribus/ui/loremipsum.cpp \ - scribus/ui/marginpresetlayout.cpp \ - scribus/ui/marginwidget.cpp \ + scribus/ui/marginpresetlayout.cpp \ scribus/ui/mark2item.cpp \ scribus/ui/mark2mark.cpp \ scribus/ui/markanchor.cpp \ Index: resources/iconsets/1_7_0/16/page-orientation-horizontal.svg =================================================================== --- resources/iconsets/1_7_0/16/page-orientation-horizontal.svg (nicht existent) +++ resources/iconsets/1_7_0/16/page-orientation-horizontal.svg (Arbeitskopie) @@ -0,0 +1,3 @@ +<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><style>@import '../colors.css';</style> +<path fill-rule="evenodd" clip-rule="evenodd" d="M5.41421 4L2 7.41421V12H14V4H5.41421ZM1 7L5 3H14H15V4V12V13H14H2H1V12V7Z"/> +</svg> Index: resources/iconsets/1_7_0/16/page-orientation-vertical.svg =================================================================== --- resources/iconsets/1_7_0/16/page-orientation-vertical.svg (nicht existent) +++ resources/iconsets/1_7_0/16/page-orientation-vertical.svg (Arbeitskopie) @@ -0,0 +1,3 @@ +<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><style>@import '../colors.css';</style> +<path fill-rule="evenodd" clip-rule="evenodd" d="M7.41421 2L4 5.41421V14H12V2H7.41421ZM3 5L7 1H12H13V2V14V15H12H4H3V14V5Z"/> +</svg> Index: resources/iconsets/1_7_0/1_7_0.xml =================================================================== --- resources/iconsets/1_7_0/1_7_0.xml (Revision 26264) +++ resources/iconsets/1_7_0/1_7_0.xml (Arbeitskopie) @@ -387,6 +387,8 @@ <icon id="layer-move-up" file="16/object-level-up.svg" /> <icon id="page-first-left" file="16/page-first-left.svg" /> <icon id="page-first-right" file="16/page-first-right.svg" /> + <icon id="page-orientation-horizontal" file="16/page-orientation-horizontal.svg" /> + <icon id="page-orientation-vertical" file="16/page-orientation-vertical.svg" /> <!-- PDF Tools --> <icon id="16/insert-button.png" file="16/pdf-button.svg" /> Index: scribus/CMakeLists_Sources.txt =================================================================== --- scribus/CMakeLists_Sources.txt (Revision 26264) +++ scribus/CMakeLists_Sources.txt (Arbeitskopie) @@ -363,7 +363,6 @@ ui/marksmanager.cpp ui/markvariabletext.cpp ui/marginpresetlayout.cpp - ui/marginwidget.cpp ui/newmarginwidget.cpp ui/mergedoc.cpp ui/missing.cpp @@ -383,7 +382,6 @@ ui/outputpreview_ps.cpp ui/outputpreviewbase.cpp ui/pageitemattributes.cpp - ui/pagelayout.cpp ui/pagepalette.cpp ui/pagepalette_pages.cpp ui/pagepalette_masterpages.cpp @@ -560,6 +558,10 @@ ui/widgets/floatingwindow.cpp ui/widgets/form_widget.cpp ui/widgets/gradientlistbox.cpp + ui/widgets/pagelayout.cpp + ui/widgets/pagesizelist.cpp + ui/widgets/pagesizepreview.cpp + ui/widgets/pagesizeselector.cpp ui/widgets/popup_menu.cpp ui/widgets/section_container.cpp ui/widgets/stacked_container.cpp Index: scribus/designer/formwidget_plugin.cpp =================================================================== --- scribus/designer/formwidget_plugin.cpp (Revision 26264) +++ scribus/designer/formwidget_plugin.cpp (Arbeitskopie) @@ -92,30 +92,25 @@ <ui language="c++" displayname="Form Widget"> <widget class="FormWidget" name="formWidget"> <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> - <property name="font"> - <font> - <pointsize>8</pointsize> - </font> - </property> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - </layout> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + </layout> </widget> <customwidgets> <customwidget> Index: scribus/designer/sectioncontainer_plugin.cpp =================================================================== --- scribus/designer/sectioncontainer_plugin.cpp (Revision 26264) +++ scribus/designer/sectioncontainer_plugin.cpp (Arbeitskopie) @@ -100,9 +100,9 @@ return QLatin1String(R"( <ui language="c++" displayname="Section Container"> <widget class="SectionContainer" name="sectionContainer"> - <widget class="QWidget" name="page"> - <layout class="QVBoxLayout" name="verticalLayout"/> - </widget> + <widget class="QWidget" name="page"> + <layout class="QVBoxLayout" name="verticalLayout"/> + </widget> </widget> <customwidgets> <customwidget> Index: scribus/localemgr.cpp =================================================================== --- scribus/localemgr.cpp (Revision 26264) +++ scribus/localemgr.cpp (Arbeitskopie) @@ -32,6 +32,7 @@ #include "scribuscore.h" #include "localemgr.h" #include "scpaths.h" +#include "pagesize.h" LocaleManager& LocaleManager::instance() { @@ -60,13 +61,20 @@ //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", "A4" )); - m_localeTable.append(LocaleDef("en", "in", "Letter")); - m_localeTable.append(LocaleDef("en_AU", "mm", "A4" )); - m_localeTable.append(LocaleDef("en_GB", "mm", "A4" )); - m_localeTable.append(LocaleDef("en_US", "in", "Letter")); - m_localeTable.append(LocaleDef("fr", "mm", "A4" )); - m_localeTable.append(LocaleDef("fr_QC", "pica", "Letter")); + // m_localeTable.append(LocaleDef("default","mm", QString::number(PageSizeInfo::IsoA) + "_A4" )); + // m_localeTable.append(LocaleDef("en", "in", QString::number(PageSizeInfo::USStandard) + "_Letter")); + // m_localeTable.append(LocaleDef("en_AU", "mm", QString::number(PageSizeInfo::IsoA) + "_A4" )); + // m_localeTable.append(LocaleDef("en_GB", "mm", QString::number(PageSizeInfo::IsoA) + "_A4" )); + // m_localeTable.append(LocaleDef("en_US", "in", QString::number(PageSizeInfo::USStandard) + "_Letter")); + // m_localeTable.append(LocaleDef("fr", "mm", QString::number(PageSizeInfo::IsoA) + "_A4" )); + // m_localeTable.append(LocaleDef("fr_QC", "pica", QString::number(PageSizeInfo::USStandard) + "_Letter")); + 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))); } void LocaleManager::printSelectedForLocale(const QString& locale) @@ -104,8 +112,8 @@ //qDebug()<<"No definition for locale: "<<selectedLocale; //No, we don't translate these, they are internal use that don't get to the GUI if (m_sysLocale.measurementSystem()==0) - return "A4"; - return "Letter"; + return PageSize::defaultSizesList().at(1); + return PageSize::defaultSizesList().at(4); // qFatal("Page Size not found in LocaleManager"); // return ""; } Index: scribus/pagesize.cpp =================================================================== --- scribus/pagesize.cpp (Revision 26264) +++ scribus/pagesize.cpp (Arbeitskopie) @@ -19,17 +19,12 @@ * * ***************************************************************************/ +#include "commonstrings.h" #include "pagesize.h" #include "prefsmanager.h" - #include <QStringList> +#include <QObject> -#include <cmath> -#include <iostream> - -#include "commonstrings.h" - - PageSize::PageSize(const QString& sizeName) { init(sizeName); @@ -68,6 +63,7 @@ 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. @@ -82,6 +78,7 @@ m_height = it.value().height; m_pageUnitIndex = it.value().pageUnitIndex; m_trPageSizeName = it.value().trSizeName; + m_category = it.value().category; valuesSet = true; } } @@ -95,334 +92,655 @@ m_pageUnitIndex = -1; m_pageSizeName = CommonStrings::customPageSize; m_trPageSizeName = CommonStrings::trCustomPageSize; + m_category = PageSizeInfo::Custom; } } -QStringList PageSize::sizeList() const +QStringList PageSize::defaultSizesList() { - QStringList pageSizes; - for (auto it = m_pageSizeList.begin(); it != m_pageSizeList.end(); ++it) - pageSizes.append(it.key()); - return QStringList(pageSizes); + return { "A03", "A04", "A05", "A06", "Letter" }; } -QStringList PageSize::sizeTRList() const +PageSizeCategoriesMap PageSize::categories() { - QStringList pageSizes; + PageSizeCategoriesMap map; + for (auto it = m_pageSizeList.begin(); it != m_pageSizeList.end(); ++it) - pageSizes.append(it.value().trSizeName); - return QStringList(pageSizes); + map.insert(it.value().category, categoryToString(it.value().category)); + + return map; } -QStringList PageSize::activeSizeList() const +PageSizeInfoMap PageSize::sizesByCategory(PageSizeInfo::Category category) { - QStringList pageSizes = sizeList(); - if (PrefsManager::instance().appPrefs.activePageSizes.count() == 0) - return QStringList(pageSizes); - QStringList activePageSizes(PrefsManager::instance().appPrefs.activePageSizes); - QStringList activeSizes; - for (int i = 0; i < activePageSizes.size(); ++i) + PageSizeInfoMap map; + + for (auto it = m_pageSizeList.begin(); it != m_pageSizeList.end(); ++it) { - if (pageSizes.contains(activePageSizes.at(i))) - activeSizes << activePageSizes.at(i); + if (it.value().category == category) + map.insert(it.value().sizeName, it.value()); } - return QStringList(activeSizes); + + return map; } -QStringList PageSize::activeSizeTRList() const +PageSizeInfoMap PageSize::sizesByDimensions(QSize sizePt) { - QStringList pageTRSizes = sizeTRList(); - QStringList pageSizes = sizeList(); - if (PrefsManager::instance().appPrefs.activePageSizes.count() == 0) - return QStringList(pageTRSizes); - QStringList activePageSizes(PrefsManager::instance().appPrefs.activePageSizes); - QStringList activeTRSizes; - for (int i = 0; i < activePageSizes.size(); ++i) + PageSizeInfoMap map; + + for (auto it = m_pageSizeList.begin(); it != m_pageSizeList.end(); ++it) { - int j = pageSizes.indexOf(activePageSizes.at(i)); - if (j != -1) - { - activeTRSizes << pageTRSizes.at(j); - } + if (it.value().width == sizePt.width() && it.value().height == sizePt.height()) + map.insert(it.value().sizeName, it.value()); } - return QStringList(activeTRSizes); + + return map; } -QStringList PageSize::untransPageSizeList(const QStringList &transList) +PageSizeInfoMap PageSize::activePageSizes() { - QStringList pageTRSizes = sizeTRList(); - QStringList pageSizes = sizeList(); - QStringList untranslatedList; - for (int i = 0; i < transList.size(); ++i) + 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) { - int j = pageTRSizes.indexOf(transList.at(i)); - if (j != -1) - { - untranslatedList << pageSizes.at(j); - } + if (activeList.contains(it.value().sizeName)) + map.insert(it.value().sizeName, it.value()); } - return QStringList(untranslatedList); + + return map; } - -void PageSize::generateSizeList() +void PageSize::addPageSize(const QString id, const QString name, double width, double height, int unitIndex, PageSizeInfo::Category category) { - /* - {"A5", "A6", "A7", "A8", "A9", "B0", "B1", "B2", "B3", - "B4", "B5", "B6", "B7", "B8", "B9", "B10", "C5E", "Comm10E", "DLE", QObject::tr("Executive"), - QObject::tr("Folio"), QObject::tr("Ledger"), QObject::tr("Legal"), QObject::tr("Letter"), QObject::tr("Tabloid") - }; - */ -// double width, height, tmp; - int format; - QString name; struct PageSizeInfo info; - /* A series */ -// width = floor(1000.0 / sqrt(sqrt(2.0)) + 0.5); -// height = floor(sqrt(sqrt(2.0))*1000.0 + 0.5); - //4A0 - info.width = mm2pts(1682.0); - info.height = mm2pts(2378.0); - info.pageUnitIndex = SC_MM; - info.trSizeName = QObject::tr("4A0"); - m_pageSizeList.insert("4A0", info); - //2A0 - info.width = mm2pts(1189.0); - info.height = mm2pts(1682.0); - info.pageUnitIndex = SC_MM; - info.trSizeName = QObject::tr("2A0"); - m_pageSizeList.insert("2A0", info); - //Continue with rest of A series - // do not use the formula below, as it is correct in theory, - // but due to rounding errors it gives incorrect results. -/* for (format = 0; format <= 10; format++) { + 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); - info.pageUnitIndex = SC_MM; - name = QString("A%1").arg(format); - info.trSizeName = name; - pageSizeList.insert(name, info); - tmp = height; - height = width; - width = floor(tmp / 2.0); - } */ - // all of the following data is taken from the Ghostscript manual - // "Appendix: Paper sizes known to Ghostscript" - QList<double> Awidths; - QList<double> Aheights; - Awidths << 841.0 << 594.0 << 420.0 << 297.0 << 210.0 << 148.0 << 105.0 << 74.0 << 52.0 << 37.0 << 26.0; - Aheights << 1189.0 << 841.0 << 594.0 << 420.0 << 297.0 << 210.0 << 148.0 << 105.0 << 74.0 << 52.0 << 37.0; - for (format = 0; format < Awidths.count(); format++) - { - info.width = mm2pts(Awidths[format]); - info.height = mm2pts(Aheights[format]); - info.pageUnitIndex = SC_MM; - name = QString("A%1").arg(format); - info.trSizeName = name; - m_pageSizeList.insert(name, info); + unit = "mm"; + break; + case SC_P: // picas + info.width = p2pts(width); + info.height = p2pts(height); + unit = "p"; + break; } - - /* B series */ - Awidths.clear(); - Aheights.clear(); - Awidths << 1000.0 << 707.0 << 500.0 << 353.0 << 250.0 << 176.0 << 125.0 << 88.0 << 62.0 << 44.0 << 31.0; - Aheights << 1414.0 << 1000.0 << 707.0 << 500.0 << 353.0 << 250.0 << 176.0 << 125.0 << 88.0 << 62.0 << 44.0; - for (format = 0; format < Awidths.count(); format++) + + 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) { - info.width = mm2pts(Awidths[format]); - info.height = mm2pts(Aheights[format]); - info.pageUnitIndex = SC_MM; - name = QString("B%1").arg(format); - info.trSizeName = name; - m_pageSizeList.insert(name, info); + 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("Candian"); + 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 Envelop"); + case PageSizeInfo::IsoEnvelop: + return QObject::tr("International Envelops"); + 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::USEnvelop: + return QObject::tr("US Envelops"); + default: + return "undefined"; + break; } - /* C series */ - Awidths.clear(); - Aheights.clear(); - Awidths << 917.0 << 648.0 << 458.0 << 324.0 << 229.0 << 162.0 << 114.0 << 81.0 << 57.0 << 40.0 << 28.0; - Aheights << 1297.0 << 917.0 << 648.0 << 458.0 << 324.0 << 229.0 << 162.0 << 114.0 << 81.0 << 57.0 << 40.0; - for (format = 0; format < Awidths.count(); format++) - { - info.width = mm2pts(Awidths[format]); - info.height = mm2pts(Aheights[format]); - info.pageUnitIndex = SC_MM; - name = QString("C%1").arg(format); - info.trSizeName = name; - m_pageSizeList.insert(name, info); - } -/* - width = 1000.0; - height = floor(sqrt(2.0)*1000.0 + 0.5); +} - for (format = 0; format <= 10; format++) { - info.width = mm2pts(width); - info.height = mm2pts(height); - info.pageUnitIndex = SC_MM; - name = QString("B%1").arg(format); - info.trSizeName = name; - pageSizeList.insert(name, info); - tmp = height; - height = width; - width = floor(tmp / 2.0); - } +void PageSize::generateSizeList() +{ + // Books + // https://papersizes.io/books/ + // https://paper-size.com/size/12mo-books-sizes.html + // https://en.wikipedia.org/wiki/Book_size + 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); - // C series - width = floor(1000.0 / sqrt(sqrt(sqrt(2.0)))+0.5); - height = floor(sqrt(sqrt(sqrt(8.0)))*1000.0 + 0.5); + // 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); - for (format = 0; format <= 10; format++) { - info.width = mm2pts(width); - info.height = mm2pts(height); - info.pageUnitIndex = SC_MM; - name = QString("C%1").arg(format); - info.trSizeName = name; - pageSizeList.insert(name, info); + // 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); - tmp = height; - height = width; - width = floor(tmp / 2.0); - } -*/ - /* PA series */ - double tmp; - double width = 840; - double height = 1120; - for (format = 0; format <= 10; format++) - { - info.width = mm2pts(width); - info.height = mm2pts(height); - info.pageUnitIndex = SC_MM; - name = QString("PA%1").arg(format); - info.trSizeName = name; - m_pageSizeList.insert(name, info); - tmp = height; - height = width; - width = floor(tmp / 2.0); - } - - //Imperial - //http://en.wikipedia.org/wiki/Paper_sizes - double impWidths[]={8.0,8.0,8.5,8.0,8.5,11.0,7.25,15.5,15.0,16.5,17.5,18.0,20.0,23.0,23.5,35.0,5.5,8.5,11.0,17.0,22.0,34.0}; - double impHeights[]={10.0,13.0,11.0,10.5,14.0,17.0,10.5,19.25,20.0,21.0,22.5,23.0,25.0,28.0,35.0,45.0,8.5,11.0,17.0,22.0,34.0,44.0}; - QString impNames[]={"Quarto","Foolscap","Letter","Govt. Letter","Legal","Ledger","Executive","Post","Crown","Large Post","Demy","Medium","Royal","Elephant","Double Demy","Quad Demy","STMT","A","B","C","D","E"}; - QString impTrNames[]={QObject::tr("Quarto"), QObject::tr("Foolscap"), QObject::tr("Letter"), - QObject::tr("Govt. Letter"), QObject::tr("Legal"), QObject::tr("Ledger"), QObject::tr("Executive"), - QObject::tr("Post"), QObject::tr("Crown"), QObject::tr("Large Post"), QObject::tr("Demy"), - QObject::tr("Medium"), QObject::tr("Royal"), QObject::tr("Elephant"), QObject::tr("Double Demy"), - QObject::tr("Quad Demy"), QObject::tr("STMT"), QObject::tr("A"), QObject::tr("B"), QObject::tr("C"), - QObject::tr("D"), QObject::tr("E")}; - - size_t const num_mappings_widths = (sizeof impWidths)/(sizeof *impWidths); - - for (uint i = 0; i < num_mappings_widths; ++i) - { - info.width = in2pts(impWidths[i]); - info.height = in2pts(impHeights[i]); - info.pageUnitIndex = SC_IN; - info.trSizeName = impTrNames[i]; - m_pageSizeList.insert(impNames[i], info); - } - //Comm10E - info.width = in2pts(4.125); - info.height = in2pts(9.5); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("Comm10E"); - m_pageSizeList.insert("Comm10E", info); - //DLE - info.width = mm2pts(110); - info.height = mm2pts(220); - info.pageUnitIndex = SC_MM; - info.trSizeName = QObject::tr("DLE"); - m_pageSizeList.insert("DLE", info); - // additional page sizes used by Viva Designer - //Compact Disc - info.width = mm2pts(119.9); - info.height = mm2pts(120.7); - info.pageUnitIndex = SC_MM; - info.trSizeName = QObject::tr("Compact Disc"); - m_pageSizeList.insert("Compact Disc", info); - //Letter Half - info.width = mm2pts(139.7); - info.height = mm2pts(215.9); - info.pageUnitIndex = SC_MM; - info.trSizeName = QObject::tr("Letter Half"); - m_pageSizeList.insert("Letter Half", info); - //US Letter - info.width = mm2pts(215.9); - info.height = mm2pts(279.4); - info.pageUnitIndex = SC_MM; - info.trSizeName = QObject::tr("US Letter"); - m_pageSizeList.insert("US Letter", info); - //US Legal - info.width = mm2pts(215.9); - info.height = mm2pts(355.6); - info.pageUnitIndex = SC_MM; - info.trSizeName = QObject::tr("US Legal"); - m_pageSizeList.insert("US Legal", info); - //11x17 - info.width = in2pts(11); - info.height = in2pts(17); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("11x17"); - m_pageSizeList.insert("11x17", info); + // 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); - // Arch A 9 × 12 - info.width = in2pts(9); - info.height = in2pts(12); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("9x12 (Arch A)"); - m_pageSizeList.insert("9x12 (Arch A)", info); - // Arch B 12 × 18 - info.width = in2pts(12); - info.height = in2pts(18); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("12x18 (Arch B)"); - m_pageSizeList.insert("12x18 (Arch B)", info); - // Arch C 18 × 24 - info.width = in2pts(18); - info.height = in2pts(24); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("18x24 (Arch C)"); - m_pageSizeList.insert("18x (Arch C)", info); - // Arch D 24 × 36 - info.width = in2pts(24); - info.height = in2pts(36); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("24x36 (Arch D)"); - m_pageSizeList.insert("24x36 (Arch D)", info); - // Arch E 36 × 48 - info.width = in2pts(36); - info.height = in2pts(48); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("36x48 (Arch E)"); - m_pageSizeList.insert("36x48 (Arch E)", info); - // Arch E1 30 × 42 - info.width = in2pts(30); - info.height = in2pts(42); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("30x42 (Arch E1)"); - m_pageSizeList.insert("30x42 (Arch E1)", info); - // Arch E2 26 × 38 - info.width = in2pts(26); - info.height = in2pts(38); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("26x38 (Arch E2)"); - m_pageSizeList.insert("26x38 (Arch E2)", info); - // Arch E3 27 × 39 - info.width = in2pts(27); - info.height = in2pts(39); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("27x39 (Arch E3)"); - m_pageSizeList.insert("27x39 (Arch E3)", info); + // 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); - //Executive - //Folio - //Ledger - //Legal - //Letter - //Tabloid + // 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 catIsoEnvelop = PageSizeInfo::IsoEnvelop; + prefix = "IsoEnv_"; + addPageSize(prefix + "DL/E65", "DL, E65", 110.0, 220.0, SC_MM, catIsoEnvelop); // from 1.6.2 + // addPageSize(prefix + "B4", "B4", 250.0, 353.0, SC_MM, catIsoEnvelop); + // addPageSize(prefix + "B5", "B5", 176.0, 250.0, SC_MM, catIsoEnvelop); + // addPageSize(prefix + "B6", "B6", 125.0, 176.0, SC_MM, catIsoEnvelop); + // addPageSize(prefix + "C3", "C3", 324.0, 458.0, SC_MM, catIsoEnvelop); + // addPageSize(prefix + "C4", "C4", 229.0, 324.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "C4M", "C4M", 229.0, 318.0, SC_MM, catIsoEnvelop); + // addPageSize(prefix + "C5", "C5", 162.0, 229.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "C6/C5", "C6/C5", 114.0, 229.0, SC_MM, catIsoEnvelop); + // addPageSize(prefix + "C6", "C6", 114.0, 162.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "C64M", "C64M", 114.0, 318.0, SC_MM, catIsoEnvelop); + // addPageSize(prefix + "C7", "C7", 81.0, 114.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "C7/C6", "C7/C6", 81.0, 162.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "B6/C4", "B6/C4", 125.0, 324.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "E4", "E4", 220.0, 312.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "E5", "E5", 115.0, 220.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "E56", "E56", 115.0, 115.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "E6", "E6", 110.0, 155.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "EC45", "EC45", 220.0, 229.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "EC5", "EC5", 155.0, 229.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "R7", "R7", 120.0, 135.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "S4", "S4", 250.0, 330.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "S5", "S5", 185.0, 255.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "S65", "S65", 110.0, 225.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "X5", "X5", 105.0, 216.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "EX5", "EX5", 115.0, 216.0, SC_MM, catIsoEnvelop); + + // 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 irgendein langes wort"), 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 catUSEnvelop = PageSizeInfo::USEnvelop; + prefix = "USEnv_"; + addPageSize(prefix + "A01", "A-1", 3.625, 5.125, SC_IN, catUSEnvelop); + addPageSize(prefix + "A02", "A-2 (Lady Grey)", 4.375, 5.75, SC_IN, catUSEnvelop); + addPageSize(prefix + "A04", "A-4", 4.25, 6.25, SC_IN, catUSEnvelop); + addPageSize(prefix + "A06", "A-6 (Thompson Standard)", 4.75, 6.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "A07", "A-7 (Besselheim)", 5.25, 7.25, SC_IN, catUSEnvelop); + addPageSize(prefix + "A08", "A-8 (Carrs)", 5.5, 8.125, SC_IN, catUSEnvelop); + addPageSize(prefix + "A09", "A-9 (Diplomat)", 5.75, 8.75, SC_IN, catUSEnvelop); + addPageSize(prefix + "A10", "A-10 (Willow)", 6.0, 9.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Baronial 04", "Baronial 4", 3.625, 5.125, SC_IN, catUSEnvelop); + addPageSize(prefix + "Baronial 05 1/2", "Baronial 5 1/2", 4.375, 5.75, SC_IN, catUSEnvelop); + addPageSize(prefix + "Baronial 06", "Baronial 6", 4.75, 6.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Baronial Lee", "Lee", 5.25, 7.25, SC_IN, catUSEnvelop); + addPageSize(prefix + "Booklet 03", "Booklet 3", 4.75, 6.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Booklet 04 1/2", "Booklet 4 1/2", 5.5, 7.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Booklet 06", "Booklet 6", 5.75, 8.875, SC_IN, catUSEnvelop); + addPageSize(prefix + "Booklet 06 1/2", "Booklet 6 1/2", 6.0, 9.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Booklet 06 7/8", "Booklet 6 7/8", 6.0, 9.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Booklet 06 3/4", "Booklet 6 3/4", 6.5, 9.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Booklet 07 1/2", "Booklet 7 1/2", 7.5, 10.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Booklet 09", "Booklet 9", 8.75, 11.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Booklet 09 1/2", "Booklet 9 1/2", 9.0, 12.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Booklet 10", "Booklet 10", 9.5, 12.625, SC_IN, catUSEnvelop); + addPageSize(prefix + "Booklet 13", "Booklet 13", 10.0, 13.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Catalog 01", "Catalog 1", 6.0, 9.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Catalog 01 3/4", "Catalog 1 3/4", 6.5, 9.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Catalog 03", "Catalog 3", 7.0, 10.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Catalog 06", "Catalog 6", 7.5, 10.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Catalog 08", "Catalog 8", 8.25, 11.25, SC_IN, catUSEnvelop); + addPageSize(prefix + "Catalog 09 3/4", "Catalog 9 3/4", 8.75, 11.25, SC_IN, catUSEnvelop); + addPageSize(prefix + "Catalog 10 1/2", "Catalog 10 1/2", 9.0, 12.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Catalog 12 1/5", "Catalog 12 1/5", 9.5, 12.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Catalog 13 1/2", "Catalog 13 1/2", 10.0, 13.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Catalog 14 1/2", "Catalog 14 1/2", 11.5, 14.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Catalog 15", "Catalog 15", 10.0, 15.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Catalog 15 1/2", "Catalog 15 1/2", 12.0, 15.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Commerical 05", "Commerical 5", 3.125, 5.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Commerical 06 1/4", "Commerical 6 1/4", 3.5, 6.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Commerical 06 3/4", "Commerical 6 3/4", 3.625, 6.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Commerical 07", "Commerical 7", 3.75, 6.75, SC_IN, catUSEnvelop); + addPageSize(prefix + "Commerical 07 1/2", "Commerical 7 1/2", 3.9375, 7.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Commerical 08 5/8", "Commerical 8 5/8", 3.625, 8.625, SC_IN, catUSEnvelop); + addPageSize(prefix + "Commerical 09", "Commerical 9", 3.875, 8.875, SC_IN, catUSEnvelop); + addPageSize(prefix + "Commerical 10", "Commerical 10", 4.125, 9.5, SC_IN, catUSEnvelop); // from 1.6.2 + addPageSize(prefix + "Commerical 11", "Commerical 11", 4.5, 10.375, SC_IN, catUSEnvelop); + addPageSize(prefix + "Commerical 12", "Commerical 12", 4.75, 11, SC_IN, catUSEnvelop); + addPageSize(prefix + "Commerical 14", "Commerical 14", 5.0, 11.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Square 06", "Square 6", 6.0, 6.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Square 06 1/2", "Square 6 1/2", 6.5, 6.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Square 07", "Square 7", 7.0, 7.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Square 07 1/2", "Square 7 1/2", 7.5, 7.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Square 08", "Square 8", 8.0, 8.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Square 08 1/2", "Square 8 1/2", 8.5, 8.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Square 09", "Square 9", 9.0, 9.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Square 09 1/2", "Square 9 1/2", 9.5, 9.5, SC_IN, catUSEnvelop); + + // 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 @@ -432,7 +750,7 @@ 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() << std::endl; + std::cout << it.value().trSizeName.toStdString() << categoryToString(it.value().category).toStdString() << std::endl; } } Index: scribus/pagesize.h =================================================================== --- scribus/pagesize.h (Revision 26264) +++ scribus/pagesize.h (Arbeitskopie) @@ -24,22 +24,59 @@ #include <QMap> #include <QString> +#include <QSize> #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, + IsoEnvelop = 13, + + USStandard = 20, + USPress = 21, + USEnvelop = 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<QString, PageSizeInfo>; +using PageSizeCategoriesMap = QMap<PageSizeInfo::Category, QString>; class SCRIBUS_API PageSize { public: + PageSize(const QString&); PageSize(const double, const double); PageSize& operator=(const PageSize& other); @@ -46,18 +83,20 @@ void init(const QString&); QString name() const { return m_pageSizeName; } QString nameTR() const { return m_trPageSizeName; } + PageSizeInfo::Category category() { return m_category; }; 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); } - QStringList sizeList() const; - QStringList sizeTRList() const; - QStringList activeSizeList() const; - QStringList activeSizeTRList() const; - void generateSizeList(); + static QStringList defaultSizesList(); + PageSizeCategoriesMap categories(); + PageSizeInfoMap sizesByCategory(PageSizeInfo::Category category); + PageSizeInfoMap sizesByDimensions(QSize sizePt); + PageSizeInfoMap activePageSizes(); + PageSizeInfoMap pageSizes() const { return m_pageSizeList; }; void printSizeList() const; - QStringList untransPageSizeList(const QStringList &transList); + QString categoryToString(PageSizeInfo::Category category) const; private: PageSizeInfoMap m_pageSizeList; @@ -66,6 +105,12 @@ 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); + }; #endif Index: scribus/prefsmanager.cpp =================================================================== --- scribus/prefsmanager.cpp (Revision 26264) +++ scribus/prefsmanager.cpp (Arbeitskopie) @@ -521,7 +521,7 @@ appPrefs.imageCachePrefs.maxCacheEntries = 1000; appPrefs.imageCachePrefs.compressionLevel = 1; appPrefs.activePageSizes.clear(); - appPrefs.activePageSizes << "A3" << "A4" << "A5" << "A6" << "Letter"; + appPrefs.activePageSizes = defaultPageSize.defaultSizesList(); //Attribute setup appPrefs.itemAttrPrefs.defaultItemAttributes.clear(); @@ -1903,7 +1903,7 @@ elem.appendChild(icElem); // active page sizes QDomElement apsElem = docu.createElement("ActivePageSizes"); - apsElem.setAttribute("Names", appPrefs.activePageSizes.join(",")); + apsElem.setAttribute("Names", appPrefs.activePageSizes.join(";")); elem.appendChild(apsElem); // experimental features @@ -2008,7 +2008,8 @@ if (appPrefs.docSetupPrefs.language.isEmpty()) appPrefs.docSetupPrefs.language = "en_GB"; appPrefs.docSetupPrefs.docUnitIndex = dc.attribute("UnitIndex", "0").toInt(); - appPrefs.docSetupPrefs.pageSize = dc.attribute("PageSize", "A4"); + PageSize ps( dc.attribute("PageSize", PageSize::defaultSizesList().at(1)) ); + appPrefs.docSetupPrefs.pageSize = (ps.name() == CommonStrings::customPageSize ) ? PageSize::defaultSizesList().at(1) : ps.name(); 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); @@ -2721,7 +2722,20 @@ // active page sizes if (dc.tagName() == "ActivePageSizes") { - appPrefs.activePageSizes = QString(dc.attribute("Names", "")).split(","); + QStringList checkedPageSizes; + QString separator = dc.attribute("Names", "").contains(";") ? ";" : ","; + appPrefs.activePageSizes = QString(dc.attribute("Names", "")).split(separator); + + // check if page sizes existing + foreach (auto item, appPrefs.activePageSizes) + { + PageSize ps(item); + if (ps.name() != CommonStrings::customPageSize) + checkedPageSizes.append(ps.name()); + } + + appPrefs.activePageSizes = (checkedPageSizes.count() == 0) ? PageSize::defaultSizesList() : checkedPageSizes; + } // experimental features if (dc.tagName() == "ExperimentalFeatures") Index: scribus/scribus.cpp =================================================================== --- scribus/scribus.cpp (Revision 26264) +++ scribus/scribus.cpp (Arbeitskopie) @@ -183,7 +183,6 @@ #include "ui/javadocs.h" #include "ui/layers.h" #include "ui/loremipsum.h" -#include "ui/marginwidget.h" #include "ui/mark2item.h" #include "ui/mark2mark.h" #include "ui/markanchor.h" @@ -2016,12 +2015,12 @@ if (dia->tabSelected() == NewDocDialog::NewDocumentTab) { int facingPages = dia->choosenLayout(); - int firstPage = dia->firstPage->currentIndex(); + int firstPage = dia->pageLayouts->firstPage();//firstPage->currentIndex(); docSet = dia->startDocSetup->isChecked(); - double topMargin = dia->marginGroup->top(); - double bottomMargin = dia->marginGroup->bottom(); - double leftMargin = dia->marginGroup->left(); - double rightMargin = dia->marginGroup->right(); + 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 columnDistance = dia->distance(); double pageWidth = dia->pageWidth(); double pageHeight = dia->pageHeight(); @@ -2029,15 +2028,8 @@ bool autoframes = dia->autoTextFrame->isChecked(); int orientation = dia->orientation(); int pageCount = dia->pageCountSpinBox->value(); - QString pagesize; - if (dia->pageSizeComboBox->currentText() == CommonStrings::trCustomPageSize) - pagesize = CommonStrings::customPageSize; - else - { - PageSize ps2(dia->pageSizeComboBox->currentText()); - pagesize = ps2.name(); - } - doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, numberCols, autoframes, facingPages, dia->unitOfMeasureComboBox->currentIndex(), firstPage, orientation, 1, pagesize, true, pageCount, true, dia->marginGroup->getMarginPreset()); + QString pagesize = dia->pageSizeName(); + doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, numberCols, autoframes, facingPages, dia->unitOfMeasureComboBox->currentIndex(), firstPage, orientation, 1, pagesize, true, pageCount, true, dia->marginGroup->marginPreset()); doc->setPageSetFirstPage(facingPages, firstPage); doc->bleeds()->set(dia->bleedTop(), dia->bleedLeft(), dia->bleedBottom(), dia->bleedRight()); HaveNewDoc(); @@ -2099,12 +2091,12 @@ return false; int facingPages = dia->choosenLayout(); - int firstPage = dia->firstPage->currentIndex(); + int firstPage = dia->pageLayouts->firstPage(); bool docSet = dia->startDocSetup->isChecked(); - double topMargin = dia->marginGroup->top(); - double bottomMargin = dia->marginGroup->bottom(); - double leftMargin = dia->marginGroup->left(); - double rightMargin = dia->marginGroup->right(); + 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 columnDistance = dia->distance(); double pageWidth = dia->pageWidth(); double pageHeight = dia->pageHeight(); @@ -2112,16 +2104,10 @@ bool autoframes = dia->autoTextFrame->isChecked(); int orientation = dia->orientation(); int pageCount = dia->pageCountSpinBox->value(); - QString pagesize; - if (dia->pageSizeComboBox->currentText() == CommonStrings::trCustomPageSize) - pagesize = CommonStrings::customPageSize; - else + QString pagesize = dia->pageSizeName(); + + 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())) { - PageSize ps2(dia->pageSizeComboBox->currentText()); - pagesize = ps2.name(); - } - if (doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, numberCols, autoframes, facingPages, dia->unitOfMeasureComboBox->currentIndex(), firstPage, orientation, 1, pagesize, true, pageCount, true, dia->marginGroup->getMarginPreset())) - { doc->setPageSetFirstPage(facingPages, firstPage); doc->bleeds()->set(dia->bleedTop(), dia->bleedLeft(), dia->bleedBottom(), dia->bleedRight()); m_mainWindowStatusLabel->setText( tr("Ready")); Index: scribus/ui/delegates/sclistitemdelegate.cpp =================================================================== --- scribus/ui/delegates/sclistitemdelegate.cpp (Revision 26264) +++ scribus/ui/delegates/sclistitemdelegate.cpp (Arbeitskopie) @@ -4,6 +4,8 @@ #include <QRect> #include <QApplication> #include <QFlags> +#include <QFontMetrics> +#include <QTextLayout> ScListItemDelegate::ScListItemDelegate(QListView::ViewMode mode, QSize iconSize, TextPosition textPosition, Style style, QObject *parent) : QItemDelegate (parent) @@ -33,6 +35,19 @@ cHighlight.setAlphaF(0.2f); QBrush fillSelected(cHighlight); + QFont subFont = QFont(); +#ifdef Q_OS_MACOS + subFont.setPointSize(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont).pointSize()); +#else + subFont.setPointSize(qRound(QFont().pointSize() * .75)); +#endif + + QFontMetrics fm = painter->fontMetrics(); + QFontMetrics sfm(subFont); + + QTextOption tOptions; + QTextOption sOptions; + if(m_style == Style::Simple) { radius = 0; @@ -41,10 +56,11 @@ lineMarkedPen = Qt::NoPen; } - QTextOption tOptions; + QRect rSaveArea = option.rect.adjusted(padding, padding, -padding, -padding); + QRect rIcon = rSaveArea; + QRect rText = rSaveArea; + QRect rSubText = rSaveArea; - QRect rIcon = option.rect; - QRect rText = option.rect; QRectF rItem = option.rect; rItem = rItem.adjusted(margin, margin, -margin, -margin); @@ -68,6 +84,7 @@ // Item Data QIcon ic = qvariant_cast<QIcon>(index.data(Qt::DecorationRole)); QString title = index.data(Qt::DisplayRole).toString(); + QString subTitle = index.data(Qt::UserRole).toString(); switch (m_textPosition) { @@ -74,22 +91,35 @@ default: case TextPosition::Bottom: { - int hSpace = (option.rect.width() - m_iconSize.width()) / 2; - int vSpace = padding; - QPoint p = option.rect.topLeft(); - rIcon = QRect(p.x() + hSpace, p.y() + vSpace, m_iconSize.width(), m_iconSize.height()); + tOptions.setFlags(QFlag(Qt::AlignBottom|Qt::AlignHCenter|Qt::TextWordWrap)); + sOptions.setFlags(QFlag(Qt::AlignBottom|Qt::AlignHCenter|Qt::TextWordWrap)); - rText = option.rect.adjusted(padding, padding + m_iconSize.height(), -padding, -padding); - tOptions.setFlags(QFlag(Qt::AlignBottom|Qt::AlignHCenter|Qt::TextWordWrap)); + rIcon = QRect(0, 0, m_iconSize.width(), m_iconSize.height()); + rIcon.moveCenter(rSaveArea.center()); + rIcon.moveTop(rSaveArea.top()); + + rSubText = sfm.boundingRect(rSaveArea, sOptions.flags(), subTitle); + rSubText.moveBottom(rSaveArea.bottom()); + + rText = rSaveArea.adjusted(0, rIcon.height(), 0, -rSubText.height() -fm.leading() -fm.descent()); + } break; case TextPosition::Right: { - QPoint p = option.rect.topLeft(); - rIcon = QRect(p.x() + padding, p.y() + padding, m_iconSize.width(), m_iconSize.height()); + tOptions.setFlags(QFlag(Qt::AlignCenter|Qt::AlignLeft|Qt::TextWordWrap)); + sOptions.setFlags(QFlag(Qt::AlignBottom|Qt::AlignLeft|Qt::TextWordWrap)); - rText = option.rect.adjusted(padding * 2 + m_iconSize.width(), padding, -padding, -padding); - tOptions.setFlags(QFlag(Qt::AlignVCenter|Qt::AlignLeft|Qt::TextWordWrap)); + rIcon = QRect(0, 0, m_iconSize.width(), m_iconSize.height()); + rIcon.moveCenter(rSaveArea.center()); + rIcon.moveLeft(rSaveArea.left()); + + rSubText = rSaveArea.adjusted(padding + m_iconSize.width(), 0, 0, 0); + rSubText = sfm.boundingRect(rSaveArea, sOptions.flags(), subTitle); + rSubText.moveBottom(rSaveArea.bottom()); + + rText = rSaveArea.adjusted(padding + m_iconSize.width(), 0, 0, -rSubText.height() -fm.leading() -fm.descent()); + } break; } @@ -103,9 +133,33 @@ // Label if (!title.isEmpty()) { + QRect rectNorm = rText.normalized(); + painter->setPen(fontPen); + painter->setBrush(Qt::NoBrush); painter->setFont(QFont()); - painter->drawText(rText, tOptions.flags(), title, &rText); + + int textWidth = rText.width(); + int lineCount = 0; + QTextLayout textLayout(title, painter->font()); + textLayout.beginLayout(); + + while (++lineCount < rText.height() / fm.lineSpacing()) { + QTextLine line = textLayout.createLine(); + if (!line.isValid()) + break; + + line.setLineWidth(rText.width()); + textWidth += line.naturalTextWidth(); + } + textLayout.endLayout(); + title = fm.elidedText(title, Qt::ElideRight, textWidth); + + painter->drawText(rText, tOptions.flags(), title, &rectNorm); + + painter->setFont(subFont); + painter->drawText(rSubText, sOptions.flags(), subTitle); + } painter->restore(); Index: scribus/ui/inspage.cpp =================================================================== --- scribus/ui/inspage.cpp (Revision 26264) +++ scribus/ui/inspage.cpp (Arbeitskopie) @@ -34,11 +34,11 @@ setWindowIcon(IconManager::instance().loadIcon("AppIcon.png")); dialogLayout = new QVBoxLayout(this); - dialogLayout->setSpacing(6); - dialogLayout->setContentsMargins(9, 9, 9, 9); + dialogLayout->setSpacing(4); + dialogLayout->setContentsMargins(8, 8, 8, 8); whereLayout = new QGridLayout(); - whereLayout->setSpacing(6); + whereLayout->setSpacing(4); whereLayout->setContentsMargins(0, 0, 0, 0); insCountData = new QSpinBox(this); @@ -75,8 +75,8 @@ masterPageGroup->setTitle( tr( "Master Pages" ) ); masterPageLayout = new QGridLayout( masterPageGroup ); masterPageLayout->setAlignment(Qt::AlignTop); - masterPageLayout->setSpacing(6); - masterPageLayout->setContentsMargins(9, 9, 9, 9); + masterPageLayout->setSpacing(4); + masterPageLayout->setContentsMargins(8, 8, 8, 8); if (m_doc->pagePositioning() == 0) { QComboBox* pageData = new QComboBox(masterPageGroup); @@ -224,6 +224,19 @@ masterPageCombos.append(pageData); } } + + QScopedPointer<PageSize> ps(new PageSize(m_doc->pageSize())); + + // try to find coresponding 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(); + dialogLayout->addWidget(masterPageGroup); overrideMPSizingCheckBox = new QCheckBox( tr("Override Master Page Sizing")); dialogLayout->addWidget(overrideMPSizingCheckBox); @@ -230,31 +243,16 @@ dsGroupBox7 = new QGroupBox( this ); dsGroupBox7->setTitle( tr( "Page Size" ) ); dsGroupBox7Layout = new QGridLayout(dsGroupBox7); - dsGroupBox7Layout->setSpacing(6); - dsGroupBox7Layout->setContentsMargins(9, 9, 9, 9); + dsGroupBox7Layout->setSpacing(4); + dsGroupBox7Layout->setContentsMargins(8, 8, 8, 8); textLabel1 = new QLabel( tr( "&Size:" ), dsGroupBox7); - dsGroupBox7Layout->addWidget(textLabel1, 0, 0); - - QScopedPointer<PageSize> ps(new PageSize(m_doc->pageSize())); - prefsPageSizeName = ps->name(); - sizeQComboBox = new QComboBox(dsGroupBox7); - QStringList insertList(ps->activeSizeTRList()); - if (insertList.indexOf(prefsPageSizeName) == -1) - insertList << prefsPageSizeName; - insertList.sort(); - insertList << CommonStrings::trCustomPageSize; - sizeQComboBox->addItems(insertList); - int sizeIndex = insertList.indexOf(ps->nameTR()); - if (sizeIndex != -1) - sizeQComboBox->setCurrentIndex(sizeIndex); - else - sizeQComboBox->setCurrentIndex(sizeQComboBox->count() - 1); - - textLabel1->setBuddy(sizeQComboBox); - dsGroupBox7Layout->addWidget(sizeQComboBox, 0, 1, 1, 3); - + dsGroupBox7Layout->addWidget(textLabel1, 0, 0, Qt::AlignTop | Qt::AlignRight); + pageSizeSelector = new PageSizeSelector(dsGroupBox7); + pageSizeSelector->setPageSize(m_doc->pageSize()); + textLabel1->setBuddy(pageSizeSelector); + dsGroupBox7Layout->addWidget(pageSizeSelector, 0, 1); textLabel2 = new QLabel( tr( "Orie&ntation:" ), dsGroupBox7); - dsGroupBox7Layout->addWidget(textLabel2, 1, 0); + dsGroupBox7Layout->addWidget(textLabel2, 1, 0, Qt::AlignRight); orientationQComboBox = new QComboBox(dsGroupBox7); orientationQComboBox->addItem( tr( "Portrait" ) ); @@ -261,13 +259,13 @@ orientationQComboBox->addItem( tr( "Landscape" ) ); orientationQComboBox->setCurrentIndex(m_doc->pageOrientation() ); textLabel2->setBuddy(orientationQComboBox); - dsGroupBox7Layout->addWidget(orientationQComboBox, 1, 1, 1, 3); + dsGroupBox7Layout->addWidget(orientationQComboBox, 1, 1); widthSpinBox = new ScrSpinBox(1, 10000, dsGroupBox7, m_doc->unitIndex()); widthQLabel = new QLabel( tr( "&Width:" ), dsGroupBox7); widthSpinBox->setValue(m_doc->pageWidth() * m_doc->unitRatio()); widthQLabel->setBuddy(widthSpinBox); - dsGroupBox7Layout->addWidget(widthQLabel, 2, 0); + dsGroupBox7Layout->addWidget(widthQLabel, 2, 0, Qt::AlignRight); dsGroupBox7Layout->addWidget(widthSpinBox, 2, 1); heightSpinBox = new ScrSpinBox(1, 10000, dsGroupBox7, m_doc->unitIndex()); @@ -274,17 +272,17 @@ heightSpinBox->setValue(m_doc->pageHeight() * m_doc->unitRatio()); heightQLabel = new QLabel( tr( "&Height:" ), dsGroupBox7); heightQLabel->setBuddy(heightSpinBox); - dsGroupBox7Layout->addWidget(heightQLabel, 3, 0); + dsGroupBox7Layout->addWidget(heightQLabel, 3, 0, Qt::AlignRight); dsGroupBox7Layout->addWidget(heightSpinBox, 3, 1); moveObjectsCheckBox = new QCheckBox( dsGroupBox7); moveObjectsCheckBox->setText( tr( "Move Objects with their Page" ) ); moveObjectsCheckBox->setChecked(true); - dsGroupBox7Layout->addWidget(moveObjectsCheckBox, 4, 0, 1, 4); + dsGroupBox7Layout->addWidget(moveObjectsCheckBox, 4, 0, 1, 2); dialogLayout->addWidget(dsGroupBox7); dsGroupBox7->setEnabled(false); - bool b = (sizeQComboBox->currentText() == CommonStrings::trCustomPageSize); + bool b = (pageSizeSelector->pageSizeTR() == CommonStrings::trCustomPageSize); heightSpinBox->setEnabled(b); widthSpinBox->setEnabled(b); @@ -298,7 +296,7 @@ connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); connect(orientationQComboBox, SIGNAL(activated(int)), this, SLOT(setOrientation(int))); - connect(sizeQComboBox, SIGNAL(textActivated(QString)), this, SLOT(setSize(QString))); + connect(pageSizeSelector, SIGNAL(pageSizeChanged(QString)), this, SLOT(setSize(QString))); connect(overrideMPSizingCheckBox, SIGNAL(stateChanged(int)), this, SLOT(enableSizingControls(int))); } @@ -325,10 +323,10 @@ void InsPage::setOrientation(int ori) { double br; - setSize(sizeQComboBox->currentText()); + setSize(pageSizeSelector->pageSizeTR()); if (ori == 0) { - if (sizeQComboBox->currentText() == CommonStrings::trCustomPageSize) + if (pageSizeSelector->pageSizeTR() == CommonStrings::trCustomPageSize) { br = widthSpinBox->value(); widthSpinBox->setValue(heightSpinBox->value()); Index: scribus/ui/inspage.h =================================================================== --- scribus/ui/inspage.h (Revision 26264) +++ scribus/ui/inspage.h (Arbeitskopie) @@ -8,6 +8,7 @@ #define INSPAGE_H #include "scribusapi.h" +#include "widgets/pagesizeselector.h" #include <QDialog> #include <QDialogButtonBox> #include <QList> @@ -71,7 +72,8 @@ QLabel* heightQLabel { nullptr }; QLabel* textLabel1 { nullptr }; QLabel* textLabel2 { nullptr }; - QComboBox* sizeQComboBox { nullptr }; + PageSizeSelector* pageSizeSelector { nullptr }; +// QComboBox* sizeQComboBox { nullptr }; QComboBox* orientationQComboBox { nullptr }; QCheckBox* moveObjectsCheckBox { nullptr }; QCheckBox* overrideMPSizingCheckBox { nullptr }; Index: scribus/ui/marginwidget.cpp =================================================================== --- scribus/ui/marginwidget.cpp (Revision 26264) +++ scribus/ui/marginwidget.cpp (nicht existent) @@ -1,623 +0,0 @@ -/* -For general Scribus (>=1.3.2) copyright and licensing information please refer -to the COPYING file provided with the program. Following this notice may exist -a copyright and/or license notice that predates the release of Scribus 1.3.2 -for which a new license (GPL+exception) is in place. -*/ -#include "marginwidget.h" - -#include <QHBoxLayout> -#include <QGridLayout> -#include <QLabel> -#include <QToolTip> -#include <QCheckBox> -#include <QLabel> -#include <QPushButton> - -#include "scrspinbox.h" -#include "units.h" -#include "ui/useprintermarginsdialog.h" - - -MarginWidget::MarginWidget( QWidget* parent, const QString& /*title*/, const MarginStruct* margs, int unitIndex, bool showChangeAll, bool showBleeds) : QTabWidget(parent), - m_useBleeds(showBleeds) -{ - marginData = *margs; - m_savedMargins = *margs; - m_savedPresetItem = PresetLayout::none; //we don't recheck if we are using a layout but always start at none - marginPage = new QWidget(this); - - presetCombo = new PresetLayout(marginPage); - presetLabel = new QLabel( tr("Preset Layouts:"), marginPage); - presetLabel->setBuddy(presetCombo); - m_unitIndex = unitIndex; - m_unitRatio = unitGetRatioFromIndex(unitIndex); - leftR = new ScrSpinBox( 0, 1000, marginPage, unitIndex ); - rightR = new ScrSpinBox( 0, 1000, marginPage, unitIndex ); - topR = new ScrSpinBox( 0, 1000, marginPage, unitIndex ); - bottomR = new ScrSpinBox( 0, 1000, marginPage, unitIndex ); - updateMarginSpinValues(); - - bText = new QLabel( tr( "&Bottom:" ), marginPage); - bText->setBuddy(bottomR); - tText = new QLabel( tr( "&Top:" ), marginPage); - tText->setBuddy(topR); - rText = new QLabel( tr( "&Right:" ), marginPage); - rText->setBuddy(rightR); - lText = new QLabel( tr( "&Left:" ), marginPage); - lText->setBuddy(leftR); - - linkMargins = new LinkButton( marginPage ); - linkMargins->setCheckable( true ); - linkMargins->setChecked(false); - linkMargins->setAutoRaise( true ); - linkMargins->setMinimumSize( QSize( 15, 0 ) ); - linkMargins->setMaximumSize( QSize( 15, 32767 ) ); - - // layout - GroupLayout = new QGridLayout( marginPage ); - GroupLayout->setSpacing(6); - GroupLayout->setContentsMargins(9, 9, 9, 9); - GroupLayout->addWidget(presetLabel, 0, 0); - GroupLayout->addWidget(presetCombo, 0, 1); - GroupLayout->addWidget( leftR, 1, 1 ); - GroupLayout->addWidget( rightR, 2, 1 ); - GroupLayout->addWidget( topR, 3, 1 ); - GroupLayout->addWidget( bottomR, 4, 1 ); - GroupLayout->addWidget( lText, 1, 0 ); - GroupLayout->addWidget( rText, 2, 0 ); - GroupLayout->addWidget( tText, 3, 0 ); - GroupLayout->addWidget( bText, 4, 0 ); - GroupLayout->addWidget( linkMargins, 1, 2, 4, 1 ); - if (showChangeAll) - { - marginsForPagesLayout = new QHBoxLayout; - marginsForPagesLayout->setContentsMargins(9, 9, 9, 9); - marginsForPagesLayout->setSpacing(6); - marginsForPages = new QLabel( tr( "Apply settings to:" ), marginPage ); - marginsForPagesLayout->addWidget(marginsForPages); - marginsForAllPages = new QCheckBox( marginPage ); - marginsForAllPages->setText( tr( "All Document Pages" ) ); - marginsForAllPages->setChecked( false ); - marginsForPagesLayout->addWidget(marginsForAllPages); - marginsForAllMasterPages = new QCheckBox( marginPage ); - marginsForAllMasterPages->setText( tr( "All Master Pages" ) ); - marginsForAllMasterPages->setChecked( false ); - marginsForPagesLayout->addWidget(marginsForAllMasterPages); - GroupLayout->addLayout( marginsForPagesLayout, 6, 0, 1, 2 ); - marginsForAllPages->setToolTip( "<qt>" + tr( "Apply the margin changes to all existing pages in the document" ) + "</qt>" ); - marginsForAllMasterPages->setToolTip( "<qt>" + tr( "Apply the margin changes to all existing master pages in the document" ) + "</qt>" ); - } - - usePrinterMarginsButton = nullptr; - usePrinterMarginsButton = new QPushButton( tr("Printer Margins..."),marginPage ); - GroupLayout->addWidget( usePrinterMarginsButton, 5, 1 ); - usePrinterMarginsButton->setToolTip( "<qt>" + tr( "Import the margins for the selected page size from the available printers" ) + "</qt>"); - connect(usePrinterMarginsButton, SIGNAL(clicked()), this, SLOT(setMarginsToPrinterMargins())); - - addTab(marginPage, tr("Margin Guides")); - - if (m_useBleeds) - { - bleedPage = new QWidget(this); - BleedGroupLayout = new QGridLayout( bleedPage ); - BleedGroupLayout->setSpacing(6); - BleedGroupLayout->setContentsMargins(9, 9, 9, 9); - BleedGroupLayout->setAlignment( Qt::AlignTop ); - BleedTxt3 = new QLabel( bleedPage ); - BleedGroupLayout->addWidget( BleedTxt3, 0, 0 ); - BleedLeft = new ScrSpinBox( 0, 3000*m_unitRatio, bleedPage, unitIndex ); - BleedGroupLayout->addWidget( BleedLeft, 0, 1 ); - BleedTxt4 = new QLabel( bleedPage ); - BleedGroupLayout->addWidget( BleedTxt4, 1, 0 ); - BleedRight = new ScrSpinBox( 0, 3000*m_unitRatio, bleedPage, unitIndex ); - BleedGroupLayout->addWidget( BleedRight, 1, 1 ); - BleedTxt1 = new QLabel( bleedPage ); - BleedTxt1->setText( tr( "Top:" ) ); - BleedGroupLayout->addWidget( BleedTxt1, 2, 0 ); - BleedTop = new ScrSpinBox( 0, 3000*m_unitRatio, bleedPage, unitIndex ); - BleedGroupLayout->addWidget( BleedTop, 2, 1 ); - BleedTxt2 = new QLabel( bleedPage ); - BleedTxt2->setText( tr( "Bottom:" ) ); - BleedGroupLayout->addWidget( BleedTxt2, 3, 0 ); - BleedBottom = new ScrSpinBox( 0, 3000*m_unitRatio, bleedPage, unitIndex ); - BleedGroupLayout->addWidget( BleedBottom, 3, 1 ); - linkBleeds = new LinkButton( bleedPage ); -/** Fix Me to move this to the prefsmanager.cpp someday */ - linkBleeds->setCheckable( true ); - linkBleeds->setChecked(true); - linkBleeds->setAutoRaise( true ); - linkBleeds->setMinimumSize( QSize( 15, 0 ) ); - linkBleeds->setMaximumSize( QSize( 15, 32767 ) ); - BleedGroupLayout->addWidget( linkBleeds, 0, 2, 4, 1 ); - BleedTop->setToolTip( "<qt>" + tr( "Distance for bleed from the top of the physical page" ) + "</qt>" ); - BleedBottom->setToolTip( "<qt>" + tr( "Distance for bleed from the bottom of the physical page" ) + "</qt>" ); - BleedLeft->setToolTip( "<qt>" + tr( "Distance for bleed from the left of the physical page" ) + "</qt>" ); - BleedRight->setToolTip( "<qt>" + tr( "Distance for bleed from the right of the physical page" ) + "</qt>"); - linkBleeds->setToolTip( "<qt>" + tr( "Ensure all bleeds have the same value" ) + "</qt>"); - connect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(linkBleeds, SIGNAL(clicked()), this, SLOT(slotLinkBleeds())); - addTab(bleedPage, tr("Bleeds")); - } - - // hints - topR->setToolTip( "<qt>" + tr( "Distance between the top margin guide and the edge of the page" ) + "</qt>"); - bottomR->setToolTip( "<qt>" + tr( "Distance between the bottom margin guide and the edge of the page" ) + "</qt>"); - leftR->setToolTip( "<qt>" + tr( "Distance between the left margin guide and the edge of the page. If a double-sided, 3 or 4-fold layout is selected, this margin space can be used to achieve the correct margins for binding.") + "</qt>"); - rightR->setToolTip( "<qt>" + tr( "Distance between the right margin guide and the edge of the page. If a double-sided, 3 or 4-fold layout is selected, this margin space can be used to achieve the correct margins for binding.") + "</qt>"); - linkMargins->setToolTip( "<qt>" + tr( "Ensure all margins have the same value") + "</qt>"); - - // signals&slots - connect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - connect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - connect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - connect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - connect(presetCombo, SIGNAL(activated(int)), this, SLOT(setPreset())); - connect(linkMargins, SIGNAL(clicked()), this, SLOT(slotLinkMargins())); -} - -void MarginWidget::slotLinkBleeds() -{ - disconnect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - - double bleedValue = BleedLeft->value(); - if (BleedLeft->hasFocus()) - { - BleedLeft->clearFocus(); - bleedValue = BleedLeft->value(); - } - if (BleedRight->hasFocus()) - { - BleedRight->clearFocus(); - bleedValue = BleedRight->value(); - } - if (BleedTop->hasFocus()) - { - BleedTop->clearFocus(); - bleedValue = BleedTop->value(); - } - if (BleedBottom->hasFocus()) - { - BleedBottom->clearFocus(); - bleedValue = BleedBottom->value(); - } - - if (linkBleeds->isChecked()) - { - BleedLeft->setValue(bleedValue); - BleedTop->setValue(bleedValue); - BleedBottom->setValue(bleedValue); - BleedRight->setValue(bleedValue); - } - - connect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); -} - -void MarginWidget::changeBleeds() -{ - if (linkBleeds->isChecked()) - { - double val = 0.0; - if (BleedTop == sender()) - val = BleedTop->value(); - else if (BleedBottom == sender()) - val = BleedBottom->value(); - else if (BleedLeft == sender()) - val = BleedLeft->value(); - else if (BleedRight == sender()) - val = BleedRight->value(); - val = val / m_unitRatio; - MarginStruct v(val,val,val,val); - setNewBleeds(v); - } -} - -void MarginWidget::setFacingPages(bool facing, int pagetype) -{ - m_facingPages = facing; - m_pageType = pagetype; - lText->setText(facing ? tr( "&Inside:" ) : tr( "&Left:" )); - rText->setText(facing ? tr( "O&utside:" ) : tr( "&Right:" )); - if (m_useBleeds) - { - if (facing) - { - BleedTxt3->setText( tr( "Inside:" ) ); - BleedTxt4->setText( tr( "Outside:" ) ); - } - else - { - BleedTxt3->setText( tr( "Left:" ) ); - BleedTxt4->setText( tr( "Right:" ) ); - } - } - setPreset(); -} - -void MarginWidget::setPageWidthHeight(double width, double height) -{ - rightR->setMaximum(qMax(0.0, width * m_unitRatio - leftR->value())); - leftR->setMaximum(qMax(0.0, width * m_unitRatio - rightR->value())); - m_pageWidth = width; - topR->setMaximum(qMax(0.0, height * m_unitRatio - bottomR->value())); - bottomR->setMaximum(qMax(0.0, height * m_unitRatio - topR->value())); - m_pageHeight = height; - setPreset(); -} - -void MarginWidget::setPageWidth(double width) -{ - rightR->setMaximum(qMax(0.0, width * m_unitRatio - leftR->value())); - leftR->setMaximum(qMax(0.0,width * m_unitRatio - rightR->value())); - m_pageWidth = width; - setPreset(); -} - -void MarginWidget::setPageHeight(double height) -{ - topR->setMaximum(qMax(0.0, height * m_unitRatio - bottomR->value())); - bottomR->setMaximum(qMax(0.0,height * m_unitRatio - topR->value())); - m_pageHeight = height; - setPreset(); -} - -void MarginWidget::setTop() -{ - double newVal = topR->value() / m_unitRatio; - bottomR->setMaximum(qMax(0.0, m_pageHeight * m_unitRatio - topR->value())); - if (linkMargins->isChecked() && m_savedPresetItem == PresetLayout::none) - { - marginData.set(newVal, newVal, newVal, newVal); - updateMarginSpinValues(); - } - else - marginData.setTop(newVal); - setPreset(); -} - -void MarginWidget::setBottom() -{ - double newVal = bottomR->value() / m_unitRatio; - topR->setMaximum(qMax(0.0, m_pageHeight * m_unitRatio - bottomR->value())); - if (linkMargins->isChecked() && m_savedPresetItem == PresetLayout::none) - { - marginData.set(newVal, newVal, newVal, newVal); - updateMarginSpinValues(); - } - else - marginData.setBottom(newVal); - setPreset(); -} - -void MarginWidget::setLeft() -{ - double newVal = leftR->value() / m_unitRatio; - rightR->setMaximum(qMax(0.0, m_pageWidth * m_unitRatio - leftR->value())); - if (linkMargins->isChecked() && m_savedPresetItem == PresetLayout::none) - { - marginData.set(newVal, newVal, newVal, newVal); - updateMarginSpinValues(); - } - else - marginData.setLeft(newVal); - setPreset(); -} - -void MarginWidget::setRight() -{ - double newVal = rightR->value() / m_unitRatio; - leftR->setMaximum(qMax(0.0, m_pageWidth * m_unitRatio - rightR->value())); - if (linkMargins->isChecked() && m_savedPresetItem == PresetLayout::none) - { - marginData.set(newVal, newVal, newVal, newVal); - updateMarginSpinValues(); - } - else - marginData.setRight(newVal); - setPreset(); -} - -void MarginWidget::setNewUnit(int newUnitIndex) -{ - disconnect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - disconnect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - disconnect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - disconnect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - m_unitIndex = newUnitIndex; - m_unitRatio = unitGetRatioFromIndex(newUnitIndex); - topR->setNewUnit(newUnitIndex); - bottomR->setNewUnit(newUnitIndex); - leftR->setNewUnit(newUnitIndex); - rightR->setNewUnit(newUnitIndex); - - if (m_useBleeds) - { - disconnect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - BleedBottom->setNewUnit(newUnitIndex); - BleedTop->setNewUnit(newUnitIndex); - BleedRight->setNewUnit(newUnitIndex); - BleedLeft->setNewUnit(newUnitIndex); - connect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - } - connect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - connect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - connect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - connect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); -} - -void MarginWidget::setPreset() -{ - disconnect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - disconnect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - disconnect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - disconnect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - if (m_savedPresetItem == PresetLayout::none) - m_savedMargins = marginData; - int item = presetCombo->currentIndex(); - - MarginStruct marg = presetCombo->getMargins(item, m_pageWidth, m_pageHeight, leftR->value() / m_unitRatio); - presetCombo->setEnabled(m_facingPages); - - bool restoringValues = false; - if ((item == PresetLayout::none) && (m_savedPresetItem != PresetLayout::none)) - { - marg = m_savedMargins; - restoringValues = true; - } - if (restoringValues || (presetCombo->needUpdate() && m_facingPages)) - { - marginData.set(qMax(0.0, marg.top()), qMax(0.0, marg.left()), qMax(0.0, marg.bottom()), qMax(0.0, marg.right())); - updateMarginSpinValues(); - - bottomR->setMaximum(qMax(0.0, m_pageHeight * m_unitRatio - topR->value())); - topR->setMaximum(qMax(0.0, m_pageHeight * m_unitRatio - bottomR->value())); - rightR->setMaximum(qMax(0.0, m_pageWidth * m_unitRatio - leftR->value())); - leftR->setMaximum(qMax(0.0, m_pageWidth * m_unitRatio - rightR->value())); - rightR->setEnabled(restoringValues); - topR->setEnabled(restoringValues); - bottomR->setEnabled(restoringValues); - } - else - { - rightR->setEnabled(true); - topR->setEnabled(true); - bottomR->setEnabled(true); - } - if (m_pageType == 1) - rightR->setEnabled(false); - leftR->setEnabled(item != PresetLayout::nineparts); - if (item != PresetLayout::none) - linkMargins->setChecked(false); - linkMargins->setEnabled(item == PresetLayout::none || !presetCombo->isEnabled()); - connect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - connect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - connect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - connect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - m_savedPresetItem = item; -} - -void MarginWidget::setPageSize(const QString& pageSize) -{ - m_pageSize = pageSize; -} - -void MarginWidget::setMarginsToPrinterMargins() -{ - 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); - presetCombo->setCurrentIndex(PresetLayout::none); - - marginData.setTop(t); - marginData.setBottom(b); - marginData.setLeft(l); - marginData.setRight(r); - updateMarginSpinValues(); - - bottomR->setMaximum((qMax(0.0, m_pageHeight - t) * m_unitRatio)); - topR->setMaximum((qMax(0.0, m_pageHeight - b) * m_unitRatio)); - rightR->setMaximum((qMax(0.0, m_pageWidth - l) * m_unitRatio)); - leftR->setMaximum((qMax(0.0, m_pageWidth - r) * m_unitRatio)); - - rightR->setEnabled(true); - topR->setEnabled(true); - bottomR->setEnabled(true); -} - -double MarginWidget::top() const -{ - return marginData.top(); -} - -double MarginWidget::bottom() const -{ - return marginData.bottom(); -} - -double MarginWidget::left() const -{ - return marginData.left(); -} - -double MarginWidget::right() const -{ - return marginData.right(); -} - -void MarginWidget::setNewMargins(MarginStruct &m) -{ - disconnect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - disconnect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - disconnect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - disconnect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - marginData = m; - updateMarginSpinValues(); - connect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - connect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - connect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - connect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); -} - -void MarginWidget::setMarginPreset(int p) -{ - disconnect(presetCombo, SIGNAL(activated(int)), this, SLOT(setPreset())); - m_savedPresetItem = p; - presetCombo->setCurrentIndex(p); - if (m_savedPresetItem == PresetLayout::none) - m_savedMargins = marginData; - int item = presetCombo->currentIndex(); - presetCombo->setEnabled(m_facingPages); - bool restoringValues = false; - if ((item == PresetLayout::none) && (m_savedPresetItem != PresetLayout::none)) - { - restoringValues = true; - } - if (restoringValues || (presetCombo->needUpdate() && m_facingPages)) - { - rightR->setEnabled(restoringValues); - topR->setEnabled(restoringValues); - bottomR->setEnabled(restoringValues); - } - else - { - rightR->setEnabled(true); - topR->setEnabled(true); - bottomR->setEnabled(true); - } - if (m_pageType == 1) - rightR->setEnabled(false); - leftR->setEnabled(item != PresetLayout::nineparts); - if (item != PresetLayout::none) - linkMargins->setChecked(false); - linkMargins->setEnabled(item == PresetLayout::none); - connect(presetCombo, SIGNAL(activated(int)), this, SLOT(setPreset())); -} - -int MarginWidget::getMarginPreset() -{ - return presetCombo->currentIndex(); -} - -bool MarginWidget::getMarginsForAllPages() const -{ - return marginsForAllPages->isChecked(); -} - -bool MarginWidget::getMarginsForAllMasterPages() const -{ - return marginsForAllMasterPages->isChecked(); -} - -void MarginWidget::setNewBleeds(MarginStruct& b) -{ - disconnect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - BleedTop->setValue(b.top() * m_unitRatio); - BleedBottom->setValue(b.bottom() * m_unitRatio); - BleedLeft->setValue(b.left() * m_unitRatio); - BleedRight->setValue(b.right() * m_unitRatio); - connect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); -} - -double MarginWidget::topBleed() const -{ - return BleedTop->value() / m_unitRatio; -} - -double MarginWidget::bottomBleed() const -{ - return BleedBottom->value() / m_unitRatio; -} - -double MarginWidget::leftBleed() const -{ - return BleedLeft->value() / m_unitRatio; -} - -double MarginWidget::rightBleed() const -{ - return BleedRight->value() / m_unitRatio; -} - -const MarginStruct & MarginWidget::margins() const -{ - return marginData; -} - -void MarginWidget::slotLinkMargins() -{ - disconnect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - disconnect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - disconnect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - disconnect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - - double marginValue = leftR->value(); - if (leftR->hasFocus()) - { - leftR->clearFocus(); - marginValue = leftR->value(); - } - if (rightR->hasFocus()) - { - rightR->clearFocus(); - marginValue = rightR->value(); - } - if (topR->hasFocus()) - { - topR->clearFocus(); - marginValue = topR->value(); - } - if (bottomR->hasFocus()) - { - bottomR->clearFocus(); - marginValue = bottomR->value(); - } - - if (linkMargins->isChecked()) - { - leftR->setValue(marginValue); - bottomR->setValue(marginValue); - topR->setValue(marginValue); - rightR->setValue(marginValue); - double newVal = marginValue / m_unitRatio; - marginData.set(newVal, newVal, newVal, newVal); - } - - connect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - connect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - connect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - connect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - -} - -void MarginWidget::updateMarginSpinValues() -{ - topR->setValue(marginData.top() * m_unitRatio); - rightR->setValue(marginData.right() * m_unitRatio); - bottomR->setValue(marginData.bottom() * m_unitRatio); - leftR->setValue(marginData.left() * m_unitRatio); -} Property changes on: scribus/ui/marginwidget.cpp ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Author Date Id Revision \ No newline at end of property Index: scribus/ui/marginwidget.h =================================================================== --- scribus/ui/marginwidget.h (Revision 26264) +++ scribus/ui/marginwidget.h (nicht existent) @@ -1,178 +0,0 @@ -/* -For general Scribus (>=1.3.2) copyright and licensing information please refer -to the COPYING file provided with the program. Following this notice may exist -a copyright and/or license notice that predates the release of Scribus 1.3.2 -for which a new license (GPL+exception) is in place. -*/ -#ifndef MARGINWIDGET_H -#define MARGINWIDGET_H - -#include "scribusapi.h" -#include "scribusstructs.h" - -#include <QComboBox> -#include <QTabWidget> -#include "linkbutton.h" -#include "marginpresetlayout.h" - -class QCheckBox; -class QPushButton; -class QLabel; -class QGridLayout; -class QHBoxLayout; -class ScrSpinBox; - - -/*! \brief Widget for Margins setting. -Used e.g. in "New Doc Dialog" or "Preferences". -*/ -class SCRIBUS_API MarginWidget : public QTabWidget -{ - Q_OBJECT - -public: - /*! \brief It creates an user interface for base margin settings for the document. - \param parent Parent widget (used as standard in Qt) - \param title Title of the Group box - \param margs A reference to the margins in the preferences. - \param unitIndex and index of the unit combobox - \param showChangeAll show "apply to all pages" related items - */ - MarginWidget(QWidget* parent, const QString& title, const MarginStruct* margs, int unitIndex, bool showChangeAll = false, bool showBleeds = true); - ~MarginWidget() {} - /*! \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 and height */ - void setPageWidthHeight(double width, double height); - /*! \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); - /*! \brief Setup the widgets by new options */ - void setNewUnit(int newUnitIndex); - /*! \brief Set the page size for margin getting from cups */ - void setPageSize(const QString& pageSize); - - /*! \brief Margins - \retval MarginStruct data */ - const MarginStruct& margins() const; - /*! \brief Top Margin - \retval double margin size */ - double top() const; - /*! \brief Bottom Margin - \retval double margin size */ - double bottom() const; - /*! \brief Left Margin - \retval double margin size */ - double left() const; - /*! \brief Right Margin - \retval double margin size */ - double right() const; - - /*! \brief set new margin values for the dialog - It calls overridden setTop(), setBottom() etc. slots itself - via signals emitted from spinboxes. - \param m MarginStruct - */ - void setNewMargins(MarginStruct& m); - - /*! \brief Setup the presetCombo without changing the margin values, only used by tabdocument */ - void setMarginPreset(int p); - int getMarginPreset(); - - /*! \brief Top Bleed - \retval double bleed size */ - double topBleed() const; - /*! \brief Bottom Bleed - \retval double bleed size */ - double bottomBleed() const; - /*! \brief Left Bleed - \retval double bleed size */ - double leftBleed() const; - /*! \brief Right Bleed - \retval double bleed size */ - double rightBleed() const; - - /*! \brief set new bleed values for the dialog - \param b MarginStruct - */ - void setNewBleeds(MarginStruct& b); - - /*! \brief Return marginsForAllPages property - \retval bool true to apply for all pages */ - bool getMarginsForAllPages() const; - bool getMarginsForAllMasterPages() const; - -private: - /*! Tabs */ - QWidget *marginPage { nullptr }; - QWidget* bleedPage { nullptr }; - /*! Spinboxes */ - ScrSpinBox* topR { nullptr }; - ScrSpinBox* bottomR { nullptr }; - ScrSpinBox* rightR { nullptr }; - ScrSpinBox* leftR { nullptr }; - ScrSpinBox* BleedBottom { nullptr }; - ScrSpinBox* BleedLeft { nullptr }; - ScrSpinBox* BleedRight { nullptr }; - ScrSpinBox* BleedTop { nullptr }; - PresetLayout* presetCombo { nullptr }; - /*! Labels */ - QLabel* lText { nullptr }; - QLabel* rText { nullptr }; - QLabel* tText { nullptr }; - QLabel* bText { nullptr }; - QLabel* presetLabel { nullptr }; - QLabel* marginsForPages { nullptr }; - QLabel* BleedTxt1 { nullptr }; - QLabel* BleedTxt2 { nullptr }; - QLabel* BleedTxt3 { nullptr }; - QLabel* BleedTxt4 { nullptr }; - QCheckBox* marginsForAllPages { nullptr }; - QCheckBox* marginsForAllMasterPages { nullptr }; - QPushButton* usePrinterMarginsButton { nullptr }; - LinkButton* linkBleeds { nullptr }; - LinkButton* linkMargins { nullptr }; - - /*! \brief Margin values converted by unitRatio */ - MarginStruct marginData; - - /*! \brief Internally used page width */ - double m_pageWidth { 0.0 }; - /*! \brief Internally used page height */ - double m_pageHeight { 0.0 }; - -public slots: - /*! \brief Recompute the values after spinbox change */ - void setTop(); - void setBottom(); - void setLeft(); - void setRight(); - /*! \brief Recompute margins in PresetLayout combobox and disable/enable widgets. */ - void setPreset(); - void slotLinkBleeds(); - void slotLinkMargins(); - void changeBleeds(); - -protected slots: - virtual void setMarginsToPrinterMargins(); - -protected: - void updateMarginSpinValues(); - - QGridLayout* GroupLayout { nullptr }; - QHBoxLayout* marginsForPagesLayout { nullptr }; - QGridLayout* BleedGroupLayout { nullptr }; - - QString m_pageSize; - int m_unitIndex { 0 }; - double m_unitRatio { 1.0 }; - //! \brief if the outer facing palette points to the facing pages item - bool m_facingPages { false }; - bool m_useBleeds { false }; - int m_pageType { 0 }; - MarginStruct m_savedMargins; - int m_savedPresetItem { PresetLayout::none }; -}; - -#endif Property changes on: scribus/ui/marginwidget.h ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Author Date Id Revision \ No newline at end of property Index: scribus/ui/newdocdialog.cpp =================================================================== --- scribus/ui/newdocdialog.cpp (Revision 26264) +++ scribus/ui/newdocdialog.cpp (Arbeitskopie) @@ -12,6 +12,7 @@ #include <QHBoxLayout> #include <QVBoxLayout> +#include <QButtonGroup> #include <QCheckBox> #include <QComboBox> #include <QDir> @@ -29,14 +30,13 @@ #include <QStringList> #include <QTabWidget> #include <QToolTip> +#include <QVBoxLayout> -#include "scconfig.h" - #include "commonstrings.h" #include "filedialogeventcatcher.h" #include "fileloader.h" #include "iconmanager.h" -#include "marginwidget.h" +#include "newmarginwidget.h" #include "pagesize.h" #include "pagestructs.h" #include "prefsfile.h" @@ -43,63 +43,20 @@ #include "prefsmanager.h" #include "scrspinbox.h" #include "units.h" -#include "ui/delegates/sclistitemdelegate.h" +#include "ui/widgets/pagesizelist.h" -PageLayoutsWidget::PageLayoutsWidget(QWidget* parent) : - QListWidget(parent) -{ - setDragEnabled(false); - setViewMode(QListView::IconMode); - setFlow(QListView::LeftToRight); - setSortingEnabled(false); - setWrapping(false); - setWordWrap(true); - setAcceptDrops(false); - setDropIndicatorShown(false); - setDragDropMode(QAbstractItemView::NoDragDrop); - setResizeMode(QListView::Adjust); - setSelectionMode(QAbstractItemView::SingleSelection); - setFocusPolicy(Qt::NoFocus); - setIconSize(QSize(32, 32)); - clear(); - setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); - setGridSize(QSize(96, 96)); - setItemDelegate(new ScListItemDelegate(QListWidget::IconMode, QSize(32,32))); -} -void PageLayoutsWidget::arrangeIcons() -{ - int startY = 5; - int startX = 5; - int maxSizeY = 0; - - setResizeMode(QListView::Fixed); - - for (int i = 0; i < count(); ++i) - { - QListWidgetItem* itemWidget = item(i); - QRect itemRect = visualItemRect(itemWidget); - setPositionForIndex(QPoint(startX, startY), indexFromItem(itemWidget)); - startX += itemRect.width() + 5; - maxSizeY = qMax(maxSizeY, itemRect.height()); - } - - maxX = startX; - maxY = maxSizeY + 10; -} - -QSize PageLayoutsWidget::minimumSizeHint() const -{ - return QSize(maxX, maxY); -} - NewDocDialog::NewDocDialog(QWidget* parent, const QStringList& recentDocs, bool startUp, const QString& lang) : QDialog(parent), prefsManager(PrefsManager::instance()), m_onStartup(startUp) { + setupUi(this); + setObjectName(QString::fromLocal8Bit("NewDocumentWindow")); setModal(true); + IconManager &iconManager = IconManager::instance(); + m_unitIndex = prefsManager.appPrefs.docSetupPrefs.docUnitIndex; m_unitRatio = unitGetRatioFromIndex(m_unitIndex); m_unitSuffix = unitGetSuffixFromIndex(m_unitIndex); @@ -106,58 +63,35 @@ m_orientation = prefsManager.appPrefs.docSetupPrefs.pageOrientation; setWindowTitle( tr( "New Document" ) ); - setWindowIcon(IconManager::instance().loadIcon("AppIcon.png")); - if (startUp) - setContentsMargins(0, 0, 0, 0); - else - setContentsMargins(9, 9, 9, 9); - TabbedNewDocLayout = new QVBoxLayout( this ); - if (startUp) - TabbedNewDocLayout->setContentsMargins(9, 9, 9, 9); - else - TabbedNewDocLayout->setContentsMargins(0, 0, 0, 0); - TabbedNewDocLayout->setSpacing(6); + setWindowIcon(iconManager.loadIcon("AppIcon.png")); + + buttonVertical->setIcon(iconManager.loadIcon("page-orientation-vertical")); + buttonHorizontal->setIcon(iconManager.loadIcon("page-orientation-horizontal")); + createNewDocPage(); if (startUp) { - tabWidget = new QTabWidget( this ); - tabWidget->addTab(newDocFrame, tr("&New Document")); - createNewFromTempPage(); nftGui->setupSettings(lang); - tabWidget->addTab(newFromTempFrame, tr("New &from Template")); createOpenDocPage(); - tabWidget->addTab(openDocFrame, tr("Open &Existing Document")); recentDocList = recentDocs; - createRecentDocPage(); - tabWidget->addTab(recentDocFrame, tr("Open Recent &Document")); - TabbedNewDocLayout->addWidget(tabWidget); + createRecentDocPage(); + startUpDialog->setChecked(!prefsManager.appPrefs.uiPrefs.showStartupDialog); } else - TabbedNewDocLayout->addWidget(newDocFrame); - - Layout1 = new QHBoxLayout; - Layout1->setContentsMargins(0, 0, 0, 0); - Layout1->setSpacing(6); - if (startUp) { - startUpDialog = new QCheckBox( tr( "Do not show this dialog again" ), this ); - startUpDialog->setChecked(!prefsManager.appPrefs.uiPrefs.showStartupDialog); - Layout1->addWidget( startUpDialog ); + tabWidget->removeTab(3); + tabWidget->removeTab(2); + tabWidget->removeTab(1); } - QSpacerItem* spacer = new QSpacerItem( 2, 2, QSizePolicy::Expanding, QSizePolicy::Minimum ); - Layout1->addItem( spacer ); - buttonBox = new QDialogButtonBox(); - Layout1->addWidget(buttonBox); - okButton = new QPushButton( CommonStrings::tr_OK, this ); - okButton->setDefault( true ); - buttonBox->addButton(okButton, QDialogButtonBox::AcceptRole); - cancelButton = new QPushButton( CommonStrings::tr_Cancel, this ); - cancelButton->setAutoDefault( false ); - buttonBox->addButton(cancelButton, QDialogButtonBox::RejectRole); - TabbedNewDocLayout->addLayout( Layout1 ); + + + tabWidget->setCurrentIndex(0); + startUpDialog->setVisible(startUp); + //tooltips - pageSizeComboBox->setToolTip( tr( "Document page size, either a standard size or a custom size" ) ); - pageOrientationComboBox->setToolTip( tr( "Orientation of the document's pages" ) ); + listPageFormats->setToolTip( tr( "Document page size, either a standard size or a custom size" ) ); + buttonVertical->setToolTip( tr( "Vertical orientation of the document's pages" ) ); + buttonHorizontal->setToolTip( tr( "Horizontal orientation of the document's pages" ) ); widthSpinBox->setToolTip( tr( "Width of the document's pages, editable if you have chosen a custom page size" ) ); heightSpinBox->setToolTip( tr( "Height of the document's pages, editable if you have chosen a custom page size" ) ); pageCountSpinBox->setToolTip( tr( "Initial number of pages of the document" ) ); @@ -170,15 +104,17 @@ connect(buttonBox, &QDialogButtonBox::accepted, this, &NewDocDialog::ExitOK); connect(buttonBox, &QDialogButtonBox::rejected, this, &NewDocDialog::reject); - connect(pageSizeComboBox, SIGNAL(textActivated(QString)), this, SLOT(setPageSize(QString))); - connect(pageOrientationComboBox, SIGNAL(activated(int)), this, SLOT(setOrientation(int))); + connect(pageOrientationButtons, &QButtonGroup::idClicked, this, &NewDocDialog::setOrientation); 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(layoutsView, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - connect(layoutsView, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - connect(layoutsView, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - connect(layoutsView, SIGNAL(itemPressed(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); + connect(listPageFormats, &PageSizeList::clicked, this, &NewDocDialog::changePageSize); + connect(pageSizeSelector, &PageSizeSelector::pageCategoryChanged, this, &NewDocDialog::changeCategory); + connect(pageLayouts, &PageLayouts::schemeChanged, this, &NewDocDialog::changeScheme); + connect(pageLayouts, &PageLayouts::firstPageChanged, this, &NewDocDialog::changeFirstPage); + connect(marginGroup, &NewMarginWidget::marginChanged, this, &NewDocDialog::changeMargin); + connect(bleedGroup, &NewMarginWidget::marginChanged, this, &NewDocDialog::changeMargin); + connect(comboSortSizes, &QComboBox::currentIndexChanged, this, &NewDocDialog::changeSortMode); if (startUp) { connect(nftGui, SIGNAL(leaveOK()), this, SLOT(ExitOK())); @@ -189,180 +125,101 @@ void NewDocDialog::createNewDocPage() { - newDocFrame = new QFrame(this); + 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; - pageSizeGroupBox = new QGroupBox(newDocFrame ); - pageSizeGroupBox->setTitle( tr( "Document Layout" ) ); - pageSizeGroupBoxLayout = new QGridLayout( pageSizeGroupBox ); - pageSizeGroupBoxLayout->setContentsMargins(9, 9, 9, 9); - pageSizeGroupBoxLayout->setSpacing(6); - pageSizeGroupBoxLayout->setAlignment( Qt::AlignTop ); + comboSortSizes->addItem( tr("Name Asc"), PageSizeList::NameAsc); + comboSortSizes->addItem( tr("Name Desc"), PageSizeList::NameDesc); + comboSortSizes->addItem( tr("Size Asc"), PageSizeList::DimensionAsc); + comboSortSizes->addItem( tr("Size Desc"), PageSizeList::DimensionDesc); + comboSortSizes->setCurrentIndex(0); - layoutsView = new PageLayoutsWidget( pageSizeGroupBox ); - layoutsView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); - for (int i = 0; i < prefsManager.appPrefs.pageSets.count(); ++i) - { - QListWidgetItem *ic; - QString psname = CommonStrings::translatePageSetString(prefsManager.appPrefs.pageSets[i].Name); - if (i == 0) - { - ic = new QListWidgetItem( IconManager::instance().loadIcon("32/page-simple.png"), psname, layoutsView ); - ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - } - else if (i == 1) - { - ic = new QListWidgetItem( IconManager::instance().loadIcon("32/page-doublesided.png"), psname, layoutsView ); - ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - } - else if (i == 2 && prefsManager.appPrefs.docSetupPrefs.pagePositioning == 2) - { - ic = new QListWidgetItem( IconManager::instance().loadIcon("32/page-3fold.png"), psname, layoutsView ); - ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - } - else if (i == 3 && prefsManager.appPrefs.docSetupPrefs.pagePositioning == 3) - { - ic = new QListWidgetItem( IconManager::instance().loadIcon("32/page-4fold.png"), psname, layoutsView ); - ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - } - } - layoutsView->arrangeIcons(); - pageSizeGroupBoxLayout->addWidget( layoutsView, 0, 0, 5, 1 ); - layoutsView->arrangeIcons(); + pageOrientationButtons = new QButtonGroup(); + pageOrientationButtons->addButton(buttonVertical, 0); + pageOrientationButtons->addButton(buttonHorizontal, 1); + pageOrientationButtons->button(orientation)->setChecked(true); - TextLabel1 = new QLabel( tr( "&Size:" ), pageSizeGroupBox ); - pageSizeGroupBoxLayout->addWidget( TextLabel1, 0, 1 ); - PageSize ps(prefsManager.appPrefs.docSetupPrefs.pageSize); - pageSizeComboBox = new QComboBox( pageSizeGroupBox ); - pageSizeComboBox->addItems(ps.activeSizeTRList()); - pageSizeComboBox->addItem( CommonStrings::trCustomPageSize ); - pageSizeComboBox->setEditable(false); - TextLabel1->setBuddy(pageSizeComboBox); - pageSizeGroupBoxLayout->addWidget(pageSizeComboBox, 0, 2 ); - TextLabel2 = new QLabel( tr( "Orie&ntation:" ), pageSizeGroupBox ); - pageSizeGroupBoxLayout->addWidget( TextLabel2, 1, 1 ); - pageOrientationComboBox = new QComboBox( pageSizeGroupBox ); - pageOrientationComboBox->addItem( tr( "Portrait" ) ); - pageOrientationComboBox->addItem( tr( "Landscape" ) ); - pageOrientationComboBox->setEditable(false); - pageOrientationComboBox->setCurrentIndex(prefsManager.appPrefs.docSetupPrefs.pageOrientation); - TextLabel2->setBuddy(pageOrientationComboBox); - pageSizeGroupBoxLayout->addWidget( pageOrientationComboBox, 1, 2 ); + listPageFormats->setValues(pageSize, orientation, PageSizeInfo::Preferred, PageSizeList::NameAsc); - TextLabel1_2 = new QLabel( tr( "&Width:" ), pageSizeGroupBox ); - pageSizeGroupBoxLayout->addWidget(TextLabel1_2, 2, 1 ); - widthSpinBox = new ScrSpinBox(pts2value(1.0, m_unitIndex), 16777215, pageSizeGroupBox, m_unitIndex ); + pageSizeSelector->setHasFormatSelector(false); + pageSizeSelector->setHasCustom(false); + pageSizeSelector->setPageSize(pageSize); + pageSizeSelector->setCurrentCategory(PageSizeInfo::Preferred); + + widthSpinBox->setMinimum(pts2value(1.0, m_unitIndex)); + widthSpinBox->setMaximum(16777215); + widthSpinBox->setNewUnit(m_unitIndex); widthSpinBox->setSuffix(m_unitSuffix); - TextLabel1_2->setBuddy(widthSpinBox); - pageSizeGroupBoxLayout->addWidget(widthSpinBox, 2, 2 ); - TextLabel2_2 = new QLabel( tr( "&Height:" ), pageSizeGroupBox ); - pageSizeGroupBoxLayout->addWidget(TextLabel2_2, 3, 1 ); - heightSpinBox = new ScrSpinBox( pts2value(1.0, m_unitIndex), 16777215, pageSizeGroupBox, m_unitIndex ); + + heightSpinBox->setMinimum(pts2value(1.0, m_unitIndex)); + heightSpinBox->setMaximum(16777215); + heightSpinBox->setNewUnit(m_unitIndex); heightSpinBox->setSuffix(m_unitSuffix); - TextLabel2_2->setBuddy(heightSpinBox); - pageSizeGroupBoxLayout->addWidget(heightSpinBox, 3, 2 ); - unitOfMeasureLabel = new QLabel( tr( "&Default Unit:" ), pageSizeGroupBox ); - unitOfMeasureComboBox = new QComboBox( pageSizeGroupBox ); unitOfMeasureComboBox->addItems(unitGetTextUnitList()); unitOfMeasureComboBox->setCurrentIndex(m_unitIndex); unitOfMeasureComboBox->setEditable(false); - unitOfMeasureLabel->setBuddy(unitOfMeasureComboBox); - pageSizeGroupBoxLayout->addWidget( unitOfMeasureLabel, 4, 1 ); - pageSizeGroupBoxLayout->addWidget( unitOfMeasureComboBox, 4, 2 ); MarginStruct marg(prefsManager.appPrefs.docSetupPrefs.margins); - marginGroup = new MarginWidget(newDocFrame, tr( "Margin Guides" ), &marg, m_unitIndex ); - marginGroup->setPageWidthHeight(prefsManager.appPrefs.docSetupPrefs.pageWidth, prefsManager.appPrefs.docSetupPrefs.pageHeight); - marginGroup->setFacingPages(!(prefsManager.appPrefs.docSetupPrefs.pagePositioning == singlePage)); - widthSpinBox->setValue(prefsManager.appPrefs.docSetupPrefs.pageWidth * m_unitRatio); - heightSpinBox->setValue(prefsManager.appPrefs.docSetupPrefs.pageHeight * m_unitRatio); - QStringList pageSizes = ps.activeSizeTRList(); - int sizeIndex = pageSizes.indexOf(ps.nameTR()); - if (sizeIndex != -1) - pageSizeComboBox->setCurrentIndex(sizeIndex); - else - pageSizeComboBox->setCurrentIndex(pageSizeComboBox->count() - 1); - marginGroup->setPageSize(pageSizeComboBox->currentText()); - marginGroup->setNewBleeds(prefsManager.appPrefs.docSetupPrefs.bleeds); + marginGroup->setup(marg, !(pagePositioning == singlePage), m_unitIndex, NewMarginWidget::MarginWidgetFlags); + marginGroup->setPageHeight(pageHeight); + marginGroup->setPageWidth(pageWidth); + marginGroup->setFacingPages(!(pagePositioning == singlePage)); + + MarginStruct bleed; + bleed.resetToZero(); + + bleedGroup->setup(bleed, !(pagePositioning == singlePage), m_unitIndex, NewMarginWidget::BleedWidgetFlags); + bleedGroup->setPageHeight(pageHeight); + bleedGroup->setPageWidth(pageWidth); + bleedGroup->setFacingPages(!(pagePositioning == singlePage)); + widthSpinBox->setValue(pageWidth * m_unitRatio); + heightSpinBox->setValue(pageHeight * m_unitRatio); + + marginGroup->setPageSize(pageSize); marginGroup->setMarginPreset(prefsManager.appPrefs.docSetupPrefs.marginPreset); + bleedGroup->setPageSize(pageSize); + bleedGroup->setMarginPreset(prefsManager.appPrefs.docSetupPrefs.marginPreset); - optionsGroupBox = new QGroupBox( newDocFrame ); - optionsGroupBox->setTitle( tr( "Options" ) ); - optionsGroupBoxLayout = new QGridLayout( optionsGroupBox ); - optionsGroupBoxLayout->setSpacing(6); - optionsGroupBoxLayout->setContentsMargins(9, 9, 9, 9); - optionsGroupBoxLayout->setAlignment( Qt::AlignTop ); - pageCountLabel = new QLabel( tr( "N&umber of Pages:" ), optionsGroupBox ); - - pageCountSpinBox = new QSpinBox( optionsGroupBox ); pageCountSpinBox->setMaximum( 10000 ); pageCountSpinBox->setMinimum( 1 ); - pageCountLabel->setBuddy(pageCountSpinBox); - optionsGroupBoxLayout->addWidget(pageCountLabel, 0, 0, Qt::AlignLeft); - optionsGroupBoxLayout->addWidget(pageCountSpinBox, 0, 1); - layoutLabel1 = new QLabel( optionsGroupBox ); - layoutLabel1->setText( tr( "First Page is:" ) ); - firstPage = new QComboBox( optionsGroupBox ); - firstPage->clear(); - selectItem(prefsManager.appPrefs.docSetupPrefs.pagePositioning); - optionsGroupBoxLayout->addWidget(layoutLabel1, 1, 0, Qt::AlignLeft); - optionsGroupBoxLayout->addWidget(firstPage, 1, 1); - firstPage->setCurrentIndex(prefsManager.appPrefs.pageSets[prefsManager.appPrefs.docSetupPrefs.pagePositioning].FirstPage); + pageLayouts->updateSchemeSelector(prefsManager.appPrefs.pageSets, prefsManager.appPrefs.pageSets[pagePositioning].FirstPage); - setDocLayout(prefsManager.appPrefs.docSetupPrefs.pagePositioning); - setSize(prefsManager.appPrefs.docSetupPrefs.pageSize); - setOrientation(prefsManager.appPrefs.docSetupPrefs.pageOrientation); + setDocLayout(pagePositioning); + setSize(pageSize); + setOrientation(orientation); - autoTextFrame = new QCheckBox( optionsGroupBox ); - autoTextFrame->setText( tr( "&Automatic Text Frames" ) ); - optionsGroupBoxLayout->addWidget(autoTextFrame, 2, 0, 1, 2, Qt::AlignLeft); - - TextLabel3 = new QLabel( tr( "Colu&mns:" ), optionsGroupBox ); - numberOfCols = new QSpinBox( optionsGroupBox ); numberOfCols->setButtonSymbols( QSpinBox::UpDownArrows ); numberOfCols->setMinimum( 1 ); numberOfCols->setValue( 1 ); - TextLabel3->setBuddy(numberOfCols); - optionsGroupBoxLayout->addWidget(TextLabel3, 3, 0, Qt::AlignLeft); - optionsGroupBoxLayout->addWidget(numberOfCols, 3, 1); - TextLabel4 = new QLabel( tr( "&Gap:" ), optionsGroupBox ); - Distance = new ScrSpinBox( 0, 1000, optionsGroupBox, m_unitIndex ); + Distance->setMinimum(0); + Distance->setMaximum(1000); + Distance->setNewUnit(m_unitIndex); Distance->setValue(11 * m_unitRatio); - TextLabel4->setBuddy(Distance); - optionsGroupBoxLayout->addWidget(TextLabel4, 4, 0, Qt::AlignLeft); - optionsGroupBoxLayout->addWidget(Distance, 4, 1); - firstPage->setMinimumWidth(Distance->width()); - - TextLabel3->setEnabled(false); - TextLabel4->setEnabled(false); + labelColumns->setEnabled(false); + labelGap->setEnabled(false); Distance->setEnabled(false); numberOfCols->setEnabled(false); - startDocSetup = new QCheckBox( optionsGroupBox ); + startDocSetup->setText( tr( "Show Document Settings After Creation" ) ); startDocSetup->setChecked(false); - optionsGroupBoxLayout->addWidget(startDocSetup, 5, 0, 1, 2, Qt::AlignLeft); - NewDocLayout = new QGridLayout( newDocFrame ); - if (m_onStartup) - NewDocLayout->setContentsMargins(9, 9, 9, 9); - else - NewDocLayout->setContentsMargins(0, 0, 0, 0); - NewDocLayout->setSpacing(6); - NewDocLayout->addWidget( marginGroup, 1, 0 ); - NewDocLayout->addWidget( optionsGroupBox, 1, 1 ); - NewDocLayout->addWidget( pageSizeGroupBox, 0, 0, 1, 2); -} + sectionBleeds->collapse(); + sectionTextFrame->collapse(); -void NewDocDialog::createNewFromTempPage() -{ - newFromTempFrame = new QFrame(this); - verticalLayout = new QVBoxLayout(newFromTempFrame); - verticalLayout->setContentsMargins(9, 9, 9, 9); - nftGui = new nftwidget(newFromTempFrame); - verticalLayout->addWidget(nftGui); + // We have to calculate the width of the properties panel manually, + // because QSizePolicy::Minimum doesn't work as expected + scrollAreaWidgetContents->adjustSize(); + scrollAreaWidgetContents->setFixedWidth(scrollAreaWidgetContents->width()); + scrollArea->setWidgetResizable(true); + scrollArea->setFixedWidth(scrollAreaWidgetContents->width() + qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent)); + } void NewDocDialog::createOpenDocPage() @@ -376,10 +233,9 @@ docDir = docContext->get("docsopen", "."); QString formats(FileLoader::getLoadFilterString()); // formats.remove("PDF (*.pdf *.PDF);;"); - openDocFrame = new QFrame(this); - openDocLayout = new QVBoxLayout(openDocFrame); + QVBoxLayout *openDocLayout = new QVBoxLayout(tab_3); openDocLayout->setContentsMargins(0, 0, 0, 0); - openDocLayout->setSpacing(6); + openDocLayout->setSpacing(4); m_selectedFile = ""; // With Qt 5.15 we have to be in careful so that new document dialog doesn't display too large on startup. @@ -386,7 +242,7 @@ // To avoid this we have to use QFileDialog(QWidget *parent, Qt::WindowFlags flags) constructor, then // set the QFileDialog::DontUseNativeDialog option as early as possible, and nonetheless set again // the Qt::Widget window flag before adding the widget to layout. - fileDialog = new QFileDialog(openDocFrame, Qt::Widget); + fileDialog = new QFileDialog(tab_3, Qt::Widget); fileDialog->setOption(QFileDialog::DontUseNativeDialog); fileDialog->setWindowTitle(tr("Open")); fileDialog->setDirectory(docDir); @@ -404,6 +260,7 @@ fileDialog->setWindowFlags(Qt::Widget); openDocLayout->addWidget(fileDialog); + FileDialogEventCatcher* keyCatcher = new FileDialogEventCatcher(this); QList<QListView *> listViews = fileDialog->findChildren<QListView *>(); for (auto listView : std::as_const(listViews)) @@ -426,12 +283,6 @@ void NewDocDialog::createRecentDocPage() { - recentDocFrame = new QFrame(this); - recentDocLayout = new QVBoxLayout(recentDocFrame); - recentDocLayout->setContentsMargins(9, 9, 9, 9); - recentDocLayout->setSpacing(6); - recentDocListBox = new QListWidget(recentDocFrame); - recentDocLayout->addWidget(recentDocListBox); int max = qMin(prefsManager.appPrefs.uiPrefs.recentDocCount, recentDocList.count()); for (int i = 0; i < max; ++i) recentDocListBox->addItem(QDir::toNativeSeparators(recentDocList[i])); @@ -443,16 +294,20 @@ { m_pageWidth = widthSpinBox->value() / m_unitRatio; marginGroup->setPageWidth(m_pageWidth); - QString psText = pageSizeComboBox->currentText(); - if (psText != CommonStrings::trCustomPageSize && psText != CommonStrings::customPageSize) - pageSizeComboBox->setCurrentIndex(pageSizeComboBox->count() - 1); + bleedGroup->setPageWidth(m_pageWidth); + listPageFormats->clearSelection(); + m_pageSize = CommonStrings::customPageSize; + pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_pageSize, m_choosenLayout, pageLayouts->firstPage()); + int newOrientation = (widthSpinBox->value() > heightSpinBox->value()) ? landscapePage : portraitPage; if (newOrientation != m_orientation) { - pageOrientationComboBox->blockSignals(true); - pageOrientationComboBox->setCurrentIndex(newOrientation); - pageOrientationComboBox->blockSignals(false); m_orientation = newOrientation; + + QSignalBlocker sigOri(pageOrientationButtons); + pageOrientationButtons->button(newOrientation)->setChecked(true); + QSignalBlocker sigFormats(listPageFormats); + listPageFormats->setOrientation(m_orientation); } } @@ -460,68 +315,67 @@ { m_pageHeight = heightSpinBox->value() / m_unitRatio; marginGroup->setPageHeight(m_pageHeight); - QString psText = pageSizeComboBox->currentText(); - if (psText != CommonStrings::trCustomPageSize && psText != CommonStrings::customPageSize) - pageSizeComboBox->setCurrentIndex(pageSizeComboBox->count() - 1); + bleedGroup->setPageHeight(m_pageHeight); + listPageFormats->clearSelection(); + m_pageSize = CommonStrings::customPageSize; + pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_pageSize, m_choosenLayout, pageLayouts->firstPage()); + int newOrientation = (widthSpinBox->value() > heightSpinBox->value()) ? landscapePage : portraitPage; if (newOrientation != m_orientation) { - pageOrientationComboBox->blockSignals(true); - pageOrientationComboBox->setCurrentIndex(newOrientation); - pageOrientationComboBox->blockSignals(false); m_orientation = newOrientation; + + QSignalBlocker sigOri(pageOrientationButtons); + pageOrientationButtons->button(newOrientation)->setChecked(true); + QSignalBlocker sigFormats(listPageFormats); + listPageFormats->setOrientation(m_orientation); } } void NewDocDialog::selectItem(uint nr) { - disconnect(layoutsView, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - disconnect(layoutsView, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - disconnect(layoutsView, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - disconnect(layoutsView, SIGNAL(itemPressed(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - if (nr > 0) - { - const QStringList& pageNames = prefsManager.appPrefs.pageSets[nr].pageNames; - firstPage->setEnabled(true); - firstPage->clear(); - for (auto pNames = pageNames.begin(); pNames != pageNames.end(); ++pNames) - firstPage->addItem(CommonStrings::translatePageSetLocString((*pNames))); - } - else - { - firstPage->clear(); - firstPage->addItem(" "); - firstPage->setEnabled(false); - } - layoutsView->setCurrentRow(nr); - layoutsView->item(nr)->setSelected(true); - connect(layoutsView, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - connect(layoutsView, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - connect(layoutsView, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - connect(layoutsView, SIGNAL(itemPressed(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); + pageLayouts->setScheme(nr); + pageLayouts->setFirstPage(nr); } -void NewDocDialog::itemSelected(QListWidgetItem* ic) +void NewDocDialog::changePageSize(const QModelIndex &ic) { - if (ic == nullptr) - return; - selectItem(layoutsView->row(ic)); - setDocLayout(layoutsView->row(ic)); + int unit = ic.data(PageSizeList::Unit).toInt(); + QString sizeName = ic.data(PageSizeList::Name).toString(); + + setUnit(unit); + setPageSize(sizeName); + + QSignalBlocker sig(unitOfMeasureComboBox); + unitOfMeasureComboBox->setCurrentIndex(unit); + } +void NewDocDialog::changeScheme(int ic) +{ + selectItem(ic); + setDocLayout(ic); +} + +void NewDocDialog::changeSortMode(int ic) +{ + Q_UNUSED(ic); + listPageFormats->setSortMode(static_cast<PageSizeList::SortMode>(comboSortSizes->currentData().toInt())); +} + void NewDocDialog::handleAutoFrame() { if (autoTextFrame->isChecked()) { - TextLabel3->setEnabled(true); - TextLabel4->setEnabled(true); + labelColumns->setEnabled(true); + labelGap->setEnabled(true); Distance->setEnabled(true); numberOfCols->setEnabled(true); } else { - TextLabel3->setEnabled(false); - TextLabel4->setEnabled(false); + labelColumns->setEnabled(false); + labelGap->setEnabled(false); Distance->setEnabled(false); numberOfCols->setEnabled(false); } @@ -547,6 +401,9 @@ marginGroup->setNewUnit(m_unitIndex); marginGroup->setPageHeight(m_pageHeight); marginGroup->setPageWidth(m_pageWidth); + bleedGroup->setNewUnit(m_unitIndex); + bleedGroup->setPageHeight(m_pageHeight); + bleedGroup->setPageWidth(m_pageWidth); connect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double))); connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double))); } @@ -555,10 +412,10 @@ { m_pageWidth = widthSpinBox->value() / m_unitRatio; m_pageHeight = heightSpinBox->value() / m_unitRatio; - m_bleedBottom = marginGroup->bottomBleed(); - m_bleedTop = marginGroup->topBleed(); - m_bleedLeft = marginGroup->leftBleed(); - m_bleedRight = marginGroup->rightBleed(); + m_bleedBottom = bleedGroup->margins().bottom(); + m_bleedTop = bleedGroup->margins().top(); + m_bleedLeft = bleedGroup->margins().left(); + m_bleedRight = bleedGroup->margins().right(); if (m_onStartup) { m_tabSelected = tabWidget->currentIndex(); @@ -609,19 +466,17 @@ 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; - if (pageSizeComboBox->currentText() == CommonStrings::trCustomPageSize) - { - if (widthSpinBox->value() > heightSpinBox->value()) - pageOrientationComboBox->setCurrentIndex(landscapePage); - else - pageOrientationComboBox->setCurrentIndex(portraitPage); - } // end of #869 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, pageLayouts->firstPage()); + connect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double))); connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double))); } @@ -628,14 +483,13 @@ void NewDocDialog::setPageSize(const QString &size) { - if (size == CommonStrings::trCustomPageSize) - setSize(size); - else - { - setSize(size); - setOrientation(pageOrientationComboBox->currentIndex()); - } + setSize(size); + + if (size != CommonStrings::customPageSize) + setOrientation(pageOrientationButtons->checkedId()); + marginGroup->setPageSize(size); + bleedGroup->setPageSize(size); } void NewDocDialog::setSize(const QString& gr) @@ -642,10 +496,11 @@ { 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 (gr == CommonStrings::trCustomPageSize || gr == CommonStrings::customPageSize) + if (m_pageSize == CommonStrings::trCustomPageSize || m_pageSize == CommonStrings::customPageSize) { widthSpinBox->setEnabled(true); heightSpinBox->setEnabled(true); @@ -652,8 +507,8 @@ } else { - PageSize ps2(gr); - if (pageOrientationComboBox->currentIndex() == portraitPage) + PageSize ps2(m_pageSize); + if (pageOrientationButtons->checkedId() == portraitPage) { m_pageWidth = ps2.width(); m_pageHeight = ps2.height(); @@ -668,15 +523,23 @@ 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, pageLayouts->firstPage()); + connect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double))); connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double))); + } void NewDocDialog::setDocLayout(int layout) { marginGroup->setFacingPages(layout != singlePage); + bleedGroup->setFacingPages(layout != singlePage); m_choosenLayout = layout; - firstPage->setCurrentIndex(prefsManager.appPrefs.pageSets[m_choosenLayout].FirstPage); + pageLayouts->setScheme(m_choosenLayout); + pageLayouts->setFirstPage(prefsManager.appPrefs.pageSets[m_choosenLayout].FirstPage); + pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_pageSize, m_choosenLayout, pageLayouts->firstPage()); } void NewDocDialog::recentDocListBox_doubleClicked() @@ -698,7 +561,7 @@ setWindowTitle(tr("Open Recent Document")); else setWindowTitle(tr("New Document")); - okButton->setEnabled(tab!=2); + //okButton->setEnabled(tab!=2); } void NewDocDialog::locationDropped(const QString& fileUrl) @@ -750,5 +613,29 @@ void NewDocDialog::openFileDialogFileClicked(const QString& path) { - okButton->setEnabled(!path.isEmpty()); + //okButton->setEnabled(!path.isEmpty()); } + +void NewDocDialog::changeMargin(MarginStruct margin) +{ + pagePreview->setMargins(margin); +} + +void NewDocDialog::changeBleed(MarginStruct bleed) +{ + pagePreview->setBleeds(bleed); +} + +void NewDocDialog::changeFirstPage(int firstPage) +{ + pagePreview->setFirstPage(firstPage); +} + +void NewDocDialog::changeCategory(PageSizeInfo::Category category) +{ + if (listPageFormats->category() == category) + return; + + listPageFormats->setFormat(m_pageSize); + listPageFormats->setCategory(category); +} Index: scribus/ui/newdocdialog.h =================================================================== --- scribus/ui/newdocdialog.h (Revision 26264) +++ scribus/ui/newdocdialog.h (Arbeitskopie) @@ -33,31 +33,19 @@ #include "ui/customfdialog.h" #include "ui/nftwidget.h" +#include "ui_newdocdialog.h" + class PrefsManager; -class MarginWidget; +class NewMarginWidget; class ScrSpinBox; class QFileDialog; -class SCRIBUS_API PageLayoutsWidget : public QListWidget +class SCRIBUS_API NewDocDialog : public QDialog, public Ui::newDocDialog { Q_OBJECT public: - PageLayoutsWidget(QWidget* parent); - ~PageLayoutsWidget() = default; - void arrangeIcons(); - QSize minimumSizeHint() const override; - int maxX {0}; - int maxY {0}; -}; - -class SCRIBUS_API NewDocDialog : public QDialog -{ - Q_OBJECT - -public: - //! \brief Indexes of the dialog's tabs. enum { NewDocumentTab = 0, @@ -70,48 +58,12 @@ ~NewDocDialog() = default; void createNewDocPage(); - void createNewFromTempPage(); void createOpenDocPage(); void createRecentDocPage(); void setSize(const QString& gr); + QString pageSizeName() { return m_pageSize; }; - QTabWidget* tabWidget {nullptr}; - QFrame* newDocFrame {nullptr}; - PageLayoutsWidget* layoutsView {nullptr}; - QLabel* layoutLabel1 {nullptr}; - QComboBox* firstPage {nullptr}; - QGroupBox* pageSizeGroupBox {nullptr}; - MarginWidget* marginGroup {nullptr}; - QGroupBox* optionsGroupBox {nullptr}; - QLabel* TextLabel1 {nullptr}; - QLabel* TextLabel2 {nullptr}; - QLabel* TextLabel3 {nullptr}; - QLabel* TextLabel4 {nullptr}; - QLabel* TextLabel1_2 {nullptr}; - QLabel* TextLabel1_3 {nullptr}; - QLabel* pageCountLabel {nullptr}; - QLabel* TextLabel2_2 {nullptr}; - QLabel* unitOfMeasureLabel {nullptr}; - QComboBox* pageSizeComboBox {nullptr}; - QComboBox* pageOrientationComboBox {nullptr}; - QComboBox* unitOfMeasureComboBox {nullptr}; - QCheckBox* startUpDialog {nullptr}; - QCheckBox* autoTextFrame {nullptr}; - QCheckBox* startDocSetup {nullptr}; - ScrSpinBox* Distance {nullptr}; - QSpinBox* numberOfCols {nullptr}; - QSpinBox* pageCountSpinBox {nullptr}; - ScrSpinBox* widthSpinBox {nullptr}; - ScrSpinBox* heightSpinBox {nullptr}; - QFrame* openDocFrame {nullptr}; QFileDialog *fileDialog {nullptr}; - QFrame* newFromTempFrame {nullptr}; - nftwidget *nftGui {nullptr}; - QFrame* recentDocFrame {nullptr}; - QListWidget* recentDocListBox {nullptr}; - QDialogButtonBox* buttonBox {nullptr}; - QPushButton* okButton {nullptr}; - QPushButton* cancelButton {nullptr}; bool onStartup() const { return m_onStartup;} int tabSelected() const { return m_tabSelected;} @@ -134,8 +86,7 @@ public slots: void setHeight(double v); void setWidth(double v); - void selectItem(uint nr); - void itemSelected(QListWidgetItem* ic); + void selectItem(uint nr); void handleAutoFrame(); void setDistance(double v); void setUnit(int u); @@ -156,17 +107,19 @@ void gotoHomeDirectory(); void openFileDialogFileClicked(const QString &path); +private slots: + void changeMargin(MarginStruct margin); + void changeBleed(MarginStruct bleed); + void changeFirstPage(int firstPage); + void changeCategory(PageSizeInfo::Category category); + void changePageSize(const QModelIndex &ic); + void changeScheme(int ic); + void changeSortMode(int ic); + protected: - QVBoxLayout* TabbedNewDocLayout {nullptr}; - QHBoxLayout* Layout1 {nullptr}; - QGridLayout* NewDocLayout {nullptr}; - QGridLayout* pageSizeGroupBoxLayout {nullptr}; - QGridLayout* optionsGroupBoxLayout {nullptr}; - QVBoxLayout* openDocLayout {nullptr}; - QVBoxLayout* recentDocLayout {nullptr}; - QVBoxLayout *verticalLayout {nullptr}; PrefsManager& prefsManager; QStringList recentDocList; + QButtonGroup* pageOrientationButtons; double m_unitRatio { 1.0 }; int m_orientation { 0 }; @@ -176,6 +129,7 @@ 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 }; Index: scribus/ui/newdocdialog.ui =================================================================== --- scribus/ui/newdocdialog.ui (nicht existent) +++ scribus/ui/newdocdialog.ui (Arbeitskopie) @@ -0,0 +1,837 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>newDocDialog</class> + <widget class="QDialog" name="newDocDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>900</width> + <height>600</height> + </rect> + </property> + <property name="windowTitle"> + <string>Dialog</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="spacing"> + <number>4</number> + </property> + <property name="leftMargin"> + <number>8</number> + </property> + <property name="topMargin"> + <number>8</number> + </property> + <property name="rightMargin"> + <number>8</number> + </property> + <property name="bottomMargin"> + <number>8</number> + </property> + <item> + <widget class="QTabWidget" name="tabWidget"> + <property name="currentIndex"> + <number>0</number> + </property> + <property name="tabBarAutoHide"> + <bool>true</bool> + </property> + <widget class="QWidget" name="tab"> + <attribute name="title"> + <string>New Document</string> + </attribute> + <layout class="QHBoxLayout" name="horizontalLayout_7"> + <property name="spacing"> + <number>4</number> + </property> + <property name="leftMargin"> + <number>8</number> + </property> + <property name="topMargin"> + <number>8</number> + </property> + <property name="rightMargin"> + <number>8</number> + </property> + <property name="bottomMargin"> + <number>8</number> + </property> + <item> + <layout class="QVBoxLayout" name="verticalLayout_5"> + <property name="spacing"> + <number>4</number> + </property> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_8"> + <property name="spacing"> + <number>4</number> + </property> + <item> + <widget class="PageSizeSelector" name="pageSizeSelector" native="true"/> + </item> + <item> + <spacer name="horizontalSpacer_4"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>16</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QComboBox" name="comboSortSizes"/> + </item> + </layout> + </item> + <item> + <widget class="PageSizeList" name="listPageFormats"/> + </item> + </layout> + </item> + <item> + <widget class="QScrollArea" name="scrollArea"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>QFrame::Shape::NoFrame</enum> + </property> + <property name="sizeAdjustPolicy"> + <enum>QAbstractScrollArea::SizeAdjustPolicy::AdjustToContents</enum> + </property> + <property name="widgetResizable"> + <bool>true</bool> + </property> + <property name="alignment"> + <set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set> + </property> + <widget class="QWidget" name="scrollAreaWidgetContents"> + <property name="geometry"> + <rect> + <x>0</x> + <y>-97</y> + <width>304</width> + <height>638</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout_7"> + <property name="spacing"> + <number>0</number> + </property> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>8</number> + </property> + <item> + <widget class="SectionContainer" name="sectionPreview"> + <property name="title" stdset="0"> + <string>Preview</string> + </property> + <widget class="QWidget" name="page_5"> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <property name="spacing"> + <number>0</number> + </property> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="PageSizePreview" name="pagePreview" native="true"> + <property name="minimumSize"> + <size> + <width>120</width> + <height>120</height> + </size> + </property> + </widget> + </item> + </layout> + </widget> + </widget> + </item> + <item> + <widget class="SectionContainer" name="sectionDocument"> + <property name="title" stdset="0"> + <string>Document</string> + </property> + <widget class="QWidget" name="page"> + <layout class="QVBoxLayout" name="verticalLayout_6"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_10"> + <item> + <widget class="FormWidget" name="labelPageWidth"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Width</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_9"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="ScrSpinBox" name="widthSpinBox"/> + </item> + </layout> + </widget> + </item> + <item> + <widget class="FormWidget" name="labelPageHeight"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Height</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_11"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="ScrSpinBox" name="heightSpinBox"/> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_5"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_13" stretch="0,0,0,1"> + <item> + <widget class="FormWidget" name="formWidget_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Unit</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_14"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QComboBox" name="unitOfMeasureComboBox"/> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Policy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>16</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="FormWidget" name="formWidget"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Orientation</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <property name="spacing"> + <number>4</number> + </property> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QToolButton" name="buttonVertical"> + <property name="text"> + <string/> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="autoExclusive"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="buttonHorizontal"> + <property name="text"> + <string/> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="autoExclusive"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_8"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_9"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_12" stretch="0,0,0,1"> + <item> + <widget class="FormWidget" name="pageCountLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Pages</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QSpinBox" name="pageCountSpinBox"/> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_7"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Policy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>16</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="PageLayouts" name="pageLayouts" native="true"/> + </item> + <item> + <spacer name="horizontalSpacer_6"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </widget> + </widget> + </item> + <item> + <widget class="SectionContainer" name="sectionMargins"> + <property name="title" stdset="0"> + <string>Margins</string> + </property> + <widget class="QWidget" name="page_2"> + <layout class="QVBoxLayout" name="verticalLayout_8"> + <item> + <widget class="NewMarginWidget" name="marginGroup" native="true"/> + </item> + </layout> + </widget> + </widget> + </item> + <item> + <widget class="SectionContainer" name="sectionBleeds"> + <property name="title" stdset="0"> + <string>Bleeds</string> + </property> + <widget class="QWidget" name="page_3"> + <layout class="QVBoxLayout" name="verticalLayout_9"> + <item> + <widget class="NewMarginWidget" name="bleedGroup" native="true"/> + </item> + </layout> + </widget> + </widget> + </item> + <item> + <widget class="SectionContainer" name="sectionTextFrame"> + <property name="title" stdset="0"> + <string>Text Frame</string> + </property> + <property name="isCollapsed"> + <bool>false</bool> + </property> + <widget class="QWidget" name="page_4"> + <layout class="QVBoxLayout" name="verticalLayout_10"> + <item> + <widget class="QCheckBox" name="autoTextFrame"> + <property name="text"> + <string>&Automatic Text Frame</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="FormWidget" name="labelColumns"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Columns</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_5"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QSpinBox" name="numberOfCols"/> + </item> + </layout> + </widget> + </item> + <item> + <widget class="FormWidget" name="labelGap"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Gap</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_6"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="ScrSpinBox" name="Distance"/> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </widget> + </widget> + </item> + <item> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Orientation::Vertical</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Policy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>16</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QCheckBox" name="startDocSetup"> + <property name="text"> + <string>Show Document Settings After Creation</string> + </property> + </widget> + </item> + <item> + <spacer name="spacerBottom"> + <property name="orientation"> + <enum>Qt::Orientation::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab_2"> + <attribute name="title"> + <string>New from Template</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <property name="spacing"> + <number>4</number> + </property> + <property name="leftMargin"> + <number>8</number> + </property> + <property name="topMargin"> + <number>8</number> + </property> + <property name="rightMargin"> + <number>8</number> + </property> + <property name="bottomMargin"> + <number>8</number> + </property> + <item> + <widget class="nftwidget" name="nftGui" native="true"/> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab_3"> + <attribute name="title"> + <string>Open Existing Document</string> + </attribute> + </widget> + <widget class="QWidget" name="tab_4"> + <attribute name="title"> + <string>Open Recent Document</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <property name="spacing"> + <number>4</number> + </property> + <property name="leftMargin"> + <number>8</number> + </property> + <property name="topMargin"> + <number>8</number> + </property> + <property name="rightMargin"> + <number>8</number> + </property> + <property name="bottomMargin"> + <number>8</number> + </property> + <item> + <widget class="QListWidget" name="recentDocListBox"/> + </item> + </layout> + </widget> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="spacing"> + <number>4</number> + </property> + <property name="leftMargin"> + <number>8</number> + </property> + <item> + <widget class="QCheckBox" name="startUpDialog"> + <property name="text"> + <string>Do not show this dialog again</string> + </property> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>FormWidget</class> + <extends>QWidget</extends> + <header>ui/widgets/form_widget.h</header> + <container>1</container> + </customwidget> + <customwidget> + <class>SectionContainer</class> + <extends>QWidget</extends> + <header>ui/widgets/section_container.h</header> + <addpagemethod>setWidget</addpagemethod> + <container>1</container> + </customwidget> + <customwidget> + <class>ScrSpinBox</class> + <extends>QDoubleSpinBox</extends> + <header location="global">ui/scrspinbox.h</header> + </customwidget> + <customwidget> + <class>NewMarginWidget</class> + <extends>QWidget</extends> + <header location="global">ui/newmarginwidget.h</header> + <container>1</container> + </customwidget> + <customwidget> + <class>PageLayouts</class> + <extends>QWidget</extends> + <header location="global">ui/widgets/pagelayout.h</header> + <container>1</container> + </customwidget> + <customwidget> + <class>PageSizeList</class> + <extends>QListWidget</extends> + <header>ui/widgets/pagesizelist.h</header> + </customwidget> + <customwidget> + <class>nftwidget</class> + <extends>QWidget</extends> + <header>ui/nftwidget.h</header> + <container>1</container> + </customwidget> + <customwidget> + <class>PageSizePreview</class> + <extends>QWidget</extends> + <header>ui/widgets/pagesizepreview.h</header> + <container>1</container> + </customwidget> + <customwidget> + <class>PageSizeSelector</class> + <extends>QWidget</extends> + <header>ui/widgets/pagesizeselector.h</header> + <container>1</container> + </customwidget> + </customwidgets> + <tabstops> + <tabstop>tabWidget</tabstop> + <tabstop>scrollArea</tabstop> + <tabstop>widthSpinBox</tabstop> + <tabstop>heightSpinBox</tabstop> + <tabstop>pageCountSpinBox</tabstop> + <tabstop>buttonVertical</tabstop> + <tabstop>buttonHorizontal</tabstop> + <tabstop>autoTextFrame</tabstop> + <tabstop>numberOfCols</tabstop> + <tabstop>Distance</tabstop> + <tabstop>startUpDialog</tabstop> + <tabstop>recentDocListBox</tabstop> + </tabstops> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>newDocDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>newDocDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> Index: scribus/ui/newmarginwidget.cpp =================================================================== --- scribus/ui/newmarginwidget.cpp (Revision 26264) +++ scribus/ui/newmarginwidget.cpp (Arbeitskopie) @@ -10,6 +10,7 @@ #include "units.h" #include "ui/marginpresetlayout.h" #include "ui/useprintermarginsdialog.h" +#include "scribusapp.h" NewMarginWidget::NewMarginWidget(QWidget* parent) : QWidget(parent) @@ -39,8 +40,8 @@ presetLayoutLabel->resize(0,0); presetLayoutComboBox->hide(); presetLayoutLabel->hide(); - gridLayout->removeWidget(presetLayoutComboBox); - gridLayout->removeWidget(presetLayoutLabel); + horizontalLayout->removeWidget(presetLayoutComboBox); + horizontalLayout->removeWidget(presetLayoutLabel); } if ((m_flags & ShowPrinterMargins) == 0) { @@ -47,14 +48,14 @@ printerMarginsPushButton->blockSignals(true); printerMarginsPushButton->resize(0,0); printerMarginsPushButton->hide(); - gridLayout->removeWidget(printerMarginsPushButton); + horizontalLayout->removeWidget(printerMarginsPushButton); } setFacingPages(!(layoutType == singlePage)); - gridLayout->invalidate(); - languageChange(); + iconSetChange(); + connect(ScQApp, SIGNAL(iconSetChanged()), this, SLOT(iconSetChange())); connect(topMarginSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setTop())); connect(bottomMarginSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); connect(leftMarginSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); @@ -83,8 +84,15 @@ marginLinkButton->setToolTip( "<qt>" + tr( "Ensure all bleeds have the same value" ) + "</qt>"); } printerMarginsPushButton->setToolTip( "<qt>" + tr( "Import the margins for the selected page size from the available printers" ) + "</qt>"); + + leftMarginLabel->setText( m_facingPages ? tr("Inside") : tr("Left")); + rightMarginLabel->setText( m_facingPages ? tr("Outside") : tr("Right")); } +void NewMarginWidget::iconSetChange() +{ +} + void NewMarginWidget::setNewValues(const MarginStruct& margs) { m_marginData = m_savedMarginData = margs; @@ -234,6 +242,8 @@ topMarginSpinBox->blockSignals(false); bottomMarginSpinBox->blockSignals(false); m_savedPresetItem = item; + + emit marginChanged(m_marginData); } void NewMarginWidget::setPageSize(const QString& pageSize) @@ -274,6 +284,8 @@ rightMarginSpinBox->setValue(leftMarginSpinBox->value()); double newVal = leftMarginSpinBox->value() / m_unitRatio; m_marginData.set(newVal, newVal, newVal, newVal); + + emit marginChanged(m_marginData); } leftMarginSpinBox->blockSignals(leftBlocked); @@ -324,8 +336,10 @@ { m_facingPages = facing; m_pageType = pageType; - leftMarginLabel->setText(facing ? tr( "&Inside:" ) : tr( "&Left:" )); - rightMarginLabel->setText(facing ? tr( "O&utside:" ) : tr( "&Right:" )); + + leftMarginLabel->setText( m_facingPages ? tr("Inside") : tr("Left")); + rightMarginLabel->setText( m_facingPages ? tr("Outside") : tr("Right")); + setPreset(); } Index: scribus/ui/newmarginwidget.h =================================================================== --- scribus/ui/newmarginwidget.h (Revision 26264) +++ scribus/ui/newmarginwidget.h (Arbeitskopie) @@ -41,10 +41,12 @@ 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 setTop(); void setBottom(); void setLeft(); @@ -69,6 +71,9 @@ int m_pageType {0}; int m_savedPresetItem {PresetLayout::none}; int m_unitIndex {0}; + +signals: + void marginChanged(MarginStruct); }; #endif // NEWMARGINWIDGET_H Index: scribus/ui/newmarginwidgetbase.ui =================================================================== --- scribus/ui/newmarginwidgetbase.ui (Revision 26264) +++ scribus/ui/newmarginwidgetbase.ui (Arbeitskopie) @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>308</width> - <height>230</height> + <width>180</width> + <height>186</height> </rect> </property> <property name="sizePolicy"> @@ -16,82 +16,35 @@ <verstretch>0</verstretch> </sizepolicy> </property> - <layout class="QGridLayout" name="gridLayout_2"> + <layout class="QGridLayout" name="gridLayout"> <property name="leftMargin"> - <number>0</number> + <number>8</number> </property> <property name="topMargin"> - <number>0</number> + <number>8</number> </property> <property name="rightMargin"> - <number>0</number> + <number>8</number> </property> <property name="bottomMargin"> - <number>0</number> + <number>8</number> </property> - <item row="0" column="0"> - <layout class="QGridLayout" name="gridLayout"> - <item row="4" column="0"> - <widget class="QLabel" name="bottomMarginLabel"> - <property name="text"> - <string>Bottom:</string> - </property> - <property name="buddy"> - <cstring>bottomMarginSpinBox</cstring> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="leftMarginLabel"> - <property name="text"> - <string>Left:</string> - </property> - <property name="buddy"> - <cstring>leftMarginSpinBox</cstring> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="ScrSpinBox" name="bottomMarginSpinBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="rightMarginLabel"> - <property name="text"> - <string>Right:</string> - </property> - <property name="buddy"> - <cstring>rightMarginSpinBox</cstring> - </property> - </widget> - </item> - <item row="0" column="0"> + <property name="spacing"> + <number>4</number> + </property> + <item row="0" column="1" colspan="3"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> <widget class="QLabel" name="presetLayoutLabel"> <property name="text"> - <string>Preset Layouts:</string> + <string>Preset:</string> </property> </widget> </item> - <item row="3" column="0"> - <widget class="QLabel" name="topMarginLabel"> - <property name="text"> - <string>Top:</string> - </property> - <property name="buddy"> - <cstring>topMarginSpinBox</cstring> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="ScrSpinBox" name="leftMarginSpinBox"> + <item> + <widget class="PresetLayout" name="presetLayoutComboBox"> <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> @@ -98,37 +51,159 @@ </property> </widget> </item> - <item row="2" column="1"> - <widget class="ScrSpinBox" name="rightMarginSpinBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <item> + <spacer name="horizontalSpacer_5"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="ScrSpinBox" name="topMarginSpinBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> </property> - </widget> + </spacer> </item> - <item row="0" column="1"> - <widget class="PresetLayout" name="presetLayoutComboBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - <item row="5" column="1"> + </layout> + </item> + <item row="1" column="2" rowspan="2"> + <widget class="FormWidget" name="formWidget"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string/> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <property name="preserveLabelSpace"> + <bool>true</bool> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="LinkButton" name="marginLinkButton"> + <property name="text"> + <string/> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonStyle::ToolButtonIconOnly</enum> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="1" column="1"> + <widget class="FormWidget" name="leftMarginLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Left</string> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_5"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="ScrSpinBox" name="leftMarginSpinBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="2" column="1"> + <widget class="FormWidget" name="topMarginLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Top</string> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="ScrSpinBox" name="topMarginSpinBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="4" column="1" colspan="3"> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <item> <widget class="QPushButton" name="printerMarginsPushButton"> <property name="text"> <string>Printer Margins...</string> @@ -135,43 +210,118 @@ </property> </widget> </item> - <item row="1" column="2" rowspan="4"> - <widget class="LinkButton" name="marginLinkButton"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> </property> - <property name="minimumSize"> + <property name="sizeHint" stdset="0"> <size> - <width>15</width> + <width>0</width> <height>0</height> </size> </property> - <property name="text"> - <string/> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="toolButtonStyle"> - <enum>Qt::ToolButtonIconOnly</enum> - </property> - <property name="autoRaise"> - <bool>true</bool> - </property> - </widget> + </spacer> </item> </layout> </item> + <item row="2" column="3"> + <widget class="FormWidget" name="bottomMarginLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Bottom</string> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_8"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="ScrSpinBox" name="bottomMarginSpinBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="1" column="3"> + <widget class="FormWidget" name="rightMarginLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="label" stdset="0"> + <string>Right</string> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_6"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="ScrSpinBox" name="rightMarginSpinBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> + </widget> + </item> </layout> </widget> <customwidgets> <customwidget> + <class>FormWidget</class> + <extends>QWidget</extends> + <header>ui/widgets/form_widget.h</header> + <container>1</container> + </customwidget> + <customwidget> <class>ScrSpinBox</class> <extends>QDoubleSpinBox</extends> - <header>ui/scrspinbox.h</header> + <header location="global">ui/scrspinbox.h</header> </customwidget> <customwidget> <class>LinkButton</class> @@ -189,8 +339,8 @@ <tabstop>leftMarginSpinBox</tabstop> <tabstop>rightMarginSpinBox</tabstop> <tabstop>topMarginSpinBox</tabstop> + <tabstop>marginLinkButton</tabstop> <tabstop>bottomMarginSpinBox</tabstop> - <tabstop>marginLinkButton</tabstop> <tabstop>printerMarginsPushButton</tabstop> </tabstops> <resources/> Index: scribus/ui/nftwidget.cpp =================================================================== --- scribus/ui/nftwidget.cpp (Revision 26264) +++ scribus/ui/nftwidget.cpp (Arbeitskopie) @@ -17,7 +17,7 @@ #include "iconmanager.h" #include "ui/delegates/sclistitemdelegate.h" -int ICONSIZE = 64; +int ICONSIZE = 80; nftwidget::nftwidget(QWidget* parent) : QWidget(parent) { @@ -40,9 +40,9 @@ toolBox->setItemIcon(1, IconManager::instance().loadIcon("16/image-x-generic.png")); toolBox->setItemIcon(2, IconManager::instance().loadIcon("16/help-browser.png")); tnailGrid->setIconSize(QSize(ICONSIZE, ICONSIZE)); - tnailGrid->setGridSize(QSize(220, 80)); + tnailGrid->setGridSize(QSize(160, 160)); tnailGrid->setResizeMode(QListView::Adjust); - tnailGrid->setItemDelegate(new ScListItemDelegate(QListWidget::IconMode, QSize(ICONSIZE,ICONSIZE), ScListItemDelegate::Right)); + tnailGrid->setItemDelegate(new ScListItemDelegate(QListWidget::IconMode, QSize(ICONSIZE,ICONSIZE), ScListItemDelegate::Bottom)); // Signals and Slots Connections connect(categoryList, SIGNAL(itemSelectionChanged()), this, SLOT(setThumbnails())); connect(tnailGrid, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SIGNAL(leaveOK())); Index: scribus/ui/pagelayout.cpp =================================================================== --- scribus/ui/pagelayout.cpp (Revision 26264) +++ scribus/ui/pagelayout.cpp (nicht existent) @@ -1,209 +0,0 @@ -/* -For general Scribus (>=1.3.2) copyright and licensing information please refer -to the COPYING file provided with the program. Following this notice may exist -a copyright and/or license notice that predates the release of Scribus 1.3.2 -for which a new license (GPL+exception) is in place. -*/ -#include "pagelayout.h" - -#include <QComboBox> -#include <QToolButton> -#include <QVBoxLayout> -#include <QListWidgetItem> -#include <QLabel> -#include <QPixmap> -#include <QList> - -#include "commonstrings.h" -#include "iconmanager.h" -#include "scribusapp.h" -#include "ui/widgets/form_widget.h" - -PageLayouts::PageLayouts(QWidget* parent) : QWidget( parent ) -{ - struct PageSet pageS; - pageS.Name = CommonStrings::trPageSet2; - pageS.FirstPage = 0; - pageS.Rows = 1; - pageS.Columns = 1; - pageS.pageNames.clear(); - pageS.pageNames.append(CommonStrings::trPageLocMiddleRight); - pageSets.append(pageS); - - layoutGroupLayout = new QHBoxLayout(this); - layoutGroupLayout->setSpacing(4); - layoutGroupLayout->setContentsMargins(0, 0, 0, 0); - - QFont layFont(this->font()); - layFont.setPointSize(8); - - menuScheme = new QMenu(); - - buttonScheme = new QToolButton(this); - buttonScheme->setPopupMode(QToolButton::InstantPopup); - buttonScheme->setMenu(menuScheme); - - labelScheme = new FormWidget(); - labelScheme->setFont(layFont); - labelScheme->addWidget(buttonScheme); - labelScheme->setLabelVisibility(!m_hideLabels); - layoutGroupLayout->addWidget( labelScheme ); - - menuFirstPage = new QMenu(); - - buttonFirstPage = new QToolButton(this); - buttonFirstPage->setPopupMode(QToolButton::InstantPopup); - buttonFirstPage->setMenu(menuFirstPage); - - labelPages = new FormWidget(); - labelPages->setFont(layFont); - labelPages->addWidget( buttonFirstPage ); - labelPages->setLabelVisibility(!m_hideLabels); - layoutGroupLayout->addWidget( labelPages ); - - languageChange(); - - connect(ScQApp, SIGNAL(labelVisibilityChanged(bool)), this, SLOT(toggleLabelVisibility(bool))); - connect(menuScheme, &QMenu::triggered, this, &PageLayouts::schemeChanged); - connect(menuFirstPage, &QMenu::triggered, this, &PageLayouts::firstPageChanged); -} - -void PageLayouts::updateSchemeSelector(const ScribusDoc* doc) -{ - pageSets = doc->pageSets(); - docPagePositioning = doc->pagePositioning(); - labelPages->setVisible( docPagePositioning > 0 ); - - reloadScheme(); -} - -void PageLayouts::selectFirstPage(int nr) -{ - if (menuFirstPage->actions().count() == 0) - return; - - m_firstPage = qBound(0, nr, menuFirstPage->actions().count()); - buttonFirstPage->setIcon(menuFirstPage->actions().at(m_firstPage)->icon()); -} - -void PageLayouts::selectScheme(int nr) -{ - if (menuScheme->actions().count() == 0) - return; - - m_scheme = qBound(0, nr, menuScheme->actions().count()); - buttonScheme->setIcon(menuScheme->actions().at(m_scheme)->icon()); - - reloadFirstPage(m_scheme); - -} - -void PageLayouts::setHideLabelsPermanently(bool hide) -{ - m_hideLabels = hide; - toggleLabelVisibility(!hide); -} - -void PageLayouts::reloadScheme() -{ - disconnect(menuScheme, &QMenu::triggered, this, &PageLayouts::schemeChanged); - - menuScheme->clear(); - - for (int pg = 0; pg < pageSets.count(); ++pg) - { - //Leave the code in for 3-/4- fold but exclude from UI in case we bring it back. - if (pg > 1 && docPagePositioning < 2) - continue; - - QString psname = CommonStrings::translatePageSetString(pageSets[pg].Name); - if (pg == 0) - menuScheme->addAction(IconManager::instance().loadIcon("16/page-simple.png"), psname)->setData(QVariant(pg)); - else if (pg == 1) - menuScheme->addAction(IconManager::instance().loadIcon("16/page-doublesided.png"), psname)->setData(QVariant(pg)); - else if (pg == 2) - menuScheme->addAction(IconManager::instance().loadIcon("16/page-3fold.png"), psname)->setData(QVariant(pg)); - else if (pg == 3) - menuScheme->addAction(IconManager::instance().loadIcon("16/page-4fold.png"), psname)->setData(QVariant(pg)); - else - menuScheme->addAction(IconManager::instance().loadIcon("16/page-simple.png"), psname)->setData(QVariant(pg)); - } - - connect(menuScheme, &QMenu::triggered, this, &PageLayouts::schemeChanged); - - -} - -void PageLayouts::reloadFirstPage(int scheme) -{ - disconnect(menuFirstPage, &QMenu::triggered, this, &PageLayouts::firstPageChanged); - - menuFirstPage->clear(); - - // We have to add the other cases if want to support them again - // CommonStrings::trPageLocLeft - // CommonStrings::trPageLocMiddle - // CommonStrings::trPageLocMiddleLeft - // CommonStrings::trPageLocMiddleRight - // CommonStrings::trPageLocRight - - for (int pg = 0; pg < pageSets[scheme].pageNames.count(); ++pg) - { - QString psname = CommonStrings::translatePageSetString(pageSets[scheme].pageNames[pg]); - - if (psname == CommonStrings::trPageLocLeft) - menuFirstPage->addAction(IconManager::instance().loadIcon("page-first-left"), psname)->setData(QVariant(pg)); - else if (psname == CommonStrings::trPageLocRight) - menuFirstPage->addAction(IconManager::instance().loadIcon("page-first-right"), psname)->setData(QVariant(pg)); - else - menuFirstPage->addAction(IconManager::instance().loadIcon("page-first-left"), psname)->setData(QVariant(pg)); - } - - connect(menuFirstPage, &QMenu::triggered, this, &PageLayouts::firstPageChanged); - - -} - -void PageLayouts::schemeSelected(int ic) -{ - reloadFirstPage(ic); - labelPages->setVisible( ic > 0 ); - emit selectedScheme(ic); -} - -void PageLayouts::toggleLabelVisibility(bool visibility) -{ - // hide labels always if flag is false - if (m_hideLabels) - visibility = false; - - labelScheme->setLabelVisibility(visibility); - labelPages->setLabelVisibility(visibility); -} - -void PageLayouts::languageChange() -{ - - reloadScheme(); - reloadFirstPage(m_scheme); - - labelScheme->setText( tr( "Scheme" ) ); - labelPages->setText( tr( "First Page" ) ); - - buttonScheme->setToolTip( tr( "Number of pages to show side-by-side on the canvas. Often used for allowing items to be placed across page spreads." ) ); - buttonFirstPage->setToolTip( tr( "Location on the canvas where the first page of the document is placed" ) ); -} - -void PageLayouts::schemeChanged(QAction *action) -{ - buttonScheme->setIcon(action->icon()); - m_scheme = action->data().toInt(); - schemeSelected(m_scheme); -} - -void PageLayouts::firstPageChanged(QAction *action) -{ - buttonFirstPage->setIcon(action->icon()); - m_firstPage = action->data().toInt(); - emit selectedFirstPage(m_firstPage); -} Property changes on: scribus/ui/pagelayout.cpp ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Author Date Id Revision \ No newline at end of property Index: scribus/ui/pagelayout.h =================================================================== --- scribus/ui/pagelayout.h (Revision 26264) +++ scribus/ui/pagelayout.h (nicht existent) @@ -1,76 +0,0 @@ -/* -For general Scribus (>=1.3.2) copyright and licensing information please refer -to the COPYING file provided with the program. Following this notice may exist -a copyright and/or license notice that predates the release of Scribus 1.3.2 -for which a new license (GPL+exception) is in place. -*/ -#ifndef PAGELAYOUT_H -#define PAGELAYOUT_H - -#include <QGroupBox> -#include <QListWidget> -#include <QList> - -class QToolButton; -class QLabel; -class QHBoxLayout; -class FormWidget; -class QMenu; - -#include "scribusapi.h" -#include "scribusstructs.h" -#include "scribusdoc.h" - -/*! \brief A widget for changing pages layout. -User can change layouts on-the-fly changing widget's -comboboxes. */ -class SCRIBUS_API PageLayouts : public QWidget -{ - Q_OBJECT - -public: - PageLayouts(QWidget* parent); - ~PageLayouts() {}; - - void updateSchemeSelector(const ScribusDoc* doc); - void selectFirstPage(int nr); - void selectScheme(int nr); - - void setHideLabelsPermanently(bool hide); - bool hideLabelsPermanently() { return m_hideLabels; }; - -public slots: - void schemeSelected(int ic); - void toggleLabelVisibility(bool visibility); - -signals: - void selectedScheme(int); - void selectedFirstPage(int); - -private: - - int m_scheme {0}; - int m_firstPage {0}; - bool m_hideLabels {false}; - int docPagePositioning {0}; - - FormWidget* labelScheme; - FormWidget* labelPages; - QList<PageSet> pageSets; - QToolButton* buttonScheme; - QToolButton* buttonFirstPage; - QMenu* menuScheme; - QMenu* menuFirstPage; - QHBoxLayout* layoutGroupLayout; - - void reloadScheme(); - void reloadFirstPage(int scheme); - -protected slots: - void languageChange(); - void schemeChanged(QAction* action); - void firstPageChanged(QAction* action); - -}; - -#endif // PAGELAYOUT_H Property changes on: scribus/ui/pagelayout.h ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Author Date Id Revision \ No newline at end of property Index: scribus/ui/pagepalette_pages.cpp =================================================================== --- scribus/ui/pagepalette_pages.cpp (Revision 26264) +++ scribus/ui/pagepalette_pages.cpp (Arbeitskopie) @@ -22,7 +22,7 @@ #include "commonstrings.h" #include "iconmanager.h" -#include "pagelayout.h" +#include "ui/widgets/pagelayout.h" #include "pagepalette_pages.h" #include "pagepalette_widgets.h" #include "qobjectdefs.h" @@ -45,11 +45,11 @@ masterPageList->m_thumb = true; masterPageList->setIconSize(QSize(60, 60)); - pageLayout->setHideLabelsPermanently(true); + pageLayout->setHideLabelsPermanently(true); - trash->setMinimumSize(QSize(24, 24)); - trash->setMaximumSize(QSize(24, 24)); - + trash->setMinimumSize(QSize(24, 24)); + trash->setMaximumSize(QSize(24, 24)); + PageGrid *pageGrid = pageViewWidget->pageGrid(); rebuild(); @@ -62,8 +62,8 @@ connect(masterPageList, SIGNAL(thumbnailChanged()), this, SLOT(rebuildMasters())); connect(masterPageList, SIGNAL(delMasterRequest(QString)), this, SLOT(deleteMasterPage(QString))); - connect(pageLayout, SIGNAL(selectedScheme(int)), this, SLOT(handlePageLayout(int))); - connect(pageLayout, SIGNAL(selectedFirstPage(int)), this, SLOT(handleFirstPage(int))); + connect(pageLayout, SIGNAL(schemeChanged(int)), this, SLOT(handlePageLayout(int))); + connect(pageLayout, SIGNAL(firstPageChanged(int)), this, SLOT(handleFirstPage(int))); connect(pageGrid, SIGNAL(click(int, int)), this, SLOT(pageView_gotoPage(int, int))); connect(pageGrid, SIGNAL(movePage(int, int)), this, SLOT(pageView_movePage(int, int))); @@ -137,8 +137,8 @@ double pageRatio = page.width() / page.height(); PageCell *pc = pageViewWidget->pageGrid()->getPageItem(pageIndex); - pc->pageName = masterpageName; - pc->pageRatio = pageRatio; + pc->pageName = masterpageName; + pc->pageRatio = pageRatio; } @@ -205,8 +205,8 @@ QPixmap pix = ( previews.contains(i) ) ? QPixmap::fromImage( previews.value(i) ) : QPixmap(); PageCell *pc = pageViewWidget->pageGrid()->pageList.at(i); - pc->pagePreview = pix; - pc->pageRatio = pageRatio; + pc->pagePreview = pix; + pc->pageRatio = pageRatio; } } @@ -283,7 +283,7 @@ void PagePalette_Pages::handlePageLayout(int layout) { - pageLayout->selectFirstPage(currView->m_doc->pageSets()[layout].FirstPage); + pageLayout->setFirstPage(currView->m_doc->pageSets()[layout].FirstPage); currView->m_doc->setPagePositioning(layout); currView->reformPages(); currView->DrawNew(); @@ -333,21 +333,21 @@ if (m_scMW->scriptIsRunning()) return; - disconnect(pageLayout, SIGNAL(selectedScheme(int)), this, SLOT(handlePageLayout(int))); - disconnect(pageLayout, SIGNAL(selectedFirstPage(int)), this, SLOT(handleFirstPage(int))); + disconnect(pageLayout, SIGNAL(schemeChanged(int)), this, SLOT(handlePageLayout(int))); + disconnect(pageLayout, SIGNAL(firstPageChanged(int)), this, SLOT(handleFirstPage(int))); pageViewWidget->pageGrid()->clear(); if (currView == nullptr) { - connect(pageLayout, SIGNAL(selectedScheme(int)), this, SLOT(handlePageLayout(int))); - connect(pageLayout, SIGNAL(selectedFirstPage(int)), this, SLOT(handleFirstPage(int))); + connect(pageLayout, SIGNAL(schemeChanged(int)), this, SLOT(handlePageLayout(int))); + connect(pageLayout, SIGNAL(firstPageChanged(int)), this, SLOT(handleFirstPage(int))); return; } const PageSet ¤tPageSet = currView->m_doc->pageSets()[currView->m_doc->pagePositioning()]; - pageLayout->updateSchemeSelector(currView->m_doc); - pageLayout->selectScheme(currView->m_doc->pagePositioning()); - pageLayout->selectFirstPage(currentPageSet.FirstPage); + pageLayout->updateSchemeSelector(currView->m_doc->pageSets(), currView->m_doc->pagePositioning()); + pageLayout->setScheme(currView->m_doc->pagePositioning()); + pageLayout->setFirstPage(currentPageSet.FirstPage); int counter = currentPageSet.FirstPage; int cols = currentPageSet.Columns; @@ -391,8 +391,8 @@ { markPage(currView->m_doc->currentPageNumber()); } - connect(pageLayout, SIGNAL(selectedScheme(int)), this, SLOT(handlePageLayout(int))); - connect(pageLayout, SIGNAL(selectedFirstPage(int)), this, SLOT(handleFirstPage(int))); + connect(pageLayout, SIGNAL(schemeChanged(int)), this, SLOT(handlePageLayout(int))); + connect(pageLayout, SIGNAL(firstPageChanged(int)), this, SLOT(handleFirstPage(int))); } void PagePalette_Pages::rebuild() Index: scribus/ui/pagepalette_pagesbase.ui =================================================================== --- scribus/ui/pagepalette_pagesbase.ui (Revision 26264) +++ scribus/ui/pagepalette_pagesbase.ui (Arbeitskopie) @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>235</width> - <height>498</height> + <width>235</width> + <height>498</height> </rect> </property> <property name="windowTitle"> @@ -14,45 +14,45 @@ <string>Arrange Pages</string> </property> <layout class="QVBoxLayout" name="verticalLayout"> - <property name="spacing"> - <number>4</number> - </property> + <property name="spacing"> + <number>4</number> + </property> <property name="leftMargin"> - <number>8</number> + <number>8</number> </property> <property name="topMargin"> - <number>8</number> + <number>8</number> </property> <property name="rightMargin"> - <number>8</number> + <number>8</number> </property> <property name="bottomMargin"> - <number>8</number> + <number>8</number> </property> <item> <widget class="QSplitter" name="splitter"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="orientation"> - <enum>Qt::Orientation::Vertical</enum> + <enum>Qt::Orientation::Vertical</enum> </property> <property name="childrenCollapsible"> <bool>false</bool> </property> <widget class="QWidget" name="widget" native="true"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <layout class="QVBoxLayout" name="verticalLayout_3"> <property name="spacing"> - <number>4</number> + <number>4</number> </property> <property name="leftMargin"> <number>0</number> @@ -89,15 +89,15 @@ </layout> </widget> <widget class="QWidget" name="widget_2" native="true"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>1</verstretch> - </sizepolicy> - </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>1</verstretch> + </sizepolicy> + </property> <layout class="QVBoxLayout" name="verticalLayout_4"> <property name="spacing"> - <number>4</number> + <number>4</number> </property> <property name="leftMargin"> <number>0</number> @@ -119,104 +119,104 @@ </widget> </item> <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <property name="spacing"> - <number>4</number> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="spacing"> + <number>4</number> </property> - <item> - <widget class="QToolButton" name="buttonPageInsert"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="buttonPageImport"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="buttonPageDuplicate"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="buttonPageMove"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Orientation::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Policy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>16</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="PageLayouts" name="pageLayout" native="true"/> - </item> - <item> - <spacer name="horizontalSpacer_2"> - <property name="orientation"> - <enum>Qt::Orientation::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Policy::MinimumExpanding</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>16</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="TrashBin" name="trash"> - <property name="minimumSize"> - <size> - <width>32</width> - <height>32</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>32</width> - <height>32</height> - </size> - </property> - <property name="toolTip"> - <string><qt>Drag pages or master pages onto the trash to delete them</qt></string> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="PageViewer" name="pageViewWidget" native="true"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <item> + <widget class="QToolButton" name="buttonPageInsert"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="buttonPageImport"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="buttonPageDuplicate"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="buttonPageMove"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Policy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>16</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="PageLayouts" name="pageLayout" native="true"/> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Policy::MinimumExpanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>16</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="TrashBin" name="trash"> + <property name="minimumSize"> + <size> + <width>32</width> + <height>32</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>32</width> + <height>32</height> + </size> + </property> + <property name="toolTip"> + <string><qt>Drag pages or master pages onto the trash to delete them</qt></string> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="PageViewer" name="pageViewWidget" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> </widget> </item> @@ -233,20 +233,20 @@ <header>ui/pagepalette_widgets.h</header> </customwidget> <customwidget> - <class>TrashBin</class> - <extends>QLabel</extends> - <header>ui/pagepalette_widgets.h</header> - </customwidget> - <customwidget> - <class>PageViewer</class> - <extends>QWidget</extends> - <header>ui/pagepalette_widgets.h</header> - <container>1</container> - </customwidget> - <customwidget> + <class>TrashBin</class> + <extends>QLabel</extends> + <header>ui/pagepalette_widgets.h</header> + </customwidget> + <customwidget> + <class>PageViewer</class> + <extends>QWidget</extends> + <header>ui/pagepalette_widgets.h</header> + <container>1</container> + </customwidget> + <customwidget> <class>PageLayouts</class> - <extends>QWidget</extends> - <header>ui/pagelayout.h</header> + <extends>QWidget</extends> + <header location="global">ui/widgets/pagelayout.h</header> <container>1</container> </customwidget> </customwidgets> Index: scribus/ui/pagepropertiesdialog.cpp =================================================================== --- scribus/ui/pagepropertiesdialog.cpp (Revision 26264) +++ scribus/ui/pagepropertiesdialog.cpp (Arbeitskopie) @@ -17,7 +17,7 @@ #include "commonstrings.h" #include "iconmanager.h" -#include "marginwidget.h" +#include "newmarginwidget.h" #include "pagepropertiesdialog.h" #include "pagesize.h" #include "pagestructs.h" @@ -25,6 +25,7 @@ #include "scribusdoc.h" #include "scrspinbox.h" #include "units.h" +#include "widgets/pagesizeselector.h" PagePropertiesDialog::PagePropertiesDialog( QWidget* parent, ScribusDoc* doc ) : QDialog( parent), @@ -35,36 +36,34 @@ setWindowIcon(IconManager::instance().loadIcon("AppIcon.png")); dialogLayout = new QVBoxLayout(this); dialogLayout->setContentsMargins(9, 9, 9, 9); - dialogLayout->setSpacing(6); + dialogLayout->setSpacing(4); + PageSize ps(doc->currentPage()->size()); + + // try to find coresponding 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(); + dsGroupBox7 = new QGroupBox(this); dsGroupBox7->setTitle( tr( "Page Size" ) ); dsGroupBox7Layout = new QGridLayout(dsGroupBox7); dsGroupBox7Layout->setAlignment( Qt::AlignTop ); - dsGroupBox7Layout->setSpacing(6); + dsGroupBox7Layout->setSpacing(4); dsGroupBox7Layout->setContentsMargins(9, 9, 9, 9); TextLabel1 = new QLabel( tr( "&Size:" ), dsGroupBox7 ); - dsGroupBox7Layout->addWidget( TextLabel1, 0, 0, 1, 2 ); - - PageSize ps(doc->currentPage()->size()); - prefsPageSizeName = ps.name(); - sizeQComboBox = new QComboBox(dsGroupBox7); - QStringList insertList(ps.activeSizeTRList()); - if (insertList.indexOf(prefsPageSizeName) == -1 && prefsPageSizeName != CommonStrings::customPageSize) - insertList << prefsPageSizeName; - insertList.sort(); - insertList << CommonStrings::trCustomPageSize; - sizeQComboBox->addItems(insertList); - int sizeIndex = insertList.indexOf(ps.nameTR()); - if (sizeIndex != -1) - sizeQComboBox->setCurrentIndex(sizeIndex); - else - sizeQComboBox->setCurrentIndex(sizeQComboBox->count()-1); - - TextLabel1->setBuddy(sizeQComboBox); - dsGroupBox7Layout->addWidget(sizeQComboBox, 0, 2, 1, 2); + dsGroupBox7Layout->addWidget( TextLabel1, 0, 0, Qt::AlignTop | Qt::AlignRight); + pageSizeSelector = new PageSizeSelector(dsGroupBox7); + pageSizeSelector->setPageSize(doc->currentPage()->size()); + TextLabel1->setBuddy(pageSizeSelector); + dsGroupBox7Layout->addWidget(pageSizeSelector, 0, 1); TextLabel2 = new QLabel( tr( "Orie&ntation:" ), dsGroupBox7 ); - dsGroupBox7Layout->addWidget( TextLabel2, 1, 0, 1, 2 ); + dsGroupBox7Layout->addWidget( TextLabel2, 1, 0, Qt::AlignRight); orientationQComboBox = new QComboBox( dsGroupBox7 ); orientationQComboBox->addItem( tr( "Portrait" ) ); orientationQComboBox->addItem( tr( "Landscape" ) ); @@ -72,28 +71,28 @@ orientationQComboBox->setCurrentIndex(doc->currentPage()->orientation() ); oldOri = doc->currentPage()->orientation(); TextLabel2->setBuddy(orientationQComboBox); - dsGroupBox7Layout->addWidget( orientationQComboBox, 1, 2, 1, 2 ); + dsGroupBox7Layout->addWidget( orientationQComboBox, 1, 1 ); widthSpinBox = new ScrSpinBox(pts2value(1.0, doc->unitIndex()), 16777215, dsGroupBox7, doc->unitIndex()); widthQLabel = new QLabel( tr( "&Width:" ), dsGroupBox7 ); widthSpinBox->setValue(doc->currentPage()->width() * doc->unitRatio()); widthQLabel->setBuddy(widthSpinBox); - dsGroupBox7Layout->addWidget( widthQLabel, 2, 0 ); + dsGroupBox7Layout->addWidget( widthQLabel, 2, 0, Qt::AlignRight); dsGroupBox7Layout->addWidget( widthSpinBox, 2, 1 ); heightSpinBox = new ScrSpinBox(pts2value(1.0, doc->unitIndex()), 16777215, dsGroupBox7, doc->unitIndex()); heightSpinBox->setValue(doc->currentPage()->height() * doc->unitRatio()); heightQLabel = new QLabel( tr( "&Height:" ), dsGroupBox7 ); heightQLabel->setBuddy(heightSpinBox); - dsGroupBox7Layout->addWidget( heightQLabel, 2, 2 ); - dsGroupBox7Layout->addWidget( heightSpinBox, 2, 3 ); + dsGroupBox7Layout->addWidget( heightQLabel, 3, 0, Qt::AlignRight ); + dsGroupBox7Layout->addWidget( heightSpinBox, 3, 1 ); moveObjects = new QCheckBox( dsGroupBox7 ); moveObjects->setText( tr( "Move Objects with their Page" ) ); moveObjects->setChecked( true ); - dsGroupBox7Layout->addWidget( moveObjects, 3, 0, 1, 4 ); + dsGroupBox7Layout->addWidget( moveObjects, 4, 0, 1, 2 ); Links = nullptr; if ((doc->pagePositioning() != singlePage) && (doc->masterPageMode())) { TextLabel3 = new QLabel( tr( "Type:" ), dsGroupBox7 ); - dsGroupBox7Layout->addWidget( TextLabel3, 4, 0, 1, 2 ); + dsGroupBox7Layout->addWidget( TextLabel3, 5, 0, Qt::AlignRight); Links = new QComboBox( dsGroupBox7 ); QList<PageSet> pageSet(doc->pageSets()); const QStringList& pageNames = pageSet.at(doc->pagePositioning()).pageNames; @@ -102,7 +101,7 @@ Links->addItem(CommonStrings::translatePageSetLocString((*pNames))); } Links->setEditable(false); - dsGroupBox7Layout->addWidget( Links, 4, 2, 1, 2 ); + dsGroupBox7Layout->addWidget( Links, 5, 1); if (doc->currentPage()->LeftPg == 0) Links->setCurrentIndex(Links->count()-1); else if (doc->currentPage()->LeftPg == 1) @@ -112,17 +111,20 @@ } dialogLayout->addWidget( dsGroupBox7 ); - marginWidget = new MarginWidget(this, tr( "Margin Guides" ), &doc->currentPage()->initialMargins, doc->unitIndex(), false, false); - marginWidget->setPageWidthHeight(doc->currentPage()->width(), doc->currentPage()->height()); +// 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->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 ); groupMaster->setTitle( tr( "Other Settings" ) ); masterLayout = new QHBoxLayout( groupMaster ); - masterLayout->setSpacing(6); - masterLayout->setContentsMargins(9, 9, 9, 9); + masterLayout->setSpacing(4); + masterLayout->setContentsMargins(8, 8, 8, 8); masterPageLabel = new QLabel( groupMaster ); masterLayout->addWidget( masterPageLabel ); if (!doc->masterPageMode()) @@ -163,7 +165,7 @@ m_pageWidth = widthSpinBox->value() / m_unitRatio; m_pageHeight = heightSpinBox->value() / m_unitRatio; - bool isCustom = (sizeQComboBox->currentText() == CommonStrings::trCustomPageSize); + bool isCustom = (pageSizeSelector->pageSizeTR() == CommonStrings::trCustomPageSize); heightSpinBox->setEnabled(isCustom); widthSpinBox->setEnabled(isCustom); // signals and slots connections @@ -170,12 +172,12 @@ connect(okButton, SIGNAL(clicked()), this, SLOT(accept())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject())); connect(orientationQComboBox, SIGNAL(activated(int)), this, SLOT(setOrientation(int))); - connect(sizeQComboBox, SIGNAL(textActivated(QString)), this, SLOT(setPageSize())); + connect(pageSizeSelector, SIGNAL(pageSizeChanged(QString)), this, SLOT(setPageSize())); connect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setPageWidth(double))); connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setPageHeight(double))); //tooltips - sizeQComboBox->setToolTip( tr( "Size of the inserted pages, either a standard or custom size" ) ); + pageSizeSelector->setToolTip( tr( "Size of the inserted pages, either a standard or custom size" ) ); orientationQComboBox->setToolTip( tr( "Orientation of the page(s) to be inserted" ) ); widthSpinBox->setToolTip( tr( "Width of the page(s) to be inserted" ) ); heightSpinBox->setToolTip( tr( "Height of the page(s) to be inserted" ) ); @@ -217,7 +219,7 @@ void PagePropertiesDialog::setPageSize() { - if (sizeQComboBox->currentText() != CommonStrings::trCustomPageSize) + if (pageSizeSelector->pageSizeTR() != CommonStrings::trCustomPageSize) oldOri++; setOrientation(orientationQComboBox->currentIndex()); } @@ -254,10 +256,10 @@ void PagePropertiesDialog::setOrientation(int ori) { - setSize(sizeQComboBox->currentText()); + setSize(pageSizeSelector->pageSizeTR()); disconnect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setPageWidth(double))); disconnect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setPageHeight(double))); - if ((sizeQComboBox->currentText() == CommonStrings::trCustomPageSize) && (ori != oldOri)) + if ((pageSizeSelector->pageSizeTR() == CommonStrings::trCustomPageSize) && (ori != oldOri)) { double w = widthSpinBox->value(), h = heightSpinBox->value(); widthSpinBox->setValue((ori == portraitPage) ? qMin(w, h) : qMax(w, h)); @@ -320,22 +322,22 @@ double PagePropertiesDialog::top() const { - return marginWidget->top(); + return marginWidget->margins().top(); } double PagePropertiesDialog::bottom() const { - return marginWidget->bottom(); + return marginWidget->margins().bottom(); } double PagePropertiesDialog::left() const { - return marginWidget->left(); + return marginWidget->margins().left(); } double PagePropertiesDialog::right() const { - return marginWidget->right(); + return marginWidget->margins().right(); } QString PagePropertiesDialog::masterPage() const @@ -347,5 +349,5 @@ int PagePropertiesDialog::getMarginPreset() const { - return marginWidget->getMarginPreset(); + return marginWidget->marginPreset(); } Index: scribus/ui/pagepropertiesdialog.h =================================================================== --- scribus/ui/pagepropertiesdialog.h (Revision 26264) +++ scribus/ui/pagepropertiesdialog.h (Arbeitskopie) @@ -10,6 +10,8 @@ #include "scribusapi.h" #include <QDialog> +#include "widgets/pagesizeselector.h" + class QGroupBox; class QLabel; class QPushbutton; @@ -20,7 +22,7 @@ class QHBoxLayout; class QVBoxLayout; class ScrSpinBox; -class MarginWidget; +class NewMarginWidget; class ScribusDoc; /*! \brief A dialog to setup the existing document margins. @@ -90,7 +92,7 @@ void setPageHeight(double v); private: - MarginWidget* marginWidget { nullptr }; + NewMarginWidget* marginWidget { nullptr }; QGroupBox* dsGroupBox7 { nullptr }; QGroupBox* groupMaster { nullptr }; QLabel* masterPageLabel { nullptr }; @@ -101,7 +103,7 @@ QLabel* heightQLabel { nullptr }; QLabel* TextLabel1 { nullptr }; QLabel* TextLabel2 { nullptr }; - QComboBox* sizeQComboBox { nullptr }; + PageSizeSelector* pageSizeSelector { nullptr }; QComboBox* orientationQComboBox { nullptr }; QComboBox* Links { nullptr }; QLabel* TextLabel3 { nullptr }; Index: scribus/ui/prefs_documentsetup.cpp =================================================================== --- scribus/ui/prefs_documentsetup.cpp (Revision 26264) +++ scribus/ui/prefs_documentsetup.cpp (Arbeitskopie) @@ -68,7 +68,7 @@ pageHeightSpinBox->setMaximum(16777215); languageChange(); - connect(pageSizeComboBox, SIGNAL(activated(int)), this, SLOT(setPageSize())); + connect(pageSizeSelector, SIGNAL(pageSizeChanged(QString)), this, SLOT(setPageSize())); connect(pageOrientationComboBox, SIGNAL(activated(int)), this, SLOT(setPageOrientation(int))); connect(pageWidthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setPageWidth(double))); connect(pageHeightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setPageHeight(double))); @@ -121,7 +121,7 @@ pageWidthSpinBox->setToolTip( "<qt>" + tr( "Width of document pages, editable if you have chosen a custom page size" ) + "</qt>" ); pageHeightSpinBox->setToolTip( "<qt>" + tr( "Height of document pages, editable if you have chosen a custom page size" ) + "</qt>" ); - pageSizeComboBox->setToolTip( "<qt>" + tr( "Default page size, either a standard size or a custom size. More page sizes can be made visible by activating them in Preferences." ) + "</qt>" ); + pageSizeSelector->setToolTip( "<qt>" + tr( "Default page size, either a standard size or a custom size. More page sizes can be made visible by activating them in Preferences." ) + "</qt>" ); pageSizeLinkToolButton->setToolTip( "<qt>" + tr( "Enable or disable more page sizes by jumping to Page Size preferences" ) + "</qt>" ); pageOrientationComboBox->setToolTip( "<qt>" + tr( "Default orientation of document pages" ) + "</qt>" ); pageUnitsComboBox->setToolTip( "<qt>" + tr( "Default unit of measurement for document editing" ) + "</qt>" ); @@ -138,7 +138,7 @@ pageWidthSpinBox->blockSignals(true); pageHeightSpinBox->blockSignals(true); pageOrientationComboBox->blockSignals(true); - pageSizeComboBox->blockSignals(true); + pageSizeSelector->blockSignals(true); setCurrentComboItem(languageComboBox, LanguageManager::instance()->getLangFromAbbrev(prefsData->docSetupPrefs.language, true)); @@ -179,7 +179,7 @@ pageWidthSpinBox->blockSignals(false); pageHeightSpinBox->blockSignals(false); pageOrientationComboBox->blockSignals(false); - pageSizeComboBox->blockSignals(false); + pageSizeSelector->blockSignals(false); marginsWidget->setup(prefsData->docSetupPrefs.margins, prefsData->docSetupPrefs.pagePositioning, prefsData->docSetupPrefs.docUnitIndex, NewMarginWidget::MarginWidgetFlags); marginsWidget->setPageWidth(prefsData->docSetupPrefs.pageWidth); @@ -271,42 +271,19 @@ void Prefs_DocumentSetup::setupPageSizes(struct ApplicationPrefs *prefsData) { - PageSize ps(prefsData->docSetupPrefs.pageSize); - QStringList insertList(ps.activeSizeList()); - QStringList insertTrList(ps.activeSizeTRList()); - prefsPageSizeName = prefsData->docSetupPrefs.pageSize; - if (prefsPageSizeName == CommonStrings::trCustomPageSize) - prefsPageSizeName = CommonStrings::customPageSize; - if ((prefsPageSizeName != CommonStrings::customPageSize) && - (prefsPageSizeName != CommonStrings::trCustomPageSize) && - (insertList.indexOf(prefsPageSizeName) == -1)) - { - insertList << prefsPageSizeName; - insertTrList << prefsPageSizeName; - } - QMap<QString, QString> insertMap; - for (int i = 0; i < insertTrList.count(); ++i) - { - const QString& key = insertTrList.at(i); - insertMap[key] = insertList.at(i); - } - insertTrList.sort(); + PageSize ps(prefsPageSizeName); - pageSizeComboBox->clear(); - for (int i = 0; i < insertList.count(); ++i) + // try to find coresponding page size by dimensions + if (ps.name() == CommonStrings::customPageSize) { - const QString& key = insertTrList.at(i); - pageSizeComboBox->addItem(key, insertMap[key]); + PageSizeInfoMap pages = ps.sizesByDimensions(QSize(prefsData->docSetupPrefs.pageWidth, prefsData->docSetupPrefs.pageHeight)); + if (pages.count() > 0) + prefsPageSizeName = pages.firstKey(); } - pageSizeComboBox->addItem(CommonStrings::trCustomPageSize, CommonStrings::customPageSize); - QString pageSizeName = CommonStrings::trCustomPageSize; - int index = pageSizeComboBox->findData(prefsPageSizeName); - if (index >= 0) - pageSizeName = pageSizeComboBox->itemText(index); - setCurrentComboItem(pageSizeComboBox, pageSizeName); + pageSizeSelector->setPageSize(prefsPageSizeName); marginsWidget->setPageSize(prefsPageSizeName); bleedsWidget->setPageSize(prefsPageSizeName); } @@ -322,9 +299,9 @@ { pageW = pageWidthSpinBox->value() / unitRatio; marginsWidget->setPageWidth(pageW); - QString psText = pageSizeComboBox->currentText(); + QString psText = pageSizeSelector->pageSizeTR(); if (psText != CommonStrings::trCustomPageSize && psText != CommonStrings::customPageSize) - pageSizeComboBox->setCurrentIndex(pageSizeComboBox->count() - 1); + pageSizeSelector->setPageSize(CommonStrings::customPageSize); int newOrientation = (pageWidthSpinBox->value() > pageHeightSpinBox->value()) ? landscapePage : portraitPage; if (newOrientation != pageOrientationComboBox->currentIndex()) { @@ -338,9 +315,9 @@ { pageH = pageHeightSpinBox->value() / unitRatio; marginsWidget->setPageHeight(pageH); - QString psText = pageSizeComboBox->currentText(); + QString psText = pageSizeSelector->pageSizeTR(); if (psText != CommonStrings::trCustomPageSize && psText != CommonStrings::customPageSize) - pageSizeComboBox->setCurrentIndex(pageSizeComboBox->count() - 1); + pageSizeSelector->setPageSize(CommonStrings::customPageSize); int newOrientation = (pageWidthSpinBox->value() > pageHeightSpinBox->value()) ? landscapePage : portraitPage; if (newOrientation != pageOrientationComboBox->currentIndex()) { @@ -352,10 +329,10 @@ void Prefs_DocumentSetup::setPageOrientation(int orientation) { - setSize(pageSizeComboBox->currentText()); + setSize(pageSizeSelector->pageSize()); pageWidthSpinBox->blockSignals(true); pageHeightSpinBox->blockSignals(true); - if ((orientation==0 && pageSizeComboBox->currentText() == CommonStrings::trCustomPageSize) || orientation!=0) + if ((orientation==0 && pageSizeSelector->pageSizeTR() == CommonStrings::trCustomPageSize) || orientation!=0) { double w = pageWidthSpinBox->value(), h = pageHeightSpinBox->value(); pageWidthSpinBox->setValue((orientation == portraitPage) ? qMin(w, h) : qMax(w, h)); @@ -379,7 +356,7 @@ PageSize ps2(newSize); prefsPageSizeName = ps2.name(); - if (newSize != CommonStrings::trCustomPageSize) + if (newSize != CommonStrings::customPageSize && newSize != CommonStrings::trCustomPageSize) { pageW = ps2.width(); pageH = ps2.height(); Index: scribus/ui/prefs_documentsetupbase.ui =================================================================== --- scribus/ui/prefs_documentsetupbase.ui (Revision 26264) +++ scribus/ui/prefs_documentsetupbase.ui (Arbeitskopie) @@ -28,7 +28,6 @@ <property name="font"> <font> <pointsize>14</pointsize> - <weight>75</weight> <bold>true</bold> </font> </property> @@ -40,7 +39,7 @@ <item> <widget class="Line" name="line"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Orientation::Horizontal</enum> </property> </widget> </item> @@ -69,7 +68,7 @@ <item> <spacer name="horizontalSpacer_3"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Orientation::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -84,10 +83,10 @@ <item> <spacer name="verticalSpacer"> <property name="orientation"> - <enum>Qt::Vertical</enum> + <enum>Qt::Orientation::Vertical</enum> </property> <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> + <enum>QSizePolicy::Policy::Fixed</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -101,7 +100,6 @@ <widget class="QLabel" name="pageSizeTitleLabel"> <property name="font"> <font> - <weight>75</weight> <bold>true</bold> </font> </property> @@ -113,7 +111,7 @@ <item> <widget class="Line" name="line_2"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Orientation::Horizontal</enum> </property> </widget> </item> @@ -124,20 +122,17 @@ <property name="text"> <string>Size:</string> </property> - <property name="buddy"> - <cstring>pageSizeComboBox</cstring> - </property> </widget> </item> <item row="0" column="1"> <layout class="QHBoxLayout" name="pageSizeLayout"> <item> - <widget class="QComboBox" name="pageSizeComboBox"/> + <widget class="PageSizeSelector" name="pageSizeSelector" native="true"/> </item> <item> <widget class="QToolButton" name="pageSizeLinkToolButton"> <property name="arrowType"> - <enum>Qt::NoArrow</enum> + <enum>Qt::ArrowType::NoArrow</enum> </property> </widget> </item> @@ -214,7 +209,7 @@ <item> <spacer name="verticalSpacer_5"> <property name="orientation"> - <enum>Qt::Vertical</enum> + <enum>Qt::Orientation::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -235,7 +230,6 @@ <widget class="QLabel" name="pageLayoutTitleLabel"> <property name="font"> <font> - <weight>75</weight> <bold>true</bold> </font> </property> @@ -247,7 +241,7 @@ <item> <widget class="Line" name="line_3"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Orientation::Horizontal</enum> </property> </widget> </item> @@ -266,7 +260,7 @@ <item row="4" column="1"> <widget class="QComboBox" name="layoutFirstPageIsComboBox"> <property name="sizeAdjustPolicy"> - <enum>QComboBox::AdjustToContents</enum> + <enum>QComboBox::SizeAdjustPolicy::AdjustToContents</enum> </property> </widget> </item> @@ -318,7 +312,7 @@ <item> <spacer name="verticalSpacer_8"> <property name="orientation"> - <enum>Qt::Vertical</enum> + <enum>Qt::Orientation::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -350,10 +344,10 @@ <item> <widget class="QScrollArea" name="scrollArea"> <property name="frameShape"> - <enum>QFrame::NoFrame</enum> + <enum>QFrame::Shape::NoFrame</enum> </property> <property name="frameShadow"> - <enum>QFrame::Plain</enum> + <enum>QFrame::Shadow::Plain</enum> </property> <property name="lineWidth"> <number>0</number> @@ -366,8 +360,8 @@ <rect> <x>0</x> <y>0</y> - <width>458</width> - <height>540</height> + <width>494</width> + <height>575</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_5"> @@ -375,7 +369,6 @@ <widget class="QLabel" name="marginsTitleLabel"> <property name="font"> <font> - <weight>75</weight> <bold>true</bold> </font> </property> @@ -387,7 +380,7 @@ <item> <widget class="Line" name="line_5"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Orientation::Horizontal</enum> </property> </widget> </item> @@ -411,7 +404,7 @@ <item> <spacer name="horizontalSpacer_6"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Orientation::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -440,10 +433,10 @@ <item> <spacer name="verticalSpacer_3"> <property name="orientation"> - <enum>Qt::Vertical</enum> + <enum>Qt::Orientation::Vertical</enum> </property> <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> + <enum>QSizePolicy::Policy::Fixed</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -457,7 +450,6 @@ <widget class="QLabel" name="bleedsTitleLabel"> <property name="font"> <font> - <weight>75</weight> <bold>true</bold> </font> </property> @@ -469,7 +461,7 @@ <item> <widget class="Line" name="line_4"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Orientation::Horizontal</enum> </property> </widget> </item> @@ -493,7 +485,7 @@ <item> <spacer name="horizontalSpacer_7"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Orientation::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -508,7 +500,7 @@ <item> <spacer name="verticalSpacer_4"> <property name="orientation"> - <enum>Qt::Vertical</enum> + <enum>Qt::Orientation::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -546,10 +538,10 @@ <item> <spacer name="verticalSpacer_6"> <property name="orientation"> - <enum>Qt::Vertical</enum> + <enum>Qt::Orientation::Vertical</enum> </property> <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> + <enum>QSizePolicy::Policy::Fixed</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -563,7 +555,6 @@ <widget class="QLabel" name="autosaveTitleLable"> <property name="font"> <font> - <weight>75</weight> <bold>true</bold> </font> </property> @@ -575,7 +566,7 @@ <item> <widget class="Line" name="line_6"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Orientation::Horizontal</enum> </property> </widget> </item> @@ -626,7 +617,7 @@ <item> <spacer name="horizontalSpacer_2"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Orientation::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -689,10 +680,10 @@ <item> <spacer name="verticalSpacer_7"> <property name="orientation"> - <enum>Qt::Vertical</enum> + <enum>Qt::Orientation::Vertical</enum> </property> <property name="sizeType"> - <enum>QSizePolicy::Maximum</enum> + <enum>QSizePolicy::Policy::Maximum</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -706,7 +697,6 @@ <widget class="QLabel" name="undoRedoTitleLabel"> <property name="font"> <font> - <weight>75</weight> <bold>true</bold> </font> </property> @@ -718,7 +708,7 @@ <item> <widget class="Line" name="line_7"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Orientation::Horizontal</enum> </property> </widget> </item> @@ -744,7 +734,7 @@ <item> <spacer name="horizontalSpacer"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Orientation::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -759,7 +749,7 @@ <item> <spacer name="verticalSpacer_2"> <property name="orientation"> - <enum>Qt::Vertical</enum> + <enum>Qt::Orientation::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -787,11 +777,16 @@ <header location="global">ui/newmarginwidget.h</header> <container>1</container> </customwidget> + <customwidget> + <class>PageSizeSelector</class> + <extends>QWidget</extends> + <header>ui/widgets/pagesizeselector.h</header> + <container>1</container> + </customwidget> </customwidgets> <tabstops> <tabstop>tabWidget</tabstop> <tabstop>languageComboBox</tabstop> - <tabstop>pageSizeComboBox</tabstop> <tabstop>pageSizeLinkToolButton</tabstop> <tabstop>pageOrientationComboBox</tabstop> <tabstop>pageUnitsComboBox</tabstop> Index: scribus/ui/prefs_pagesizes.cpp =================================================================== --- scribus/ui/prefs_pagesizes.cpp (Revision 26264) +++ scribus/ui/prefs_pagesizes.cpp (Arbeitskopie) @@ -19,11 +19,15 @@ : Prefs_Pane(parent) { setupUi(this); - languageChange(); m_caption = tr("Page Sizes"); m_icon = "16/page-simple.png"; + treeAvailableSizes->setColumnCount(2); + treeActiveSizes->setColumnCount(2); + + languageChange(); + toActiveButton->setIcon(IconManager::instance().loadIcon("22/go-next.png")); fromActiveButton->setIcon(IconManager::instance().loadIcon("22/go-previous.png")); connect(toActiveButton, SIGNAL(clicked()), this, SLOT(moveToActive())); @@ -34,68 +38,161 @@ void Prefs_PageSizes::languageChange() { - // No need to do anything here, the UI language cannot change while prefs dialog is opened + QString textSize = tr("Page Format"); + QString textDimension = tr("Dimension"); + + if(QTreeWidgetItem* header = treeAvailableSizes->headerItem()) { + header->setText(0, textSize); + + if (header->columnCount() > 1) + header->setText(1, textDimension); + } + else + treeAvailableSizes->setHeaderLabel( textSize ); + + + if(QTreeWidgetItem* header = treeActiveSizes->headerItem()) { + header->setText(0, textSize); + if (header->columnCount() > 1) + header->setText(1, textDimension); + } + else + treeActiveSizes->setHeaderLabel( textSize ); + } void Prefs_PageSizes::restoreDefaults(struct ApplicationPrefs *prefsData) { PageSize ps(prefsData->docSetupPrefs.pageSize); - QStringList sizeList(ps.sizeList()); - QStringList activeSizeList(ps.activeSizeList()); - activeSizesListWidget->clear(); - availableSizesListWidget->clear(); - for (int i = 0; i < activeSizeList.count(); ++i) + treeAvailableSizes->clear(); + treeActiveSizes->clear(); + + auto cats = ps.categories(); + + // Available Page Sizes + for (auto it = cats.begin(); it != cats.end(); ++it) { - QListWidgetItem* lwi = new QListWidgetItem(); - PageSize ps2(activeSizeList.at(i)); - lwi->setText(ps2.nameTR()); - lwi->setToolTip(QString("%1 x %2 %3").arg(ps2.originalWidth()).arg(ps2.originalHeight()).arg(ps2.originalUnit())); - activeSizesListWidget->addItem(lwi); + QTreeWidgetItem* tlItem = new QTreeWidgetItem(); + tlItem->setText(0, it.value()); + tlItem->setData(0, Qt::UserRole, it.key()); + + treeAvailableSizes->addTopLevelItem(tlItem); + + PageSizeInfoMap sizes = ps.sizesByCategory(it.key()); + + 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()); + + tlItem->addChild(sItem); + } + } } - for (int i = 0; i < sizeList.count(); ++i) + // Active page Sizes + for (auto it = cats.begin(); it != cats.end(); ++it) { - if (!activeSizeList.contains(sizeList.at(i))) + 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) { - QListWidgetItem* lwi = new QListWidgetItem(); - PageSize ps2(sizeList.at(i)); - lwi->setText(ps2.nameTR()); - lwi->setToolTip(QString("%1 x %2 %3").arg(ps2.originalWidth()).arg(ps2.originalHeight()).arg(ps2.originalUnit())); - availableSizesListWidget->addItem(lwi); + 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); + } + } } + } void Prefs_PageSizes::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const { QStringList newActivePageSizes; - for (int i = 0; i < activeSizesListWidget->count(); ++i) - newActivePageSizes << activeSizesListWidget->item(i)->text(); - PageSize ps(prefsData->docSetupPrefs.pageSize); - prefsData->activePageSizes = ps.untransPageSizeList(newActivePageSizes); + + for (int i = 0; i < treeActiveSizes->topLevelItemCount(); ++i) + { + QTreeWidgetItem* item = treeActiveSizes->takeTopLevelItem(i); + + for (int j = 0; j < item->childCount(); ++j) + newActivePageSizes << item->child(j)->data(0, Qt::UserRole).toString(); + } + + prefsData->activePageSizes = newActivePageSizes; + } void Prefs_PageSizes::moveToActive() { - QList<QListWidgetItem *> si(availableSizesListWidget->selectedItems()); - for (int i = 0; i < si.count(); ++i) - { - QListWidgetItem* it = availableSizesListWidget->takeItem(availableSizesListWidget->row(si.at(i))); - activeSizesListWidget->addItem(it); - } + moveItems(treeAvailableSizes, treeActiveSizes); } void Prefs_PageSizes::moveFromActive() { - QList<QListWidgetItem *> si(activeSizesListWidget->selectedItems()); + int childrenCount = 0; + + for (int i = 0; i < treeActiveSizes->topLevelItemCount(); ++i) + childrenCount += treeActiveSizes->topLevelItem(i)->childCount(); + + if (childrenCount > 1) + moveItems(treeActiveSizes, treeAvailableSizes); +} + +void Prefs_PageSizes::moveItems(QTreeWidget *fromList, QTreeWidget *toList) +{ + QList<QTreeWidgetItem *> si(fromList->selectedItems()); + + if (si.count() != 1) + return; + for (int i = 0; i < si.count(); ++i) { - if (activeSizesListWidget->count()>1) + QTreeWidgetItem* currentItem = si.at(i); + QTreeWidgetItem* currentParent = currentItem->parent(); + + if (currentParent) { - QListWidgetItem* it = activeSizesListWidget->takeItem(activeSizesListWidget->row(si.at(i))); - availableSizesListWidget->addItem(it); + int index = fromList->indexOfTopLevelItem(currentParent); + + QTreeWidgetItem* exItem = currentParent->takeChild(currentParent->indexOfChild(currentItem)); + if (exItem) + { + QTreeWidgetItem* newParentItem = toList->topLevelItem(index); + newParentItem->addChild(exItem); + newParentItem->sortChildren(0, Qt::AscendingOrder); + } } + else + { + int index = fromList->indexOfTopLevelItem(currentItem); + + QList<QTreeWidgetItem*> exItems = currentItem->takeChildren(); + if (exItems.count() > 0) + { + QTreeWidgetItem* newParentItem = toList->topLevelItem(index); + newParentItem->addChildren(exItems); + newParentItem->sortChildren(0, Qt::AscendingOrder); + } + } } } Index: scribus/ui/prefs_pagesizes.h =================================================================== --- scribus/ui/prefs_pagesizes.h (Revision 26264) +++ scribus/ui/prefs_pagesizes.h (Arbeitskopie) @@ -31,6 +31,9 @@ protected slots: void moveToActive(); void moveFromActive(); + +private: + void moveItems(QTreeWidget* fromList, QTreeWidget* toList); }; #endif // PREFS_PAGESIZES_H Index: scribus/ui/prefs_pagesizesbase.ui =================================================================== --- scribus/ui/prefs_pagesizesbase.ui (Revision 26264) +++ scribus/ui/prefs_pagesizesbase.ui (Arbeitskopie) @@ -7,28 +7,27 @@ <x>0</x> <y>0</y> <width>657</width> - <height>358</height> - </rect> - </property> - <layout class="QVBoxLayout" name="verticalLayout_4"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="label"> - <property name="font"> - <font> - <pointsize>14</pointsize> - <weight>75</weight> + <height>358</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QLabel" name="label"> + <property name="font"> + <font> + <pointsize>14</pointsize> <bold>true</bold> </font> </property> @@ -40,7 +39,7 @@ <item> <widget class="Line" name="line"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Orientation::Horizontal</enum> </property> </widget> </item> @@ -56,16 +55,15 @@ </widget> </item> <item> - <widget class="QListWidget" name="availableSizesListWidget"> - <property name="alternatingRowColors"> - <bool>false</bool> - </property> + <widget class="QTreeWidget" name="treeAvailableSizes"> <property name="selectionMode"> - <enum>QAbstractItemView::ExtendedSelection</enum> + <enum>QAbstractItemView::SelectionMode::SingleSelection</enum> </property> - <property name="sortingEnabled"> - <bool>true</bool> - </property> + <column> + <property name="text"> + <string notr="true">1</string> + </property> + </column> </widget> </item> </layout> @@ -75,7 +73,7 @@ <item> <spacer name="verticalSpacer"> <property name="orientation"> - <enum>Qt::Vertical</enum> + <enum>Qt::Orientation::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -102,7 +100,7 @@ <item> <spacer name="verticalSpacer_2"> <property name="orientation"> - <enum>Qt::Vertical</enum> + <enum>Qt::Orientation::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> @@ -119,18 +117,20 @@ <item> <widget class="QLabel" name="label_3"> <property name="text"> - <string>Active Sizes</string> + <string>Preferred Sizes</string> </property> </widget> </item> <item> - <widget class="QListWidget" name="activeSizesListWidget"> + <widget class="QTreeWidget" name="treeActiveSizes"> <property name="selectionMode"> - <enum>QAbstractItemView::ExtendedSelection</enum> + <enum>QAbstractItemView::SelectionMode::SingleSelection</enum> </property> - <property name="sortingEnabled"> - <bool>true</bool> - </property> + <column> + <property name="text"> + <string notr="true">1</string> + </property> + </column> </widget> </item> </layout> Index: scribus/ui/widgets/pagelayout.cpp =================================================================== --- scribus/ui/widgets/pagelayout.cpp (nicht existent) +++ scribus/ui/widgets/pagelayout.cpp (Arbeitskopie) @@ -0,0 +1,205 @@ +/* +For general Scribus (>=1.3.2) copyright and licensing information please refer +to the COPYING file provided with the program. Following this notice may exist +a copyright and/or license notice that predates the release of Scribus 1.3.2 +for which a new license (GPL+exception) is in place. +*/ +#include "pagelayout.h" + +#include <QComboBox> +#include <QToolButton> +#include <QVBoxLayout> +#include <QListWidgetItem> +#include <QLabel> +#include <QPixmap> +#include <QList> + +#include "commonstrings.h" +#include "iconmanager.h" +#include "scribusapp.h" +#include "ui/widgets/form_widget.h" + +PageLayouts::PageLayouts(QWidget* parent) : QWidget( parent ) +{ + struct PageSet pageS; + pageS.Name = CommonStrings::trPageSet2; + pageS.FirstPage = 0; + pageS.Rows = 1; + pageS.Columns = 1; + pageS.pageNames.clear(); + pageS.pageNames.append(CommonStrings::trPageLocMiddleRight); + m_pageSets.append(pageS); + + layoutGroupLayout = new QHBoxLayout(this); + layoutGroupLayout->setSpacing(4); + layoutGroupLayout->setContentsMargins(0, 0, 0, 0); + + QFont layFont(this->font()); + layFont.setPointSize(8); + + menuScheme = new QMenu(); + + buttonScheme = new QToolButton(this); + buttonScheme->setPopupMode(QToolButton::InstantPopup); + buttonScheme->setMenu(menuScheme); + + labelScheme = new FormWidget(); + labelScheme->setFont(layFont); + labelScheme->addWidget(buttonScheme); + labelScheme->setLabelVisibility(!m_hideLabels); + layoutGroupLayout->addWidget( labelScheme ); + + menuFirstPage = new QMenu(); + + buttonFirstPage = new QToolButton(this); + buttonFirstPage->setPopupMode(QToolButton::InstantPopup); + buttonFirstPage->setMenu(menuFirstPage); + + labelPages = new FormWidget(); + labelPages->setFont(layFont); + labelPages->addWidget( buttonFirstPage ); + labelPages->setLabelVisibility(!m_hideLabels); + layoutGroupLayout->addWidget( labelPages ); + + languageChange(); + + connect(ScQApp, SIGNAL(labelVisibilityChanged(bool)), this, SLOT(toggleLabelVisibility(bool))); + connect(menuScheme, &QMenu::triggered, this, &PageLayouts::changeScheme); + connect(menuFirstPage, &QMenu::triggered, this, &PageLayouts::changeFirstPage); +} + +void PageLayouts::updateSchemeSelector(QList<PageSet> pageSets, int pagePositioning) +{ + m_pageSets = pageSets; + docPagePositioning = pagePositioning; + labelPages->setVisible( docPagePositioning > 0 ); + + reloadScheme(); +} + +void PageLayouts::setFirstPage(int nr) +{ + if (menuFirstPage->actions().count() == 0) + return; + + m_firstPage = qBound(0, nr, menuFirstPage->actions().count()); + buttonFirstPage->setIcon(menuFirstPage->actions().at(m_firstPage)->icon()); +} + +void PageLayouts::setScheme(int nr) +{ + if (menuScheme->actions().count() == 0) + return; + + m_scheme = qBound(0, nr, menuScheme->actions().count()); + buttonScheme->setIcon(menuScheme->actions().at(m_scheme)->icon()); + + reloadFirstPage(m_scheme); + +} + +void PageLayouts::setHideLabelsPermanently(bool hide) +{ + m_hideLabels = hide; + toggleLabelVisibility(!hide); +} + +void PageLayouts::reloadScheme() +{ + disconnect(menuScheme, &QMenu::triggered, this, &PageLayouts::changeScheme); + + menuScheme->clear(); + + for (int pg = 0; pg < m_pageSets.count(); ++pg) + { + //Leave the code in for 3-/4- fold but exclude from UI in case we bring it back. + if (pg > 1 && docPagePositioning < 2) + continue; + + QString psname = CommonStrings::translatePageSetString(m_pageSets[pg].Name); + if (pg == 0) + menuScheme->addAction(IconManager::instance().loadIcon("16/page-simple.png"), psname)->setData(QVariant(pg)); + else if (pg == 1) + menuScheme->addAction(IconManager::instance().loadIcon("16/page-doublesided.png"), psname)->setData(QVariant(pg)); + else if (pg == 2) + menuScheme->addAction(IconManager::instance().loadIcon("16/page-3fold.png"), psname)->setData(QVariant(pg)); + else if (pg == 3) + menuScheme->addAction(IconManager::instance().loadIcon("16/page-4fold.png"), psname)->setData(QVariant(pg)); + else + menuScheme->addAction(IconManager::instance().loadIcon("16/page-simple.png"), psname)->setData(QVariant(pg)); + } + + connect(menuScheme, &QMenu::triggered, this, &PageLayouts::changeScheme); + + +} + +void PageLayouts::reloadFirstPage(int scheme) +{ + disconnect(menuFirstPage, &QMenu::triggered, this, &PageLayouts::changeFirstPage); + + menuFirstPage->clear(); + + // We have to add the other cases if want to support them again + // CommonStrings::pageLocLeft + // CommonStrings::pageLocMiddle + // CommonStrings::pageLocMiddleLeft + // CommonStrings::pageLocMiddleRight + // CommonStrings::pageLocRight + + for (int pg = 0; pg < m_pageSets[scheme].pageNames.count(); ++pg) + { + QString psname = m_pageSets[scheme].pageNames[pg]; + + if (psname == CommonStrings::pageLocLeft) + menuFirstPage->addAction(IconManager::instance().loadIcon("page-first-left"), psname)->setData(QVariant(pg)); + else if (psname == CommonStrings::pageLocRight) + menuFirstPage->addAction(IconManager::instance().loadIcon("page-first-right"), psname)->setData(QVariant(pg)); + else + menuFirstPage->addAction(IconManager::instance().loadIcon("page-first-left"), psname)->setData(QVariant(pg)); + } + + connect(menuFirstPage, &QMenu::triggered, this, &PageLayouts::changeFirstPage); + + +} + +void PageLayouts::toggleLabelVisibility(bool visibility) +{ + // hide labels always if flag is false + if (m_hideLabels) + visibility = false; + + labelScheme->setLabelVisibility(visibility); + labelPages->setLabelVisibility(visibility); +} + +void PageLayouts::languageChange() +{ + + reloadScheme(); + reloadFirstPage(m_scheme); + + labelScheme->setText( tr( "Scheme" ) ); + labelPages->setText( tr( "First Page" ) ); + + buttonScheme->setToolTip( tr( "Number of pages to show side-by-side on the canvas. Often used for allowing items to be placed across page spreads." ) ); + buttonFirstPage->setToolTip( tr( "Location on the canvas where the first page of the document is placed" ) ); +} + +void PageLayouts::changeScheme(QAction *action) +{ + buttonScheme->setIcon(action->icon()); + int ic = action->data().toInt(); +// setScheme(ic); + reloadFirstPage(ic); + labelPages->setVisible( ic > 0 ); + emit schemeChanged(ic); +} + +void PageLayouts::changeFirstPage(QAction *action) +{ + buttonFirstPage->setIcon(action->icon()); + m_firstPage = action->data().toInt(); + emit firstPageChanged(m_firstPage); +} Index: scribus/ui/widgets/pagelayout.h =================================================================== --- scribus/ui/widgets/pagelayout.h (nicht existent) +++ scribus/ui/widgets/pagelayout.h (Arbeitskopie) @@ -0,0 +1,77 @@ +/* +For general Scribus (>=1.3.2) copyright and licensing information please refer +to the COPYING file provided with the program. Following this notice may exist +a copyright and/or license notice that predates the release of Scribus 1.3.2 +for which a new license (GPL+exception) is in place. +*/ +#ifndef PAGELAYOUT_H +#define PAGELAYOUT_H + +#include <QGroupBox> +#include <QListWidget> +#include <QList> + +class QToolButton; +class QLabel; +class QHBoxLayout; +class FormWidget; +class QMenu; + +#include "scribusapi.h" +#include "scribusstructs.h" +#include "scribusdoc.h" + +/*! \brief A widget for changing pages layout. +User can change layouts on-the-fly changing widget's +comboboxes. */ +class SCRIBUS_API PageLayouts : public QWidget +{ + Q_OBJECT + +public: + PageLayouts(QWidget* parent); + ~PageLayouts() {}; + + void updateSchemeSelector(QList<PageSet> pageSets, int pagePositioning); + void setFirstPage(int nr); + int firstPage() { return m_firstPage; }; + void setScheme(int nr); + int scheme() { return m_scheme; }; + + void setHideLabelsPermanently(bool hide); + bool hideLabelsPermanently() { return m_hideLabels; }; + +public slots: + void toggleLabelVisibility(bool visibility); + +signals: + void schemeChanged(int); + void firstPageChanged(int); + +private: + + int m_scheme {0}; + int m_firstPage {0}; + bool m_hideLabels {false}; + int docPagePositioning {0}; + + FormWidget* labelScheme; + FormWidget* labelPages; + QList<PageSet> m_pageSets; + QToolButton* buttonScheme; + QToolButton* buttonFirstPage; + QMenu* menuScheme; + QMenu* menuFirstPage; + QHBoxLayout* layoutGroupLayout; + + void reloadScheme(); + void reloadFirstPage(int scheme); + +protected slots: + void languageChange(); + void changeScheme(QAction* action); + void changeFirstPage(QAction* action); + +}; + +#endif // PAGELAYOUT_H Index: scribus/ui/widgets/pagesizelist.cpp =================================================================== --- scribus/ui/widgets/pagesizelist.cpp (nicht existent) +++ scribus/ui/widgets/pagesizelist.cpp (Arbeitskopie) @@ -0,0 +1,196 @@ +/* +For general Scribus (>=1.3.2) copyright and licensing information please refer +to the COPYING file provided with the program. Following this notice may exist +a copyright and/or license notice that predates the release of Scribus 1.3.2 +for which a new license (GPL+exception) is in place. +*/ + +#include "pagesizelist.h" +#include "ui/delegates/sclistitemdelegate.h" +#include "pagesize.h" +#include "prefsmanager.h" +#include <QPainter> + +PageSizeList::PageSizeList(QWidget* parent) : + QListView(parent) +{ + m_model = new QStandardItemModel(); + setModel(m_model); + setDragEnabled(false); + setViewMode(QListView::IconMode); + setFlow(QListView::LeftToRight); + setWordWrap(true); + setAcceptDrops(false); + setDropIndicatorShown(false); + setDragDropMode(QAbstractItemView::NoDragDrop); + setResizeMode(QListView::Adjust); + setSelectionMode(QAbstractItemView::SingleSelection); + setFocusPolicy(Qt::NoFocus); + setIconSize(QSize(80, 80)); + setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + setGridSize(QSize(160, 160)); + setItemDelegate(new ScListItemDelegate(QListWidget::IconMode, iconSize())); + setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); + +} + +void PageSizeList::setFormat(QString format) +{ + loadPageSizes(format, m_orientation, m_category); + m_name = format; + setSortMode(m_sortMode); +} + +void PageSizeList::setOrientation(int orientation) +{ + loadPageSizes(m_name, orientation, m_category); + m_orientation = orientation; + setSortMode(m_sortMode); +} + +void PageSizeList::setCategory(PageSizeInfo::Category category) +{ + loadPageSizes(m_name, m_orientation, category); + m_category = category; + setSortMode(m_sortMode); +} + +void PageSizeList::setSortMode(SortMode sortMode) +{ + QSignalBlocker sig(this); + + m_sortMode = sortMode; + + switch (sortMode) + { + case NameAsc: + m_model->setSortRole(ItemData::Name); + m_model->sort(0, Qt::AscendingOrder); + break; + case NameDesc: + m_model->setSortRole(ItemData::Name); + m_model->sort(0, Qt::DescendingOrder); + break; + case DimensionAsc: + m_model->setSortRole(ItemData::Dimension); + m_model->sort(0, Qt::AscendingOrder); + break; + case DimensionDesc: + m_model->setSortRole(ItemData::Dimension); + m_model->sort(0, Qt::DescendingOrder); + break; + } + +} + +void PageSizeList::setValues(QString format, int orientation, PageSizeInfo::Category category, SortMode sortMode) +{ + loadPageSizes(format, orientation, category); + m_name = format; + m_orientation = orientation; + m_category = category; + setSortMode(sortMode); +} + +void PageSizeList::loadPageSizes(QString name, int orientation, PageSizeInfo::Category category) +{ + QSignalBlocker sig(this); + + PageSize ps(name); + PageSize pref(PrefsManager::instance().appPrefs.docSetupPrefs.pageSize); + + int sel = -1; + + // reset sorting to default + m_model->setSortRole(ItemData::Name); + m_model->sort(0, Qt::AscendingOrder); + + if (m_category == category && this->selectionModel()->currentIndex().isValid()) + sel = this->selectionModel()->currentIndex().row(); + + m_model->clear(); + + foreach (auto item, ps.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())) + { + QStandardItem* itemA = new QStandardItem(); + itemA->setText(item.trSizeName); + itemA->setIcon(sizePreview(this->iconSize(), size)); + itemA->setData(QVariant(item.sizeLabel), 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.width * item.height), ItemData::Dimension); + m_model->appendRow(itemA); + + if (sel == -1 && item.sizeName == ps.name()) + sel = itemA->row(); + } + } + + if (sel > -1) + this->selectionModel()->setCurrentIndex(m_model->item(sel)->index(), QItemSelectionModel::Select ); + +} + +void PageSizeList::updateGeometries() +{ + QListView::updateGeometries(); + verticalScrollBar()->setSingleStep(10); +} + +QIcon PageSizeList::sizePreview(QSize iconSize, QSize pageSize) +{ + double devicePixelRatio = qApp->devicePixelRatio(); + double max = mm2pts(500 * devicePixelRatio); // reference for scale: large side of B3 + double iW = iconSize.width() * devicePixelRatio; + double iH = iconSize.height() * devicePixelRatio; + double pW = pageSize.width() * devicePixelRatio; + double pH = pageSize.height() * devicePixelRatio; + bool isVertical = pW <= pH; + + QPixmap pix(QSize(iW, iH)); + pix.fill(Qt::transparent); + + // vertical + double mod = qMin(pH / max, 1.0); + double ratio = pW / pH; + int height = iH * mod; + int width = height * ratio; + int x = iW / 2 - width / 2; + int y = iH - height; + + // horizontal + if (!isVertical) + { + mod = qMin(pW / max, 1.0); + ratio = pH / pW; + width = iW * mod; + height = width * ratio; + x = iW / 2 - width / 2; + y = iH - height; + } + + QRect page(x, y, width, height); + + QLinearGradient m_gradient(page.topLeft(), page.bottomRight()); + m_gradient.setColorAt(0.0, Qt::white); + m_gradient.setColorAt(1.0, QColor(240, 240, 240)); + + QPainter painter(&pix); + painter.setPen(QPen(palette().text().color())); + painter.setBrush(m_gradient); + painter.drawRect(page.adjusted(0, 0, -1, -1)); + painter.end(); + + return QIcon(pix); + +} Index: scribus/ui/widgets/pagesizelist.h =================================================================== --- scribus/ui/widgets/pagesizelist.h (nicht existent) +++ scribus/ui/widgets/pagesizelist.h (Arbeitskopie) @@ -0,0 +1,70 @@ +/* +For general Scribus (>=1.3.2) copyright and licensing information please refer +to the COPYING file provided with the program. Following this notice may exist +a copyright and/or license notice that predates the release of Scribus 1.3.2 +for which a new license (GPL+exception) is in place. +*/ +#ifndef PAGESIZELIST_H +#define PAGESIZELIST_H + +#include <QListView> +#include <QScrollBar> +#include <QStandardItemModel> +#include "scribusapi.h" +#include "pagesize.h" + +class SCRIBUS_API PageSizeList : public QListView +{ + Q_OBJECT + +public: + + enum SortMode { + NameAsc = 0, + NameDesc = 1, + DimensionAsc = 2, + DimensionDesc = 3 + }; + + enum ItemData { + SizeLabel = Qt::UserRole, + Unit = Qt::UserRole + 1, + Category = Qt::UserRole + 2, + Name = Qt::UserRole + 3, + Dimension = Qt::UserRole + 4, + }; + + PageSizeList(QWidget* parent); + ~PageSizeList() = default; + + void setFormat(QString format); + QString format() { return m_name; }; + + void setOrientation(int orientation); + int orientation() { return m_orientation; }; + + void setCategory(PageSizeInfo::Category category); + PageSizeInfo::Category category() { return m_category; }; + + void setSortMode(SortMode sortMode); + SortMode sortMode() { return m_sortMode; }; + + void setValues(QString format, int orientation, PageSizeInfo::Category category, SortMode sortMode); + + void updateGeometries() override; + +private: + + QString m_name {PageSize::defaultSizesList().at(1)}; + int m_orientation {0}; + PageSizeInfo::Category m_category {PageSizeInfo::Preferred}; + SortMode m_sortMode {SortMode::NameAsc}; + QStandardItemModel* m_model; + + QIcon sizePreview(QSize iconSize, QSize pageSize); + void loadPageSizes(QString name, int orientation, PageSizeInfo::Category category); + +}; + + +#endif // PAGESIZELIST_H Index: scribus/ui/widgets/pagesizepreview.cpp =================================================================== --- scribus/ui/widgets/pagesizepreview.cpp (nicht existent) +++ scribus/ui/widgets/pagesizepreview.cpp (Arbeitskopie) @@ -0,0 +1,79 @@ +#include "pagesizepreview.h" +#include "prefsmanager.h" + +#include <QFontMetrics> + +PageSizePreview::PageSizePreview(QWidget *parent) : QWidget{parent} +{ + setMinimumSize(120, 120); +} + +void PageSizePreview::paintEvent(QPaintEvent *event) +{ + QColor colPage = PrefsManager::instance().appPrefs.displayPrefs.paperColor; + QColor colBackground = PrefsManager::instance().appPrefs.displayPrefs.scratchColor; + QColor colMargin(Qt::blue); + QColor colFrame(Qt::black); + QColor colLabel(Qt::white); + QColor colLabelBackground(QColor(0, 0, 0, 128)); + + + int count = m_layout + 1; + int space = 8; + QRect saveArea(rect().adjusted(space, space, -space, -space)); + double ratio = qMin( saveArea.height() / m_height, saveArea.width() / (m_width * count) ); + double pageWidth = m_width * ratio; + double pageHeight = m_height * ratio; + QSize pageSize(pageWidth, pageHeight); + QRect rectPaper(0, 0, pageSize.width() * count, pageSize.height()); + rectPaper.setLeft( space + (saveArea.width() - rectPaper.width()) / 2 ); + rectPaper.setTop( space + (saveArea.height() - rectPaper.height()) / 2 ); + + QPainter painter(this); + painter.fillRect( rect(), QBrush(colBackground) ); + + for (int i = 0; i < count; i++) + { + QRect rPage(rectPaper.x() + pageSize.width() * i , rectPaper.y(), pageSize.width(), pageSize.height()); + QRect rMargin; + + // Left Page + if (i == 0 && count > 1) + { + rMargin.setLeft(rPage.left() + m_margins.right() * ratio); + rMargin.setRight(rPage.right() - m_margins.left() * ratio); + } + // Right and Single Page + else + { + rMargin.setLeft(rPage.left() + m_margins.left() * ratio); + rMargin.setRight(rPage.right() - m_margins.right() * ratio); + } + + rMargin.setTop(rPage.top() + m_margins.top() * ratio); + rMargin.setBottom(rPage.bottom() - m_margins.bottom() * ratio); + + + // Draw Pages + painter.setBrush( colPage ); + painter.setPen( QPen(colFrame) ); + painter.drawRect( rPage ); + + // Draw Margins + painter.setBrush( Qt::NoBrush ); + painter.setPen( QPen(colMargin) ); + painter.drawRect( rMargin ); + + painter.setPen( QPen(colFrame) ); + if (m_firstPage == i && count > 1) + painter.drawText(rPage, Qt::AlignCenter | Qt::AlignVCenter, QString::number(1)); + + } + + // Draw label + painter.setBackgroundMode(Qt::OpaqueMode); + painter.setBackground(colLabelBackground); + painter.setPen(QPen(colLabel)); + painter.drawText(saveArea, Qt::AlignLeft | Qt::AlignBottom |Qt::TextWordWrap, " " + m_name + " "); + +} Index: scribus/ui/widgets/pagesizepreview.h =================================================================== --- scribus/ui/widgets/pagesizepreview.h (nicht existent) +++ scribus/ui/widgets/pagesizepreview.h (Arbeitskopie) @@ -0,0 +1,54 @@ +#ifndef PAGESIZEPREVIEW_H +#define PAGESIZEPREVIEW_H + +#include "margins.h" +#include "pagesize.h" +#include <QWidget> + +class PageSizePreview : public QWidget +{ + Q_OBJECT +public: + explicit PageSizePreview(QWidget *parent = nullptr); + + void setPageHeight(double height) { m_height = height; update(); }; + void setPageWidth(double width) { m_width = width; update(); }; + void setMargins(MarginStruct margins) { m_margins = margins; update(); }; + void setBleeds(MarginStruct bleeds) { m_bleeds = bleeds; update(); }; + void setPageName(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, MarginStruct margins, MarginStruct bleeds, QString name, int layout, int firstPage) + { + PageSize ps(name); + + m_height = height; + m_width = width; + m_margins = margins; + m_bleeds = bleeds; + m_name = ps.nameTR(); + m_layout = layout; + m_firstPage = firstPage; + update(); + } + +private: + MarginStruct m_margins; + MarginStruct m_bleeds; + double m_height; + double m_width; + QString m_name; + int m_layout; + int m_firstPage; + + void paintEvent(QPaintEvent *event) override; + +signals: + +}; + +#endif // PAGESIZEPREVIEW_H Index: scribus/ui/widgets/pagesizeselector.cpp =================================================================== --- scribus/ui/widgets/pagesizeselector.cpp (nicht existent) +++ scribus/ui/widgets/pagesizeselector.cpp (Arbeitskopie) @@ -0,0 +1,162 @@ +/* +For general Scribus (>=1.3.2) copyright and licensing information please refer +to the COPYING file provided with the program. Following this notice may exist +a copyright and/or license notice that predates the release of Scribus 1.3.2 +for which a new license (GPL+exception) is in place. +*/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include <QVBoxLayout> + +#include "pagesizeselector.h" +#include "pagesize.h" +#include "commonstrings.h" + +PageSizeSelector::PageSizeSelector(QWidget *parent) + : QWidget{parent} +{ + comboCategory = new QComboBox(); + comboFormat = new QComboBox(); + + QVBoxLayout* lytMain = new QVBoxLayout(); + lytMain->setContentsMargins(0, 0, 0, 0); + lytMain->setSpacing(4); + lytMain->addWidget(comboCategory); + lytMain->addWidget(comboFormat); + this->setLayout(lytMain); + + connect(comboCategory, &QComboBox::currentIndexChanged, this, &PageSizeSelector::categorySelected); + connect(comboFormat, &QComboBox::currentIndexChanged, this, &PageSizeSelector::formatSelected); +} + + +void PageSizeSelector::setHasFormatSelector(bool isVisble) +{ + m_hasFormatSelector = isVisble; + comboFormat->setVisible(isVisble); +} + +void PageSizeSelector::setHasCustom(bool hasCustom) +{ + m_hasCustom = hasCustom; + + if (!m_sizeName.isEmpty()) + setPageSize(m_sizeName); +} + +void PageSizeSelector::setCurrentCategory(PageSizeInfo::Category category) +{ + int index = comboCategory->findData(category); + if (index != -1) + comboCategory->setCurrentIndex(index); +} + +void PageSizeSelector::setPageSize(QString name) +{ + PageSize ps(name); + + m_sizeName = ps.name(); + m_sizeCategory = ps.category(); + m_trSizeName = ps.nameTR(); + + // Load category list + int index = -1; + QSignalBlocker sigCat(comboCategory); + comboCategory->clear(); + + // Add Custom + if (hasCustom()) + { + comboCategory->addItem(CommonStrings::trCustomPageSize, PageSizeInfo::Custom); + if (m_sizeName == CommonStrings::customPageSize || m_sizeName == CommonStrings::trCustomPageSize) + index = comboCategory->count() - 1; + } + + // Add Preferred + comboCategory->addItem(ps.categoryToString(PageSizeInfo::Preferred), PageSizeInfo::Preferred); + + // Add all available categories + PageSizeCategoriesMap categories = ps.categories(); + for (auto it = categories.begin(); it != categories.end(); ++it) + { + comboCategory->addItem(it.value(), it.key()); + if (it.key() == m_sizeCategory) + index = comboCategory->count() - 1; + } + + comboCategory->setCurrentIndex(index); + comboCategory->insertSeparator(comboCategory->findData(PageSizeInfo::Preferred) + 1); + comboCategory->insertSeparator(comboCategory->findData(PageSizeInfo::IsoEnvelop) + 1); + comboCategory->insertSeparator(comboCategory->findData(PageSizeInfo::USEnvelop) + 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) +{ + if (!hasFormatSelector()) + return; + + PageSize ps(name); + + int index = -1; + QSignalBlocker sigFormat(comboFormat); + comboFormat->clear(); + + if (category == PageSizeInfo::Custom) + { + comboFormat->setEnabled(false); + m_sizeName = CommonStrings::customPageSize; + m_trSizeName = CommonStrings::trCustomPageSize; + return; + } + else + { + comboFormat->setEnabled(true); + } + + foreach (auto item, ps.pageSizes()) { + if (item.category == category || (category == PageSizeInfo::Preferred && ps.activePageSizes().contains(item.sizeName))) + { + comboFormat->addItem(item.trSizeName, item.sizeName); + if (item.sizeName == name) + index = comboFormat->count() - 1; + } + } + + if (index == -1) + index = 0; + + comboFormat->setCurrentIndex(index); + + m_sizeName = static_cast<QString>(comboFormat->currentData().toString()); + m_trSizeName = comboFormat->currentText(); + +} + +void PageSizeSelector::categorySelected(int index) +{ + m_sizeCategory = static_cast<PageSizeInfo::Category>(comboCategory->itemData(index).toInt()); + + setFormat(m_sizeCategory, m_sizeName); + emit pageCategoryChanged(m_sizeCategory); + emit pageSizeChanged(m_trSizeName); +} + +void PageSizeSelector::formatSelected(int index) +{ + m_sizeName = static_cast<QString>(comboFormat->itemData(index).toString()); + m_trSizeName = comboFormat->itemText(index); + + emit pageSizeChanged(m_trSizeName); +} Index: scribus/ui/widgets/pagesizeselector.h =================================================================== --- scribus/ui/widgets/pagesizeselector.h (nicht existent) +++ scribus/ui/widgets/pagesizeselector.h (Arbeitskopie) @@ -0,0 +1,64 @@ +/* +For general Scribus (>=1.3.2) copyright and licensing information please refer +to the COPYING file provided with the program. Following this notice may exist +a copyright and/or license notice that predates the release of Scribus 1.3.2 +for which a new license (GPL+exception) is in place. +*/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef PAGESIZESELECTOR_H +#define PAGESIZESELECTOR_H + +#include <QWidget> +#include <QComboBox> + +#include "pagesize.h" + +class PageSizeSelector : public QWidget +{ + Q_OBJECT +public: + explicit PageSizeSelector(QWidget *parent = nullptr); + + void setPageSize(QString name); + void setHasFormatSelector(bool isVisble ); + void setHasCustom(bool hasCustom); + bool hasCustom() { return m_hasCustom; }; + bool hasFormatSelector() { return m_hasFormatSelector; }; + void setCurrentCategory(PageSizeInfo::Category category); + + PageSizeInfo::Category category() { return m_sizeCategory; }; + QString pageSize() { return m_sizeName; }; + QString pageSizeTR() { return m_trSizeName; }; + +private: + QComboBox* comboCategory; + QComboBox* comboFormat; + + QString m_sizeName; + QString m_trSizeName; + PageSizeInfo::Category m_sizeCategory; + bool m_hasFormatSelector {true}; + bool m_hasCustom {true}; + + void setFormat(PageSizeInfo::Category category, QString name); + +signals: + void pageSizeChanged(QString); + void pageCategoryChanged(PageSizeInfo::Category); + +private slots: + void categorySelected(int index); + void formatSelected(int index); + +}; + +#endif // PAGESIZESELECTOR_H Index: scribus/ui/widgets/section_container.cpp =================================================================== --- scribus/ui/widgets/section_container.cpp (Revision 26264) +++ scribus/ui/widgets/section_container.cpp (Arbeitskopie) @@ -22,7 +22,7 @@ */ SectionContainer::SectionContainer(QWidget *parent) - : SectionContainer("Title", "", true, parent) {} + : SectionContainer("Title", "", true, true, parent) {} SectionContainer::SectionContainer(QString title, QString objectName, bool isCollapsible, bool isExpanded, QWidget *parent) @@ -36,11 +36,12 @@ m_isCollapsed = !isExpanded; // Main Layout - mainLayout = new QVBoxLayout(this); + mainLayout = new QVBoxLayout(); mainLayout->setSpacing(0); mainLayout->setContentsMargins(0, 0, 0, 0); mainLayout->addWidget(header); mainLayout->addWidget(body); + QWidget::setLayout(mainLayout); // Size Policy QSizePolicy sizePol(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum); @@ -241,7 +242,7 @@ QSize SectionContainer::calculateSize() { - QSize s = minimumSizeHint(); + QSize s = SectionContainer::minimumSizeHint(); s.setWidth(this->width()); return s; @@ -435,7 +436,7 @@ SectionContainerHeader::SectionContainerHeader(QWidget *parent) : SectionContainerHeader("Title", parent) {} -SectionContainerHeader::SectionContainerHeader(QString title, QWidget *parent) +SectionContainerHeader::SectionContainerHeader(QString title, QWidget *parent) : QWidget(parent) { int padding = 6; m_hasStyle = true; @@ -490,6 +491,8 @@ void SectionContainerHeader::paintEvent(QPaintEvent *event) { + Q_UNUSED(event) + if (!m_hasStyle) return; |
|
back from my holidays. i need to clean up my local copy to be able to compile again scribus... as soon as i've done that, i will test the patch. |
|
I found an issue in the previous patch. Default active pages are empty if there is no Scribus configuration file. The new patch fixes that. newdocdialog_2024-09-10.patch (291,485 bytes)
Index: Scribus.pro =================================================================== --- Scribus.pro (Revision 26264) +++ Scribus.pro (Arbeitskopie) @@ -481,8 +481,7 @@ scribus/ui/linecombo.h \ scribus/ui/linkbutton.h \ scribus/ui/loremipsum.h \ - scribus/ui/marginpresetlayout.h \ - scribus/ui/marginwidget.h \ + scribus/ui/marginpresetlayout.h \ scribus/ui/mark2item.h \ scribus/ui/mark2mark.h \ scribus/ui/markanchor.h \ @@ -1083,6 +1082,7 @@ scribus/ui/measurementsbase.ui \ scribus/ui/multipleduplicate.ui \ scribus/ui/multiprogressdialog.ui \ + scribus/ui/newdocdialog.ui \ scribus/ui/newmarginwidgetbase.ui \ scribus/ui/nftdialog.ui \ scribus/ui/nftwidget.ui \ @@ -1627,8 +1627,7 @@ scribus/ui/linecombo.cpp \ scribus/ui/linkbutton.cpp \ scribus/ui/loremipsum.cpp \ - scribus/ui/marginpresetlayout.cpp \ - scribus/ui/marginwidget.cpp \ + scribus/ui/marginpresetlayout.cpp \ scribus/ui/mark2item.cpp \ scribus/ui/mark2mark.cpp \ scribus/ui/markanchor.cpp \ Index: resources/iconsets/1_7_0/16/page-orientation-horizontal.svg =================================================================== --- resources/iconsets/1_7_0/16/page-orientation-horizontal.svg (nicht existent) +++ resources/iconsets/1_7_0/16/page-orientation-horizontal.svg (Arbeitskopie) @@ -0,0 +1,3 @@ +<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><style>@import '../colors.css';</style> +<path fill-rule="evenodd" clip-rule="evenodd" d="M5.41421 4L2 7.41421V12H14V4H5.41421ZM1 7L5 3H14H15V4V12V13H14H2H1V12V7Z"/> +</svg> Index: resources/iconsets/1_7_0/16/page-orientation-vertical.svg =================================================================== --- resources/iconsets/1_7_0/16/page-orientation-vertical.svg (nicht existent) +++ resources/iconsets/1_7_0/16/page-orientation-vertical.svg (Arbeitskopie) @@ -0,0 +1,3 @@ +<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><style>@import '../colors.css';</style> +<path fill-rule="evenodd" clip-rule="evenodd" d="M7.41421 2L4 5.41421V14H12V2H7.41421ZM3 5L7 1H12H13V2V14V15H12H4H3V14V5Z"/> +</svg> Index: resources/iconsets/1_7_0/1_7_0.xml =================================================================== --- resources/iconsets/1_7_0/1_7_0.xml (Revision 26264) +++ resources/iconsets/1_7_0/1_7_0.xml (Arbeitskopie) @@ -387,6 +387,8 @@ <icon id="layer-move-up" file="16/object-level-up.svg" /> <icon id="page-first-left" file="16/page-first-left.svg" /> <icon id="page-first-right" file="16/page-first-right.svg" /> + <icon id="page-orientation-horizontal" file="16/page-orientation-horizontal.svg" /> + <icon id="page-orientation-vertical" file="16/page-orientation-vertical.svg" /> <!-- PDF Tools --> <icon id="16/insert-button.png" file="16/pdf-button.svg" /> Index: scribus/CMakeLists_Sources.txt =================================================================== --- scribus/CMakeLists_Sources.txt (Revision 26264) +++ scribus/CMakeLists_Sources.txt (Arbeitskopie) @@ -363,7 +363,6 @@ ui/marksmanager.cpp ui/markvariabletext.cpp ui/marginpresetlayout.cpp - ui/marginwidget.cpp ui/newmarginwidget.cpp ui/mergedoc.cpp ui/missing.cpp @@ -383,7 +382,6 @@ ui/outputpreview_ps.cpp ui/outputpreviewbase.cpp ui/pageitemattributes.cpp - ui/pagelayout.cpp ui/pagepalette.cpp ui/pagepalette_pages.cpp ui/pagepalette_masterpages.cpp @@ -560,6 +558,10 @@ ui/widgets/floatingwindow.cpp ui/widgets/form_widget.cpp ui/widgets/gradientlistbox.cpp + ui/widgets/pagelayout.cpp + ui/widgets/pagesizelist.cpp + ui/widgets/pagesizepreview.cpp + ui/widgets/pagesizeselector.cpp ui/widgets/popup_menu.cpp ui/widgets/section_container.cpp ui/widgets/stacked_container.cpp Index: scribus/designer/formwidget_plugin.cpp =================================================================== --- scribus/designer/formwidget_plugin.cpp (Revision 26264) +++ scribus/designer/formwidget_plugin.cpp (Arbeitskopie) @@ -92,30 +92,25 @@ <ui language="c++" displayname="Form Widget"> <widget class="FormWidget" name="formWidget"> <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> - <property name="font"> - <font> - <pointsize>8</pointsize> - </font> - </property> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - </layout> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + </layout> </widget> <customwidgets> <customwidget> Index: scribus/designer/sectioncontainer_plugin.cpp =================================================================== --- scribus/designer/sectioncontainer_plugin.cpp (Revision 26264) +++ scribus/designer/sectioncontainer_plugin.cpp (Arbeitskopie) @@ -100,9 +100,9 @@ return QLatin1String(R"( <ui language="c++" displayname="Section Container"> <widget class="SectionContainer" name="sectionContainer"> - <widget class="QWidget" name="page"> - <layout class="QVBoxLayout" name="verticalLayout"/> - </widget> + <widget class="QWidget" name="page"> + <layout class="QVBoxLayout" name="verticalLayout"/> + </widget> </widget> <customwidgets> <customwidget> Index: scribus/localemgr.cpp =================================================================== --- scribus/localemgr.cpp (Revision 26264) +++ scribus/localemgr.cpp (Arbeitskopie) @@ -32,6 +32,7 @@ #include "scribuscore.h" #include "localemgr.h" #include "scpaths.h" +#include "pagesize.h" LocaleManager& LocaleManager::instance() { @@ -60,13 +61,20 @@ //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", "A4" )); - m_localeTable.append(LocaleDef("en", "in", "Letter")); - m_localeTable.append(LocaleDef("en_AU", "mm", "A4" )); - m_localeTable.append(LocaleDef("en_GB", "mm", "A4" )); - m_localeTable.append(LocaleDef("en_US", "in", "Letter")); - m_localeTable.append(LocaleDef("fr", "mm", "A4" )); - m_localeTable.append(LocaleDef("fr_QC", "pica", "Letter")); + // m_localeTable.append(LocaleDef("default","mm", QString::number(PageSizeInfo::IsoA) + "_A4" )); + // m_localeTable.append(LocaleDef("en", "in", QString::number(PageSizeInfo::USStandard) + "_Letter")); + // m_localeTable.append(LocaleDef("en_AU", "mm", QString::number(PageSizeInfo::IsoA) + "_A4" )); + // m_localeTable.append(LocaleDef("en_GB", "mm", QString::number(PageSizeInfo::IsoA) + "_A4" )); + // m_localeTable.append(LocaleDef("en_US", "in", QString::number(PageSizeInfo::USStandard) + "_Letter")); + // m_localeTable.append(LocaleDef("fr", "mm", QString::number(PageSizeInfo::IsoA) + "_A4" )); + // m_localeTable.append(LocaleDef("fr_QC", "pica", QString::number(PageSizeInfo::USStandard) + "_Letter")); + 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))); } void LocaleManager::printSelectedForLocale(const QString& locale) @@ -104,8 +112,8 @@ //qDebug()<<"No definition for locale: "<<selectedLocale; //No, we don't translate these, they are internal use that don't get to the GUI if (m_sysLocale.measurementSystem()==0) - return "A4"; - return "Letter"; + return PageSize::defaultSizesList().at(1); + return PageSize::defaultSizesList().at(4); // qFatal("Page Size not found in LocaleManager"); // return ""; } Index: scribus/pagesize.cpp =================================================================== --- scribus/pagesize.cpp (Revision 26264) +++ scribus/pagesize.cpp (Arbeitskopie) @@ -19,17 +19,12 @@ * * ***************************************************************************/ +#include "commonstrings.h" #include "pagesize.h" #include "prefsmanager.h" - #include <QStringList> +#include <QObject> -#include <cmath> -#include <iostream> - -#include "commonstrings.h" - - PageSize::PageSize(const QString& sizeName) { init(sizeName); @@ -68,6 +63,7 @@ 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. @@ -82,6 +78,7 @@ m_height = it.value().height; m_pageUnitIndex = it.value().pageUnitIndex; m_trPageSizeName = it.value().trSizeName; + m_category = it.value().category; valuesSet = true; } } @@ -95,334 +92,655 @@ m_pageUnitIndex = -1; m_pageSizeName = CommonStrings::customPageSize; m_trPageSizeName = CommonStrings::trCustomPageSize; + m_category = PageSizeInfo::Custom; } } -QStringList PageSize::sizeList() const +QStringList PageSize::defaultSizesList() { - QStringList pageSizes; - for (auto it = m_pageSizeList.begin(); it != m_pageSizeList.end(); ++it) - pageSizes.append(it.key()); - return QStringList(pageSizes); + return { "IsoA_A03", "IsoA_A04", "IsoA_A05", "IsoA_A06", "US_Letter" }; } -QStringList PageSize::sizeTRList() const +PageSizeCategoriesMap PageSize::categories() { - QStringList pageSizes; + PageSizeCategoriesMap map; + for (auto it = m_pageSizeList.begin(); it != m_pageSizeList.end(); ++it) - pageSizes.append(it.value().trSizeName); - return QStringList(pageSizes); + map.insert(it.value().category, categoryToString(it.value().category)); + + return map; } -QStringList PageSize::activeSizeList() const +PageSizeInfoMap PageSize::sizesByCategory(PageSizeInfo::Category category) { - QStringList pageSizes = sizeList(); - if (PrefsManager::instance().appPrefs.activePageSizes.count() == 0) - return QStringList(pageSizes); - QStringList activePageSizes(PrefsManager::instance().appPrefs.activePageSizes); - QStringList activeSizes; - for (int i = 0; i < activePageSizes.size(); ++i) + PageSizeInfoMap map; + + for (auto it = m_pageSizeList.begin(); it != m_pageSizeList.end(); ++it) { - if (pageSizes.contains(activePageSizes.at(i))) - activeSizes << activePageSizes.at(i); + if (it.value().category == category) + map.insert(it.value().sizeName, it.value()); } - return QStringList(activeSizes); + + return map; } -QStringList PageSize::activeSizeTRList() const +PageSizeInfoMap PageSize::sizesByDimensions(QSize sizePt) { - QStringList pageTRSizes = sizeTRList(); - QStringList pageSizes = sizeList(); - if (PrefsManager::instance().appPrefs.activePageSizes.count() == 0) - return QStringList(pageTRSizes); - QStringList activePageSizes(PrefsManager::instance().appPrefs.activePageSizes); - QStringList activeTRSizes; - for (int i = 0; i < activePageSizes.size(); ++i) + PageSizeInfoMap map; + + for (auto it = m_pageSizeList.begin(); it != m_pageSizeList.end(); ++it) { - int j = pageSizes.indexOf(activePageSizes.at(i)); - if (j != -1) - { - activeTRSizes << pageTRSizes.at(j); - } + if (it.value().width == sizePt.width() && it.value().height == sizePt.height()) + map.insert(it.value().sizeName, it.value()); } - return QStringList(activeTRSizes); + + return map; } -QStringList PageSize::untransPageSizeList(const QStringList &transList) +PageSizeInfoMap PageSize::activePageSizes() { - QStringList pageTRSizes = sizeTRList(); - QStringList pageSizes = sizeList(); - QStringList untranslatedList; - for (int i = 0; i < transList.size(); ++i) + 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) { - int j = pageTRSizes.indexOf(transList.at(i)); - if (j != -1) - { - untranslatedList << pageSizes.at(j); - } + if (activeList.contains(it.value().sizeName)) + map.insert(it.value().sizeName, it.value()); } - return QStringList(untranslatedList); + + return map; } - -void PageSize::generateSizeList() +void PageSize::addPageSize(const QString id, const QString name, double width, double height, int unitIndex, PageSizeInfo::Category category) { - /* - {"A5", "A6", "A7", "A8", "A9", "B0", "B1", "B2", "B3", - "B4", "B5", "B6", "B7", "B8", "B9", "B10", "C5E", "Comm10E", "DLE", QObject::tr("Executive"), - QObject::tr("Folio"), QObject::tr("Ledger"), QObject::tr("Legal"), QObject::tr("Letter"), QObject::tr("Tabloid") - }; - */ -// double width, height, tmp; - int format; - QString name; struct PageSizeInfo info; - /* A series */ -// width = floor(1000.0 / sqrt(sqrt(2.0)) + 0.5); -// height = floor(sqrt(sqrt(2.0))*1000.0 + 0.5); - //4A0 - info.width = mm2pts(1682.0); - info.height = mm2pts(2378.0); - info.pageUnitIndex = SC_MM; - info.trSizeName = QObject::tr("4A0"); - m_pageSizeList.insert("4A0", info); - //2A0 - info.width = mm2pts(1189.0); - info.height = mm2pts(1682.0); - info.pageUnitIndex = SC_MM; - info.trSizeName = QObject::tr("2A0"); - m_pageSizeList.insert("2A0", info); - //Continue with rest of A series - // do not use the formula below, as it is correct in theory, - // but due to rounding errors it gives incorrect results. -/* for (format = 0; format <= 10; format++) { + 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); - info.pageUnitIndex = SC_MM; - name = QString("A%1").arg(format); - info.trSizeName = name; - pageSizeList.insert(name, info); - tmp = height; - height = width; - width = floor(tmp / 2.0); - } */ - // all of the following data is taken from the Ghostscript manual - // "Appendix: Paper sizes known to Ghostscript" - QList<double> Awidths; - QList<double> Aheights; - Awidths << 841.0 << 594.0 << 420.0 << 297.0 << 210.0 << 148.0 << 105.0 << 74.0 << 52.0 << 37.0 << 26.0; - Aheights << 1189.0 << 841.0 << 594.0 << 420.0 << 297.0 << 210.0 << 148.0 << 105.0 << 74.0 << 52.0 << 37.0; - for (format = 0; format < Awidths.count(); format++) - { - info.width = mm2pts(Awidths[format]); - info.height = mm2pts(Aheights[format]); - info.pageUnitIndex = SC_MM; - name = QString("A%1").arg(format); - info.trSizeName = name; - m_pageSizeList.insert(name, info); + unit = "mm"; + break; + case SC_P: // picas + info.width = p2pts(width); + info.height = p2pts(height); + unit = "p"; + break; } - - /* B series */ - Awidths.clear(); - Aheights.clear(); - Awidths << 1000.0 << 707.0 << 500.0 << 353.0 << 250.0 << 176.0 << 125.0 << 88.0 << 62.0 << 44.0 << 31.0; - Aheights << 1414.0 << 1000.0 << 707.0 << 500.0 << 353.0 << 250.0 << 176.0 << 125.0 << 88.0 << 62.0 << 44.0; - for (format = 0; format < Awidths.count(); format++) + + 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) { - info.width = mm2pts(Awidths[format]); - info.height = mm2pts(Aheights[format]); - info.pageUnitIndex = SC_MM; - name = QString("B%1").arg(format); - info.trSizeName = name; - m_pageSizeList.insert(name, info); + 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("Candian"); + 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 Envelop"); + case PageSizeInfo::IsoEnvelop: + return QObject::tr("International Envelops"); + 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::USEnvelop: + return QObject::tr("US Envelops"); + default: + return "undefined"; + break; } - /* C series */ - Awidths.clear(); - Aheights.clear(); - Awidths << 917.0 << 648.0 << 458.0 << 324.0 << 229.0 << 162.0 << 114.0 << 81.0 << 57.0 << 40.0 << 28.0; - Aheights << 1297.0 << 917.0 << 648.0 << 458.0 << 324.0 << 229.0 << 162.0 << 114.0 << 81.0 << 57.0 << 40.0; - for (format = 0; format < Awidths.count(); format++) - { - info.width = mm2pts(Awidths[format]); - info.height = mm2pts(Aheights[format]); - info.pageUnitIndex = SC_MM; - name = QString("C%1").arg(format); - info.trSizeName = name; - m_pageSizeList.insert(name, info); - } -/* - width = 1000.0; - height = floor(sqrt(2.0)*1000.0 + 0.5); +} - for (format = 0; format <= 10; format++) { - info.width = mm2pts(width); - info.height = mm2pts(height); - info.pageUnitIndex = SC_MM; - name = QString("B%1").arg(format); - info.trSizeName = name; - pageSizeList.insert(name, info); - tmp = height; - height = width; - width = floor(tmp / 2.0); - } +void PageSize::generateSizeList() +{ + // Books + // https://papersizes.io/books/ + // https://paper-size.com/size/12mo-books-sizes.html + // https://en.wikipedia.org/wiki/Book_size + 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); - // C series - width = floor(1000.0 / sqrt(sqrt(sqrt(2.0)))+0.5); - height = floor(sqrt(sqrt(sqrt(8.0)))*1000.0 + 0.5); + // 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); - for (format = 0; format <= 10; format++) { - info.width = mm2pts(width); - info.height = mm2pts(height); - info.pageUnitIndex = SC_MM; - name = QString("C%1").arg(format); - info.trSizeName = name; - pageSizeList.insert(name, info); + // 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); - tmp = height; - height = width; - width = floor(tmp / 2.0); - } -*/ - /* PA series */ - double tmp; - double width = 840; - double height = 1120; - for (format = 0; format <= 10; format++) - { - info.width = mm2pts(width); - info.height = mm2pts(height); - info.pageUnitIndex = SC_MM; - name = QString("PA%1").arg(format); - info.trSizeName = name; - m_pageSizeList.insert(name, info); - tmp = height; - height = width; - width = floor(tmp / 2.0); - } - - //Imperial - //http://en.wikipedia.org/wiki/Paper_sizes - double impWidths[]={8.0,8.0,8.5,8.0,8.5,11.0,7.25,15.5,15.0,16.5,17.5,18.0,20.0,23.0,23.5,35.0,5.5,8.5,11.0,17.0,22.0,34.0}; - double impHeights[]={10.0,13.0,11.0,10.5,14.0,17.0,10.5,19.25,20.0,21.0,22.5,23.0,25.0,28.0,35.0,45.0,8.5,11.0,17.0,22.0,34.0,44.0}; - QString impNames[]={"Quarto","Foolscap","Letter","Govt. Letter","Legal","Ledger","Executive","Post","Crown","Large Post","Demy","Medium","Royal","Elephant","Double Demy","Quad Demy","STMT","A","B","C","D","E"}; - QString impTrNames[]={QObject::tr("Quarto"), QObject::tr("Foolscap"), QObject::tr("Letter"), - QObject::tr("Govt. Letter"), QObject::tr("Legal"), QObject::tr("Ledger"), QObject::tr("Executive"), - QObject::tr("Post"), QObject::tr("Crown"), QObject::tr("Large Post"), QObject::tr("Demy"), - QObject::tr("Medium"), QObject::tr("Royal"), QObject::tr("Elephant"), QObject::tr("Double Demy"), - QObject::tr("Quad Demy"), QObject::tr("STMT"), QObject::tr("A"), QObject::tr("B"), QObject::tr("C"), - QObject::tr("D"), QObject::tr("E")}; - - size_t const num_mappings_widths = (sizeof impWidths)/(sizeof *impWidths); - - for (uint i = 0; i < num_mappings_widths; ++i) - { - info.width = in2pts(impWidths[i]); - info.height = in2pts(impHeights[i]); - info.pageUnitIndex = SC_IN; - info.trSizeName = impTrNames[i]; - m_pageSizeList.insert(impNames[i], info); - } - //Comm10E - info.width = in2pts(4.125); - info.height = in2pts(9.5); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("Comm10E"); - m_pageSizeList.insert("Comm10E", info); - //DLE - info.width = mm2pts(110); - info.height = mm2pts(220); - info.pageUnitIndex = SC_MM; - info.trSizeName = QObject::tr("DLE"); - m_pageSizeList.insert("DLE", info); - // additional page sizes used by Viva Designer - //Compact Disc - info.width = mm2pts(119.9); - info.height = mm2pts(120.7); - info.pageUnitIndex = SC_MM; - info.trSizeName = QObject::tr("Compact Disc"); - m_pageSizeList.insert("Compact Disc", info); - //Letter Half - info.width = mm2pts(139.7); - info.height = mm2pts(215.9); - info.pageUnitIndex = SC_MM; - info.trSizeName = QObject::tr("Letter Half"); - m_pageSizeList.insert("Letter Half", info); - //US Letter - info.width = mm2pts(215.9); - info.height = mm2pts(279.4); - info.pageUnitIndex = SC_MM; - info.trSizeName = QObject::tr("US Letter"); - m_pageSizeList.insert("US Letter", info); - //US Legal - info.width = mm2pts(215.9); - info.height = mm2pts(355.6); - info.pageUnitIndex = SC_MM; - info.trSizeName = QObject::tr("US Legal"); - m_pageSizeList.insert("US Legal", info); - //11x17 - info.width = in2pts(11); - info.height = in2pts(17); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("11x17"); - m_pageSizeList.insert("11x17", info); + // 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); - // Arch A 9 × 12 - info.width = in2pts(9); - info.height = in2pts(12); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("9x12 (Arch A)"); - m_pageSizeList.insert("9x12 (Arch A)", info); - // Arch B 12 × 18 - info.width = in2pts(12); - info.height = in2pts(18); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("12x18 (Arch B)"); - m_pageSizeList.insert("12x18 (Arch B)", info); - // Arch C 18 × 24 - info.width = in2pts(18); - info.height = in2pts(24); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("18x24 (Arch C)"); - m_pageSizeList.insert("18x (Arch C)", info); - // Arch D 24 × 36 - info.width = in2pts(24); - info.height = in2pts(36); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("24x36 (Arch D)"); - m_pageSizeList.insert("24x36 (Arch D)", info); - // Arch E 36 × 48 - info.width = in2pts(36); - info.height = in2pts(48); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("36x48 (Arch E)"); - m_pageSizeList.insert("36x48 (Arch E)", info); - // Arch E1 30 × 42 - info.width = in2pts(30); - info.height = in2pts(42); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("30x42 (Arch E1)"); - m_pageSizeList.insert("30x42 (Arch E1)", info); - // Arch E2 26 × 38 - info.width = in2pts(26); - info.height = in2pts(38); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("26x38 (Arch E2)"); - m_pageSizeList.insert("26x38 (Arch E2)", info); - // Arch E3 27 × 39 - info.width = in2pts(27); - info.height = in2pts(39); - info.pageUnitIndex = SC_IN; - info.trSizeName = QObject::tr("27x39 (Arch E3)"); - m_pageSizeList.insert("27x39 (Arch E3)", info); + // 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); - //Executive - //Folio - //Ledger - //Legal - //Letter - //Tabloid + // 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 catIsoEnvelop = PageSizeInfo::IsoEnvelop; + prefix = "IsoEnv_"; + addPageSize(prefix + "DL/E65", "DL, E65", 110.0, 220.0, SC_MM, catIsoEnvelop); // from 1.6.2 + // addPageSize(prefix + "B4", "B4", 250.0, 353.0, SC_MM, catIsoEnvelop); + // addPageSize(prefix + "B5", "B5", 176.0, 250.0, SC_MM, catIsoEnvelop); + // addPageSize(prefix + "B6", "B6", 125.0, 176.0, SC_MM, catIsoEnvelop); + // addPageSize(prefix + "C3", "C3", 324.0, 458.0, SC_MM, catIsoEnvelop); + // addPageSize(prefix + "C4", "C4", 229.0, 324.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "C4M", "C4M", 229.0, 318.0, SC_MM, catIsoEnvelop); + // addPageSize(prefix + "C5", "C5", 162.0, 229.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "C6/C5", "C6/C5", 114.0, 229.0, SC_MM, catIsoEnvelop); + // addPageSize(prefix + "C6", "C6", 114.0, 162.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "C64M", "C64M", 114.0, 318.0, SC_MM, catIsoEnvelop); + // addPageSize(prefix + "C7", "C7", 81.0, 114.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "C7/C6", "C7/C6", 81.0, 162.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "B6/C4", "B6/C4", 125.0, 324.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "E4", "E4", 220.0, 312.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "E5", "E5", 115.0, 220.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "E56", "E56", 115.0, 115.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "E6", "E6", 110.0, 155.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "EC45", "EC45", 220.0, 229.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "EC5", "EC5", 155.0, 229.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "R7", "R7", 120.0, 135.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "S4", "S4", 250.0, 330.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "S5", "S5", 185.0, 255.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "S65", "S65", 110.0, 225.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "X5", "X5", 105.0, 216.0, SC_MM, catIsoEnvelop); + addPageSize(prefix + "EX5", "EX5", 115.0, 216.0, SC_MM, catIsoEnvelop); + + // 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 irgendein langes wort"), 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 catUSEnvelop = PageSizeInfo::USEnvelop; + prefix = "USEnv_"; + addPageSize(prefix + "A01", "A-1", 3.625, 5.125, SC_IN, catUSEnvelop); + addPageSize(prefix + "A02", "A-2 (Lady Grey)", 4.375, 5.75, SC_IN, catUSEnvelop); + addPageSize(prefix + "A04", "A-4", 4.25, 6.25, SC_IN, catUSEnvelop); + addPageSize(prefix + "A06", "A-6 (Thompson Standard)", 4.75, 6.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "A07", "A-7 (Besselheim)", 5.25, 7.25, SC_IN, catUSEnvelop); + addPageSize(prefix + "A08", "A-8 (Carrs)", 5.5, 8.125, SC_IN, catUSEnvelop); + addPageSize(prefix + "A09", "A-9 (Diplomat)", 5.75, 8.75, SC_IN, catUSEnvelop); + addPageSize(prefix + "A10", "A-10 (Willow)", 6.0, 9.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Baronial 04", "Baronial 4", 3.625, 5.125, SC_IN, catUSEnvelop); + addPageSize(prefix + "Baronial 05 1/2", "Baronial 5 1/2", 4.375, 5.75, SC_IN, catUSEnvelop); + addPageSize(prefix + "Baronial 06", "Baronial 6", 4.75, 6.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Baronial Lee", "Lee", 5.25, 7.25, SC_IN, catUSEnvelop); + addPageSize(prefix + "Booklet 03", "Booklet 3", 4.75, 6.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Booklet 04 1/2", "Booklet 4 1/2", 5.5, 7.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Booklet 06", "Booklet 6", 5.75, 8.875, SC_IN, catUSEnvelop); + addPageSize(prefix + "Booklet 06 1/2", "Booklet 6 1/2", 6.0, 9.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Booklet 06 7/8", "Booklet 6 7/8", 6.0, 9.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Booklet 06 3/4", "Booklet 6 3/4", 6.5, 9.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Booklet 07 1/2", "Booklet 7 1/2", 7.5, 10.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Booklet 09", "Booklet 9", 8.75, 11.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Booklet 09 1/2", "Booklet 9 1/2", 9.0, 12.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Booklet 10", "Booklet 10", 9.5, 12.625, SC_IN, catUSEnvelop); + addPageSize(prefix + "Booklet 13", "Booklet 13", 10.0, 13.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Catalog 01", "Catalog 1", 6.0, 9.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Catalog 01 3/4", "Catalog 1 3/4", 6.5, 9.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Catalog 03", "Catalog 3", 7.0, 10.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Catalog 06", "Catalog 6", 7.5, 10.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Catalog 08", "Catalog 8", 8.25, 11.25, SC_IN, catUSEnvelop); + addPageSize(prefix + "Catalog 09 3/4", "Catalog 9 3/4", 8.75, 11.25, SC_IN, catUSEnvelop); + addPageSize(prefix + "Catalog 10 1/2", "Catalog 10 1/2", 9.0, 12.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Catalog 12 1/5", "Catalog 12 1/5", 9.5, 12.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Catalog 13 1/2", "Catalog 13 1/2", 10.0, 13.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Catalog 14 1/2", "Catalog 14 1/2", 11.5, 14.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Catalog 15", "Catalog 15", 10.0, 15.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Catalog 15 1/2", "Catalog 15 1/2", 12.0, 15.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Commerical 05", "Commerical 5", 3.125, 5.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Commerical 06 1/4", "Commerical 6 1/4", 3.5, 6.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Commerical 06 3/4", "Commerical 6 3/4", 3.625, 6.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Commerical 07", "Commerical 7", 3.75, 6.75, SC_IN, catUSEnvelop); + addPageSize(prefix + "Commerical 07 1/2", "Commerical 7 1/2", 3.9375, 7.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Commerical 08 5/8", "Commerical 8 5/8", 3.625, 8.625, SC_IN, catUSEnvelop); + addPageSize(prefix + "Commerical 09", "Commerical 9", 3.875, 8.875, SC_IN, catUSEnvelop); + addPageSize(prefix + "Commerical 10", "Commerical 10", 4.125, 9.5, SC_IN, catUSEnvelop); // from 1.6.2 + addPageSize(prefix + "Commerical 11", "Commerical 11", 4.5, 10.375, SC_IN, catUSEnvelop); + addPageSize(prefix + "Commerical 12", "Commerical 12", 4.75, 11, SC_IN, catUSEnvelop); + addPageSize(prefix + "Commerical 14", "Commerical 14", 5.0, 11.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Square 06", "Square 6", 6.0, 6.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Square 06 1/2", "Square 6 1/2", 6.5, 6.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Square 07", "Square 7", 7.0, 7.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Square 07 1/2", "Square 7 1/2", 7.5, 7.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Square 08", "Square 8", 8.0, 8.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Square 08 1/2", "Square 8 1/2", 8.5, 8.5, SC_IN, catUSEnvelop); + addPageSize(prefix + "Square 09", "Square 9", 9.0, 9.0, SC_IN, catUSEnvelop); + addPageSize(prefix + "Square 09 1/2", "Square 9 1/2", 9.5, 9.5, SC_IN, catUSEnvelop); + + // 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 @@ -432,7 +750,7 @@ 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() << std::endl; + std::cout << it.value().trSizeName.toStdString() << categoryToString(it.value().category).toStdString() << std::endl; } } Index: scribus/pagesize.h =================================================================== --- scribus/pagesize.h (Revision 26264) +++ scribus/pagesize.h (Arbeitskopie) @@ -24,22 +24,59 @@ #include <QMap> #include <QString> +#include <QSize> #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, + IsoEnvelop = 13, + + USStandard = 20, + USPress = 21, + USEnvelop = 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<QString, PageSizeInfo>; +using PageSizeCategoriesMap = QMap<PageSizeInfo::Category, QString>; class SCRIBUS_API PageSize { public: + PageSize(const QString&); PageSize(const double, const double); PageSize& operator=(const PageSize& other); @@ -46,18 +83,20 @@ void init(const QString&); QString name() const { return m_pageSizeName; } QString nameTR() const { return m_trPageSizeName; } + PageSizeInfo::Category category() { return m_category; }; 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); } - QStringList sizeList() const; - QStringList sizeTRList() const; - QStringList activeSizeList() const; - QStringList activeSizeTRList() const; - void generateSizeList(); + static QStringList defaultSizesList(); + PageSizeCategoriesMap categories(); + PageSizeInfoMap sizesByCategory(PageSizeInfo::Category category); + PageSizeInfoMap sizesByDimensions(QSize sizePt); + PageSizeInfoMap activePageSizes(); + PageSizeInfoMap pageSizes() const { return m_pageSizeList; }; void printSizeList() const; - QStringList untransPageSizeList(const QStringList &transList); + QString categoryToString(PageSizeInfo::Category category) const; private: PageSizeInfoMap m_pageSizeList; @@ -66,6 +105,12 @@ 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); + }; #endif Index: scribus/prefsmanager.cpp =================================================================== --- scribus/prefsmanager.cpp (Revision 26264) +++ scribus/prefsmanager.cpp (Arbeitskopie) @@ -521,7 +521,7 @@ appPrefs.imageCachePrefs.maxCacheEntries = 1000; appPrefs.imageCachePrefs.compressionLevel = 1; appPrefs.activePageSizes.clear(); - appPrefs.activePageSizes << "A3" << "A4" << "A5" << "A6" << "Letter"; + appPrefs.activePageSizes = defaultPageSize.defaultSizesList(); //Attribute setup appPrefs.itemAttrPrefs.defaultItemAttributes.clear(); @@ -1903,7 +1903,7 @@ elem.appendChild(icElem); // active page sizes QDomElement apsElem = docu.createElement("ActivePageSizes"); - apsElem.setAttribute("Names", appPrefs.activePageSizes.join(",")); + apsElem.setAttribute("Names", appPrefs.activePageSizes.join(";")); elem.appendChild(apsElem); // experimental features @@ -2008,7 +2008,8 @@ if (appPrefs.docSetupPrefs.language.isEmpty()) appPrefs.docSetupPrefs.language = "en_GB"; appPrefs.docSetupPrefs.docUnitIndex = dc.attribute("UnitIndex", "0").toInt(); - appPrefs.docSetupPrefs.pageSize = dc.attribute("PageSize", "A4"); + PageSize ps( dc.attribute("PageSize", PageSize::defaultSizesList().at(1)) ); + appPrefs.docSetupPrefs.pageSize = (ps.name() == CommonStrings::customPageSize ) ? PageSize::defaultSizesList().at(1) : ps.name(); 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); @@ -2721,7 +2722,20 @@ // active page sizes if (dc.tagName() == "ActivePageSizes") { - appPrefs.activePageSizes = QString(dc.attribute("Names", "")).split(","); + QStringList checkedPageSizes; + QString separator = dc.attribute("Names", "").contains(";") ? ";" : ","; + appPrefs.activePageSizes = QString(dc.attribute("Names", "")).split(separator); + + // check if page sizes existing + foreach (auto item, appPrefs.activePageSizes) + { + PageSize ps(item); + if (ps.name() != CommonStrings::customPageSize) + checkedPageSizes.append(ps.name()); + } + + appPrefs.activePageSizes = (checkedPageSizes.count() == 0) ? PageSize::defaultSizesList() : checkedPageSizes; + } // experimental features if (dc.tagName() == "ExperimentalFeatures") Index: scribus/scribus.cpp =================================================================== --- scribus/scribus.cpp (Revision 26264) +++ scribus/scribus.cpp (Arbeitskopie) @@ -183,7 +183,6 @@ #include "ui/javadocs.h" #include "ui/layers.h" #include "ui/loremipsum.h" -#include "ui/marginwidget.h" #include "ui/mark2item.h" #include "ui/mark2mark.h" #include "ui/markanchor.h" @@ -2016,12 +2015,12 @@ if (dia->tabSelected() == NewDocDialog::NewDocumentTab) { int facingPages = dia->choosenLayout(); - int firstPage = dia->firstPage->currentIndex(); + int firstPage = dia->pageLayouts->firstPage();//firstPage->currentIndex(); docSet = dia->startDocSetup->isChecked(); - double topMargin = dia->marginGroup->top(); - double bottomMargin = dia->marginGroup->bottom(); - double leftMargin = dia->marginGroup->left(); - double rightMargin = dia->marginGroup->right(); + 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 columnDistance = dia->distance(); double pageWidth = dia->pageWidth(); double pageHeight = dia->pageHeight(); @@ -2029,15 +2028,8 @@ bool autoframes = dia->autoTextFrame->isChecked(); int orientation = dia->orientation(); int pageCount = dia->pageCountSpinBox->value(); - QString pagesize; - if (dia->pageSizeComboBox->currentText() == CommonStrings::trCustomPageSize) - pagesize = CommonStrings::customPageSize; - else - { - PageSize ps2(dia->pageSizeComboBox->currentText()); - pagesize = ps2.name(); - } - doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, numberCols, autoframes, facingPages, dia->unitOfMeasureComboBox->currentIndex(), firstPage, orientation, 1, pagesize, true, pageCount, true, dia->marginGroup->getMarginPreset()); + QString pagesize = dia->pageSizeName(); + doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, numberCols, autoframes, facingPages, dia->unitOfMeasureComboBox->currentIndex(), firstPage, orientation, 1, pagesize, true, pageCount, true, dia->marginGroup->marginPreset()); doc->setPageSetFirstPage(facingPages, firstPage); doc->bleeds()->set(dia->bleedTop(), dia->bleedLeft(), dia->bleedBottom(), dia->bleedRight()); HaveNewDoc(); @@ -2099,12 +2091,12 @@ return false; int facingPages = dia->choosenLayout(); - int firstPage = dia->firstPage->currentIndex(); + int firstPage = dia->pageLayouts->firstPage(); bool docSet = dia->startDocSetup->isChecked(); - double topMargin = dia->marginGroup->top(); - double bottomMargin = dia->marginGroup->bottom(); - double leftMargin = dia->marginGroup->left(); - double rightMargin = dia->marginGroup->right(); + 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 columnDistance = dia->distance(); double pageWidth = dia->pageWidth(); double pageHeight = dia->pageHeight(); @@ -2112,16 +2104,10 @@ bool autoframes = dia->autoTextFrame->isChecked(); int orientation = dia->orientation(); int pageCount = dia->pageCountSpinBox->value(); - QString pagesize; - if (dia->pageSizeComboBox->currentText() == CommonStrings::trCustomPageSize) - pagesize = CommonStrings::customPageSize; - else + QString pagesize = dia->pageSizeName(); + + 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())) { - PageSize ps2(dia->pageSizeComboBox->currentText()); - pagesize = ps2.name(); - } - if (doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, numberCols, autoframes, facingPages, dia->unitOfMeasureComboBox->currentIndex(), firstPage, orientation, 1, pagesize, true, pageCount, true, dia->marginGroup->getMarginPreset())) - { doc->setPageSetFirstPage(facingPages, firstPage); doc->bleeds()->set(dia->bleedTop(), dia->bleedLeft(), dia->bleedBottom(), dia->bleedRight()); m_mainWindowStatusLabel->setText( tr("Ready")); Index: scribus/ui/delegates/sclistitemdelegate.cpp =================================================================== --- scribus/ui/delegates/sclistitemdelegate.cpp (Revision 26264) +++ scribus/ui/delegates/sclistitemdelegate.cpp (Arbeitskopie) @@ -4,6 +4,8 @@ #include <QRect> #include <QApplication> #include <QFlags> +#include <QFontMetrics> +#include <QTextLayout> ScListItemDelegate::ScListItemDelegate(QListView::ViewMode mode, QSize iconSize, TextPosition textPosition, Style style, QObject *parent) : QItemDelegate (parent) @@ -33,6 +35,19 @@ cHighlight.setAlphaF(0.2f); QBrush fillSelected(cHighlight); + QFont subFont = QFont(); +#ifdef Q_OS_MACOS + subFont.setPointSize(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont).pointSize()); +#else + subFont.setPointSize(qRound(QFont().pointSize() * .75)); +#endif + + QFontMetrics fm = painter->fontMetrics(); + QFontMetrics sfm(subFont); + + QTextOption tOptions; + QTextOption sOptions; + if(m_style == Style::Simple) { radius = 0; @@ -41,10 +56,11 @@ lineMarkedPen = Qt::NoPen; } - QTextOption tOptions; + QRect rSaveArea = option.rect.adjusted(padding, padding, -padding, -padding); + QRect rIcon = rSaveArea; + QRect rText = rSaveArea; + QRect rSubText = rSaveArea; - QRect rIcon = option.rect; - QRect rText = option.rect; QRectF rItem = option.rect; rItem = rItem.adjusted(margin, margin, -margin, -margin); @@ -68,6 +84,7 @@ // Item Data QIcon ic = qvariant_cast<QIcon>(index.data(Qt::DecorationRole)); QString title = index.data(Qt::DisplayRole).toString(); + QString subTitle = index.data(Qt::UserRole).toString(); switch (m_textPosition) { @@ -74,22 +91,35 @@ default: case TextPosition::Bottom: { - int hSpace = (option.rect.width() - m_iconSize.width()) / 2; - int vSpace = padding; - QPoint p = option.rect.topLeft(); - rIcon = QRect(p.x() + hSpace, p.y() + vSpace, m_iconSize.width(), m_iconSize.height()); + tOptions.setFlags(QFlag(Qt::AlignBottom|Qt::AlignHCenter|Qt::TextWordWrap)); + sOptions.setFlags(QFlag(Qt::AlignBottom|Qt::AlignHCenter|Qt::TextWordWrap)); - rText = option.rect.adjusted(padding, padding + m_iconSize.height(), -padding, -padding); - tOptions.setFlags(QFlag(Qt::AlignBottom|Qt::AlignHCenter|Qt::TextWordWrap)); + rIcon = QRect(0, 0, m_iconSize.width(), m_iconSize.height()); + rIcon.moveCenter(rSaveArea.center()); + rIcon.moveTop(rSaveArea.top()); + + rSubText = sfm.boundingRect(rSaveArea, sOptions.flags(), subTitle); + rSubText.moveBottom(rSaveArea.bottom()); + + rText = rSaveArea.adjusted(0, rIcon.height(), 0, -rSubText.height() -fm.leading() -fm.descent()); + } break; case TextPosition::Right: { - QPoint p = option.rect.topLeft(); - rIcon = QRect(p.x() + padding, p.y() + padding, m_iconSize.width(), m_iconSize.height()); + tOptions.setFlags(QFlag(Qt::AlignCenter|Qt::AlignLeft|Qt::TextWordWrap)); + sOptions.setFlags(QFlag(Qt::AlignBottom|Qt::AlignLeft|Qt::TextWordWrap)); - rText = option.rect.adjusted(padding * 2 + m_iconSize.width(), padding, -padding, -padding); - tOptions.setFlags(QFlag(Qt::AlignVCenter|Qt::AlignLeft|Qt::TextWordWrap)); + rIcon = QRect(0, 0, m_iconSize.width(), m_iconSize.height()); + rIcon.moveCenter(rSaveArea.center()); + rIcon.moveLeft(rSaveArea.left()); + + rSubText = rSaveArea.adjusted(padding + m_iconSize.width(), 0, 0, 0); + rSubText = sfm.boundingRect(rSaveArea, sOptions.flags(), subTitle); + rSubText.moveBottom(rSaveArea.bottom()); + + rText = rSaveArea.adjusted(padding + m_iconSize.width(), 0, 0, -rSubText.height() -fm.leading() -fm.descent()); + } break; } @@ -103,9 +133,33 @@ // Label if (!title.isEmpty()) { + QRect rectNorm = rText.normalized(); + painter->setPen(fontPen); + painter->setBrush(Qt::NoBrush); painter->setFont(QFont()); - painter->drawText(rText, tOptions.flags(), title, &rText); + + int textWidth = rText.width(); + int lineCount = 0; + QTextLayout textLayout(title, painter->font()); + textLayout.beginLayout(); + + while (++lineCount < rText.height() / fm.lineSpacing()) { + QTextLine line = textLayout.createLine(); + if (!line.isValid()) + break; + + line.setLineWidth(rText.width()); + textWidth += line.naturalTextWidth(); + } + textLayout.endLayout(); + title = fm.elidedText(title, Qt::ElideRight, textWidth); + + painter->drawText(rText, tOptions.flags(), title, &rectNorm); + + painter->setFont(subFont); + painter->drawText(rSubText, sOptions.flags(), subTitle); + } painter->restore(); Index: scribus/ui/inspage.cpp =================================================================== --- scribus/ui/inspage.cpp (Revision 26264) +++ scribus/ui/inspage.cpp (Arbeitskopie) @@ -34,11 +34,11 @@ setWindowIcon(IconManager::instance().loadIcon("AppIcon.png")); dialogLayout = new QVBoxLayout(this); - dialogLayout->setSpacing(6); - dialogLayout->setContentsMargins(9, 9, 9, 9); + dialogLayout->setSpacing(4); + dialogLayout->setContentsMargins(8, 8, 8, 8); whereLayout = new QGridLayout(); - whereLayout->setSpacing(6); + whereLayout->setSpacing(4); whereLayout->setContentsMargins(0, 0, 0, 0); insCountData = new QSpinBox(this); @@ -75,8 +75,8 @@ masterPageGroup->setTitle( tr( "Master Pages" ) ); masterPageLayout = new QGridLayout( masterPageGroup ); masterPageLayout->setAlignment(Qt::AlignTop); - masterPageLayout->setSpacing(6); - masterPageLayout->setContentsMargins(9, 9, 9, 9); + masterPageLayout->setSpacing(4); + masterPageLayout->setContentsMargins(8, 8, 8, 8); if (m_doc->pagePositioning() == 0) { QComboBox* pageData = new QComboBox(masterPageGroup); @@ -224,6 +224,19 @@ masterPageCombos.append(pageData); } } + + QScopedPointer<PageSize> ps(new PageSize(m_doc->pageSize())); + + // try to find coresponding 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(); + dialogLayout->addWidget(masterPageGroup); overrideMPSizingCheckBox = new QCheckBox( tr("Override Master Page Sizing")); dialogLayout->addWidget(overrideMPSizingCheckBox); @@ -230,31 +243,16 @@ dsGroupBox7 = new QGroupBox( this ); dsGroupBox7->setTitle( tr( "Page Size" ) ); dsGroupBox7Layout = new QGridLayout(dsGroupBox7); - dsGroupBox7Layout->setSpacing(6); - dsGroupBox7Layout->setContentsMargins(9, 9, 9, 9); + dsGroupBox7Layout->setSpacing(4); + dsGroupBox7Layout->setContentsMargins(8, 8, 8, 8); textLabel1 = new QLabel( tr( "&Size:" ), dsGroupBox7); - dsGroupBox7Layout->addWidget(textLabel1, 0, 0); - - QScopedPointer<PageSize> ps(new PageSize(m_doc->pageSize())); - prefsPageSizeName = ps->name(); - sizeQComboBox = new QComboBox(dsGroupBox7); - QStringList insertList(ps->activeSizeTRList()); - if (insertList.indexOf(prefsPageSizeName) == -1) - insertList << prefsPageSizeName; - insertList.sort(); - insertList << CommonStrings::trCustomPageSize; - sizeQComboBox->addItems(insertList); - int sizeIndex = insertList.indexOf(ps->nameTR()); - if (sizeIndex != -1) - sizeQComboBox->setCurrentIndex(sizeIndex); - else - sizeQComboBox->setCurrentIndex(sizeQComboBox->count() - 1); - - textLabel1->setBuddy(sizeQComboBox); - dsGroupBox7Layout->addWidget(sizeQComboBox, 0, 1, 1, 3); - + dsGroupBox7Layout->addWidget(textLabel1, 0, 0, Qt::AlignTop | Qt::AlignRight); + pageSizeSelector = new PageSizeSelector(dsGroupBox7); + pageSizeSelector->setPageSize(m_doc->pageSize()); + textLabel1->setBuddy(pageSizeSelector); + dsGroupBox7Layout->addWidget(pageSizeSelector, 0, 1); textLabel2 = new QLabel( tr( "Orie&ntation:" ), dsGroupBox7); - dsGroupBox7Layout->addWidget(textLabel2, 1, 0); + dsGroupBox7Layout->addWidget(textLabel2, 1, 0, Qt::AlignRight); orientationQComboBox = new QComboBox(dsGroupBox7); orientationQComboBox->addItem( tr( "Portrait" ) ); @@ -261,13 +259,13 @@ orientationQComboBox->addItem( tr( "Landscape" ) ); orientationQComboBox->setCurrentIndex(m_doc->pageOrientation() ); textLabel2->setBuddy(orientationQComboBox); - dsGroupBox7Layout->addWidget(orientationQComboBox, 1, 1, 1, 3); + dsGroupBox7Layout->addWidget(orientationQComboBox, 1, 1); widthSpinBox = new ScrSpinBox(1, 10000, dsGroupBox7, m_doc->unitIndex()); widthQLabel = new QLabel( tr( "&Width:" ), dsGroupBox7); widthSpinBox->setValue(m_doc->pageWidth() * m_doc->unitRatio()); widthQLabel->setBuddy(widthSpinBox); - dsGroupBox7Layout->addWidget(widthQLabel, 2, 0); + dsGroupBox7Layout->addWidget(widthQLabel, 2, 0, Qt::AlignRight); dsGroupBox7Layout->addWidget(widthSpinBox, 2, 1); heightSpinBox = new ScrSpinBox(1, 10000, dsGroupBox7, m_doc->unitIndex()); @@ -274,17 +272,17 @@ heightSpinBox->setValue(m_doc->pageHeight() * m_doc->unitRatio()); heightQLabel = new QLabel( tr( "&Height:" ), dsGroupBox7); heightQLabel->setBuddy(heightSpinBox); - dsGroupBox7Layout->addWidget(heightQLabel, 3, 0); + dsGroupBox7Layout->addWidget(heightQLabel, 3, 0, Qt::AlignRight); dsGroupBox7Layout->addWidget(heightSpinBox, 3, 1); moveObjectsCheckBox = new QCheckBox( dsGroupBox7); moveObjectsCheckBox->setText( tr( "Move Objects with their Page" ) ); moveObjectsCheckBox->setChecked(true); - dsGroupBox7Layout->addWidget(moveObjectsCheckBox, 4, 0, 1, 4); + dsGroupBox7Layout->addWidget(moveObjectsCheckBox, 4, 0, 1, 2); dialogLayout->addWidget(dsGroupBox7); dsGroupBox7->setEnabled(false); - bool b = (sizeQComboBox->currentText() == CommonStrings::trCustomPageSize); + bool b = (pageSizeSelector->pageSizeTR() == CommonStrings::trCustomPageSize); heightSpinBox->setEnabled(b); widthSpinBox->setEnabled(b); @@ -298,7 +296,7 @@ connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); connect(orientationQComboBox, SIGNAL(activated(int)), this, SLOT(setOrientation(int))); - connect(sizeQComboBox, SIGNAL(textActivated(QString)), this, SLOT(setSize(QString))); + connect(pageSizeSelector, SIGNAL(pageSizeChanged(QString)), this, SLOT(setSize(QString))); connect(overrideMPSizingCheckBox, SIGNAL(stateChanged(int)), this, SLOT(enableSizingControls(int))); } @@ -325,10 +323,10 @@ void InsPage::setOrientation(int ori) { double br; - setSize(sizeQComboBox->currentText()); + setSize(pageSizeSelector->pageSizeTR()); if (ori == 0) { - if (sizeQComboBox->currentText() == CommonStrings::trCustomPageSize) + if (pageSizeSelector->pageSizeTR() == CommonStrings::trCustomPageSize) { br = widthSpinBox->value(); widthSpinBox->setValue(heightSpinBox->value()); Index: scribus/ui/inspage.h =================================================================== --- scribus/ui/inspage.h (Revision 26264) +++ scribus/ui/inspage.h (Arbeitskopie) @@ -8,6 +8,7 @@ #define INSPAGE_H #include "scribusapi.h" +#include "widgets/pagesizeselector.h" #include <QDialog> #include <QDialogButtonBox> #include <QList> @@ -71,7 +72,8 @@ QLabel* heightQLabel { nullptr }; QLabel* textLabel1 { nullptr }; QLabel* textLabel2 { nullptr }; - QComboBox* sizeQComboBox { nullptr }; + PageSizeSelector* pageSizeSelector { nullptr }; +// QComboBox* sizeQComboBox { nullptr }; QComboBox* orientationQComboBox { nullptr }; QCheckBox* moveObjectsCheckBox { nullptr }; QCheckBox* overrideMPSizingCheckBox { nullptr }; Index: scribus/ui/marginwidget.cpp =================================================================== --- scribus/ui/marginwidget.cpp (Revision 26264) +++ scribus/ui/marginwidget.cpp (nicht existent) @@ -1,623 +0,0 @@ -/* -For general Scribus (>=1.3.2) copyright and licensing information please refer -to the COPYING file provided with the program. Following this notice may exist -a copyright and/or license notice that predates the release of Scribus 1.3.2 -for which a new license (GPL+exception) is in place. -*/ -#include "marginwidget.h" - -#include <QHBoxLayout> -#include <QGridLayout> -#include <QLabel> -#include <QToolTip> -#include <QCheckBox> -#include <QLabel> -#include <QPushButton> - -#include "scrspinbox.h" -#include "units.h" -#include "ui/useprintermarginsdialog.h" - - -MarginWidget::MarginWidget( QWidget* parent, const QString& /*title*/, const MarginStruct* margs, int unitIndex, bool showChangeAll, bool showBleeds) : QTabWidget(parent), - m_useBleeds(showBleeds) -{ - marginData = *margs; - m_savedMargins = *margs; - m_savedPresetItem = PresetLayout::none; //we don't recheck if we are using a layout but always start at none - marginPage = new QWidget(this); - - presetCombo = new PresetLayout(marginPage); - presetLabel = new QLabel( tr("Preset Layouts:"), marginPage); - presetLabel->setBuddy(presetCombo); - m_unitIndex = unitIndex; - m_unitRatio = unitGetRatioFromIndex(unitIndex); - leftR = new ScrSpinBox( 0, 1000, marginPage, unitIndex ); - rightR = new ScrSpinBox( 0, 1000, marginPage, unitIndex ); - topR = new ScrSpinBox( 0, 1000, marginPage, unitIndex ); - bottomR = new ScrSpinBox( 0, 1000, marginPage, unitIndex ); - updateMarginSpinValues(); - - bText = new QLabel( tr( "&Bottom:" ), marginPage); - bText->setBuddy(bottomR); - tText = new QLabel( tr( "&Top:" ), marginPage); - tText->setBuddy(topR); - rText = new QLabel( tr( "&Right:" ), marginPage); - rText->setBuddy(rightR); - lText = new QLabel( tr( "&Left:" ), marginPage); - lText->setBuddy(leftR); - - linkMargins = new LinkButton( marginPage ); - linkMargins->setCheckable( true ); - linkMargins->setChecked(false); - linkMargins->setAutoRaise( true ); - linkMargins->setMinimumSize( QSize( 15, 0 ) ); - linkMargins->setMaximumSize( QSize( 15, 32767 ) ); - - // layout - GroupLayout = new QGridLayout( marginPage ); - GroupLayout->setSpacing(6); - GroupLayout->setContentsMargins(9, 9, 9, 9); - GroupLayout->addWidget(presetLabel, 0, 0); - GroupLayout->addWidget(presetCombo, 0, 1); - GroupLayout->addWidget( leftR, 1, 1 ); - GroupLayout->addWidget( rightR, 2, 1 ); - GroupLayout->addWidget( topR, 3, 1 ); - GroupLayout->addWidget( bottomR, 4, 1 ); - GroupLayout->addWidget( lText, 1, 0 ); - GroupLayout->addWidget( rText, 2, 0 ); - GroupLayout->addWidget( tText, 3, 0 ); - GroupLayout->addWidget( bText, 4, 0 ); - GroupLayout->addWidget( linkMargins, 1, 2, 4, 1 ); - if (showChangeAll) - { - marginsForPagesLayout = new QHBoxLayout; - marginsForPagesLayout->setContentsMargins(9, 9, 9, 9); - marginsForPagesLayout->setSpacing(6); - marginsForPages = new QLabel( tr( "Apply settings to:" ), marginPage ); - marginsForPagesLayout->addWidget(marginsForPages); - marginsForAllPages = new QCheckBox( marginPage ); - marginsForAllPages->setText( tr( "All Document Pages" ) ); - marginsForAllPages->setChecked( false ); - marginsForPagesLayout->addWidget(marginsForAllPages); - marginsForAllMasterPages = new QCheckBox( marginPage ); - marginsForAllMasterPages->setText( tr( "All Master Pages" ) ); - marginsForAllMasterPages->setChecked( false ); - marginsForPagesLayout->addWidget(marginsForAllMasterPages); - GroupLayout->addLayout( marginsForPagesLayout, 6, 0, 1, 2 ); - marginsForAllPages->setToolTip( "<qt>" + tr( "Apply the margin changes to all existing pages in the document" ) + "</qt>" ); - marginsForAllMasterPages->setToolTip( "<qt>" + tr( "Apply the margin changes to all existing master pages in the document" ) + "</qt>" ); - } - - usePrinterMarginsButton = nullptr; - usePrinterMarginsButton = new QPushButton( tr("Printer Margins..."),marginPage ); - GroupLayout->addWidget( usePrinterMarginsButton, 5, 1 ); - usePrinterMarginsButton->setToolTip( "<qt>" + tr( "Import the margins for the selected page size from the available printers" ) + "</qt>"); - connect(usePrinterMarginsButton, SIGNAL(clicked()), this, SLOT(setMarginsToPrinterMargins())); - - addTab(marginPage, tr("Margin Guides")); - - if (m_useBleeds) - { - bleedPage = new QWidget(this); - BleedGroupLayout = new QGridLayout( bleedPage ); - BleedGroupLayout->setSpacing(6); - BleedGroupLayout->setContentsMargins(9, 9, 9, 9); - BleedGroupLayout->setAlignment( Qt::AlignTop ); - BleedTxt3 = new QLabel( bleedPage ); - BleedGroupLayout->addWidget( BleedTxt3, 0, 0 ); - BleedLeft = new ScrSpinBox( 0, 3000*m_unitRatio, bleedPage, unitIndex ); - BleedGroupLayout->addWidget( BleedLeft, 0, 1 ); - BleedTxt4 = new QLabel( bleedPage ); - BleedGroupLayout->addWidget( BleedTxt4, 1, 0 ); - BleedRight = new ScrSpinBox( 0, 3000*m_unitRatio, bleedPage, unitIndex ); - BleedGroupLayout->addWidget( BleedRight, 1, 1 ); - BleedTxt1 = new QLabel( bleedPage ); - BleedTxt1->setText( tr( "Top:" ) ); - BleedGroupLayout->addWidget( BleedTxt1, 2, 0 ); - BleedTop = new ScrSpinBox( 0, 3000*m_unitRatio, bleedPage, unitIndex ); - BleedGroupLayout->addWidget( BleedTop, 2, 1 ); - BleedTxt2 = new QLabel( bleedPage ); - BleedTxt2->setText( tr( "Bottom:" ) ); - BleedGroupLayout->addWidget( BleedTxt2, 3, 0 ); - BleedBottom = new ScrSpinBox( 0, 3000*m_unitRatio, bleedPage, unitIndex ); - BleedGroupLayout->addWidget( BleedBottom, 3, 1 ); - linkBleeds = new LinkButton( bleedPage ); -/** Fix Me to move this to the prefsmanager.cpp someday */ - linkBleeds->setCheckable( true ); - linkBleeds->setChecked(true); - linkBleeds->setAutoRaise( true ); - linkBleeds->setMinimumSize( QSize( 15, 0 ) ); - linkBleeds->setMaximumSize( QSize( 15, 32767 ) ); - BleedGroupLayout->addWidget( linkBleeds, 0, 2, 4, 1 ); - BleedTop->setToolTip( "<qt>" + tr( "Distance for bleed from the top of the physical page" ) + "</qt>" ); - BleedBottom->setToolTip( "<qt>" + tr( "Distance for bleed from the bottom of the physical page" ) + "</qt>" ); - BleedLeft->setToolTip( "<qt>" + tr( "Distance for bleed from the left of the physical page" ) + "</qt>" ); - BleedRight->setToolTip( "<qt>" + tr( "Distance for bleed from the right of the physical page" ) + "</qt>"); - linkBleeds->setToolTip( "<qt>" + tr( "Ensure all bleeds have the same value" ) + "</qt>"); - connect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(linkBleeds, SIGNAL(clicked()), this, SLOT(slotLinkBleeds())); - addTab(bleedPage, tr("Bleeds")); - } - - // hints - topR->setToolTip( "<qt>" + tr( "Distance between the top margin guide and the edge of the page" ) + "</qt>"); - bottomR->setToolTip( "<qt>" + tr( "Distance between the bottom margin guide and the edge of the page" ) + "</qt>"); - leftR->setToolTip( "<qt>" + tr( "Distance between the left margin guide and the edge of the page. If a double-sided, 3 or 4-fold layout is selected, this margin space can be used to achieve the correct margins for binding.") + "</qt>"); - rightR->setToolTip( "<qt>" + tr( "Distance between the right margin guide and the edge of the page. If a double-sided, 3 or 4-fold layout is selected, this margin space can be used to achieve the correct margins for binding.") + "</qt>"); - linkMargins->setToolTip( "<qt>" + tr( "Ensure all margins have the same value") + "</qt>"); - - // signals&slots - connect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - connect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - connect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - connect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - connect(presetCombo, SIGNAL(activated(int)), this, SLOT(setPreset())); - connect(linkMargins, SIGNAL(clicked()), this, SLOT(slotLinkMargins())); -} - -void MarginWidget::slotLinkBleeds() -{ - disconnect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - - double bleedValue = BleedLeft->value(); - if (BleedLeft->hasFocus()) - { - BleedLeft->clearFocus(); - bleedValue = BleedLeft->value(); - } - if (BleedRight->hasFocus()) - { - BleedRight->clearFocus(); - bleedValue = BleedRight->value(); - } - if (BleedTop->hasFocus()) - { - BleedTop->clearFocus(); - bleedValue = BleedTop->value(); - } - if (BleedBottom->hasFocus()) - { - BleedBottom->clearFocus(); - bleedValue = BleedBottom->value(); - } - - if (linkBleeds->isChecked()) - { - BleedLeft->setValue(bleedValue); - BleedTop->setValue(bleedValue); - BleedBottom->setValue(bleedValue); - BleedRight->setValue(bleedValue); - } - - connect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); -} - -void MarginWidget::changeBleeds() -{ - if (linkBleeds->isChecked()) - { - double val = 0.0; - if (BleedTop == sender()) - val = BleedTop->value(); - else if (BleedBottom == sender()) - val = BleedBottom->value(); - else if (BleedLeft == sender()) - val = BleedLeft->value(); - else if (BleedRight == sender()) - val = BleedRight->value(); - val = val / m_unitRatio; - MarginStruct v(val,val,val,val); - setNewBleeds(v); - } -} - -void MarginWidget::setFacingPages(bool facing, int pagetype) -{ - m_facingPages = facing; - m_pageType = pagetype; - lText->setText(facing ? tr( "&Inside:" ) : tr( "&Left:" )); - rText->setText(facing ? tr( "O&utside:" ) : tr( "&Right:" )); - if (m_useBleeds) - { - if (facing) - { - BleedTxt3->setText( tr( "Inside:" ) ); - BleedTxt4->setText( tr( "Outside:" ) ); - } - else - { - BleedTxt3->setText( tr( "Left:" ) ); - BleedTxt4->setText( tr( "Right:" ) ); - } - } - setPreset(); -} - -void MarginWidget::setPageWidthHeight(double width, double height) -{ - rightR->setMaximum(qMax(0.0, width * m_unitRatio - leftR->value())); - leftR->setMaximum(qMax(0.0, width * m_unitRatio - rightR->value())); - m_pageWidth = width; - topR->setMaximum(qMax(0.0, height * m_unitRatio - bottomR->value())); - bottomR->setMaximum(qMax(0.0, height * m_unitRatio - topR->value())); - m_pageHeight = height; - setPreset(); -} - -void MarginWidget::setPageWidth(double width) -{ - rightR->setMaximum(qMax(0.0, width * m_unitRatio - leftR->value())); - leftR->setMaximum(qMax(0.0,width * m_unitRatio - rightR->value())); - m_pageWidth = width; - setPreset(); -} - -void MarginWidget::setPageHeight(double height) -{ - topR->setMaximum(qMax(0.0, height * m_unitRatio - bottomR->value())); - bottomR->setMaximum(qMax(0.0,height * m_unitRatio - topR->value())); - m_pageHeight = height; - setPreset(); -} - -void MarginWidget::setTop() -{ - double newVal = topR->value() / m_unitRatio; - bottomR->setMaximum(qMax(0.0, m_pageHeight * m_unitRatio - topR->value())); - if (linkMargins->isChecked() && m_savedPresetItem == PresetLayout::none) - { - marginData.set(newVal, newVal, newVal, newVal); - updateMarginSpinValues(); - } - else - marginData.setTop(newVal); - setPreset(); -} - -void MarginWidget::setBottom() -{ - double newVal = bottomR->value() / m_unitRatio; - topR->setMaximum(qMax(0.0, m_pageHeight * m_unitRatio - bottomR->value())); - if (linkMargins->isChecked() && m_savedPresetItem == PresetLayout::none) - { - marginData.set(newVal, newVal, newVal, newVal); - updateMarginSpinValues(); - } - else - marginData.setBottom(newVal); - setPreset(); -} - -void MarginWidget::setLeft() -{ - double newVal = leftR->value() / m_unitRatio; - rightR->setMaximum(qMax(0.0, m_pageWidth * m_unitRatio - leftR->value())); - if (linkMargins->isChecked() && m_savedPresetItem == PresetLayout::none) - { - marginData.set(newVal, newVal, newVal, newVal); - updateMarginSpinValues(); - } - else - marginData.setLeft(newVal); - setPreset(); -} - -void MarginWidget::setRight() -{ - double newVal = rightR->value() / m_unitRatio; - leftR->setMaximum(qMax(0.0, m_pageWidth * m_unitRatio - rightR->value())); - if (linkMargins->isChecked() && m_savedPresetItem == PresetLayout::none) - { - marginData.set(newVal, newVal, newVal, newVal); - updateMarginSpinValues(); - } - else - marginData.setRight(newVal); - setPreset(); -} - -void MarginWidget::setNewUnit(int newUnitIndex) -{ - disconnect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - disconnect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - disconnect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - disconnect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - m_unitIndex = newUnitIndex; - m_unitRatio = unitGetRatioFromIndex(newUnitIndex); - topR->setNewUnit(newUnitIndex); - bottomR->setNewUnit(newUnitIndex); - leftR->setNewUnit(newUnitIndex); - rightR->setNewUnit(newUnitIndex); - - if (m_useBleeds) - { - disconnect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - BleedBottom->setNewUnit(newUnitIndex); - BleedTop->setNewUnit(newUnitIndex); - BleedRight->setNewUnit(newUnitIndex); - BleedLeft->setNewUnit(newUnitIndex); - connect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - } - connect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - connect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - connect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - connect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); -} - -void MarginWidget::setPreset() -{ - disconnect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - disconnect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - disconnect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - disconnect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - if (m_savedPresetItem == PresetLayout::none) - m_savedMargins = marginData; - int item = presetCombo->currentIndex(); - - MarginStruct marg = presetCombo->getMargins(item, m_pageWidth, m_pageHeight, leftR->value() / m_unitRatio); - presetCombo->setEnabled(m_facingPages); - - bool restoringValues = false; - if ((item == PresetLayout::none) && (m_savedPresetItem != PresetLayout::none)) - { - marg = m_savedMargins; - restoringValues = true; - } - if (restoringValues || (presetCombo->needUpdate() && m_facingPages)) - { - marginData.set(qMax(0.0, marg.top()), qMax(0.0, marg.left()), qMax(0.0, marg.bottom()), qMax(0.0, marg.right())); - updateMarginSpinValues(); - - bottomR->setMaximum(qMax(0.0, m_pageHeight * m_unitRatio - topR->value())); - topR->setMaximum(qMax(0.0, m_pageHeight * m_unitRatio - bottomR->value())); - rightR->setMaximum(qMax(0.0, m_pageWidth * m_unitRatio - leftR->value())); - leftR->setMaximum(qMax(0.0, m_pageWidth * m_unitRatio - rightR->value())); - rightR->setEnabled(restoringValues); - topR->setEnabled(restoringValues); - bottomR->setEnabled(restoringValues); - } - else - { - rightR->setEnabled(true); - topR->setEnabled(true); - bottomR->setEnabled(true); - } - if (m_pageType == 1) - rightR->setEnabled(false); - leftR->setEnabled(item != PresetLayout::nineparts); - if (item != PresetLayout::none) - linkMargins->setChecked(false); - linkMargins->setEnabled(item == PresetLayout::none || !presetCombo->isEnabled()); - connect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - connect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - connect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - connect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - m_savedPresetItem = item; -} - -void MarginWidget::setPageSize(const QString& pageSize) -{ - m_pageSize = pageSize; -} - -void MarginWidget::setMarginsToPrinterMargins() -{ - 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); - presetCombo->setCurrentIndex(PresetLayout::none); - - marginData.setTop(t); - marginData.setBottom(b); - marginData.setLeft(l); - marginData.setRight(r); - updateMarginSpinValues(); - - bottomR->setMaximum((qMax(0.0, m_pageHeight - t) * m_unitRatio)); - topR->setMaximum((qMax(0.0, m_pageHeight - b) * m_unitRatio)); - rightR->setMaximum((qMax(0.0, m_pageWidth - l) * m_unitRatio)); - leftR->setMaximum((qMax(0.0, m_pageWidth - r) * m_unitRatio)); - - rightR->setEnabled(true); - topR->setEnabled(true); - bottomR->setEnabled(true); -} - -double MarginWidget::top() const -{ - return marginData.top(); -} - -double MarginWidget::bottom() const -{ - return marginData.bottom(); -} - -double MarginWidget::left() const -{ - return marginData.left(); -} - -double MarginWidget::right() const -{ - return marginData.right(); -} - -void MarginWidget::setNewMargins(MarginStruct &m) -{ - disconnect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - disconnect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - disconnect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - disconnect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - marginData = m; - updateMarginSpinValues(); - connect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - connect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - connect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - connect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); -} - -void MarginWidget::setMarginPreset(int p) -{ - disconnect(presetCombo, SIGNAL(activated(int)), this, SLOT(setPreset())); - m_savedPresetItem = p; - presetCombo->setCurrentIndex(p); - if (m_savedPresetItem == PresetLayout::none) - m_savedMargins = marginData; - int item = presetCombo->currentIndex(); - presetCombo->setEnabled(m_facingPages); - bool restoringValues = false; - if ((item == PresetLayout::none) && (m_savedPresetItem != PresetLayout::none)) - { - restoringValues = true; - } - if (restoringValues || (presetCombo->needUpdate() && m_facingPages)) - { - rightR->setEnabled(restoringValues); - topR->setEnabled(restoringValues); - bottomR->setEnabled(restoringValues); - } - else - { - rightR->setEnabled(true); - topR->setEnabled(true); - bottomR->setEnabled(true); - } - if (m_pageType == 1) - rightR->setEnabled(false); - leftR->setEnabled(item != PresetLayout::nineparts); - if (item != PresetLayout::none) - linkMargins->setChecked(false); - linkMargins->setEnabled(item == PresetLayout::none); - connect(presetCombo, SIGNAL(activated(int)), this, SLOT(setPreset())); -} - -int MarginWidget::getMarginPreset() -{ - return presetCombo->currentIndex(); -} - -bool MarginWidget::getMarginsForAllPages() const -{ - return marginsForAllPages->isChecked(); -} - -bool MarginWidget::getMarginsForAllMasterPages() const -{ - return marginsForAllMasterPages->isChecked(); -} - -void MarginWidget::setNewBleeds(MarginStruct& b) -{ - disconnect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - disconnect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - BleedTop->setValue(b.top() * m_unitRatio); - BleedBottom->setValue(b.bottom() * m_unitRatio); - BleedLeft->setValue(b.left() * m_unitRatio); - BleedRight->setValue(b.right() * m_unitRatio); - connect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); - connect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds())); -} - -double MarginWidget::topBleed() const -{ - return BleedTop->value() / m_unitRatio; -} - -double MarginWidget::bottomBleed() const -{ - return BleedBottom->value() / m_unitRatio; -} - -double MarginWidget::leftBleed() const -{ - return BleedLeft->value() / m_unitRatio; -} - -double MarginWidget::rightBleed() const -{ - return BleedRight->value() / m_unitRatio; -} - -const MarginStruct & MarginWidget::margins() const -{ - return marginData; -} - -void MarginWidget::slotLinkMargins() -{ - disconnect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - disconnect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - disconnect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - disconnect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - - double marginValue = leftR->value(); - if (leftR->hasFocus()) - { - leftR->clearFocus(); - marginValue = leftR->value(); - } - if (rightR->hasFocus()) - { - rightR->clearFocus(); - marginValue = rightR->value(); - } - if (topR->hasFocus()) - { - topR->clearFocus(); - marginValue = topR->value(); - } - if (bottomR->hasFocus()) - { - bottomR->clearFocus(); - marginValue = bottomR->value(); - } - - if (linkMargins->isChecked()) - { - leftR->setValue(marginValue); - bottomR->setValue(marginValue); - topR->setValue(marginValue); - rightR->setValue(marginValue); - double newVal = marginValue / m_unitRatio; - marginData.set(newVal, newVal, newVal, newVal); - } - - connect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop())); - connect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom())); - connect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft())); - connect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight())); - -} - -void MarginWidget::updateMarginSpinValues() -{ - topR->setValue(marginData.top() * m_unitRatio); - rightR->setValue(marginData.right() * m_unitRatio); - bottomR->setValue(marginData.bottom() * m_unitRatio); - leftR->setValue(marginData.left() * m_unitRatio); -} Property changes on: scribus/ui/marginwidget.cpp ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Author Date Id Revision \ No newline at end of property Index: scribus/ui/marginwidget.h =================================================================== --- scribus/ui/marginwidget.h (Revision 26264) +++ scribus/ui/marginwidget.h (nicht existent) @@ -1,178 +0,0 @@ -/* -For general Scribus (>=1.3.2) copyright and licensing information please refer -to the COPYING file provided with the program. Following this notice may exist -a copyright and/or license notice that predates the release of Scribus 1.3.2 -for which a new license (GPL+exception) is in place. -*/ -#ifndef MARGINWIDGET_H -#define MARGINWIDGET_H - -#include "scribusapi.h" -#include "scribusstructs.h" - -#include <QComboBox> -#include <QTabWidget> -#include "linkbutton.h" -#include "marginpresetlayout.h" - -class QCheckBox; -class QPushButton; -class QLabel; -class QGridLayout; -class QHBoxLayout; -class ScrSpinBox; - - -/*! \brief Widget for Margins setting. -Used e.g. in "New Doc Dialog" or "Preferences". -*/ -class SCRIBUS_API MarginWidget : public QTabWidget -{ - Q_OBJECT - -public: - /*! \brief It creates an user interface for base margin settings for the document. - \param parent Parent widget (used as standard in Qt) - \param title Title of the Group box - \param margs A reference to the margins in the preferences. - \param unitIndex and index of the unit combobox - \param showChangeAll show "apply to all pages" related items - */ - MarginWidget(QWidget* parent, const QString& title, const MarginStruct* margs, int unitIndex, bool showChangeAll = false, bool showBleeds = true); - ~MarginWidget() {} - /*! \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 and height */ - void setPageWidthHeight(double width, double height); - /*! \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); - /*! \brief Setup the widgets by new options */ - void setNewUnit(int newUnitIndex); - /*! \brief Set the page size for margin getting from cups */ - void setPageSize(const QString& pageSize); - - /*! \brief Margins - \retval MarginStruct data */ - const MarginStruct& margins() const; - /*! \brief Top Margin - \retval double margin size */ - double top() const; - /*! \brief Bottom Margin - \retval double margin size */ - double bottom() const; - /*! \brief Left Margin - \retval double margin size */ - double left() const; - /*! \brief Right Margin - \retval double margin size */ - double right() const; - - /*! \brief set new margin values for the dialog - It calls overridden setTop(), setBottom() etc. slots itself - via signals emitted from spinboxes. - \param m MarginStruct - */ - void setNewMargins(MarginStruct& m); - - /*! \brief Setup the presetCombo without changing the margin values, only used by tabdocument */ - void setMarginPreset(int p); - int getMarginPreset(); - - /*! \brief Top Bleed - \retval double bleed size */ - double topBleed() const; - /*! \brief Bottom Bleed - \retval double bleed size */ - double bottomBleed() const; - /*! \brief Left Bleed - \retval double bleed size */ - double leftBleed() const; - /*! \brief Right Bleed - \retval double bleed size */ - double rightBleed() const; - - /*! \brief set new bleed values for the dialog - \param b MarginStruct - */ - void setNewBleeds(MarginStruct& b); - - /*! \brief Return marginsForAllPages property - \retval bool true to apply for all pages */ - bool getMarginsForAllPages() const; - bool getMarginsForAllMasterPages() const; - -private: - /*! Tabs */ - QWidget *marginPage { nullptr }; - QWidget* bleedPage { nullptr }; - /*! Spinboxes */ - ScrSpinBox* topR { nullptr }; - ScrSpinBox* bottomR { nullptr }; - ScrSpinBox* rightR { nullptr }; - ScrSpinBox* leftR { nullptr }; - ScrSpinBox* BleedBottom { nullptr }; - ScrSpinBox* BleedLeft { nullptr }; - ScrSpinBox* BleedRight { nullptr }; - ScrSpinBox* BleedTop { nullptr }; - PresetLayout* presetCombo { nullptr }; - /*! Labels */ - QLabel* lText { nullptr }; - QLabel* rText { nullptr }; - QLabel* tText { nullptr }; - QLabel* bText { nullptr }; - QLabel* presetLabel { nullptr }; - QLabel* marginsForPages { nullptr }; - QLabel* BleedTxt1 { nullptr }; - QLabel* BleedTxt2 { nullptr }; - QLabel* BleedTxt3 { nullptr }; - QLabel* BleedTxt4 { nullptr }; - QCheckBox* marginsForAllPages { nullptr }; - QCheckBox* marginsForAllMasterPages { nullptr }; - QPushButton* usePrinterMarginsButton { nullptr }; - LinkButton* linkBleeds { nullptr }; - LinkButton* linkMargins { nullptr }; - - /*! \brief Margin values converted by unitRatio */ - MarginStruct marginData; - - /*! \brief Internally used page width */ - double m_pageWidth { 0.0 }; - /*! \brief Internally used page height */ - double m_pageHeight { 0.0 }; - -public slots: - /*! \brief Recompute the values after spinbox change */ - void setTop(); - void setBottom(); - void setLeft(); - void setRight(); - /*! \brief Recompute margins in PresetLayout combobox and disable/enable widgets. */ - void setPreset(); - void slotLinkBleeds(); - void slotLinkMargins(); - void changeBleeds(); - -protected slots: - virtual void setMarginsToPrinterMargins(); - -protected: - void updateMarginSpinValues(); - - QGridLayout* GroupLayout { nullptr }; - QHBoxLayout* marginsForPagesLayout { nullptr }; - QGridLayout* BleedGroupLayout { nullptr }; - - QString m_pageSize; - int m_unitIndex { 0 }; - double m_unitRatio { 1.0 }; - //! \brief if the outer facing palette points to the facing pages item - bool m_facingPages { false }; - bool m_useBleeds { false }; - int m_pageType { 0 }; - MarginStruct m_savedMargins; - int m_savedPresetItem { PresetLayout::none }; -}; - -#endif Property changes on: scribus/ui/marginwidget.h ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Author Date Id Revision \ No newline at end of property Index: scribus/ui/newdocdialog.cpp =================================================================== --- scribus/ui/newdocdialog.cpp (Revision 26264) +++ scribus/ui/newdocdialog.cpp (Arbeitskopie) @@ -12,6 +12,7 @@ #include <QHBoxLayout> #include <QVBoxLayout> +#include <QButtonGroup> #include <QCheckBox> #include <QComboBox> #include <QDir> @@ -29,14 +30,13 @@ #include <QStringList> #include <QTabWidget> #include <QToolTip> +#include <QVBoxLayout> -#include "scconfig.h" - #include "commonstrings.h" #include "filedialogeventcatcher.h" #include "fileloader.h" #include "iconmanager.h" -#include "marginwidget.h" +#include "newmarginwidget.h" #include "pagesize.h" #include "pagestructs.h" #include "prefsfile.h" @@ -43,63 +43,20 @@ #include "prefsmanager.h" #include "scrspinbox.h" #include "units.h" -#include "ui/delegates/sclistitemdelegate.h" +#include "ui/widgets/pagesizelist.h" -PageLayoutsWidget::PageLayoutsWidget(QWidget* parent) : - QListWidget(parent) -{ - setDragEnabled(false); - setViewMode(QListView::IconMode); - setFlow(QListView::LeftToRight); - setSortingEnabled(false); - setWrapping(false); - setWordWrap(true); - setAcceptDrops(false); - setDropIndicatorShown(false); - setDragDropMode(QAbstractItemView::NoDragDrop); - setResizeMode(QListView::Adjust); - setSelectionMode(QAbstractItemView::SingleSelection); - setFocusPolicy(Qt::NoFocus); - setIconSize(QSize(32, 32)); - clear(); - setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); - setGridSize(QSize(96, 96)); - setItemDelegate(new ScListItemDelegate(QListWidget::IconMode, QSize(32,32))); -} -void PageLayoutsWidget::arrangeIcons() -{ - int startY = 5; - int startX = 5; - int maxSizeY = 0; - - setResizeMode(QListView::Fixed); - - for (int i = 0; i < count(); ++i) - { - QListWidgetItem* itemWidget = item(i); - QRect itemRect = visualItemRect(itemWidget); - setPositionForIndex(QPoint(startX, startY), indexFromItem(itemWidget)); - startX += itemRect.width() + 5; - maxSizeY = qMax(maxSizeY, itemRect.height()); - } - - maxX = startX; - maxY = maxSizeY + 10; -} - -QSize PageLayoutsWidget::minimumSizeHint() const -{ - return QSize(maxX, maxY); -} - NewDocDialog::NewDocDialog(QWidget* parent, const QStringList& recentDocs, bool startUp, const QString& lang) : QDialog(parent), prefsManager(PrefsManager::instance()), m_onStartup(startUp) { + setupUi(this); + setObjectName(QString::fromLocal8Bit("NewDocumentWindow")); setModal(true); + IconManager &iconManager = IconManager::instance(); + m_unitIndex = prefsManager.appPrefs.docSetupPrefs.docUnitIndex; m_unitRatio = unitGetRatioFromIndex(m_unitIndex); m_unitSuffix = unitGetSuffixFromIndex(m_unitIndex); @@ -106,58 +63,35 @@ m_orientation = prefsManager.appPrefs.docSetupPrefs.pageOrientation; setWindowTitle( tr( "New Document" ) ); - setWindowIcon(IconManager::instance().loadIcon("AppIcon.png")); - if (startUp) - setContentsMargins(0, 0, 0, 0); - else - setContentsMargins(9, 9, 9, 9); - TabbedNewDocLayout = new QVBoxLayout( this ); - if (startUp) - TabbedNewDocLayout->setContentsMargins(9, 9, 9, 9); - else - TabbedNewDocLayout->setContentsMargins(0, 0, 0, 0); - TabbedNewDocLayout->setSpacing(6); + setWindowIcon(iconManager.loadIcon("AppIcon.png")); + + buttonVertical->setIcon(iconManager.loadIcon("page-orientation-vertical")); + buttonHorizontal->setIcon(iconManager.loadIcon("page-orientation-horizontal")); + createNewDocPage(); if (startUp) { - tabWidget = new QTabWidget( this ); - tabWidget->addTab(newDocFrame, tr("&New Document")); - createNewFromTempPage(); nftGui->setupSettings(lang); - tabWidget->addTab(newFromTempFrame, tr("New &from Template")); createOpenDocPage(); - tabWidget->addTab(openDocFrame, tr("Open &Existing Document")); recentDocList = recentDocs; - createRecentDocPage(); - tabWidget->addTab(recentDocFrame, tr("Open Recent &Document")); - TabbedNewDocLayout->addWidget(tabWidget); + createRecentDocPage(); + startUpDialog->setChecked(!prefsManager.appPrefs.uiPrefs.showStartupDialog); } else - TabbedNewDocLayout->addWidget(newDocFrame); - - Layout1 = new QHBoxLayout; - Layout1->setContentsMargins(0, 0, 0, 0); - Layout1->setSpacing(6); - if (startUp) { - startUpDialog = new QCheckBox( tr( "Do not show this dialog again" ), this ); - startUpDialog->setChecked(!prefsManager.appPrefs.uiPrefs.showStartupDialog); - Layout1->addWidget( startUpDialog ); + tabWidget->removeTab(3); + tabWidget->removeTab(2); + tabWidget->removeTab(1); } - QSpacerItem* spacer = new QSpacerItem( 2, 2, QSizePolicy::Expanding, QSizePolicy::Minimum ); - Layout1->addItem( spacer ); - buttonBox = new QDialogButtonBox(); - Layout1->addWidget(buttonBox); - okButton = new QPushButton( CommonStrings::tr_OK, this ); - okButton->setDefault( true ); - buttonBox->addButton(okButton, QDialogButtonBox::AcceptRole); - cancelButton = new QPushButton( CommonStrings::tr_Cancel, this ); - cancelButton->setAutoDefault( false ); - buttonBox->addButton(cancelButton, QDialogButtonBox::RejectRole); - TabbedNewDocLayout->addLayout( Layout1 ); + + + tabWidget->setCurrentIndex(0); + startUpDialog->setVisible(startUp); + //tooltips - pageSizeComboBox->setToolTip( tr( "Document page size, either a standard size or a custom size" ) ); - pageOrientationComboBox->setToolTip( tr( "Orientation of the document's pages" ) ); + listPageFormats->setToolTip( tr( "Document page size, either a standard size or a custom size" ) ); + buttonVertical->setToolTip( tr( "Vertical orientation of the document's pages" ) ); + buttonHorizontal->setToolTip( tr( "Horizontal orientation of the document's pages" ) ); widthSpinBox->setToolTip( tr( "Width of the document's pages, editable if you have chosen a custom page size" ) ); heightSpinBox->setToolTip( tr( "Height of the document's pages, editable if you have chosen a custom page size" ) ); pageCountSpinBox->setToolTip( tr( "Initial number of pages of the document" ) ); @@ -170,15 +104,17 @@ connect(buttonBox, &QDialogButtonBox::accepted, this, &NewDocDialog::ExitOK); connect(buttonBox, &QDialogButtonBox::rejected, this, &NewDocDialog::reject); - connect(pageSizeComboBox, SIGNAL(textActivated(QString)), this, SLOT(setPageSize(QString))); - connect(pageOrientationComboBox, SIGNAL(activated(int)), this, SLOT(setOrientation(int))); + connect(pageOrientationButtons, &QButtonGroup::idClicked, this, &NewDocDialog::setOrientation); 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(layoutsView, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - connect(layoutsView, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - connect(layoutsView, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - connect(layoutsView, SIGNAL(itemPressed(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); + connect(listPageFormats, &PageSizeList::clicked, this, &NewDocDialog::changePageSize); + connect(pageSizeSelector, &PageSizeSelector::pageCategoryChanged, this, &NewDocDialog::changeCategory); + connect(pageLayouts, &PageLayouts::schemeChanged, this, &NewDocDialog::changeScheme); + connect(pageLayouts, &PageLayouts::firstPageChanged, this, &NewDocDialog::changeFirstPage); + connect(marginGroup, &NewMarginWidget::marginChanged, this, &NewDocDialog::changeMargin); + connect(bleedGroup, &NewMarginWidget::marginChanged, this, &NewDocDialog::changeMargin); + connect(comboSortSizes, &QComboBox::currentIndexChanged, this, &NewDocDialog::changeSortMode); if (startUp) { connect(nftGui, SIGNAL(leaveOK()), this, SLOT(ExitOK())); @@ -189,180 +125,101 @@ void NewDocDialog::createNewDocPage() { - newDocFrame = new QFrame(this); + 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; - pageSizeGroupBox = new QGroupBox(newDocFrame ); - pageSizeGroupBox->setTitle( tr( "Document Layout" ) ); - pageSizeGroupBoxLayout = new QGridLayout( pageSizeGroupBox ); - pageSizeGroupBoxLayout->setContentsMargins(9, 9, 9, 9); - pageSizeGroupBoxLayout->setSpacing(6); - pageSizeGroupBoxLayout->setAlignment( Qt::AlignTop ); + comboSortSizes->addItem( tr("Name Asc"), PageSizeList::NameAsc); + comboSortSizes->addItem( tr("Name Desc"), PageSizeList::NameDesc); + comboSortSizes->addItem( tr("Size Asc"), PageSizeList::DimensionAsc); + comboSortSizes->addItem( tr("Size Desc"), PageSizeList::DimensionDesc); + comboSortSizes->setCurrentIndex(0); - layoutsView = new PageLayoutsWidget( pageSizeGroupBox ); - layoutsView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); - for (int i = 0; i < prefsManager.appPrefs.pageSets.count(); ++i) - { - QListWidgetItem *ic; - QString psname = CommonStrings::translatePageSetString(prefsManager.appPrefs.pageSets[i].Name); - if (i == 0) - { - ic = new QListWidgetItem( IconManager::instance().loadIcon("32/page-simple.png"), psname, layoutsView ); - ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - } - else if (i == 1) - { - ic = new QListWidgetItem( IconManager::instance().loadIcon("32/page-doublesided.png"), psname, layoutsView ); - ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - } - else if (i == 2 && prefsManager.appPrefs.docSetupPrefs.pagePositioning == 2) - { - ic = new QListWidgetItem( IconManager::instance().loadIcon("32/page-3fold.png"), psname, layoutsView ); - ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - } - else if (i == 3 && prefsManager.appPrefs.docSetupPrefs.pagePositioning == 3) - { - ic = new QListWidgetItem( IconManager::instance().loadIcon("32/page-4fold.png"), psname, layoutsView ); - ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - } - } - layoutsView->arrangeIcons(); - pageSizeGroupBoxLayout->addWidget( layoutsView, 0, 0, 5, 1 ); - layoutsView->arrangeIcons(); + pageOrientationButtons = new QButtonGroup(); + pageOrientationButtons->addButton(buttonVertical, 0); + pageOrientationButtons->addButton(buttonHorizontal, 1); + pageOrientationButtons->button(orientation)->setChecked(true); - TextLabel1 = new QLabel( tr( "&Size:" ), pageSizeGroupBox ); - pageSizeGroupBoxLayout->addWidget( TextLabel1, 0, 1 ); - PageSize ps(prefsManager.appPrefs.docSetupPrefs.pageSize); - pageSizeComboBox = new QComboBox( pageSizeGroupBox ); - pageSizeComboBox->addItems(ps.activeSizeTRList()); - pageSizeComboBox->addItem( CommonStrings::trCustomPageSize ); - pageSizeComboBox->setEditable(false); - TextLabel1->setBuddy(pageSizeComboBox); - pageSizeGroupBoxLayout->addWidget(pageSizeComboBox, 0, 2 ); - TextLabel2 = new QLabel( tr( "Orie&ntation:" ), pageSizeGroupBox ); - pageSizeGroupBoxLayout->addWidget( TextLabel2, 1, 1 ); - pageOrientationComboBox = new QComboBox( pageSizeGroupBox ); - pageOrientationComboBox->addItem( tr( "Portrait" ) ); - pageOrientationComboBox->addItem( tr( "Landscape" ) ); - pageOrientationComboBox->setEditable(false); - pageOrientationComboBox->setCurrentIndex(prefsManager.appPrefs.docSetupPrefs.pageOrientation); - TextLabel2->setBuddy(pageOrientationComboBox); - pageSizeGroupBoxLayout->addWidget( pageOrientationComboBox, 1, 2 ); + listPageFormats->setValues(pageSize, orientation, PageSizeInfo::Preferred, PageSizeList::NameAsc); - TextLabel1_2 = new QLabel( tr( "&Width:" ), pageSizeGroupBox ); - pageSizeGroupBoxLayout->addWidget(TextLabel1_2, 2, 1 ); - widthSpinBox = new ScrSpinBox(pts2value(1.0, m_unitIndex), 16777215, pageSizeGroupBox, m_unitIndex ); + pageSizeSelector->setHasFormatSelector(false); + pageSizeSelector->setHasCustom(false); + pageSizeSelector->setPageSize(pageSize); + pageSizeSelector->setCurrentCategory(PageSizeInfo::Preferred); + + widthSpinBox->setMinimum(pts2value(1.0, m_unitIndex)); + widthSpinBox->setMaximum(16777215); + widthSpinBox->setNewUnit(m_unitIndex); widthSpinBox->setSuffix(m_unitSuffix); - TextLabel1_2->setBuddy(widthSpinBox); - pageSizeGroupBoxLayout->addWidget(widthSpinBox, 2, 2 ); - TextLabel2_2 = new QLabel( tr( "&Height:" ), pageSizeGroupBox ); - pageSizeGroupBoxLayout->addWidget(TextLabel2_2, 3, 1 ); - heightSpinBox = new ScrSpinBox( pts2value(1.0, m_unitIndex), 16777215, pageSizeGroupBox, m_unitIndex ); + + heightSpinBox->setMinimum(pts2value(1.0, m_unitIndex)); + heightSpinBox->setMaximum(16777215); + heightSpinBox->setNewUnit(m_unitIndex); heightSpinBox->setSuffix(m_unitSuffix); - TextLabel2_2->setBuddy(heightSpinBox); - pageSizeGroupBoxLayout->addWidget(heightSpinBox, 3, 2 ); - unitOfMeasureLabel = new QLabel( tr( "&Default Unit:" ), pageSizeGroupBox ); - unitOfMeasureComboBox = new QComboBox( pageSizeGroupBox ); unitOfMeasureComboBox->addItems(unitGetTextUnitList()); unitOfMeasureComboBox->setCurrentIndex(m_unitIndex); unitOfMeasureComboBox->setEditable(false); - unitOfMeasureLabel->setBuddy(unitOfMeasureComboBox); - pageSizeGroupBoxLayout->addWidget( unitOfMeasureLabel, 4, 1 ); - pageSizeGroupBoxLayout->addWidget( unitOfMeasureComboBox, 4, 2 ); MarginStruct marg(prefsManager.appPrefs.docSetupPrefs.margins); - marginGroup = new MarginWidget(newDocFrame, tr( "Margin Guides" ), &marg, m_unitIndex ); - marginGroup->setPageWidthHeight(prefsManager.appPrefs.docSetupPrefs.pageWidth, prefsManager.appPrefs.docSetupPrefs.pageHeight); - marginGroup->setFacingPages(!(prefsManager.appPrefs.docSetupPrefs.pagePositioning == singlePage)); - widthSpinBox->setValue(prefsManager.appPrefs.docSetupPrefs.pageWidth * m_unitRatio); - heightSpinBox->setValue(prefsManager.appPrefs.docSetupPrefs.pageHeight * m_unitRatio); - QStringList pageSizes = ps.activeSizeTRList(); - int sizeIndex = pageSizes.indexOf(ps.nameTR()); - if (sizeIndex != -1) - pageSizeComboBox->setCurrentIndex(sizeIndex); - else - pageSizeComboBox->setCurrentIndex(pageSizeComboBox->count() - 1); - marginGroup->setPageSize(pageSizeComboBox->currentText()); - marginGroup->setNewBleeds(prefsManager.appPrefs.docSetupPrefs.bleeds); + marginGroup->setup(marg, !(pagePositioning == singlePage), m_unitIndex, NewMarginWidget::MarginWidgetFlags); + marginGroup->setPageHeight(pageHeight); + marginGroup->setPageWidth(pageWidth); + marginGroup->setFacingPages(!(pagePositioning == singlePage)); + + MarginStruct bleed; + bleed.resetToZero(); + + bleedGroup->setup(bleed, !(pagePositioning == singlePage), m_unitIndex, NewMarginWidget::BleedWidgetFlags); + bleedGroup->setPageHeight(pageHeight); + bleedGroup->setPageWidth(pageWidth); + bleedGroup->setFacingPages(!(pagePositioning == singlePage)); + widthSpinBox->setValue(pageWidth * m_unitRatio); + heightSpinBox->setValue(pageHeight * m_unitRatio); + + marginGroup->setPageSize(pageSize); marginGroup->setMarginPreset(prefsManager.appPrefs.docSetupPrefs.marginPreset); + bleedGroup->setPageSize(pageSize); + bleedGroup->setMarginPreset(prefsManager.appPrefs.docSetupPrefs.marginPreset); - optionsGroupBox = new QGroupBox( newDocFrame ); - optionsGroupBox->setTitle( tr( "Options" ) ); - optionsGroupBoxLayout = new QGridLayout( optionsGroupBox ); - optionsGroupBoxLayout->setSpacing(6); - optionsGroupBoxLayout->setContentsMargins(9, 9, 9, 9); - optionsGroupBoxLayout->setAlignment( Qt::AlignTop ); - pageCountLabel = new QLabel( tr( "N&umber of Pages:" ), optionsGroupBox ); - - pageCountSpinBox = new QSpinBox( optionsGroupBox ); pageCountSpinBox->setMaximum( 10000 ); pageCountSpinBox->setMinimum( 1 ); - pageCountLabel->setBuddy(pageCountSpinBox); - optionsGroupBoxLayout->addWidget(pageCountLabel, 0, 0, Qt::AlignLeft); - optionsGroupBoxLayout->addWidget(pageCountSpinBox, 0, 1); - layoutLabel1 = new QLabel( optionsGroupBox ); - layoutLabel1->setText( tr( "First Page is:" ) ); - firstPage = new QComboBox( optionsGroupBox ); - firstPage->clear(); - selectItem(prefsManager.appPrefs.docSetupPrefs.pagePositioning); - optionsGroupBoxLayout->addWidget(layoutLabel1, 1, 0, Qt::AlignLeft); - optionsGroupBoxLayout->addWidget(firstPage, 1, 1); - firstPage->setCurrentIndex(prefsManager.appPrefs.pageSets[prefsManager.appPrefs.docSetupPrefs.pagePositioning].FirstPage); + pageLayouts->updateSchemeSelector(prefsManager.appPrefs.pageSets, prefsManager.appPrefs.pageSets[pagePositioning].FirstPage); - setDocLayout(prefsManager.appPrefs.docSetupPrefs.pagePositioning); - setSize(prefsManager.appPrefs.docSetupPrefs.pageSize); - setOrientation(prefsManager.appPrefs.docSetupPrefs.pageOrientation); + setDocLayout(pagePositioning); + setSize(pageSize); + setOrientation(orientation); - autoTextFrame = new QCheckBox( optionsGroupBox ); - autoTextFrame->setText( tr( "&Automatic Text Frames" ) ); - optionsGroupBoxLayout->addWidget(autoTextFrame, 2, 0, 1, 2, Qt::AlignLeft); - - TextLabel3 = new QLabel( tr( "Colu&mns:" ), optionsGroupBox ); - numberOfCols = new QSpinBox( optionsGroupBox ); numberOfCols->setButtonSymbols( QSpinBox::UpDownArrows ); numberOfCols->setMinimum( 1 ); numberOfCols->setValue( 1 ); - TextLabel3->setBuddy(numberOfCols); - optionsGroupBoxLayout->addWidget(TextLabel3, 3, 0, Qt::AlignLeft); - optionsGroupBoxLayout->addWidget(numberOfCols, 3, 1); - TextLabel4 = new QLabel( tr( "&Gap:" ), optionsGroupBox ); - Distance = new ScrSpinBox( 0, 1000, optionsGroupBox, m_unitIndex ); + Distance->setMinimum(0); + Distance->setMaximum(1000); + Distance->setNewUnit(m_unitIndex); Distance->setValue(11 * m_unitRatio); - TextLabel4->setBuddy(Distance); - optionsGroupBoxLayout->addWidget(TextLabel4, 4, 0, Qt::AlignLeft); - optionsGroupBoxLayout->addWidget(Distance, 4, 1); - firstPage->setMinimumWidth(Distance->width()); - - TextLabel3->setEnabled(false); - TextLabel4->setEnabled(false); + labelColumns->setEnabled(false); + labelGap->setEnabled(false); Distance->setEnabled(false); numberOfCols->setEnabled(false); - startDocSetup = new QCheckBox( optionsGroupBox ); + startDocSetup->setText( tr( "Show Document Settings After Creation" ) ); startDocSetup->setChecked(false); - optionsGroupBoxLayout->addWidget(startDocSetup, 5, 0, 1, 2, Qt::AlignLeft); - NewDocLayout = new QGridLayout( newDocFrame ); - if (m_onStartup) - NewDocLayout->setContentsMargins(9, 9, 9, 9); - else - NewDocLayout->setContentsMargins(0, 0, 0, 0); - NewDocLayout->setSpacing(6); - NewDocLayout->addWidget( marginGroup, 1, 0 ); - NewDocLayout->addWidget( optionsGroupBox, 1, 1 ); - NewDocLayout->addWidget( pageSizeGroupBox, 0, 0, 1, 2); -} + sectionBleeds->collapse(); + sectionTextFrame->collapse(); -void NewDocDialog::createNewFromTempPage() -{ - newFromTempFrame = new QFrame(this); - verticalLayout = new QVBoxLayout(newFromTempFrame); - verticalLayout->setContentsMargins(9, 9, 9, 9); - nftGui = new nftwidget(newFromTempFrame); - verticalLayout->addWidget(nftGui); + // We have to calculate the width of the properties panel manually, + // because QSizePolicy::Minimum doesn't work as expected + scrollAreaWidgetContents->adjustSize(); + scrollAreaWidgetContents->setFixedWidth(scrollAreaWidgetContents->width()); + scrollArea->setWidgetResizable(true); + scrollArea->setFixedWidth(scrollAreaWidgetContents->width() + qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent)); + } void NewDocDialog::createOpenDocPage() @@ -376,10 +233,9 @@ docDir = docContext->get("docsopen", "."); QString formats(FileLoader::getLoadFilterString()); // formats.remove("PDF (*.pdf *.PDF);;"); - openDocFrame = new QFrame(this); - openDocLayout = new QVBoxLayout(openDocFrame); + QVBoxLayout *openDocLayout = new QVBoxLayout(tab_3); openDocLayout->setContentsMargins(0, 0, 0, 0); - openDocLayout->setSpacing(6); + openDocLayout->setSpacing(4); m_selectedFile = ""; // With Qt 5.15 we have to be in careful so that new document dialog doesn't display too large on startup. @@ -386,7 +242,7 @@ // To avoid this we have to use QFileDialog(QWidget *parent, Qt::WindowFlags flags) constructor, then // set the QFileDialog::DontUseNativeDialog option as early as possible, and nonetheless set again // the Qt::Widget window flag before adding the widget to layout. - fileDialog = new QFileDialog(openDocFrame, Qt::Widget); + fileDialog = new QFileDialog(tab_3, Qt::Widget); fileDialog->setOption(QFileDialog::DontUseNativeDialog); fileDialog->setWindowTitle(tr("Open")); fileDialog->setDirectory(docDir); @@ -404,6 +260,7 @@ fileDialog->setWindowFlags(Qt::Widget); openDocLayout->addWidget(fileDialog); + FileDialogEventCatcher* keyCatcher = new FileDialogEventCatcher(this); QList<QListView *> listViews = fileDialog->findChildren<QListView *>(); for (auto listView : std::as_const(listViews)) @@ -426,12 +283,6 @@ void NewDocDialog::createRecentDocPage() { - recentDocFrame = new QFrame(this); - recentDocLayout = new QVBoxLayout(recentDocFrame); - recentDocLayout->setContentsMargins(9, 9, 9, 9); - recentDocLayout->setSpacing(6); - recentDocListBox = new QListWidget(recentDocFrame); - recentDocLayout->addWidget(recentDocListBox); int max = qMin(prefsManager.appPrefs.uiPrefs.recentDocCount, recentDocList.count()); for (int i = 0; i < max; ++i) recentDocListBox->addItem(QDir::toNativeSeparators(recentDocList[i])); @@ -443,16 +294,20 @@ { m_pageWidth = widthSpinBox->value() / m_unitRatio; marginGroup->setPageWidth(m_pageWidth); - QString psText = pageSizeComboBox->currentText(); - if (psText != CommonStrings::trCustomPageSize && psText != CommonStrings::customPageSize) - pageSizeComboBox->setCurrentIndex(pageSizeComboBox->count() - 1); + bleedGroup->setPageWidth(m_pageWidth); + listPageFormats->clearSelection(); + m_pageSize = CommonStrings::customPageSize; + pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_pageSize, m_choosenLayout, pageLayouts->firstPage()); + int newOrientation = (widthSpinBox->value() > heightSpinBox->value()) ? landscapePage : portraitPage; if (newOrientation != m_orientation) { - pageOrientationComboBox->blockSignals(true); - pageOrientationComboBox->setCurrentIndex(newOrientation); - pageOrientationComboBox->blockSignals(false); m_orientation = newOrientation; + + QSignalBlocker sigOri(pageOrientationButtons); + pageOrientationButtons->button(newOrientation)->setChecked(true); + QSignalBlocker sigFormats(listPageFormats); + listPageFormats->setOrientation(m_orientation); } } @@ -460,68 +315,67 @@ { m_pageHeight = heightSpinBox->value() / m_unitRatio; marginGroup->setPageHeight(m_pageHeight); - QString psText = pageSizeComboBox->currentText(); - if (psText != CommonStrings::trCustomPageSize && psText != CommonStrings::customPageSize) - pageSizeComboBox->setCurrentIndex(pageSizeComboBox->count() - 1); + bleedGroup->setPageHeight(m_pageHeight); + listPageFormats->clearSelection(); + m_pageSize = CommonStrings::customPageSize; + pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_pageSize, m_choosenLayout, pageLayouts->firstPage()); + int newOrientation = (widthSpinBox->value() > heightSpinBox->value()) ? landscapePage : portraitPage; if (newOrientation != m_orientation) { - pageOrientationComboBox->blockSignals(true); - pageOrientationComboBox->setCurrentIndex(newOrientation); - pageOrientationComboBox->blockSignals(false); m_orientation = newOrientation; + + QSignalBlocker sigOri(pageOrientationButtons); + pageOrientationButtons->button(newOrientation)->setChecked(true); + QSignalBlocker sigFormats(listPageFormats); + listPageFormats->setOrientation(m_orientation); } } void NewDocDialog::selectItem(uint nr) { - disconnect(layoutsView, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - disconnect(layoutsView, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - disconnect(layoutsView, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - disconnect(layoutsView, SIGNAL(itemPressed(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - if (nr > 0) - { - const QStringList& pageNames = prefsManager.appPrefs.pageSets[nr].pageNames; - firstPage->setEnabled(true); - firstPage->clear(); - for (auto pNames = pageNames.begin(); pNames != pageNames.end(); ++pNames) - firstPage->addItem(CommonStrings::translatePageSetLocString((*pNames))); - } - else - { - firstPage->clear(); - firstPage->addItem(" "); - firstPage->setEnabled(false); - } - layoutsView->setCurrentRow(nr); - layoutsView->item(nr)->setSelected(true); - connect(layoutsView, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - connect(layoutsView, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - connect(layoutsView, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); - connect(layoutsView, SIGNAL(itemPressed(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); + pageLayouts->setScheme(nr); + pageLayouts->setFirstPage(nr); } -void NewDocDialog::itemSelected(QListWidgetItem* ic) +void NewDocDialog::changePageSize(const QModelIndex &ic) { - if (ic == nullptr) - return; - selectItem(layoutsView->row(ic)); - setDocLayout(layoutsView->row(ic)); + int unit = ic.data(PageSizeList::Unit).toInt(); + QString sizeName = ic.data(PageSizeList::Name).toString(); + + setUnit(unit); + setPageSize(sizeName); + + QSignalBlocker sig(unitOfMeasureComboBox); + unitOfMeasureComboBox->setCurrentIndex(unit); + } +void NewDocDialog::changeScheme(int ic) +{ + selectItem(ic); + setDocLayout(ic); +} + +void NewDocDialog::changeSortMode(int ic) +{ + Q_UNUSED(ic); + listPageFormats->setSortMode(static_cast<PageSizeList::SortMode>(comboSortSizes->currentData().toInt())); +} + void NewDocDialog::handleAutoFrame() { if (autoTextFrame->isChecked()) { - TextLabel3->setEnabled(true); - TextLabel4->setEnabled(true); + labelColumns->setEnabled(true); + labelGap->setEnabled(true); Distance->setEnabled(true); numberOfCols->setEnabled(true); } else { - TextLabel3->setEnabled(false); - TextLabel4->setEnabled(false); + labelColumns->setEnabled(false); + labelGap->setEnabled(false); Distance->setEnabled(false); numberOfCols->setEnabled(false); } @@ -547,6 +401,9 @@ marginGroup->setNewUnit(m_unitIndex); marginGroup->setPageHeight(m_pageHeight); marginGroup->setPageWidth(m_pageWidth); + bleedGroup->setNewUnit(m_unitIndex); + bleedGroup->setPageHeight(m_pageHeight); + bleedGroup->setPageWidth(m_pageWidth); connect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double))); connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double))); } @@ -555,10 +412,10 @@ { m_pageWidth = widthSpinBox->value() / m_unitRatio; m_pageHeight = heightSpinBox->value() / m_unitRatio; - m_bleedBottom = marginGroup->bottomBleed(); - m_bleedTop = marginGroup->topBleed(); - m_bleedLeft = marginGroup->leftBleed(); - m_bleedRight = marginGroup->rightBleed(); + m_bleedBottom = bleedGroup->margins().bottom(); + m_bleedTop = bleedGroup->margins().top(); + m_bleedLeft = bleedGroup->margins().left(); + m_bleedRight = bleedGroup->margins().right(); if (m_onStartup) { m_tabSelected = tabWidget->currentIndex(); @@ -609,19 +466,17 @@ 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; - if (pageSizeComboBox->currentText() == CommonStrings::trCustomPageSize) - { - if (widthSpinBox->value() > heightSpinBox->value()) - pageOrientationComboBox->setCurrentIndex(landscapePage); - else - pageOrientationComboBox->setCurrentIndex(portraitPage); - } // end of #869 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, pageLayouts->firstPage()); + connect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double))); connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double))); } @@ -628,14 +483,13 @@ void NewDocDialog::setPageSize(const QString &size) { - if (size == CommonStrings::trCustomPageSize) - setSize(size); - else - { - setSize(size); - setOrientation(pageOrientationComboBox->currentIndex()); - } + setSize(size); + + if (size != CommonStrings::customPageSize) + setOrientation(pageOrientationButtons->checkedId()); + marginGroup->setPageSize(size); + bleedGroup->setPageSize(size); } void NewDocDialog::setSize(const QString& gr) @@ -642,10 +496,11 @@ { 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 (gr == CommonStrings::trCustomPageSize || gr == CommonStrings::customPageSize) + if (m_pageSize == CommonStrings::trCustomPageSize || m_pageSize == CommonStrings::customPageSize) { widthSpinBox->setEnabled(true); heightSpinBox->setEnabled(true); @@ -652,8 +507,8 @@ } else { - PageSize ps2(gr); - if (pageOrientationComboBox->currentIndex() == portraitPage) + PageSize ps2(m_pageSize); + if (pageOrientationButtons->checkedId() == portraitPage) { m_pageWidth = ps2.width(); m_pageHeight = ps2.height(); @@ -668,15 +523,23 @@ 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, pageLayouts->firstPage()); + connect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double))); connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double))); + } void NewDocDialog::setDocLayout(int layout) { marginGroup->setFacingPages(layout != singlePage); + bleedGroup->setFacingPages(layout != singlePage); m_choosenLayout = layout; - firstPage->setCurrentIndex(prefsManager.appPrefs.pageSets[m_choosenLayout].FirstPage); + pageLayouts->setScheme(m_choosenLayout); + pageLayouts->setFirstPage(prefsManager.appPrefs.pageSets[m_choosenLayout].FirstPage); + pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_pageSize, m_choosenLayout, pageLayouts->firstPage()); } void NewDocDialog::recentDocListBox_doubleClicked() @@ -698,7 +561,7 @@ setWindowTitle(tr("Open Recent Document")); else setWindowTitle(tr("New Document")); - okButton->setEnabled(tab!=2); + //okButton->setEnabled(tab!=2); } void NewDocDialog::locationDropped(const QString& fileUrl) @@ -750,5 +613,29 @@ void NewDocDialog::openFileDialogFileClicked(const QString& path) { - okButton->setEnabled(!path.isEmpty()); + //okButton->setEnabled(!path.isEmpty()); } + +void NewDocDialog::changeMargin(MarginStruct margin) +{ + pagePreview->setMargins(margin); +} + +void NewDocDialog::changeBleed(MarginStruct bleed) +{ + pagePreview->setBleeds(bleed); +} + +void NewDocDialog::changeFirstPage(int firstPage) +{ + pagePreview->setFirstPage(firstPage); +} + +void NewDocDialog::changeCategory(PageSizeInfo::Category category) +{ + if (listPageFormats->category() == category) + return; + + listPageFormats->setFormat(m_pageSize); + listPageFormats->setCategory(category); +} Index: scribus/ui/newdocdialog.h =================================================================== --- scribus/ui/newdocdialog.h (Revision 26264) +++ scribus/ui/newdocdialog.h (Arbeitskopie) @@ -33,31 +33,19 @@ #include "ui/customfdialog.h" #include "ui/nftwidget.h" +#include "ui_newdocdialog.h" + class PrefsManager; -class MarginWidget; +class NewMarginWidget; class ScrSpinBox; class QFileDialog; -class SCRIBUS_API PageLayoutsWidget : public QListWidget +class SCRIBUS_API NewDocDialog : public QDialog, public Ui::newDocDialog { Q_OBJECT public: - PageLayoutsWidget(QWidget* parent); - ~PageLayoutsWidget() = default; - void arrangeIcons(); - QSize minimumSizeHint() const override; - int maxX {0}; - int maxY {0}; -}; - -class SCRIBUS_API NewDocDialog : public QDialog -{ - Q_OBJECT - -public: - //! \brief Indexes of the dialog's tabs. enum { NewDocumentTab = 0, @@ -70,48 +58,12 @@ ~NewDocDialog() = default; void createNewDocPage(); - void createNewFromTempPage(); void createOpenDocPage(); void createRecentDocPage(); void setSize(const QString& gr); + QString pageSizeName() { return m_pageSize; }; - QTabWidget* tabWidget {nullptr}; - QFrame* newDocFrame {nullptr}; - PageLayoutsWidget* layoutsView {nullptr}; - QLabel* layoutLabel1 {nullptr}; - QComboBox* firstPage {nullptr}; - QGroupBox* pageSizeGroupBox {nullptr}; - MarginWidget* marginGroup {nullptr}; - QGroupBox* optionsGroupBox {nullptr}; - QLabel* TextLabel1 {nullptr}; - QLabel* TextLabel2 {nullptr}; - QLabel* TextLabel3 {nullptr}; - QLabel* TextLabel4 {nullptr}; - QLabel* TextLabel1_2 {nullptr}; - QLabel* TextLabel1_3 {nullptr}; - QLabel* pageCountLabel {nullptr}; - QLabel* TextLabel2_2 {nullptr}; - QLabel* unitOfMeasureLabel {nullptr}; - QComboBox* pageSizeComboBox {nullptr}; - QComboBox* pageOrientationComboBox {nullptr}; - QComboBox* unitOfMeasureComboBox {nullptr}; - QCheckBox* startUpDialog {nullptr}; - QCheckBox* autoTextFrame {nullptr}; - QCheckBox* startDocSetup {nullptr}; - ScrSpinBox* Distance {nullptr}; - QSpinBox* numberOfCols {nullptr}; - QSpinBox* pageCountSpinBox {nullptr}; - ScrSpinBox* widthSpinBox {nullptr}; - ScrSpinBox* heightSpinBox {nullptr}; - QFrame* openDocFrame {nullptr}; QFileDialog *fileDialog {nullptr}; - QFrame* newFromTempFrame {nullptr}; - nftwidget *nftGui {nullptr}; - QFrame* recentDocFrame {nullptr}; - QListWidget* recentDocListBox {nullptr}; - QDialogButtonBox* buttonBox {nullptr}; - QPushButton* okButton {nullptr}; - QPushButton* cancelButton {nullptr}; bool onStartup() const { return m_onStartup;} int tabSelected() const { return m_tabSelected;} @@ -134,8 +86,7 @@ public slots: void setHeight(double v); void setWidth(double v); - void selectItem(uint nr); - void itemSelected(QListWidgetItem* ic); + void selectItem(uint nr); void handleAutoFrame(); void setDistance(double v); void setUnit(int u); @@ -156,17 +107,19 @@ void gotoHomeDirectory(); void openFileDialogFileClicked(const QString &path); +private slots: + void changeMargin(MarginStruct margin); + void changeBleed(MarginStruct bleed); + void changeFirstPage(int firstPage); + void changeCategory(PageSizeInfo::Category category); + void changePageSize(const QModelIndex &ic); + void changeScheme(int ic); + void changeSortMode(int ic); + protected: - QVBoxLayout* TabbedNewDocLayout {nullptr}; - QHBoxLayout* Layout1 {nullptr}; - QGridLayout* NewDocLayout {nullptr}; - QGridLayout* pageSizeGroupBoxLayout {nullptr}; - QGridLayout* optionsGroupBoxLayout {nullptr}; - QVBoxLayout* openDocLayout {nullptr}; - QVBoxLayout* recentDocLayout {nullptr}; - QVBoxLayout *verticalLayout {nullptr}; PrefsManager& prefsManager; QStringList recentDocList; + QButtonGroup* pageOrientationButtons; double m_unitRatio { 1.0 }; int m_orientation { 0 }; @@ -176,6 +129,7 @@ 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 }; Index: scribus/ui/newdocdialog.ui =================================================================== --- scribus/ui/newdocdialog.ui (nicht existent) +++ scribus/ui/newdocdialog.ui (Arbeitskopie) @@ -0,0 +1,837 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>newDocDialog</class> + <widget class="QDialog" name="newDocDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>900</width> + <height>600</height> + </rect> + </property> + <property name="windowTitle"> + <string>Dialog</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="spacing"> + <number>4</number> + </property> + <property name="leftMargin"> + <number>8</number> + </property> + <property name="topMargin"> + <number>8</number> + </property> + <property name="rightMargin"> + <number>8</number> + </property> + <property name="bottomMargin"> + <number>8</number> + </property> + <item> + <widget class="QTabWidget" name="tabWidget"> + <property name="currentIndex"> + <number>0</number> + </property> + <property name="tabBarAutoHide"> + <bool>true</bool> + </property> + <widget class="QWidget" name="tab"> + <attribute name="title"> + <string>New Document</string> + </attribute> + <layout class="QHBoxLayout" name="horizontalLayout_7"> + <property name="spacing"> + <number>4</number> + </property> + <property name="leftMargin"> + <number>8</number> + </property> + <property name="topMargin"> + <number |