Skip to content

Commit 28c59c3

Browse files
committed
[themes] Fix field expression widget not playing nice with themes
1 parent 05751a4 commit 28c59c3

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/gui/qgsfieldexpressionwidget.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ QgsFieldExpressionWidget::QgsFieldExpressionWidget( QWidget *parent )
7171
<< QgsExpressionContextUtils::projectScope( QgsProject::instance() );
7272

7373
mCombo->installEventFilter( this );
74-
75-
mComboPalette = mCombo->lineEdit()->palette();
7674
}
7775

7876
void QgsFieldExpressionWidget::setExpressionDialogTitle( const QString &title )
@@ -339,10 +337,10 @@ void QgsFieldExpressionWidget::currentFieldChanged()
339337

340338
void QgsFieldExpressionWidget::updateLineEditStyle( const QString &expression )
341339
{
342-
QPalette palette( mComboPalette );
340+
QString stylesheet;
343341
if ( !isEnabled() )
344342
{
345-
palette.setColor( QPalette::Text, Qt::gray );
343+
stylesheet = QStringLiteral( "QLineEdit { color: %1; } Qt::gray );" ).arg( QColor( Qt::gray ).name() );
346344
}
347345
else
348346
{
@@ -362,10 +360,10 @@ void QgsFieldExpressionWidget::updateLineEditStyle( const QString &expression )
362360

363361
if ( isExpression && !isValid )
364362
{
365-
palette.setColor( QPalette::Text, Qt::red );
363+
stylesheet = QStringLiteral( "QLineEdit { color: %1; } Qt::gray );" ).arg( QColor( Qt::red ).name() );
366364
}
367365
}
368-
mCombo->lineEdit()->setPalette( palette );
366+
mCombo->lineEdit()->setStyleSheet( stylesheet );
369367
}
370368

371369
bool QgsFieldExpressionWidget::isExpressionValid( const QString &expressionStr )

src/gui/qgsfieldexpressionwidget.h

-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ class GUI_EXPORT QgsFieldExpressionWidget : public QWidget
249249
const QgsExpressionContextGenerator *mExpressionContextGenerator = nullptr;
250250
QString mBackupExpression;
251251
bool mAllowEvalErrors = false;
252-
QPalette mComboPalette;
253252

254253
friend class TestQgsFieldExpressionWidget;
255254
};

0 commit comments

Comments
 (0)