aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/controls
diff options
context:
space:
mode:
Diffstat (limited to 'src/imports/controls')
-rw-r--r--src/imports/controls/ApplicationWindow.qml2
-rw-r--r--src/imports/controls/BusyIndicator.qml2
-rw-r--r--src/imports/controls/Button.qml16
-rw-r--r--src/imports/controls/CheckBox.qml28
-rw-r--r--src/imports/controls/Frame.qml6
-rw-r--r--src/imports/controls/GroupBox.qml16
-rw-r--r--src/imports/controls/PageIndicator.qml6
-rw-r--r--src/imports/controls/ProgressBar.qml10
-rw-r--r--src/imports/controls/RadioButton.qml26
-rw-r--r--src/imports/controls/ScrollBar.qml4
-rw-r--r--src/imports/controls/ScrollIndicator.qml4
-rw-r--r--src/imports/controls/Slider.qml22
-rw-r--r--src/imports/controls/SpinBox.qml42
-rw-r--r--src/imports/controls/Switch.qml26
-rw-r--r--src/imports/controls/TabBar.qml8
-rw-r--r--src/imports/controls/TabButton.qml8
-rw-r--r--src/imports/controls/TextArea.qml10
-rw-r--r--src/imports/controls/TextField.qml18
-rw-r--r--src/imports/controls/ToggleButton.qml28
-rw-r--r--src/imports/controls/ToolBar.qml2
-rw-r--r--src/imports/controls/ToolButton.qml10
-rw-r--r--src/imports/controls/controls.pro9
-rw-r--r--src/imports/controls/qquickstyle.cpp826
-rw-r--r--src/imports/controls/qquickstyle_p.h168
-rw-r--r--src/imports/controls/qquickstyledata.cpp101
-rw-r--r--src/imports/controls/qquickstyledata_p.h128
-rw-r--r--src/imports/controls/qtquickcontrols2plugin.cpp2
-rw-r--r--src/imports/controls/qtquickcontrols2plugin.qrc3
-rw-r--r--src/imports/controls/style.json16
29 files changed, 1399 insertions, 148 deletions
diff --git a/src/imports/controls/ApplicationWindow.qml b/src/imports/controls/ApplicationWindow.qml
index b64770a8..551598c6 100644
--- a/src/imports/controls/ApplicationWindow.qml
+++ b/src/imports/controls/ApplicationWindow.qml
@@ -41,7 +41,7 @@ import QtQuick.Controls 2.0
AbstractApplicationWindow {
id: window
- color: style.backgroundColor
+ color: Style.backgroundColor
flags: Qt.Window | Qt.WindowFullscreenButtonHint
contentWidth: contentItem.children.length === 1 ? contentItem.children[0].implicitWidth : 0
diff --git a/src/imports/controls/BusyIndicator.qml b/src/imports/controls/BusyIndicator.qml
index 1fb1df53..dcaa0ff7 100644
--- a/src/imports/controls/BusyIndicator.qml
+++ b/src/imports/controls/BusyIndicator.qml
@@ -45,7 +45,7 @@ AbstractBusyIndicator {
Accessible.role: Accessible.Indicator
- padding: style.padding
+ padding: Style.padding
indicator: Item {
id: delegate
diff --git a/src/imports/controls/Button.qml b/src/imports/controls/Button.qml
index 9780b6b1..e78aa731 100644
--- a/src/imports/controls/Button.qml
+++ b/src/imports/controls/Button.qml
@@ -49,7 +49,7 @@ AbstractButton {
Accessible.pressed: pressed
Accessible.role: Accessible.Button
- padding: style.padding
+ padding: Style.padding
label: Text {
x: control.leftPadding
@@ -58,9 +58,9 @@ AbstractButton {
height: parent.height - control.topPadding - control.bottomPadding
text: control.text
- color: control.style.selectedTextColor
+ color: control.Style.selectedTextColor
elide: Text.ElideRight
- opacity: enabled ? 1.0 : control.style.disabledOpacity
+ opacity: enabled ? 1.0 : control.Style.disabledOpacity
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
@@ -69,10 +69,10 @@ AbstractButton {
implicitWidth: 26
implicitHeight: 26
- radius: style.roundness
- opacity: control.enabled ? 1.0 : style.disabledOpacity
- color: Qt.tint(Qt.tint(style.accentColor,
- control.activeFocus ? style.focusColor : "transparent"),
- control.pressed ? style.pressColor : "transparent")
+ radius: control.Style.roundness
+ opacity: control.enabled ? 1.0 : control.Style.disabledOpacity
+ color: Qt.tint(Qt.tint(control.Style.accentColor,
+ control.activeFocus ? control.Style.focusColor : "transparent"),
+ control.pressed ? control.Style.pressColor : "transparent")
}
}
diff --git a/src/imports/controls/CheckBox.qml b/src/imports/controls/CheckBox.qml
index a0ab0358..ed1eea0f 100644
--- a/src/imports/controls/CheckBox.qml
+++ b/src/imports/controls/CheckBox.qml
@@ -43,7 +43,7 @@ AbstractCheckBox {
implicitWidth: Math.max(background ? background.implicitWidth : 0,
(label ? label.implicitWidth : 0) +
(indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? style.spacing : 0) + leftPadding + rightPadding)
+ (label && indicator ? Style.spacing : 0) + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
Math.max(label ? label.implicitHeight : 0,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
@@ -53,7 +53,7 @@ AbstractCheckBox {
Accessible.pressed: pressed
Accessible.role: Accessible.CheckBox
- padding: style.padding
+ padding: Style.padding
indicator: Rectangle {
readonly property bool mirror: control.effectiveLayoutDirection == Qt.RightToLeft
@@ -63,38 +63,38 @@ AbstractCheckBox {
x: text ? (mirror ? parent.width - width - control.rightPadding : control.leftPadding) : (parent.width - width) / 2
y: (parent.height - height) / 2
- radius: style.roundness
+ radius: control.Style.roundness
border.width: control.activeFocus ? 2 : 1
- border.color: control.activeFocus ? style.focusColor : style.frameColor
- opacity: enabled ? 1.0 : style.disabledOpacity
- color: style.backgroundColor
+ border.color: control.activeFocus ? control.Style.focusColor : control.Style.frameColor
+ opacity: enabled ? 1.0 : control.Style.disabledOpacity
+ color: control.Style.backgroundColor
Rectangle {
x: (parent.width - width) / 2
y: (parent.height - height) / 2
width: 12
height: 12
- color: Qt.tint(Qt.tint(control.checked ? style.accentColor : style.baseColor,
- control.checked && control.activeFocus ? style.focusColor : "transparent"),
- control.pressed ? style.pressColor : "transparent")
+ color: Qt.tint(Qt.tint(control.checked ? control.Style.accentColor : control.Style.baseColor,
+ control.checked && control.activeFocus ? control.Style.focusColor : "transparent"),
+ control.pressed ? control.Style.pressColor : "transparent")
border.width: control.checked || control.pressed ? 0 : 1
- border.color: style.frameColor
+ border.color: control.Style.frameColor
}
}
label: Text {
readonly property bool mirror: control.effectiveLayoutDirection == Qt.RightToLeft
- x: mirror ? control.leftPadding : (indicator.x + indicator.width + control.style.spacing)
+ x: mirror ? control.leftPadding : (indicator.x + indicator.width + control.Style.spacing)
y: control.topPadding
- width: parent.width - indicator.width - control.style.spacing - control.leftPadding - control.rightPadding
+ width: parent.width - indicator.width - control.Style.spacing - control.leftPadding - control.rightPadding
height: parent.height - control.topPadding - control.bottomPadding
text: control.text
- color: control.style.textColor
+ color: control.Style.textColor
elide: Text.ElideRight
visible: control.text
- opacity: enabled ? 1.0 : control.style.disabledOpacity
+ opacity: enabled ? 1.0 : control.Style.disabledOpacity
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
diff --git a/src/imports/controls/Frame.qml b/src/imports/controls/Frame.qml
index 251d10ca..8c73f6ba 100644
--- a/src/imports/controls/Frame.qml
+++ b/src/imports/controls/Frame.qml
@@ -50,7 +50,7 @@ AbstractFrame {
contentWidth: content.children.length === 1 ? content.children[0].implicitWidth : 0
contentHeight: content.children.length === 1 ? content.children[0].implicitHeight : 0
- padding: style.padding
+ padding: Style.padding
contentItem: Item {
id: content
@@ -62,7 +62,7 @@ AbstractFrame {
background: Rectangle {
color: "transparent"
- radius: style.roundness
- border.color: style.frameColor
+ radius: control.Style.roundness
+ border.color: control.Style.frameColor
}
}
diff --git a/src/imports/controls/GroupBox.qml b/src/imports/controls/GroupBox.qml
index 773f1092..acd6f7ac 100644
--- a/src/imports/controls/GroupBox.qml
+++ b/src/imports/controls/GroupBox.qml
@@ -50,8 +50,8 @@ AbstractGroupBox {
contentWidth: content.children.length === 1 ? content.children[0].implicitWidth : 0
contentHeight: content.children.length === 1 ? content.children[0].implicitHeight : 0
- padding: style.padding
- topPadding: style.padding + (label && title ? label.implicitHeight + style.spacing : 0)
+ padding: Style.padding
+ topPadding: Style.padding + (label && title ? label.implicitHeight + Style.spacing : 0)
contentItem: Item {
id: content
@@ -66,20 +66,20 @@ AbstractGroupBox {
width: parent.width - control.leftPadding - control.rightPadding
text: control.title
- color: control.style.textColor
+ color: control.Style.textColor
elide: Text.ElideRight
- opacity: enabled ? 1.0 : control.style.disabledOpacity
+ opacity: enabled ? 1.0 : control.Style.disabledOpacity
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
frame: Rectangle {
- y: control.topPadding - style.padding
+ y: control.topPadding - control.Style.padding
width: parent.width
- height: parent.height - control.topPadding + style.padding
+ height: parent.height - control.topPadding + control.Style.padding
color: "transparent"
- radius: style.roundness
- border.color: style.frameColor
+ radius: control.Style.roundness
+ border.color: control.Style.frameColor
}
}
diff --git a/src/imports/controls/PageIndicator.qml b/src/imports/controls/PageIndicator.qml
index 0fb1a018..fb0faeef 100644
--- a/src/imports/controls/PageIndicator.qml
+++ b/src/imports/controls/PageIndicator.qml
@@ -47,7 +47,7 @@ AbstractPageIndicator {
implicitHeight: 8
radius: width / 2
- color: style.shadowColor // TODO
+ color: control.Style.shadowColor // TODO
opacity: index === currentIndex ? 0.75 : 0.25
Behavior on opacity { OpacityAnimator { duration: 100 } }
@@ -61,7 +61,7 @@ AbstractPageIndicator {
implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + topPadding + bottomPadding)
- padding: style.padding
+ padding: Style.padding
contentItem: Row {
id: row
@@ -71,7 +71,7 @@ AbstractPageIndicator {
width: parent.width - control.leftPadding - control.rightPadding
height: parent.height - control.topPadding - control.bottomPadding
- spacing: style.spacing
+ spacing: control.Style.spacing
Repeater {
model: control.count
diff --git a/src/imports/controls/ProgressBar.qml b/src/imports/controls/ProgressBar.qml
index 6ff666e7..0ebaa994 100644
--- a/src/imports/controls/ProgressBar.qml
+++ b/src/imports/controls/ProgressBar.qml
@@ -47,7 +47,7 @@ AbstractProgressBar {
Accessible.role: Accessible.ProgressBar
- padding: style.padding
+ padding: Style.padding
indicator: Item {
x: control.leftPadding
@@ -68,8 +68,8 @@ AbstractProgressBar {
width: offset * (parent.width - x) - 2
height: 2
- color: style.accentColor
- radius: style.roundness
+ color: control.Style.accentColor
+ radius: control.Style.roundness
SequentialAnimation on offset {
loops: Animation.Infinite
@@ -95,8 +95,8 @@ AbstractProgressBar {
width: parent.width - control.leftPadding - control.rightPadding
height: 6
- radius: style.roundness
- border.color: style.frameColor
+ radius: control.Style.roundness
+ border.color: control.Style.frameColor
color: "transparent"
}
}
diff --git a/src/imports/controls/RadioButton.qml b/src/imports/controls/RadioButton.qml
index 8a916270..af6cc1fc 100644
--- a/src/imports/controls/RadioButton.qml
+++ b/src/imports/controls/RadioButton.qml
@@ -43,7 +43,7 @@ AbstractRadioButton {
implicitWidth: Math.max(background ? background.implicitWidth : 0,
(label ? label.implicitWidth : 0) +
(indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? style.spacing : 0) + leftPadding + rightPadding)
+ (label && indicator ? Style.spacing : 0) + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
Math.max(label ? label.implicitHeight : 0,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
@@ -53,7 +53,7 @@ AbstractRadioButton {
Accessible.pressed: pressed
Accessible.role: Accessible.RadioButton
- padding: style.padding
+ padding: Style.padding
indicator: Rectangle {
readonly property bool mirror: control.effectiveLayoutDirection == Qt.RightToLeft
@@ -65,9 +65,9 @@ AbstractRadioButton {
radius: width / 2
border.width: control.activeFocus ? 2 : 1
- border.color: control.activeFocus ? style.focusColor : style.frameColor
- opacity: enabled ? 1.0 : style.disabledOpacity
- color: style.backgroundColor
+ border.color: control.activeFocus ? control.Style.focusColor : control.Style.frameColor
+ opacity: enabled ? 1.0 : control.Style.disabledOpacity
+ color: control.Style.backgroundColor
Rectangle {
x: (parent.width - width) / 2
@@ -75,27 +75,27 @@ AbstractRadioButton {
width: 12
height: 12
radius: width / 2
- color: Qt.tint(Qt.tint(control.checked ? style.accentColor : style.baseColor,
- control.checked && control.activeFocus ? style.focusColor : "transparent"),
- control.pressed ? style.pressColor : "transparent")
+ color: Qt.tint(Qt.tint(control.checked ? control.Style.accentColor : control.Style.baseColor,
+ control.checked && control.activeFocus ? control.Style.focusColor : "transparent"),
+ control.pressed ? control.Style.pressColor : "transparent")
border.width: control.checked || control.pressed ? 0 : 1
- border.color: style.frameColor
+ border.color: control.Style.frameColor
}
}
label: Text {
readonly property bool mirror: control.effectiveLayoutDirection == Qt.RightToLeft
- x: mirror ? control.leftPadding : (indicator.x + indicator.width + control.style.spacing)
+ x: mirror ? control.leftPadding : (indicator.x + indicator.width + control.Style.spacing)
y: control.topPadding
- width: parent.width - indicator.width - control.style.spacing - control.leftPadding - control.rightPadding
+ width: parent.width - indicator.width - control.Style.spacing - control.leftPadding - control.rightPadding
height: parent.height - control.topPadding - control.bottomPadding
text: control.text
- color: control.style.textColor
+ color: control.Style.textColor
elide: Text.ElideRight
visible: control.text
- opacity: enabled ? 1.0 : control.style.disabledOpacity
+ opacity: enabled ? 1.0 : control.Style.disabledOpacity
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
diff --git a/src/imports/controls/ScrollBar.qml b/src/imports/controls/ScrollBar.qml
index 956401b3..ed79c8db 100644
--- a/src/imports/controls/ScrollBar.qml
+++ b/src/imports/controls/ScrollBar.qml
@@ -57,7 +57,7 @@ AbstractScrollBar {
implicitHeight: 6
radius: width / 2
- color: control.pressed ? style.shadowColor : style.frameColor
+ color: control.pressed ? control.Style.shadowColor : control.Style.frameColor
visible: control.size < 1.0
opacity: 0.0
@@ -70,7 +70,7 @@ AbstractScrollBar {
states: State {
name: "active"
when: control.active
- PropertyChanges { target: handle; opacity: 1.0 - style.disabledOpacity }
+ PropertyChanges { target: handle; opacity: 1.0 - control.Style.disabledOpacity }
}
transitions: Transition {
diff --git a/src/imports/controls/ScrollIndicator.qml b/src/imports/controls/ScrollIndicator.qml
index a6684330..b253ca03 100644
--- a/src/imports/controls/ScrollIndicator.qml
+++ b/src/imports/controls/ScrollIndicator.qml
@@ -55,7 +55,7 @@ AbstractScrollIndicator {
implicitWidth: 2
implicitHeight: 2
- color: style.frameColor
+ color: control.Style.frameColor
visible: control.size < 1.0
opacity: 0.0
@@ -68,7 +68,7 @@ AbstractScrollIndicator {
states: State {
name: "active"
when: control.active
- PropertyChanges { target: indicator; opacity: 1.0 - style.disabledOpacity }
+ PropertyChanges { target: indicator; opacity: 1.0 - control.Style.disabledOpacity }
}
transitions: [
diff --git a/src/imports/controls/Slider.qml b/src/imports/controls/Slider.qml
index 819d8f28..83e9d00b 100644
--- a/src/imports/controls/Slider.qml
+++ b/src/imports/controls/Slider.qml
@@ -50,15 +50,15 @@ AbstractSlider {
Accessible.pressed: pressed
Accessible.role: Accessible.Slider
- padding: style.padding
+ padding: Style.padding
handle: Rectangle {
implicitWidth: 20
implicitHeight: 20
radius: width / 2
border.width: control.activeFocus ? 2 : 1
- border.color: control.activeFocus ? style.focusColor : style.frameColor
- color: style.backgroundColor
+ border.color: control.activeFocus ? control.Style.focusColor : control.Style.frameColor
+ color: control.Style.backgroundColor
readonly property bool horizontal: control.orientation === Qt.Horizontal
x: horizontal ? control.visualPosition * (control.width - width) : (control.width - width) / 2
@@ -71,9 +71,9 @@ AbstractSlider {
height: 12
radius: width / 2
- color: Qt.tint(Qt.tint(style.accentColor,
- control.activeFocus ? style.focusColor : "transparent"),
- control.pressed ? style.pressColor : "transparent")
+ color: Qt.tint(Qt.tint(control.Style.accentColor,
+ control.activeFocus ? control.Style.focusColor : "transparent"),
+ control.pressed ? control.Style.pressColor : "transparent")
}
}
@@ -86,9 +86,9 @@ AbstractSlider {
width: horizontal ? parent.width - control.leftPadding - control.rightPadding : implicitWidth
height: horizontal ? implicitHeight : parent.height - control.topPadding - control.bottomPadding
- radius: style.roundness
- border.color: style.frameColor
- color: style.backgroundColor
+ radius: control.Style.roundness
+ border.color: control.Style.frameColor
+ color: control.Style.backgroundColor
scale: control.effectiveLayoutDirection === Qt.RightToLeft ? -1 : 1
Rectangle {
@@ -97,8 +97,8 @@ AbstractSlider {
width: control.position * parent.width - 4
height: 2
- color: style.accentColor
- radius: style.roundness
+ color: control.Style.accentColor
+ radius: control.Style.roundness
}
}
}
diff --git a/src/imports/controls/SpinBox.qml b/src/imports/controls/SpinBox.qml
index 455ea08d..06b5629e 100644
--- a/src/imports/controls/SpinBox.qml
+++ b/src/imports/controls/SpinBox.qml
@@ -43,11 +43,11 @@ AbstractSpinBox {
implicitWidth: Math.max(background ? background.implicitWidth : 0,
(upButton ? upButton.implicitWidth : 0) +
(downButton ? downButton.implicitWidth : 0) +
- (input ? input.implicitWidth : 0) + style.padding * 2)
+ (input ? input.implicitWidth : 0) + Style.padding * 2)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
(upButton ? upButton.implicitHeight : 0),
(downButton ? downButton.implicitHeight : 0),
- (input ? input.implicitHeight : 0) + style.padding * 2)
+ (input ? input.implicitHeight : 0) + Style.padding * 2)
Accessible.role: Accessible.SpinBox
@@ -56,9 +56,9 @@ AbstractSpinBox {
width: parent.width - upButton.width - downButton.width
height: parent.height
- color: style.textColor
- selectionColor: style.selectionColor
- selectedTextColor: style.selectedTextColor
+ color: control.Style.textColor
+ selectionColor: control.Style.selectionColor
+ selectedTextColor: control.Style.selectedTextColor
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
Keys.forwardTo: control
@@ -71,30 +71,30 @@ AbstractSpinBox {
height: parent.height
x: parent.width - width
- opacity: enabled ? 1.0 : style.disabledOpacity
+ opacity: enabled ? 1.0 : control.Style.disabledOpacity
clip: true
Rectangle {
x: -radius
width: parent.width + radius
height: parent.height
- radius: style.roundness
- color: Qt.tint(Qt.tint(style.accentColor,
- control.activeFocus ? style.focusColor : "transparent"),
- pressed === AbstractSpinBox.UpButton ? style.pressColor : "transparent")
+ radius: control.Style.roundness
+ color: Qt.tint(Qt.tint(control.Style.accentColor,
+ control.activeFocus ? control.Style.focusColor : "transparent"),
+ pressed === AbstractSpinBox.UpButton ? control.Style.pressColor : "transparent")
}
Rectangle {
x: (parent.width - width) / 2
y: (parent.height - height) / 2
width: parent.width / 3
height: 2
- color: control.style.selectedTextColor
+ color: control.Style.selectedTextColor
}
Rectangle {
x: (parent.width - width) / 2
y: (parent.height - height) / 2
width: 2
height: parent.height / 3
- color: control.style.selectedTextColor
+ color: control.Style.selectedTextColor
}
}
@@ -102,31 +102,31 @@ AbstractSpinBox {
implicitWidth: 26
height: parent.height
- opacity: enabled ? 1.0 : style.disabledOpacity
+ opacity: enabled ? 1.0 : control.Style.disabledOpacity
clip: true
Rectangle {
width: parent.width + radius
height: parent.height
- radius: style.roundness
- color: Qt.tint(Qt.tint(style.accentColor,
- control.activeFocus ? style.focusColor : "transparent"),
- pressed === AbstractSpinBox.DownButton ? style.pressColor : "transparent")
+ radius: control.Style.roundness
+ color: Qt.tint(Qt.tint(control.Style.accentColor,
+ control.activeFocus ? control.Style.focusColor : "transparent"),
+ pressed === AbstractSpinBox.DownButton ? control.Style.pressColor : "transparent")
}
Rectangle {
x: (parent.width - width) / 2
y: (parent.height - height) / 2
width: parent.width / 3
height: 2
- color: control.style.selectedTextColor
+ color: control.Style.selectedTextColor
}
}
background: Rectangle {
implicitWidth: 120
- radius: style.roundness
+ radius: control.Style.roundness
border.width: control.activeFocus ? 2 : 1
- border.color: control.activeFocus ? style.focusColor : style.frameColor
- opacity: enabled ? 1.0 : style.disabledOpacity
+ border.color: control.activeFocus ? control.Style.focusColor : control.Style.frameColor
+ opacity: enabled ? 1.0 : control.Style.disabledOpacity
color: input.acceptableInput ? "white" : "lightpink"
}
}
diff --git a/src/imports/controls/Switch.qml b/src/imports/controls/Switch.qml
index e602a86a..58b4b9c1 100644
--- a/src/imports/controls/Switch.qml
+++ b/src/imports/controls/Switch.qml
@@ -43,7 +43,7 @@ AbstractSwitch {
implicitWidth: Math.max(background ? background.implicitWidth : 0,
(label ? label.implicitWidth : 0) +
(indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? style.spacing : 0) + leftPadding + rightPadding)
+ (label && indicator ? Style.spacing : 0) + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
Math.max(label ? label.implicitHeight : 0,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
@@ -54,7 +54,7 @@ AbstractSwitch {
Accessible.pressed: pressed
Accessible.role: Accessible.Button // TODO: Switch?
- padding: style.padding
+ padding: Style.padding
indicator: Rectangle {
readonly property bool mirror: control.effectiveLayoutDirection == Qt.RightToLeft
@@ -66,20 +66,20 @@ AbstractSwitch {
radius: 10
border.width: control.activeFocus ? 2 : 1
- border.color: control.activeFocus ? style.focusColor : style.frameColor
- opacity: enabled ? 1.0 : style.disabledOpacity
- color: style.backgroundColor
+ border.color: control.activeFocus ? control.Style.focusColor : control.Style.frameColor
+ opacity: enabled ? 1.0 : control.Style.disabledOpacity
+ color: control.Style.backgroundColor
Rectangle {
width: 12
height: 12
radius: 6
- color: Qt.tint(Qt.tint(control.checked ? style.accentColor : style.baseColor,
- control.checked && control.activeFocus ? style.focusColor : "transparent"),
- control.pressed ? style.pressColor : "transparent")
+ color: Qt.tint(Qt.tint(control.checked ? control.Style.accentColor : control.Style.baseColor,
+ control.checked && control.activeFocus ? control.Style.focusColor : "transparent"),
+ control.pressed ? control.Style.pressColor : "transparent")
border.width: control.checked || control.pressed ? 0 : 1
- border.color: style.frameColor
+ border.color: control.Style.frameColor
x: Math.max(4, Math.min(parent.width - width - 4,
control.visualPosition * parent.width - (width / 2)))
@@ -95,16 +95,16 @@ AbstractSwitch {
label: Text {
readonly property bool mirror: control.effectiveLayoutDirection == Qt.RightToLeft
- x: mirror ? control.leftPadding : (indicator.x + indicator.width + control.style.spacing)
+ x: mirror ? control.leftPadding : (indicator.x + indicator.width + control.Style.spacing)
y: control.topPadding
- width: parent.width - indicator.width - control.style.spacing - control.leftPadding - control.rightPadding
+ width: parent.width - indicator.width - control.Style.spacing - control.leftPadding - control.rightPadding
height: parent.height - control.topPadding - control.bottomPadding
text: control.text
- color: control.style.textColor
+ color: control.Style.textColor
elide: Text.ElideRight
visible: control.text
- opacity: enabled ? 1.0 : control.style.disabledOpacity
+ opacity: enabled ? 1.0 : control.Style.disabledOpacity
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
diff --git a/src/imports/controls/TabBar.qml b/src/imports/controls/TabBar.qml
index 4748647d..6d833485 100644
--- a/src/imports/controls/TabBar.qml
+++ b/src/imports/controls/TabBar.qml
@@ -98,7 +98,7 @@ AbstractTabBar {
height: 4
width: parent.width
y: parent.height - height
- color: style.accentColor
+ color: control.Style.accentColor
}
}
}
@@ -107,14 +107,14 @@ AbstractTabBar {
implicitWidth: 26
implicitHeight: 26
width: listView.width
- border.color: style.backgroundColor
+ border.color: control.Style.backgroundColor
border.width: 8
- color: listView.count > 1 ? style.frameColor : style.backgroundColor
+ color: listView.count > 1 ? control.Style.frameColor : control.Style.backgroundColor
Rectangle {
y: parent.height - height
width: parent.width
height: 1
- color: style.frameColor
+ color: control.Style.frameColor
}
}
}
diff --git a/src/imports/controls/TabButton.qml b/src/imports/controls/TabButton.qml
index 9a527463..b70bd83c 100644
--- a/src/imports/controls/TabButton.qml
+++ b/src/imports/controls/TabButton.qml
@@ -50,7 +50,7 @@ AbstractTabButton {
Accessible.selected: checked
Accessible.role: Accessible.PageTab
- padding: style.padding
+ padding: Style.padding
label: Text {
x: control.leftPadding
@@ -61,8 +61,8 @@ AbstractTabButton {
text: control.text
font.pointSize: 10
elide: Text.ElideRight
- color: control.pressed ? control.style.accentColor : control.style.textColor
- opacity: enabled ? 1.0 : control.style.disabledOpacity
+ color: control.pressed ? control.Style.accentColor : control.Style.textColor
+ opacity: enabled ? 1.0 : control.Style.disabledOpacity
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
@@ -70,6 +70,6 @@ AbstractTabButton {
background: Rectangle {
height: parent.height - 1
implicitHeight: 26
- color: style.backgroundColor
+ color: Style.backgroundColor
}
}
diff --git a/src/imports/controls/TextArea.qml b/src/imports/controls/TextArea.qml
index f4810031..d1895a9e 100644
--- a/src/imports/controls/TextArea.qml
+++ b/src/imports/controls/TextArea.qml
@@ -46,9 +46,9 @@ AbstractTextArea {
Accessible.readOnly: readOnly
Accessible.description: placeholder ? placeholder.text : ""
- color: style.textColor
- selectionColor: style.selectionColor
- selectedTextColor: style.selectedTextColor
+ color: Style.textColor
+ selectionColor: Style.selectionColor
+ selectedTextColor: Style.selectedTextColor
placeholder: Text {
x: control.leftPadding
@@ -56,8 +56,8 @@ AbstractTextArea {
width: parent.width - control.leftPadding - control.rightPadding
height: parent.height - control.topPadding - control.bottomPadding
- color: control.style.textColor
- opacity: control.style.disabledOpacity
+ color: control.Style.textColor
+ opacity: control.Style.disabledOpacity
visible: !control.length
}
}
diff --git a/src/imports/controls/TextField.qml b/src/imports/controls/TextField.qml
index ded85e84..a8e13f57 100644
--- a/src/imports/controls/TextField.qml
+++ b/src/imports/controls/TextField.qml
@@ -46,11 +46,11 @@ AbstractTextField {
Accessible.description: placeholder ? placeholder.text : ""
Accessible.passwordEdit: echoMode === TextInput.Password || echoMode === TextInput.PasswordEchoOnEdit
- padding: style.padding
+ padding: Style.padding
- color: style.textColor
- selectionColor: style.selectionColor
- selectedTextColor: style.selectedTextColor
+ color: Style.textColor
+ selectionColor: Style.selectionColor
+ selectedTextColor: Style.selectedTextColor
verticalAlignment: TextInput.AlignVCenter
placeholder: Text {
@@ -59,16 +59,16 @@ AbstractTextField {
width: parent.width - control.leftPadding - control.rightPadding
height: parent.height - control.topPadding - control.bottomPadding
- color: control.style.textColor
- opacity: control.style.disabledOpacity
+ color: control.Style.textColor
+ opacity: control.Style.disabledOpacity
visible: !control.displayText
}
background: Rectangle {
implicitWidth: 120 // TODO
- radius: style.roundness
+ radius: control.Style.roundness
border.width: control.activeFocus ? 2 : 1
- border.color: control.activeFocus ? style.focusColor : style.frameColor
- opacity: enabled ? 1.0 : style.disabledOpacity
+ border.color: control.activeFocus ? control.Style.focusColor : control.Style.frameColor
+ opacity: enabled ? 1.0 : control.Style.disabledOpacity
}
}
diff --git a/src/imports/controls/ToggleButton.qml b/src/imports/controls/ToggleButton.qml
index 61fd69dd..7ab30bd3 100644
--- a/src/imports/controls/ToggleButton.qml
+++ b/src/imports/controls/ToggleButton.qml
@@ -43,7 +43,7 @@ AbstractToggleButton {
implicitWidth: Math.max(background ? background.implicitWidth : 0,
(label ? label.implicitWidth : 0) +
(indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? style.spacing : 0) + leftPadding + rightPadding)
+ (label && indicator ? Style.spacing : 0) + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
Math.max(label ? label.implicitHeight : 0,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
@@ -54,7 +54,7 @@ AbstractToggleButton {
Accessible.pressed: pressed
Accessible.role: Accessible.Button
- padding: style.padding
+ padding: Style.padding
indicator: Rectangle {
readonly property bool mirror: control.effectiveLayoutDirection == Qt.RightToLeft
@@ -64,21 +64,21 @@ AbstractToggleButton {
x: text ? (mirror ? parent.width - width - control.rightPadding : control.leftPadding) : (parent.width - width) / 2
y: (parent.height - height) / 2
- radius: style.roundness
+ radius: control.Style.roundness
border.width: control.activeFocus ? 2 : 1
- border.color: control.activeFocus ? style.focusColor : style.frameColor
- opacity: enabled ? 1.0 : style.disabledOpacity
- color: style.backgroundColor
+ border.color: control.activeFocus ? control.Style.focusColor : control.Style.frameColor
+ opacity: enabled ? 1.0 : control.Style.disabledOpacity
+ color: control.Style.backgroundColor
Rectangle {
width: 12
height: 12
- color: Qt.tint(Qt.tint(control.checked ? style.accentColor : style.baseColor,
- control.checked && control.activeFocus ? style.focusColor : "transparent"),
- control.pressed ? style.pressColor : "transparent")
+ color: Qt.tint(Qt.tint(control.checked ? control.Style.accentColor : control.Style.baseColor,
+ control.checked && control.activeFocus ? control.Style.focusColor : "transparent"),
+ control.pressed ? control.Style.pressColor : "transparent")
border.width: control.checked || control.pressed ? 0 : 1
- border.color: style.frameColor
+ border.color: control.Style.frameColor
x: Math.max(4, Math.min(parent.width - width - 4,
control.visualPosition * parent.width - (width / 2)))
@@ -94,16 +94,16 @@ AbstractToggleButton {
label: Text {
readonly property bool mirror: control.effectiveLayoutDirection == Qt.RightToLeft
- x: mirror ? control.leftPadding : (indicator.x + indicator.width + control.style.spacing)
+ x: mirror ? control.leftPadding : (indicator.x + indicator.width + control.Style.spacing)
y: control.topPadding
- width: parent.width - indicator.width - control.style.spacing - control.leftPadding - control.rightPadding
+ width: parent.width - indicator.width - control.Style.spacing - control.leftPadding - control.rightPadding
height: parent.height - control.topPadding - control.bottomPadding
text: control.text
- color: control.style.textColor
+ color: control.Style.textColor
elide: Text.ElideRight
visible: control.text
- opacity: enabled ? 1.0 : control.style.disabledOpacity
+ opacity: enabled ? 1.0 : control.Style.disabledOpacity
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
diff --git a/src/imports/controls/ToolBar.qml b/src/imports/controls/ToolBar.qml
index 7806a1fc..8bdedd82 100644
--- a/src/imports/controls/ToolBar.qml
+++ b/src/imports/controls/ToolBar.qml
@@ -62,6 +62,6 @@ AbstractToolBar {
background: Rectangle {
implicitHeight: 26
- color: style.baseColor
+ color: control.Style.baseColor
}
}
diff --git a/src/imports/controls/ToolButton.qml b/src/imports/controls/ToolButton.qml
index f03b35c6..ade1c72a 100644
--- a/src/imports/controls/ToolButton.qml
+++ b/src/imports/controls/ToolButton.qml
@@ -49,7 +49,7 @@ AbstractButton {
Accessible.pressed: pressed
Accessible.role: Accessible.Button
- padding: style.padding
+ padding: Style.padding
label: Text {
x: control.leftPadding
@@ -58,9 +58,9 @@ AbstractButton {
height: parent.height - control.topPadding - control.bottomPadding
text: control.text
- color: control.style.textColor
+ color: control.Style.textColor
elide: Text.ElideRight
- opacity: enabled ? 1.0 : control.style.disabledOpacity
+ opacity: enabled ? 1.0 : control.Style.disabledOpacity
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
@@ -69,8 +69,8 @@ AbstractButton {
implicitWidth: 26
implicitHeight: 26
- opacity: style.disabledOpacity
- color: style.frameColor
+ opacity: control.Style.disabledOpacity
+ color: control.Style.frameColor
visible: control.pressed
}
}
diff --git a/src/imports/controls/controls.pro b/src/imports/controls/controls.pro
index d9de2bf9..98472d9f 100644
--- a/src/imports/controls/controls.pro
+++ b/src/imports/controls/controls.pro
@@ -37,11 +37,20 @@ QML_FILES = \
ToolBar.qml \
ToolButton.qml
+HEADERS += \
+ $$PWD/qquickstyle_p.h \
+ $$PWD/qquickstyledata_p.h
+
SOURCES += \
+ $$PWD/qquickstyle.cpp \
+ $$PWD/qquickstyledata.cpp \
$$PWD/qtquickcontrols2plugin.cpp
RESOURCES += \
$$PWD/qtquickcontrols2plugin.qrc
+OTHER_FILES += \
+ $$PWD/style.json
+
CONFIG += no_cxx_module
load(qml_plugin)
diff --git a/src/imports/controls/qquickstyle.cpp b/src/imports/controls/qquickstyle.cpp
new file mode 100644
index 00000000..54abbbf6
--- /dev/null
+++ b/src/imports/controls/qquickstyle.cpp
@@ -0,0 +1,826 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickstyle_p.h"
+#include "qquickstyledata_p.h"
+
+#include <QtCore/qset.h>
+#include <QtCore/qpointer.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickwindow.h>
+#include <QtQuick/private/qquickitem_p.h>
+#include <QtQuick/private/qquickitemchangelistener_p.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype Style
+ \inherits QtObject
+ \instantiates QQuickStyle
+ \inqmlmodule QtQuick.Controls
+ \ingroup utilities
+ \brief A style interface.
+
+ TODO
+*/
+
+/*!
+ \qmlattachedproperty color QtQuickControls2::Style::accentColor
+*/
+
+/*!
+ \qmlattachedproperty color QtQuickControls2::Style::backgroundColor
+*/
+
+/*!
+ \qmlattachedproperty color QtQuickControls2::Style::focusColor
+*/
+
+/*!
+ \qmlattachedproperty color QtQuickControls2::Style::frameColor
+*/
+
+/*!
+ \qmlattachedproperty color QtQuickControls2::Style::pressColor
+*/
+
+/*!
+ \qmlattachedproperty color QtQuickControls2::Style::selectedTextColor
+*/
+
+/*!
+ \qmlattachedproperty color QtQuickControls2::Style::selectionColor
+*/
+
+/*!
+ \qmlattachedproperty color QtQuickControls2::Style::shadowColor
+*/
+
+/*!
+ \qmlattachedproperty color QtQuickControls2::Style::textColor
+*/
+
+/*!
+ \qmlattachedproperty int QtQuickControls2::Style::padding
+*/
+
+/*!
+ \qmlattachedproperty int QtQuickControls2::Style::roundness
+*/
+
+/*!
+ \qmlattachedproperty int QtQuickControls2::Style::spacing
+*/
+
+/*!
+ \qmlattachedproperty real QtQuickControls2::Style::disabledOpacity
+*/
+
+Q_GLOBAL_STATIC_WITH_ARGS(QQuickStyleData, globalStyleData, QStringLiteral(":/qtquickcontrols/style.json"))
+
+static QQuickStyle *styleInstance(QQmlEngine *engine)
+{
+ static QHash<QQmlEngine *, QQuickStyle *> styles;
+ QHash<QQmlEngine *, QQuickStyle *>::iterator it = styles.find(engine);
+ if (it == styles.end())
+ it = styles.insert(engine, new QQuickStyle(*globalStyleData(), engine));
+ return it.value();
+}
+
+static QQuickStyle *attachedStyle(QObject *object)
+{
+ if (object)
+ return qobject_cast<QQuickStyle*>(qmlAttachedPropertiesObject<QQuickStyle>(object, false));
+ return Q_NULLPTR;
+}
+
+static QQuickStyle *findParentStyle(QObject *object)
+{
+ QQuickItem *item = qobject_cast<QQuickItem *>(object);
+ if (item) {
+ // lookup parent items
+ QQuickItem *parent = item->parentItem();
+ while (parent) {
+ QQuickStyle *attached = attachedStyle(parent);
+ if (attached)
+ return attached;
+ parent = parent->parentItem();
+ }
+
+ // fallback to item's window style
+ QQuickWindow *window = item->window();
+ if (window) {
+ QQuickStyle *attached = attachedStyle(window);
+ if (attached)
+ return attached;
+ }
+ }
+
+ // lookup parent window style
+ QQuickWindow *window = qobject_cast<QQuickWindow *>(object);
+ if (window) {
+ QQuickWindow *parentWindow = qobject_cast<QQuickWindow *>(window->parent());
+ if (parentWindow) {
+ QQuickStyle *attached = attachedStyle(window);
+ if (attached)
+ return attached;
+ }
+ }
+
+ // fallback to global style
+ if (object) {
+ QQmlEngine *engine = qmlEngine(object);
+ if (engine)
+ return styleInstance(engine);
+ }
+
+ return Q_NULLPTR;
+}
+
+static QList<QQuickStyle *> findChildStyles(QObject *object)
+{
+ QList<QQuickStyle *> styles;
+
+ QQuickItem *item = qobject_cast<QQuickItem *>(object);
+ if (!item) {
+ QQuickWindow *window = qobject_cast<QQuickWindow *>(object);
+ if (window) {
+ item = window->contentItem();
+
+ foreach (QObject *child, window->children()) {
+ QQuickWindow *childWindow = qobject_cast<QQuickWindow *>(child);
+ if (childWindow) {
+ QQuickStyle *style = attachedStyle(childWindow);
+ if (style)
+ styles += style;
+ }
+ }
+ }
+ }
+
+ if (item) {
+ foreach (QQuickItem *child, item->childItems()) {
+ QQuickStyle *style = attachedStyle(child);
+ if (style)
+ styles += style;
+ else
+ styles += findChildStyles(child);
+ }
+ }
+
+ return styles;
+}
+
+class QQuickStylePrivate : public QObjectPrivate, public QQuickItemChangeListener
+{
+ Q_DECLARE_PUBLIC(QQuickStyle)
+
+public:
+ QQuickStylePrivate(const QQuickStyleData &data) : data(data),
+ explicitAccentColor(false),
+ explicitBackgroundColor(false),
+ explicitBaseColor(false),
+ explicitFocusColor(false),
+ explicitFrameColor(false),
+ explicitPressColor(false),
+ explicitSelectedTextColor(false),
+ explicitSelectionColor(false),
+ explicitShadowColor(false),
+ explicitTextColor(false),
+ explicitPadding(false),
+ explicitSpacing(false),
+ explicitRoundness(false),
+ explicitDisabledOpacity(false) { }
+
+ enum Method { Implicit, Explicit, Inherit };
+
+ void setAccentColor(const QColor &color, Method method);
+ void setBackgroundColor(const QColor &color, Method method);
+ void setBaseColor(const QColor &color, Method method);
+ void setFocusColor(const QColor &color, Method method);
+ void setFrameColor(const QColor &color, Method method);
+ void setPressColor(const QColor &color, Method method);
+ void setSelectedTextColor(const QColor &color, Method method);
+ void setSelectionColor(const QColor &color, Method method);
+ void setShadowColor(const QColor &color, Method method);
+ void setTextColor(const QColor &color, Method method);
+ void setPadding(int padding, Method method);
+ void setRoundness(int roundness, Method method);
+ void setSpacing(int spacing, Method method);
+ void setDisabledOpacity(qreal opacity, Method method);
+
+ void inherit(QQuickStyle *style);
+
+ const QQuickStyleData &resolve() const;
+
+ // TODO: add QQuickItemChangeListener::itemSceneChanged()
+ void itemParentChanged(QQuickItem *item, QQuickItem *parent) Q_DECL_OVERRIDE;
+
+ QQuickStyleData data;
+ QPointer<QQuickStyle> parentStyle;
+ QSet<QQuickStyle *> childStyles;
+
+ bool explicitAccentColor;
+ bool explicitBackgroundColor;
+ bool explicitBaseColor;
+ bool explicitFocusColor;
+ bool explicitFrameColor;
+ bool explicitPressColor;
+ bool explicitSelectedTextColor;
+ bool explicitSelectionColor;
+ bool explicitShadowColor;
+ bool explicitTextColor;
+ bool explicitPadding;
+ bool explicitSpacing;
+ bool explicitRoundness;
+ bool explicitDisabledOpacity;
+};
+
+void QQuickStylePrivate::setAccentColor(const QColor &color, Method method)
+{
+ Q_Q(QQuickStyle);
+ if (!explicitAccentColor || method != Inherit) {
+ explicitAccentColor = method == Explicit;
+ if (data.accentColor() != color) {
+ data.setAccentColor(color);
+ emit q->accentColorChanged();
+
+ foreach (QQuickStyle *child, childStyles)
+ child->d_func()->setAccentColor(color, Inherit);
+ }
+ }
+}
+
+void QQuickStylePrivate::setBackgroundColor(const QColor &color, Method method)
+{
+ Q_Q(QQuickStyle);
+ if (!explicitBackgroundColor || method != Inherit) {
+ explicitBackgroundColor = method == Explicit;
+ if (data.backgroundColor() != color) {
+ data.setBackgroundColor(color);
+ emit q->backgroundColorChanged();
+
+ foreach (QQuickStyle *child, childStyles)
+ child->d_func()->setBackgroundColor(color, Inherit);
+ }
+ }
+}
+
+void QQuickStylePrivate::setBaseColor(const QColor &color, Method method)
+{
+ Q_Q(QQuickStyle);
+ if (!explicitBaseColor || method != Inherit) {
+ explicitBaseColor = method == Explicit;
+ if (data.baseColor() != color) {
+ data.setBaseColor(color);
+ emit q->baseColorChanged();
+
+ foreach (QQuickStyle *child, childStyles)
+ child->d_func()->setBaseColor(color, Inherit);
+ }
+ }
+}
+
+void QQuickStylePrivate::setFocusColor(const QColor &color, Method method)
+{
+ Q_Q(QQuickStyle);
+ if (!explicitFocusColor || method != Inherit) {
+ explicitFocusColor = method == Explicit;
+ if (data.focusColor() != color) {
+ data.setFocusColor(color);
+ emit q->focusColorChanged();
+
+ foreach (QQuickStyle *child, childStyles)
+ child->d_func()->setFocusColor(color, Inherit);
+ }
+ }
+}
+
+void QQuickStylePrivate::setFrameColor(const QColor &color, Method method)
+{
+ Q_Q(QQuickStyle);
+ if (!explicitFrameColor || method != Inherit) {
+ explicitFrameColor = method == Explicit;
+ if (data.frameColor() != color) {
+ data.setFrameColor(color);
+ emit q->frameColorChanged();
+
+ foreach (QQuickStyle *child, childStyles)
+ child->d_func()->setFrameColor(color, Inherit);
+ }
+ }
+}
+
+void QQuickStylePrivate::setPressColor(const QColor &color, Method method)
+{
+ Q_Q(QQuickStyle);
+ if (!explicitPressColor || method != Inherit) {
+ explicitPressColor = method == Explicit;
+ if (data.pressColor() != color) {
+ data.setPressColor(color);
+ emit q->pressColorChanged();
+
+ foreach (QQuickStyle *child, childStyles)
+ child->d_func()->setPressColor(color, Inherit);
+ }
+ }
+}
+
+void QQuickStylePrivate::setSelectedTextColor(const QColor &color, Method method)
+{
+ Q_Q(QQuickStyle);
+ if (!explicitSelectedTextColor || method != Inherit) {
+ explicitSelectedTextColor = method == Explicit;
+ if (data.selectedTextColor() != color) {
+ data.setSelectedTextColor(color);
+ q->selectedTextColorChanged();
+
+ foreach (QQuickStyle *child, childStyles)
+ child->d_func()->setSelectedTextColor(color, Inherit);
+ }
+ }
+}
+
+void QQuickStylePrivate::setSelectionColor(const QColor &color, Method method)
+{
+ Q_Q(QQuickStyle);
+ if (!explicitSelectionColor || method != Inherit) {
+ explicitSelectionColor = method == Explicit;
+ if (data.selectionColor() != color) {
+ data.setSelectionColor(color);
+ emit q->selectionColorChanged();
+
+ foreach (QQuickStyle *child, childStyles)
+ child->d_func()->setSelectionColor(color, Inherit);
+ }
+ }
+}
+
+void QQuickStylePrivate::setShadowColor(const QColor &color, Method method)
+{
+ Q_Q(QQuickStyle);
+ if (!explicitShadowColor || method != Inherit) {
+ explicitShadowColor = method == Explicit;
+ if (data.shadowColor() != color) {
+ data.setShadowColor(color);
+ emit q->shadowColorChanged();
+
+ foreach (QQuickStyle *child, childStyles)
+ child->d_func()->setShadowColor(color, Inherit);
+ }
+ }
+}
+
+void QQuickStylePrivate::setTextColor(const QColor &color, Method method)
+{
+ Q_Q(QQuickStyle);
+ if (!explicitTextColor || method != Inherit) {
+ explicitTextColor = method == Explicit;
+ if (data.textColor() != color) {
+ data.setTextColor(color);
+ emit q->textColorChanged();
+
+ foreach (QQuickStyle *child, childStyles)
+ child->d_func()->setTextColor(color, Inherit);
+ }
+ }
+}
+
+void QQuickStylePrivate::setPadding(int padding, Method method)
+{
+ Q_Q(QQuickStyle);
+ if (!explicitPadding || method != Inherit) {
+ explicitPadding = method == Explicit;
+ if (data.padding() != padding) {
+ data.setPadding(padding);
+ emit q->paddingChanged();
+
+ foreach (QQuickStyle *child, childStyles)
+ child->d_func()->setPadding(padding, Inherit);
+ }
+ }
+}
+
+void QQuickStylePrivate::setRoundness(int roundness, Method method)
+{
+ Q_Q(QQuickStyle);
+ if (!explicitRoundness || method != Inherit) {
+ explicitRoundness = method == Explicit;
+ if (data.roundness() != roundness) {
+ data.setRoundness(roundness);
+ emit q->roundnessChanged();
+
+ foreach (QQuickStyle *child, childStyles)
+ child->d_func()->setRoundness(roundness, Inherit);
+ }
+ }
+}
+
+void QQuickStylePrivate::setSpacing(int spacing, Method method)
+{
+ Q_Q(QQuickStyle);
+ if (!explicitSpacing || method != Inherit) {
+ explicitSpacing = method == Explicit;
+ if (data.spacing() != spacing) {
+ data.setSpacing(spacing);
+ emit q->spacingChanged();
+
+ foreach (QQuickStyle *child, childStyles)
+ child->d_func()->setSpacing(spacing, Inherit);
+ }
+ }
+}
+
+void QQuickStylePrivate::setDisabledOpacity(qreal opacity, Method method)
+{
+ Q_Q(QQuickStyle);
+ if (!explicitDisabledOpacity || method != Inherit) {
+ explicitDisabledOpacity = method == Explicit;
+ if (data.disabledOpacity() != opacity) {
+ data.setDisabledOpacity(opacity);
+ emit q->disabledOpacityChanged();
+
+ foreach (QQuickStyle *child, childStyles)
+ child->d_func()->setDisabledOpacity(opacity, Inherit);
+ }
+ }
+}
+
+void QQuickStylePrivate::inherit(QQuickStyle *style)
+{
+ setAccentColor(style->accentColor(), Inherit);
+ setBackgroundColor(style->backgroundColor(), Inherit);
+ setBaseColor(style->baseColor(), QQuickStylePrivate::Inherit);
+ setFocusColor(style->focusColor(), Inherit);
+ setFrameColor(style->frameColor(), Inherit);
+ setPressColor(style->pressColor(), Inherit);
+ setSelectedTextColor(style->selectedTextColor(), Inherit);
+ setSelectionColor(style->selectionColor(), Inherit);
+ setShadowColor(style->shadowColor(), Inherit);
+ setTextColor(style->textColor(), Inherit);
+ setPadding(style->padding(), Inherit);
+ setRoundness(style->roundness(), Inherit);
+ setSpacing(style->spacing(), Inherit);
+ setDisabledOpacity(style->disabledOpacity(), Inherit);
+}
+
+const QQuickStyleData &QQuickStylePrivate::resolve() const
+{
+ Q_Q(const QQuickStyle);
+ QQuickStyle *style = findParentStyle(const_cast<QQuickStyle *>(q));
+ return style ? style->d_func()->data : *globalStyleData();
+}
+
+void QQuickStylePrivate::itemParentChanged(QQuickItem *item, QQuickItem *)
+{
+ QQuickStyle *style = attachedStyle(item);
+ if (style) {
+ QQuickStyle *parent = findParentStyle(style);
+ if (parent)
+ style->setParentStyle(parent);
+ }
+}
+
+QQuickStyle::QQuickStyle(const QQuickStyleData &data, QObject *parent) :
+ QObject(*(new QQuickStylePrivate(data)), parent)
+{
+ Q_D(QQuickStyle);
+ QQuickItem *item = qobject_cast<QQuickItem *>(parent);
+ if (item)
+ QQuickItemPrivate::get(item)->addItemChangeListener(d, QQuickItemPrivate::Parent);
+}
+
+QQuickStyle::~QQuickStyle()
+{
+ Q_D(QQuickStyle);
+ QQuickItem *item = qobject_cast<QQuickItem *>(parent());
+ if (item)
+ QQuickItemPrivate::get(item)->removeItemChangeListener(d, QQuickItemPrivate::Parent);
+
+ setParentStyle(Q_NULLPTR);
+}
+
+QQuickStyle *QQuickStyle::qmlAttachedProperties(QObject *object)
+{
+ QQuickStyle *style = Q_NULLPTR;
+ QQuickStyle *parent = findParentStyle(object);
+ if (parent) {
+ style = new QQuickStyle(parent->d_func()->data, object);
+ style->setParentStyle(parent);
+ } else {
+ style = new QQuickStyle(*globalStyleData(), object);
+ }
+
+ QList<QQuickStyle *> childStyles = findChildStyles(object);
+ foreach (QQuickStyle *child, childStyles)
+ child->setParentStyle(style);
+ return style;
+}
+
+QQuickStyle *QQuickStyle::parentStyle() const
+{
+ Q_D(const QQuickStyle);
+ return d->parentStyle;
+}
+
+void QQuickStyle::setParentStyle(QQuickStyle *style)
+{
+ Q_D(QQuickStyle);
+ if (d->parentStyle != style) {
+ if (d->parentStyle)
+ d->parentStyle->d_func()->childStyles.remove(this);
+ d->parentStyle = style;
+ if (style) {
+ style->d_func()->childStyles.insert(this);
+ d->inherit(style);
+ }
+ }
+}
+
+QColor QQuickStyle::accentColor() const
+{
+ Q_D(const QQuickStyle);
+ return d->data.accentColor();
+}
+
+void QQuickStyle::setAccentColor(const QColor &color)
+{
+ Q_D(QQuickStyle);
+ d->setAccentColor(color, QQuickStylePrivate::Explicit);
+}
+
+void QQuickStyle::resetAccentColor()
+{
+ Q_D(QQuickStyle);
+ d->setAccentColor(d->resolve().accentColor(), QQuickStylePrivate::Implicit);
+}
+
+QColor QQuickStyle::backgroundColor() const
+{
+ Q_D(const QQuickStyle);
+ return d->data.backgroundColor();
+}
+
+void QQuickStyle::setBackgroundColor(const QColor &color)
+{
+ Q_D(QQuickStyle);
+ d->setBackgroundColor(color, QQuickStylePrivate::Explicit);
+}
+
+void QQuickStyle::resetBackgroundColor()
+{
+ Q_D(QQuickStyle);
+ d->setBackgroundColor(d->resolve().backgroundColor(), QQuickStylePrivate::Implicit);
+}
+
+QColor QQuickStyle::baseColor() const
+{
+ Q_D(const QQuickStyle);
+ return d->data.baseColor();
+}
+
+void QQuickStyle::setBaseColor(const QColor &color)
+{
+ Q_D(QQuickStyle);
+ d->setBaseColor(color, QQuickStylePrivate::Explicit);
+}
+
+void QQuickStyle::resetBaseColor()
+{
+ Q_D(QQuickStyle);
+ d->setBaseColor(d->resolve().baseColor(), QQuickStylePrivate::Implicit);
+}
+
+QColor QQuickStyle::focusColor() const
+{
+ Q_D(const QQuickStyle);
+ return d->data.focusColor();
+}
+
+void QQuickStyle::setFocusColor(const QColor &color)
+{
+ Q_D(QQuickStyle);
+ d->setFocusColor(color, QQuickStylePrivate::Explicit);
+}
+
+void QQuickStyle::resetFocusColor()
+{
+ Q_D(QQuickStyle);
+ d->setFocusColor(d->resolve().focusColor(), QQuickStylePrivate::Implicit);
+}
+
+QColor QQuickStyle::frameColor() const
+{
+ Q_D(const QQuickStyle);
+ return d->data.frameColor();
+}
+
+void QQuickStyle::setFrameColor(const QColor &color)
+{
+ Q_D(QQuickStyle);
+ d->setFrameColor(color, QQuickStylePrivate::Explicit);
+}
+
+void QQuickStyle::resetFrameColor()
+{
+ Q_D(QQuickStyle);
+ d->setFrameColor(d->resolve().frameColor(), QQuickStylePrivate::Implicit);
+}
+
+QColor QQuickStyle::pressColor() const
+{
+ Q_D(const QQuickStyle);
+ return d->data.pressColor();
+}
+
+void QQuickStyle::setPressColor(const QColor &color)
+{
+ Q_D(QQuickStyle);
+ d->setPressColor(color, QQuickStylePrivate::Explicit);
+}
+
+void QQuickStyle::resetPressColor()
+{
+ Q_D(QQuickStyle);
+ d->setPressColor(d->resolve().pressColor(), QQuickStylePrivate::Implicit);
+}
+
+QColor QQuickStyle::selectedTextColor() const
+{
+ Q_D(const QQuickStyle);
+ return d->data.selectedTextColor();
+}
+
+void QQuickStyle::setSelectedTextColor(const QColor &color)
+{
+ Q_D(QQuickStyle);
+ d->setSelectedTextColor(color, QQuickStylePrivate::Explicit);
+}
+
+void QQuickStyle::resetSelectedTextColor()
+{
+ Q_D(QQuickStyle);
+ d->setSelectedTextColor(d->resolve().selectedTextColor(), QQuickStylePrivate::Implicit);
+}
+
+QColor QQuickStyle::selectionColor() const
+{
+ Q_D(const QQuickStyle);
+ return d->data.selectionColor();
+}
+
+void QQuickStyle::setSelectionColor(const QColor &color)
+{
+ Q_D(QQuickStyle);
+ d->setSelectionColor(color, QQuickStylePrivate::Explicit);
+}
+
+void QQuickStyle::resetSelectionColor()
+{
+ Q_D(QQuickStyle);
+ d->setSelectionColor(d->resolve().selectionColor(), QQuickStylePrivate::Implicit);
+}
+
+QColor QQuickStyle::shadowColor() const
+{
+ Q_D(const QQuickStyle);
+ return d->data.shadowColor();
+}
+
+void QQuickStyle::setShadowColor(const QColor &color)
+{
+ Q_D(QQuickStyle);
+ d->setShadowColor(color, QQuickStylePrivate::Explicit);
+}
+
+void QQuickStyle::resetShadowColor()
+{
+ Q_D(QQuickStyle);
+ d->setShadowColor(d->resolve().shadowColor(), QQuickStylePrivate::Implicit);
+}
+
+QColor QQuickStyle::textColor() const
+{
+ Q_D(const QQuickStyle);
+ return d->data.textColor();
+}
+
+void QQuickStyle::setTextColor(const QColor &color)
+{
+ Q_D(QQuickStyle);
+ d->setTextColor(color, QQuickStylePrivate::Explicit);
+}
+
+void QQuickStyle::resetTextColor()
+{
+ Q_D(QQuickStyle);
+ d->setTextColor(d->resolve().textColor(), QQuickStylePrivate::Implicit);
+}
+
+int QQuickStyle::padding() const
+{
+ Q_D(const QQuickStyle);
+ return d->data.padding();
+}
+
+void QQuickStyle::setPadding(int padding)
+{
+ Q_D(QQuickStyle);
+ d->setPadding(padding, QQuickStylePrivate::Explicit);
+}
+
+void QQuickStyle::resetPadding()
+{
+ Q_D(QQuickStyle);
+ d->setPadding(d->resolve().padding(), QQuickStylePrivate::Implicit);
+}
+
+int QQuickStyle::roundness() const
+{
+ Q_D(const QQuickStyle);
+ return d->data.roundness();
+}
+
+void QQuickStyle::setRoundness(int roundness)
+{
+ Q_D(QQuickStyle);
+ d->setRoundness(roundness, QQuickStylePrivate::Explicit);
+}
+
+void QQuickStyle::resetRoundness()
+{
+ Q_D(QQuickStyle);
+ d->setRoundness(d->resolve().roundness(), QQuickStylePrivate::Implicit);
+}
+
+int QQuickStyle::spacing() const
+{
+ Q_D(const QQuickStyle);
+ return d->data.spacing();
+}
+
+void QQuickStyle::setSpacing(int spacing)
+{
+ Q_D(QQuickStyle);
+ d->setSpacing(spacing, QQuickStylePrivate::Explicit);
+}
+
+void QQuickStyle::resetSpacing()
+{
+ Q_D(QQuickStyle);
+ d->setSpacing(d->resolve().spacing(), QQuickStylePrivate::Implicit);
+}
+
+qreal QQuickStyle::disabledOpacity() const
+{
+ Q_D(const QQuickStyle);
+ return d->data.disabledOpacity();
+}
+
+void QQuickStyle::setDisabledOpacity(qreal opacity)
+{
+ Q_D(QQuickStyle);
+ d->setDisabledOpacity(opacity, QQuickStylePrivate::Explicit);
+}
+
+void QQuickStyle::resetDisabledOpacity()
+{
+ Q_D(QQuickStyle);
+ d->setDisabledOpacity(d->resolve().disabledOpacity(), QQuickStylePrivate::Implicit);
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/controls/qquickstyle_p.h b/src/imports/controls/qquickstyle_p.h
new file mode 100644
index 00000000..38ffe5df
--- /dev/null
+++ b/src/imports/controls/qquickstyle_p.h
@@ -0,0 +1,168 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKSTYLE_P_H
+#define QQUICKSTYLE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtQml/qqml.h>
+#include <QtGui/qcolor.h>
+#include <QtCore/qobject.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickStyleData;
+class QQuickStylePrivate;
+
+class QQuickStyle : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor accentColor READ accentColor WRITE setAccentColor RESET resetAccentColor NOTIFY accentColorChanged FINAL)
+ Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor RESET resetBackgroundColor NOTIFY backgroundColorChanged FINAL)
+ Q_PROPERTY(QColor baseColor READ baseColor WRITE setBaseColor RESET resetBaseColor NOTIFY baseColorChanged FINAL)
+ Q_PROPERTY(QColor focusColor READ focusColor WRITE setFocusColor RESET resetFocusColor NOTIFY focusColorChanged FINAL)
+ Q_PROPERTY(QColor frameColor READ frameColor WRITE setFrameColor RESET resetFrameColor NOTIFY frameColorChanged FINAL)
+ Q_PROPERTY(QColor pressColor READ pressColor WRITE setPressColor RESET resetPressColor NOTIFY pressColorChanged FINAL)
+ Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor RESET resetSelectedTextColor NOTIFY selectedTextColorChanged FINAL)
+ Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor RESET resetSelectionColor NOTIFY selectionColorChanged FINAL)
+ Q_PROPERTY(QColor shadowColor READ shadowColor WRITE setShadowColor RESET resetShadowColor NOTIFY shadowColorChanged FINAL)
+ Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor RESET resetTextColor NOTIFY textColorChanged FINAL)
+ Q_PROPERTY(int padding READ padding WRITE setPadding RESET resetPadding NOTIFY paddingChanged FINAL)
+ Q_PROPERTY(int roundness READ roundness WRITE setRoundness RESET resetRoundness NOTIFY roundnessChanged FINAL)
+ Q_PROPERTY(int spacing READ spacing WRITE setSpacing RESET resetSpacing NOTIFY spacingChanged FINAL)
+ Q_PROPERTY(qreal disabledOpacity READ disabledOpacity WRITE setDisabledOpacity RESET resetDisabledOpacity NOTIFY disabledOpacityChanged FINAL)
+
+public:
+ explicit QQuickStyle(const QQuickStyleData &data, QObject *parent = Q_NULLPTR);
+ ~QQuickStyle();
+
+ static QQuickStyle *qmlAttachedProperties(QObject *object);
+
+ QQuickStyle *parentStyle() const;
+ void setParentStyle(QQuickStyle *style);
+
+ QColor accentColor() const;
+ void setAccentColor(const QColor &color);
+ void resetAccentColor();
+
+ QColor backgroundColor() const;
+ void setBackgroundColor(const QColor &color);
+ void resetBackgroundColor();
+
+ QColor baseColor() const;
+ void setBaseColor(const QColor &color);
+ void resetBaseColor();
+
+ QColor focusColor() const;
+ void setFocusColor(const QColor &color);
+ void resetFocusColor();
+
+ QColor frameColor() const;
+ void setFrameColor(const QColor &color);
+ void resetFrameColor();
+
+ QColor pressColor() const;
+ void setPressColor(const QColor &color);
+ void resetPressColor();
+
+ QColor selectedTextColor() const;
+ void setSelectedTextColor(const QColor &color);
+ void resetSelectedTextColor();
+
+ QColor selectionColor() const;
+ void setSelectionColor(const QColor &color);
+ void resetSelectionColor();
+
+ QColor shadowColor() const;
+ void setShadowColor(const QColor &color);
+ void resetShadowColor();
+
+ QColor textColor() const;
+ void setTextColor(const QColor &color);
+ void resetTextColor();
+
+ int padding() const;
+ void setPadding(int padding);
+ void resetPadding();
+
+ int roundness() const;
+ void setRoundness(int roundness);
+ void resetRoundness();
+
+ int spacing() const;
+ void setSpacing(int spacing);
+ void resetSpacing();
+
+ qreal disabledOpacity() const;
+ void setDisabledOpacity(qreal opacity);
+ void resetDisabledOpacity();
+
+Q_SIGNALS:
+ void accentColorChanged();
+ void backgroundColorChanged();
+ void baseColorChanged();
+ void focusColorChanged();
+ void frameColorChanged();
+ void pressColorChanged();
+ void selectedTextColorChanged();
+ void selectionColorChanged();
+ void shadowColorChanged();
+ void textColorChanged();
+ void paddingChanged();
+ void roundnessChanged();
+ void spacingChanged();
+ void disabledOpacityChanged();
+
+private:
+ Q_DISABLE_COPY(QQuickStyle)
+ Q_DECLARE_PRIVATE(QQuickStyle)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPEINFO(QQuickStyle, QML_HAS_ATTACHED_PROPERTIES)
+
+#endif // QQUICKSTYLE_P_H
diff --git a/src/imports/controls/qquickstyledata.cpp b/src/imports/controls/qquickstyledata.cpp
new file mode 100644
index 00000000..9e81e61b
--- /dev/null
+++ b/src/imports/controls/qquickstyledata.cpp
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickstyledata_p.h"
+
+#include <QtCore/qfile.h>
+#include <QtCore/qjsondocument.h>
+#include <QtCore/qjsonobject.h>
+#include <QtCore/qjsonvalue.h>
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+QQuickStyleData::QQuickStyleData(const QString &filePath) : d(new Data)
+{
+ if (!filePath.isEmpty())
+ load(filePath);
+}
+
+static QColor readColorValue(const QJsonValue &value, const QColor &defaultValue)
+{
+ if (value.isString())
+ return QColor(value.toString());
+ return QColor::fromRgba(value.toInt(defaultValue.rgba()));
+}
+
+static double readNumberValue(const QJsonValue &value, double defaultValue)
+{
+ return value.toDouble(defaultValue);
+}
+
+bool QQuickStyleData::load(const QString &filePath)
+{
+ QJsonDocument doc;
+
+ QFile file(filePath);
+ if (!file.open(QFile::ReadOnly | QFile::Text)) {
+ qDebug() << file.error();
+ qWarning() << "QQuickStyle: failed to open ':/qtquickcontrols/style.json': " << qPrintable(file.errorString());
+ return false;
+ } else {
+ QJsonParseError error;
+ doc = QJsonDocument::fromJson(file.readAll(), &error);
+ if (error.error != QJsonParseError::NoError) {
+ qWarning() << "QQuickStyle: failed to parse ':/qtquickcontrols/style.json': " << qPrintable(error.errorString());
+ return false;
+ }
+ }
+
+ QJsonObject style = doc.object();
+ d->accentColor = readColorValue(style.value(QStringLiteral("accentColor")), QColor("#7bc258"));
+ d->backgroundColor = readColorValue(style.value(QStringLiteral("backgroundColor")), QColor("#ffffff"));
+ d->baseColor = readColorValue(style.value(QStringLiteral("baseColor")), QColor("#eeeeee"));
+ d->focusColor = readColorValue(style.value(QStringLiteral("focusColor")), QColor("#45a7d7"));
+ d->frameColor = readColorValue(style.value(QStringLiteral("frameColor")), QColor("#bdbebf"));
+ d->pressColor = readColorValue(style.value(QStringLiteral("pressColor")), QColor("#33333333"));
+ d->selectedTextColor = readColorValue(style.value(QStringLiteral("selectedTextColor")), QColor("#ffffff"));
+ d->selectionColor = readColorValue(style.value(QStringLiteral("selectionColor")), QColor("#45a7d7"));
+ d->shadowColor = readColorValue(style.value(QStringLiteral("shadowColor")), QColor("#28282a"));
+ d->textColor = readColorValue(style.value(QStringLiteral("textColor")), QColor("#26282a"));
+ d->padding = readNumberValue(style.value(QStringLiteral("padding")), 6);
+ d->roundness = readNumberValue(style.value(QStringLiteral("roundness")), 3);
+ d->spacing = readNumberValue(style.value(QStringLiteral("spacing")), 6);
+ d->disabledOpacity = readNumberValue(style.value(QStringLiteral("disabledOpacity")), 0.3);
+ return true;
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/controls/qquickstyledata_p.h b/src/imports/controls/qquickstyledata_p.h
new file mode 100644
index 00000000..29938f7d
--- /dev/null
+++ b/src/imports/controls/qquickstyledata_p.h
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKSTYLEDATA_P_H
+#define QQUICKSTYLEDATA_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtGui/qcolor.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qshareddata.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickStyleData
+{
+public:
+ QQuickStyleData(const QString &filePath = QString());
+
+ bool load(const QString &filePath);
+
+ QColor accentColor() const { return d->accentColor; }
+ void setAccentColor(const QColor &color) { d->accentColor = color; }
+
+ QColor backgroundColor() const { return d->backgroundColor; }
+ void setBackgroundColor(const QColor &color) { d->backgroundColor = color; }
+
+ QColor baseColor() const { return d->baseColor; }
+ void setBaseColor(const QColor &color) { d->baseColor = color; }
+
+ QColor focusColor() const { return d->focusColor; }
+ void setFocusColor(const QColor &color) { d->focusColor = color; }
+
+ QColor frameColor() const { return d->frameColor; }
+ void setFrameColor(const QColor &color) { d->frameColor = color; }
+
+ QColor pressColor() const { return d->pressColor; }
+ void setPressColor(const QColor &color) { d->pressColor = color; }
+
+ QColor selectedTextColor() const { return d->selectedTextColor; }
+ void setSelectedTextColor(const QColor &color) { d->selectedTextColor = color; }
+
+ QColor selectionColor() const { return d->selectionColor; }
+ void setSelectionColor(const QColor &color) { d->selectionColor = color; }
+
+ QColor shadowColor() const { return d->shadowColor; }
+ void setShadowColor(const QColor &color) { d->shadowColor = color; }
+
+ QColor textColor() const { return d->textColor; }
+ void setTextColor(const QColor &color) { d->textColor = color; }
+
+ int padding() const { return d->padding; }
+ void setPadding(int padding) { d->padding = padding; }
+
+ int roundness() const { return d->roundness; }
+ void setRoundness(int roundness) { d->roundness = roundness; }
+
+ int spacing() const { return d->spacing; }
+ void setSpacing(int spacing) { d->spacing = spacing; }
+
+ qreal disabledOpacity() const { return d->disabledOpacity; }
+ void setDisabledOpacity(qreal opacity) { d->disabledOpacity = opacity; }
+
+private:
+ struct Data : public QSharedData {
+ QColor accentColor;
+ QColor baseColor;
+ QColor backgroundColor;
+ QColor focusColor;
+ QColor frameColor;
+ QColor pressColor;
+ QColor selectedTextColor;
+ QColor selectionColor;
+ QColor shadowColor;
+ QColor textColor;
+ int padding;
+ int spacing;
+ int roundness;
+ qreal disabledOpacity;
+ };
+ QSharedDataPointer<Data> d;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKSTYLEDATA_P_H
diff --git a/src/imports/controls/qtquickcontrols2plugin.cpp b/src/imports/controls/qtquickcontrols2plugin.cpp
index 8a992758..7c7d2bf9 100644
--- a/src/imports/controls/qtquickcontrols2plugin.cpp
+++ b/src/imports/controls/qtquickcontrols2plugin.cpp
@@ -107,11 +107,11 @@ void QtQuickControls2Plugin::registerTypes(const char *uri)
qmlRegisterUncreatableType<QQuickExclusiveAttached>(uri, 2, 0, "Exclusive", "Exclusive is an attached property");
qmlRegisterUncreatableType<QQuickStackAttached>(uri, 2, 0, "Stack", "Stack is an attached property");
+ qmlRegisterUncreatableType<QQuickStyle>(uri, 2, 0, "Style", "Style is an attached property");
qmlRegisterUncreatableType<QQuickTabAttached>(uri, 2, 0, "Tab", "Tab is an attached property");
qmlRegisterType<QQuickControl>(uri, 2, 0, "Control");
qmlRegisterType<QQuickExclusiveGroup>(uri, 2, 0, "ExclusiveGroup");
- qmlRegisterType<QQuickStyle>(uri, 2, 0, "Style");
qmlRegisterRevision<QQuickTextInput, 6>(uri, 2, 0);
qmlRegisterRevision<QQuickTextEdit, 6>(uri, 2, 0);
diff --git a/src/imports/controls/qtquickcontrols2plugin.qrc b/src/imports/controls/qtquickcontrols2plugin.qrc
index 544c42f5..76d81809 100644
--- a/src/imports/controls/qtquickcontrols2plugin.qrc
+++ b/src/imports/controls/qtquickcontrols2plugin.qrc
@@ -1,4 +1,7 @@
<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/qtquickcontrols">
+ <file>style.json</file>
+</qresource>
<qresource>
<file>images/spinner_small.png</file>
<file>images/spinner_medium.png</file>
diff --git a/src/imports/controls/style.json b/src/imports/controls/style.json
new file mode 100644
index 00000000..a1a79969
--- /dev/null
+++ b/src/imports/controls/style.json
@@ -0,0 +1,16 @@
+{
+ "accentColor": "#7bc258",
+ "backgroundColor": "#ffffff",
+ "baseColor": "#eeeeee",
+ "focusColor": "#45a7d7",
+ "frameColor": "#bdbebf",
+ "pressColor": "#33333333",
+ "selectedTextColor": "#ffffff",
+ "selectionColor": "#45a7d7",
+ "shadowColor": "#28282a",
+ "textColor": "#26282a",
+ "padding": 6,
+ "roundness": 3,
+ "disabledOpacity": 0.3,
+ "spacing": 6
+}