Skip to content
Permalink
Browse files

[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
  • Loading branch information
m-kuhn committed Oct 15, 2014
1 parent cd59091 commit 3d9ba705de9887d46f3bb35a148b0b5b0b7a8999
Showing with 12 additions and 0 deletions.
  1. +10 −0 src/gui/editorwidgets/qgstexteditwrapper.cpp
  2. +2 −0 src/gui/editorwidgets/qgstexteditwrapper.h
@@ -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

0 comments on commit 3d9ba70

Please sign in to comment.
You can’t perform that action at this time.