14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
51
52
53
54
55
56
57
58
59
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
94template <
typename EnumType>
97 auto propertyMetaEnum = QMetaEnum::fromType<EnumType>();
98 return QString::fromUtf8(propertyMetaEnum.valueToKeys(quint64(enumValue)));
102 if (!obj->objectName().isEmpty())
103 return obj->objectName();
105 QString str = QString::fromLatin1(obj->metaObject()->className());
106 int idx = str.indexOf(
"_QMLTYPE"_L1);
110 const QString prefix(
"QQStyleKit"_L1);
111 if (str.startsWith(prefix))
112 str = str.mid(prefix.length());
120 const QStringList list = enumToString(state).split(
'|'_L1);
121 return "["_L1 + list.join(
','_L1) +
"]"_L1;
124QString
QQStyleKitDebug::styleReaderToString(
const QQStyleKitReader *reader)
126 return "StyleKitReader"_L1 + stateToString(reader->controlState());
131 const QString path = group->pathToString();
132 QString propertyName = enumToString(property.property());
133 propertyName[0] = propertyName[0].toLower();
136 return path + kDot + propertyName;
139QString
QQStyleKitDebug::controlToString(
const QQStyleKitControlProperties *control)
141 if (!control->objectName().isEmpty())
142 return control->objectName();
144 const QObject *parentObj = control->parent();
146 return "<no parent>"_L1;
150 return "<"_L1 + QString::fromUtf8(parentObj->metaObject()->className()) +
">"_L1;
152 const int startIndex = QQStyleKitControls::staticMetaObject.propertyOffset();
153 const int endIndex = QQStyleKitControls::staticMetaObject.propertyCount();
155 const QMetaObject* parentMeta = parentObj->metaObject();
156 for (
int i = startIndex; i < endIndex; ++i) {
157 const QMetaProperty prop = parentMeta->property(i);
158 const QMetaObject* typeMeta = QMetaType::fromName(prop.typeName()).metaObject();
159 if (!typeMeta || !typeMeta->inherits(&QQStyleKitControl::staticMetaObject))
162 QObject *propObj = prop.read(parentObj).value<QObject *>();
163 if (propObj == control)
164 return QString::fromUtf8(prop.name());
167 return "<unknown control>"_L1;
170QString
QQStyleKitDebug::objectPath(
const QQStyleKitControlProperties *properties, QObject *from)
173 const QObject *obj = properties;
179 if (
auto *theme = qobject_cast<
const QQStyleKitCustomTheme *>(obj)) {
180 path.prepend(theme->name() + kDot);
181 }
else if (
auto *theme = qobject_cast<
const QQStyleKitTheme *>(obj)) {
183 path.prepend(
"Theme("_L1 + theme->style()->m_effectiveThemeName +
")"_L1);
184 }
else if (
auto *variation = qobject_cast<
const QQStyleKitVariation *>(obj)) {
185 path.prepend(
"StyleVariation("_L1 + variation->name() +
")"_L1);
186 }
else if (
auto *control = qobject_cast<
const QQStyleKitControl *>(obj)) {
187 path.prepend(controlToString(control));
188 }
else if (
auto *reader = qobject_cast<
const QQStyleKitReader *>(obj)) {
189 path.prepend(styleReaderToString(reader));
191 path.prepend(objectName(obj));
205 const QQStyleKitControlProperties *storage,
206 const QQSK::State state,
207 const QVariant &value)
212 if (reader->subclass() == QQSK::Subclass::QQStyleKitState) {
214
215
219 if (!insideControl(reader)) {
224 const QString _readerPath = objectPath(reader, m_item);
225 const QString _readPropertyPath = propertyPath(QQStyleKitDebug::groupBeingRead, property);
226 const QString queriedPath = _readerPath + kDot +_readPropertyPath;
229 if (storage->subclass() == QQSK::Subclass::QQStyleKitReader) {
231
232
234 storagePath =
"[local storage] "_L1;
239 const QString _controlPathInStyle = objectPath(storage, storage->style());
240 const QString _statePath = stateToString(state);
241 storagePath = _controlPathInStyle + _statePath;
244 QString valueString = value.toString();
245 if (!value.isValid())
246 valueString =
"<undefined>"_L1;
247 else if (valueString.isEmpty())
248 valueString =
"<object>"_L1;
250 const QString output = queriedPath +
" -> "_L1 + storagePath +
" = "_L1 + valueString;
252 if (!QRegularExpression(m_filter).match(output).hasMatch())
255 qDebug().nospace().noquote() << m_outputCount++ <<
" | [read] "_L1 << output;
260 const QQSK::Property property,
261 const QQStyleKitControlProperties *storage,
262 const QQSK::State state,
263 const PropertyStorageId key,
264 const QVariant &value)
275
277 if (storage->subclass() == QQSK::Subclass::QQStyleKitReader) {
278 storagePath =
"[local storage]"_L1;
280 const QString _controlPathInStyle = objectPath(storage, storage->style());
281 const QString _statePath = stateToString(state);
282 storagePath = _controlPathInStyle + _statePath;
285 QString valueString = value.toString();
286 if (!value.isValid())
287 valueString =
"<undefined>"_L1;
288 else if (valueString.isEmpty())
289 valueString =
"<object>"_L1;
291 const QString path = propertyPath(group, property);
292 const QString output = storagePath + kDot + path +
" (storage key:"_L1 + QString::number(key) +
") = "_L1 + valueString;
294 qDebug().nospace().noquote() << m_outputCount++ <<
" | [write] "_L1 << output;
301 if (!insideControl(reader)) {
306 const QString _readerPath = objectPath(reader, m_item);
307 const QString _propertyPath = propertyPath(QQStyleKitDebug::groupBeingRead, property);
308 const QString queriedPath = _readerPath + kDot +_propertyPath;
309 const QString output = queriedPath +
" -> <property not set>"_L1;
311 if (!QRegularExpression(m_filter).match(output).hasMatch())
314 qDebug().nospace().noquote() << m_outputCount++ <<
" | [read] "_L1 << output;
319 const QQStyleKitControlProperties *storage,
320 const QQSK::State state,
321 const PropertyStorageId key)
329 const QQStyleKitControlProperties *reader = QQStyleKitDebug::groupBeingRead->controlProperties();
330 if (reader->subclass() == QQSK::Subclass::QQStyleKitState) {
332
333
337 if (!insideControl(reader)) {
342 const QString _readerPath = objectPath(reader, m_item);
343 const QString _readPropertyPath = propertyPath(QQStyleKitDebug::groupBeingRead, property);
344 const QString queriedPath = _readerPath + kDot +_readPropertyPath;
347 if (storage->subclass() == QQSK::Subclass::QQStyleKitReader) {
349
350
352 storagePath =
"[local storage]"_L1;
357 const QString _controlPathInStyle = objectPath(storage, storage->style());
358 const QString _statePath = stateToString(state);
359 storagePath = _controlPathInStyle + _statePath;
362 const QString output = queriedPath +
", checking "_L1 + storagePath +
" (storage key:"_L1 + QString::number(key)+
")"_L1;
364 if (!QRegularExpression(m_filter).match(output).hasMatch())
367 qDebug().nospace().noquote() << m_outputCount++ <<
" | [trace] "_L1 << output;
382 emit controlChanged();
392 if (m_filter == filter)
396 emit filterChanged();
403 const QObject *obj = child;
414#include "moc_qqstylekitdebug_p.cpp"
void setFilter(const QString &filter)
void setControl(QQuickItem *item)
QQStyleKitControlProperties * controlProperties() const
Combined button and popup list for selecting options.