aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2015-03-06 11:52:10 +0100
committerJari-Pekka Nurmi <jpnurmi@theqtcompany.com>2015-03-11 01:06:44 +0200
commita3921bcf01275425350c9c153fe92086a34d1403 (patch)
tree1c5c4dd36e9d19a36281bde723c7bf989bc70298
parente9398b7465c7df38876d0c6528ea5c42bbd8bf6a (diff)
Implement Style as an attached property
Change-Id: I006ee566647e31d1a14919d164d7dd68539aae10 Reviewed-by: Jari-Pekka Nurmi <jpnurmi@theqtcompany.com>
-rw-r--r--examples/quick/calendar/main.qml12
-rw-r--r--examples/quick/controls/drawer/main.qml16
-rw-r--r--examples/quick/controls/mirroring/main.qml10
-rw-r--r--examples/quick/controls/styles/main.qml37
-rw-r--r--examples/quick/controls/tabs/main.qml62
-rw-r--r--src/controls/controls.pri8
-rw-r--r--src/controls/controls.pro6
-rw-r--r--src/controls/controls.qrc5
-rw-r--r--src/controls/qquickabstractapplicationwindow.cpp47
-rw-r--r--src/controls/qquickabstractapplicationwindow_p.h12
-rw-r--r--src/controls/qquickabstracttextarea.cpp71
-rw-r--r--src/controls/qquickabstracttextarea_p.h13
-rw-r--r--src/controls/qquickabstracttextfield.cpp71
-rw-r--r--src/controls/qquickabstracttextfield_p.h13
-rw-r--r--src/controls/qquickcontrol.cpp72
-rw-r--r--src/controls/qquickcontrol_p.h14
-rw-r--r--src/controls/qquickcontrol_p_p.h5
-rw-r--r--src/controls/qquickstylable_p.h73
-rw-r--r--src/controls/qquickstyle.cpp204
-rw-r--r--src/controls/qquickstyle_p.h122
-rw-r--r--src/controls/qquickstyle_p_p.h64
-rw-r--r--src/imports/calendar/CalendarView.qml4
-rw-r--r--src/imports/calendar/DayOfWeekRow.qml6
-rw-r--r--src/imports/calendar/WeekNumberColumn.qml6
-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.json (renamed from src/controls/style.json)0
-rw-r--r--src/imports/extras/Drawer.qml4
-rw-r--r--tests/auto/controls/data/tst_style.qml304
55 files changed, 1773 insertions, 1019 deletions
diff --git a/examples/quick/calendar/main.qml b/examples/quick/calendar/main.qml
index 759a081e..645b05dd 100644
--- a/examples/quick/calendar/main.qml
+++ b/examples/quick/calendar/main.qml
@@ -99,7 +99,7 @@ ApplicationWindow {
id: title
x: delegate.contentItem.x
width: delegate.contentItem.width
- spacing: window.style.spacing
+ spacing: Style.spacing
Text {
width: parent.width
height: implicitHeight * 2
@@ -129,7 +129,7 @@ ApplicationWindow {
width: delegate.contentItem.width / 7
height: delegate.contentItem.height / 6
opacity: model.month === delegate.month ? 1 : 0
- color: model.today ? window.style.accentColor : window.style.textColor
+ color: model.today ? Style.accentColor : Style.textColor
Rectangle {
z: -1
anchors.centerIn: parent
@@ -137,8 +137,8 @@ ApplicationWindow {
height: width
radius: width / 2
opacity: 0.5
- color: pressed ? window.style.pressColor : "transparent"
- border.color: eventModel.eventsForDate(model.date).length > 0 ? window.style.accentColor : "transparent"
+ color: pressed ? Style.pressColor : "transparent"
+ border.color: eventModel.eventsForDate(model.date).length > 0 ? Style.accentColor : "transparent"
}
}
}
@@ -146,7 +146,7 @@ ApplicationWindow {
z: -1
parent: calendar
anchors.fill: parent
- border.color: window.style.frameColor
+ border.color: Style.frameColor
}
}
@@ -185,7 +185,7 @@ ApplicationWindow {
Rectangle {
width: (parent.width > parent.height ? (parent.width - parent.spacing) * 0.4 : parent.width)
height: (parent.height > parent.width ? (parent.height - parent.spacing) * 0.4 : parent.height)
- border.color: window.style.frameColor
+ border.color: Style.frameColor
ListView {
id: eventsListView
diff --git a/examples/quick/controls/drawer/main.qml b/examples/quick/controls/drawer/main.qml
index df46577b..8ab67829 100644
--- a/examples/quick/controls/drawer/main.qml
+++ b/examples/quick/controls/drawer/main.qml
@@ -53,7 +53,7 @@ ApplicationWindow {
id: content
anchors.fill: parent
anchors.margins: -1
- border.color: window.style.frameColor
+ border.color: Style.frameColor
Image {
width: window.width / 2
@@ -98,13 +98,13 @@ ApplicationWindow {
model: VisualItemModel {
Label {
text: "Settings"
- x: window.style.padding
- width: parent.width - window.style.padding * 2
+ x: Style.padding
+ width: parent.width - Style.padding * 2
lineHeight: 2.0
- color: window.style.accentColor
+ color: Style.accentColor
verticalAlignment: Text.AlignVCenter
}
- Rectangle { width: parent.width; height: 1; color: window.style.frameColor }
+ Rectangle { width: parent.width; height: 1; color: Style.frameColor }
Switch {
id: dim
text: "Dim"
@@ -113,7 +113,7 @@ ApplicationWindow {
layoutDirection: Qt.RightToLeft
enabled: effect.current != uncover
}
- Rectangle { width: parent.width; height: 1; color: window.style.frameColor }
+ Rectangle { width: parent.width; height: 1; color: Style.frameColor }
RadioButton {
id: overlay
text: "Overlay"
@@ -136,14 +136,14 @@ ApplicationWindow {
Exclusive.group: effect
layoutDirection: Qt.RightToLeft
}
- Rectangle { width: parent.width; height: 1; color: window.style.frameColor }
+ Rectangle { width: parent.width; height: 1; color: Style.frameColor }
}
Rectangle {
z: -1
anchors.fill: parent
anchors.topMargin: -1
anchors.bottomMargin: -1
- border.color: window.style.frameColor
+ border.color: Style.frameColor
}
transform: Translate {
diff --git a/examples/quick/controls/mirroring/main.qml b/examples/quick/controls/mirroring/main.qml
index 8aeae85f..1bdf8cb2 100644
--- a/examples/quick/controls/mirroring/main.qml
+++ b/examples/quick/controls/mirroring/main.qml
@@ -67,7 +67,7 @@ ApplicationWindow {
Label {
id: label
text: "Beyond the essentials."
- color: window.style.accentColor
+ color: Style.accentColor
anchors.fill: parent
anchors.margins: 48
horizontalAlignment: Text.AlignHCenter
@@ -89,7 +89,7 @@ ApplicationWindow {
width: parent.width
height: 1
anchors.bottom: parent.bottom
- color: window.style.frameColor
+ color: Style.frameColor
}
}
@@ -157,7 +157,7 @@ ApplicationWindow {
width: flow.width
Row {
width: parent.width
- spacing: window.style.spacing
+ spacing: Style.spacing
readonly property real availableWidth: (flow.width - 12) / 2
readonly property real contentWidth: okButton.implicitWidth + cancelButton.implicitWidth + 12
readonly property real buttonWidth: contentWidth > availableWidth ? (width / 2 - spacing) : (width / 2 - 2 * spacing) / 2
@@ -196,7 +196,7 @@ ApplicationWindow {
width: flow.width
Column {
width: parent.width
- spacing: window.style.spacing
+ spacing: Style.spacing
ProgressBar {
width: parent.width
indeterminate: true
@@ -213,7 +213,7 @@ ApplicationWindow {
width: flow.width
Column {
width: parent.width
- spacing: window.style.spacing
+ spacing: Style.spacing
Slider {
id: slider
value: 0.4
diff --git a/examples/quick/controls/styles/main.qml b/examples/quick/controls/styles/main.qml
index 1d0dd20b..c614320d 100644
--- a/examples/quick/controls/styles/main.qml
+++ b/examples/quick/controls/styles/main.qml
@@ -52,7 +52,7 @@ ApplicationWindow {
ToolButton {
label: Text {
text: "\u25C0"
- color: enabled ? window.style.accentColor : window.style.frameColor
+ color: enabled ? Style.accentColor : Style.frameColor
anchors.centerIn: parent
}
enabled: stackview.depth > 1
@@ -70,18 +70,15 @@ ApplicationWindow {
id: pageComponent
Control {
id: page
- style: Style {
- padding: 6
- roundness: roundedToggle.checked ? 3 : 0
- accentColor: Qt.hsla(colorSlider.position, 0.5, 0.5, 1.0)
- backgroundColor: darkButton.checked ? "#444" : "#fff"
- frameColor: darkButton.checked ? "#666" : "#ccc"
- textColor: darkButton.checked ? "#eee" : "#111"
- pressColor: darkButton.checked ? "#33ffffff" : "#33333333"
- baseColor: darkButton.checked ? "#444" : "#eee"
- }
+ Style.roundness: roundedToggle.checked ? 3 : 0
+ Style.accentColor: Qt.hsla(colorSlider.position, 0.5, 0.5, 1.0)
+ Style.backgroundColor: darkButton.checked ? "#444" : "#fff"
+ Style.frameColor: darkButton.checked ? "#666" : "#ccc"
+ Style.textColor: darkButton.checked ? "#eee" : "#111"
+ Style.pressColor: darkButton.checked ? "#33ffffff" : "#33333333"
+ Style.baseColor: darkButton.checked ? "#444" : "#eee"
background: Rectangle {
- color: style.backgroundColor
+ color: Style.backgroundColor
}
Flickable {
anchors.fill: parent
@@ -97,7 +94,7 @@ ApplicationWindow {
Label {
text: "Code less. Create more."
- color: page.style.accentColor
+ color: Style.accentColor
width: parent.width
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
@@ -110,7 +107,7 @@ ApplicationWindow {
Rectangle {
width: parent.width
height: 1
- color: page.style.frameColor
+ color: Style.frameColor
}
Column {
@@ -118,20 +115,19 @@ ApplicationWindow {
width: parent.width
Label {
text: "Accent color"
- color: page.style.textColor
+ color: Style.textColor
}
Slider {
id: colorSlider
width: parent.width
value: 0.275
- //background: Rectangle { border.color: "red" }
}
}
Rectangle {
width: parent.width
height: 1
- color: page.style.frameColor
+ color: Style.frameColor
}
ExclusiveGroup {
@@ -148,7 +144,6 @@ ApplicationWindow {
checked: true
layoutDirection: Qt.RightToLeft
Exclusive.group: styleGroup
- //background: Rectangle { border.color: "red" }
}
RadioButton {
id: darkButton
@@ -156,14 +151,13 @@ ApplicationWindow {
width: parent.width
layoutDirection: Qt.RightToLeft
Exclusive.group: styleGroup
- //background: Rectangle { border.color: "red" }
}
}
Rectangle {
width: parent.width
height: 1
- color: page.style.frameColor
+ color: Style.frameColor
}
ToggleButton {
@@ -172,13 +166,12 @@ ApplicationWindow {
text: "Rounded corners"
layoutDirection: Qt.RightToLeft
checked: true
- //background: Rectangle { border.color: "red" }
}
Rectangle {
width: parent.width
height: 1
- color: page.style.frameColor
+ color: Style.frameColor
}
Button {
diff --git a/examples/quick/controls/tabs/main.qml b/examples/quick/controls/tabs/main.qml
index 48daaa51..42902298 100644
--- a/examples/quick/controls/tabs/main.qml
+++ b/examples/quick/controls/tabs/main.qml
@@ -55,7 +55,7 @@ ApplicationWindow {
spacing: 1
anchors.fill: parent
- background: Rectangle { color: style.frameColor }
+ background: Rectangle { color: Style.frameColor }
Rectangle {
Tab.title: "Home"
@@ -72,7 +72,7 @@ ApplicationWindow {
Label {
text: "Things just got better"
- color: window.style.accentColor
+ color: Style.accentColor
anchors.margins: 40
anchors.top: logo.bottom
anchors.left: parent.left
@@ -110,46 +110,46 @@ ApplicationWindow {
Column {
id: feedItem
width: parent.width
- spacing: window.style.spacing
+ spacing: Style.spacing
Rectangle {
width: parent.width
height: 1
- color: window.style.frameColor
+ color: Style.frameColor
visible: index == 0
}
- Item { width: 1; height: window.style.spacing }
+ Item { width: 1; height: Style.spacing }
Label {
text: model.title
- x: window.style.padding
- width: parent.width - 2 * window.style.padding
+ x: Style.padding
+ width: parent.width - 2 * Style.padding
elide: Text.ElideRight
- color: window.style.accentColor
+ color: Style.accentColor
font.pointSize: 20
lineHeight: 0.75
}
Label {
text: model.description
textFormat: Qt.RichText
- x: window.style.padding
- width: parent.width - 2 * window.style.padding
+ x: Style.padding
+ width: parent.width - 2 * Style.padding
wrapMode: Text.WordWrap
}
RowLayout {
- x: window.style.padding
- width: parent.width - 2 * window.style.padding
- spacing: window.style.spacing
+ x: Style.padding
+ width: parent.width - 2 * Style.padding
+ spacing: Style.spacing
Label {
text: model.creator
height: parent.height
verticalAlignment: Text.AlignVCenter
- color: window.style.focusColor
+ color: Style.focusColor
font.pointSize: 8
}
Label {
text: model.pubDate
height: parent.height
verticalAlignment: Text.AlignVCenter
- opacity: window.style.disabledOpacity
+ opacity: Style.disabledOpacity
font.pointSize: 8
}
Item { Layout.fillWidth: true }
@@ -161,7 +161,7 @@ ApplicationWindow {
Rectangle {
width: parent.width
height: 1
- color: window.style.frameColor
+ color: Style.frameColor
}
}
}
@@ -200,47 +200,47 @@ ApplicationWindow {
Column {
id: commentItem
width: parent.width
- spacing: window.style.spacing
+ spacing: Style.spacing
Rectangle {
width: parent.width
height: 1
- color: window.style.frameColor
+ color: Style.frameColor
visible: index == 0
}
- Item { width: 1; height: window.style.spacing }
+ Item { width: 1; height: Style.spacing }
Label {
text: model.title
- x: window.style.padding
- width: parent.width - 2 * window.style.padding
+ x: Style.padding
+ width: parent.width - 2 * Style.padding
elide: Text.ElideRight
- color: window.style.accentColor
+ color: Style.accentColor
font.pointSize: 14
lineHeight: 0.75
}
- Item { width: 1; height: window.style.spacing }
+ Item { width: 1; height: Style.spacing }
Label {
text: model.description
textFormat: Qt.RichText
- x: window.style.padding
- width: parent.width - 2 * window.style.padding
+ x: Style.padding
+ width: parent.width - 2 * Style.padding
wrapMode: Text.WordWrap
}
RowLayout {
- x: window.style.padding
- width: parent.width - 2 * window.style.padding
- spacing: window.style.spacing
+ x: Style.padding
+ width: parent.width - 2 * Style.padding
+ spacing: Style.spacing
Label {
text: model.creator
height: parent.height
verticalAlignment: Text.AlignVCenter
- color: window.style.focusColor
+ color: Style.focusColor
font.pointSize: 8
}
Label {
text: model.pubDate
height: parent.height
verticalAlignment: Text.AlignVCenter
- opacity: window.style.disabledOpacity
+ opacity: Style.disabledOpacity
font.pointSize: 8
}
Item { Layout.fillWidth: true }
@@ -252,7 +252,7 @@ ApplicationWindow {
Rectangle {
width: parent.width
height: 1
- color: window.style.frameColor
+ color: Style.frameColor
}
}
}
diff --git a/src/controls/controls.pri b/src/controls/controls.pri
index 189ed27e..0a2e647d 100644
--- a/src/controls/controls.pri
+++ b/src/controls/controls.pri
@@ -30,10 +30,7 @@ HEADERS += \
$$PWD/qquickabstracttoolbar_p.h \
$$PWD/qquickcontrol_p.h \
$$PWD/qquickcontrol_p_p.h \
- $$PWD/qquickexclusivegroup_p.h \
- $$PWD/qquickstylable_p.h \
- $$PWD/qquickstyle_p_p.h \
- $$PWD/qquickstyle_p.h
+ $$PWD/qquickexclusivegroup_p.h
SOURCES += \
$$PWD/qquickabstractapplicationwindow.cpp \
@@ -61,5 +58,4 @@ SOURCES += \
$$PWD/qquickabstracttogglebutton.cpp \
$$PWD/qquickabstracttoolbar.cpp \
$$PWD/qquickcontrol.cpp \
- $$PWD/qquickexclusivegroup.cpp \
- $$PWD/qquickstyle.cpp
+ $$PWD/qquickexclusivegroup.cpp
diff --git a/src/controls/controls.pro b/src/controls/controls.pro
index c4a1ff87..ae69b57b 100644
--- a/src/controls/controls.pro
+++ b/src/controls/controls.pro
@@ -12,11 +12,5 @@ QMAKE_DOCS = $$PWD/doc/qtquickcontrols2.qdocconf
HEADERS += \
$$PWD/qtquickcontrolsglobal_p.h
-OTHER_FILES += \
- $$PWD/style.json
-
-RESOURCES += \
- $$PWD/controls.qrc
-
include(controls.pri)
load(qt_module)
diff --git a/src/controls/controls.qrc b/src/controls/controls.qrc
deleted file mode 100644
index c1dded8a..00000000
--- a/src/controls/controls.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/qtquickcontrols">
- <file>style.json</file>
-</qresource>
-</RCC>
diff --git a/src/controls/qquickabstractapplicationwindow.cpp b/src/controls/qquickabstractapplicationwindow.cpp
index 1800e302..1ac37d7e 100644
--- a/src/controls/qquickabstractapplicationwindow.cpp
+++ b/src/controls/qquickabstractapplicationwindow.cpp
@@ -35,9 +35,7 @@
****************************************************************************/
#include "qquickabstractapplicationwindow_p.h"
-#include "qquickstyle_p.h"
-#include <QtCore/qcoreapplication.h>
#include <QtQuick/private/qquickitem_p.h>
#include <QtQuick/private/qquickitemchangelistener_p.h>
@@ -59,8 +57,7 @@ class QQuickAbstractApplicationWindowPrivate : public QQuickItemChangeListener
Q_DECLARE_PUBLIC(QQuickAbstractApplicationWindow)
public:
- QQuickAbstractApplicationWindowPrivate() : contentWidth(0), contentHeight(0),
- header(Q_NULLPTR), footer(Q_NULLPTR), hasStyle(false), style(Q_NULLPTR) { }
+ QQuickAbstractApplicationWindowPrivate() : contentWidth(0), contentHeight(0), header(Q_NULLPTR), footer(Q_NULLPTR) { }
void relayout();
@@ -71,8 +68,6 @@ public:
qreal contentHeight;
QQuickItem *header;
QQuickItem *footer;
- bool hasStyle;
- mutable QQuickStyle *style;
QQuickAbstractApplicationWindow *q_ptr;
};
@@ -176,46 +171,6 @@ void QQuickAbstractApplicationWindow::setFooter(QQuickItem *footer)
}
/*!
- \qmlproperty Style QtQuickControls2::ApplicationWindow::style
-
- TODO
-*/
-QQuickStyle *QQuickAbstractApplicationWindow::style() const
-{
- Q_D(const QQuickAbstractApplicationWindow);
- if (!d->style)
- d->style = QQuickStyle::instance(qmlEngine(this));
- return d->style;
-}
-
-void QQuickAbstractApplicationWindow::setStyle(QQuickStyle *style)
-{
- Q_D(QQuickAbstractApplicationWindow);
- if (d->style != style) {
- d->style = style;
- d->hasStyle = style;
- emit styleChanged();
-
- QEvent change(QEvent::StyleChange);
- foreach (QQuickItem *item, contentItem()->findChildren<QQuickItem *>()) {
- if (qobject_cast<QQuickStylable *>(item))
- QCoreApplication::sendEvent(item, &change);
- }
- }
-}
-
-bool QQuickAbstractApplicationWindow::hasStyle() const
-{
- Q_D(const QQuickAbstractApplicationWindow);
- return d->hasStyle;
-}
-
-void QQuickAbstractApplicationWindow::resetStyle()
-{
- setStyle(Q_NULLPTR);
-}
-
-/*!
\qmlproperty real QtQuickControls2::ApplicationWindow::contentWidth
TODO
diff --git a/src/controls/qquickabstractapplicationwindow_p.h b/src/controls/qquickabstractapplicationwindow_p.h
index 8438a278..4b378123 100644
--- a/src/controls/qquickabstractapplicationwindow_p.h
+++ b/src/controls/qquickabstractapplicationwindow_p.h
@@ -50,20 +50,16 @@
#include <QtQuick/private/qquickwindowmodule_p.h>
#include <QtQuickControls/private/qtquickcontrolsglobal_p.h>
-#include <QtQuickControls/private/qquickstylable_p.h>
QT_BEGIN_NAMESPACE
-class QQuickStyle;
class QQuickAbstractApplicationWindowPrivate;
-class Q_QUICKCONTROLS_EXPORT QQuickAbstractApplicationWindow : public QQuickWindowQmlImpl, public QQuickStylable
+class Q_QUICKCONTROLS_EXPORT QQuickAbstractApplicationWindow : public QQuickWindowQmlImpl
{
Q_OBJECT
- Q_INTERFACES(QQuickStylable)
Q_PROPERTY(QQuickItem *header READ header WRITE setHeader NOTIFY headerChanged FINAL)
Q_PROPERTY(QQuickItem *footer READ footer WRITE setFooter NOTIFY footerChanged FINAL)
- Q_PROPERTY(QQuickStyle *style READ style WRITE setStyle NOTIFY styleChanged FINAL)
Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth NOTIFY contentWidthChanged FINAL)
Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged FINAL)
@@ -77,11 +73,6 @@ public:
QQuickItem *footer() const;
void setFooter(QQuickItem *footer);
- QQuickStyle *style() const Q_DECL_OVERRIDE;
- void setStyle(QQuickStyle *style) Q_DECL_OVERRIDE;
- bool hasStyle() const Q_DECL_OVERRIDE;
- void resetStyle() Q_DECL_OVERRIDE;
-
qreal contentWidth() const;
void setContentWidth(qreal width);
@@ -91,7 +82,6 @@ public:
Q_SIGNALS:
void headerChanged();
void footerChanged();
- void styleChanged();
void contentWidthChanged();
void contentHeightChanged();
diff --git a/src/controls/qquickabstracttextarea.cpp b/src/controls/qquickabstracttextarea.cpp
index 0da6cdb1..8f4219d6 100644
--- a/src/controls/qquickabstracttextarea.cpp
+++ b/src/controls/qquickabstracttextarea.cpp
@@ -35,14 +35,10 @@
****************************************************************************/
#include "qquickabstracttextarea_p.h"
-#include "qquickabstractapplicationwindow_p.h"
-#include "qquickstyle_p_p.h"
-#include "qquickstyle_p.h"
#include <QtQuick/private/qquickitem_p.h>
#include <QtQuick/private/qquicktext_p.h>
#include <QtQuick/private/qquickclipnode_p.h>
-#include <QtCore/qcoreapplication.h>
QT_BEGIN_NAMESPACE
@@ -51,28 +47,13 @@ class QQuickAbstractTextAreaPrivate
Q_DECLARE_PUBLIC(QQuickAbstractTextArea)
public:
- QQuickAbstractTextAreaPrivate() : hasStyle(false), style(Q_NULLPTR),
- background(Q_NULLPTR), placeholder(Q_NULLPTR) { }
+ QQuickAbstractTextAreaPrivate() : background(Q_NULLPTR), placeholder(Q_NULLPTR) { }
- void resolveStyle(QQuickStyle *other = 0); // TODO
-
- bool hasStyle;
- QQuickStyle *style;
QQuickItem *background;
QQuickText *placeholder;
QQuickAbstractTextArea *q_ptr;
};
-void QQuickAbstractTextAreaPrivate::resolveStyle(QQuickStyle *res)
-{
- Q_Q(QQuickAbstractTextArea);
- res = QQuickStylePrivate::resolve(q, res);
- if (style != res) {
- style = res;
- emit q->styleChanged();
- }
-}
-
QQuickAbstractTextArea::QQuickAbstractTextArea(QQuickItem *parent) :
QQuickTextEdit(parent), d_ptr(new QQuickAbstractTextAreaPrivate)
{
@@ -84,40 +65,6 @@ QQuickAbstractTextArea::~QQuickAbstractTextArea()
{
}
-QQuickStyle *QQuickAbstractTextArea::style() const
-{
- Q_D(const QQuickAbstractTextArea);
- if (!d->style)
- const_cast<QQuickAbstractTextArea *>(this)->d_func()->resolveStyle();
- return d->style;
-}
-
-void QQuickAbstractTextArea::setStyle(QQuickStyle *style)
-{
- Q_D(QQuickAbstractTextArea);
- if (d->style != style) {
- d->hasStyle = true;
- d->resolveStyle(style);
-
- QEvent change(QEvent::StyleChange);
- foreach (QObject *object, findChildren<QObject *>()) {
- if (qobject_cast<QQuickStylable *>(object))
- QCoreApplication::sendEvent(object, &change);
- }
- }
-}
-
-bool QQuickAbstractTextArea::hasStyle() const
-{
- Q_D(const QQuickAbstractTextArea);
- return d->hasStyle;
-}
-
-void QQuickAbstractTextArea::resetStyle()
-{
- setStyle(Q_NULLPTR);
-}
-
QQuickItem *QQuickAbstractTextArea::background() const
{
Q_D(const QQuickAbstractTextArea);
@@ -157,22 +104,6 @@ void QQuickAbstractTextArea::setPlaceholder(QQuickText *placeholder)
}
}
-bool QQuickAbstractTextArea::event(QEvent *event)
-{
- Q_D(QQuickAbstractTextArea);
- if (event->type() == QEvent::StyleChange)
- d->resolveStyle();
- return QQuickTextEdit::event(event);
-}
-
-void QQuickAbstractTextArea::itemChange(ItemChange change, const ItemChangeData &data)
-{
- Q_D(QQuickAbstractTextArea);
- QQuickTextEdit::itemChange(change, data);
- if (change == ItemSceneChange || change == ItemParentHasChanged)
- d->resolveStyle();
-}
-
void QQuickAbstractTextArea::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
{
Q_D(QQuickAbstractTextArea);
diff --git a/src/controls/qquickabstracttextarea_p.h b/src/controls/qquickabstracttextarea_p.h
index e937a16a..24e76d29 100644
--- a/src/controls/qquickabstracttextarea_p.h
+++ b/src/controls/qquickabstracttextarea_p.h
@@ -50,18 +50,15 @@
#include <QtQuick/private/qquicktextedit_p.h>
#include <QtQuickControls/private/qtquickcontrolsglobal_p.h>
-#include <QtQuickControls/private/qquickstylable_p.h>
QT_BEGIN_NAMESPACE
class QQuickText;
class QQuickAbstractTextAreaPrivate;
-class Q_QUICKCONTROLS_EXPORT QQuickAbstractTextArea : public QQuickTextEdit, public QQuickStylable
+class Q_QUICKCONTROLS_EXPORT QQuickAbstractTextArea : public QQuickTextEdit
{
Q_OBJECT
- Q_INTERFACES(QQuickStylable)
- Q_PROPERTY(QQuickStyle *style READ style WRITE setStyle RESET resetStyle NOTIFY styleChanged FINAL)
Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL)
Q_PROPERTY(QQuickText *placeholder READ placeholder WRITE setPlaceholder NOTIFY placeholderChanged FINAL)
@@ -69,11 +66,6 @@ public:
explicit QQuickAbstractTextArea(QQuickItem *parent = Q_NULLPTR);
~QQuickAbstractTextArea();
- QQuickStyle *style() const;
- void setStyle(QQuickStyle *style);
- bool hasStyle() const;
- void resetStyle();
-
QQuickItem *background() const;
void setBackground(QQuickItem *background);
@@ -81,13 +73,10 @@ public:
void setPlaceholder(QQuickText *placeholder);
Q_SIGNALS:
- void styleChanged();
void backgroundChanged();
void placeholderChanged();
protected:
- bool event(QEvent *event) Q_DECL_OVERRIDE;
- void itemChange(ItemChange, const ItemChangeData &data) Q_DECL_OVERRIDE;
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) Q_DECL_OVERRIDE;
diff --git a/src/controls/qquickabstracttextfield.cpp b/src/controls/qquickabstracttextfield.cpp
index ced75544..82825ce4 100644
--- a/src/controls/qquickabstracttextfield.cpp
+++ b/src/controls/qquickabstracttextfield.cpp
@@ -35,14 +35,10 @@
****************************************************************************/
#include "qquickabstracttextfield_p.h"
-#include "qquickabstractapplicationwindow_p.h"
-#include "qquickstyle_p_p.h"
-#include "qquickstyle_p.h"
#include <QtQuick/private/qquickitem_p.h>
#include <QtQuick/private/qquicktext_p.h>
#include <QtQuick/private/qquickclipnode_p.h>
-#include <QtCore/qcoreapplication.h>
QT_BEGIN_NAMESPACE
@@ -51,28 +47,13 @@ class QQuickAbstractTextFieldPrivate
Q_DECLARE_PUBLIC(QQuickAbstractTextField)
public:
- QQuickAbstractTextFieldPrivate() : hasStyle(false), style(Q_NULLPTR),
- background(Q_NULLPTR), placeholder(Q_NULLPTR) { }
+ QQuickAbstractTextFieldPrivate() : background(Q_NULLPTR), placeholder(Q_NULLPTR) { }
- void resolveStyle(QQuickStyle *other = 0); // TODO
-
- bool hasStyle;
- QQuickStyle *style;
QQuickItem *background;
QQuickText *placeholder;
QQuickAbstractTextField *q_ptr;
};
-void QQuickAbstractTextFieldPrivate::resolveStyle(QQuickStyle *res)
-{
- Q_Q(QQuickAbstractTextField);
- res = QQuickStylePrivate::resolve(q, res);
- if (style != res) {
- style = res;
- emit q->styleChanged();
- }
-}
-
QQuickAbstractTextField::QQuickAbstractTextField(QQuickItem *parent) :
QQuickTextInput(parent), d_ptr(new QQuickAbstractTextFieldPrivate)
{
@@ -84,40 +65,6 @@ QQuickAbstractTextField::~QQuickAbstractTextField()
{
}
-QQuickStyle *QQuickAbstractTextField::style() const
-{
- Q_D(const QQuickAbstractTextField);
- if (!d->style)
- const_cast<QQuickAbstractTextField *>(this)->d_func()->resolveStyle();
- return d->style;
-}
-
-void QQuickAbstractTextField::setStyle(QQuickStyle *style)
-{
- Q_D(QQuickAbstractTextField);
- if (d->style != style) {
- d->hasStyle = true;
- d->resolveStyle(style);
-
- QEvent change(QEvent::StyleChange);
- foreach (QObject *object, findChildren<QObject *>()) {
- if (qobject_cast<QQuickStylable *>(object))
- QCoreApplication::sendEvent(object, &change);
- }
- }
-}
-
-bool QQuickAbstractTextField::hasStyle() const
-{
- Q_D(const QQuickAbstractTextField);
- return d->hasStyle;
-}
-
-void QQuickAbstractTextField::resetStyle()
-{
- setStyle(Q_NULLPTR);
-}
-
QQuickItem *QQuickAbstractTextField::background() const
{
Q_D(const QQuickAbstractTextField);
@@ -157,22 +104,6 @@ void QQuickAbstractTextField::setPlaceholder(QQuickText *placeholder)
}
}
-bool QQuickAbstractTextField::event(QEvent *event)
-{
- Q_D(QQuickAbstractTextField);
- if (event->type() == QEvent::StyleChange)
- d->resolveStyle();
- return QQuickTextInput::event(event);
-}
-
-void QQuickAbstractTextField::itemChange(ItemChange change, const ItemChangeData &data)
-{
- Q_D(QQuickAbstractTextField);
- QQuickTextInput::itemChange(change, data);
- if (change == ItemSceneChange || change == ItemParentHasChanged)
- d->resolveStyle();
-}
-
void QQuickAbstractTextField::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
{
Q_D(QQuickAbstractTextField);
diff --git a/src/controls/qquickabstracttextfield_p.h b/src/controls/qquickabstracttextfield_p.h
index e666fa9b..248c6a55 100644
--- a/src/controls/qquickabstracttextfield_p.h
+++ b/src/controls/qquickabstracttextfield_p.h
@@ -50,18 +50,15 @@
#include <QtQuick/private/qquicktextinput_p.h>
#include <QtQuickControls/private/qtquickcontrolsglobal_p.h>
-#include <QtQuickControls/private/qquickstylable_p.h>
QT_BEGIN_NAMESPACE
class QQuickText;
class QQuickAbstractTextFieldPrivate;
-class Q_QUICKCONTROLS_EXPORT QQuickAbstractTextField : public QQuickTextInput, public QQuickStylable
+class Q_QUICKCONTROLS_EXPORT QQuickAbstractTextField : public QQuickTextInput
{
Q_OBJECT
- Q_INTERFACES(QQuickStylable)
- Q_PROPERTY(QQuickStyle *style READ style WRITE setStyle RESET resetStyle NOTIFY styleChanged FINAL)
Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL)
Q_PROPERTY(QQuickText *placeholder READ placeholder WRITE setPlaceholder NOTIFY placeholderChanged FINAL)
@@ -69,11 +66,6 @@ public:
explicit QQuickAbstractTextField(QQuickItem *parent = Q_NULLPTR);
~QQuickAbstractTextField();
- QQuickStyle *style() const;
- void setStyle(QQuickStyle *style);
- bool hasStyle() const;
- void resetStyle();
-
QQuickItem *background() const;
void setBackground(QQuickItem *background);
@@ -81,13 +73,10 @@ public:
void setPlaceholder(QQuickText *placeholder);
Q_SIGNALS:
- void styleChanged();
void backgroundChanged();
void placeholderChanged();
protected:
- bool event(QEvent *event) Q_DECL_OVERRIDE;
- void itemChange(ItemChange, const ItemChangeData &data) Q_DECL_OVERRIDE;
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) Q_DECL_OVERRIDE;
diff --git a/src/controls/qquickcontrol.cpp b/src/controls/qquickcontrol.cpp
index 1d843597..61389ad6 100644
--- a/src/controls/qquickcontrol.cpp
+++ b/src/controls/qquickcontrol.cpp
@@ -36,9 +36,6 @@
#include "qquickcontrol_p.h"
#include "qquickcontrol_p_p.h"
-#include "qquickstyle_p_p.h"
-
-#include <QtCore/qcoreapplication.h>
QT_BEGIN_NAMESPACE
@@ -53,9 +50,9 @@ QT_BEGIN_NAMESPACE
*/
QQuickControlPrivate::QQuickControlPrivate() :
- hasStyle(false), hasTopPadding(false), hasLeftPadding(false), hasRightPadding(false), hasBottomPadding(false),
+ hasTopPadding(false), hasLeftPadding(false), hasRightPadding(false), hasBottomPadding(false),
padding(0), topPadding(0), leftPadding(0), rightPadding(0), bottomPadding(0),
- background(Q_NULLPTR), style(Q_NULLPTR)
+ background(Q_NULLPTR)
{
}
@@ -105,16 +102,6 @@ void QQuickControlPrivate::setBottomPadding(qreal value, bool reset)
emit q->bottomPaddingChanged();
}
-void QQuickControlPrivate::resolveStyle(QQuickStyle *res)
-{
- Q_Q(QQuickControl);
- res = QQuickStylePrivate::resolve(q, res);
- if (style != res) {
- style = res;
- emit q->styleChanged();
- }
-}
-
QQuickControl::QQuickControl(QQuickItem *parent) :
QQuickItem(*(new QQuickControlPrivate), parent)
{
@@ -268,61 +255,6 @@ void QQuickControl::setBackground(QQuickItem *background)
}
}
-/*!
- \qmlproperty Style QtQuickControls2::Control::style
-
- This property holds the style.
-*/
-QQuickStyle *QQuickControl::style() const
-{
- Q_D(const QQuickControl);
- if (!d->style)
- const_cast<QQuickControl *>(this)->d_func()->resolveStyle();
- return d->style;
-}
-
-void QQuickControl::setStyle(QQuickStyle *style)
-{
- Q_D(QQuickControl);
- if (d->style != style) {
- d->hasStyle = style;
- d->resolveStyle(style);
-
- QEvent change(QEvent::StyleChange);
- foreach (QQuickItem *item, findChildren<QQuickItem *>()) {
- if (qobject_cast<QQuickStylable *>(item))
- QCoreApplication::sendEvent(item, &change);
- }
- }
-}
-
-bool QQuickControl::hasStyle() const
-{
- Q_D(const QQuickControl);
- return d->hasStyle;
-}
-
-void QQuickControl::resetStyle()
-{
- setStyle(Q_NULLPTR);
-}
-
-bool QQuickControl::event(QEvent *event)
-{
- Q_D(QQuickControl);
- if (event->type() == QEvent::StyleChange)
- d->resolveStyle();
- return QQuickItem::event(event);
-}
-
-void QQuickControl::itemChange(ItemChange change, const ItemChangeData &data)
-{
- Q_D(QQuickControl);
- QQuickItem::itemChange(change, data);
- if (change == ItemSceneChange || change == ItemParentHasChanged)
- d->resolveStyle();
-}
-
void QQuickControl::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
{
Q_D(QQuickControl);
diff --git a/src/controls/qquickcontrol_p.h b/src/controls/qquickcontrol_p.h
index 3744700e..d0da80fe 100644
--- a/src/controls/qquickcontrol_p.h
+++ b/src/controls/qquickcontrol_p.h
@@ -50,24 +50,20 @@
#include <QtQuick/qquickitem.h>
#include <QtQuickControls/private/qtquickcontrolsglobal_p.h>
-#include <QtQuickControls/private/qquickstylable_p.h>
QT_BEGIN_NAMESPACE
-class QQuickStyle;
class QQuickControlPrivate;
-class Q_QUICKCONTROLS_EXPORT QQuickControl : public QQuickItem, public QQuickStylable
+class Q_QUICKCONTROLS_EXPORT QQuickControl : public QQuickItem
{
Q_OBJECT
- Q_INTERFACES(QQuickStylable)
Q_PROPERTY(qreal padding READ padding WRITE setPadding RESET resetPadding NOTIFY paddingChanged FINAL)
Q_PROPERTY(qreal topPadding READ topPadding WRITE setTopPadding RESET resetTopPadding NOTIFY topPaddingChanged FINAL)
Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding NOTIFY leftPaddingChanged FINAL)
Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding NOTIFY rightPaddingChanged FINAL)
Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged FINAL)
Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL)
- Q_PROPERTY(QQuickStyle *style READ style WRITE setStyle RESET resetStyle NOTIFY styleChanged FINAL)
public:
explicit QQuickControl(QQuickItem *parent = Q_NULLPTR);
@@ -95,11 +91,6 @@ public:
QQuickItem *background() const;
void setBackground(QQuickItem *background);
- QQuickStyle *style() const Q_DECL_OVERRIDE;
- void setStyle(QQuickStyle *style) Q_DECL_OVERRIDE;
- bool hasStyle() const Q_DECL_OVERRIDE;
- void resetStyle() Q_DECL_OVERRIDE;
-
Q_SIGNALS:
void paddingChanged();
void topPaddingChanged();
@@ -107,13 +98,10 @@ Q_SIGNALS:
void rightPaddingChanged();
void bottomPaddingChanged();
void backgroundChanged();
- void styleChanged();
protected:
QQuickControl(QQuickControlPrivate &dd, QQuickItem *parent);
- bool event(QEvent *event) Q_DECL_OVERRIDE;
- void itemChange(ItemChange, const ItemChangeData &data) Q_DECL_OVERRIDE;
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
bool isMirrored() const;
diff --git a/src/controls/qquickcontrol_p_p.h b/src/controls/qquickcontrol_p_p.h
index afd05385..4a3cf8af 100644
--- a/src/controls/qquickcontrol_p_p.h
+++ b/src/controls/qquickcontrol_p_p.h
@@ -49,7 +49,6 @@
//
#include <QtQuick/private/qquickitem_p.h>
-#include <QtQuickControls/private/qquickstyle_p.h>
QT_BEGIN_NAMESPACE
@@ -67,9 +66,6 @@ public:
void setRightPadding(qreal value, bool reset = false);
void setBottomPadding(qreal value, bool reset = false);
- void resolveStyle(QQuickStyle *other = 0);
-
- bool hasStyle;
bool hasTopPadding;
bool hasLeftPadding;
bool hasRightPadding;
@@ -80,7 +76,6 @@ public:
qreal rightPadding;
qreal bottomPadding;
QQuickItem *background;
- QQuickStyle *style;
};
QT_END_NAMESPACE
diff --git a/src/controls/qquickstylable_p.h b/src/controls/qquickstylable_p.h
deleted file mode 100644
index d3a72882..00000000
--- a/src/controls/qquickstylable_p.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** 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 QQUICKSTYLABLE_P_H
-#define QQUICKSTYLABLE_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 <QtCore/qobject.h>
-#include <QtQuickControls/private/qtquickcontrolsglobal_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QQuickStyle;
-
-class Q_QUICKCONTROLS_EXPORT QQuickStylable
-{
-public:
- virtual ~QQuickStylable() { }
-
- virtual QQuickStyle *style() const = 0;
- virtual void setStyle(QQuickStyle *style) = 0;
- virtual bool hasStyle() const = 0;
- virtual void resetStyle() = 0;
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_INTERFACE(QQuickStylable, "io.qt.QQuickStylable")
-
-#endif // QQUICKSTYLABLE_P_H
diff --git a/src/controls/qquickstyle.cpp b/src/controls/qquickstyle.cpp
deleted file mode 100644
index 8b3612c6..00000000
--- a/src/controls/qquickstyle.cpp
+++ /dev/null
@@ -1,204 +0,0 @@
-/****************************************************************************
-**
-** 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 "qquickstyle_p_p.h"
-#include "qquickstylable_p.h"
-
-#include <QtCore/qfile.h>
-#include <QtCore/qjsondocument.h>
-#include <QtCore/qjsonobject.h>
-#include <QtCore/qjsonvalue.h>
-#include <QtCore/qdebug.h>
-#include <QtQml/qqmlengine.h>
-#include <QtQuick/qquickitem.h>
-#include <QtQuick/qquickwindow.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmltype Style
- \inherits QtObject
- \instantiates QQuickStyle
- \inqmlmodule QtQuick.Controls
- \ingroup utilities
- \brief A style interface.
-
- TODO
-*/
-
-/*!
- \qmlproperty color QtQuickControls2::Style::accentColor
-*/
-
-/*!
- \qmlproperty color QtQuickControls2::Style::backgroundColor
-*/
-
-/*!
- \qmlproperty color QtQuickControls2::Style::focusColor
-*/
-
-/*!
- \qmlproperty color QtQuickControls2::Style::frameColor
-*/
-
-/*!
- \qmlproperty color QtQuickControls2::Style::pressColor
-*/
-
-/*!
- \qmlproperty color QtQuickControls2::Style::selectedTextColor
-*/
-
-/*!
- \qmlproperty color QtQuickControls2::Style::selectionColor
-*/
-
-/*!
- \qmlproperty color QtQuickControls2::Style::shadowColor
-*/
-
-/*!
- \qmlproperty color QtQuickControls2::Style::textColor
-*/
-
-/*!
- \qmlproperty int QtQuickControls2::Style::padding
-*/
-
-/*!
- \qmlproperty int QtQuickControls2::Style::roundness
-*/
-
-/*!
- \qmlproperty int QtQuickControls2::Style::spacing
-*/
-
-/*!
- \qmlproperty real QtQuickControls2::Style::disabledOpacity
-*/
-
-QQuickStyle *QQuickStylePrivate::resolve(QQuickItem *item, QQuickStyle *res)
-{
- QQuickStylable *stylable = qobject_cast<QQuickStylable *>(item);
- Q_ASSERT(stylable);
-
- if (!res && stylable->hasStyle())
- return stylable->style();
-
- // lookup parent style
- if (!res) {
- QQuickItem *parent = item->parentItem();
- while (!res && parent) {
- QQuickStylable *stylable = qobject_cast<QQuickStylable *>(parent);
- if (stylable && stylable->hasStyle())
- res = stylable->style();
- parent = parent->parentItem();
- }
- }
-
- // fallback to window or global style
- if (!res) {
- QQuickStylable *window = qobject_cast<QQuickStylable *>(item->window());
- if (window)
- res = window->style();
- if (!res)
- res = QQuickStyle::instance(qmlEngine(item));
- }
-
- return res;
-}
-
-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);
-}
-
-QQuickStyle::QQuickStyle(QObject *parent) : QObject(parent)
-{
- QJsonDocument doc;
-
- QFile file(QStringLiteral(":/qtquickcontrols/style.json"));
- if (!file.open(QFile::ReadOnly | QFile::Text)) {
- qDebug() << file.error();
- qWarning() << "QQuickStyle: failed to open ':/qtquickcontrols/style.json': " << qPrintable(file.errorString());
- } 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());
- }
-
- QJsonObject style = doc.object();
- accentColor = readColorValue(style.value(QStringLiteral("accentColor")), QColor("#7bc258"));
- backgroundColor = readColorValue(style.value(QStringLiteral("backgroundColor")), QColor("#ffffff"));
- baseColor = readColorValue(style.value(QStringLiteral("baseColor")), QColor("#eeeeee"));
- focusColor = readColorValue(style.value(QStringLiteral("focusColor")), QColor("#45a7d7"));
- frameColor = readColorValue(style.value(QStringLiteral("frameColor")), QColor("#bdbebf"));
- pressColor = readColorValue(style.value(QStringLiteral("pressColor")), QColor("#33333333"));
- selectedTextColor = readColorValue(style.value(QStringLiteral("selectedTextColor")), QColor("#ffffff"));
- selectionColor = readColorValue(style.value(QStringLiteral("selectionColor")), QColor("#45a7d7"));
- shadowColor = readColorValue(style.value(QStringLiteral("shadowColor")), QColor("#28282a"));
- textColor = readColorValue(style.value(QStringLiteral("textColor")), QColor("#26282a"));
- padding = readNumberValue(style.value(QStringLiteral("padding")), 6);
- roundness = readNumberValue(style.value(QStringLiteral("roundness")), 3);
- spacing = readNumberValue(style.value(QStringLiteral("spacing")), 6);
- disabledOpacity = readNumberValue(style.value(QStringLiteral("disabledOpacity")), 0.3);
-}
-
-QQuickStyle *QQuickStyle::instance(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(engine));
- return it.value();
-}
-
-QQuickStyle *QQuickStyle::qmlAttachedProperties(QObject *object)
-{
- return instance(qmlEngine(object));
-}
-
-QT_END_NAMESPACE
diff --git a/src/controls/qquickstyle_p.h b/src/controls/qquickstyle_p.h
deleted file mode 100644
index 4b04ddac..00000000
--- a/src/controls/qquickstyle_p.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/****************************************************************************
-**
-** 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 <QtCore/qobject.h>
-#include <QtGui/qcolor.h>
-#include <QtQuickControls/private/qtquickcontrolsglobal_p.h>
-#include <QtQml/qqml.h>
-
-QT_BEGIN_NAMESPACE
-
-class QQmlEngine;
-class QJSEngine;
-
-class Q_QUICKCONTROLS_EXPORT QQuickStyle : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QColor accentColor MEMBER accentColor NOTIFY accentColorChanged FINAL)
- Q_PROPERTY(QColor backgroundColor MEMBER backgroundColor NOTIFY backgroundColorChanged FINAL)
- Q_PROPERTY(QColor baseColor MEMBER baseColor NOTIFY baseColorChanged FINAL)
- Q_PROPERTY(QColor focusColor MEMBER focusColor NOTIFY focusColorChanged FINAL)
- Q_PROPERTY(QColor frameColor MEMBER frameColor NOTIFY frameColorChanged FINAL)
- Q_PROPERTY(QColor pressColor MEMBER pressColor NOTIFY pressColorChanged FINAL)
- Q_PROPERTY(QColor selectedTextColor MEMBER selectedTextColor NOTIFY selectedTextColorChanged FINAL)
- Q_PROPERTY(QColor selectionColor MEMBER selectionColor NOTIFY selectionColorChanged FINAL)
- Q_PROPERTY(QColor shadowColor MEMBER shadowColor NOTIFY shadowColorChanged FINAL)
- Q_PROPERTY(QColor textColor MEMBER textColor NOTIFY textColorChanged FINAL)
- Q_PROPERTY(int padding MEMBER padding NOTIFY paddingChanged FINAL)
- Q_PROPERTY(int roundness MEMBER roundness NOTIFY roundnessChanged FINAL)
- Q_PROPERTY(int spacing MEMBER spacing NOTIFY spacingChanged FINAL)
- Q_PROPERTY(qreal disabledOpacity MEMBER disabledOpacity NOTIFY disabledOpacityChanged FINAL)
-
-public:
- explicit QQuickStyle(QObject *parent = Q_NULLPTR);
-
- static QQuickStyle *instance(QQmlEngine *engine);
- static QQuickStyle *qmlAttachedProperties(QObject *object);
-
-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:
- 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;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPEINFO(QQuickStyle, QML_HAS_ATTACHED_PROPERTIES)
-
-#endif // QQUICKSTYLE_P_H
diff --git a/src/controls/qquickstyle_p_p.h b/src/controls/qquickstyle_p_p.h
deleted file mode 100644
index 276ce6aa..00000000
--- a/src/controls/qquickstyle_p_p.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** 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_P_H
-#define QQUICKSTYLE_P_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.
-//
-
-QT_BEGIN_NAMESPACE
-
-class QQuickItem;
-class QQuickStylable;
-
-class QQuickStylePrivate
-{
-public:
- static QQuickStyle *resolve(QQuickItem *item, QQuickStyle *other = 0);
-};
-
-QT_END_NAMESPACE
-
-#endif // QQUICKSTYLE_P_P_H
diff --git a/src/imports/calendar/CalendarView.qml b/src/imports/calendar/CalendarView.qml
index 3dfe5074..541c7d6b 100644
--- a/src/imports/calendar/CalendarView.qml
+++ b/src/imports/calendar/CalendarView.qml
@@ -45,9 +45,9 @@ AbstractCalendarView {
width: grid.width ? grid.width / 7 : implicitWidth
height: grid.height ? grid.height / 6 : implicitHeight
opacity: model.month === control.month ? 1 : 0
- color: model.today ? style.accentColor : style.textColor
+ color: model.today ? control.Style.accentColor : control.Style.textColor
text: model.day
- padding: style.padding
+ padding: control.Style.padding
}
contentWidth: grid.implicitWidth
diff --git a/src/imports/calendar/DayOfWeekRow.qml b/src/imports/calendar/DayOfWeekRow.qml
index 6c03ddd6..ef59ec5f 100644
--- a/src/imports/calendar/DayOfWeekRow.qml
+++ b/src/imports/calendar/DayOfWeekRow.qml
@@ -44,7 +44,7 @@ AbstractDayOfWeekRow {
property Component delegate: Text {
text: model.shortName
font.bold: true
- color: control.style.textColor
+ color: control.Style.textColor
width: row.width ? row.width / 7 : implicitWidth
height: row.height ? row.height : implicitHeight
horizontalAlignment: Text.AlignHCenter
@@ -57,8 +57,8 @@ AbstractDayOfWeekRow {
implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + topPadding + bottomPadding)
- topPadding: style.padding
- bottomPadding: style.padding
+ topPadding: Style.padding
+ bottomPadding: Style.padding
contentItem: Row {
id: row
diff --git a/src/imports/calendar/WeekNumberColumn.qml b/src/imports/calendar/WeekNumberColumn.qml
index 15037be1..732a914a 100644
--- a/src/imports/calendar/WeekNumberColumn.qml
+++ b/src/imports/calendar/WeekNumberColumn.qml
@@ -44,7 +44,7 @@ AbstractWeekNumberColumn {
property Component delegate: Text {
text: model.weekNumber
font.bold: true
- color: control.style.textColor
+ color: control.Style.textColor
width: column.width ? column.width : implicitWidth
height: column.height ? column.height / 6 : implicitHeight
horizontalAlignment: Text.AlignHCenter
@@ -57,8 +57,8 @@ AbstractWeekNumberColumn {
implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + topPadding + bottomPadding)
- leftPadding: style.padding
- rightPadding: style.padding
+ leftPadding: Style.padding
+ rightPadding: Style.padding
contentItem: Column {
id: column
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/controls/style.json b/src/imports/controls/style.json
index a1a79969..a1a79969 100644
--- a/src/controls/style.json
+++ b/src/imports/controls/style.json
diff --git a/src/imports/extras/Drawer.qml b/src/imports/extras/Drawer.qml
index 831c18d8..b1347142 100644
--- a/src/imports/extras/Drawer.qml
+++ b/src/imports/extras/Drawer.qml
@@ -45,8 +45,8 @@ AbstractDrawer {
height: parent.height // TODO: Window.height
background: Rectangle {
- color: style.shadowColor
- opacity: position * style.disabledOpacity
+ color: control.Style.shadowColor
+ opacity: position * control.Style.disabledOpacity
}
// TODO: make this a proper transition
diff --git a/tests/auto/controls/data/tst_style.qml b/tests/auto/controls/data/tst_style.qml
new file mode 100644
index 00000000..b6a6deec
--- /dev/null
+++ b/tests/auto/controls/data/tst_style.qml
@@ -0,0 +1,304 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtQuick.Window 2.2
+import QtTest 1.0
+import QtQuick.Controls 2.0
+
+TestCase {
+ id: testCase
+ width: 200
+ height: 200
+ visible: true
+ when: windowShown
+ name: "Style"
+
+ Component {
+ id: button
+ Button { }
+ }
+
+ Component {
+ id: styledButton
+ Button {
+ Style.accentColor: "#111111"
+ Style.backgroundColor: "#222222"
+ Style.baseColor: "#333333"
+ Style.focusColor: "#444444"
+ Style.frameColor: "#555555"
+ Style.pressColor: "#666666"
+ Style.selectedTextColor: "#777777"
+ Style.selectionColor: "#888888"
+ Style.textColor: "#999999"
+ Style.padding: 111
+ Style.roundness: 222
+ Style.spacing: 333
+ Style.disabledOpacity: 0.123
+ }
+ }
+
+ Component {
+ id: window
+ Window { }
+ }
+
+ Component {
+ id: styledWindow
+ Window {
+ Style.accentColor: "#111111"
+ Style.backgroundColor: "#222222"
+ Style.baseColor: "#333333"
+ Style.focusColor: "#444444"
+ Style.frameColor: "#555555"
+ Style.pressColor: "#666666"
+ Style.selectedTextColor: "#777777"
+ Style.selectionColor: "#888888"
+ Style.textColor: "#999999"
+ Style.padding: 111
+ Style.roundness: 222
+ Style.spacing: 333
+ Style.disabledOpacity: 0.123
+ }
+ }
+
+ Component {
+ id: loader
+ Loader {
+ active: false
+ sourceComponent: Button { }
+ }
+ }
+
+ function test_defaults() {
+ var control = button.createObject(testCase)
+ verify(control)
+ verify(control.Style)
+ verify(control.Style.accentColor !== undefined)
+ verify(control.Style.backgroundColor !== undefined)
+ verify(control.Style.baseColor !== undefined)
+ verify(control.Style.focusColor !== undefined)
+ verify(control.Style.frameColor !== undefined)
+ verify(control.Style.pressColor !== undefined)
+ verify(control.Style.selectedTextColor !== undefined)
+ verify(control.Style.selectionColor !== undefined)
+ verify(control.Style.textColor !== undefined)
+ verify(control.Style.padding !== undefined)
+ verify(control.Style.roundness !== undefined)
+ verify(control.Style.spacing !== undefined)
+ verify(control.Style.disabledOpacity !== undefined)
+ control.destroy()
+ }
+
+ function test_set() {
+ var control = button.createObject(testCase)
+ verify(control)
+ control.Style.accentColor = "#111111"
+ control.Style.backgroundColor = "#222222"
+ control.Style.baseColor = "#333333"
+ control.Style.focusColor = "#444444"
+ control.Style.frameColor = "#555555"
+ control.Style.pressColor = "#666666"
+ control.Style.selectedTextColor = "#777777"
+ control.Style.selectionColor = "#888888"
+ control.Style.textColor = "#999999"
+ control.Style.padding = 111
+ control.Style.roundness = 222
+ control.Style.spacing = 333
+ control.Style.disabledOpacity = 0.123
+ compare(control.Style.accentColor, "#111111")
+ compare(control.Style.backgroundColor, "#222222")
+ compare(control.Style.baseColor, "#333333")
+ compare(control.Style.focusColor, "#444444")
+ compare(control.Style.frameColor, "#555555")
+ compare(control.Style.pressColor, "#666666")
+ compare(control.Style.selectedTextColor, "#777777")
+ compare(control.Style.selectionColor, "#888888")
+ compare(control.Style.textColor, "#999999")
+ compare(control.Style.padding, 111)
+ compare(control.Style.roundness, 222)
+ compare(control.Style.spacing, 333)
+ compare(control.Style.disabledOpacity, 0.123)
+ control.destroy()
+ }
+
+ function test_reset() {
+ var control = styledButton.createObject(testCase)
+ verify(control)
+ compare(control.Style.accentColor, "#111111")
+ compare(control.Style.backgroundColor, "#222222")
+ compare(control.Style.baseColor, "#333333")
+ compare(control.Style.focusColor, "#444444")
+ compare(control.Style.frameColor, "#555555")
+ compare(control.Style.pressColor, "#666666")
+ compare(control.Style.selectedTextColor, "#777777")
+ compare(control.Style.selectionColor, "#888888")
+ compare(control.Style.textColor, "#999999")
+ compare(control.Style.padding, 111)
+ compare(control.Style.roundness, 222)
+ compare(control.Style.spacing, 333)
+ compare(control.Style.disabledOpacity, 0.123)
+ control.Style.accentColor = undefined
+ control.Style.backgroundColor = undefined
+ control.Style.baseColor = undefined
+ control.Style.focusColor = undefined
+ control.Style.frameColor = undefined
+ control.Style.pressColor = undefined
+ control.Style.selectedTextColor = undefined
+ control.Style.selectionColor = undefined
+ control.Style.textColor = undefined
+ control.Style.padding = undefined
+ control.Style.roundness = undefined
+ control.Style.spacing = undefined
+ control.Style.disabledOpacity = undefined
+ compare(control.Style.accentColor, testCase.Style.accentColor)
+ compare(control.Style.backgroundColor, testCase.Style.backgroundColor)
+ compare(control.Style.baseColor, testCase.Style.baseColor)
+ compare(control.Style.focusColor, testCase.Style.focusColor)
+ compare(control.Style.frameColor, testCase.Style.frameColor)
+ compare(control.Style.pressColor, testCase.Style.pressColor)
+ compare(control.Style.selectedTextColor, testCase.Style.selectedTextColor)
+ compare(control.Style.selectionColor, testCase.Style.selectionColor)
+ compare(control.Style.textColor, testCase.Style.textColor)
+ compare(control.Style.padding, testCase.Style.padding)
+ compare(control.Style.roundness, testCase.Style.roundness)
+ compare(control.Style.spacing, testCase.Style.spacing)
+ compare(control.Style.disabledOpacity, testCase.Style.disabledOpacity)
+ control.destroy()
+ }
+
+ function test_inheritance_data() {
+ return [
+ { tag: "accentColor", value1: "#111111", value2: "#101010" },
+ { tag: "backgroundColor", value1: "#222222", value2: "#202020" },
+ { tag: "baseColor", value1: "#333333", value2: "#303030" },
+ { tag: "focusColor", value1: "#444444", value2: "#404040" },
+ { tag: "frameColor", value1: "#555555", value2: "#505050" },
+ { tag: "pressColor", value1: "#666666", value2: "#606060" },
+ { tag: "selectedTextColor", value1: "#777777", value2: "#707070" },
+ { tag: "selectionColor", value1: "#888888", value2: "#808080" },
+ { tag: "textColor", value1: "#999999", value2: "#909090" },
+ { tag: "padding", value1: 11, value2: 10 },
+ { tag: "roundness", value1: 22, value2: 20 },
+ { tag: "spacing", value1: 33, value2: 30 },
+ { tag: "disabledOpacity", value1: 0.123, value2: 0.345 }
+ ]
+ }
+
+ function test_inheritance(data) {
+ var prop = data.tag
+ var parent = button.createObject(testCase)
+ parent.Style[prop] = data.value1
+ compare(parent.Style[prop], data.value1)
+
+ var child1 = button.createObject(parent)
+ compare(child1.Style[prop], data.value1)
+
+ parent.Style[prop] = data.value2
+ compare(parent.Style[prop], data.value2)
+ compare(child1.Style[prop], data.value2)
+
+ var child2 = button.createObject(parent)
+ compare(child2.Style[prop], data.value2)
+
+ child2.Style[prop] = data.value1
+ compare(child2.Style[prop], data.value1)
+ compare(child1.Style[prop], data.value2)
+ compare(parent.Style[prop], data.value2)
+
+ parent.Style[prop] = undefined
+ verify(parent.Style[prop] !== data.value1)
+ verify(parent.Style[prop] !== data.value2)
+ verify(parent.Style[prop] !== undefined)
+ compare(child1.Style[prop], parent.Style[prop])
+ verify(child2.Style[prop] !== parent.Style[prop])
+
+ var grandChild1 = button.createObject(child1)
+ var grandChild2 = button.createObject(child2)
+ compare(grandChild1.Style[prop], child1.Style[prop])
+ compare(grandChild2.Style[prop], child2.Style[prop])
+
+ var stylelessGrandGrandChild = button.createObject(grandChild1)
+ var grandGrandGrandChild1 = button.createObject(stylelessGrandGrandChild)
+ compare(grandGrandGrandChild1.Style[prop], parent.Style[prop])
+
+ child1.Style[prop] = data.value2
+ verify(parent.Style[prop] !== data.value2)
+ compare(child1.Style[prop], data.value2)
+ compare(grandChild1.Style[prop], data.value2)
+ compare(grandGrandGrandChild1.Style[prop], data.value2)
+
+ parent.destroy()
+ }
+
+ function test_window() {
+ var parent = window.createObject()
+
+ var control = button.createObject(parent.contentItem)
+ compare(control.Style.backgroundColor, parent.Style.backgroundColor)
+
+ var styledChild = styledWindow.createObject(window)
+ verify(styledChild.Style.backgroundColor !== parent.Style.backgroundColor)
+
+ var unstyledChild = window.createObject(window)
+ compare(unstyledChild.Style.backgroundColor, parent.Style.backgroundColor)
+
+ parent.Style.backgroundColor = "#123456"
+ compare(control.Style.backgroundColor, "#123456")
+ verify(styledChild.Style.backgroundColor !== "#123456")
+ // ### FIXME: compare(unstyledChild.Style.backgroundColor, "#123456")
+
+ parent.destroy()
+ }
+
+ function test_loader() {
+ var control = loader.createObject(testCase)
+ control.Style.accentColor = "#111111"
+ control.active = true
+ compare(control.item.Style.accentColor, "#111111")
+ control.Style.accentColor = "#222222"
+ compare(control.item.Style.accentColor, "#222222")
+ control.active = false
+ control.Style.accentColor = "#333333"
+ control.active = true
+ compare(control.item.Style.accentColor, "#333333")
+ control.destroy()
+ }
+}