Skip to content

Commit

Permalink
Flip all composer double spin boxes to QgsDoubleSpin (refs #10544)
Browse files Browse the repository at this point in the history
Add clear buttons to applicable properties.
  • Loading branch information
nyalldawson committed Dec 5, 2014
1 parent 7400106 commit dfe7980
Show file tree
Hide file tree
Showing 14 changed files with 317 additions and 128 deletions.
96 changes: 75 additions & 21 deletions src/app/composer/qgscomposeritemwidget.cpp
Expand Up @@ -108,7 +108,13 @@ QgsVectorLayer* QgsComposerItemBaseWidget::atlasCoverageLayer() const

//QgsComposerItemWidget

QgsComposerItemWidget::QgsComposerItemWidget( QWidget* parent, QgsComposerItem* item ): QgsComposerItemBaseWidget( parent, item ), mItem( item )
QgsComposerItemWidget::QgsComposerItemWidget( QWidget* parent, QgsComposerItem* item )
: QgsComposerItemBaseWidget( parent, item )
, mItem( item )
, mFreezeXPosSpin( false )
, mFreezeYPosSpin( false )
, mFreezeWidthSpin( false )
, mFreezeHeightSpin( false )
{

setupUi( this );
Expand Down Expand Up @@ -376,68 +382,88 @@ void QgsComposerItemWidget::setValuesForGuiPositionElements()
if ( mItem->lastUsedPositionMode() == QgsComposerItem::UpperLeft )
{
mUpperLeftCheckBox->setChecked( true );
mXPosSpin->setValue( pos.x() );
mYPosSpin->setValue( pos.y() );
if ( !mFreezeXPosSpin )
mXPosSpin->setValue( pos.x() );
if ( !mFreezeYPosSpin )
mYPosSpin->setValue( pos.y() );
}

if ( mItem->lastUsedPositionMode() == QgsComposerItem::UpperMiddle )
{
mUpperMiddleCheckBox->setChecked( true );
mXPosSpin->setValue( pos.x() + mItem->rect().width() / 2.0 );
mYPosSpin->setValue( pos.y() );
if ( !mFreezeXPosSpin )
mXPosSpin->setValue( pos.x() + mItem->rect().width() / 2.0 );
if ( !mFreezeYPosSpin )
mYPosSpin->setValue( pos.y() );
}

if ( mItem->lastUsedPositionMode() == QgsComposerItem::UpperRight )
{
mUpperRightCheckBox->setChecked( true );
mXPosSpin->setValue( pos.x() + mItem->rect().width() );
mYPosSpin->setValue( pos.y() );
if ( !mFreezeXPosSpin )
mXPosSpin->setValue( pos.x() + mItem->rect().width() );
if ( !mFreezeYPosSpin )
mYPosSpin->setValue( pos.y() );
}

if ( mItem->lastUsedPositionMode() == QgsComposerItem::MiddleLeft )
{
mMiddleLeftCheckBox->setChecked( true );
mXPosSpin->setValue( pos.x() );
mYPosSpin->setValue( pos.y() + mItem->rect().height() / 2.0 );
if ( !mFreezeXPosSpin )
mXPosSpin->setValue( pos.x() );
if ( !mFreezeYPosSpin )
mYPosSpin->setValue( pos.y() + mItem->rect().height() / 2.0 );
}

if ( mItem->lastUsedPositionMode() == QgsComposerItem::Middle )
{
mMiddleCheckBox->setChecked( true );
mXPosSpin->setValue( pos.x() + mItem->rect().width() / 2.0 );
mYPosSpin->setValue( pos.y() + mItem->rect().height() / 2.0 );
if ( !mFreezeXPosSpin )
mXPosSpin->setValue( pos.x() + mItem->rect().width() / 2.0 );
if ( !mFreezeYPosSpin )
mYPosSpin->setValue( pos.y() + mItem->rect().height() / 2.0 );
}

if ( mItem->lastUsedPositionMode() == QgsComposerItem::MiddleRight )
{
mMiddleRightCheckBox->setChecked( true );
mXPosSpin->setValue( pos.x() + mItem->rect().width() );
mYPosSpin->setValue( pos.y() + mItem->rect().height() / 2.0 );
if ( !mFreezeXPosSpin )
mXPosSpin->setValue( pos.x() + mItem->rect().width() );
if ( !mFreezeYPosSpin )
mYPosSpin->setValue( pos.y() + mItem->rect().height() / 2.0 );
}

if ( mItem->lastUsedPositionMode() == QgsComposerItem::LowerLeft )
{
mLowerLeftCheckBox->setChecked( true );
mXPosSpin->setValue( pos.x() );
mYPosSpin->setValue( pos.y() + mItem->rect().height() );
if ( !mFreezeXPosSpin )
mXPosSpin->setValue( pos.x() );
if ( !mFreezeYPosSpin )
mYPosSpin->setValue( pos.y() + mItem->rect().height() );
}

if ( mItem->lastUsedPositionMode() == QgsComposerItem::LowerMiddle )
{
mLowerMiddleCheckBox->setChecked( true );
mXPosSpin->setValue( pos.x() + mItem->rect().width() / 2.0 );
mYPosSpin->setValue( pos.y() + mItem->rect().height() );
if ( !mFreezeXPosSpin )
mXPosSpin->setValue( pos.x() + mItem->rect().width() / 2.0 );
if ( !mFreezeYPosSpin )
mYPosSpin->setValue( pos.y() + mItem->rect().height() );
}

if ( mItem->lastUsedPositionMode() == QgsComposerItem::LowerRight )
{
mLowerRightCheckBox->setChecked( true );
mXPosSpin->setValue( pos.x() + mItem->rect().width() );
mYPosSpin->setValue( pos.y() + mItem->rect().height() );
if ( !mFreezeXPosSpin )
mXPosSpin->setValue( pos.x() + mItem->rect().width() );
if ( !mFreezeYPosSpin )
mYPosSpin->setValue( pos.y() + mItem->rect().height() );
}

mWidthSpin->setValue( mItem->rect().width() );
mHeightSpin->setValue( mItem->rect().height() );
if ( !mFreezeWidthSpin )
mWidthSpin->setValue( mItem->rect().width() );
if ( !mFreezeHeightSpin )
mHeightSpin->setValue( mItem->rect().height() );
mPageSpinBox->setValue( mItem->page() );

mXPosSpin->blockSignals( false );
Expand Down Expand Up @@ -635,6 +661,34 @@ void QgsComposerItemWidget::on_mItemIdLineEdit_editingFinished()
}
}

void QgsComposerItemWidget::on_mXPosSpin_valueChanged( double )
{
mFreezeXPosSpin = true;
changeItemPosition();
mFreezeXPosSpin = false;
}

void QgsComposerItemWidget::on_mYPosSpin_valueChanged( double )
{
mFreezeYPosSpin = true;
changeItemPosition();
mFreezeYPosSpin = false;
}

void QgsComposerItemWidget::on_mWidthSpin_valueChanged( double )
{
mFreezeWidthSpin = true;
changeItemPosition();
mFreezeWidthSpin = false;
}

void QgsComposerItemWidget::on_mHeightSpin_valueChanged( double )
{
mFreezeHeightSpin = true;
changeItemPosition();
mFreezeHeightSpin = false;
}

void QgsComposerItemWidget::on_mUpperLeftCheckBox_stateChanged( int state )
{
if ( state != Qt::Checked )
Expand Down
13 changes: 9 additions & 4 deletions src/app/composer/qgscomposeritemwidget.h
Expand Up @@ -91,10 +91,10 @@ class QgsComposerItemWidget: public QgsComposerItemBaseWidget, private Ui::QgsCo

//adjust coordinates in line edits
void on_mPageSpinBox_valueChanged( int ) { changeItemPosition(); }
void on_mXPosSpin_valueChanged( double ) { changeItemPosition(); }
void on_mYPosSpin_valueChanged( double ) { changeItemPosition(); }
void on_mWidthSpin_valueChanged( double ) { changeItemPosition(); }
void on_mHeightSpin_valueChanged( double ) { changeItemPosition(); }
void on_mXPosSpin_valueChanged( double );
void on_mYPosSpin_valueChanged( double );
void on_mWidthSpin_valueChanged( double );
void on_mHeightSpin_valueChanged( double );

void on_mUpperLeftCheckBox_stateChanged( int state );
void on_mUpperMiddleCheckBox_stateChanged( int state );
Expand Down Expand Up @@ -130,6 +130,11 @@ class QgsComposerItemWidget: public QgsComposerItemBaseWidget, private Ui::QgsCo

QgsComposerItem* mItem;

bool mFreezeXPosSpin;
bool mFreezeYPosSpin;
bool mFreezeWidthSpin;
bool mFreezeHeightSpin;

// void changeItemTransparency( int value );
void changeItemPosition();

Expand Down
3 changes: 3 additions & 0 deletions src/app/composer/qgscomposerlabelwidget.cpp
Expand Up @@ -36,6 +36,9 @@ QgsComposerLabelWidget::QgsComposerLabelWidget( QgsComposerLabel* label ): QgsCo
mFontColorButton->setColorDialogTitle( tr( "Select font color" ) );
mFontColorButton->setContext( "composer" );

mMarginXDoubleSpinBox->setClearValue( 0.0 );
mMarginYDoubleSpinBox->setClearValue( 0.0 );

if ( mComposerLabel )
{
setGuiElementValues();
Expand Down
27 changes: 19 additions & 8 deletions src/ui/qgscomposerarrowwidgetbase.ui
Expand Up @@ -188,13 +188,16 @@
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="mOutlineWidthSpinBox">
<widget class="QgsDoubleSpinBox" name="mOutlineWidthSpinBox">
<property name="prefix">
<string/>
</property>
<property name="suffix">
<string> mm</string>
</property>
<property name="showClearButton">
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="0">
Expand All @@ -205,13 +208,16 @@
</widget>
</item>
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="mArrowHeadWidthSpinBox">
<widget class="QgsDoubleSpinBox" name="mArrowHeadWidthSpinBox">
<property name="prefix">
<string/>
</property>
<property name="suffix">
<string> mm</string>
</property>
<property name="showClearButton">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="0">
Expand Down Expand Up @@ -266,18 +272,23 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsCollapsibleGroupBoxBasic</class>
<extends>QGroupBox</extends>
<header location="global">qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsColorButtonV2</class>
<extends>QToolButton</extends>
<header>qgscolorbuttonv2.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>qgsdoublespinbox.h</header>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBoxBasic</class>
<extends>QGroupBox</extends>
<header location="global">qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>scrollArea</tabstop>
Expand Down
33 changes: 22 additions & 11 deletions src/ui/qgscomposerattributetablewidgetbase.ui
Expand Up @@ -45,9 +45,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-400</y>
<y>0</y>
<width>392</width>
<height>1192</height>
<height>1204</height>
</rect>
</property>
<layout class="QVBoxLayout" name="mainLayout">
Expand Down Expand Up @@ -260,10 +260,13 @@
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="mMarginSpinBox">
<widget class="QgsDoubleSpinBox" name="mMarginSpinBox">
<property name="suffix">
<string> mm</string>
</property>
<property name="showClearButton">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="0">
Expand Down Expand Up @@ -397,10 +400,13 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="mGridStrokeWidthSpinBox">
<widget class="QgsDoubleSpinBox" name="mGridStrokeWidthSpinBox">
<property name="suffix">
<string> mm</string>
</property>
<property name="showClearButton">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
Expand Down Expand Up @@ -705,22 +711,27 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsCollapsibleGroupBoxBasic</class>
<extends>QGroupBox</extends>
<header location="global">qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsColorButtonV2</class>
<extends>QToolButton</extends>
<header>qgscolorbuttonv2.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>qgsdoublespinbox.h</header>
</customwidget>
<customwidget>
<class>QgsMapLayerComboBox</class>
<extends>QComboBox</extends>
<header location="global">qgsmaplayercombobox.h</header>
<header>qgsmaplayercombobox.h</header>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBoxBasic</class>
<extends>QGroupBox</extends>
<header location="global">qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
Expand Down
24 changes: 16 additions & 8 deletions src/ui/qgscomposerhtmlwidgetbase.ui
Expand Up @@ -45,9 +45,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-157</y>
<y>-155</y>
<width>391</width>
<height>517</height>
<height>515</height>
</rect>
</property>
<layout class="QVBoxLayout" name="mainLayout">
Expand Down Expand Up @@ -222,7 +222,7 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="mMaxDistanceSpinBox">
<widget class="QgsDoubleSpinBox" name="mMaxDistanceSpinBox">
<property name="suffix">
<string> mm</string>
</property>
Expand All @@ -235,6 +235,9 @@
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="showClearButton">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
Expand Down Expand Up @@ -278,17 +281,22 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsDataDefinedButton</class>
<extends>QToolButton</extends>
<header>qgsdatadefinedbutton.h</header>
</customwidget>
<customwidget>
<class>QgsDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>qgsdoublespinbox.h</header>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBoxBasic</class>
<extends>QGroupBox</extends>
<header location="global">qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsDataDefinedButton</class>
<extends>QToolButton</extends>
<header>qgsdatadefinedbutton.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>scrollArea</tabstop>
Expand Down

0 comments on commit dfe7980

Please sign in to comment.