Update new composer item Rendering group box

- 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)
This commit is contained in:
Larry Shaffer 2013-04-18 07:35:05 -06:00
parent bf0e8c516f
commit facbff73b8
2 changed files with 38 additions and 57 deletions

View File

@ -48,6 +48,8 @@ QgsComposerItemWidget::QgsComposerItemWidget( QWidget* parent, QgsComposerItem*
setValuesForGuiElements(); setValuesForGuiElements();
connect( mItem, SIGNAL( sizeChanged() ), this, SLOT( setValuesForGuiPositionElements() ) ); 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 ) QgsComposerItemWidget::QgsComposerItemWidget(): QWidget( 0 ), mItem( 0 )
@ -99,9 +101,7 @@ void QgsComposerItemWidget::on_mBackgroundColorButton_colorChanged( const QColor
{ {
return; return;
} }
// QColor newColor( newBackgroundColor );
mItem->beginCommand( tr( "Background color changed" ) ); mItem->beginCommand( tr( "Background color changed" ) );
// newColor.setAlpha( 255 - ( mTransparencySpinBox->value() * 2.55 ) );
mItem->setBackgroundColor( newBackgroundColor ); mItem->setBackgroundColor( newBackgroundColor );
//if the item is a composer map, we need to regenerate the map image //if the item is a composer map, we need to regenerate the map image
@ -115,40 +115,6 @@ void QgsComposerItemWidget::on_mBackgroundColorButton_colorChanged( const QColor
mItem->endCommand(); 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() void QgsComposerItemWidget::changeItemPosition()
{ {
mItem->beginCommand( tr( "Item position changed" ) ); mItem->beginCommand( tr( "Item position changed" ) );
@ -358,7 +324,6 @@ void QgsComposerItemWidget::setValuesForGuiElements()
setValuesForGuiPositionElements(); setValuesForGuiPositionElements();
// mTransparencySlider->blockSignals( true );
mOutlineWidthSpinBox->blockSignals( true ); mOutlineWidthSpinBox->blockSignals( true );
mFrameGroupBox->blockSignals( true ); mFrameGroupBox->blockSignals( true );
mBackgroundGroupBox->blockSignals( true ); mBackgroundGroupBox->blockSignals( true );
@ -366,15 +331,11 @@ void QgsComposerItemWidget::setValuesForGuiElements()
mItemUuidLineEdit->blockSignals( true ); mItemUuidLineEdit->blockSignals( true );
mBlendModeCombo->blockSignals( true ); mBlendModeCombo->blockSignals( true );
mTransparencySlider->blockSignals( true ); mTransparencySlider->blockSignals( true );
// mTransparencySpinBox->blockSignals( true ); mTransparencySpnBx->blockSignals( true );
mBackgroundColorButton->setColor( mItem->brush().color() ); mBackgroundColorButton->setColor( mItem->brush().color() );
mBackgroundColorButton->setColorDialogTitle( tr( "Select background color" ) ); mBackgroundColorButton->setColorDialogTitle( tr( "Select background color" ) );
mBackgroundColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel ); 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->setColor( mItem->pen().color() );
mFrameColorButton->setColorDialogTitle( tr( "Select frame color" ) ); mFrameColorButton->setColorDialogTitle( tr( "Select frame color" ) );
mFrameColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel ); mFrameColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
@ -385,8 +346,8 @@ void QgsComposerItemWidget::setValuesForGuiElements()
mBackgroundGroupBox->setChecked( mItem->hasBackground() ); mBackgroundGroupBox->setChecked( mItem->hasBackground() );
mBlendModeCombo->setBlendMode( mItem->blendMode() ); mBlendModeCombo->setBlendMode( mItem->blendMode() );
mTransparencySlider->setValue( mItem->transparency() ); mTransparencySlider->setValue( mItem->transparency() );
mTransparencySpnBx->setValue( mItem->transparency() );
// mTransparencySlider->blockSignals( false );
mOutlineWidthSpinBox->blockSignals( false ); mOutlineWidthSpinBox->blockSignals( false );
mFrameGroupBox->blockSignals( false ); mFrameGroupBox->blockSignals( false );
mBackgroundGroupBox->blockSignals( false ); mBackgroundGroupBox->blockSignals( false );
@ -394,7 +355,7 @@ void QgsComposerItemWidget::setValuesForGuiElements()
mItemUuidLineEdit->blockSignals( false ); mItemUuidLineEdit->blockSignals( false );
mBlendModeCombo->blockSignals( false ); mBlendModeCombo->blockSignals( false );
mTransparencySlider->blockSignals( false ); mTransparencySlider->blockSignals( false );
// mTransparencySpinBox->blockSignals( false ); mTransparencySpnBx->blockSignals( false );
} }
void QgsComposerItemWidget::on_mBlendModeCombo_currentIndexChanged( int index ) void QgsComposerItemWidget::on_mBlendModeCombo_currentIndexChanged( int index )

View File

@ -345,7 +345,16 @@
<property name="collapsed" stdset="0"> <property name="collapsed" stdset="0">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="syncGroup" stdset="0">
<string notr="true">composeritem</string>
</property>
<layout class="QFormLayout" name="formLayout_3"> <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"> <item row="0" column="0">
<widget class="QLabel" name="labelBlendMode"> <widget class="QLabel" name="labelBlendMode">
<property name="text"> <property name="text">
@ -364,14 +373,25 @@
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QSlider" name="mTransparencySlider"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="maximum"> <item>
<number>100</number> <widget class="QSlider" name="mTransparencySlider">
</property> <property name="maximum">
<property name="orientation"> <number>100</number>
<enum>Qt::Horizontal</enum> </property>
</property> <property name="orientation">
</widget> <enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="mTransparencySpnBx">
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
</layout>
</item> </item>
</layout> </layout>
</widget> </widget>
@ -400,17 +420,17 @@
<extends>QPushButton</extends> <extends>QPushButton</extends>
<header>qgscolorbutton.h</header> <header>qgscolorbutton.h</header>
</customwidget> </customwidget>
<customwidget>
<class>QgsBlendModeComboBox</class>
<extends>QComboBox</extends>
<header>qgsblendmodecombobox.h</header>
</customwidget>
<customwidget> <customwidget>
<class>QgsCollapsibleGroupBoxBasic</class> <class>QgsCollapsibleGroupBoxBasic</class>
<extends>QGroupBox</extends> <extends>QGroupBox</extends>
<header location="global">qgscollapsiblegroupbox.h</header> <header location="global">qgscollapsiblegroupbox.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>QgsBlendModeComboBox</class>
<extends>QComboBox</extends>
<header>qgsblendmodecombobox.h</header>
</customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>
<connections/> <connections/>