mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
[editwidgets] text color for r/o line edits matches disabled color
Line edits are set to readonly to make it possible to copy values from disabled forms. Unfortunately Qt uses a style that makes them look editable even though they are not. This patches the text color to have the appearance that hints an uneditable widget. Fix #11413
This commit is contained in:
parent
cd59091b9c
commit
3d9ba705de
@ -105,6 +105,10 @@ void QgsTextEditWrapper::initWidget( QWidget* editor )
|
||||
}
|
||||
|
||||
connect( mLineEdit, SIGNAL( textChanged( QString ) ), this, SLOT( valueChanged( QString ) ) );
|
||||
|
||||
mWritablePalette = mLineEdit->palette();
|
||||
mReadOnlyPalette = mLineEdit->palette();
|
||||
mReadOnlyPalette.setColor( QPalette::Text, mWritablePalette.color( QPalette::Disabled, QPalette::Text ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,5 +147,11 @@ void QgsTextEditWrapper::setEnabled( bool enabled )
|
||||
mPlainTextEdit->setReadOnly( !enabled );
|
||||
|
||||
if ( mLineEdit )
|
||||
{
|
||||
mLineEdit->setReadOnly( !enabled );
|
||||
if ( enabled )
|
||||
mLineEdit->setPalette( mWritablePalette );
|
||||
else
|
||||
mLineEdit->setPalette( mReadOnlyPalette );
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,8 @@ class GUI_EXPORT QgsTextEditWrapper : public QgsEditorWidgetWrapper
|
||||
QTextEdit* mTextEdit;
|
||||
QPlainTextEdit* mPlainTextEdit;
|
||||
QLineEdit* mLineEdit;
|
||||
QPalette mReadOnlyPalette;
|
||||
QPalette mWritablePalette;
|
||||
};
|
||||
|
||||
#endif // QGSTEXTEDITWRAPPER_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user