diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-07-02 12:27:53 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-07-06 10:41:09 +0000 |
commit | 36c40a1cebe522e2655ab05d4e461eddbed364c7 (patch) | |
tree | b8d714cd20904933384e04a1209790c2a8625d18 /src | |
parent | 44cb549108913757277bd266c64aac9b2f6e6e8e (diff) |
Remove non-color properties from Theme
Better start with a minimal set. It will be also easier to transition
from Theme to Palette if it gets done.
Change-Id: Ic9951ac5b913f99a84e2b8efb9ae7f8d61177aee
Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
Diffstat (limited to 'src')
22 files changed, 40 insertions, 204 deletions
diff --git a/src/imports/calendar/CalendarView.qml b/src/imports/calendar/CalendarView.qml index 9a6c8d1e..7fd1ee0f 100644 --- a/src/imports/calendar/CalendarView.qml +++ b/src/imports/calendar/CalendarView.qml @@ -59,7 +59,7 @@ AbstractCalendarView { opacity: model.month === control.month ? 1 : 0 color: model.today ? control.Theme.accentColor : control.Theme.textColor text: model.day - padding: control.Theme.padding + padding: control.padding } //! [delegate] diff --git a/src/imports/calendar/DayOfWeekRow.qml b/src/imports/calendar/DayOfWeekRow.qml index 08532527..581071b1 100644 --- a/src/imports/calendar/DayOfWeekRow.qml +++ b/src/imports/calendar/DayOfWeekRow.qml @@ -46,8 +46,8 @@ AbstractDayOfWeekRow { implicitHeight: Math.max(background ? background.implicitHeight : 0, contentItem.implicitHeight + topPadding + bottomPadding) - topPadding: Theme.padding - bottomPadding: Theme.padding + topPadding: 6 + bottomPadding: 6 //! [delegate] delegate: Text { diff --git a/src/imports/calendar/WeekNumberColumn.qml b/src/imports/calendar/WeekNumberColumn.qml index 8c0e75fa..221b9d71 100644 --- a/src/imports/calendar/WeekNumberColumn.qml +++ b/src/imports/calendar/WeekNumberColumn.qml @@ -46,8 +46,8 @@ AbstractWeekNumberColumn { implicitHeight: Math.max(background ? background.implicitHeight : 0, contentItem.implicitHeight + topPadding + bottomPadding) - leftPadding: Theme.padding - rightPadding: Theme.padding + leftPadding: 6 + rightPadding: 6 //! [delegate] delegate: Text { diff --git a/src/imports/controls/BusyIndicator.qml b/src/imports/controls/BusyIndicator.qml index 3c37a27f..f67728c5 100644 --- a/src/imports/controls/BusyIndicator.qml +++ b/src/imports/controls/BusyIndicator.qml @@ -45,7 +45,7 @@ AbstractBusyIndicator { Accessible.role: Accessible.Indicator - padding: Theme.padding + padding: 6 //! [indicator] indicator: Item { diff --git a/src/imports/controls/Button.qml b/src/imports/controls/Button.qml index 899b3d3c..d46ecf22 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: Theme.padding + padding: 6 //! [label] label: Text { @@ -71,7 +71,7 @@ AbstractButton { implicitWidth: 26 implicitHeight: 26 - radius: control.Theme.roundness + radius: 3 color: Qt.tint(!control.enabled ? control.Theme.disabledColor : control.activeFocus ? control.Theme.focusColor : control.Theme.accentColor, control.pressed ? control.Theme.pressColor : "transparent") diff --git a/src/imports/controls/CheckBox.qml b/src/imports/controls/CheckBox.qml index 833a720f..9db6aaa4 100644 --- a/src/imports/controls/CheckBox.qml +++ b/src/imports/controls/CheckBox.qml @@ -53,8 +53,8 @@ AbstractCheckBox { Accessible.pressed: pressed Accessible.role: Accessible.CheckBox - padding: Theme.padding - spacing: Theme.spacing + padding: 6 + spacing: 6 //! [indicator] indicator: Rectangle { @@ -63,7 +63,7 @@ AbstractCheckBox { x: text ? (control.mirrored ? parent.width - width - control.rightPadding : control.leftPadding) : (parent.width - width) / 2 y: (parent.height - height) / 2 - radius: control.Theme.roundness + radius: 3 border.width: control.activeFocus ? 2 : 1 border.color: control.activeFocus ? control.Theme.focusColor : control.Theme.frameColor color: control.Theme.backgroundColor diff --git a/src/imports/controls/Frame.qml b/src/imports/controls/Frame.qml index 9e016b40..be5fc29f 100644 --- a/src/imports/controls/Frame.qml +++ b/src/imports/controls/Frame.qml @@ -46,7 +46,7 @@ AbstractFrame { contentWidth: contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0 contentHeight: contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0 - padding: Theme.padding + padding: 6 //! [contentItem] contentItem: Item { } @@ -57,8 +57,8 @@ AbstractFrame { width: parent.width height: parent.height + radius: 3 color: "transparent" - radius: control.Theme.roundness border.color: control.Theme.frameColor } //! [frame] diff --git a/src/imports/controls/GroupBox.qml b/src/imports/controls/GroupBox.qml index 7a625a81..94cc528d 100644 --- a/src/imports/controls/GroupBox.qml +++ b/src/imports/controls/GroupBox.qml @@ -46,9 +46,9 @@ AbstractGroupBox { contentWidth: contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0 contentHeight: contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0 - spacing: Theme.spacing - padding: Theme.padding - topPadding: Theme.padding + (label && title ? label.implicitHeight + spacing : 0) + spacing: 6 + padding: 6 + topPadding: 6 + (label && title ? label.implicitHeight + spacing : 0) //! [contentItem] contentItem: Item { } @@ -69,12 +69,12 @@ AbstractGroupBox { //! [frame] frame: Rectangle { - y: control.topPadding - control.Theme.padding + y: control.topPadding - control.padding width: parent.width - height: parent.height - control.topPadding + control.Theme.padding + height: parent.height - control.topPadding + control.padding + radius: 3 color: "transparent" - radius: control.Theme.roundness border.color: control.Theme.frameColor } //! [frame] diff --git a/src/imports/controls/PageIndicator.qml b/src/imports/controls/PageIndicator.qml index cb74567d..dd1dee81 100644 --- a/src/imports/controls/PageIndicator.qml +++ b/src/imports/controls/PageIndicator.qml @@ -47,8 +47,8 @@ AbstractPageIndicator { implicitHeight: Math.max(background ? background.implicitHeight : 0, contentItem.implicitHeight + topPadding + bottomPadding) - padding: Theme.padding - spacing: Theme.spacing + padding: 6 + spacing: 6 //! [delegate] delegate: Rectangle { diff --git a/src/imports/controls/ProgressBar.qml b/src/imports/controls/ProgressBar.qml index 6a6dfc11..e78c4683 100644 --- a/src/imports/controls/ProgressBar.qml +++ b/src/imports/controls/ProgressBar.qml @@ -47,7 +47,7 @@ AbstractProgressBar { Accessible.role: Accessible.ProgressBar - padding: Theme.padding + padding: 6 //! [indicator] indicator: Item { @@ -69,8 +69,8 @@ AbstractProgressBar { width: offset * (parent.width - x) - 2 height: 2 + radius: 3 color: control.enabled ? control.Theme.accentColor : control.Theme.disabledColor - radius: control.Theme.roundness SequentialAnimation on offset { loops: Animation.Infinite @@ -98,7 +98,7 @@ AbstractProgressBar { width: control.availableWidth height: 6 - radius: control.Theme.roundness + radius: 3 border.color: control.Theme.frameColor color: "transparent" } diff --git a/src/imports/controls/RadioButton.qml b/src/imports/controls/RadioButton.qml index cd2b553a..262a28de 100644 --- a/src/imports/controls/RadioButton.qml +++ b/src/imports/controls/RadioButton.qml @@ -53,8 +53,8 @@ AbstractRadioButton { Accessible.pressed: pressed Accessible.role: Accessible.RadioButton - padding: Theme.padding - spacing: Theme.spacing + padding: 6 + spacing: 6 //! [indicator] indicator: Rectangle { diff --git a/src/imports/controls/Slider.qml b/src/imports/controls/Slider.qml index 79792709..9e92c0b2 100644 --- a/src/imports/controls/Slider.qml +++ b/src/imports/controls/Slider.qml @@ -50,7 +50,7 @@ AbstractSlider { Accessible.pressed: pressed Accessible.role: Accessible.Slider - padding: Theme.padding + padding: 6 //! [handle] handle: Rectangle { @@ -89,7 +89,7 @@ AbstractSlider { width: horizontal ? control.availableWidth : implicitWidth height: horizontal ? implicitHeight : control.availableHeight - radius: control.Theme.roundness + radius: 3 border.color: control.Theme.frameColor color: control.Theme.backgroundColor scale: horizontal && control.mirrored ? -1 : 1 @@ -100,8 +100,8 @@ AbstractSlider { width: parent.horizontal ? control.position * parent.width - 4 : 2 height: parent.horizontal ? 2 : control.position * parent.height - 4 + radius: 3 color: control.enabled ? control.Theme.accentColor : control.Theme.disabledColor - radius: control.Theme.roundness } } //! [track] diff --git a/src/imports/controls/Switch.qml b/src/imports/controls/Switch.qml index e61fb152..24ac8297 100644 --- a/src/imports/controls/Switch.qml +++ b/src/imports/controls/Switch.qml @@ -54,8 +54,8 @@ AbstractSwitch { Accessible.pressed: pressed Accessible.role: Accessible.Button // TODO: Switch? - padding: Theme.padding - spacing: Theme.spacing + padding: 6 + spacing: 6 //! [indicator] indicator: Rectangle { diff --git a/src/imports/controls/TabButton.qml b/src/imports/controls/TabButton.qml index 2b9658be..d6d893b8 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: Theme.padding + padding: 6 //! [label] label: Text { diff --git a/src/imports/controls/TextField.qml b/src/imports/controls/TextField.qml index 946afe18..57b3eeb2 100644 --- a/src/imports/controls/TextField.qml +++ b/src/imports/controls/TextField.qml @@ -46,7 +46,7 @@ AbstractTextField { Accessible.description: placeholder ? placeholder.text : "" Accessible.passwordEdit: echoMode === TextInput.Password || echoMode === TextInput.PasswordEchoOnEdit - padding: Theme.padding + padding: 6 color: enabled ? Theme.textColor : Theme.disabledColor selectionColor: Theme.selectionColor @@ -68,9 +68,9 @@ AbstractTextField { //! [background] background: Rectangle { implicitWidth: 120 // TODO - radius: control.Theme.roundness border.width: control.activeFocus ? 2 : 1 border.color: control.activeFocus ? control.Theme.focusColor : control.Theme.frameColor + radius: 3 } //! [background] } diff --git a/src/imports/controls/ToggleButton.qml b/src/imports/controls/ToggleButton.qml index 2ecc0f18..bdb9849a 100644 --- a/src/imports/controls/ToggleButton.qml +++ b/src/imports/controls/ToggleButton.qml @@ -54,8 +54,8 @@ AbstractToggleButton { Accessible.pressed: pressed Accessible.role: Accessible.Button - padding: Theme.padding - spacing: Theme.spacing + padding: 6 + spacing: 6 //! [indicator] indicator: Rectangle { @@ -64,7 +64,7 @@ AbstractToggleButton { x: text ? (control.mirrored ? parent.width - width - control.rightPadding : control.leftPadding) : (parent.width - width) / 2 y: (parent.height - height) / 2 - radius: control.Theme.roundness + radius: 3 border.width: control.activeFocus ? 2 : 1 border.color: control.activeFocus ? control.Theme.focusColor : control.Theme.frameColor color: control.Theme.backgroundColor diff --git a/src/imports/controls/ToolButton.qml b/src/imports/controls/ToolButton.qml index 0c1d61f8..dc3a919b 100644 --- a/src/imports/controls/ToolButton.qml +++ b/src/imports/controls/ToolButton.qml @@ -49,7 +49,7 @@ AbstractToolButton { Accessible.pressed: pressed Accessible.role: Accessible.Button - padding: Theme.padding + padding: 6 //! [label] label: Text { diff --git a/src/imports/controls/qquicktheme.cpp b/src/imports/controls/qquicktheme.cpp index 59f1a78b..c404dac8 100644 --- a/src/imports/controls/qquicktheme.cpp +++ b/src/imports/controls/qquicktheme.cpp @@ -98,18 +98,6 @@ QT_BEGIN_NAMESPACE \qmlattachedproperty color QtQuickControls2::Theme::textColor */ -/*! - \qmlattachedproperty real QtQuickControls2::Theme::padding -*/ - -/*! - \qmlattachedproperty real QtQuickControls2::Theme::roundness -*/ - -/*! - \qmlattachedproperty real QtQuickControls2::Theme::spacing -*/ - Q_GLOBAL_STATIC_WITH_ARGS(QQuickThemeData, globalThemeData, (QString::fromLatin1(":/qtquickcontrols/theme.json"))) static QQuickThemeAttached *themeInstance(QQmlEngine *engine) @@ -221,10 +209,7 @@ public: explicitSelectedTextColor(false), explicitSelectionColor(false), explicitShadowColor(false), - explicitTextColor(false), - explicitPadding(false), - explicitSpacing(false), - explicitRoundness(false) { } + explicitTextColor(false) { } enum Method { Implicit, Explicit, Inherit }; @@ -239,9 +224,6 @@ public: void setSelectionColor(const QColor &color, Method method); void setShadowColor(const QColor &color, Method method); void setTextColor(const QColor &color, Method method); - void setPadding(qreal padding, Method method); - void setRoundness(qreal roundness, Method method); - void setSpacing(qreal spacing, Method method); void inherit(QQuickThemeAttached *theme); @@ -265,9 +247,6 @@ public: bool explicitSelectionColor; bool explicitShadowColor; bool explicitTextColor; - bool explicitPadding; - bool explicitSpacing; - bool explicitRoundness; }; void QQuickThemeAttachedPrivate::setAccentColor(const QColor &color, Method method) @@ -435,51 +414,6 @@ void QQuickThemeAttachedPrivate::setTextColor(const QColor &color, Method method } } -void QQuickThemeAttachedPrivate::setPadding(qreal padding, Method method) -{ - Q_Q(QQuickThemeAttached); - if (!explicitPadding || method != Inherit) { - explicitPadding = method == Explicit; - if (data.padding() != padding) { - data.setPadding(padding); - emit q->paddingChanged(); - - foreach (QQuickThemeAttached *child, childThemes) - child->d_func()->setPadding(padding, Inherit); - } - } -} - -void QQuickThemeAttachedPrivate::setRoundness(qreal roundness, Method method) -{ - Q_Q(QQuickThemeAttached); - if (!explicitRoundness || method != Inherit) { - explicitRoundness = method == Explicit; - if (data.roundness() != roundness) { - data.setRoundness(roundness); - emit q->roundnessChanged(); - - foreach (QQuickThemeAttached *child, childThemes) - child->d_func()->setRoundness(roundness, Inherit); - } - } -} - -void QQuickThemeAttachedPrivate::setSpacing(qreal spacing, Method method) -{ - Q_Q(QQuickThemeAttached); - if (!explicitSpacing || method != Inherit) { - explicitSpacing = method == Explicit; - if (data.spacing() != spacing) { - data.setSpacing(spacing); - emit q->spacingChanged(); - - foreach (QQuickThemeAttached *child, childThemes) - child->d_func()->setSpacing(spacing, Inherit); - } - } -} - void QQuickThemeAttachedPrivate::inherit(QQuickThemeAttached *theme) { setAccentColor(theme->accentColor(), Inherit); @@ -493,9 +427,6 @@ void QQuickThemeAttachedPrivate::inherit(QQuickThemeAttached *theme) setSelectionColor(theme->selectionColor(), Inherit); setShadowColor(theme->shadowColor(), Inherit); setTextColor(theme->textColor(), Inherit); - setPadding(theme->padding(), Inherit); - setRoundness(theme->roundness(), Inherit); - setSpacing(theme->spacing(), Inherit); } const QQuickThemeData &QQuickThemeAttachedPrivate::resolve() const @@ -769,58 +700,4 @@ void QQuickThemeAttached::resetTextColor() d->setTextColor(d->resolve().textColor(), QQuickThemeAttachedPrivate::Implicit); } -qreal QQuickThemeAttached::padding() const -{ - Q_D(const QQuickThemeAttached); - return d->data.padding(); -} - -void QQuickThemeAttached::setPadding(qreal padding) -{ - Q_D(QQuickThemeAttached); - d->setPadding(padding, QQuickThemeAttachedPrivate::Explicit); -} - -void QQuickThemeAttached::resetPadding() -{ - Q_D(QQuickThemeAttached); - d->setPadding(d->resolve().padding(), QQuickThemeAttachedPrivate::Implicit); -} - -qreal QQuickThemeAttached::roundness() const -{ - Q_D(const QQuickThemeAttached); - return d->data.roundness(); -} - -void QQuickThemeAttached::setRoundness(qreal roundness) -{ - Q_D(QQuickThemeAttached); - d->setRoundness(roundness, QQuickThemeAttachedPrivate::Explicit); -} - -void QQuickThemeAttached::resetRoundness() -{ - Q_D(QQuickThemeAttached); - d->setRoundness(d->resolve().roundness(), QQuickThemeAttachedPrivate::Implicit); -} - -qreal QQuickThemeAttached::spacing() const -{ - Q_D(const QQuickThemeAttached); - return d->data.spacing(); -} - -void QQuickThemeAttached::setSpacing(qreal spacing) -{ - Q_D(QQuickThemeAttached); - d->setSpacing(spacing, QQuickThemeAttachedPrivate::Explicit); -} - -void QQuickThemeAttached::resetSpacing() -{ - Q_D(QQuickThemeAttached); - d->setSpacing(d->resolve().spacing(), QQuickThemeAttachedPrivate::Implicit); -} - QT_END_NAMESPACE diff --git a/src/imports/controls/qquicktheme_p.h b/src/imports/controls/qquicktheme_p.h index 9dbe1c15..bdb6592a 100644 --- a/src/imports/controls/qquicktheme_p.h +++ b/src/imports/controls/qquicktheme_p.h @@ -71,9 +71,6 @@ class QQuickThemeAttached : public QObject 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(qreal padding READ padding WRITE setPadding RESET resetPadding NOTIFY paddingChanged FINAL) - Q_PROPERTY(qreal roundness READ roundness WRITE setRoundness RESET resetRoundness NOTIFY roundnessChanged FINAL) - Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing RESET resetSpacing NOTIFY spacingChanged FINAL) public: explicit QQuickThemeAttached(const QQuickThemeData &data, QObject *parent = Q_NULLPTR); @@ -128,18 +125,6 @@ public: void setTextColor(const QColor &color); void resetTextColor(); - qreal padding() const; - void setPadding(qreal padding); - void resetPadding(); - - qreal roundness() const; - void setRoundness(qreal roundness); - void resetRoundness(); - - qreal spacing() const; - void setSpacing(qreal spacing); - void resetSpacing(); - Q_SIGNALS: void accentColorChanged(); void backgroundColorChanged(); @@ -152,9 +137,6 @@ Q_SIGNALS: void selectionColorChanged(); void shadowColorChanged(); void textColorChanged(); - void paddingChanged(); - void roundnessChanged(); - void spacingChanged(); private: Q_DISABLE_COPY(QQuickThemeAttached) diff --git a/src/imports/controls/qquickthemedata.cpp b/src/imports/controls/qquickthemedata.cpp index 1b6fb26a..df924860 100644 --- a/src/imports/controls/qquickthemedata.cpp +++ b/src/imports/controls/qquickthemedata.cpp @@ -57,11 +57,6 @@ static QColor readColorValue(const QJsonValue &value, const QColor &defaultValue return QColor::fromRgba(value.toInt(defaultValue.rgba())); } -static double readNumberValue(const QJsonValue &value, double defaultValue) -{ - return value.toDouble(defaultValue); -} - bool QQuickThemeData::load(const QString &filePath) { QJsonDocument doc; @@ -92,9 +87,6 @@ bool QQuickThemeData::load(const QString &filePath) d->selectionColor = readColorValue(theme.value(QStringLiteral("selectionColor")), QColor("#45a7d7")); d->shadowColor = readColorValue(theme.value(QStringLiteral("shadowColor")), QColor("#28282a")); d->textColor = readColorValue(theme.value(QStringLiteral("textColor")), QColor("#26282a")); - d->padding = readNumberValue(theme.value(QStringLiteral("padding")), 6); - d->roundness = readNumberValue(theme.value(QStringLiteral("roundness")), 3); - d->spacing = readNumberValue(theme.value(QStringLiteral("spacing")), 6); return true; } diff --git a/src/imports/controls/qquickthemedata_p.h b/src/imports/controls/qquickthemedata_p.h index 85c938e9..1e0b40bb 100644 --- a/src/imports/controls/qquickthemedata_p.h +++ b/src/imports/controls/qquickthemedata_p.h @@ -94,15 +94,6 @@ public: QColor textColor() const { return d->textColor; } void setTextColor(const QColor &color) { d->textColor = color; } - qreal padding() const { return d->padding; } - void setPadding(qreal padding) { d->padding = padding; } - - qreal roundness() const { return d->roundness; } - void setRoundness(qreal roundness) { d->roundness = roundness; } - - qreal spacing() const { return d->spacing; } - void setSpacing(qreal spacing) { d->spacing = spacing; } - private: struct Data : public QSharedData { QColor accentColor; @@ -116,9 +107,6 @@ private: QColor selectionColor; QColor shadowColor; QColor textColor; - qreal padding; - qreal spacing; - qreal roundness; }; QSharedDataPointer<Data> d; }; diff --git a/src/imports/controls/theme.json b/src/imports/controls/theme.json index 53196bf7..c5c19d47 100644 --- a/src/imports/controls/theme.json +++ b/src/imports/controls/theme.json @@ -9,8 +9,5 @@ "selectedTextColor": "#ffffff", "selectionColor": "#45a7d7", "shadowColor": "#28282a", - "textColor": "#26282a", - "padding": 6, - "roundness": 3, - "spacing": 6 + "textColor": "#26282a" } |