Skip to content
Permalink
Browse files

Handle position and size with units and ratio lock in item properties

  • Loading branch information
nyalldawson committed Oct 10, 2017
1 parent aebe5a4 commit 1c735d59ee41c08cc4ddc83d431f731e61418210
@@ -53,6 +53,7 @@ class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem, QgsLayoutUndoObjectInt
enum UndoCommand
{
UndoIncrementalMove,
UndoIncrementalResize,
UndoStrokeColor,
UndoStrokeWidth,
UndoBackgroundColor,
@@ -84,6 +84,7 @@ class CORE_EXPORT QgsLayoutItem : public QgsLayoutObject, public QGraphicsRectIt
enum UndoCommand
{
UndoIncrementalMove = 1, //!< Layout item incremental movement, e.g. as a result of a keypress
UndoIncrementalResize, //!< Incremental resize
UndoStrokeColor, //!< Stroke color adjustment
UndoStrokeWidth, //!< Stroke width adjustment
UndoBackgroundColor, //!< Background color adjustment

Large diffs are not rendered by default.

@@ -206,18 +206,20 @@ class GUI_EXPORT QgsLayoutItemPropertiesWidget: public QWidget, private Ui::QgsL
void mPageSpinBox_valueChanged( int );
void mXPosSpin_valueChanged( double );
void mYPosSpin_valueChanged( double );
void positionUnitsChanged( QgsUnitTypes::LayoutUnit unit );
void mWidthSpin_valueChanged( double );
void mHeightSpin_valueChanged( double );

void mUpperLeftCheckBox_stateChanged( int state );
void mUpperMiddleCheckBox_stateChanged( int state );
void mUpperRightCheckBox_stateChanged( int state );
void mMiddleLeftCheckBox_stateChanged( int state );
void mMiddleCheckBox_stateChanged( int state );
void mMiddleRightCheckBox_stateChanged( int state );
void mLowerLeftCheckBox_stateChanged( int state );
void mLowerMiddleCheckBox_stateChanged( int state );
void mLowerRightCheckBox_stateChanged( int state );
void sizeUnitsChanged( QgsUnitTypes::LayoutUnit unit );

void mUpperLeftCheckBox_stateChanged( bool state );
void mUpperMiddleCheckBox_stateChanged( bool state );
void mUpperRightCheckBox_stateChanged( bool state );
void mMiddleLeftCheckBox_stateChanged( bool state );
void mMiddleCheckBox_stateChanged( bool state );
void mMiddleRightCheckBox_stateChanged( bool state );
void mLowerLeftCheckBox_stateChanged( bool state );
void mLowerMiddleCheckBox_stateChanged( bool state );
void mLowerRightCheckBox_stateChanged( bool state );

void mBlendModeCombo_currentIndexChanged( int index );
void opacityChanged( double value );
@@ -247,6 +249,8 @@ class GUI_EXPORT QgsLayoutItemPropertiesWidget: public QWidget, private Ui::QgsL

// void changeItemTransparency( int value );
void changeItemPosition();
void changeItemReference( QgsLayoutItem::ReferencePoint point );
void changeItemSize();

};

@@ -25,15 +25,15 @@ QgsLayoutItemPropertiesDialog::QgsLayoutItemPropertiesDialog( QWidget *parent, Q

//make button exclusive
QButtonGroup *buttonGroup = new QButtonGroup( this );
buttonGroup->addButton( mUpperLeftCheckBox );
buttonGroup->addButton( mUpperMiddleCheckBox );
buttonGroup->addButton( mUpperRightCheckBox );
buttonGroup->addButton( mMiddleLeftCheckBox );
buttonGroup->addButton( mMiddleCheckBox );
buttonGroup->addButton( mMiddleRightCheckBox );
buttonGroup->addButton( mLowerLeftCheckBox );
buttonGroup->addButton( mLowerMiddleCheckBox );
buttonGroup->addButton( mLowerRightCheckBox );
buttonGroup->addButton( mUpperLeftRadioButton );
buttonGroup->addButton( mUpperMiddleRadioButton );
buttonGroup->addButton( mUpperRightRadioButton );
buttonGroup->addButton( mMiddleLeftRadioButton );
buttonGroup->addButton( mMiddleRadioButton );
buttonGroup->addButton( mMiddleRightRadioButton );
buttonGroup->addButton( mLowerLeftRadioButton );
buttonGroup->addButton( mLowerMiddleRadioButton );
buttonGroup->addButton( mLowerRightRadioButton );
buttonGroup->setExclusive( true );

QgsSettings settings;
@@ -77,39 +77,39 @@ QgsLayoutSize QgsLayoutItemPropertiesDialog::itemSize() const

QgsLayoutItem::ReferencePoint QgsLayoutItemPropertiesDialog::referencePoint() const
{
if ( mUpperLeftCheckBox->checkState() == Qt::Checked )
if ( mUpperLeftRadioButton->isChecked() )
{
return QgsLayoutItem::UpperLeft;
}
else if ( mUpperMiddleCheckBox->checkState() == Qt::Checked )
else if ( mUpperMiddleRadioButton->isChecked() )
{
return QgsLayoutItem::UpperMiddle;
}
else if ( mUpperRightCheckBox->checkState() == Qt::Checked )
else if ( mUpperRightRadioButton->isChecked() )
{
return QgsLayoutItem::UpperRight;
}
else if ( mMiddleLeftCheckBox->checkState() == Qt::Checked )
else if ( mMiddleLeftRadioButton->isChecked() )
{
return QgsLayoutItem::MiddleLeft;
}
else if ( mMiddleCheckBox->checkState() == Qt::Checked )
else if ( mMiddleRadioButton->isChecked() )
{
return QgsLayoutItem::Middle;
}
else if ( mMiddleRightCheckBox->checkState() == Qt::Checked )
else if ( mMiddleRightRadioButton->isChecked() )
{
return QgsLayoutItem::MiddleRight;
}
else if ( mLowerLeftCheckBox->checkState() == Qt::Checked )
else if ( mLowerLeftRadioButton->isChecked() )
{
return QgsLayoutItem::LowerLeft;
}
else if ( mLowerMiddleCheckBox->checkState() == Qt::Checked )
else if ( mLowerMiddleRadioButton->isChecked() )
{
return QgsLayoutItem::LowerMiddle;
}
else if ( mLowerRightCheckBox->checkState() == Qt::Checked )
else if ( mLowerRightRadioButton->isChecked() )
{
return QgsLayoutItem::LowerRight;
}
@@ -121,39 +121,39 @@ void QgsLayoutItemPropertiesDialog::setReferencePoint( QgsLayoutItem::ReferenceP
switch ( point )
{
case QgsLayoutItem::UpperLeft:
mUpperLeftCheckBox->setChecked( true );
mUpperLeftRadioButton->setChecked( true );
break;

case QgsLayoutItem::UpperMiddle:
mUpperMiddleCheckBox->setChecked( true );
mUpperMiddleRadioButton->setChecked( true );
break;

case QgsLayoutItem::UpperRight:
mUpperRightCheckBox->setChecked( true );
mUpperRightRadioButton->setChecked( true );
break;

case QgsLayoutItem::MiddleLeft:
mMiddleLeftCheckBox->setChecked( true );
mMiddleLeftRadioButton->setChecked( true );
break;

case QgsLayoutItem::Middle:
mMiddleCheckBox->setChecked( true );
mMiddleRadioButton->setChecked( true );
break;

case QgsLayoutItem::MiddleRight:
mMiddleRightCheckBox->setChecked( true );
mMiddleRightRadioButton->setChecked( true );
break;

case QgsLayoutItem::LowerLeft:
mLowerLeftCheckBox->setChecked( true );
mLowerLeftRadioButton->setChecked( true );
break;

case QgsLayoutItem::LowerMiddle:
mLowerMiddleCheckBox->setChecked( true );
mLowerMiddleRadioButton->setChecked( true );
break;

case QgsLayoutItem::LowerRight:
mLowerRightCheckBox->setChecked( true );
mLowerRightRadioButton->setChecked( true );
break;
}
}

0 comments on commit 1c735d5

Please sign in to comment.
You can’t perform that action at this time.