Skip to content

Commit ea0c87e

Browse files
committed
Fix #7195, transparency options in composer should be 0-100%
1 parent 4fb89db commit ea0c87e

File tree

3 files changed

+15
-47
lines changed

3 files changed

+15
-47
lines changed

src/app/composer/qgscomposeritemwidget.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void QgsComposerItemWidget::on_mBackgroundColorButton_clicked()
9797
}
9898

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

126-
void QgsComposerItemWidget::on_mTransparencySlider_sliderReleased()
126+
void QgsComposerItemWidget::on_mTransparencySlider_valueChanged( int value )
127127
{
128128
if ( !mItem )
129129
{
130130
return;
131131
}
132-
int value = mTransparencySlider->value();
133-
mTransparencySpinBox->blockSignals( true );
132+
// do item updates only off of mTransparencySpinBox valueChanged
134133
mTransparencySpinBox->setValue( value );
135-
mTransparencySpinBox->blockSignals( false );
136-
changeItemTransparency( value );
137134
}
138135

139136
void QgsComposerItemWidget::changeItemTransparency( int value )
140137
{
141-
mItem->beginCommand( tr( "Item Transparency changed" ) );
138+
mItem->beginCommand( tr( "Item transparency changed" ) );
142139
QBrush itemBrush = mItem->brush();
143140
QColor brushColor = itemBrush.color();
144-
brushColor.setAlpha( 255 - value );
141+
brushColor.setAlpha( 255 - ( value * 2.55 ) );
145142
mItem->setBrush( QBrush( brushColor ) );
146143
mItem->update();
147144
mItem->endCommand();
@@ -354,8 +351,9 @@ void QgsComposerItemWidget::setValuesForGuiElements()
354351
mItemIdLineEdit->blockSignals( true );
355352
mTransparencySpinBox->blockSignals( true );
356353

357-
mTransparencySpinBox->setValue( 255 - mItem->brush().color().alpha() );
358-
mTransparencySlider->setValue( 255 - mItem->brush().color().alpha() );
354+
int alphaPercent = ( 255 - mItem->brush().color().alpha() ) / 2.55;
355+
mTransparencySpinBox->setValue( alphaPercent );
356+
mTransparencySlider->setValue( alphaPercent );
359357
mOutlineWidthSpinBox->setValue( mItem->pen().widthF() );
360358
mItemIdLineEdit->setText( mItem->id() );
361359
mFrameGroupBox->setChecked( mItem->hasFrame() );

src/app/composer/qgscomposeritemwidget.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class QgsComposerItemWidget: public QWidget, private Ui::QgsComposerItemWidgetBa
3939
public slots:
4040
void on_mFrameColorButton_clicked();
4141
void on_mBackgroundColorButton_clicked();
42-
void on_mTransparencySlider_sliderReleased();
42+
void on_mTransparencySlider_valueChanged( int value );
4343
void on_mTransparencySpinBox_valueChanged( int value );
4444
void on_mOutlineWidthSpinBox_valueChanged( double d );
4545
void on_mFrameGroupBox_toggled( bool state );

src/ui/qgscomposeritemwidgetbase.ui

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@
318318
<item>
319319
<widget class="QSlider" name="mTransparencySlider">
320320
<property name="maximum">
321-
<number>255</number>
321+
<number>100</number>
322322
</property>
323323
<property name="orientation">
324324
<enum>Qt::Horizontal</enum>
@@ -327,8 +327,11 @@
327327
</item>
328328
<item>
329329
<widget class="QSpinBox" name="mTransparencySpinBox">
330+
<property name="suffix">
331+
<string>%</string>
332+
</property>
330333
<property name="maximum">
331-
<number>255</number>
334+
<number>100</number>
332335
</property>
333336
</widget>
334337
</item>
@@ -395,38 +398,5 @@
395398
</customwidget>
396399
</customwidgets>
397400
<resources/>
398-
<connections>
399-
<connection>
400-
<sender>mTransparencySlider</sender>
401-
<signal>valueChanged(int)</signal>
402-
<receiver>mTransparencySpinBox</receiver>
403-
<slot>setValue(int)</slot>
404-
<hints>
405-
<hint type="sourcelabel">
406-
<x>255</x>
407-
<y>387</y>
408-
</hint>
409-
<hint type="destinationlabel">
410-
<x>364</x>
411-
<y>389</y>
412-
</hint>
413-
</hints>
414-
</connection>
415-
<connection>
416-
<sender>mTransparencySpinBox</sender>
417-
<signal>valueChanged(int)</signal>
418-
<receiver>mTransparencySlider</receiver>
419-
<slot>setValue(int)</slot>
420-
<hints>
421-
<hint type="sourcelabel">
422-
<x>364</x>
423-
<y>389</y>
424-
</hint>
425-
<hint type="destinationlabel">
426-
<x>271</x>
427-
<y>387</y>
428-
</hint>
429-
</hints>
430-
</connection>
431-
</connections>
401+
<connections/>
432402
</ui>

0 commit comments

Comments
 (0)