Skip to content
Permalink
Browse files

Display alpha value as transparency (to be consistent with the interf…

…ace in old symbology)

git-svn-id: http://svn.osgeo.org/qgis/trunk@12847 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Jan 29, 2010
1 parent bff8c3b commit f46f158d4da2f589ff9e2359ec396156d787a87b
@@ -48,9 +48,11 @@ QgsSymbolV2SelectorDialog::QgsSymbolV2SelectorDialog( QgsSymbolV2* symbol, QgsSt
mSymbolUnitComboBox->setCurrentIndex( mSymbol->outputUnit() );
mSymbolUnitComboBox->blockSignals( false );

mOpacitySlider->blockSignals( true );
mOpacitySlider->setValue( symbol->alpha() * 255 );
mOpacitySlider->blockSignals( false );
mTransparencySlider->blockSignals( true );
double transparency = 1 - symbol->alpha();
mTransparencySlider->setValue( transparency * 255 );
displayTransparency( symbol->alpha() );
mTransparencySlider->blockSignals( false );
}

// select correct page in stacked widget
@@ -243,12 +245,20 @@ void QgsSymbolV2SelectorDialog::on_mSymbolUnitComboBox_currentIndexChanged( cons
}
}

void QgsSymbolV2SelectorDialog::on_mOpacitySlider_valueChanged( int value )
void QgsSymbolV2SelectorDialog::on_mTransparencySlider_valueChanged( int value )
{
if ( mSymbol )
{
mSymbol->setAlpha( value / 255.0 );
double alpha = 1 - ( value / 255.0 );
mSymbol->setAlpha( alpha );
displayTransparency( alpha );
updateSymbolPreview();
emit symbolModified();
}
}

void QgsSymbolV2SelectorDialog::displayTransparency( double alpha )
{
double transparencyPercent = ( 1 - alpha ) * 100;
mTransparencyLabel->setText( tr( "Transparency: %1%" ).arg( transparencyPercent ) );
}
@@ -25,6 +25,10 @@ class GUI_EXPORT QgsSymbolV2SelectorDialog : public QDialog, private Ui::QgsSymb
//! Reimplements dialog keyPress event so we can ignore it
void keyPressEvent( QKeyEvent * event );

private:
/**Displays alpha value as transparency in mTransparencyLabel*/
void displayTransparency( double alpha );

public slots:
void changeSymbolProperties();
void setSymbolFromStyle( const QModelIndex & index );
@@ -34,7 +38,7 @@ class GUI_EXPORT QgsSymbolV2SelectorDialog : public QDialog, private Ui::QgsSymb
void setLineWidth( double width );
void addSymbolToStyle();
void on_mSymbolUnitComboBox_currentIndexChanged( const QString & text );
void on_mOpacitySlider_valueChanged( int value );
void on_mTransparencySlider_valueChanged( int value );

signals:
void symbolModified();
@@ -68,14 +68,14 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="mOpacityLabel">
<widget class="QLabel" name="mTransparencyLabel">
<property name="text">
<string>Opacity</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="mOpacitySlider">
<widget class="QSlider" name="mTransparencySlider">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -281,7 +281,7 @@
<tabstops>
<tabstop>btnSymbolProperties</tabstop>
<tabstop>mSymbolUnitComboBox</tabstop>
<tabstop>mOpacitySlider</tabstop>
<tabstop>mTransparencySlider</tabstop>
<tabstop>spinSize</tabstop>
<tabstop>spinAngle</tabstop>
<tabstop>spinWidth</tabstop>

0 comments on commit f46f158

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