37 mVariableEditor->setMinimumHeight( mVariableEditor->fontMetrics().height() * 15 );
39 updateSnappingElements();
41 mGridSpacingUnitsCombo->linkToWidget( mGridResolutionSpinBox );
42 mGridOffsetUnitsComboBox->linkToWidget( mOffsetXSpinBox );
43 mGridOffsetUnitsComboBox->linkToWidget( mOffsetYSpinBox );
45 blockSignals(
false );
47 connect( mSnapToleranceSpinBox, static_cast <
void ( QSpinBox::* )(
int ) > ( &QSpinBox::valueChanged ),
this, &QgsLayoutPropertiesWidget::snapToleranceChanged );
51 connect( mGridResolutionSpinBox, static_cast <
void (
QgsDoubleSpinBox::* )(
double ) > ( &QgsDoubleSpinBox::valueChanged ),
this, &QgsLayoutPropertiesWidget::gridResolutionChanged );
52 connect( mOffsetXSpinBox, static_cast <
void (
QgsDoubleSpinBox::* )(
double ) > ( &QgsDoubleSpinBox::valueChanged ),
this, &QgsLayoutPropertiesWidget::gridOffsetXChanged );
53 connect( mOffsetYSpinBox, static_cast <
void (
QgsDoubleSpinBox::* )(
double ) > ( &QgsDoubleSpinBox::valueChanged ),
this, &QgsLayoutPropertiesWidget::gridOffsetYChanged );
55 double leftMargin = mLayout->
customProperty( QStringLiteral(
"resizeToContentsLeftMargin" ) ).toDouble();
56 double topMargin = mLayout->
customProperty( QStringLiteral(
"resizeToContentsTopMargin" ) ).toDouble();
57 double bottomMargin = mLayout->
customProperty( QStringLiteral(
"resizeToContentsBottomMargin" ) ).toDouble();
58 double rightMargin = mLayout->
customProperty( QStringLiteral(
"resizeToContentsRightMargin" ) ).toDouble();
62 bool exportWorldFile = mLayout->
customProperty( QStringLiteral(
"exportWorldFile" ),
false ).toBool();
63 mGenerateWorldFileCheckBox->setChecked( exportWorldFile );
64 connect( mGenerateWorldFileCheckBox, &QCheckBox::toggled,
this, &QgsLayoutPropertiesWidget::worldFileToggled );
66 connect( mRasterizeCheckBox, &QCheckBox::toggled,
this, &QgsLayoutPropertiesWidget::rasterizeToggled );
67 connect( mForceVectorCheckBox, &QCheckBox::toggled,
this, &QgsLayoutPropertiesWidget::forceVectorToggled );
69 mTopMarginSpinBox->setValue( topMargin );
70 mMarginUnitsComboBox->linkToWidget( mTopMarginSpinBox );
71 mRightMarginSpinBox->setValue( rightMargin );
72 mMarginUnitsComboBox->linkToWidget( mRightMarginSpinBox );
73 mBottomMarginSpinBox->setValue( bottomMargin );
74 mMarginUnitsComboBox->linkToWidget( mBottomMarginSpinBox );
75 mLeftMarginSpinBox->setValue( leftMargin );
76 mMarginUnitsComboBox->linkToWidget( mLeftMarginSpinBox );
77 mMarginUnitsComboBox->setUnit( marginUnit );
80 connect( mTopMarginSpinBox, static_cast <
void ( QDoubleSpinBox::* )(
double ) > ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutPropertiesWidget::resizeMarginsChanged );
81 connect( mRightMarginSpinBox, static_cast <
void ( QDoubleSpinBox::* )(
double ) > ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutPropertiesWidget::resizeMarginsChanged );
82 connect( mBottomMarginSpinBox, static_cast <
void ( QDoubleSpinBox::* )(
double ) > ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutPropertiesWidget::resizeMarginsChanged );
83 connect( mLeftMarginSpinBox, static_cast <
void ( QDoubleSpinBox::* )(
double ) > ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutPropertiesWidget::resizeMarginsChanged );
84 connect( mResizePageButton, &QPushButton::clicked,
this, &QgsLayoutPropertiesWidget::resizeToContents );
86 connect( mResolutionSpinBox, static_cast <
void ( QSpinBox::* )(
int ) > ( &QSpinBox::valueChanged ),
this, &QgsLayoutPropertiesWidget::dpiChanged );
88 mReferenceMapComboBox->setCurrentLayout( mLayout );
109 if (
QgsPrintLayout *printLayout = dynamic_cast< QgsPrintLayout * >( masterLayout ) )
121 bool rasterize = mLayout->
customProperty( QStringLiteral(
"rasterize" ),
false ).toBool();
122 whileBlocking( mRasterizeCheckBox )->setChecked( rasterize );
124 bool forceVectors = mLayout->
customProperty( QStringLiteral(
"forceVector" ),
false ).toBool();
125 whileBlocking( mForceVectorCheckBox )->setChecked( forceVectors );
129 mForceVectorCheckBox->setChecked(
false );
130 mForceVectorCheckBox->setEnabled(
false );
134 mForceVectorCheckBox->setEnabled(
true );
138 void QgsLayoutPropertiesWidget::updateSnappingElements()
150 void QgsLayoutPropertiesWidget::gridResolutionChanged(
double d )
166 void QgsLayoutPropertiesWidget::gridOffsetXChanged(
double d )
174 void QgsLayoutPropertiesWidget::gridOffsetYChanged(
double d )
190 void QgsLayoutPropertiesWidget::snapToleranceChanged(
int tolerance )
195 void QgsLayoutPropertiesWidget::resizeMarginsChanged()
197 mLayout->
setCustomProperty( QStringLiteral(
"resizeToContentsLeftMargin" ), mLeftMarginSpinBox->value() );
198 mLayout->
setCustomProperty( QStringLiteral(
"resizeToContentsTopMargin" ), mTopMarginSpinBox->value() );
199 mLayout->
setCustomProperty( QStringLiteral(
"resizeToContentsBottomMargin" ), mBottomMarginSpinBox->value() );
200 mLayout->
setCustomProperty( QStringLiteral(
"resizeToContentsRightMargin" ), mRightMarginSpinBox->value() );
201 mLayout->
setCustomProperty( QStringLiteral(
"imageCropMarginUnit" ), mMarginUnitsComboBox->unit() );
204 void QgsLayoutPropertiesWidget::resizeToContents()
209 mTopMarginSpinBox->value(),
210 mRightMarginSpinBox->value(),
211 mBottomMarginSpinBox->value() ),
212 mMarginUnitsComboBox->unit() );
217 void QgsLayoutPropertiesWidget::referenceMapChanged(
QgsLayoutItem *item )
225 void QgsLayoutPropertiesWidget::dpiChanged(
int value )
232 void QgsLayoutPropertiesWidget::worldFileToggled()
234 mLayout->
setCustomProperty( QStringLiteral(
"exportWorldFile" ), mGenerateWorldFileCheckBox->isChecked() );
237 void QgsLayoutPropertiesWidget::rasterizeToggled()
239 mLayout->
setCustomProperty( QStringLiteral(
"rasterize" ), mRasterizeCheckBox->isChecked() );
241 if ( mRasterizeCheckBox->isChecked() )
243 mForceVectorCheckBox->setChecked(
false );
244 mForceVectorCheckBox->setEnabled(
false );
248 mForceVectorCheckBox->setEnabled(
true );
252 void QgsLayoutPropertiesWidget::forceVectorToggled()
254 mLayout->
setCustomProperty( QStringLiteral(
"forceVector" ), mForceVectorCheckBox->isChecked() );
257 void QgsLayoutPropertiesWidget::variablesChanged()
259 mBlockVariableUpdates =
true;
261 mBlockVariableUpdates =
false;
264 void QgsLayoutPropertiesWidget::updateVariables()
266 if ( mBlockVariableUpdates )
273 mVariableEditor->setContext( &context );
274 mVariableEditor->setEditableScopeIndex( 2 );
277 void QgsLayoutPropertiesWidget::blockSignals(
bool block )
279 mGridResolutionSpinBox->blockSignals( block );
280 mOffsetXSpinBox->blockSignals( block );
281 mOffsetYSpinBox->blockSignals( block );
282 mSnapToleranceSpinBox->blockSignals( block );
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value...
void setDpi(double dpi)
Sets the dpi for outputting the layout.
QgsUnitTypes::LayoutUnit units() const
Returns the units for the measurement.
Base class for graphical items within a QgsLayout.
static QgsApplication * instance()
Returns the singleton instance of the QgsApplication.
void setY(const double y)
Sets y coordinate of point.
void customVariablesChanged()
Emitted whenever a custom global variable changes.
QgsLayoutUndoStack * undoStack()
Returns a pointer to the layout's undo stack, which manages undo/redo states for the layout and it's ...
Change layout default DPI.
QVariant customProperty(const QString &key, const QVariant &defaultValue=QVariant()) const
Read a custom property from the layout.
void resizeToContents(const QgsMargins &margins, QgsUnitTypes::LayoutUnit marginUnits)
Resizes the layout to a single page which fits the current contents of the layout.
QgsLayoutSnapper & snapper()
Returns a reference to the layout's snapper, which stores handles layout snap grids and lines and sna...
void metadataChanged()
Emitted when the project's metadata is changed.
void changed()
Emitted when pages are added or removed from the collection.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
static void setLayoutVariables(QgsLayout *layout, const QVariantMap &variables)
Sets all layout context variables.
QgsLayoutRenderContext & renderContext()
Returns a reference to the layout's render context, which stores information relating to the current ...
void dpiChanged()
Emitted when the context's DPI is changed.
void setResolution(QgsLayoutMeasurement resolution)
Sets the page/snap grid resolution.
This class provides a method of storing points, consisting of an x and y coordinate, for use in QGIS layouts.
void setX(const double x)
Sets the x coordinate of point.
QgsUnitTypes::LayoutUnit units() const
Returns the units for the point.
Layout graphical items for displaying a map.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
void endCommand()
Saves final state of an object and pushes the active command to the undo history. ...
void setLength(const double length)
Sets the length of the measurement.
void variablesChanged()
Emitted whenever the expression variables stored in the layout have been changed. ...
This class provides a method of storing measurements for use in QGIS layouts using a variety of diffe...
QgsLayoutMeasurement resolution() const
Returns the page/snap grid resolution.
QgsLayoutPageCollection * pageCollection()
Returns a pointer to the layout's page collection, which stores and manages page items in the layout...
QgsLayoutGridSettings & gridSettings()
Returns a reference to the layout's grid settings, which stores settings relating to grid appearance...
double dpi() const
Returns the dpi for outputting the layout.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
double y() const
Returns y coordinate of point.
void setOffset(const QgsLayoutPoint &offset)
Sets the offset of the page/snap grid.
double x() const
Returns x coordinate of point.
void redraw()
Triggers a redraw for all pages.
void changed(QgsUnitTypes::LayoutUnit unit)
Emitted when the unit is changed.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
void beginMacro(const QString &commandText)
Starts a macro command, with the given descriptive commandText.
void itemChanged(QgsLayoutItem *item)
Emitted whenever the currently selected item changes.
void beginCommand(QgsLayoutUndoObjectInterface *object, const QString &commandText, int id=0)
Begins a new undo command for the specified object.
void setUnits(const QgsUnitTypes::LayoutUnit units)
Sets the units for the measurement.
QgsLayoutPoint offset() const
Returns the offset of the page/snap grid.
QgsLayoutItemMap * referenceMap() const
Returns the map item which will be used to generate corresponding world files when the layout is expo...
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
double length() const
Returns the length of the measurement.
void customVariablesChanged()
Emitted whenever the expression variables stored in the project have been changed.
const QgsLayoutMeasurementConverter & measurementConverter() const
Returns the layout measurement converter to be used in the layout.
void setUnits(const QgsUnitTypes::LayoutUnit units)
Sets the units for the point.
static QgsExpressionContextScope * layoutScope(const QgsLayout *layout)
Creates a new scope which contains variables and functions relating to a QgsLayout layout...
static QgsProject * instance()
Returns the QgsProject singleton instance.
void nameChanged(const QString &name)
Emitted when the layout's name is changed.
void setReferenceMap(QgsLayoutItemMap *map)
Sets the map item which will be used to generate corresponding world files when the layout is exporte...
void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for the layout.
void setSnapTolerance(int snapTolerance)
Sets the snap tolerance (in pixels) to use when snapping.
LayoutUnit
Layout measurement units.
int snapTolerance() const
Returns the snap tolerance (in pixels) to use when snapping.
Print layout, a QgsLayout subclass for static or atlas-based layouts.
void endMacro()
Ends a macro command.
void changed()
Emitted when properties of the layout change.
Interface for master layout type objects, such as print layouts and reports.
The QgsMargins class defines the four margins of a rectangle.
void coverageLayerChanged(QgsVectorLayer *layer)
Emitted when the coverage layer for the atlas changes.