aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-11-16 13:28:17 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2016-11-16 14:50:19 +0000
commit3ea7f91d9bb0e74f1c49384019f22d55b2fb6263 (patch)
tree7bc4be92765a8fe85db33e902a5aa912293183dc
parentc69c1f32b0b42adb670c08653282a86cc411b239 (diff)
Material: de-couple foreground and primaryTextColor
In order to get the ComboBox colors right, it must be possible to query the original primary text color value. It was very convenient to make Material.primaryTextColor return custom Material.foreground colors, because that way we didn't have to touch our QML files, but this approach is no longer usable. Task-number: QTBUG-57167 Change-Id: Iee003e96112b919dc7c84a906e4f5691b0f2a6ab Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/imports/controls/material/Button.qml2
-rw-r--r--src/imports/controls/material/CheckBox.qml2
-rw-r--r--src/imports/controls/material/CheckDelegate.qml2
-rw-r--r--src/imports/controls/material/ComboBox.qml6
-rw-r--r--src/imports/controls/material/GroupBox.qml2
-rw-r--r--src/imports/controls/material/ItemDelegate.qml2
-rw-r--r--src/imports/controls/material/Label.qml2
-rw-r--r--src/imports/controls/material/MenuItem.qml2
-rw-r--r--src/imports/controls/material/PageIndicator.qml2
-rw-r--r--src/imports/controls/material/RadioButton.qml2
-rw-r--r--src/imports/controls/material/RadioDelegate.qml2
-rw-r--r--src/imports/controls/material/RangeSlider.qml2
-rw-r--r--src/imports/controls/material/RoundButton.qml2
-rw-r--r--src/imports/controls/material/Slider.qml2
-rw-r--r--src/imports/controls/material/SpinBox.qml10
-rw-r--r--src/imports/controls/material/SwipeDelegate.qml2
-rw-r--r--src/imports/controls/material/Switch.qml2
-rw-r--r--src/imports/controls/material/SwitchDelegate.qml2
-rw-r--r--src/imports/controls/material/TabButton.qml2
-rw-r--r--src/imports/controls/material/TextArea.qml2
-rw-r--r--src/imports/controls/material/TextField.qml2
-rw-r--r--src/imports/controls/material/ToolButton.qml2
-rw-r--r--src/imports/controls/material/ToolTip.qml2
-rw-r--r--src/imports/controls/material/Tumbler.qml2
-rw-r--r--src/imports/controls/material/qquickmaterialstyle.cpp16
-rw-r--r--src/imports/controls/material/qquickmaterialstyle_p.h2
26 files changed, 39 insertions, 39 deletions
diff --git a/src/imports/controls/material/Button.qml b/src/imports/controls/material/Button.qml
index 8842f0ac..9b3ced25 100644
--- a/src/imports/controls/material/Button.qml
+++ b/src/imports/controls/material/Button.qml
@@ -62,7 +62,7 @@ T.Button {
font: control.font
color: !control.enabled ? control.Material.hintTextColor :
control.flat && control.highlighted ? control.Material.accentColor :
- control.highlighted ? control.Material.primaryHighlightedTextColor : control.Material.primaryTextColor
+ control.highlighted ? control.Material.primaryHighlightedTextColor : control.Material.foreground
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
diff --git a/src/imports/controls/material/CheckBox.qml b/src/imports/controls/material/CheckBox.qml
index bb760bbd..979654f7 100644
--- a/src/imports/controls/material/CheckBox.qml
+++ b/src/imports/controls/material/CheckBox.qml
@@ -78,7 +78,7 @@ T.CheckBox {
text: control.text
font: control.font
- color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
diff --git a/src/imports/controls/material/CheckDelegate.qml b/src/imports/controls/material/CheckDelegate.qml
index e77e0a9c..aec48bf1 100644
--- a/src/imports/controls/material/CheckDelegate.qml
+++ b/src/imports/controls/material/CheckDelegate.qml
@@ -66,7 +66,7 @@ T.CheckDelegate {
text: control.text
font: control.font
- color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
diff --git a/src/imports/controls/material/ComboBox.qml b/src/imports/controls/material/ComboBox.qml
index 8ad1fd36..15987ebc 100644
--- a/src/imports/controls/material/ComboBox.qml
+++ b/src/imports/controls/material/ComboBox.qml
@@ -60,7 +60,7 @@ T.ComboBox {
Material.elevation: flat ? control.pressed || control.hovered ? 2 : 0
: control.pressed ? 8 : 2
Material.background: flat ? "transparent" : undefined
- Material.foreground: flat ? undefined : Material.foreground
+ Material.foreground: flat ? undefined : Material.primaryTextColor
delegate: MenuItem {
width: control.popup.width
@@ -73,7 +73,7 @@ T.ComboBox {
indicator: Image {
x: control.mirrored ? control.leftPadding : control.width - width - control.rightPadding
y: control.topPadding + (control.availableHeight - height) / 2
- source: "image://material/drop-indicator/" + (control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor)
+ source: "image://material/drop-indicator/" + (control.enabled ? control.Material.foreground : control.Material.hintTextColor)
}
contentItem: Text {
@@ -82,7 +82,7 @@ T.ComboBox {
text: control.displayText
font: control.font
- color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
diff --git a/src/imports/controls/material/GroupBox.qml b/src/imports/controls/material/GroupBox.qml
index afd1c8d1..64b589af 100644
--- a/src/imports/controls/material/GroupBox.qml
+++ b/src/imports/controls/material/GroupBox.qml
@@ -60,7 +60,7 @@ T.GroupBox {
text: control.title
font: control.font
- color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
elide: Text.ElideRight
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
diff --git a/src/imports/controls/material/ItemDelegate.qml b/src/imports/controls/material/ItemDelegate.qml
index ad9604fd..ec74fbee 100644
--- a/src/imports/controls/material/ItemDelegate.qml
+++ b/src/imports/controls/material/ItemDelegate.qml
@@ -58,7 +58,7 @@ T.ItemDelegate {
text: control.text
font: control.font
- color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
diff --git a/src/imports/controls/material/Label.qml b/src/imports/controls/material/Label.qml
index f4e12813..3a728dc8 100644
--- a/src/imports/controls/material/Label.qml
+++ b/src/imports/controls/material/Label.qml
@@ -41,6 +41,6 @@ import QtQuick.Controls.Material 2.1
T.Label {
id: control
- color: enabled ? Material.primaryTextColor : Material.hintTextColor
+ color: enabled ? Material.foreground : Material.hintTextColor
linkColor: Material.accentColor
}
diff --git a/src/imports/controls/material/MenuItem.qml b/src/imports/controls/material/MenuItem.qml
index 15c2d392..a6dbba2c 100644
--- a/src/imports/controls/material/MenuItem.qml
+++ b/src/imports/controls/material/MenuItem.qml
@@ -67,7 +67,7 @@ T.MenuItem {
text: control.text
font: control.font
- color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
diff --git a/src/imports/controls/material/PageIndicator.qml b/src/imports/controls/material/PageIndicator.qml
index 7378dbbf..5a68df6b 100644
--- a/src/imports/controls/material/PageIndicator.qml
+++ b/src/imports/controls/material/PageIndicator.qml
@@ -54,7 +54,7 @@ T.PageIndicator {
implicitHeight: 8
radius: width / 2
- color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
opacity: index === currentIndex ? 0.95 : pressed ? 0.7 : 0.45
Behavior on opacity { OpacityAnimator { duration: 100 } }
diff --git a/src/imports/controls/material/RadioButton.qml b/src/imports/controls/material/RadioButton.qml
index 6faf1caa..32bf1cbd 100644
--- a/src/imports/controls/material/RadioButton.qml
+++ b/src/imports/controls/material/RadioButton.qml
@@ -78,7 +78,7 @@ T.RadioButton {
text: control.text
font: control.font
- color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
diff --git a/src/imports/controls/material/RadioDelegate.qml b/src/imports/controls/material/RadioDelegate.qml
index 4b7af82a..349352b4 100644
--- a/src/imports/controls/material/RadioDelegate.qml
+++ b/src/imports/controls/material/RadioDelegate.qml
@@ -66,7 +66,7 @@ T.RadioDelegate {
text: control.text
font: control.font
- color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
diff --git a/src/imports/controls/material/RangeSlider.qml b/src/imports/controls/material/RangeSlider.qml
index 4381fd41..0233f137 100644
--- a/src/imports/controls/material/RangeSlider.qml
+++ b/src/imports/controls/material/RangeSlider.qml
@@ -76,7 +76,7 @@ T.RangeSlider {
implicitHeight: horizontal ? 48 : 200
width: horizontal ? control.availableWidth : 1
height: horizontal ? 1 : control.availableHeight
- color: control.Material.primaryTextColor
+ color: control.Material.foreground
scale: horizontal && control.mirrored ? -1 : 1
readonly property bool horizontal: control.orientation === Qt.Horizontal
diff --git a/src/imports/controls/material/RoundButton.qml b/src/imports/controls/material/RoundButton.qml
index e385ac1b..f6899dea 100644
--- a/src/imports/controls/material/RoundButton.qml
+++ b/src/imports/controls/material/RoundButton.qml
@@ -60,7 +60,7 @@ T.RoundButton {
font: control.font
color: !control.enabled ? control.Material.hintTextColor :
control.flat && control.highlighted ? control.Material.accentColor :
- control.highlighted ? control.Material.primaryHighlightedTextColor : control.Material.primaryTextColor
+ control.highlighted ? control.Material.primaryHighlightedTextColor : control.Material.foreground
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
diff --git a/src/imports/controls/material/Slider.qml b/src/imports/controls/material/Slider.qml
index 7cf858e7..d13797c5 100644
--- a/src/imports/controls/material/Slider.qml
+++ b/src/imports/controls/material/Slider.qml
@@ -65,7 +65,7 @@ T.Slider {
implicitHeight: horizontal ? 48 : 200
width: horizontal ? control.availableWidth : 1
height: horizontal ? 1 : control.availableHeight
- color: control.Material.primaryTextColor
+ color: control.Material.foreground
scale: horizontal && control.mirrored ? -1 : 1
readonly property bool horizontal: control.orientation === Qt.Horizontal
diff --git a/src/imports/controls/material/SpinBox.qml b/src/imports/controls/material/SpinBox.qml
index b371f714..6881fc23 100644
--- a/src/imports/controls/material/SpinBox.qml
+++ b/src/imports/controls/material/SpinBox.qml
@@ -68,9 +68,9 @@ T.SpinBox {
text: control.textFromValue(control.value, control.locale)
font: control.font
- color: enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: enabled ? control.Material.foreground : control.Material.hintTextColor
selectionColor: control.Material.textSelectionColor
- selectedTextColor: control.Material.primaryTextColor
+ selectedTextColor: control.Material.foreground
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
cursorDelegate: Rectangle {
@@ -127,14 +127,14 @@ T.SpinBox {
y: (parent.height - height) / 2
width: Math.min(parent.width / 3, parent.width / 3)
height: 2
- color: enabled ? control.Material.primaryTextColor : control.Material.spinBoxDisabledIconColor
+ color: enabled ? control.Material.foreground : control.Material.spinBoxDisabledIconColor
}
Rectangle {
x: (parent.width - width) / 2
y: (parent.height - height) / 2
width: 2
height: Math.min(parent.width / 3, parent.width / 3)
- color: enabled ? control.Material.primaryTextColor : control.Material.spinBoxDisabledIconColor
+ color: enabled ? control.Material.foreground : control.Material.spinBoxDisabledIconColor
}
}
@@ -161,7 +161,7 @@ T.SpinBox {
y: (parent.height - height) / 2
width: parent.width / 3
height: 2
- color: enabled ? control.Material.primaryTextColor : control.Material.spinBoxDisabledIconColor
+ color: enabled ? control.Material.foreground : control.Material.spinBoxDisabledIconColor
}
}
diff --git a/src/imports/controls/material/SwipeDelegate.qml b/src/imports/controls/material/SwipeDelegate.qml
index 23db44fd..da54b0c3 100644
--- a/src/imports/controls/material/SwipeDelegate.qml
+++ b/src/imports/controls/material/SwipeDelegate.qml
@@ -60,7 +60,7 @@ T.SwipeDelegate {
text: control.text
font: control.font
- color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
diff --git a/src/imports/controls/material/Switch.qml b/src/imports/controls/material/Switch.qml
index 3c9fbe51..645dc55a 100644
--- a/src/imports/controls/material/Switch.qml
+++ b/src/imports/controls/material/Switch.qml
@@ -73,7 +73,7 @@ T.Switch {
text: control.text
font: control.font
- color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
diff --git a/src/imports/controls/material/SwitchDelegate.qml b/src/imports/controls/material/SwitchDelegate.qml
index 1a590774..9fb18271 100644
--- a/src/imports/controls/material/SwitchDelegate.qml
+++ b/src/imports/controls/material/SwitchDelegate.qml
@@ -66,7 +66,7 @@ T.SwitchDelegate {
text: control.text
font: control.font
- color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
diff --git a/src/imports/controls/material/TabButton.qml b/src/imports/controls/material/TabButton.qml
index a900747a..a76df820 100644
--- a/src/imports/controls/material/TabButton.qml
+++ b/src/imports/controls/material/TabButton.qml
@@ -54,7 +54,7 @@ T.TabButton {
text: control.text
font: control.font
elide: Text.ElideRight
- color: !control.enabled ? control.Material.hintTextColor : control.down || control.checked ? control.Material.accentColor : control.Material.primaryTextColor
+ color: !control.enabled ? control.Material.hintTextColor : control.down || control.checked ? control.Material.accentColor : control.Material.foreground
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
diff --git a/src/imports/controls/material/TextArea.qml b/src/imports/controls/material/TextArea.qml
index 8fdead60..d454796a 100644
--- a/src/imports/controls/material/TextArea.qml
+++ b/src/imports/controls/material/TextArea.qml
@@ -51,7 +51,7 @@ T.TextArea {
topPadding: 8
bottomPadding: 16
- color: enabled ? Material.primaryTextColor : Material.hintTextColor
+ color: enabled ? Material.foreground : Material.hintTextColor
selectionColor: Material.accentColor
selectedTextColor: Material.primaryHighlightedTextColor
cursorDelegate: Rectangle {
diff --git a/src/imports/controls/material/TextField.qml b/src/imports/controls/material/TextField.qml
index be51fd13..8954dd26 100644
--- a/src/imports/controls/material/TextField.qml
+++ b/src/imports/controls/material/TextField.qml
@@ -51,7 +51,7 @@ T.TextField {
topPadding: 8
bottomPadding: 16
- color: enabled ? Material.primaryTextColor : Material.hintTextColor
+ color: enabled ? Material.foreground : Material.hintTextColor
selectionColor: Material.accentColor
selectedTextColor: Material.primaryHighlightedTextColor
verticalAlignment: TextInput.AlignVCenter
diff --git a/src/imports/controls/material/ToolButton.qml b/src/imports/controls/material/ToolButton.qml
index d11e41ae..78b15ac2 100644
--- a/src/imports/controls/material/ToolButton.qml
+++ b/src/imports/controls/material/ToolButton.qml
@@ -54,7 +54,7 @@ T.ToolButton {
text: control.text
font: control.font
color: !control.enabled ? control.Material.hintTextColor :
- control.checked || control.highlighted ? control.Material.accent : control.Material.primaryTextColor
+ control.checked || control.highlighted ? control.Material.accent : control.Material.foreground
elide: Text.ElideRight
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
diff --git a/src/imports/controls/material/ToolTip.qml b/src/imports/controls/material/ToolTip.qml
index 455f79c6..559b85da 100644
--- a/src/imports/controls/material/ToolTip.qml
+++ b/src/imports/controls/material/ToolTip.qml
@@ -72,7 +72,7 @@ T.ToolTip {
text: control.text
font: control.font
// TODO: wrapMode: Label.Wrap
- color: control.Material.primaryTextColor
+ color: control.Material.foreground
}
background: Rectangle {
diff --git a/src/imports/controls/material/Tumbler.qml b/src/imports/controls/material/Tumbler.qml
index 88750855..a3be17b7 100644
--- a/src/imports/controls/material/Tumbler.qml
+++ b/src/imports/controls/material/Tumbler.qml
@@ -48,7 +48,7 @@ T.Tumbler {
delegate: Text {
id: label
text: modelData
- color: control.Material.primaryTextColor
+ color: control.Material.foreground
font: control.font
opacity: (1.0 - Math.abs(Tumbler.displacement) / (visibleItemCount / 2)) * (control.enabled ? 1 : 0.6)
horizontalAlignment: Text.AlignHCenter
diff --git a/src/imports/controls/material/qquickmaterialstyle.cpp b/src/imports/controls/material/qquickmaterialstyle.cpp
index a4041d0d..08203482 100644
--- a/src/imports/controls/material/qquickmaterialstyle.cpp
+++ b/src/imports/controls/material/qquickmaterialstyle.cpp
@@ -638,7 +638,13 @@ void QQuickMaterialStyle::resetAccent()
QVariant QQuickMaterialStyle::foreground() const
{
- return primaryTextColor();
+ if (!m_hasForeground)
+ return QColor::fromRgba(m_theme == Light ? primaryTextColorLight : primaryTextColorDark);
+ if (m_customForeground)
+ return QColor::fromRgba(m_foreground);
+ if (m_foreground > BlueGrey)
+ return QColor();
+ return QColor::fromRgba(colors[m_foreground][Shade500]);
}
void QQuickMaterialStyle::setForeground(const QVariant &var)
@@ -814,13 +820,7 @@ QColor QQuickMaterialStyle::backgroundColor() const
QColor QQuickMaterialStyle::primaryTextColor() const
{
- if (!m_hasForeground)
- return QColor::fromRgba(m_theme == Light ? primaryTextColorLight : primaryTextColorDark);
- if (m_customForeground)
- return QColor::fromRgba(m_foreground);
- if (m_foreground > BlueGrey)
- return QColor();
- return colors[m_foreground][Shade500];
+ return QColor::fromRgba(m_theme == Light ? primaryTextColorLight : primaryTextColorDark);
}
QColor QQuickMaterialStyle::primaryHighlightedTextColor() const
diff --git a/src/imports/controls/material/qquickmaterialstyle_p.h b/src/imports/controls/material/qquickmaterialstyle_p.h
index 938bc4c2..78fef272 100644
--- a/src/imports/controls/material/qquickmaterialstyle_p.h
+++ b/src/imports/controls/material/qquickmaterialstyle_p.h
@@ -67,7 +67,7 @@ class QQuickMaterialStyle : public QQuickStyleAttached
Q_PROPERTY(QColor primaryColor READ primaryColor NOTIFY primaryChanged FINAL) // TODO: remove?
Q_PROPERTY(QColor accentColor READ accentColor NOTIFY accentChanged FINAL) // TODO: remove?
Q_PROPERTY(QColor backgroundColor READ backgroundColor NOTIFY backgroundChanged FINAL)
- Q_PROPERTY(QColor primaryTextColor READ primaryTextColor NOTIFY foregroundChanged FINAL) // TODO: rename to foregroundColor()?
+ Q_PROPERTY(QColor primaryTextColor READ primaryTextColor NOTIFY paletteChanged FINAL)
Q_PROPERTY(QColor primaryHighlightedTextColor READ primaryHighlightedTextColor NOTIFY paletteChanged FINAL)
Q_PROPERTY(QColor secondaryTextColor READ secondaryTextColor NOTIFY paletteChanged FINAL)
Q_PROPERTY(QColor hintTextColor READ hintTextColor NOTIFY paletteChanged FINAL)