From 4cf39df949c3a1e136ac8832be9d4608733e45f2 Mon Sep 17 00:00:00 2001 From: Nikita Krupenko Date: Thu, 5 May 2016 22:50:04 +0300 Subject: Material: fix flat button colors As 251afe3eaac3367c5c659dddc1e8854f833d5112 changed the way, how button color are retrieved, use it for flat buttons too. Change-Id: I28448c597b027293b1acac22dad586e0e7156707 Reviewed-by: J-P Nurmi --- src/imports/controls/material/ToolButton.qml | 2 +- src/imports/controls/material/qquickmaterialstyle.cpp | 18 ++++++++++-------- src/imports/controls/material/qquickmaterialstyle_p.h | 2 -- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/imports/controls/material') diff --git a/src/imports/controls/material/ToolButton.qml b/src/imports/controls/material/ToolButton.qml index 59a6110e..2fcae7e8 100644 --- a/src/imports/controls/material/ToolButton.qml +++ b/src/imports/controls/material/ToolButton.qml @@ -65,7 +65,7 @@ T.ToolButton { implicitWidth: 48 implicitHeight: 48 - color: control.down ? control.Material.buttonPressColor : control.Material.flatButtonFocusColor + color: control.down ? control.Material.buttonPressColor : control.Material.buttonHoverColor visible: control.enabled && (control.down || control.visualFocus || control.checked || control.highlighted) } //! [background] diff --git a/src/imports/controls/material/qquickmaterialstyle.cpp b/src/imports/controls/material/qquickmaterialstyle.cpp index b80fc729..ce72e04b 100644 --- a/src/imports/controls/material/qquickmaterialstyle.cpp +++ b/src/imports/controls/material/qquickmaterialstyle.cpp @@ -861,9 +861,16 @@ QColor QQuickMaterialStyle::buttonColor(bool highlighted, bool pressed, bool hov } } - if (color == Qt::transparent && pressed) { - color = QColor::fromRgba(m_theme == Light ? flatButtonPressColorLight - : flatButtonPressColorDark); + if (color == Qt::transparent) { + if (pressed) { + return QColor::fromRgba(m_theme == Light ? flatButtonPressColorLight + : flatButtonPressColorDark); + } else if (hover) { + return QColor::fromRgba(m_theme == Light ? flatButtonFocusColorLight + : flatButtonFocusColorDark); + } else { + return color; + } } if (pressed || hover) { @@ -914,11 +921,6 @@ QColor QQuickMaterialStyle::highlightedButtonPressColor() const return buttonColor(true, true, false); } -QColor QQuickMaterialStyle::flatButtonFocusColor() const -{ - return QColor::fromRgba(m_theme == Light ? flatButtonFocusColorLight : flatButtonFocusColorDark); -} - QColor QQuickMaterialStyle::swipeDelegateColor() const { return QColor::fromRgba(m_theme == Light ? swipeDelegateColorLight : swipeDelegateColorDark); diff --git a/src/imports/controls/material/qquickmaterialstyle_p.h b/src/imports/controls/material/qquickmaterialstyle_p.h index fb73b7d7..e7434d83 100644 --- a/src/imports/controls/material/qquickmaterialstyle_p.h +++ b/src/imports/controls/material/qquickmaterialstyle_p.h @@ -83,7 +83,6 @@ class QQuickMaterialStyle : public QQuickStyleAttached Q_PROPERTY(QColor highlightedButtonColor READ highlightedButtonColor NOTIFY paletteChanged FINAL) Q_PROPERTY(QColor highlightedButtonHoverColor READ highlightedButtonHoverColor NOTIFY paletteChanged FINAL) Q_PROPERTY(QColor highlightedButtonPressColor READ highlightedButtonPressColor NOTIFY paletteChanged FINAL) - Q_PROPERTY(QColor flatButtonFocusColor READ flatButtonFocusColor NOTIFY paletteChanged FINAL) Q_PROPERTY(QColor swipeDelegateColor READ swipeDelegateColor NOTIFY paletteChanged FINAL) Q_PROPERTY(QColor swipeDelegateHoverColor READ swipeDelegateHoverColor NOTIFY paletteChanged FINAL) Q_PROPERTY(QColor swipeDelegatePressColor READ swipeDelegatePressColor NOTIFY paletteChanged FINAL) @@ -211,7 +210,6 @@ public: QColor highlightedButtonHoverColor() const; QColor highlightedButtonPressColor() const; QColor highlightedButtonDisabledColor() const; - QColor flatButtonFocusColor() const; QColor swipeDelegateColor() const; QColor swipeDelegateHoverColor() const; QColor swipeDelegatePressColor() const; -- cgit v1.2.3