Skip to content

Commit

Permalink
use opactify in colorbutton when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Apr 23, 2023
1 parent 92a0015 commit de1363d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
Expand Up @@ -59,6 +59,9 @@ Returns the setting
virtual bool configureEditorPrivate( QWidget *editor, const QgsSettingsEntryBase *setting );

virtual void configureEditorPrivateImplementation();
%Docstring
To be re-implemented to implemeent type specific configuration (e.g. opacity for colors)
%End

};

Expand Down Expand Up @@ -228,6 +231,9 @@ typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryColor,QgsColorBut

virtual bool setWidgetValue( const QColor &value ) const;


virtual void configureEditorPrivateImplementation();

};


Expand Down
12 changes: 12 additions & 0 deletions src/gui/settings/qgssettingseditorwidgetwrapperimpl.cpp
Expand Up @@ -250,6 +250,18 @@ bool QgsSettingsColorEditorWidgetWrapper::setWidgetValue( const QColor &value )
return false;
}

void QgsSettingsColorEditorWidgetWrapper::configureEditorPrivateImplementation()
{
if ( mEditor )
{
mEditor->setAllowOpacity( mSetting->allowAlpha() );
}
else
{
QgsDebugMsg( QStringLiteral( "Settings editor not set for %1" ).arg( mSetting->definitionKey() ) );
}
}

bool QgsSettingsColorEditorWidgetWrapper::setSettingFromWidget() const
{
if ( mEditor )
Expand Down
3 changes: 3 additions & 0 deletions src/gui/settings/qgssettingseditorwidgetwrapperimpl.h
Expand Up @@ -103,6 +103,7 @@ class GUI_EXPORT QgsSettingsEditorWidgetWrapperTemplate : public QgsSettingsEdit
return false;
}

//! To be re-implemented to implemeent type specific configuration (e.g. opacity for colors)
virtual void configureEditorPrivateImplementation() {}

const T *mSetting = nullptr;
Expand Down Expand Up @@ -225,6 +226,8 @@ class GUI_EXPORT QgsSettingsColorEditorWidgetWrapper : public QgsSettingsEditorW
QColor valueFromWidget() const override;

bool setWidgetValue( const QColor &value ) const override;

void configureEditorPrivateImplementation() override;
};

///**
Expand Down

0 comments on commit de1363d

Please sign in to comment.