void QgsLayoutItemScaleBar::resizeToMinimumWidth() { if ( !mStyle ) return; double widthMM = mStyle->calculateBoxSize( mSettings, createScaleContext() ).width(); QgsLayoutSize currentSize = sizeWithUnits(); currentSize.setWidth( mLayout->renderContext().measurementConverter().convert( QgsLayoutMeasurement( widthMM, QgsUnitTypes::LayoutMillimeters ), currentSize.units() ).length() ); attemptResize( currentSize ); update(); emit changed(); }
void QgsLayoutItemPropertiesWidget::setValuesForGuiPositionElements() { if ( !mItem ) { return; } auto block = [ = ]( bool blocked ) { mXPosSpin->blockSignals( blocked ); mYPosSpin->blockSignals( blocked ); mPosUnitsComboBox->blockSignals( blocked ); mWidthSpin->blockSignals( blocked ); mHeightSpin->blockSignals( blocked ); mSizeUnitsComboBox->blockSignals( blocked ); mUpperLeftRadioButton->blockSignals( blocked ); mUpperMiddleRadioButton->blockSignals( blocked ); mUpperRightRadioButton->blockSignals( blocked ); mMiddleLeftRadioButton->blockSignals( blocked ); mMiddleRadioButton->blockSignals( blocked ); mMiddleRightRadioButton->blockSignals( blocked ); mLowerLeftRadioButton->blockSignals( blocked ); mLowerMiddleRadioButton->blockSignals( blocked ); mLowerRightRadioButton->blockSignals( blocked ); mPageSpinBox->blockSignals( blocked ); }; block( true ); QgsLayoutPoint point = mItem->pagePositionWithUnits(); if ( !mFreezeXPosSpin ) mXPosSpin->setValue( point.x() ); if ( !mFreezeYPosSpin ) mYPosSpin->setValue( point.y() ); mPosUnitsComboBox->setUnit( point.units() ); switch ( mItem->referencePoint() ) { case QgsLayoutItem::UpperLeft: { mUpperLeftRadioButton->setChecked( true ); break; } case QgsLayoutItem::UpperMiddle: { mUpperMiddleRadioButton->setChecked( true ); break; } case QgsLayoutItem::UpperRight: { mUpperRightRadioButton->setChecked( true ); break; } case QgsLayoutItem::MiddleLeft: { mMiddleLeftRadioButton->setChecked( true ); break; } case QgsLayoutItem::Middle: { mMiddleRadioButton->setChecked( true ); break; } case QgsLayoutItem::MiddleRight: { mMiddleRightRadioButton->setChecked( true ); break; } case QgsLayoutItem::LowerLeft: { mLowerLeftRadioButton->setChecked( true ); break; } case QgsLayoutItem::LowerMiddle: { mLowerMiddleRadioButton->setChecked( true ); break; } case QgsLayoutItem::LowerRight: { mLowerRightRadioButton->setChecked( true ); break; } } QgsLayoutSize size = mItem->sizeWithUnits(); if ( !mFreezeWidthSpin ) mWidthSpin->setValue( size.width() ); if ( !mFreezeHeightSpin ) mHeightSpin->setValue( size.height() ); mSizeUnitsComboBox->setUnit( size.units() ); mSizeLockAspectRatio->resetRatio(); mPosLockAspectRatio->resetRatio(); if ( !mFreezePageSpin ) mPageSpinBox->setValue( mItem->page() + 1 ); block( false ); }
void QgsLayoutItemPropertiesDialog::setItemSize( QgsLayoutSize size ) { mWidthSpin->setValue( size.width() ); mHeightSpin->setValue( size.height() ); whileBlocking( mSizeUnitsComboBox )->setUnit( size.units() ); }