Skip to content
Permalink
Browse files

Use QgsOpacityWidget wherever appropriate

  • Loading branch information
nyalldawson committed May 30, 2017
1 parent eed758e commit d24c64f8dfa027fe46cbbb6b52510f71532db1dc
Showing with 871 additions and 1,850 deletions.
  1. +6 −15 src/app/composer/qgscomposeritemwidget.cpp
  2. +1 −1 src/app/composer/qgscomposeritemwidget.h
  3. +2 −7 src/app/qgsdiagramproperties.cpp
  4. +5 −19 src/app/qgsprojectproperties.cpp
  5. +0 −2 src/app/qgsprojectproperties.h
  6. +2 −14 src/app/qgsrasterlayerproperties.cpp
  7. +0 −2 src/app/qgsrasterlayerproperties.h
  8. +28 −80 src/gui/effects/qgspainteffectwidget.cpp
  9. +5 −10 src/gui/effects/qgspainteffectwidget.h
  10. +1 −1 src/gui/qgsopacitywidget.cpp
  11. +16 −24 src/gui/qgstextformatwidget.cpp
  12. +3 −13 src/gui/raster/qgsrastertransparencywidget.cpp
  13. +0 −3 src/gui/raster/qgsrastertransparencywidget.h
  14. +7 −8 src/gui/symbology-ng/qgsrendererpropertiesdialog.cpp
  15. +6 −11 src/gui/symbology-ng/qgssymbollayerwidget.cpp
  16. +1 −1 src/gui/symbology-ng/qgssymbollayerwidget.h
  17. +4 −9 src/gui/symbology-ng/qgssymbolslistwidget.cpp
  18. +1 −1 src/gui/symbology-ng/qgssymbolslistwidget.h
  19. +32 −62 src/ui/composer/qgscomposeritemwidgetbase.ui
  20. +14 −70 src/ui/effects/widget_blur.ui
  21. +14 −66 src/ui/effects/widget_coloreffects.ui
  22. +15 −71 src/ui/effects/widget_drawsource.ui
  23. +14 −65 src/ui/effects/widget_glow.ui
  24. +14 −65 src/ui/effects/widget_shadoweffect.ui
  25. +16 −70 src/ui/qgsdiagrampropertiesbase.ui
  26. +34 −73 src/ui/qgsprojectpropertiesbase.ui
  27. +75 −149 src/ui/qgsrasterlayerpropertiesbase.ui
  28. +34 −70 src/ui/qgsrendererv2propsdialogbase.ui
  29. +442 −662 src/ui/qgstextformatwidgetbase.ui
  30. +41 −91 src/ui/raster/qgsrastertransparencywidget.ui
  31. +18 −53 src/ui/symbollayer/widget_rasterfill.ui
  32. +20 −62 src/ui/symbollayer/widget_symbolslist.ui
@@ -165,14 +165,11 @@ QgsComposerItemWidget::QgsComposerItemWidget( QWidget *parent, QgsComposerItem *

initializeDataDefinedButtons();

mOpacitySpnBx->setClearValue( 100.0 );

setValuesForGuiElements();
connect( mItem->composition(), &QgsComposition::paperSizeChanged, this, &QgsComposerItemWidget::setValuesForGuiPositionElements );
connect( mItem, &QgsComposerItem::sizeChanged, this, &QgsComposerItemWidget::setValuesForGuiPositionElements );
connect( mItem, &QgsComposerObject::itemChanged, this, &QgsComposerItemWidget::setValuesForGuiNonPositionElements );

connect( mOpacitySlider, &QAbstractSlider::valueChanged, this, [ = ]( int value ) { mOpacitySpnBx->setValue( value / 10.0 ); } );
connect( mOpacityWidget, &QgsOpacityWidget::opacityChanged, this, &QgsComposerItemWidget::opacityChanged );

updateVariables();
connect( mVariableEditor, &QgsVariableEditorWidget::scopeChanged, this, &QgsComposerItemWidget::variablesChanged );
@@ -506,8 +503,7 @@ void QgsComposerItemWidget::setValuesForGuiNonPositionElements()
mBackgroundGroupBox->blockSignals( true );
mItemIdLineEdit->blockSignals( true );
mBlendModeCombo->blockSignals( true );
mOpacitySlider->blockSignals( true );
mOpacitySpnBx->blockSignals( true );
mOpacityWidget->blockSignals( true );
mFrameColorButton->blockSignals( true );
mFrameJoinStyleCombo->blockSignals( true );
mBackgroundColorButton->blockSignals( true );
@@ -522,8 +518,7 @@ void QgsComposerItemWidget::setValuesForGuiNonPositionElements()
mFrameGroupBox->setChecked( mItem->hasFrame() );
mBackgroundGroupBox->setChecked( mItem->hasBackground() );
mBlendModeCombo->setBlendMode( mItem->blendMode() );
mOpacitySlider->setValue( mItem->itemOpacity() * 1000.0 );
mOpacitySpnBx->setValue( mItem->itemOpacity() * 100.0 );
mOpacityWidget->setOpacity( mItem->itemOpacity() );
mItemRotationSpinBox->setValue( mItem->itemRotation( QgsComposerObject::OriginalValue ) );
mExcludeFromPrintsCheckBox->setChecked( mItem->excludeFromExports( QgsComposerObject::OriginalValue ) );

@@ -535,8 +530,7 @@ void QgsComposerItemWidget::setValuesForGuiNonPositionElements()
mBackgroundGroupBox->blockSignals( false );
mItemIdLineEdit->blockSignals( false );
mBlendModeCombo->blockSignals( false );
mOpacitySlider->blockSignals( false );
mOpacitySpnBx->blockSignals( false );
mOpacityWidget->blockSignals( false );
mItemRotationSpinBox->blockSignals( false );
mExcludeFromPrintsCheckBox->blockSignals( false );
}
@@ -593,15 +587,12 @@ void QgsComposerItemWidget::on_mBlendModeCombo_currentIndexChanged( int index )
}
}

void QgsComposerItemWidget::on_mOpacitySpnBx_valueChanged( double value )
void QgsComposerItemWidget::opacityChanged( double value )
{
mOpacitySlider->blockSignals( true );
mOpacitySlider->setValue( value * 10 );
mOpacitySlider->blockSignals( false );
if ( mItem )
{
mItem->beginCommand( tr( "Item opacity changed" ), QgsComposerMergeCommand::ItemOpacity );
mItem->setItemOpacity( value / 100.0 );
mItem->setItemOpacity( value );
mItem->endCommand();
}
}
@@ -172,7 +172,7 @@ class QgsComposerItemWidget: public QWidget, private Ui::QgsComposerItemWidgetBa
void on_mLowerRightCheckBox_stateChanged( int state );

void on_mBlendModeCombo_currentIndexChanged( int index );
void on_mOpacitySpnBx_valueChanged( double value );
void opacityChanged( double value );

void on_mItemRotationSpinBox_valueChanged( double val );
void on_mExcludeFromPrintsCheckBox_toggled( bool checked );
@@ -94,7 +94,6 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer *layer, QWidget *pare
mDiagramPenColorButton->setContext( QStringLiteral( "symbology" ) );
mDiagramPenColorButton->setShowNoColor( true );
mDiagramPenColorButton->setNoColorString( tr( "Transparent stroke" ) );
mOpacitySpinBox->setClearValue( 100.0 );

mMaxValueSpinBox->setShowClearButton( false );

@@ -262,8 +261,7 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer *layer, QWidget *pare
mDiagramFont = settingList.at( 0 ).font;
QSizeF size = settingList.at( 0 ).size;
mBackgroundColorButton->setColor( settingList.at( 0 ).backgroundColor );
mOpacitySpinBox->setValue( settingList.at( 0 ).opacity * 100.0 );
mOpacitySlider->setValue( mOpacitySpinBox->value() * 10 );
mOpacityWidget->setOpacity( settingList.at( 0 ).opacity );
mDiagramPenColorButton->setColor( settingList.at( 0 ).penColor );
mPenWidthSpinBox->setValue( settingList.at( 0 ).penWidth );
mDiagramSizeSpinBox->setValue( ( size.width() + size.height() ) / 2.0 );
@@ -405,9 +403,6 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer *layer, QWidget *pare
}

connect( mAddAttributeExpression, &QPushButton::clicked, this, &QgsDiagramProperties::showAddAttributeExpressionDialog );
connect( mOpacitySlider, &QSlider::valueChanged, this, [ = ]( int value ) { mOpacitySpinBox->setValue( value / 10.0 ); } );
connect( mOpacitySpinBox, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ), this, [ = ]( double value ) { mOpacitySlider->setValue( value * 10 ); } );

registerDataDefinedButton( mBackgroundColorDDBtn, QgsDiagramLayerSettings::BackgroundColor );
registerDataDefinedButton( mLineColorDDBtn, QgsDiagramLayerSettings::StrokeColor );
registerDataDefinedButton( mLineWidthDDBtn, QgsDiagramLayerSettings::StrokeWidth );
@@ -739,7 +734,7 @@ void QgsDiagramProperties::apply()
QgsDiagramSettings ds;
ds.enabled = ( mDiagramTypeComboBox->currentIndex() != 0 );
ds.font = mDiagramFont;
ds.opacity = mOpacitySpinBox->value() / 100.0;
ds.opacity = mOpacityWidget->opacity();

QList<QColor> categoryColors;
QList<QString> categoryAttributes;
@@ -1133,7 +1133,7 @@ void QgsProjectProperties::apply()
QgsProject::instance()->writeEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/Line" ), cboStyleLine->currentText() );
QgsProject::instance()->writeEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/Fill" ), cboStyleFill->currentText() );
QgsProject::instance()->writeEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/ColorRamp" ), cboStyleColorRamp->currentText() );
QgsProject::instance()->writeEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/Opacity" ), 1.0 - mTransparencySlider->value() / 100.0 );
QgsProject::instance()->writeEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/Opacity" ), mDefaultOpacityWidget->opacity() );
QgsProject::instance()->writeEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/RandomColors" ), cbxStyleRandomColors->isChecked() );
if ( mTreeProjectColors->isDirty() )
{
@@ -1687,16 +1687,16 @@ void QgsProjectProperties::populateStyles()
cbxStyleRandomColors->setChecked( QgsProject::instance()->readBoolEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/RandomColors" ), true ) );

// alpha transparency
int transparencyInt = 255;
double opacity = 1.0;
bool ok = false;
double alpha = QgsProject::instance()->readDoubleEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/AlphaInt" ), 255, &ok );
if ( ok )
transparencyInt = alpha;
opacity = 1.0 - alpha / 255.0;
double newOpacity = QgsProject::instance()->readDoubleEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/Opacity" ), 1.0, &ok );
if ( ok )
transparencyInt = 255 - newOpacity * 255.0;
opacity = newOpacity;

mTransparencySlider->setValue( transparencyInt );
mDefaultOpacityWidget->setOpacity( opacity );
}

void QgsProjectProperties::on_pbtnStyleManager_clicked()
@@ -1728,20 +1728,6 @@ void QgsProjectProperties::on_pbtnStyleColorRamp_clicked()
on_pbtnStyleManager_clicked();
}

void QgsProjectProperties::on_mTransparencySlider_valueChanged( int value )
{
mTransparencySpinBox->blockSignals( true );
mTransparencySpinBox->setValue( value );
mTransparencySpinBox->blockSignals( false );
}

void QgsProjectProperties::on_mTransparencySpinBox_valueChanged( int value )
{
mTransparencySlider->blockSignals( true );
mTransparencySlider->setValue( value );
mTransparencySlider->blockSignals( false );
}

void QgsProjectProperties::editSymbol( QComboBox *cbo )
{
QString symbolName = cbo->currentText();
@@ -124,8 +124,6 @@ class APP_EXPORT QgsProjectProperties : public QgsOptionsDialogBase, private Ui:
void on_pbtnStyleLine_clicked();
void on_pbtnStyleFill_clicked();
void on_pbtnStyleColorRamp_clicked();
void on_mTransparencySlider_valueChanged( int value );
void on_mTransparencySpinBox_valueChanged( int value );

/**
* Slot to show the context help for this dialog
@@ -112,8 +112,6 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanv

connect( mOptionsStackedWidget, &QStackedWidget::currentChanged, this, &QgsRasterLayerProperties::mOptionsStackedWidget_CurrentChanged );

connect( sliderTransparency, &QAbstractSlider::valueChanged, this, &QgsRasterLayerProperties::sliderTransparency_valueChanged );

// brightness/contrast controls
connect( mSliderBrightness, &QAbstractSlider::valueChanged, mBrightnessSpinBox, &QSpinBox::setValue );
connect( mBrightnessSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), mSliderBrightness, &QAbstractSlider::setValue );
@@ -651,10 +649,7 @@ void QgsRasterLayerProperties::sync()
QgsRasterRenderer *renderer = mRasterLayer->renderer();
if ( renderer )
{
sliderTransparency->setValue( ( 1.0 - renderer->opacity() ) * 255 );
//update the transparency percentage label
sliderTransparency_valueChanged( ( 1.0 - renderer->opacity() ) * 255 );

mOpacityWidget->setOpacity( renderer->opacity() );
cboxTransparencyBand->setBand( renderer->alphaBand() );
}

@@ -904,7 +899,7 @@ void QgsRasterLayerProperties::apply()
rasterRenderer->setRasterTransparency( rasterTransparency );

//set global transparency
rasterRenderer->setOpacity( ( 255 - sliderTransparency->value() ) / 255.0 );
rasterRenderer->setOpacity( mOpacityWidget->opacity() );
}

QgsDebugMsg( "processing general tab" );
@@ -1613,13 +1608,6 @@ void QgsRasterLayerProperties::pixelSelected( const QgsPoint &canvasPoint )
tableTransparency->resizeRowsToContents();
}

void QgsRasterLayerProperties::sliderTransparency_valueChanged( int value )
{
//set the transparency percentage label to a suitable value
int myInt = static_cast < int >( ( value / 255.0 ) * 100 ); //255.0 to prevent integer division
lblTransparencyPercent->setText( QString::number( myInt ) + '%' );
}//sliderTransparency_valueChanged

void QgsRasterLayerProperties::toggleSaturationControls( int grayscaleMode )
{
// Enable or disable saturation controls based on choice of grayscale mode
@@ -84,8 +84,6 @@ class APP_EXPORT QgsRasterLayerProperties : public QgsOptionsDialogBase, private
//void on_btnResetNull_clicked();

void pixelSelected( const QgsPoint & );
//! \brief slot executed when the transparency level changes.
void sliderTransparency_valueChanged( int );

private slots:
void on_mRenderTypeComboBox_currentIndexChanged( int index );

0 comments on commit d24c64f

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