37 mPageSizeComboBox->addItem( size.displayName, size.name );
39 mPageSizeComboBox->addItem( tr(
"Custom" ) );
46 mPageOrientationComboBox->setCurrentIndex( mPageOrientationComboBox->findData( mPage->
orientation() ) );
48 mSizeUnitsComboBox->linkToWidget( mWidthSpin );
49 mSizeUnitsComboBox->linkToWidget( mHeightSpin );
52 mLockAspectRatio->setWidthSpinBox( mWidthSpin );
53 mLockAspectRatio->setHeightSpinBox( mHeightSpin );
58 connect( mPageSizeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutPagePropertiesWidget::pageSizeChanged );
59 connect( mPageOrientationComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutPagePropertiesWidget::orientationChanged );
61 connect( mWidthSpin,
static_cast< void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutPagePropertiesWidget::updatePageSize );
62 connect( mHeightSpin,
static_cast< void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutPagePropertiesWidget::updatePageSize );
63 connect( mWidthSpin,
static_cast< void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutPagePropertiesWidget::setToCustomSize );
64 connect( mHeightSpin,
static_cast< void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutPagePropertiesWidget::setToCustomSize );
65 connect( mExcludePageCheckBox, &QCheckBox::toggled,
this, &QgsLayoutPagePropertiesWidget::excludeExportsToggled );
79 mExcludePageDDBtn->registerEnabledWidget( mExcludePageCheckBox,
false );
81 mSymbolButton->registerExpressionContextGenerator( mPage );
88 showCurrentPageSize();
91 void QgsLayoutPagePropertiesWidget::pageSizeChanged(
int )
93 mBlockPageUpdate =
true;
94 if ( mPageSizeComboBox->currentData().toString().isEmpty() )
97 mLockAspectRatio->setEnabled(
true );
98 mSizeUnitsComboBox->setEnabled(
true );
99 mPageOrientationComboBox->setEnabled(
false );
103 mLockAspectRatio->setEnabled(
false );
104 mLockAspectRatio->setLocked(
false );
105 mSizeUnitsComboBox->setEnabled(
false );
106 mPageOrientationComboBox->setEnabled(
true );
109 mSettingPresetSize =
true;
110 switch ( mPageOrientationComboBox->currentData().toInt() )
113 mWidthSpin->setValue( convertedSize.
height() );
114 mHeightSpin->setValue( convertedSize.
width() );
118 mWidthSpin->setValue( convertedSize.
width() );
119 mHeightSpin->setValue( convertedSize.
height() );
122 mSettingPresetSize =
false;
124 mBlockPageUpdate =
false;
128 void QgsLayoutPagePropertiesWidget::orientationChanged(
int )
130 if ( mPageSizeComboBox->currentData().toString().isEmpty() )
133 double width = mWidthSpin->value();
134 double height = mHeightSpin->value();
135 switch ( mPageOrientationComboBox->currentData().toInt() )
138 if ( width < height )
146 if ( width > height )
157 void QgsLayoutPagePropertiesWidget::updatePageSize()
159 if ( mBlockPageUpdate )
175 void QgsLayoutPagePropertiesWidget::setToCustomSize()
177 if ( mSettingPresetSize )
179 whileBlocking( mPageSizeComboBox )->setCurrentIndex( mPageSizeComboBox->count() - 1 );
180 mPageOrientationComboBox->setEnabled(
false );
183 void QgsLayoutPagePropertiesWidget::symbolChanged()
186 mPage->
setPageStyleSymbol( static_cast< QgsFillSymbol * >( mSymbolButton->symbol() )->clone() );
190 void QgsLayoutPagePropertiesWidget::excludeExportsToggled(
bool checked )
192 mPage->
beginCommand( !checked ? tr(
"Include Page in Exports" ) : tr(
"Exclude Page from Exports" ) );
197 void QgsLayoutPagePropertiesWidget::refreshLayout()
202 void QgsLayoutPagePropertiesWidget::showCurrentPageSize()
206 if ( !pageSize.isEmpty() )
208 whileBlocking( mPageSizeComboBox )->setCurrentIndex( mPageSizeComboBox->findData( pageSize ) );
209 mLockAspectRatio->setEnabled(
false );
210 mLockAspectRatio->setLocked(
false );
211 mSizeUnitsComboBox->setEnabled(
false );
212 mPageOrientationComboBox->setEnabled(
true );
217 whileBlocking( mPageSizeComboBox )->setCurrentIndex( mPageSizeComboBox->count() - 1 );
218 mLockAspectRatio->setEnabled(
true );
219 mSizeUnitsComboBox->setEnabled(
true );
220 mPageOrientationComboBox->setEnabled(
false );
void beginCommand(const QString &commandText, UndoCommand command=UndoNone)
Starts new undo command for this item.
int pageNumber(QgsLayoutItemPage *page) const
Returns the page number for the specified page, or -1 if the page is not contained in the collection...
Base class for graphical items within a QgsLayout.
QgsLayoutUndoStack * undoStack()
Returns a pointer to the layout's undo stack, which manages undo/redo states for the layout and it's ...
QgsLayoutMeasurement convert(QgsLayoutMeasurement measurement, QgsUnitTypes::LayoutUnit targetUnits) const
Converts a measurement from one unit to another.
Exclude item from exports.
Layout page symbol change.
void setPageStyleSymbol(QgsFillSymbol *symbol)
Sets the symbol to use for drawing the page background.
QgsLayoutPagePropertiesWidget(QWidget *parent, QgsLayoutItem *page)
Constructor for QgsLayoutPagePropertiesWidget.
void pageOrientationChanged()
Emitted when page orientation changes.
QgsLayoutRenderContext & renderContext()
Returns a reference to the layout's render context, which stores information relating to the current ...
QList< QgsPageSize > entries() const
Returns a list of page sizes in the registry.
QList< QgsPageSize > find(const QString &name) const
Finds matching page sizes from the registry, using a case insensitive match on the page size name...
void beginPageSizeChange()
Should be called before changing any page item sizes, and followed by a call to endPageSizeChange().
const QgsFillSymbol * pageStyleSymbol() const
Returns the symbol to use for drawing the page background.
void setExcludeFromExports(bool exclude)
Sets whether the item should be excluded from layout exports and prints.
void endCommand()
Saves final state of an object and pushes the active command to the undo history. ...
const QgsLayout * layout() const
Returns the layout the object is attached to.
void endCommand()
Completes the current item command and push it onto the layout's undo stack.
void refresh()
Forces the layout, and all items contained within it, to refresh.
QgsFillSymbol * clone() const override
Returns a deep copy of this symbol.
QgsLayoutPageCollection * pageCollection()
Returns a pointer to the layout's page collection, which stores and manages page items in the layout...
Orientation orientation() const
Returns the page orientation.
QgsUnitTypes::LayoutUnit units() const
Returns the units for the size.
void layerChanged(QgsVectorLayer *layer)
Emitted when the context's layer is changed.
void beginMacro(const QString &commandText)
Starts a macro command, with the given descriptive commandText.
void beginCommand(QgsLayoutUndoObjectInterface *object, const QString &commandText, int id=0)
Begins a new undo command for the specified object.
QgsLayoutReportContext & reportContext()
Returns a reference to the layout's report context, which stores information relating to the current ...
QgsLayoutSize pageSize() const
Returns the size of the page.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
const QgsLayoutMeasurementConverter & measurementConverter() const
Returns the layout measurement converter to be used in the layout.
static QgsPageSizeRegistry * pageSizeRegistry()
Returns the application's page size registry, used for managing layout page sizes.
A named page size for layouts.
Preset paper size for composition.
bool excludeFromExports() const
Returns whether the item should be excluded from layout exports and prints.
void setPageSize(const QgsLayoutSize &size)
Sets the size of the page.
void endPageSizeChange()
Should be called after changing any page item sizes, and preceded by a call to beginPageSizeChange()...
void endMacro()
Ends a macro command.
void reflow()
Forces the page collection to reflow the arrangement of pages, e.g.
This class provides a method of storing sizes, consisting of a width and height, for use in QGIS layo...
QgsLayoutSize size
Page size.
double height() const
Returns the height of the size.
Item representing the paper in a layout.
double width() const
Returns the width of the size.