diff options
author | Alessandro Portale <alessandro.portale@theqtcompany.com> | 2016-04-27 12:16:30 +0200 |
---|---|---|
committer | Alessandro Portale <alessandro.portale@theqtcompany.com> | 2016-04-29 12:57:23 +0000 |
commit | d7f8af93922face9cd8c431fe028f9c3e7854b5f (patch) | |
tree | 5e700372f3aa62a11551abc9fe21789ba2254b35 /src | |
parent | 15543d5957ffa2c493f13c918b4b281bd25d7f43 (diff) | |
download | qt-creator-d7f8af93922face9cd8c431fe028f9c3e7854b5f.tar.gz |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/coreplugin/manhattanstyle.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/plugins/coreplugin/manhattanstyle.cpp b/src/plugins/coreplugin/manhattanstyle.cpp index 33c1a17c2e..82569cb100 100644 --- a/src/plugins/coreplugin/manhattanstyle.cpp +++ b/src/plugins/coreplugin/manhattanstyle.cpp @@ -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)); |