diff --git a/python/PyQt6/core/auto_generated/layout/qgslayoutpagecollection.sip.in b/python/PyQt6/core/auto_generated/layout/qgslayoutpagecollection.sip.in
index 0c2509bbb825..e025acb815c7 100644
--- a/python/PyQt6/core/auto_generated/layout/qgslayoutpagecollection.sip.in
+++ b/python/PyQt6/core/auto_generated/layout/qgslayoutpagecollection.sip.in
@@ -368,6 +368,13 @@ Returns a reference to the collection's guide collection, which manages page sna
%End
+ void applyPropertiesToAllOtherPages( int sourcePage );
+%Docstring
+Apply the source page properties (size & background color) to all other pages
+
+.. versionadded:: 3.42
+%End
+
public slots:
void redraw();
diff --git a/python/core/auto_generated/layout/qgslayoutpagecollection.sip.in b/python/core/auto_generated/layout/qgslayoutpagecollection.sip.in
index 0c2509bbb825..e025acb815c7 100644
--- a/python/core/auto_generated/layout/qgslayoutpagecollection.sip.in
+++ b/python/core/auto_generated/layout/qgslayoutpagecollection.sip.in
@@ -368,6 +368,13 @@ Returns a reference to the collection's guide collection, which manages page sna
%End
+ void applyPropertiesToAllOtherPages( int sourcePage );
+%Docstring
+Apply the source page properties (size & background color) to all other pages
+
+.. versionadded:: 3.42
+%End
+
public slots:
void redraw();
diff --git a/src/core/layout/qgslayoutpagecollection.cpp b/src/core/layout/qgslayoutpagecollection.cpp
index 39140b907333..c49db2e126a9 100644
--- a/src/core/layout/qgslayoutpagecollection.cpp
+++ b/src/core/layout/qgslayoutpagecollection.cpp
@@ -444,6 +444,32 @@ const QgsLayoutGuideCollection &QgsLayoutPageCollection::guides() const
return *mGuideCollection;
}
+void QgsLayoutPageCollection::applyPropertiesToAllOtherPages( int sourcePage )
+{
+ QgsLayoutItemPage *referencePage = page( sourcePage );
+ if ( !referencePage )
+ {
+ return;
+ }
+
+ mLayout->undoStack()->beginCommand( this, tr( "Apply page properties" ) );
+ mBlockUndoCommands = true;
+
+ for ( QgsLayoutItemPage *page : mPages )
+ {
+ if ( page == referencePage )
+ {
+ continue;
+ }
+ page->setPageSize( referencePage->pageSize() );
+ page->setPageStyleSymbol( referencePage->pageStyleSymbol()->clone() );
+ }
+
+ mLayout->undoStack()->endCommand();
+ mBlockUndoCommands = false;
+ mLayout->refresh();
+}
+
void QgsLayoutPageCollection::redraw()
{
const auto constMPages = mPages;
diff --git a/src/core/layout/qgslayoutpagecollection.h b/src/core/layout/qgslayoutpagecollection.h
index 6a4406347e2c..e11640746a3e 100644
--- a/src/core/layout/qgslayoutpagecollection.h
+++ b/src/core/layout/qgslayoutpagecollection.h
@@ -388,6 +388,13 @@ class CORE_EXPORT QgsLayoutPageCollection : public QObject, public QgsLayoutSeri
*/
SIP_SKIP const QgsLayoutGuideCollection &guides() const;
+ /**
+ * Apply the source page properties (size & background color) to all other pages
+ *
+ * \since QGIS 3.42
+ */
+ void applyPropertiesToAllOtherPages( int sourcePage );
+
public slots:
/**
diff --git a/src/gui/layout/qgslayoutpagepropertieswidget.cpp b/src/gui/layout/qgslayoutpagepropertieswidget.cpp
index a03e71e87174..eb700688092b 100644
--- a/src/gui/layout/qgslayoutpagepropertieswidget.cpp
+++ b/src/gui/layout/qgslayoutpagepropertieswidget.cpp
@@ -83,12 +83,16 @@ QgsLayoutPagePropertiesWidget::QgsLayoutPagePropertiesWidget( QWidget *parent, Q
mSymbolButton->registerExpressionContextGenerator( mPage );
mSymbolButton->setLayer( coverageLayer() );
+
+ connect( mApplyToAllButton, &QPushButton::clicked, this, &QgsLayoutPagePropertiesWidget::applyToAll );
+
if ( mPage->layout() )
{
connect( &mPage->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mSymbolButton, &QgsSymbolButton::setLayer );
QgsLayoutPageCollection *pages = mPage->layout()->pageCollection();
- if ( pages->pageCount() > 1 )
+ const bool multiPage = pages->pageCount() > 1;
+ if ( multiPage )
{
const int pageNumber = mPage->layout()->pageCollection()->pageNumber( mPage );
mTitleLabel->setText( tr( "Page (%1/%2)" ).arg( pageNumber + 1 ).arg( pages->pageCount() ) );
@@ -97,6 +101,7 @@ QgsLayoutPagePropertiesWidget::QgsLayoutPagePropertiesWidget( QWidget *parent, Q
{
mTitleLabel->setText( tr( "Page" ) );
}
+ mApplyToAllButton->setVisible( multiPage );
}
@@ -236,3 +241,9 @@ void QgsLayoutPagePropertiesWidget::showCurrentPageSize()
mPageOrientationComboBox->setEnabled( false );
}
}
+
+void QgsLayoutPagePropertiesWidget::applyToAll()
+{
+ QgsLayoutPageCollection *pages = mPage->layout()->pageCollection();
+ pages->applyPropertiesToAllOtherPages( pages->pageNumber( mPage ) );
+}
diff --git a/src/gui/layout/qgslayoutpagepropertieswidget.h b/src/gui/layout/qgslayoutpagepropertieswidget.h
index 2ab0c192a640..b501f8a769ba 100644
--- a/src/gui/layout/qgslayoutpagepropertieswidget.h
+++ b/src/gui/layout/qgslayoutpagepropertieswidget.h
@@ -64,6 +64,7 @@ class GUI_EXPORT QgsLayoutPagePropertiesWidget : public QgsLayoutItemBaseWidget,
void symbolChanged();
void excludeExportsToggled( bool checked );
void refreshLayout();
+ void applyToAll();
private:
diff --git a/src/ui/layout/qgslayoutpagepropertieswidget.ui b/src/ui/layout/qgslayoutpagepropertieswidget.ui
index 9032c17902d3..8e0938dd06f1 100644
--- a/src/ui/layout/qgslayoutpagepropertieswidget.ui
+++ b/src/ui/layout/qgslayoutpagepropertieswidget.ui
@@ -6,7 +6,7 @@
0
0
- 385
+ 407
405
@@ -86,7 +86,7 @@
100.000000000000000
-
+
false
@@ -105,7 +105,7 @@
100.000000000000000
-
+
false
@@ -213,20 +213,14 @@
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
+
-
+
+
+ Background
-
+
- -
+
-
-
@@ -263,14 +257,7 @@
- -
-
-
- Background
-
-
-
- -
+
-
true
@@ -292,6 +279,29 @@
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+ -
+
+
+ Resets all other pages' size and background color to match this page
+
+
+ Apply to all Pages
+
+
+
@@ -338,7 +348,6 @@
mSizeUnitsComboBox
mExcludePageCheckBox
mExcludePageDDBtn
- mSymbolButton