Navigation Menu

Skip to content

Commit

Permalink
Flip 'alpha' to 'opacity' in gui API
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 30, 2017
1 parent d24c64f commit 9482920
Show file tree
Hide file tree
Showing 40 changed files with 177 additions and 153 deletions.
14 changes: 14 additions & 0 deletions doc/api_break.dox
Expand Up @@ -579,6 +579,14 @@ QgsColorButton {#qgis_api_break_3_0_QgsColorButton}
--------------

- Behaviour enum and its corresponding setter/getter have been renamed to Behavior <!--#spellok-->
- setAllowAlpha() and allowAlpha() were removed. Use setAllowOpacity() and allowOpacity() instead.


QgsColorDialog {#qgis_api_break_3_0_QgsColorDialog}
--------------

- setAllowAlpha() was removed. Use setAllowOpacity() instead.


QgsColorEffect {#qgis_api_break_3_0_QgsColorEffect}
-------------
Expand Down Expand Up @@ -800,6 +808,12 @@ all these item added events.
- addComposerMap no longer takes a setDefaultPreviewStyle argument.
- the mapsToRestore parameter has been removed from addItemsFromXml

QgsCompoundColorWidget {#qgis_api_break_3_0_QgsCompoundColorWidget}
----------------------

- setAllowAlpha() was removed. Use setAllowOpacity() instead.


QgsConditionalLayerStyle {#qgis_api_break_3_0_QgsConditionalLayerStyle}
------------------------

Expand Down
20 changes: 11 additions & 9 deletions python/gui/qgscolorbutton.sip
Expand Up @@ -54,20 +54,22 @@ class QgsColorButton : QToolButton
:rtype: QColor
%End

void setAllowAlpha( const bool allowAlpha );
void setAllowOpacity( const bool allowOpacity );
%Docstring
Sets whether alpha modification (transparency) is permitted
Sets whether opacity modification (transparency) is permitted
for the color. Defaults to false.
\param allowAlpha set to true to allow alpha modification
.. seealso:: allowAlpha
\param allowOpacity set to true to allow opacity modification
.. seealso:: allowOpacity()
.. versionadded:: 3.0
%End

bool allowAlpha() const;
bool allowOpacity() const;
%Docstring
Returns whether alpha modification (transparency) is permitted
Returns whether opacity modification (transparency) is permitted
for the color.
:return: true if alpha modification is allowed
.. seealso:: setAllowAlpha
:return: true if opacity modification is allowed
.. seealso:: setAllowOpacity()
.. versionadded:: 3.0
:rtype: bool
%End

Expand Down Expand Up @@ -313,7 +315,7 @@ class QgsColorButton : QToolButton
Sets color to a totally transparent color.
.. note::

If the color button is not set to show an alpha channel in the color
If the color button is not set to show an opacity channel in the color
dialog (see setColorDialogOptions) then the color will not be changed.
.. seealso:: setToNull()
%End
Expand Down
15 changes: 8 additions & 7 deletions python/gui/qgscolordialog.sip
Expand Up @@ -45,38 +45,39 @@ class QgsColorDialog : QDialog
\param title title for dialog box
%End

void setAllowAlpha( const bool allowAlpha );
void setAllowOpacity( const bool allowOpacity );
%Docstring
Sets whether alpha modification (transparency) is permitted
Sets whether opacity modification (transparency) is permitted
for the color dialog. Defaults to true.
\param allowAlpha set to false to disable alpha modification
\param allowOpacity set to false to disable opacity modification
.. versionadded:: 3.0
%End

static QColor getLiveColor( const QColor &initialColor, QObject *updateObject, const char *updateSlot,
QWidget *parent = 0,
const QString &title = QString(),
const bool allowAlpha = true );
const bool allowOpacity = true );
%Docstring
Return a color selection from a color dialog, with live updating of interim selections.
\param initialColor the initial color of the selection dialog.
\param updateObject the receiver object of the live updating.
\param updateSlot the receiver object's slot for live updating (e.g. SLOT( setValidColor( const QColor& ) ) ).
\param parent parent widget
\param title the title of the dialog.
\param allowAlpha set to true to allow modification of color alpha value (transparency)
\param allowOpacity set to true to allow modification of color opacity value (transparency)
:return: Selected color on accepted() or initialColor on rejected().
.. seealso:: getColor
:rtype: QColor
%End

static QColor getColor( const QColor &initialColor, QWidget *parent, const QString &title = QString(),
const bool allowAlpha = false );
const bool allowOpacity = false );
%Docstring
Return a color selection from a color dialog.
\param initialColor the initial color of the selection dialog.
\param parent parent widget
\param title the title of the dialog.
\param allowAlpha set to true to allow modification of color alpha value (transparency)
\param allowOpacity set to true to allow modification of color opacity value (transparency)
:return: Selected color on accepted() or initialColor on rejected().
.. seealso:: getLiveColor
:rtype: QColor
Expand Down
7 changes: 4 additions & 3 deletions python/gui/qgscompoundcolorwidget.sip
Expand Up @@ -45,11 +45,12 @@ class QgsCompoundColorWidget : QgsPanelWidget
:rtype: QColor
%End

void setAllowAlpha( const bool allowAlpha );
void setAllowOpacity( const bool allowOpacity );
%Docstring
Sets whether alpha modification (transparency) is permitted
Sets whether opacity modification (transparency) is permitted
for the color dialog. Defaults to true.
\param allowAlpha set to false to disable alpha modification
\param allowOpacity set to false to disable opacity modification
.. versionadded:: 3.0
%End

void setDiscarded( bool discarded );
Expand Down
4 changes: 2 additions & 2 deletions src/app/composer/qgscomposerarrowwidget.cpp
Expand Up @@ -43,12 +43,12 @@ QgsComposerArrowWidget::QgsComposerArrowWidget( QgsComposerArrow *arrow ): QgsCo
mainLayout->addWidget( itemPropertiesWidget );

mArrowHeadStrokeColorButton->setColorDialogTitle( tr( "Select arrow head stroke color" ) );
mArrowHeadStrokeColorButton->setAllowAlpha( true );
mArrowHeadStrokeColorButton->setAllowOpacity( true );
mArrowHeadStrokeColorButton->setContext( QStringLiteral( "composer" ) );
mArrowHeadStrokeColorButton->setNoColorString( tr( "Transparent stroke" ) );
mArrowHeadStrokeColorButton->setShowNoColor( true );
mArrowHeadFillColorButton->setColorDialogTitle( tr( "Select arrow head fill color" ) );
mArrowHeadFillColorButton->setAllowAlpha( true );
mArrowHeadFillColorButton->setAllowOpacity( true );
mArrowHeadFillColorButton->setContext( QStringLiteral( "composer" ) );
mArrowHeadFillColorButton->setNoColorString( tr( "Transparent fill" ) );
mArrowHeadFillColorButton->setShowNoColor( true );
Expand Down
8 changes: 4 additions & 4 deletions src/app/composer/qgscomposerattributetablewidget.cpp
Expand Up @@ -68,17 +68,17 @@ QgsComposerAttributeTableWidget::QgsComposerAttributeTableWidget( QgsComposerAtt
connect( mComposerMapComboBox, &QgsComposerItemComboBox::itemChanged, this, &QgsComposerAttributeTableWidget::composerMapChanged );

mHeaderFontColorButton->setColorDialogTitle( tr( "Select header font color" ) );
mHeaderFontColorButton->setAllowAlpha( true );
mHeaderFontColorButton->setAllowOpacity( true );
mHeaderFontColorButton->setContext( QStringLiteral( "composer" ) );
mContentFontColorButton->setColorDialogTitle( tr( "Select content font color" ) );
mContentFontColorButton->setAllowAlpha( true );
mContentFontColorButton->setAllowOpacity( true );
mContentFontColorButton->setContext( QStringLiteral( "composer" ) );
mGridColorButton->setColorDialogTitle( tr( "Select grid color" ) );
mGridColorButton->setAllowAlpha( true );
mGridColorButton->setAllowOpacity( true );
mGridColorButton->setContext( QStringLiteral( "composer" ) );
mGridColorButton->setDefaultColor( Qt::black );
mBackgroundColorButton->setColorDialogTitle( tr( "Select background color" ) );
mBackgroundColorButton->setAllowAlpha( true );
mBackgroundColorButton->setAllowOpacity( true );
mBackgroundColorButton->setContext( QStringLiteral( "composer" ) );
mBackgroundColorButton->setShowNoColor( true );
mBackgroundColorButton->setNoColorString( tr( "No background" ) );
Expand Down
4 changes: 2 additions & 2 deletions src/app/composer/qgscomposeritemwidget.cpp
Expand Up @@ -565,10 +565,10 @@ void QgsComposerItemWidget::setValuesForGuiElements()
}

mBackgroundColorButton->setColorDialogTitle( tr( "Select background color" ) );
mBackgroundColorButton->setAllowAlpha( true );
mBackgroundColorButton->setAllowOpacity( true );
mBackgroundColorButton->setContext( QStringLiteral( "composer" ) );
mFrameColorButton->setColorDialogTitle( tr( "Select frame color" ) );
mFrameColorButton->setAllowAlpha( true );
mFrameColorButton->setAllowOpacity( true );
mFrameColorButton->setContext( QStringLiteral( "composer" ) );

setValuesForGuiPositionElements();
Expand Down
2 changes: 1 addition & 1 deletion src/app/composer/qgscomposerlegendwidget.cpp
Expand Up @@ -75,7 +75,7 @@ QgsComposerLegendWidget::QgsComposerLegendWidget( QgsComposerLegend *legend )
mFontColorButton->setContext( QStringLiteral( "composer" ) );

mRasterStrokeColorButton->setColorDialogTitle( tr( "Select stroke color" ) );
mRasterStrokeColorButton->setAllowAlpha( true );
mRasterStrokeColorButton->setAllowOpacity( true );
mRasterStrokeColorButton->setContext( QStringLiteral( "composer " ) );

if ( legend )
Expand Down
8 changes: 4 additions & 4 deletions src/app/composer/qgscomposermapgridwidget.cpp
Expand Up @@ -58,7 +58,7 @@ QgsComposerMapGridWidget::QgsComposerMapGridWidget( QgsComposerMapGrid *mapGrid,
mAnnotationFormatComboBox->addItem( tr( "Custom" ), QgsComposerMapGrid::CustomFormat );

mAnnotationFontColorButton->setColorDialogTitle( tr( "Select font color" ) );
mAnnotationFontColorButton->setAllowAlpha( true );
mAnnotationFontColorButton->setAllowOpacity( true );
mAnnotationFontColorButton->setContext( QStringLiteral( "composer" ) );

insertAnnotationDisplayEntries( mAnnotationDisplayLeftComboBox );
Expand All @@ -77,19 +77,19 @@ QgsComposerMapGridWidget::QgsComposerMapGridWidget( QgsComposerMapGrid *mapGrid,
insertAnnotationDirectionEntries( mAnnotationDirectionComboBoxBottom );

mGridFramePenColorButton->setColorDialogTitle( tr( "Select grid frame color" ) );
mGridFramePenColorButton->setAllowAlpha( true );
mGridFramePenColorButton->setAllowOpacity( true );
mGridFramePenColorButton->setContext( QStringLiteral( "composer" ) );
mGridFramePenColorButton->setNoColorString( tr( "Transparent frame" ) );
mGridFramePenColorButton->setShowNoColor( true );

mGridFrameFill1ColorButton->setColorDialogTitle( tr( "Select grid frame fill color" ) );
mGridFrameFill1ColorButton->setAllowAlpha( true );
mGridFrameFill1ColorButton->setAllowOpacity( true );
mGridFrameFill1ColorButton->setContext( QStringLiteral( "composer" ) );
mGridFrameFill1ColorButton->setNoColorString( tr( "Transparent fill" ) );
mGridFrameFill1ColorButton->setShowNoColor( true );

mGridFrameFill2ColorButton->setColorDialogTitle( tr( "Select grid frame fill color" ) );
mGridFrameFill2ColorButton->setAllowAlpha( true );
mGridFrameFill2ColorButton->setAllowOpacity( true );
mGridFrameFill2ColorButton->setContext( QStringLiteral( "composer" ) );
mGridFrameFill2ColorButton->setNoColorString( tr( "Transparent fill" ) );
mGridFrameFill2ColorButton->setShowNoColor( true );
Expand Down
8 changes: 4 additions & 4 deletions src/app/composer/qgscomposerpicturewidget.cpp
Expand Up @@ -39,10 +39,10 @@ QgsComposerPictureWidget::QgsComposerPictureWidget( QgsComposerPicture *picture
setupUi( this );
setPanelTitle( tr( "Picture properties" ) );

mFillColorButton->setAllowAlpha( true );
mFillColorButton->setAllowOpacity( true );
mFillColorButton->setColorDialogTitle( tr( "Select fill color" ) );
mFillColorButton->setContext( QStringLiteral( "composer" ) );
mStrokeColorButton->setAllowAlpha( true );
mStrokeColorButton->setAllowOpacity( true );
mStrokeColorButton->setColorDialogTitle( tr( "Select stroke color" ) );
mStrokeColorButton->setContext( QStringLiteral( "composer" ) );

Expand Down Expand Up @@ -481,7 +481,7 @@ void QgsComposerPictureWidget::updateSvgParamGui( bool resetValues )
mFillColorButton->setColor( fill );
}
mFillColorButton->setEnabled( hasFillParam );
mFillColorButton->setAllowAlpha( hasFillOpacityParam );
mFillColorButton->setAllowOpacity( hasFillOpacityParam );
if ( resetValues )
{
QColor stroke = mStrokeColorButton->color();
Expand All @@ -494,7 +494,7 @@ void QgsComposerPictureWidget::updateSvgParamGui( bool resetValues )
mStrokeColorButton->setColor( stroke );
}
mStrokeColorButton->setEnabled( hasStrokeParam );
mStrokeColorButton->setAllowAlpha( hasStrokeOpacityParam );
mStrokeColorButton->setAllowOpacity( hasStrokeOpacityParam );
if ( hasDefaultStrokeWidth && resetValues )
{
mStrokeWidthSpinBox->setValue( defaultStrokeWidth );
Expand Down
8 changes: 4 additions & 4 deletions src/app/composer/qgscomposerscalebarwidget.cpp
Expand Up @@ -61,23 +61,23 @@ QgsComposerScaleBarWidget::QgsComposerScaleBarWidget( QgsComposerScaleBar *scale
mUnitsComboBox->insertItem( 3, tr( "Nautical Miles" ), QgsUnitTypes::DistanceNauticalMiles );

mFillColorButton->setColorDialogTitle( tr( "Select fill color" ) );
mFillColorButton->setAllowAlpha( true );
mFillColorButton->setAllowOpacity( true );
mFillColorButton->setContext( QStringLiteral( "composer" ) );
mFillColorButton->setNoColorString( tr( "Transparent fill" ) );
mFillColorButton->setShowNoColor( true );

mFillColor2Button->setColorDialogTitle( tr( "Select alternate fill color" ) );
mFillColor2Button->setAllowAlpha( true );
mFillColor2Button->setAllowOpacity( true );
mFillColor2Button->setContext( QStringLiteral( "composer" ) );
mFillColor2Button->setNoColorString( tr( "Transparent fill" ) );
mFillColor2Button->setShowNoColor( true );

mFontColorButton->setColorDialogTitle( tr( "Select font color" ) );
mFontColorButton->setAllowAlpha( true );
mFontColorButton->setAllowOpacity( true );
mFontColorButton->setContext( QStringLiteral( "composer" ) );

mStrokeColorButton->setColorDialogTitle( tr( "Select line color" ) );
mStrokeColorButton->setAllowAlpha( true );
mStrokeColorButton->setAllowOpacity( true );
mStrokeColorButton->setContext( QStringLiteral( "composer" ) );
mStrokeColorButton->setNoColorString( tr( "Transparent line" ) );
mStrokeColorButton->setShowNoColor( true );
Expand Down
4 changes: 2 additions & 2 deletions src/app/composer/qgscomposertablebackgroundcolorsdialog.cpp
Expand Up @@ -119,12 +119,12 @@ void QgsComposerTableBackgroundColorsDialog::setGuiElementValues()
continue;
button->setEnabled( mComposerTable->cellStyle( styleGroup )->enabled );
button->setColor( mComposerTable->cellStyle( styleGroup )->cellBackgroundColor );
button->setAllowAlpha( true );
button->setAllowOpacity( true );
button->setColorDialogTitle( tr( "Select background color" ) );
}

mDefaultColorButton->setColor( mComposerTable->backgroundColor() );
mDefaultColorButton->setAllowAlpha( true );
mDefaultColorButton->setAllowOpacity( true );
mDefaultColorButton->setColorDialogTitle( tr( "Select background color" ) );
mDefaultColorButton->setShowNoColor( true );
mDefaultColorButton->setNoColorString( tr( "No background" ) );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsdecorationcopyrightdialog.cpp
Expand Up @@ -50,7 +50,7 @@ QgsDecorationCopyrightDialog::QgsDecorationCopyrightDialog( QgsDecorationCopyrig
wgtUnitSelection->setUnit( mDeco.mMarginUnit );

// color
pbnColorChooser->setAllowAlpha( true );
pbnColorChooser->setAllowOpacity( true );
pbnColorChooser->setColor( mDeco.mColor );
pbnColorChooser->setContext( QStringLiteral( "gui" ) );
pbnColorChooser->setColorDialogTitle( tr( "Select text color" ) );
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsdecorationnortharrowdialog.cpp
Expand Up @@ -56,12 +56,12 @@ QgsDecorationNorthArrowDialog::QgsDecorationNorthArrowDialog( QgsDecorationNorth
// automatic
cboxAutomatic->setChecked( mDeco.mAutomatic );

pbnChangeColor->setAllowAlpha( true );
pbnChangeColor->setAllowOpacity( true );
pbnChangeColor->setColor( mDeco.mColor );
pbnChangeColor->setContext( QStringLiteral( "gui" ) );
pbnChangeColor->setColorDialogTitle( tr( "Select north arrow fill color" ) );

pbnChangeOutlineColor->setAllowAlpha( true );
pbnChangeOutlineColor->setAllowOpacity( true );
pbnChangeOutlineColor->setColor( mDeco.mOutlineColor );
pbnChangeOutlineColor->setContext( QStringLiteral( "gui" ) );
pbnChangeOutlineColor->setColorDialogTitle( tr( "Select north arrow outline color" ) );
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsdecorationscalebardialog.cpp
Expand Up @@ -71,12 +71,12 @@ QgsDecorationScaleBarDialog::QgsDecorationScaleBarDialog( QgsDecorationScaleBar

cboStyle->setCurrentIndex( mDeco.mStyleIndex );

pbnChangeColor->setAllowAlpha( true );
pbnChangeColor->setAllowOpacity( true );
pbnChangeColor->setColor( mDeco.mColor );
pbnChangeColor->setContext( QStringLiteral( "gui" ) );
pbnChangeColor->setColorDialogTitle( tr( "Select scale bar fill color" ) );

pbnChangeOutlineColor->setAllowAlpha( true );
pbnChangeOutlineColor->setAllowOpacity( true );
pbnChangeOutlineColor->setColor( mDeco.mOutlineColor );
pbnChangeOutlineColor->setContext( QStringLiteral( "gui" ) );
pbnChangeOutlineColor->setColorDialogTitle( tr( "Select scale bar outline color" ) );
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsdiagramproperties.cpp
Expand Up @@ -85,12 +85,12 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer *layer, QWidget *pare
mSizeFieldExpressionWidget->registerExpressionContextGenerator( this );

mBackgroundColorButton->setColorDialogTitle( tr( "Select background color" ) );
mBackgroundColorButton->setAllowAlpha( true );
mBackgroundColorButton->setAllowOpacity( true );
mBackgroundColorButton->setContext( QStringLiteral( "symbology" ) );
mBackgroundColorButton->setShowNoColor( true );
mBackgroundColorButton->setNoColorString( tr( "Transparent background" ) );
mDiagramPenColorButton->setColorDialogTitle( tr( "Select pen color" ) );
mDiagramPenColorButton->setAllowAlpha( true );
mDiagramPenColorButton->setAllowOpacity( true );
mDiagramPenColorButton->setContext( QStringLiteral( "symbology" ) );
mDiagramPenColorButton->setShowNoColor( true );
mDiagramPenColorButton->setNoColorString( tr( "Transparent stroke" ) );
Expand Down
10 changes: 5 additions & 5 deletions src/app/qgsoptions.cpp
Expand Up @@ -126,7 +126,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
connect( cmbUITheme, static_cast<void ( QComboBox::* )( const QString & )>( &QComboBox::currentIndexChanged ), this, &QgsOptions::uiThemeChanged );

mIdentifyHighlightColorButton->setColorDialogTitle( tr( "Identify highlight color" ) );
mIdentifyHighlightColorButton->setAllowAlpha( true );
mIdentifyHighlightColorButton->setAllowOpacity( true );
mIdentifyHighlightColorButton->setContext( QStringLiteral( "gui" ) );
mIdentifyHighlightColorButton->setDefaultColor( Qgis::DEFAULT_HIGHLIGHT_COLOR );

Expand Down Expand Up @@ -684,7 +684,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
int myAlpha = mSettings->value( QStringLiteral( "/qgis/default_selection_color_alpha" ), 255 ).toInt();
pbnSelectionColor->setColor( QColor( myRed, myGreen, myBlue, myAlpha ) );
pbnSelectionColor->setColorDialogTitle( tr( "Set selection color" ) );
pbnSelectionColor->setAllowAlpha( true );
pbnSelectionColor->setAllowOpacity( true );
pbnSelectionColor->setContext( QStringLiteral( "gui" ) );
pbnSelectionColor->setDefaultColor( QColor( 255, 255, 0, 255 ) );

Expand Down Expand Up @@ -790,7 +790,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
QColor gridColor = QColor( gridRed, gridGreen, gridBlue, gridAlpha );
mGridColorButton->setColor( gridColor );
mGridColorButton->setColorDialogTitle( tr( "Select grid color" ) );
mGridColorButton->setAllowAlpha( true );
mGridColorButton->setAllowOpacity( true );
mGridColorButton->setContext( QStringLiteral( "gui" ) );
mGridColorButton->setDefaultColor( QColor( 190, 190, 190, 100 ) );

Expand Down Expand Up @@ -844,7 +844,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
myBlue = mSettings->value( QStringLiteral( "/qgis/digitizing/line_color_blue" ), 0 ).toInt();
myAlpha = mSettings->value( QStringLiteral( "/qgis/digitizing/line_color_alpha" ), 200 ).toInt();
mLineColorToolButton->setColor( QColor( myRed, myGreen, myBlue, myAlpha ) );
mLineColorToolButton->setAllowAlpha( true );
mLineColorToolButton->setAllowOpacity( true );
mLineColorToolButton->setContext( QStringLiteral( "gui" ) );
mLineColorToolButton->setDefaultColor( QColor( 255, 0, 0, 200 ) );

Expand All @@ -853,7 +853,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
myBlue = mSettings->value( QStringLiteral( "/qgis/digitizing/fill_color_blue" ), 0 ).toInt();
myAlpha = mSettings->value( QStringLiteral( "/qgis/digitizing/fill_color_alpha" ), 30 ).toInt();
mFillColorToolButton->setColor( QColor( myRed, myGreen, myBlue, myAlpha ) );
mFillColorToolButton->setAllowAlpha( true );
mFillColorToolButton->setAllowOpacity( true );
mFillColorToolButton->setContext( QStringLiteral( "gui" ) );
mFillColorToolButton->setDefaultColor( QColor( 255, 0, 0, 30 ) );

Expand Down

0 comments on commit 9482920

Please sign in to comment.