Skip to content

Commit

Permalink
Add spin box to set composer item background transparence numerically
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Jul 23, 2012
1 parent decb981 commit 840e280
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 49 deletions.
23 changes: 23 additions & 0 deletions src/app/composer/qgscomposeritemwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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() );
Expand All @@ -168,6 +190,7 @@ void QgsComposerItemWidget::setValuesForGuiElements()
mOutlineWidthSpinBox->blockSignals( false );
mFrameCheckBox->blockSignals( false );
mItemIdLineEdit->blockSignals( false );
mOpacitySpinBox->blockSignals( false );
}

void QgsComposerItemWidget::on_mPositionButton_clicked()
Expand Down
2 changes: 2 additions & 0 deletions src/app/composer/qgscomposeritemwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -43,6 +44,7 @@ class QgsComposerItemWidget: public QWidget, private Ui::QgsComposerItemWidgetBa
private:
QgsComposerItemWidget();
void setValuesForGuiElements();
void changeItemOpacity( int value );

QgsComposerItem* mItem;
};
Expand Down
109 changes: 60 additions & 49 deletions src/ui/qgscomposeritemwidgetbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand All @@ -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/>
Expand Down

0 comments on commit 840e280

Please sign in to comment.