Skip to content
Permalink
Browse files

Add spin box to set composer item background transparence numerically

  • Loading branch information
mhugent committed Jul 23, 2012
1 parent decb981 commit 840e2808058ca946d9e9bdb45cb604194186a1c6
@@ -89,14 +89,34 @@ void QgsComposerItemWidget::on_mBackgroundColorButton_clicked()
mItem->endCommand();
}

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

mOpacitySlider->blockSignals( true );
mOpacitySlider->setValue( value );
mOpacitySlider->blockSignals( false );
changeItemOpacity( value );
}

void QgsComposerItemWidget::on_mOpacitySlider_sliderReleased()
{
if ( !mItem )
{
return;
}
int value = mOpacitySlider->value();
mOpacitySpinBox->blockSignals( true );
mOpacitySpinBox->setValue( value );
mOpacitySpinBox->blockSignals( false );
changeItemOpacity( value );
}

void QgsComposerItemWidget::changeItemOpacity( int value )
{
mItem->beginCommand( tr( "Item opacity changed" ) );
QBrush itemBrush = mItem->brush();
QColor brushColor = itemBrush.color();
@@ -151,7 +171,9 @@ void QgsComposerItemWidget::setValuesForGuiElements()
mOutlineWidthSpinBox->blockSignals( true );
mFrameCheckBox->blockSignals( true );
mItemIdLineEdit->blockSignals( true );
mOpacitySpinBox->blockSignals( true );

mOpacitySpinBox->setValue( mItem->brush().color().alpha() );
mOpacitySlider->setValue( mItem->brush().color().alpha() );
mOutlineWidthSpinBox->setValue( mItem->pen().widthF() );
mItemIdLineEdit->setText( mItem->id() );
@@ -168,6 +190,7 @@ void QgsComposerItemWidget::setValuesForGuiElements()
mOutlineWidthSpinBox->blockSignals( false );
mFrameCheckBox->blockSignals( false );
mItemIdLineEdit->blockSignals( false );
mOpacitySpinBox->blockSignals( false );
}

void QgsComposerItemWidget::on_mPositionButton_clicked()
@@ -35,6 +35,7 @@ class QgsComposerItemWidget: public QWidget, private Ui::QgsComposerItemWidgetBa
void on_mFrameColorButton_clicked();
void on_mBackgroundColorButton_clicked();
void on_mOpacitySlider_sliderReleased();
void on_mOpacitySpinBox_valueChanged( int value );
void on_mOutlineWidthSpinBox_valueChanged( double d );
void on_mFrameCheckBox_stateChanged( int state );
void on_mPositionButton_clicked();
@@ -43,6 +44,7 @@ class QgsComposerItemWidget: public QWidget, private Ui::QgsComposerItemWidgetBa
private:
QgsComposerItemWidget();
void setValuesForGuiElements();
void changeItemOpacity( int value );

QgsComposerItem* mItem;
};
@@ -6,28 +6,63 @@
<rect>
<x>0</x>
<y>0</y>
<width>233</width>
<height>361</height>
<width>209</width>
<height>277</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="3" column="0">
<widget class="QLabel" name="mOpacityLabel">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="3">
<widget class="QPushButton" name="mFrameColorButton">
<property name="text">
<string>Opacity</string>
</property>
<property name="wordWrap">
<bool>true</bool>
<string>Frame color...</string>
</property>
<property name="buddy">
<cstring>mOpacitySlider</cstring>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QPushButton" name="mBackgroundColorButton">
<property name="text">
<string>Background color...</string>
</property>
</widget>
</item>
<item row="5" column="0">
<item row="2" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="mOpacityLabel">
<property name="text">
<string>Opacity</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="buddy">
<cstring>mOpacitySlider</cstring>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="mOpacitySlider">
<property name="maximum">
<number>255</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="mOpacitySpinBox">
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QLabel" name="mOutlineWidthLabel">
<property name="text">
<string>Outline width</string>
@@ -40,51 +75,34 @@
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="mIdLabel">
<property name="text">
<string>Item ID</string>
</property>
</widget>
<item row="3" column="2">
<widget class="QDoubleSpinBox" name="mOutlineWidthSpinBox"/>
</item>
<item row="0" column="0" colspan="2">
<widget class="QPushButton" name="mFrameColorButton">
<item row="4" column="0" colspan="3">
<widget class="QPushButton" name="mPositionButton">
<property name="text">
<string>Frame color...</string>
<string>Position and size...</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QPushButton" name="mBackgroundColorButton">
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="mFrameCheckBox">
<property name="text">
<string>Background color...</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSlider" name="mOpacitySlider">
<property name="maximum">
<number>255</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
<string>Show frame</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QDoubleSpinBox" name="mOutlineWidthSpinBox"/>
</item>
<item row="7" column="0" colspan="2">
<widget class="QPushButton" name="mPositionButton">
<item row="6" column="0">
<widget class="QLabel" name="mIdLabel">
<property name="text">
<string>Position and size...</string>
<string>Item ID</string>
</property>
</widget>
</item>
<item row="9" column="1">
<item row="6" column="1" colspan="2">
<widget class="QLineEdit" name="mItemIdLineEdit"/>
</item>
<item row="11" column="0" colspan="2">
<item row="7" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -97,13 +115,6 @@
</property>
</spacer>
</item>
<item row="8" column="0" colspan="2">
<widget class="QCheckBox" name="mFrameCheckBox">
<property name="text">
<string>Show frame</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>

0 comments on commit 840e280

Please sign in to comment.
You can’t perform that action at this time.