Skip to content

Commit

Permalink
[editwidgets] text color for r/o line edits matches disabled color
Browse files Browse the repository at this point in the history
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
  • Loading branch information
m-kuhn committed Oct 15, 2014
1 parent cd59091 commit 3d9ba70
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/gui/editorwidgets/qgstexteditwrapper.cpp
Expand Up @@ -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 ) );
}
}

Expand Down Expand Up @@ -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 );
}
}
2 changes: 2 additions & 0 deletions src/gui/editorwidgets/qgstexteditwrapper.h
Expand Up @@ -55,6 +55,8 @@ class GUI_EXPORT QgsTextEditWrapper : public QgsEditorWidgetWrapper
QTextEdit* mTextEdit;
QPlainTextEdit* mPlainTextEdit;
QLineEdit* mLineEdit;
QPalette mReadOnlyPalette;
QPalette mWritablePalette;
};

#endif // QGSTEXTEDITWRAPPER_H

0 comments on commit 3d9ba70

Please sign in to comment.