Skip to content

Commit

Permalink
Update new composer item Rendering group box
Browse files Browse the repository at this point in the history
- Set form layout to match others in composer
- Add companion spin box for transparency slider
- Add syncGroup property for collapsible group box functionality
- Clean up some old commented-out code (replaced by QgsColorButton with alpha support)
  • Loading branch information
dakcarto committed Apr 18, 2013
1 parent bf0e8c5 commit facbff7
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 57 deletions.
49 changes: 5 additions & 44 deletions src/app/composer/qgscomposeritemwidget.cpp
Expand Up @@ -48,6 +48,8 @@ QgsComposerItemWidget::QgsComposerItemWidget( QWidget* parent, QgsComposerItem*
setValuesForGuiElements();
connect( mItem, SIGNAL( sizeChanged() ), this, SLOT( setValuesForGuiPositionElements() ) );

connect( mTransparencySlider, SIGNAL( valueChanged( int ) ), mTransparencySpnBx, SLOT( setValue( int ) ) );
connect( mTransparencySpnBx, SIGNAL( valueChanged( int ) ), mTransparencySlider, SLOT( setValue( int ) ) );
}

QgsComposerItemWidget::QgsComposerItemWidget(): QWidget( 0 ), mItem( 0 )
Expand Down Expand Up @@ -99,9 +101,7 @@ void QgsComposerItemWidget::on_mBackgroundColorButton_colorChanged( const QColor
{
return;
}
// QColor newColor( newBackgroundColor );
mItem->beginCommand( tr( "Background color changed" ) );
// newColor.setAlpha( 255 - ( mTransparencySpinBox->value() * 2.55 ) );
mItem->setBackgroundColor( newBackgroundColor );

//if the item is a composer map, we need to regenerate the map image
Expand All @@ -115,40 +115,6 @@ void QgsComposerItemWidget::on_mBackgroundColorButton_colorChanged( const QColor
mItem->endCommand();
}

//void QgsComposerItemWidget::on_mTransparencySpinBox_valueChanged( int value )
//{
// if ( !mItem )
// {
// return;
// }

// mTransparencySlider->blockSignals( true );
// mTransparencySlider->setValue( value );
// mTransparencySlider->blockSignals( false );
// changeItemTransparency( value );
//}

//void QgsComposerItemWidget::on_mTransparencySlider_valueChanged( int value )
//{
// if ( !mItem )
// {
// return;
// }
// // do item updates only off of mTransparencySpinBox valueChanged
// mTransparencySpinBox->setValue( value );
//}

//void QgsComposerItemWidget::changeItemTransparency( int value )
//{
// mItem->beginCommand( tr( "Item transparency changed" ) );
// QBrush itemBrush = mItem->brush();
// QColor brushColor = itemBrush.color();
// brushColor.setAlpha( 255 - ( value * 2.55 ) );
// mItem->setBrush( QBrush( brushColor ) );
// mItem->update();
// mItem->endCommand();
//}

void QgsComposerItemWidget::changeItemPosition()
{
mItem->beginCommand( tr( "Item position changed" ) );
Expand Down Expand Up @@ -358,23 +324,18 @@ void QgsComposerItemWidget::setValuesForGuiElements()

setValuesForGuiPositionElements();

// mTransparencySlider->blockSignals( true );
mOutlineWidthSpinBox->blockSignals( true );
mFrameGroupBox->blockSignals( true );
mBackgroundGroupBox->blockSignals( true );
mItemIdLineEdit->blockSignals( true );
mItemUuidLineEdit->blockSignals( true );
mBlendModeCombo->blockSignals( true );
mTransparencySlider->blockSignals( true );
// mTransparencySpinBox->blockSignals( true );
mTransparencySpnBx->blockSignals( true );

mBackgroundColorButton->setColor( mItem->brush().color() );
mBackgroundColorButton->setColorDialogTitle( tr( "Select background color" ) );
mBackgroundColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
// int alphaPercent = ( 255 - mItem->brush().color().alpha() ) / 2.55;
// mTransparencySpinBox->setValue( alphaPercent );
// mTransparencySlider->setValue( alphaPercent );

mFrameColorButton->setColor( mItem->pen().color() );
mFrameColorButton->setColorDialogTitle( tr( "Select frame color" ) );
mFrameColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
Expand All @@ -385,16 +346,16 @@ void QgsComposerItemWidget::setValuesForGuiElements()
mBackgroundGroupBox->setChecked( mItem->hasBackground() );
mBlendModeCombo->setBlendMode( mItem->blendMode() );
mTransparencySlider->setValue( mItem->transparency() );
mTransparencySpnBx->setValue( mItem->transparency() );

// mTransparencySlider->blockSignals( false );
mOutlineWidthSpinBox->blockSignals( false );
mFrameGroupBox->blockSignals( false );
mBackgroundGroupBox->blockSignals( false );
mItemIdLineEdit->blockSignals( false );
mItemUuidLineEdit->blockSignals( false );
mBlendModeCombo->blockSignals( false );
mTransparencySlider->blockSignals( false );
// mTransparencySpinBox->blockSignals( false );
mTransparencySpnBx->blockSignals( false );
}

void QgsComposerItemWidget::on_mBlendModeCombo_currentIndexChanged( int index )
Expand Down
46 changes: 33 additions & 13 deletions src/ui/qgscomposeritemwidgetbase.ui
Expand Up @@ -345,7 +345,16 @@
<property name="collapsed" stdset="0">
<bool>true</bool>
</property>
<property name="syncGroup" stdset="0">
<string notr="true">composeritem</string>
</property>
<layout class="QFormLayout" name="formLayout_3">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="labelAlignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<item row="0" column="0">
<widget class="QLabel" name="labelBlendMode">
<property name="text">
Expand All @@ -364,14 +373,25 @@
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="mTransparencySlider">
<property name="maximum">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QSlider" name="mTransparencySlider">
<property name="maximum">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="mTransparencySpnBx">
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
Expand Down Expand Up @@ -400,17 +420,17 @@
<extends>QPushButton</extends>
<header>qgscolorbutton.h</header>
</customwidget>
<customwidget>
<class>QgsBlendModeComboBox</class>
<extends>QComboBox</extends>
<header>qgsblendmodecombobox.h</header>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBoxBasic</class>
<extends>QGroupBox</extends>
<header location="global">qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsBlendModeComboBox</class>
<extends>QComboBox</extends>
<header>qgsblendmodecombobox.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
Expand Down

0 comments on commit facbff7

Please sign in to comment.