Merge lp:~zsombi/ubuntu-ui-toolkit/stylehints into lp:ubuntu-ui-toolkit/staging

Proposed by Zsombor Egri
Status: Merged
Approved by: Cris Dywan
Approved revision: 1533
Merged at revision: 1526
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/stylehints
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 1078 lines (+815/-20)
23 files modified
components.api (+2/-0)
modules/Ubuntu/Components/plugin/plugin.cpp (+2/-0)
modules/Ubuntu/Components/plugin/plugin.pro (+4/-2)
modules/Ubuntu/Components/plugin/propertychange_p.cpp (+30/-9)
modules/Ubuntu/Components/plugin/propertychange_p.h (+9/-0)
modules/Ubuntu/Components/plugin/ucstyleditembase.cpp (+1/-0)
modules/Ubuntu/Components/plugin/ucstyleditembase.h (+1/-0)
modules/Ubuntu/Components/plugin/ucstylehints.cpp (+259/-0)
modules/Ubuntu/Components/plugin/ucstylehints.h (+92/-0)
modules/Ubuntu/Test/plugin/uctestcase.cpp (+9/-5)
modules/Ubuntu/Test/plugin/uctestcase.h (+1/-1)
tests/unit_x11/tst_subtheming/GroupPropertyBindingHints.qml (+32/-0)
tests/unit_x11/tst_subtheming/HintedButton.qml (+24/-0)
tests/unit_x11/tst_subtheming/MoreStyleHints.qml (+34/-0)
tests/unit_x11/tst_subtheming/OverrideStyleHints.qml (+30/-0)
tests/unit_x11/tst_subtheming/PropertyBindingHints.qml (+31/-0)
tests/unit_x11/tst_subtheming/SimplePropertyHints.qml (+30/-0)
tests/unit_x11/tst_subtheming/StyleHintsElsewhere.qml (+27/-0)
tests/unit_x11/tst_subtheming/StyleHintsInvalidProperty.qml (+30/-0)
tests/unit_x11/tst_subtheming/StyleHintsWithObject.qml (+29/-0)
tests/unit_x11/tst_subtheming/StyleHintsWithSignal.qml (+29/-0)
tests/unit_x11/tst_subtheming/tst_subtheming.cpp (+98/-2)
tests/unit_x11/tst_subtheming/tst_subtheming.pro (+11/-1)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/stylehints
Reviewer Review Type Date Requested Status
Cris Dywan Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+260826@code.launchpad.net

Commit message

Introducing StyleHints to provide style specific property changes.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1532. By Zsombor Egri

documentation fixed

1533. By Zsombor Egri

accidental scrollbar style change

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Cris Dywan (kalikiana) wrote :

I wish all merge requests were this clean, every time I thought "hmm is there a test for that code" there was. Looks pretty slick, and tests pass now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'components.api'
--- components.api 2015-05-26 07:38:55 +0000
+++ components.api 2015-06-02 15:25:00 +0000
@@ -871,6 +871,8 @@
871 property bool iconFrame871 property bool iconFrame
872 property bool progression872 property bool progression
873Ubuntu.Components.StateSaver 1.0 0.1: QtObject873Ubuntu.Components.StateSaver 1.0 0.1: QtObject
874Ubuntu.Components.StyleHints 1.3: QtObject
875 property bool ignoreUnknownProperties
874Ubuntu.Components.StyledItem 1.3 1.1 1.0 0.1: Item876Ubuntu.Components.StyledItem 1.3 1.1 1.0 0.1: Item
875 property bool activeFocusOnPress877 property bool activeFocusOnPress
876 function bool requestFocus(Qt.FocusReason reason)878 function bool requestFocus(Qt.FocusReason reason)
877879
=== modified file 'modules/Ubuntu/Components/plugin/plugin.cpp'
--- modules/Ubuntu/Components/plugin/plugin.cpp 2015-05-21 10:50:35 +0000
+++ modules/Ubuntu/Components/plugin/plugin.cpp 2015-06-02 15:25:00 +0000
@@ -50,6 +50,7 @@
50#include "ucinversemouse.h"50#include "ucinversemouse.h"
51#include "sortfiltermodel.h"51#include "sortfiltermodel.h"
52#include "ucstyleditembase.h"52#include "ucstyleditembase.h"
53#include "ucstylehints.h"
53#include "ucaction.h"54#include "ucaction.h"
54#include "ucactioncontext.h"55#include "ucactioncontext.h"
55#include "ucactionmanager.h"56#include "ucactionmanager.h"
@@ -211,6 +212,7 @@
211 qmlRegisterType<UCStyledItemBase, 2>(uri, 1, 3, "StyledItem");212 qmlRegisterType<UCStyledItemBase, 2>(uri, 1, 3, "StyledItem");
212 qmlRegisterSingletonType<UCNamespaceV13>(uri, 1, 3, "Ubuntu", registerUbuntuNamespace13);213 qmlRegisterSingletonType<UCNamespaceV13>(uri, 1, 3, "Ubuntu", registerUbuntuNamespace13);
213 qmlRegisterType<UCStyledItemBase, 2>(uri, 1, 3, "StyledItem");214 qmlRegisterType<UCStyledItemBase, 2>(uri, 1, 3, "StyledItem");
215 qmlRegisterCustomType<UCStyleHints>(uri, 1, 3, "StyleHints", new UCStyleHintsParser);
214}216}
215217
216void UbuntuComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)218void UbuntuComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
217219
=== modified file 'modules/Ubuntu/Components/plugin/plugin.pro'
--- modules/Ubuntu/Components/plugin/plugin.pro 2015-03-13 09:27:53 +0000
+++ modules/Ubuntu/Components/plugin/plugin.pro 2015-06-02 15:25:00 +0000
@@ -80,7 +80,8 @@
80 privates/listitemdraghandler.h \80 privates/listitemdraghandler.h \
81 ucnamespace.h \81 ucnamespace.h \
82 ucdeprecatedtheme.h \82 ucdeprecatedtheme.h \
83 ucdefaulttheme.h83 ucdefaulttheme.h \
84 ucstylehints.h
8485
85SOURCES += plugin.cpp \86SOURCES += plugin.cpp \
86 uctheme.cpp \87 uctheme.cpp \
@@ -128,7 +129,8 @@
128 privates/listitemdraghandler.cpp \129 privates/listitemdraghandler.cpp \
129 ucnamespace.cpp \130 ucnamespace.cpp \
130 ucdeprecatedtheme.cpp \131 ucdeprecatedtheme.cpp \
131 ucdefaulttheme.cpp132 ucdefaulttheme.cpp \
133 ucstylehints.cpp
132134
133# adapters135# adapters
134SOURCES += adapters/alarmsadapter_organizer.cpp136SOURCES += adapters/alarmsadapter_organizer.cpp
135137
=== modified file 'modules/Ubuntu/Components/plugin/propertychange_p.cpp'
--- modules/Ubuntu/Components/plugin/propertychange_p.cpp 2015-01-27 18:14:44 +0000
+++ modules/Ubuntu/Components/plugin/propertychange_p.cpp 2015-06-02 15:25:00 +0000
@@ -28,6 +28,7 @@
28PropertyChange::PropertyChange(QObject *item, const char *property, bool autoBackup)28PropertyChange::PropertyChange(QObject *item, const char *property, bool autoBackup)
29 : backedUp(false)29 : backedUp(false)
30 , qmlProperty(item, property, qmlContext(item))30 , qmlProperty(item, property, qmlContext(item))
31 , backupBinding(Q_NULLPTR)
31{32{
32 if (autoBackup) {33 if (autoBackup) {
33 backup();34 backup();
@@ -41,6 +42,7 @@
41void PropertyChange::backup()42void PropertyChange::backup()
42{43{
43 if (!backedUp) {44 if (!backedUp) {
45 backupBinding = QQmlPropertyPrivate::binding(qmlProperty);
44 backupValue = qmlProperty.read();46 backupValue = qmlProperty.read();
45 backedUp = true;47 backedUp = true;
46 }48 }
@@ -56,11 +58,24 @@
56 return;58 return;
57 }59 }
58 change->backup();60 change->backup();
59 // write using QQmlPropertyPrivate so we can keep the bindings61 change->qmlProperty.write(value);
60 QQmlPropertyPrivate::write(change->qmlProperty,62}
61 value,63
62 QQmlPropertyPrivate::BypassInterceptor | QQmlPropertyPrivate::DontRemoveBinding);64/*
63}65 * Same as setValue() but setting a binding.
66 */
67void PropertyChange::setBinding(PropertyChange *change, QQmlAbstractBinding *binding)
68{
69 if (!change) {
70 return;
71 }
72 change->backup();
73 QQmlAbstractBinding *prev = QQmlPropertyPrivate::setBinding(change->qmlProperty, binding);
74 if (prev && prev != binding && prev != change->backupBinding) {
75 prev->destroy();
76 }
77}
78
6479
65/*80/*
66 * Restore backed up value or binding.81 * Restore backed up value or binding.
@@ -71,10 +86,16 @@
71 return;86 return;
72 }87 }
73 if (change->backedUp) {88 if (change->backedUp) {
74 // write using QQmlPropertyPrivate to keep the bindings89 if (change->qmlProperty.isValid()) {
75 QQmlPropertyPrivate::write(change->qmlProperty,90 if (change->backupBinding) {
76 change->backupValue,91 QQmlAbstractBinding *prev = QQmlPropertyPrivate::setBinding(change->qmlProperty, change->backupBinding);
77 QQmlPropertyPrivate::BypassInterceptor | QQmlPropertyPrivate::DontRemoveBinding);92 if (prev != change->backupBinding && prev) {
93 prev->destroy();
94 }
95 } else {
96 change->qmlProperty.write(change->backupValue);
97 }
98 }
78 change->backedUp = false;99 change->backedUp = false;
79 }100 }
80}101}
81102
=== modified file 'modules/Ubuntu/Components/plugin/propertychange_p.h'
--- modules/Ubuntu/Components/plugin/propertychange_p.h 2015-01-27 18:14:44 +0000
+++ modules/Ubuntu/Components/plugin/propertychange_p.h 2015-06-02 15:25:00 +0000
@@ -21,6 +21,7 @@
21#include <QtCore/QObject>21#include <QtCore/QObject>
22#include <QtQml/QQmlProperty>22#include <QtQml/QQmlProperty>
2323
24class QQmlAbstractBinding;
24class PropertyChange25class PropertyChange
25{26{
26public:27public:
@@ -28,11 +29,19 @@
28 ~PropertyChange();29 ~PropertyChange();
2930
30 static void setValue(PropertyChange* change, const QVariant &value);31 static void setValue(PropertyChange* change, const QVariant &value);
32 static void setBinding(PropertyChange *change, QQmlAbstractBinding *binding);
31 static void restore(PropertyChange* change);33 static void restore(PropertyChange* change);
34
35 const QQmlProperty &property()
36 {
37 return qmlProperty;
38 }
39
32private:40private:
33 bool backedUp;41 bool backedUp;
34 QQmlProperty qmlProperty;42 QQmlProperty qmlProperty;
35 QVariant backupValue;43 QVariant backupValue;
44 QQmlAbstractBinding *backupBinding;
3645
37 void backup();46 void backup();
38};47};
3948
=== modified file 'modules/Ubuntu/Components/plugin/ucstyleditembase.cpp'
--- modules/Ubuntu/Components/plugin/ucstyleditembase.cpp 2015-05-26 15:05:46 +0000
+++ modules/Ubuntu/Components/plugin/ucstyleditembase.cpp 2015-06-02 15:25:00 +0000
@@ -19,6 +19,7 @@
19#include "ucstyleditembase.h"19#include "ucstyleditembase.h"
20#include "ucstyleditembase_p.h"20#include "ucstyleditembase_p.h"
21#include "uctheme.h"21#include "uctheme.h"
22#include "ucstylehints.h"
22#include <QtQml/QQmlEngine>23#include <QtQml/QQmlEngine>
23#include <QtQuick/private/qquickanchors_p.h>24#include <QtQuick/private/qquickanchors_p.h>
2425
2526
=== modified file 'modules/Ubuntu/Components/plugin/ucstyleditembase.h'
--- modules/Ubuntu/Components/plugin/ucstyleditembase.h 2015-05-22 13:54:38 +0000
+++ modules/Ubuntu/Components/plugin/ucstyleditembase.h 2015-06-02 15:25:00 +0000
@@ -23,6 +23,7 @@
2323
24class UCStyledItemBasePrivate;24class UCStyledItemBasePrivate;
25class UCTheme;25class UCTheme;
26class UCStyleHints;
26class UCStyledItemBase : public QQuickItem27class UCStyledItemBase : public QQuickItem
27{28{
28 Q_OBJECT29 Q_OBJECT
2930
=== added file 'modules/Ubuntu/Components/plugin/ucstylehints.cpp'
--- modules/Ubuntu/Components/plugin/ucstylehints.cpp 1970-01-01 00:00:00 +0000
+++ modules/Ubuntu/Components/plugin/ucstylehints.cpp 2015-06-02 15:25:00 +0000
@@ -0,0 +1,259 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Zsombor Egri <zsombor.egri@canonical.com>
17 */
18
19#include "ucstylehints.h"
20#include "ucstyleditembase_p.h"
21#include "propertychange_p.h"
22#include <QtQml/QQmlInfo>
23
24// verifies property declaration correctness
25void UCStyleHintsParser::verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &bindings)
26{
27 Q_FOREACH(const QV4::CompiledData::Binding *binding, bindings) {
28 verifyProperty(qmlUnit, binding);
29 }
30}
31
32void UCStyleHintsParser::verifyProperty(const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding)
33{
34 if (binding->type == QV4::CompiledData::Binding::Type_Object) {
35 error(qmlUnit->objectAt(binding->value.objectIndex), "StyleHints does not support creating state-specific objects.");
36 return;
37 }
38
39 // group properties or attached properties, we do handle those as well
40 if (binding->type == QV4::CompiledData::Binding::Type_GroupProperty
41 || binding->type == QV4::CompiledData::Binding::Type_AttachedProperty) {
42 const QV4::CompiledData::Object *subObj = qmlUnit->objectAt(binding->value.objectIndex);
43 const QV4::CompiledData::Binding *subBinding = subObj->bindingTable();
44 for (quint32 i = 0; i < subObj->nBindings; ++i, ++subBinding) {
45 verifyProperty(qmlUnit, subBinding);
46 }
47 }
48
49 // filter out signals!
50 QString propertyName = qmlUnit->stringAt(binding->propertyNameIndex);
51 if (propertyName.startsWith("on") && propertyName.at(2).isUpper()) {
52 error(binding, "Signal properties are not supported.");
53 return;
54 }
55}
56
57// decodes property declarations, stores the bindings and values
58void UCStyleHintsParser::applyBindings(QObject *obj, QQmlCompiledData *cdata, const QList<const QV4::CompiledData::Binding *> &bindings)
59{
60 UCStyleHints *hints = static_cast<UCStyleHints*>(obj);
61 QV4::CompiledData::Unit *qmlUnit = cdata->compilationUnit->data;
62
63 UCStyledItemBase *styledItem = qobject_cast<UCStyledItemBase*>(hints->parent());
64 if (!styledItem) {
65 // error will be reported in componentCompleted
66 return;
67 }
68
69 Q_FOREACH(const QV4::CompiledData::Binding *binding, bindings) {
70 hints->decodeBinding(QString(), qmlUnit, binding);
71 }
72
73 hints->m_cdata = cdata;
74 hints->m_decoded = true;
75}
76
77void UCStyleHints::decodeBinding(const QString &propertyPrefix, const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding)
78{
79 QString propertyName = propertyPrefix + qmlUnit->stringAt(binding->propertyNameIndex);
80
81 // handle grouped properties first
82 if (binding->type == QV4::CompiledData::Binding::Type_GroupProperty
83 || binding->type == QV4::CompiledData::Binding::Type_AttachedProperty) {
84
85 const QV4::CompiledData::Object *subObj = qmlUnit->objectAt(binding->value.objectIndex);
86 const QV4::CompiledData::Binding *subBinding = subObj->bindingTable();
87 QString pre = propertyName + ".";
88 for (quint32 i = 0; i < subObj->nBindings; ++i, ++subBinding) {
89 decodeBinding(pre, qmlUnit, subBinding);
90 }
91 return;
92 }
93
94 switch (binding->type) {
95 case QV4::CompiledData::Binding::Type_Script:
96 {
97 QString expression = binding->valueAsScriptString(qmlUnit);
98 QUrl url = QUrl();
99 int line = -1;
100 int column = -1;
101
102 QQmlData *ddata = QQmlData::get(this);
103 if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) {
104 url = ddata->outerContext->url;
105 line = ddata->lineNumber;
106 column = ddata->columnNumber;
107 }
108 m_expressions << Expression(propertyName, binding->value.compiledScriptIndex, expression, url, line, column);
109 break;
110 }
111 case QV4::CompiledData::Binding::Type_Translation:
112 case QV4::CompiledData::Binding::Type_TranslationById:
113 case QV4::CompiledData::Binding::Type_String:
114 {
115 m_values << qMakePair(propertyName, binding->valueAsString(qmlUnit));
116 break;
117 }
118 case QV4::CompiledData::Binding::Type_Number:
119 {
120 m_values << qMakePair(propertyName, binding->valueAsNumber());
121 break;
122 }
123 case QV4::CompiledData::Binding::Type_Boolean:
124 {
125 m_values << qMakePair(propertyName, binding->valueAsBoolean());
126 break;
127 }
128 }
129}
130
131void UCStyleHints::propertyNotFound(const QString &styleName, const QString &property)
132{
133 if (!m_ignoreUnknownProperties) {
134 qmlInfo(this) << QString("Style '%1' has no property called '%2'.").arg(styleName).arg(property);
135 }
136}
137
138/*!
139 * \qmltype StyleHints
140 * \instantiates UCStyleHints
141 * \inmodule Ubuntu Components 1.3
142 * \ingroup ubuntu
143 * \since Ubuntu.Components 1.3
144 * \brief Component holding style specific properties to configure a particular
145 * StyledItem's style runtime.
146 *
147 * StyleHints is a custom parser, meaning style properties can be listed without
148 * any property declaration, same way as in PropertyChanges or Connections, which
149 * are similar custom parsers. Properties enumerated do not have to be present in
150 * the component's style as default, behavior which can be chenged by setting \l
151 * ignoreUnknownProperties to true. In this case properties not found in the style
152 * will be displayed as warnings.
153 *
154 * In the following example the Button will be drawn as white when not pressed, and
155 * colored as blue when pressed.
156 * \qml
157 * Button {
158 * id: button
159 * StyleHints {
160 * defaultColor: button.pressed ? "blue" : "white"
161 * }
162 * }
163 * \endqml
164 *
165 * StyleHints does not support signal properties (i.e signal handlers) and object
166 * declarations as property values.
167 *
168 * StyleHints can be only declared in a \l StyledItem or as a derivate of it.
169 */
170
171/*!
172 * \qmlproperty bool StyleHints::ignoreUnknownProperties
173 * The property drives whether component should warn on properties not found in
174 * the component's style. The default setting is not to warn.
175 */
176UCStyleHints::UCStyleHints(QObject *parent)
177 : QObject(parent)
178 , m_decoded(false)
179 , m_completed(false)
180 , m_ignoreUnknownProperties(true)
181{
182}
183
184UCStyleHints::~UCStyleHints()
185{
186 qDeleteAll(m_propertyBackup);
187 m_propertyBackup.clear();
188}
189
190void UCStyleHints::classBegin()
191{
192 m_styledItem = qobject_cast<UCStyledItemBase*>(parent());
193 if (m_styledItem) {
194 connect(m_styledItem, SIGNAL(styleInstanceChanged()),
195 this, SLOT(_q_applyStyleHints()));
196 } else {
197 qmlInfo(this) << "StyleHints must be declared in a StyledItem or a derivate of it.";
198 }
199}
200
201void UCStyleHints::componentComplete()
202{
203 m_completed = (m_styledItem != Q_NULLPTR);
204 _q_applyStyleHints();
205}
206
207// apply the style hints and check each property existence
208void UCStyleHints::_q_applyStyleHints()
209{
210 if (!m_completed || !m_decoded || !m_styledItem || !UCStyledItemBasePrivate::get(m_styledItem)->styleItem) {
211 return;
212 }
213
214 // restore properties first
215 qDeleteAll(m_propertyBackup);
216 m_propertyBackup.clear();
217
218 QQuickItem *item = UCStyledItemBasePrivate::get(m_styledItem)->styleItem;
219 const QMetaObject *mo = item->metaObject();
220 const QString styleName = UCStyledItemBasePrivate::get(m_styledItem)->styleName();
221 // apply values first
222 for (int i = 0; i < m_values.size(); i++) {
223 if (mo->indexOfProperty(m_values[i].first.toUtf8()) < 0) {
224 propertyNotFound(styleName, m_values[i].first);
225 continue;
226 }
227 PropertyChange *change = new PropertyChange(item, m_values[i].first.toUtf8());
228 PropertyChange::setValue(change, m_values[i].second);
229 m_propertyBackup << change;
230 }
231
232 QQmlContext *context = qmlContext(this);
233 // then apply expressions/bindings
234 for (int ii = 0; ii < m_expressions.count(); ii++) {
235 Expression e = m_expressions[ii];
236 PropertyChange *change = new PropertyChange(item, e.name.toUtf8());
237 if (!change->property().isValid()) {
238 propertyNotFound(styleName, e.name);
239 delete change;
240 continue;
241 }
242
243 // create a binding object from the expression using the palette context
244 QQmlContextData *cdata = QQmlContextData::get(context);
245 QQmlBinding *newBinding = 0;
246 if (e.id != QQmlBinding::Invalid) {
247 QV4::Scope scope(QQmlEnginePrivate::getV4Engine(qmlEngine(this)));
248 QV4::ScopedValue function(scope, QV4::QmlBindingWrapper::createQmlCallableForFunction(cdata, item, m_cdata->compilationUnit->runtimeFunctions[e.id]));
249 newBinding = new QQmlBinding(function, item, cdata);
250 }
251 if (!newBinding) {
252 newBinding = new QQmlBinding(e.expression, item, cdata, e.url.toString(), e.line, e.column);
253 }
254
255 newBinding->setTarget(change->property());
256 PropertyChange::setBinding(change, newBinding);
257 }
258}
259
0260
=== added file 'modules/Ubuntu/Components/plugin/ucstylehints.h'
--- modules/Ubuntu/Components/plugin/ucstylehints.h 1970-01-01 00:00:00 +0000
+++ modules/Ubuntu/Components/plugin/ucstylehints.h 2015-06-02 15:25:00 +0000
@@ -0,0 +1,92 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Zsombor Egri <zsombor.egri@canonical.com>
17 */
18
19#ifndef UCSTYLEHINTS_H
20#define UCSTYLEHINTS_H
21
22#include <QtCore/QObject>
23#define foreach Q_FOREACH
24#include <QtQml/private/qqmlcustomparser_p.h>
25#include <private/qv4engine_p.h>
26#include <private/qpodvector_p.h>
27#undef foreach
28#include <QtQml/private/qqmlcompiler_p.h>
29
30class UCStyleHintsParser;
31class UCStyledItemBase;
32class QQuickItem;
33class PropertyChange;
34class UCStyleHints : public QObject, public QQmlParserStatus
35{
36 Q_OBJECT
37 Q_INTERFACES(QQmlParserStatus)
38 Q_PROPERTY(bool ignoreUnknownProperties MEMBER m_ignoreUnknownProperties)
39
40public:
41 explicit UCStyleHints(QObject *parent = 0);
42 ~UCStyleHints();
43
44private Q_SLOTS:
45 void _q_applyStyleHints();
46
47protected:
48 void classBegin();
49 void componentComplete();
50
51private:
52 class Expression {
53 public:
54 Expression(const QString &name, QQmlBinding::Identifier id, const QString& expr,
55 const QUrl &url, int line, int column)
56 : name(name), id(id), expression(expr), url(url), line(line), column(column) {}
57 QString name;
58 QQmlBinding::Identifier id;
59 QString expression;
60 QUrl url;
61 int line;
62 int column;
63 };
64
65 bool m_decoded:1;
66 bool m_completed:1;
67 bool m_ignoreUnknownProperties:1;
68 QPointer<UCStyledItemBase> m_styledItem;
69 QList<Expression> m_expressions;
70 QList< QPair<QString, QVariant> > m_values;
71 QList< PropertyChange* > m_propertyBackup;
72 QQmlRefPointer<QQmlCompiledData> m_cdata;
73
74 friend class UCStyleHintsParser;
75
76 void propertyNotFound(const QString &styleName, const QString &property);
77 void decodeBinding(const QString &propertyPrefix, const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding);
78};
79
80class UCStyleHintsParser : public QQmlCustomParser
81{
82public:
83 UCStyleHintsParser() : QQmlCustomParser(QQmlCustomParser::AcceptsSignalHandlers) {}
84
85 virtual void verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &bindings);
86 virtual void applyBindings(QObject *obj, QQmlCompiledData *cdata, const QList<const QV4::CompiledData::Binding *> &bindings);
87
88private:
89 void verifyProperty(const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding);
90};
91
92#endif // UCSTYLEHINTS_H
093
=== modified file 'modules/Ubuntu/Test/plugin/uctestcase.cpp'
--- modules/Ubuntu/Test/plugin/uctestcase.cpp 2014-11-25 09:58:33 +0000
+++ modules/Ubuntu/Test/plugin/uctestcase.cpp 2015-06-02 15:25:00 +0000
@@ -32,7 +32,7 @@
32 * \ingroup ubuntu32 * \ingroup ubuntu
33 * \brief UbuntuTestCase is the C++ pendant to the QML UbuntuTestCase.33 * \brief UbuntuTestCase is the C++ pendant to the QML UbuntuTestCase.
34 */34 */
35UbuntuTestCase::UbuntuTestCase(const QString& file, QWindow* parent) : QQuickView(parent)35UbuntuTestCase::UbuntuTestCase(const QString& file, bool assertOnFailure, QWindow* parent) : QQuickView(parent)
36{36{
37 QString modules(UBUNTU_QML_IMPORT_PATH);37 QString modules(UBUNTU_QML_IMPORT_PATH);
38 Q_ASSERT(QDir(modules).exists());38 Q_ASSERT(QDir(modules).exists());
@@ -45,10 +45,14 @@
4545
46 Q_ASSERT(!file.isEmpty());46 Q_ASSERT(!file.isEmpty());
47 setSource(QUrl::fromLocalFile(file));47 setSource(QUrl::fromLocalFile(file));
48 Q_ASSERT(status() == QQuickView::Ready);48 if (assertOnFailure) {
49 Q_ASSERT(rootObject());49 Q_ASSERT(status() == QQuickView::Ready);
50 show();50 Q_ASSERT(rootObject());
51 QTest::qWaitForWindowExposed(this);51 }
52 if (rootObject()) {
53 show();
54 QTest::qWaitForWindowExposed(this);
55 }
52}56}
5357
54/*!58/*!
5559
=== modified file 'modules/Ubuntu/Test/plugin/uctestcase.h'
--- modules/Ubuntu/Test/plugin/uctestcase.h 2015-03-06 14:35:53 +0000
+++ modules/Ubuntu/Test/plugin/uctestcase.h 2015-06-02 15:25:00 +0000
@@ -28,7 +28,7 @@
28{28{
29 Q_OBJECT29 Q_OBJECT
30public:30public:
31 UbuntuTestCase(const QString& file, QWindow* parent = 0);31 UbuntuTestCase(const QString& file, bool assertOnFailure = true, QWindow* parent = 0);
32 int warnings() const;32 int warnings() const;
33 // getter33 // getter
34 template<class T>34 template<class T>
3535
=== added file 'tests/unit_x11/tst_subtheming/GroupPropertyBindingHints.qml'
--- tests/unit_x11/tst_subtheming/GroupPropertyBindingHints.qml 1970-01-01 00:00:00 +0000
+++ tests/unit_x11/tst_subtheming/GroupPropertyBindingHints.qml 2015-06-02 15:25:00 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.4
18import Ubuntu.Components 1.3
19
20Item {
21 width: units.gu(40)
22 height: units.gu(71)
23
24 HintedButton {
25 objectName: "Button"
26 id: button
27 gradient: UbuntuColors.greyGradient
28 StyleHints {
29 gradientProxy.topColor: button.pressed ? "tan" : "blue"
30 }
31 }
32}
033
=== added file 'tests/unit_x11/tst_subtheming/HintedButton.qml'
--- tests/unit_x11/tst_subtheming/HintedButton.qml 1970-01-01 00:00:00 +0000
+++ tests/unit_x11/tst_subtheming/HintedButton.qml 2015-06-02 15:25:00 +0000
@@ -0,0 +1,24 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.4
18import Ubuntu.Components 1.3
19
20Button {
21 StyleHints {
22 minimumWidth: units.gu(20)
23 }
24}
025
=== added file 'tests/unit_x11/tst_subtheming/MoreStyleHints.qml'
--- tests/unit_x11/tst_subtheming/MoreStyleHints.qml 1970-01-01 00:00:00 +0000
+++ tests/unit_x11/tst_subtheming/MoreStyleHints.qml 2015-06-02 15:25:00 +0000
@@ -0,0 +1,34 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.4
18import Ubuntu.Components 1.3
19
20Item {
21 width: units.gu(40)
22 height: units.gu(71)
23
24 Button {
25 objectName: "Button"
26 StyleHints {
27 minimumWidth: units.gu(20)
28 }
29
30 StyleHints {
31 defaultColor: "brown"
32 }
33 }
34}
035
=== added file 'tests/unit_x11/tst_subtheming/OverrideStyleHints.qml'
--- tests/unit_x11/tst_subtheming/OverrideStyleHints.qml 1970-01-01 00:00:00 +0000
+++ tests/unit_x11/tst_subtheming/OverrideStyleHints.qml 2015-06-02 15:25:00 +0000
@@ -0,0 +1,30 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.4
18import Ubuntu.Components 1.3
19
20Item {
21 width: units.gu(40)
22 height: units.gu(71)
23
24 HintedButton {
25 objectName: "Button"
26 StyleHints {
27 minimumWidth: 5
28 }
29 }
30}
031
=== added file 'tests/unit_x11/tst_subtheming/PropertyBindingHints.qml'
--- tests/unit_x11/tst_subtheming/PropertyBindingHints.qml 1970-01-01 00:00:00 +0000
+++ tests/unit_x11/tst_subtheming/PropertyBindingHints.qml 2015-06-02 15:25:00 +0000
@@ -0,0 +1,31 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.4
18import Ubuntu.Components 1.3
19
20Item {
21 width: units.gu(40)
22 height: units.gu(71)
23
24 Button {
25 objectName: "Button"
26 id: button
27 StyleHints {
28 defaultColor: button.pressed ? "tan" : "blue"
29 }
30 }
31}
032
=== added file 'tests/unit_x11/tst_subtheming/SimplePropertyHints.qml'
--- tests/unit_x11/tst_subtheming/SimplePropertyHints.qml 1970-01-01 00:00:00 +0000
+++ tests/unit_x11/tst_subtheming/SimplePropertyHints.qml 2015-06-02 15:25:00 +0000
@@ -0,0 +1,30 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.4
18import Ubuntu.Components 1.3
19
20Item {
21 width: units.gu(40)
22 height: units.gu(71)
23
24 Button {
25 objectName: "Button"
26 StyleHints {
27 defaultColor: "blue"
28 }
29 }
30}
031
=== added file 'tests/unit_x11/tst_subtheming/StyleHintsElsewhere.qml'
--- tests/unit_x11/tst_subtheming/StyleHintsElsewhere.qml 1970-01-01 00:00:00 +0000
+++ tests/unit_x11/tst_subtheming/StyleHintsElsewhere.qml 2015-06-02 15:25:00 +0000
@@ -0,0 +1,27 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.4
18import Ubuntu.Components 1.3
19
20Item {
21 width: units.gu(40)
22 height: units.gu(71)
23
24 StyleHints {
25 anyProperty: true
26 }
27}
028
=== added file 'tests/unit_x11/tst_subtheming/StyleHintsInvalidProperty.qml'
--- tests/unit_x11/tst_subtheming/StyleHintsInvalidProperty.qml 1970-01-01 00:00:00 +0000
+++ tests/unit_x11/tst_subtheming/StyleHintsInvalidProperty.qml 2015-06-02 15:25:00 +0000
@@ -0,0 +1,30 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.4
18import Ubuntu.Components 1.3
19
20Item {
21 width: units.gu(40)
22 height: units.gu(71)
23
24 Button {
25 StyleHints {
26 ignoreUnknownProperties: false
27 invalidProperty: 10
28 }
29 }
30}
031
=== added file 'tests/unit_x11/tst_subtheming/StyleHintsWithObject.qml'
--- tests/unit_x11/tst_subtheming/StyleHintsWithObject.qml 1970-01-01 00:00:00 +0000
+++ tests/unit_x11/tst_subtheming/StyleHintsWithObject.qml 2015-06-02 15:25:00 +0000
@@ -0,0 +1,29 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.4
18import Ubuntu.Components 1.3
19
20Item {
21 width: units.gu(40)
22 height: units.gu(71)
23
24 Button {
25 StyleHints {
26 anyProperty: QtObject{}
27 }
28 }
29}
030
=== added file 'tests/unit_x11/tst_subtheming/StyleHintsWithSignal.qml'
--- tests/unit_x11/tst_subtheming/StyleHintsWithSignal.qml 1970-01-01 00:00:00 +0000
+++ tests/unit_x11/tst_subtheming/StyleHintsWithSignal.qml 2015-06-02 15:25:00 +0000
@@ -0,0 +1,29 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.4
18import Ubuntu.Components 1.3
19
20Item {
21 width: units.gu(40)
22 height: units.gu(71)
23
24 Button {
25 StyleHints {
26 onDefaultColorChanged: {}
27 }
28 }
29}
030
=== modified file 'tests/unit_x11/tst_subtheming/tst_subtheming.cpp'
--- tests/unit_x11/tst_subtheming/tst_subtheming.cpp 2015-05-26 15:05:46 +0000
+++ tests/unit_x11/tst_subtheming/tst_subtheming.cpp 2015-06-02 15:25:00 +0000
@@ -25,13 +25,14 @@
25#include "uctestcase.h"25#include "uctestcase.h"
26#include "ucstyleditembase_p.h"26#include "ucstyleditembase_p.h"
27#include "ucnamespace.h"27#include "ucnamespace.h"
28#include "ucunits.h"
2829
29class ThemeTestCase : public UbuntuTestCase30class ThemeTestCase : public UbuntuTestCase
30{31{
31 Q_OBJECT32 Q_OBJECT
32public:33public:
33 ThemeTestCase(const QString& file, QWindow* parent = 0)34 ThemeTestCase(const QString& file, bool assertOnFailure = true, QWindow* parent = 0)
34 : UbuntuTestCase(file, parent)35 : UbuntuTestCase(file, assertOnFailure, parent)
35 {36 {
36 }37 }
3738
@@ -741,6 +742,101 @@
741 QScopedPointer<ThemeTestCase> view(new ThemeTestCase("DeprecatedTheme.qml"));742 QScopedPointer<ThemeTestCase> view(new ThemeTestCase("DeprecatedTheme.qml"));
742 view->rootObject()->setProperty("styleName", "OptionSelectorStyle.qml");743 view->rootObject()->setProperty("styleName", "OptionSelectorStyle.qml");
743 }744 }
745
746 void test_stylehints_errors_data()
747 {
748 QTest::addColumn<QString>("document");
749 QTest::addColumn<int>("row");
750 QTest::addColumn<int>("col");
751 QTest::addColumn<QString>("xfail");
752
753 QTest::newRow("No signals")
754 << "StyleHintsWithSignal.qml" << 26 << 13 << "Signal properties are not supported. \n" \
755" onDefaultColorChanged: {} \n" \
756" ^";
757 QTest::newRow("No embedded objects")
758 << "StyleHintsWithObject.qml" << 26 << 26 << "StyleHints does not support creating state-specific objects. \n" \
759" anyProperty: QtObject{} \n" \
760" ^";
761 QTest::newRow("StyleHints declared elsewhere")
762 << "StyleHintsElsewhere.qml" << 24 << 5 << "QML StyleHints: StyleHints must be declared in a StyledItem or a derivate of it.";
763 QTest::newRow("Invalid property")
764 << "StyleHintsInvalidProperty.qml" << 25 << 9 << "QML StyleHints: Style 'ButtonStyle' has no property called 'invalidProperty'.";
765 }
766 void test_stylehints_errors()
767 {
768 QFETCH(QString, document);
769 QFETCH(int, row);
770 QFETCH(int, col);
771 QFETCH(QString, xfail);
772
773 if (!xfail.isEmpty()) {
774 ThemeTestCase::ignoreWarning(document, row, col, xfail);
775 }
776 QScopedPointer<ThemeTestCase> view(new ThemeTestCase(document, false));
777 }
778
779 void test_stylehints_simple_property()
780 {
781 QScopedPointer<ThemeTestCase> view(new ThemeTestCase("SimplePropertyHints.qml"));
782 QQuickItem *button = view->findItem<QQuickItem*>("Button");
783 QColor color = button->property("color").value<QColor>();
784 QCOMPARE(color, QColor("blue"));
785 }
786
787 void test_stylehints_bindings()
788 {
789 QScopedPointer<ThemeTestCase> view(new ThemeTestCase("PropertyBindingHints.qml"));
790 QQuickItem *button = view->findItem<QQuickItem*>("Button");
791 QColor color = button->property("color").value<QColor>();
792 QCOMPARE(color, QColor("blue"));
793 // press the button
794 QPointF pressPt(button->width()/2, button->height()/2);
795 pressPt = view->rootObject()->mapFromItem(button, pressPt);
796 QTest::mousePress(view.data(), Qt::LeftButton, 0, pressPt.toPoint());
797 color = button->property("color").value<QColor>();
798 QCOMPARE(color, QColor("tan"));
799 QTest::mouseRelease(view.data(), Qt::LeftButton, 0, pressPt.toPoint());
800 }
801
802 void test_stylehints_multiple_data()
803 {
804 QTest::addColumn<QString>("document");
805 QTest::addColumn<QString>("colorProperty");
806 QTest::addColumn<QColor>("colorReleased");
807 QTest::addColumn<QColor>("colorPressed");
808 QTest::addColumn<QString>("widthProperty");
809 QTest::addColumn<float>("width");
810
811 QTest::newRow("Same document")
812 << "MoreStyleHints.qml" << "defaultColor" << QColor("brown") << QColor("brown") << "minimumWidth" << UCUnits::instance().gu(20);
813 QTest::newRow("Different document")
814 << "GroupPropertyBindingHints.qml" << "gradientProxy.topColor" << QColor("blue") << QColor("tan") << "minimumWidth" << UCUnits::instance().gu(20);
815 }
816 void test_stylehints_multiple()
817 {
818 QFETCH(QString, document);
819 QFETCH(QString, colorProperty);
820 QFETCH(QColor, colorReleased);
821 QFETCH(QColor, colorPressed);
822 QFETCH(QString, widthProperty);
823 QFETCH(float, width);
824
825 QScopedPointer<ThemeTestCase> view(new ThemeTestCase(document));
826 UCStyledItemBase *button = view->findItem<UCStyledItemBase*>("Button");
827 QQuickItem *styleItem = UCStyledItemBasePrivate::get(button)->styleItem;
828 QVERIFY(styleItem);
829 QQmlProperty qmlProperty(styleItem, colorProperty, qmlContext(styleItem));
830 QCOMPARE(qmlProperty.read().value<QColor>(), colorReleased);
831 QCOMPARE(styleItem->property(widthProperty.toUtf8()).toReal(), width);
832
833 QPointF pressPt(button->width()/2, button->height()/2);
834 pressPt = view->rootObject()->mapFromItem(button, pressPt);
835 QTest::mousePress(view.data(), Qt::LeftButton, 0, pressPt.toPoint());
836 QColor pressedColor = qmlProperty.read().value<QColor>();
837 QTest::mouseRelease(view.data(), Qt::LeftButton, 0, pressPt.toPoint());
838 QCOMPARE(pressedColor, colorPressed);
839 }
744};840};
745841
746QTEST_MAIN(tst_Subtheming)842QTEST_MAIN(tst_Subtheming)
747843
=== modified file 'tests/unit_x11/tst_subtheming/tst_subtheming.pro'
--- tests/unit_x11/tst_subtheming/tst_subtheming.pro 2015-05-22 13:54:38 +0000
+++ tests/unit_x11/tst_subtheming/tst_subtheming.pro 2015-06-02 15:25:00 +0000
@@ -33,6 +33,16 @@
33 DeprecatedTheme.qml \33 DeprecatedTheme.qml \
34 StyledItemAppThemeVersioned.qml \34 StyledItemAppThemeVersioned.qml \
35 StyleOverride.qml \35 StyleOverride.qml \
36 StyleKept.qml36 StyleKept.qml \
37 SimplePropertyHints.qml \
38 StyleHintsWithSignal.qml \
39 StyleHintsWithObject.qml \
40 StyleHintsElsewhere.qml \
41 StyleHintsInvalidProperty.qml \
42 PropertyBindingHints.qml \
43 MoreStyleHints.qml \
44 GroupPropertyBindingHints.qml \
45 OverrideStyleHints.qml \
46 HintedButton.qml
3747
3848

Subscribers

People subscribed via source and target branches