Skip to content

Commit

Permalink
[themes] Fix field expression widget not playing nice with themes
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed May 10, 2019
1 parent 05751a4 commit 28c59c3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/gui/qgsfieldexpressionwidget.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ QgsFieldExpressionWidget::QgsFieldExpressionWidget( QWidget *parent )
<< QgsExpressionContextUtils::projectScope( QgsProject::instance() ); << QgsExpressionContextUtils::projectScope( QgsProject::instance() );


mCombo->installEventFilter( this ); mCombo->installEventFilter( this );

mComboPalette = mCombo->lineEdit()->palette();
} }


void QgsFieldExpressionWidget::setExpressionDialogTitle( const QString &title ) void QgsFieldExpressionWidget::setExpressionDialogTitle( const QString &title )
Expand Down Expand Up @@ -339,10 +337,10 @@ void QgsFieldExpressionWidget::currentFieldChanged()


void QgsFieldExpressionWidget::updateLineEditStyle( const QString &expression ) void QgsFieldExpressionWidget::updateLineEditStyle( const QString &expression )
{ {
QPalette palette( mComboPalette ); QString stylesheet;
if ( !isEnabled() ) if ( !isEnabled() )
{ {
palette.setColor( QPalette::Text, Qt::gray ); stylesheet = QStringLiteral( "QLineEdit { color: %1; } Qt::gray );" ).arg( QColor( Qt::gray ).name() );
} }
else else
{ {
Expand All @@ -362,10 +360,10 @@ void QgsFieldExpressionWidget::updateLineEditStyle( const QString &expression )


if ( isExpression && !isValid ) if ( isExpression && !isValid )
{ {
palette.setColor( QPalette::Text, Qt::red ); stylesheet = QStringLiteral( "QLineEdit { color: %1; } Qt::gray );" ).arg( QColor( Qt::red ).name() );
} }
} }
mCombo->lineEdit()->setPalette( palette ); mCombo->lineEdit()->setStyleSheet( stylesheet );
} }


bool QgsFieldExpressionWidget::isExpressionValid( const QString &expressionStr ) bool QgsFieldExpressionWidget::isExpressionValid( const QString &expressionStr )
Expand Down
1 change: 0 additions & 1 deletion src/gui/qgsfieldexpressionwidget.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ class GUI_EXPORT QgsFieldExpressionWidget : public QWidget
const QgsExpressionContextGenerator *mExpressionContextGenerator = nullptr; const QgsExpressionContextGenerator *mExpressionContextGenerator = nullptr;
QString mBackupExpression; QString mBackupExpression;
bool mAllowEvalErrors = false; bool mAllowEvalErrors = false;
QPalette mComboPalette;


friend class TestQgsFieldExpressionWidget; friend class TestQgsFieldExpressionWidget;
}; };
Expand Down

0 comments on commit 28c59c3

Please sign in to comment.