diff --git a/Scribus.pro b/Scribus.pro index f097e699f..f8d5b56e6 100644 --- a/Scribus.pro +++ b/Scribus.pro @@ -1010,6 +1010,7 @@ FORMS += scribus/ui/aboutplugins.ui \ scribus/ui/actionsearchdialog.ui \ scribus/ui/aligndistribute.ui \ scribus/ui/annot.ui \ + scribus/ui/applytemplatedialog.ui \ scribus/ui/arcvectorbase.ui \ scribus/ui/arcwidgetbase.ui \ scribus/ui/charselect.ui \ diff --git a/scribus/ui/applytemplatedialog.cpp b/scribus/ui/applytemplatedialog.cpp index 075997b1b..d0e709e6f 100644 --- a/scribus/ui/applytemplatedialog.cpp +++ b/scribus/ui/applytemplatedialog.cpp @@ -48,79 +48,84 @@ enum { */ ApplyMasterPageDialog::ApplyMasterPageDialog( QWidget* parent ) : QDialog( parent ) { - setModal(true); - setWindowTitle( tr( "Apply Master Page" )); - setWindowIcon(IconManager::instance().loadIcon("AppIcon.png")); - ApplyMasterPageDialogLayout = new QVBoxLayout(this); - ApplyMasterPageDialogLayout->setContentsMargins(9, 9, 9, 9); - ApplyMasterPageDialogLayout->setSpacing(6); - - templateNameLayout = new QHBoxLayout; - templateNameLayout->setContentsMargins(0, 0, 0, 0); - templateNameLayout->setSpacing(6); - - masterPageLabel = new QLabel( this ); - templateNameLayout->addWidget( masterPageLabel ); - spacer2 = new QSpacerItem( 1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum ); - templateNameLayout->addItem( spacer2 ); - - masterPageComboBox = new QComboBox(this); - masterPageComboBox->setEditable(false); - templateNameLayout->addWidget( masterPageComboBox ); - ApplyMasterPageDialogLayout->addLayout( templateNameLayout ); - - applyToPageButtonGroup = new QGroupBox(this); - applyToPageButtonGroup->setMinimumSize( QSize( 250, 0 ) ); - applyToPageButtonGroupLayout = new QVBoxLayout(applyToPageButtonGroup); - applyToPageButtonGroupLayout->setSpacing(6); - applyToPageButtonGroupLayout->setContentsMargins(9, 9, 9, 9); - - currentPageRadioButton = new QRadioButton( applyToPageButtonGroup ); - currentPageRadioButton->setChecked( true ); - applyToPageButtonGroupLayout->addWidget( currentPageRadioButton ); - - evenPagesRadioButton = new QRadioButton( applyToPageButtonGroup ); - applyToPageButtonGroupLayout->addWidget( evenPagesRadioButton ); - - oddPagesRadioButton = new QRadioButton( applyToPageButtonGroup ); - applyToPageButtonGroupLayout->addWidget( oddPagesRadioButton ); - - allPagesRadioButton = new QRadioButton( applyToPageButtonGroup ); - applyToPageButtonGroupLayout->addWidget( allPagesRadioButton ); - - rangeLayout = new QHBoxLayout; - rangeLayout->setSpacing(6); - rangeLayout->setContentsMargins(0, 0, 0, 0); - - useRangeCheckBox = new QCheckBox( applyToPageButtonGroup ); - useRangeCheckBox->setEnabled( false ); - rangeLayout->addWidget( useRangeCheckBox ); - - fromPageSpinBox = new ScrSpinBox( applyToPageButtonGroup ); - fromPageSpinBox->setEnabled( false ); - fromPageSpinBox->setMinimum( 1 ); - fromPageSpinBox->setDecimals(0); + setupUi(this); + setSizePolicy( QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); fromPageSpinBox->setSuffix(""); - rangeLayout->addWidget( fromPageSpinBox ); - - toPageLabel = new QLabel( applyToPageButtonGroup ); - rangeLayout->addWidget( toPageLabel ); - - toPageSpinBox = new ScrSpinBox( applyToPageButtonGroup ); - toPageSpinBox->setEnabled( false ); - toPageSpinBox->setMinimum( 1 ); - toPageSpinBox->setDecimals(0); toPageSpinBox->setSuffix(""); - rangeLayout->addWidget( toPageSpinBox ); - spacer3 = new QSpacerItem( 1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum ); - rangeLayout->addItem( spacer3 ); - applyToPageButtonGroupLayout->addLayout( rangeLayout ); - ApplyMasterPageDialogLayout->addWidget( applyToPageButtonGroup ); - - buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - ApplyMasterPageDialogLayout->addWidget(buttonBox); - languageChange(); + + // setModal(true); + // setWindowTitle( tr( "Apply Master Page" )); + // setWindowIcon(IconManager::instance().loadIcon("AppIcon.png")); + // ApplyMasterPageDialogLayout = new QVBoxLayout(this); + // ApplyMasterPageDialogLayout->setContentsMargins(9, 9, 9, 9); + // ApplyMasterPageDialogLayout->setSpacing(6); + + // templateNameLayout = new QHBoxLayout; + // templateNameLayout->setContentsMargins(0, 0, 0, 0); + // templateNameLayout->setSpacing(6); + + // masterPageLabel = new QLabel( this ); + // templateNameLayout->addWidget( masterPageLabel ); + // spacer2 = new QSpacerItem( 1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum ); + // templateNameLayout->addItem( spacer2 ); + + // masterPageComboBox = new QComboBox(this); + // masterPageComboBox->setEditable(false); + // templateNameLayout->addWidget( masterPageComboBox ); + // ApplyMasterPageDialogLayout->addLayout( templateNameLayout ); + + // applyToPageButtonGroup = new QGroupBox(this); + // applyToPageButtonGroup->setMinimumSize( QSize( 250, 0 ) ); + // applyToPageButtonGroupLayout = new QVBoxLayout(applyToPageButtonGroup); + // applyToPageButtonGroupLayout->setSpacing(6); + // applyToPageButtonGroupLayout->setContentsMargins(9, 9, 9, 9); + + // currentPageRadioButton = new QRadioButton( applyToPageButtonGroup ); + // currentPageRadioButton->setChecked( true ); + // applyToPageButtonGroupLayout->addWidget( currentPageRadioButton ); + + // evenPagesRadioButton = new QRadioButton( applyToPageButtonGroup ); + // applyToPageButtonGroupLayout->addWidget( evenPagesRadioButton ); + + // oddPagesRadioButton = new QRadioButton( applyToPageButtonGroup ); + // applyToPageButtonGroupLayout->addWidget( oddPagesRadioButton ); + + // allPagesRadioButton = new QRadioButton( applyToPageButtonGroup ); + // applyToPageButtonGroupLayout->addWidget( allPagesRadioButton ); + + // rangeLayout = new QHBoxLayout; + // rangeLayout->setSpacing(6); + // rangeLayout->setContentsMargins(0, 0, 0, 0); + + // useRangeCheckBox = new QCheckBox( applyToPageButtonGroup ); + // useRangeCheckBox->setEnabled( false ); + // rangeLayout->addWidget( useRangeCheckBox ); + + // fromPageSpinBox = new ScrSpinBox( applyToPageButtonGroup ); + // fromPageSpinBox->setEnabled( false ); + // fromPageSpinBox->setMinimum( 1 ); + // fromPageSpinBox->setDecimals(0); + // fromPageSpinBox->setSuffix(""); + // rangeLayout->addWidget( fromPageSpinBox ); + + // toPageLabel = new QLabel( applyToPageButtonGroup ); + // rangeLayout->addWidget( toPageLabel ); + + // toPageSpinBox = new ScrSpinBox( applyToPageButtonGroup ); + // toPageSpinBox->setEnabled( false ); + // toPageSpinBox->setMinimum( 1 ); + // toPageSpinBox->setDecimals(0); + // toPageSpinBox->setSuffix(""); + // rangeLayout->addWidget( toPageSpinBox ); + // spacer3 = new QSpacerItem( 1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum ); + // rangeLayout->addItem( spacer3 ); + // applyToPageButtonGroupLayout->addLayout( rangeLayout ); + // ApplyMasterPageDialogLayout->addWidget( applyToPageButtonGroup ); + + // buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + // ApplyMasterPageDialogLayout->addWidget(buttonBox); resize( QSize(268, 230).expandedTo(minimumSizeHint()) ); + languageChange(); // signals and slots connections connect( useRangeCheckBox, SIGNAL( toggled(bool) ), this, SLOT( enableRange(bool) ) ); @@ -132,9 +137,10 @@ ApplyMasterPageDialog::ApplyMasterPageDialog( QWidget* parent ) : QDialog( paren connect( toPageSpinBox, SIGNAL( valueChanged(double) ), this, SLOT( checkRangeTo() ) ); connect(buttonBox, &QDialogButtonBox::accepted, this, &ApplyMasterPageDialog::accept); connect(buttonBox, &QDialogButtonBox::rejected, this, &ApplyMasterPageDialog::reject); + connect(moveItemsCheckBox, &QCheckBox::toggled, this, &ApplyMasterPageDialog::enableItemsSelectable); // buddies - masterPageLabel->setBuddy( masterPageComboBox ); + // masterPageLabel->setBuddy( masterPageComboBox ); } void ApplyMasterPageDialog::setup(ScribusDoc *doc, const QString& Nam) @@ -158,6 +164,7 @@ void ApplyMasterPageDialog::setup(ScribusDoc *doc, const QString& Nam) fromPageSpinBox->setValue(doc->currentPage()->pageNr() + 1); toPageSpinBox->setMaximum(docPagesCount); toPageSpinBox->setValue(docPagesCount); + facingPages = doc->pagePositioning() != 0; } @@ -218,6 +225,14 @@ void ApplyMasterPageDialog::singleSelectable() toPageSpinBox->setEnabled(false); } +void ApplyMasterPageDialog::enableItemsSelectable(bool enabled) +{ + moveItemsAnchorComboBox->setEnabled(enabled); + moveItemsAnchorComboBox->setEnabled(enabled); + moveItemsMarginLabel->setEnabled(enabled); +} + + bool ApplyMasterPageDialog::usingRange() { @@ -252,19 +267,31 @@ void ApplyMasterPageDialog::changeEvent(QEvent *e) void ApplyMasterPageDialog::languageChange() { - setWindowTitle( tr( "Apply Master Page" ) ); - masterPageLabel->setText( tr( "&Master Page:" ) ); - applyToPageButtonGroup->setTitle( tr( "Apply to" ) ); - currentPageRadioButton->setText( tr( "Current &Page" ) ); - currentPageRadioButton->setShortcut( QKeySequence( tr( "Alt+P" ) ) ); - evenPagesRadioButton->setText( tr( "&Even Pages" ) ); - evenPagesRadioButton->setShortcut( QKeySequence( tr( "Alt+E" ) ) ); - oddPagesRadioButton->setText( tr( "O&dd Pages" ) ); - oddPagesRadioButton->setShortcut( QKeySequence( tr( "Alt+D" ) ) ); - allPagesRadioButton->setText( tr( "&All Pages" ) ); - allPagesRadioButton->setShortcut( QKeySequence( tr( "Alt+A" ) ) ); - useRangeCheckBox->setText( tr( "&Within Range" ) ); - useRangeCheckBox->setShortcut( QKeySequence( tr( "Alt+W" ) ) ); - useRangeCheckBox->setToolTip( "" + tr( "Apply the selected master page to even, odd or all pages within the following range") + "" ); - toPageLabel->setText( tr( "to" ) ); + setWindowTitle(tr("Apply Master Page")); + masterPageLabel->setText(tr("&Master Page:")); + applyToPageButtonGroup->setTitle(tr("Apply to")); + currentPageRadioButton->setText(tr("Current &Page")); + currentPageRadioButton->setShortcut(QKeySequence(tr("Alt+P"))); + evenPagesRadioButton->setText(tr("&Even Pages")); + evenPagesRadioButton->setShortcut(QKeySequence(tr("Alt+E"))); + oddPagesRadioButton->setText(tr("O&dd Pages")); + oddPagesRadioButton->setShortcut(QKeySequence(tr("Alt+D"))); + allPagesRadioButton->setText(tr("&All Pages")); + allPagesRadioButton->setShortcut(QKeySequence(tr("Alt+A"))); + useRangeCheckBox->setText(tr("&Within Range")); + useRangeCheckBox->setShortcut(QKeySequence(tr("Alt+W"))); + useRangeCheckBox->setToolTip("" + tr("Apply the selected master page to even, odd or all pages within the following range") + ""); + toPageLabel->setText(tr("to")); + moveItemsCheckBox->setText(tr("Move Items with")); + moveItemsAnchorComboBox->clear(); + if (facingPages) { + moveItemsAnchorComboBox->addItem(tr("Inside")); + moveItemsAnchorComboBox->addItem(tr("Outside")); + } + else + { + moveItemsAnchorComboBox->addItem(tr("Left")); + moveItemsAnchorComboBox->addItem(tr("Right")); + } + moveItemsMarginLabel->setText(tr("Margin")); } diff --git a/scribus/ui/applytemplatedialog.h b/scribus/ui/applytemplatedialog.h index 71dd7fef4..efc177f52 100644 --- a/scribus/ui/applytemplatedialog.h +++ b/scribus/ui/applytemplatedialog.h @@ -15,6 +15,8 @@ for which a new license (GPL+exception) is in place. #ifndef APPLYMASTERPAGEDIALOG_H #define APPLYMASTERPAGEDIALOG_H +#include "ui_applytemplatedialog.h" + #include #include #include @@ -35,7 +37,7 @@ class QRadioButton; class QSpacerItem; class QVBoxLayout; -class SCRIBUS_API ApplyMasterPageDialog : public QDialog +class SCRIBUS_API ApplyMasterPageDialog : public QDialog, Ui::ApplyMasterPage { Q_OBJECT @@ -43,17 +45,17 @@ public: ApplyMasterPageDialog( QWidget* parent = nullptr ); ~ApplyMasterPageDialog() = default; - QLabel* masterPageLabel { nullptr }; - QComboBox* masterPageComboBox { nullptr }; - QGroupBox* applyToPageButtonGroup { nullptr }; - QRadioButton* currentPageRadioButton { nullptr }; - QRadioButton* evenPagesRadioButton { nullptr }; - QRadioButton* oddPagesRadioButton { nullptr }; - QRadioButton* allPagesRadioButton { nullptr }; - QCheckBox* useRangeCheckBox { nullptr }; - ScrSpinBox* fromPageSpinBox { nullptr }; - QLabel* toPageLabel { nullptr }; - ScrSpinBox* toPageSpinBox { nullptr }; + // QLabel* masterPageLabel { nullptr }; + // QComboBox* masterPageComboBox { nullptr }; + // QGroupBox* applyToPageButtonGroup { nullptr }; + // QRadioButton* currentPageRadioButton { nullptr }; + // QRadioButton* evenPagesRadioButton { nullptr }; + // QRadioButton* oddPagesRadioButton { nullptr }; + // QRadioButton* allPagesRadioButton { nullptr }; + // QCheckBox* useRangeCheckBox { nullptr }; + // ScrSpinBox* fromPageSpinBox { nullptr }; + // QLabel* toPageLabel { nullptr }; + // ScrSpinBox* toPageSpinBox { nullptr }; virtual void setup(ScribusDoc* doc, const QString& Nam); virtual QString getMasterPageName(); @@ -63,14 +65,15 @@ public: virtual int getToPage(); protected: - QVBoxLayout* ApplyMasterPageDialogLayout { nullptr }; - QHBoxLayout* templateNameLayout { nullptr }; - QSpacerItem* spacer2 { nullptr }; - QVBoxLayout* applyToPageButtonGroupLayout { nullptr }; - QHBoxLayout* rangeLayout { nullptr }; - QSpacerItem* spacer3 { nullptr }; - QDialogButtonBox* buttonBox { nullptr }; + // QVBoxLayout* ApplyMasterPageDialogLayout { nullptr }; + // QHBoxLayout* templateNameLayout { nullptr }; + // QSpacerItem* spacer2 { nullptr }; + // QVBoxLayout* applyToPageButtonGroupLayout { nullptr }; + // QHBoxLayout* rangeLayout { nullptr }; + // QSpacerItem* spacer3 { nullptr }; + // QDialogButtonBox* buttonBox { nullptr }; + bool facingPages = false; void changeEvent(QEvent *e) override; protected slots: @@ -82,6 +85,7 @@ private slots: virtual void enableRange( bool enabled ); virtual void rangeSelectable(); virtual void singleSelectable(); + virtual void enableItemsSelectable(bool enabled); };