Skip to content

Commit

Permalink
style(ColorWidget): s/supportDirection/hasDirection
Browse files Browse the repository at this point in the history
  • Loading branch information
troopa81 authored and nyalldawson committed Aug 26, 2024
1 parent 2f69449 commit 4170027
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions src/gui/qgsgradientcolorrampdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@

#include "qgsgradientcolorrampdialog.h"

#include "qgscolorramp.h"
#include "qgsdialog.h"
#include "qgscolordialog.h"
#include "qgscptcityarchive.h"
#include "qgssettings.h"
#include "qgsgui.h"
Expand Down Expand Up @@ -65,12 +63,12 @@ QgsGradientColorRampDialog::QgsGradientColorRampDialog( const QgsGradientColorRa
mStopDirection->addItem( tr( "Counterclockwise" ), static_cast< int >( Qgis::AngularDirection::CounterClockwise ) );
mStopDirection->setCurrentIndex( mStopColorSpec->findData( static_cast< int >( ramp.direction() ) ) );

mStopDirection->setEnabled( supportDirection( static_cast< QColor::Spec>( mStopColorSpec->currentData().toInt() ) ) );
mStopDirection->setEnabled( hasDirection( static_cast< QColor::Spec>( mStopColorSpec->currentData().toInt() ) ) );

connect( mStopColorSpec, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, [ = ]
{
const QColor::Spec colorSpec = static_cast< QColor::Spec>( mStopColorSpec->currentData().toInt() );
mStopDirection->setEnabled( supportDirection( colorSpec ) );
mStopDirection->setEnabled( hasDirection( colorSpec ) );

if ( colorSpec != mColorWidget->color().spec() )
{
Expand Down Expand Up @@ -369,7 +367,7 @@ void QgsGradientColorRampDialog::selectedStopChanged( const QgsGradientStop &sto

// first stop cannot have color spec or direction set
mStopColorSpec->setEnabled( !( stop.offset == 0 && stop.color == mRamp.color1() ) );
mStopDirection->setEnabled( !( stop.offset == 0 && stop.color == mRamp.color1() ) && supportDirection( mStopEditor->selectedStop().colorSpec() ) );
mStopDirection->setEnabled( !( stop.offset == 0 && stop.color == mRamp.color1() ) && hasDirection( mStopEditor->selectedStop().colorSpec() ) );

updatePlot();
}
Expand Down Expand Up @@ -539,7 +537,7 @@ void QgsGradientColorRampDialog::addMarkersForColor( double x, const QColor &col
addPlotMarker( x, color.alphaF(), color, isSelected && mCurrentPlotColorComponent == 3 );
}

bool QgsGradientColorRampDialog::supportDirection( QColor::Spec colorSpec )
bool QgsGradientColorRampDialog::hasDirection( QColor::Spec colorSpec )
{
switch ( colorSpec )
{
Expand Down Expand Up @@ -637,7 +635,7 @@ void QgsGradientColorRampDialog::updateRampFromStopEditor()

// first stop cannot have color spec or direction set
mStopColorSpec->setEnabled( !( mStopEditor->selectedStop().offset == 0 && mStopEditor->selectedStop().color == mRamp.color1() ) );
mStopDirection->setEnabled( !( mStopEditor->selectedStop().offset == 0 && mStopEditor->selectedStop().color == mRamp.color1() ) && supportDirection( mStopEditor->selectedStop().colorSpec() ) );
mStopDirection->setEnabled( !( mStopEditor->selectedStop().offset == 0 && mStopEditor->selectedStop().color == mRamp.color1() ) && hasDirection( mStopEditor->selectedStop().colorSpec() ) );

updateColorButtons();
updatePlot();
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsgradientcolorrampdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class GUI_EXPORT QgsGradientColorRampDialog : public QDialog, private Ui::QgsGra
void addMarkersForColor( double x, const QColor &color, bool isSelected = false );

// Returns TRUE if it's possible to edit direction regarding given colorSpec
static bool supportDirection( QColor::Spec colorSpec );
static bool hasDirection( QColor::Spec colorSpec );
};


Expand Down

0 comments on commit 4170027

Please sign in to comment.