forked from qt-creator/qt-creator
FancyLineEdit: Visualize the disabled state
The painting code path for flat themes did not handle the disabled state. This change catches up on that, and also suppresses the painting of the hover border in disabled state. Change-Id: I29d50be4549c81a25f976c61f6d4541862d2925e Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -454,6 +454,7 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
|
||||
|
||||
// Fill the line edit background
|
||||
QRectF backgroundRect = option->rect;
|
||||
const bool enabled = option->state & State_Enabled;
|
||||
if (Utils::creatorTheme()->widgetStyle() == Utils::Theme::StyleDefault) {
|
||||
backgroundRect.adjust(1, 1, -1, -1);
|
||||
painter->setBrushOrigin(backgroundRect.topLeft());
|
||||
@@ -464,15 +465,18 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
|
||||
static const QImage bg_disabled(StyleHelper::dpiSpecificImageFile(
|
||||
QLatin1String(":/core/images/inputfield_disabled.png")));
|
||||
|
||||
const bool enabled = option->state & State_Enabled;
|
||||
StyleHelper::drawCornerImage(enabled ? bg : bg_disabled,
|
||||
painter, option->rect, 5, 5, 5, 5);
|
||||
} else {
|
||||
painter->save();
|
||||
if (!enabled)
|
||||
painter->setOpacity(0.75);
|
||||
painter->fillRect(backgroundRect, option->palette.base());
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
const bool hasFocus = state & State_HasFocus;
|
||||
if (hasFocus || state & State_MouseOver) {
|
||||
if (enabled && (hasFocus || state & State_MouseOver)) {
|
||||
QColor hover = StyleHelper::baseColor();
|
||||
hover.setAlpha(hasFocus ? 100 : 50);
|
||||
painter->setPen(QPen(hover, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
|
||||
|
||||
Reference in New Issue
Block a user