25#include <QButtonGroup>
27#include "moc_qgslayoutnewitempropertiesdialog.cpp"
30 : QDialog( parent, flags )
37 QButtonGroup *buttonGroup =
new QButtonGroup(
this );
38 buttonGroup->addButton( mUpperLeftRadioButton );
39 buttonGroup->addButton( mUpperMiddleRadioButton );
40 buttonGroup->addButton( mUpperRightRadioButton );
41 buttonGroup->addButton( mMiddleLeftRadioButton );
42 buttonGroup->addButton( mMiddleRadioButton );
43 buttonGroup->addButton( mMiddleRightRadioButton );
44 buttonGroup->addButton( mLowerLeftRadioButton );
45 buttonGroup->addButton( mLowerMiddleRadioButton );
46 buttonGroup->addButton( mLowerRightRadioButton );
47 buttonGroup->setExclusive(
true );
50 const double lastWidth = settings.
value( QStringLiteral(
"LayoutDesigner/lastItemWidth" ), QStringLiteral(
"50" ) ).toDouble();
51 const double lastHeight = settings.
value( QStringLiteral(
"LayoutDesigner/lastItemHeight" ), QStringLiteral(
"50" ) ).toDouble();
55 mPosUnitsComboBox->linkToWidget( mXPosSpin );
56 mPosUnitsComboBox->linkToWidget( mYPosSpin );
57 mSizeUnitsComboBox->linkToWidget( mWidthSpin );
58 mSizeUnitsComboBox->linkToWidget( mHeightSpin );
60 mLockAspectRatio->setWidthSpinBox( mWidthSpin );
61 mLockAspectRatio->setHeightSpinBox( mHeightSpin );
63 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsLayoutItemPropertiesDialog::showHelp );
69 const QPointF layoutPoint = mLayout->convertToLayoutUnits( position );
70 const int page = mLayout->pageCollection()->pageNumberForPoint( layoutPoint );
73 position = mLayout->convertFromLayoutUnits( mLayout->pageCollection()->positionOnPage( layoutPoint ), position.
units() );
75 mPageSpin->setValue(
page + 1 );
77 mXPosSpin->setValue( position.
x() );
78 mYPosSpin->setValue( position.
y() );
83 return QgsLayoutPoint( mXPosSpin->value(), mYPosSpin->value(), mPosUnitsComboBox->unit() );
88 return mPageSpin->value() - 1;
93 mWidthSpin->setValue( size.
width() );
94 mHeightSpin->setValue( size.
height() );
100 return QgsLayoutSize( mWidthSpin->value(), mHeightSpin->value(), mSizeUnitsComboBox->unit() );
105 if ( mUpperLeftRadioButton->isChecked() )
109 else if ( mUpperMiddleRadioButton->isChecked() )
113 else if ( mUpperRightRadioButton->isChecked() )
117 else if ( mMiddleLeftRadioButton->isChecked() )
121 else if ( mMiddleRadioButton->isChecked() )
125 else if ( mMiddleRightRadioButton->isChecked() )
129 else if ( mLowerLeftRadioButton->isChecked() )
133 else if ( mLowerMiddleRadioButton->isChecked() )
137 else if ( mLowerRightRadioButton->isChecked() )
149 mUpperLeftRadioButton->setChecked(
true );
153 mUpperMiddleRadioButton->setChecked(
true );
157 mUpperRightRadioButton->setChecked(
true );
161 mMiddleLeftRadioButton->setChecked(
true );
165 mMiddleRadioButton->setChecked(
true );
169 mMiddleRightRadioButton->setChecked(
true );
173 mLowerLeftRadioButton->setChecked(
true );
177 mLowerMiddleRadioButton->setChecked(
true );
181 mLowerRightRadioButton->setChecked(
true );
193void QgsLayoutItemPropertiesDialog::showHelp()
195 QgsHelp::openHelp( QStringLiteral(
"print_composer/composer_items/composer_items_options.html#creating-a-layout-item" ) );
LayoutUnit
Layout measurement units.
@ Millimeters
Millimeters.
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
QgsLayoutItemPropertiesDialog(QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::WindowFlags())
Constructor for QgsLayoutNewItemPropertiesDialog.
QgsLayoutSize itemSize() const
Returns the item size defined by the dialog.
void setReferencePoint(QgsLayoutItem::ReferencePoint point)
Sets the item reference point defined to show in the dialog.
QgsLayoutItem::ReferencePoint referencePoint() const
Returns the item reference point defined by the dialog.
void setItemSize(QgsLayoutSize size)
Sets the item size to show in the dialog.
void setLayout(QgsLayout *layout)
Sets the layout associated with the dialog.
QgsLayoutPoint itemPosition() const
Returns the current item position defined by the dialog.
int page() const
Returns the page number for the new item.
void setItemPosition(QgsLayoutPoint position)
Sets the item position to show in the dialog.
ReferencePoint
Fixed position reference point.
@ LowerMiddle
Lower center of item.
@ MiddleLeft
Middle left of item.
@ UpperRight
Upper right corner of item.
@ LowerLeft
Lower left corner of item.
@ UpperLeft
Upper left corner of item.
@ UpperMiddle
Upper center of item.
@ MiddleRight
Middle right of item.
@ LowerRight
Lower right corner of item.
Provides a method of storing points, consisting of an x and y coordinate, for use in QGIS layouts.
double x() const
Returns x coordinate of point.
double y() const
Returns y coordinate of point.
Qgis::LayoutUnit units() const
Returns the units for the point.
const QgsLayoutMeasurementConverter & measurementConverter() const
Returns the layout measurement converter to be used in the layout.
Provides a method of storing sizes, consisting of a width and height, for use in QGIS layouts.
double height() const
Returns the height of the size.
Qgis::LayoutUnit units() const
Returns the units for the size.
double width() const
Returns the width of the size.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
QgsLayoutRenderContext & renderContext()
Returns a reference to the layout's render context, which stores information relating to the current ...
Stores settings for use within QGIS.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
T enumValue(const QString &key, const T &defaultValue, const Section section=NoSection)
Returns the setting value for a setting based on an enum.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.