View Issue Details

IDProjectCategoryView StatusLast Update
0002341ScribusUser Interfacepublic2025-06-12 21:01
Reporterjo-hannes Assigned Toale  
PrioritynormalSeverityfeatureReproducibilityalways
Status assignedResolutionopen 
PlatformanyOSanyOS Versionany
Product Version1.3 
Summary0002341: [PATCH] apply masterpage: change the range fields to one field where user defined pages can be entered (like 1-4,7,9)
Description.
TagsNo tags attached.
PatchYes

Relationships

child of 0003837 acknowledged Metabug: Master pages/Page templates 

Activities

mhanski

2006-04-08 16:53

developer   ~0009702

why would it be better than the current solution?

jo-hannes

2006-04-08 22:15

developer   ~0009733

i have 20 pages and want to apply masterpage 1 to pages 2,5,6,8,13. that could be done easier.

compare with the print dialog, i suggested user defined ranges there too and you have it in nearly any program

louisdesjardins

2006-04-09 02:38

developer   ~0009740

Nice! Agree.

cbradney

2006-04-21 21:41

administrator   ~0010273

Disagree with the idea of changing the existing functionality. Agree with adding this as a 5th option.

louisdesjardins

2006-04-21 22:01

developer   ~0010275

Yes.

mhanski

2006-05-04 21:22

developer   ~0010931

acknowledging as per note by cbradney

ale

2025-06-12 21:01

manager   ~0052752

- created an .ui file
- added the fifth option
- moved most of the functionality from scribus.cpp to ui/applytemplatedialog.cpp
- removed languageChange(), since it's a modal dialog.
- using modern signals

it would be a good idea to rename ui/applytemplatedialog.h to ui/applymasterpagedialog.h (the same for the .cpp) to match the class name... but it's easier to do for you directly on svn rather than getting it from the diff.
apply-master-page-to-range.diff (24,237 bytes)   
From 972d392513c7589bb3a1064f9cde8d6630d7d564 Mon Sep 17 00:00:00 2001
From: ale rimoldi <ale@graphicslab.org>
Date: Thu, 12 Jun 2025 22:59:48 +0200
Subject: add the comma separated ranges, create an .ui, and some refactoring


diff --git a/scribus/scribus.cpp b/scribus/scribus.cpp
index d82ebbab1..36d930e63 100644
--- a/scribus/scribus.cpp
+++ b/scribus/scribus.cpp
@@ -7642,38 +7642,18 @@ void ScribusMainWindow::ApplyMasterPage()
 		return;
 
 	QString masterPageName(dia->getMasterPageName());
-	int pageSelection = dia->getPageSelection(); //0=current, 1=even, 2=odd, 3=all
+	QList<int> pages = dia->getPagesSelected();
 
-	int startPage, endPage;
-	if (pageSelection == 0)
-	{
-		startPage = doc->currentPage()->pageNr();
-		endPage = doc->currentPage()->pageNr() + 1;
-	}
-	else if (dia->usingRange())
-	{
-		startPage = dia->getFromPage() - 1; //Pages start from 0, not 1
-		endPage = dia->getToPage();
-	}
-	else
-	{
-		startPage = pageSelection == 1 ? 1 : 0; //if even, startPage is 1 (real page 2)
-		endPage = doc->DocPages.count();
-	}
+	if (pages.empty())
+		return;
 
 	UndoTransaction trans;
-	if (UndoManager::undoEnabled() && (startPage + 1 < endPage))
+	if (UndoManager::undoEnabled())
 		trans = m_undoManager->beginTransaction(QString(), nullptr, Um::ApplyMasterPage, masterPageName);
 
-	for (int pageNum = startPage; pageNum < endPage; ++pageNum)
+	for (int page: pages)
 	{
-		//Increment by 1 and not 2 even for even/odd application as user
-		//can select to eg apply to even pages with a single odd page selected
-		if (pageSelection == 1 && (pageNum % 2 == 0)) //Even, %2!=0 as 1st page is numbered 0
-			continue;
-		if (pageSelection == 2 && (pageNum % 2 != 0))  //Odd, %2==0 as 1st page is numbered 0
-			continue;
-		Apply_MasterPage(masterPageName, pageNum, false);
+		Apply_MasterPage(masterPageName, page, false);
 	}
 
 	if (trans)
diff --git a/scribus/ui/applymasterpagedialog.ui b/scribus/ui/applymasterpagedialog.ui
new file mode 100644
index 000000000..7ca07fa63
--- /dev/null
+++ b/scribus/ui/applymasterpagedialog.ui
@@ -0,0 +1,283 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ApplyMasterPageDialog</class>
+ <widget class="QDialog" name="ApplyMasterPageDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>302</width>
+    <height>299</height>
+   </rect>
+  </property>
+  <property name="sizePolicy">
+   <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </property>
+  <property name="windowTitle">
+   <string>Apply Master Page</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <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="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QLabel" name="masterPageLabel">
+       <property name="text">
+        <string>&amp;Master page</string>
+       </property>
+       <property name="buddy">
+        <cstring>masterPageComboBox</cstring>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Orientation::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QComboBox" name="masterPageComboBox"/>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="QGroupBox" name="applyToPageButtonGroup">
+     <property name="title">
+      <string>Apply to</string>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout_2">
+      <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="QRadioButton" name="currentPageRadioButton">
+        <property name="text">
+         <string>Current &amp;page</string>
+        </property>
+        <property name="checked">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QRadioButton" name="evenPagesRadioButton">
+        <property name="text">
+         <string>&amp;Even pages</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QRadioButton" name="oddPagesRadioButton">
+        <property name="text">
+         <string>O&amp;dd pages</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QRadioButton" name="allPagesRadioButton">
+        <property name="text">
+         <string>&amp;All pages</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <layout class="QHBoxLayout" name="customRangeLayout">
+        <property name="spacing">
+         <number>4</number>
+        </property>
+        <item>
+         <widget class="QRadioButton" name="customRangeRadioButton">
+          <property name="toolTip">
+           <string>Apply the selected master page to the list of comma separated pages (or ranges)</string>
+          </property>
+          <property name="text">
+           <string>Custom &amp;range</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLineEdit" name="customRangeLineEdit">
+          <property name="enabled">
+           <bool>false</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <spacer name="horizontalSpacer_3">
+          <property name="orientation">
+           <enum>Qt::Orientation::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="rangeLayout">
+        <property name="spacing">
+         <number>4</number>
+        </property>
+        <item>
+         <widget class="QCheckBox" name="useRangeCheckBox">
+          <property name="enabled">
+           <bool>false</bool>
+          </property>
+          <property name="toolTip">
+           <string>Apply the selected master page to even, odd or all pages within the following range</string>
+          </property>
+          <property name="text">
+           <string>&amp;Within range</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="ScrSpinBox" name="fromPageSpinBox">
+          <property name="enabled">
+           <bool>false</bool>
+          </property>
+          <property name="suffix">
+           <string notr="true"/>
+          </property>
+          <property name="decimals">
+           <number>0</number>
+          </property>
+          <property name="minimum">
+           <double>1.000000000000000</double>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLabel" name="toPageLabel">
+          <property name="enabled">
+           <bool>false</bool>
+          </property>
+          <property name="text">
+           <string>to</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="ScrSpinBox" name="toPageSpinBox">
+          <property name="enabled">
+           <bool>false</bool>
+          </property>
+          <property name="suffix">
+           <string notr="true"/>
+          </property>
+          <property name="decimals">
+           <number>0</number>
+          </property>
+          <property name="minimum">
+           <double>1.000000000000000</double>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <spacer name="horizontalSpacer_2">
+          <property name="orientation">
+           <enum>Qt::Orientation::Horizontal</enum>
+          </property>
+          <property name="sizeHint" stdset="0">
+           <size>
+            <width>40</width>
+            <height>20</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+       </layout>
+      </item>
+     </layout>
+    </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>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>ScrSpinBox</class>
+   <extends>QDoubleSpinBox</extends>
+   <header>ui/scrspinbox.h</header>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>ApplyMasterPageDialog</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>ApplyMasterPageDialog</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>
diff --git a/scribus/ui/applytemplatedialog.cpp b/scribus/ui/applytemplatedialog.cpp
index 666896549..c92d6b767 100644
--- a/scribus/ui/applytemplatedialog.cpp
+++ b/scribus/ui/applytemplatedialog.cpp
@@ -15,130 +15,40 @@ for which a new license (GPL+exception) is in place.
 #include "applytemplatedialog.h"
 
 #include <QCheckBox>
-#include <QComboBox>
-#include <QEvent>
-#include <QGroupBox>
-#include <QHBoxLayout>
-#include <QLabel>
-#include <QPushButton>
 #include <QRadioButton>
-#include <QSpacerItem>
-#include <QSpinBox>
-#include <QToolTip>
-#include <QVBoxLayout>
 
 #include "commonstrings.h"
+#include "util.h" // for parsePagesString
 #include "scpage.h"
 #include "scribusdoc.h"
 #include "iconmanager.h"
 
-enum {
-    CurrentPage,
-    EvenPages,
-    OddPages,
-    AllPages
-};
-
-/*
- *  Constructs a ApplyMasterPageDialog as a child of 'parent', with the
- *  name 'name' and widget flags set to 'f'.
- *
- *  The dialog will by default be modeless, unless you set 'modal' to
- *  true to construct a modal dialog.
- */
-ApplyMasterPageDialog::ApplyMasterPageDialog( QWidget* parent ) : QDialog( parent )
+ApplyMasterPageDialog::ApplyMasterPageDialog(QWidget* parent) : QDialog(parent)
 {
+	setupUi(this);
 	setModal(true);
-	setWindowTitle( tr( "Apply Master Page" ));
 	setWindowIcon(IconManager::instance().loadIcon("app-icon"));
-	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 );
+	resize(QSize(268, 230).expandedTo(minimumSizeHint()));
 
-	fromPageSpinBox = new ScrSpinBox( applyToPageButtonGroup );
-	fromPageSpinBox->setEnabled( false );
-	fromPageSpinBox->setMinimum( 1 );
-	fromPageSpinBox->setDecimals(0);
-	fromPageSpinBox->setSuffix("");
-	rangeLayout->addWidget( fromPageSpinBox );
+	connect(useRangeCheckBox, qOverload<bool>(&QCheckBox::toggled), this, &ApplyMasterPageDialog::enableRange);
+	connect(currentPageRadioButton, &QCheckBox::clicked, this, &ApplyMasterPageDialog::singleSelectable);
+	connect(evenPagesRadioButton, &QCheckBox::clicked, this, &ApplyMasterPageDialog::rangeSelectable);
+	connect(oddPagesRadioButton, &QCheckBox::clicked, this, &ApplyMasterPageDialog::rangeSelectable);
+	connect(allPagesRadioButton, &QCheckBox::clicked, this, &ApplyMasterPageDialog::rangeSelectable);
+	connect(customRangeRadioButton, &QRadioButton::toggled, this, &ApplyMasterPageDialog::customRangeEditable);
 
-	toPageLabel = new QLabel( applyToPageButtonGroup );
-	rangeLayout->addWidget( toPageLabel );
+	connect(fromPageSpinBox, qOverload<double>(&ScrSpinBox::valueChanged), this, &ApplyMasterPageDialog::checkRangeFrom);
+	connect(toPageSpinBox, qOverload<double>(&ScrSpinBox::valueChanged), this, &ApplyMasterPageDialog::checkRangeTo);
 
-	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();
-	resize( QSize(268, 230).expandedTo(minimumSizeHint()) );
-
-	// signals and slots connections
-	connect( useRangeCheckBox, SIGNAL( toggled(bool) ), this, SLOT( enableRange(bool) ) );
-	connect( currentPageRadioButton, SIGNAL( clicked() ), this, SLOT( singleSelectable() ) );
-	connect( evenPagesRadioButton, SIGNAL( clicked() ), this, SLOT( rangeSelectable() ) );
-	connect( oddPagesRadioButton, SIGNAL( clicked() ), this, SLOT( rangeSelectable() ) );
-	connect( allPagesRadioButton, SIGNAL( clicked() ), this, SLOT( rangeSelectable() ) );
-	connect( fromPageSpinBox, SIGNAL( valueChanged(double) ), this, SLOT( checkRangeFrom() ) );
-	connect( toPageSpinBox, SIGNAL( valueChanged(double) ), this, SLOT( checkRangeTo() ) );
 	connect(buttonBox, &QDialogButtonBox::accepted, this, &ApplyMasterPageDialog::accept);
 	connect(buttonBox, &QDialogButtonBox::rejected, this, &ApplyMasterPageDialog::reject);
-
-	// buddies
-	masterPageLabel->setBuddy( masterPageComboBox );
 }
 
 void ApplyMasterPageDialog::setup(ScribusDoc *doc, const QString& Nam)
 {
+	m_doc = doc;
+
 	QString na = (Nam == CommonStrings::masterPageNormal) ? CommonStrings::trMasterPageNormal : Nam;
 	QString in;
 
@@ -167,36 +77,32 @@ QString ApplyMasterPageDialog::getMasterPageName()
 	return masterPageComboBox->itemData(currentIndex).toString();
 }
 
-
-int ApplyMasterPageDialog::getPageSelection()
-{
-	if (currentPageRadioButton->isChecked())
-		return CurrentPage;
-	if (evenPagesRadioButton->isChecked())
-		return EvenPages;
-	if (oddPagesRadioButton->isChecked())
-		return OddPages;
-	return AllPages;
-}
-
 void ApplyMasterPageDialog::checkRangeFrom()
 {
-	disconnect(fromPageSpinBox, SIGNAL(valueChanged(double)), this, SLOT(checkRangeFrom()));
-	disconnect(toPageSpinBox, SIGNAL(valueChanged(double)), this, SLOT(checkRangeTo()));
 	if (fromPageSpinBox->value() > toPageSpinBox->value())
+	{
+		const bool fromWasBlocked = fromPageSpinBox->blockSignals(true);
+		const bool toWasBlocked = toPageSpinBox->blockSignals(true);
+
 		toPageSpinBox->setValue(fromPageSpinBox->value());
-	connect(fromPageSpinBox, SIGNAL(valueChanged(double)), this, SLOT(checkRangeFrom()));
-	connect(toPageSpinBox, SIGNAL(valueChanged(double)), this, SLOT(checkRangeTo()));
+
+		toPageSpinBox->blockSignals(toWasBlocked);
+		fromPageSpinBox->blockSignals(fromWasBlocked);
+	}
 }
 
 void ApplyMasterPageDialog::checkRangeTo()
 {
-	disconnect(fromPageSpinBox, SIGNAL(valueChanged(double)), this, SLOT(checkRangeFrom()));
-	disconnect(toPageSpinBox, SIGNAL(valueChanged(double)), this, SLOT(checkRangeTo()));
 	if (toPageSpinBox->value() < fromPageSpinBox->value())
+	{
+		const bool fromWasBlocked = fromPageSpinBox->blockSignals(true);
+		const bool toWasBlocked = toPageSpinBox->blockSignals(true);
+
 		fromPageSpinBox->setValue(toPageSpinBox->value());
-	connect(fromPageSpinBox, SIGNAL(valueChanged(double)), this, SLOT(checkRangeFrom()));
-	connect(toPageSpinBox, SIGNAL(valueChanged(double)), this, SLOT(checkRangeTo()));
+
+		toPageSpinBox->blockSignals(toWasBlocked);
+		fromPageSpinBox->blockSignals(fromWasBlocked);
+	}
 }
 
 void ApplyMasterPageDialog::enableRange( bool enabled )
@@ -209,6 +115,7 @@ void ApplyMasterPageDialog::rangeSelectable()
 {
 	useRangeCheckBox->setEnabled(true);
 	enableRange(useRangeCheckBox->isChecked());
+	customRangeLineEdit->setEnabled(false);
 }
 
 void ApplyMasterPageDialog::singleSelectable()
@@ -218,18 +125,20 @@ void ApplyMasterPageDialog::singleSelectable()
 	toPageSpinBox->setEnabled(false);
 }
 
-
-bool ApplyMasterPageDialog::usingRange()
+void ApplyMasterPageDialog::customRangeEditable(bool enabled)
 {
-	return useRangeCheckBox->isChecked();
+	if (enabled)
+	{
+		singleSelectable();
+	}
+	customRangeLineEdit->setEnabled(enabled);
 }
 
-
 int ApplyMasterPageDialog::getFromPage()
 {
 	if (useRangeCheckBox->isChecked())
-		return static_cast<int>(fromPageSpinBox->value());
-	return -1;
+		return static_cast<int>(fromPageSpinBox->value()) - 1; // pages start from 0, not 1;
+	return 0;
 }
 
 
@@ -237,34 +146,39 @@ int ApplyMasterPageDialog::getToPage()
 {
 	if (useRangeCheckBox->isChecked())
 		return static_cast<int>(toPageSpinBox->value());
-	return -1;
+	return m_doc->DocPages.count();
 }
 
-void ApplyMasterPageDialog::changeEvent(QEvent *e)
+QList<int> ApplyMasterPageDialog::getPagesSelected()
 {
-	if (e->type() == QEvent::LanguageChange)
+	QList<int>pagesSelected;
+
+	if (currentPageRadioButton->isChecked())
 	{
-		languageChange();
+		pagesSelected.push_back(m_doc->currentPage()->pageNr());
+		return pagesSelected;
 	}
-	else
-		QWidget::changeEvent(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( "<qt>" + tr( "Apply the selected master page to even, odd or all pages within the following range") + "</qt>" );
-	toPageLabel->setText( tr( "to" ) );
+	if (customRangeRadioButton->isChecked())
+	{
+		QString customRange = customRangeLineEdit->text();
+		std::vector<int> stdPagesSelected;
+		parsePagesString(customRange, &stdPagesSelected, m_doc->DocPages.count());
+		return QList<int>(stdPagesSelected.begin(), stdPagesSelected.end());
+	}
+
+	int start = getFromPage();
+	int end = getToPage();
+
+	for (int i = start; i < end; i++)
+	{
+		// even if i % 2 != 0, since the first page is 0
+		if (evenPagesRadioButton->isChecked() && i % 2 == 0)
+			continue;
+		else if (oddPagesRadioButton->isChecked() && i % 2 != 0)
+			continue;
+		pagesSelected.push_back(i);
+	}
+
+	return pagesSelected;
 }
diff --git a/scribus/ui/applytemplatedialog.h b/scribus/ui/applytemplatedialog.h
index 71dd7fef4..05dd1c3b0 100644
--- a/scribus/ui/applytemplatedialog.h
+++ b/scribus/ui/applytemplatedialog.h
@@ -19,23 +19,14 @@ for which a new license (GPL+exception) is in place.
 #include <QDialogButtonBox>
 #include <QString>
 
+#include "ui_applymasterpagedialog.h"
+
 #include "scribusapi.h"
-#include "scribusdoc.h"
-#include "scpage.h"
-#include "ui/scrspinbox.h"
 
-class QCheckBox;
-class QComboBox;
-class QEvent;
-class QGroupBox;
-class QHBoxLayout;
-class QLabel;
-class QPushButton;
-class QRadioButton;
-class QSpacerItem;
-class QVBoxLayout;
+class ScribusDoc;
+
 
-class SCRIBUS_API ApplyMasterPageDialog : public QDialog
+class SCRIBUS_API ApplyMasterPageDialog : public QDialog, Ui::ApplyMasterPageDialog
 {
 	Q_OBJECT
 
@@ -43,46 +34,22 @@ 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 };
-
 	virtual void setup(ScribusDoc* doc, const QString& Nam);
-	virtual QString getMasterPageName();
-	virtual int getPageSelection();
-	virtual bool usingRange();
-	virtual int getFromPage();
-	virtual int getToPage();
+	QString getMasterPageName();
+	int getFromPage();
+	int getToPage();
+	QList<int> getPagesSelected();
 
-protected:
-	QVBoxLayout* ApplyMasterPageDialogLayout { nullptr };
-	QHBoxLayout* templateNameLayout { nullptr };
-	QSpacerItem* spacer2 { nullptr };
-	QVBoxLayout* applyToPageButtonGroupLayout { nullptr };
-	QHBoxLayout* rangeLayout { nullptr };
-	QSpacerItem* spacer3 { nullptr };
-	QDialogButtonBox* buttonBox { nullptr };
-	
-	void changeEvent(QEvent *e) override;
-
-protected slots:
-	virtual void languageChange();
+private:
+	ScribusDoc* m_doc = nullptr;
 
 private slots:
-	virtual void checkRangeFrom();
-	virtual void checkRangeTo();
-	virtual void enableRange( bool enabled );
-	virtual void rangeSelectable();
-	virtual void singleSelectable();
-
+	void checkRangeFrom();
+	void checkRangeTo();
+	void enableRange( bool enabled );
+	void rangeSelectable();
+	void singleSelectable();
+	void customRangeEditable(bool enabled);
 };
 
 #endif // APPLYMASTERPAGEDIALOG_H
apply-master-page-to-range.diff (24,237 bytes)   

Issue History

Date Modified Username Field Change
2005-08-01 11:00 jo-hannes New Issue
2006-04-08 16:52 mhanski Severity minor => feature
2006-04-08 16:53 mhanski Note Added: 0009702
2006-04-08 22:15 jo-hannes Note Added: 0009733
2006-04-09 02:38 louisdesjardins Note Added: 0009740
2006-04-21 18:36 mhanski OS => any
2006-04-21 18:36 mhanski OS Version => any
2006-04-21 18:36 mhanski Platform => any
2006-04-21 18:36 mhanski Product Version 1.3.1cvs => 1.3
2006-04-21 18:38 mhanski Status new => feedback
2006-04-21 21:41 cbradney Note Added: 0010273
2006-04-21 22:01 louisdesjardins Note Added: 0010275
2006-05-04 21:22 mhanski Note Added: 0010931
2006-05-04 21:22 mhanski Status feedback => acknowledged
2006-05-18 18:09 christoph_s Relationship added related to 0003837
2006-05-18 18:17 christoph_s Relationship replaced child of 0003837
2025-06-12 21:01 ale Note Added: 0052752
2025-06-12 21:01 ale File Added: apply-master-page-to-range.diff
2025-06-12 21:01 ale Assigned To => ale
2025-06-12 21:01 ale Status acknowledged => assigned
2025-06-12 21:01 ale Summary apply masterpage: change the range fields to one field where user defined pages can be entered (like 1-4,7,9) => [PATCH] apply masterpage: change the range fields to one field where user defined pages can be entered (like 1-4,7,9)
2025-06-12 21:01 ale Patch => Yes