Skip to content

Commit

Permalink
add transparency slider ; ui tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennesky committed Jul 17, 2012
1 parent fab96ed commit 3a1772f
Show file tree
Hide file tree
Showing 4 changed files with 343 additions and 255 deletions.
27 changes: 20 additions & 7 deletions src/app/qgsprojectproperties.cpp
Expand Up @@ -520,6 +520,7 @@ void QgsProjectProperties::apply()
QgsProject::instance()->writeEntry( "DefaultStyles", "/Line", cboStyleLine->currentText() );
QgsProject::instance()->writeEntry( "DefaultStyles", "/Fill", cboStyleFill->currentText() );
QgsProject::instance()->writeEntry( "DefaultStyles", "/ColorRamp", cboStyleColorRamp->currentText() );
QgsProject::instance()->writeEntry( "DefaultStyles", "/AlphaInt", 255 - mTransparencySlider->value() );
QgsProject::instance()->writeEntry( "DefaultStyles", "/RandomColors", cbxStyleRandomColors->isChecked() );

//todo XXX set canvas color
Expand Down Expand Up @@ -761,9 +762,13 @@ void QgsProjectProperties::populateStyles()
cboList[i]->setCurrentIndex( index );
}

// random colors?
// random colors
cbxStyleRandomColors->setChecked( QgsProject::instance()->readBoolEntry( "DefaultStyles", "/RandomColors", true ) );

// alpha transparency
int transparencyInt = 255 - QgsProject::instance()->readNumEntry( "DefaultStyles", "/AlphaInt", 255 );
mTransparencySlider->setValue( transparencyInt );
on_mTransparencySlider_valueChanged( transparencyInt );
}

void QgsProjectProperties::on_pbtnStyleManager_clicked()
Expand All @@ -788,6 +793,20 @@ void QgsProjectProperties::on_pbtnStyleFill_clicked()
editSymbol( cboStyleFill );
}

void QgsProjectProperties::on_pbtnStyleColorRamp_clicked()
{
// TODO for now just open style manager
// code in QgsStyleV2ManagerDialog::editColorRamp()
on_pbtnStyleManager_clicked();
}

void QgsProjectProperties::on_mTransparencySlider_valueChanged( int value )
{
double alpha = 1 - ( value / 255.0 );
double transparencyPercent = ( 1 - alpha ) * 100;
mTransparencyLabel->setText( tr( "Transparency %1%" ).arg(( int ) transparencyPercent ) );
}

void QgsProjectProperties::editSymbol( QComboBox* cbo )
{
QString symbolName = cbo->currentText();
Expand Down Expand Up @@ -819,10 +838,4 @@ void QgsProjectProperties::editSymbol( QComboBox* cbo )
cbo->setItemIcon( cbo->currentIndex(), icon );
}

void QgsProjectProperties::on_pbtnStyleColorRamp_clicked()
{
// TODO for now just open style manager
// code in QgsStyleV2ManagerDialog::editColorRamp()
on_pbtnStyleManager_clicked();
}

1 change: 1 addition & 0 deletions src/app/qgsprojectproperties.h
Expand Up @@ -99,6 +99,7 @@ class QgsProjectProperties : public QDialog, private Ui::QgsProjectPropertiesBas
void on_pbtnStyleLine_clicked();
void on_pbtnStyleFill_clicked();
void on_pbtnStyleColorRamp_clicked();
void on_mTransparencySlider_valueChanged( int value );

/*!
* Slot to show the context help for this dialog
Expand Down
3 changes: 3 additions & 0 deletions src/core/symbology-ng/qgssymbolv2.cpp
Expand Up @@ -95,6 +95,9 @@ QgsSymbolV2* QgsSymbolV2::defaultSymbol( QGis::GeometryType geomType )
}
}

// set alpha transparency
s->setAlpha( QgsProject::instance()->readDoubleEntry( "DefaultStyles", "/AlphaInt", 255 ) / 255.0 );

// set random color, it project prefs allow
if ( defaultSymbol == "" ||
QgsProject::instance()->readBoolEntry( "DefaultStyles", "/RandomColors", true ) )
Expand Down

0 comments on commit 3a1772f

Please sign in to comment.