22 #include <QButtonGroup> 25 : QDialog( parent, flags )
32 QButtonGroup *buttonGroup =
new QButtonGroup(
this );
33 buttonGroup->addButton( mUpperLeftRadioButton );
34 buttonGroup->addButton( mUpperMiddleRadioButton );
35 buttonGroup->addButton( mUpperRightRadioButton );
36 buttonGroup->addButton( mMiddleLeftRadioButton );
37 buttonGroup->addButton( mMiddleRadioButton );
38 buttonGroup->addButton( mMiddleRightRadioButton );
39 buttonGroup->addButton( mLowerLeftRadioButton );
40 buttonGroup->addButton( mLowerMiddleRadioButton );
41 buttonGroup->addButton( mLowerRightRadioButton );
42 buttonGroup->setExclusive(
true );
45 double lastWidth = settings.
value( QStringLiteral(
"LayoutDesigner/lastItemWidth" ), QStringLiteral(
"50" ) ).toDouble();
46 double lastHeight = settings.
value( QStringLiteral(
"LayoutDesigner/lastItemHeight" ), QStringLiteral(
"50" ) ).toDouble();
50 mPosUnitsComboBox->linkToWidget( mXPosSpin );
51 mPosUnitsComboBox->linkToWidget( mYPosSpin );
52 mSizeUnitsComboBox->linkToWidget( mWidthSpin );
53 mSizeUnitsComboBox->linkToWidget( mHeightSpin );
55 mLockAspectRatio->setWidthSpinBox( mWidthSpin );
56 mLockAspectRatio->setHeightSpinBox( mHeightSpin );
68 mPageSpin->setValue( page + 1 );
70 mXPosSpin->setValue( position.
x() );
71 mYPosSpin->setValue( position.
y() );
76 return QgsLayoutPoint( mXPosSpin->value(), mYPosSpin->value(), mPosUnitsComboBox->unit() );
81 return mPageSpin->value() - 1;
86 mWidthSpin->setValue( size.
width() );
87 mHeightSpin->setValue( size.
height() );
93 return QgsLayoutSize( mWidthSpin->value(), mHeightSpin->value(), mSizeUnitsComboBox->unit() );
98 if ( mUpperLeftRadioButton->isChecked() )
102 else if ( mUpperMiddleRadioButton->isChecked() )
106 else if ( mUpperRightRadioButton->isChecked() )
110 else if ( mMiddleLeftRadioButton->isChecked() )
114 else if ( mMiddleRadioButton->isChecked() )
118 else if ( mMiddleRightRadioButton->isChecked() )
122 else if ( mLowerLeftRadioButton->isChecked() )
126 else if ( mLowerMiddleRadioButton->isChecked() )
130 else if ( mLowerRightRadioButton->isChecked() )
142 mUpperLeftRadioButton->setChecked(
true );
146 mUpperMiddleRadioButton->setChecked(
true );
150 mUpperRightRadioButton->setChecked(
true );
154 mMiddleLeftRadioButton->setChecked(
true );
158 mMiddleRadioButton->setChecked(
true );
162 mMiddleRightRadioButton->setChecked(
true );
166 mLowerLeftRadioButton->setChecked(
true );
170 mLowerMiddleRadioButton->setChecked(
true );
174 mLowerRightRadioButton->setChecked(
true );
void setItemPosition(QgsLayoutPoint position)
Sets the item position to show in the dialog.
Lower left corner of item.
This class is a composition of two QSettings instances:
int pageNumberForPoint(QPointF point) const
Returns the page number corresponding to a point in the layout (in layout units). ...
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void setReferencePoint(QgsLayoutItem::ReferencePoint point)
Sets the item reference point defined to show in the dialog.
void setLayout(QgsLayout *layout)
Sets the layout associated with the dialog.
Lower right corner of item.
QgsLayoutRenderContext & renderContext()
Returns a reference to the layout's render context, which stores information relating to the current ...
QgsLayoutItemPropertiesDialog(QWidget *parent=nullptr, Qt::WindowFlags flags=nullptr)
Constructor for QgsLayoutNewItemPropertiesDialog.
This class provides a method of storing points, consisting of an x and y coordinate, for use in QGIS layouts.
ReferencePoint
Fixed position reference point.
QgsUnitTypes::LayoutUnit units() const
Returns the units for the point.
Upper right corner of item.
QgsLayoutPoint itemPosition() const
Returns the current item position defined by the dialog.
QgsLayoutPageCollection * pageCollection()
Returns a pointer to the layout's page collection, which stores and manages page items in the layout...
double y() const
Returns y coordinate of point.
QgsLayoutItem::ReferencePoint referencePoint() const
Returns the item reference point defined by the dialog.
double x() const
Returns x coordinate of point.
QgsUnitTypes::LayoutUnit units() const
Returns the units for the size.
Upper left corner of item.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
QPointF positionOnPage(QPointF point) const
Returns the position within a page of a point in the layout (in layout units).
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.
QgsLayoutSize itemSize() const
Returns the item size defined by the dialog.
QgsLayoutMeasurement convertFromLayoutUnits(double length, QgsUnitTypes::LayoutUnit unit) const
Converts a length measurement from the layout's native units to a specified target unit...
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...
T enumValue(const QString &key, const T &defaultValue, const Section section=NoSection)
Returns the setting value for a setting based on an enum.
LayoutUnit
Layout measurement units.
double convertToLayoutUnits(QgsLayoutMeasurement measurement) const
Converts a measurement into the layout's native units.
This class provides a method of storing sizes, consisting of a width and height, for use in QGIS layo...
double height() const
Returns the height of the size.
int page() const
Returns the page number for the new item.
void setItemSize(QgsLayoutSize size)
Sets the item size to show in the dialog.
double width() const
Returns the width of the size.