Skip to content

Commit

Permalink
Fix #7195, transparency options in composer should be 0-100%
Browse files Browse the repository at this point in the history
  • Loading branch information
dakcarto committed Mar 4, 2013
1 parent 4fb89db commit ea0c87e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 47 deletions.
18 changes: 8 additions & 10 deletions src/app/composer/qgscomposeritemwidget.cpp
Expand Up @@ -97,7 +97,7 @@ void QgsComposerItemWidget::on_mBackgroundColorButton_clicked()
}

mItem->beginCommand( tr( "Background color changed" ) );
newBackgroundColor.setAlpha( mTransparencySlider->value() );
newBackgroundColor.setAlpha( 255 - ( mTransparencySpinBox->value() * 2.55 ) );
mItem->setBrush( QBrush( QColor( newBackgroundColor ), Qt::SolidPattern ) );
//if the item is a composer map, we need to regenerate the map image
//because it usually is cached
Expand All @@ -123,25 +123,22 @@ void QgsComposerItemWidget::on_mTransparencySpinBox_valueChanged( int value )
changeItemTransparency( value );
}

void QgsComposerItemWidget::on_mTransparencySlider_sliderReleased()
void QgsComposerItemWidget::on_mTransparencySlider_valueChanged( int value )
{
if ( !mItem )
{
return;
}
int value = mTransparencySlider->value();
mTransparencySpinBox->blockSignals( true );
// do item updates only off of mTransparencySpinBox valueChanged
mTransparencySpinBox->setValue( value );
mTransparencySpinBox->blockSignals( false );
changeItemTransparency( value );
}

void QgsComposerItemWidget::changeItemTransparency( int value )
{
mItem->beginCommand( tr( "Item Transparency changed" ) );
mItem->beginCommand( tr( "Item transparency changed" ) );
QBrush itemBrush = mItem->brush();
QColor brushColor = itemBrush.color();
brushColor.setAlpha( 255 - value );
brushColor.setAlpha( 255 - ( value * 2.55 ) );
mItem->setBrush( QBrush( brushColor ) );
mItem->update();
mItem->endCommand();
Expand Down Expand Up @@ -354,8 +351,9 @@ void QgsComposerItemWidget::setValuesForGuiElements()
mItemIdLineEdit->blockSignals( true );
mTransparencySpinBox->blockSignals( true );

mTransparencySpinBox->setValue( 255 - mItem->brush().color().alpha() );
mTransparencySlider->setValue( 255 - mItem->brush().color().alpha() );
int alphaPercent = ( 255 - mItem->brush().color().alpha() ) / 2.55;
mTransparencySpinBox->setValue( alphaPercent );
mTransparencySlider->setValue( alphaPercent );
mOutlineWidthSpinBox->setValue( mItem->pen().widthF() );
mItemIdLineEdit->setText( mItem->id() );
mFrameGroupBox->setChecked( mItem->hasFrame() );
Expand Down
2 changes: 1 addition & 1 deletion src/app/composer/qgscomposeritemwidget.h
Expand Up @@ -39,7 +39,7 @@ class QgsComposerItemWidget: public QWidget, private Ui::QgsComposerItemWidgetBa
public slots:
void on_mFrameColorButton_clicked();
void on_mBackgroundColorButton_clicked();
void on_mTransparencySlider_sliderReleased();
void on_mTransparencySlider_valueChanged( int value );
void on_mTransparencySpinBox_valueChanged( int value );
void on_mOutlineWidthSpinBox_valueChanged( double d );
void on_mFrameGroupBox_toggled( bool state );
Expand Down
42 changes: 6 additions & 36 deletions src/ui/qgscomposeritemwidgetbase.ui
Expand Up @@ -318,7 +318,7 @@
<item>
<widget class="QSlider" name="mTransparencySlider">
<property name="maximum">
<number>255</number>
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand All @@ -327,8 +327,11 @@
</item>
<item>
<widget class="QSpinBox" name="mTransparencySpinBox">
<property name="suffix">
<string>%</string>
</property>
<property name="maximum">
<number>255</number>
<number>100</number>
</property>
</widget>
</item>
Expand Down Expand Up @@ -395,38 +398,5 @@
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>mTransparencySlider</sender>
<signal>valueChanged(int)</signal>
<receiver>mTransparencySpinBox</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel">
<x>255</x>
<y>387</y>
</hint>
<hint type="destinationlabel">
<x>364</x>
<y>389</y>
</hint>
</hints>
</connection>
<connection>
<sender>mTransparencySpinBox</sender>
<signal>valueChanged(int)</signal>
<receiver>mTransparencySlider</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel">
<x>364</x>
<y>389</y>
</hint>
<hint type="destinationlabel">
<x>271</x>
<y>387</y>
</hint>
</hints>
</connection>
</connections>
<connections/>
</ui>

0 comments on commit ea0c87e

Please sign in to comment.