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
50
51
52
53
54
55
56
57
58
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
93template <
typename EnumType>
96 auto propertyMetaEnum = QMetaEnum::fromType<EnumType>();
97 return QString::fromUtf8(propertyMetaEnum.valueToKeys(quint64(enumValue)));
101 if (!obj->objectName().isEmpty())
102 return obj->objectName();
104 QString str = QString::fromLatin1(obj->metaObject()->className());
105 int idx = str.indexOf(
"_QMLTYPE"_L1);
109 const QString prefix(
"QQStyleKit"_L1);
110 if (str.startsWith(prefix))
111 str = str.mid(prefix.length());
119 const QStringList list = enumToString(state).split(
'|'_L1);
120 return "["_L1 + list.join(
','_L1) +
"]"_L1;
123QString
QQStyleKitDebug::styleReaderToString(
const QQStyleKitReader *reader)
125 return "StyleKitReader"_L1 + stateToString(reader->controlState());
130 const QString path = group->pathToString();
131 QString propertyName = enumToString(property.property());
132 propertyName[0] = propertyName[0].toLower();
135 return path + kDot + propertyName;
138QString
QQStyleKitDebug::controlToString(
const QQStyleKitControlProperties *control)
140 if (!control->objectName().isEmpty())
141 return control->objectName();
143 const QObject *parentObj = control->parent();
145 return "<no parent>"_L1;
149 return "<"_L1 + QString::fromUtf8(parentObj->metaObject()->className()) +
">"_L1;
151 const int startIndex = QQStyleKitControls::staticMetaObject.propertyOffset();
152 const int endIndex = QQStyleKitControls::staticMetaObject.propertyCount();
154 const QMetaObject* parentMeta = parentObj->metaObject();
155 for (
int i = startIndex; i < endIndex; ++i) {
156 const QMetaProperty prop = parentMeta->property(i);
157 const QMetaObject* typeMeta = QMetaType::fromName(prop.typeName()).metaObject();
158 if (!typeMeta || !typeMeta->inherits(&QQStyleKitControl::staticMetaObject))
161 QObject *propObj = prop.read(parentObj).value<QObject *>();
162 if (propObj == control)
163 return QString::fromUtf8(prop.name());
166 return "<unknown control>"_L1;
169QString
QQStyleKitDebug::objectPath(
const QQStyleKitControlProperties *properties, QObject *from)
172 const QObject *obj = properties;
178 if (
auto *theme = qobject_cast<
const QQStyleKitCustomTheme *>(obj)) {
179 path.prepend(theme->name() + kDot);
180 }
else if (
auto *theme = qobject_cast<
const QQStyleKitTheme *>(obj)) {
182 path.prepend(
"Theme("_L1 + theme->style()->m_effectiveThemeName +
")"_L1);
183 }
else if (
auto *variation = qobject_cast<
const QQStyleKitVariation *>(obj)) {
184 path.prepend(
"StyleVariation("_L1 + variation->name() +
")"_L1);
185 }
else if (
auto *control = qobject_cast<
const QQStyleKitControl *>(obj)) {
186 path.prepend(controlToString(control));
187 }
else if (
auto *reader = qobject_cast<
const QQStyleKitReader *>(obj)) {
188 path.prepend(styleReaderToString(reader));
190 path.prepend(objectName(obj));
204 const QQStyleKitControlProperties *storage,
205 const QQSK::State state,
206 const QVariant &value)
211 if (reader->subclass() == QQSK::Subclass::QQStyleKitState) {
213
214
218 if (!insideControl(reader)) {
223 const QString _readerPath = objectPath(reader, m_item);
224 const QString _readPropertyPath = propertyPath(QQStyleKitDebug::groupBeingRead, property);
225 const QString queriedPath = _readerPath + kDot +_readPropertyPath;
228 if (storage->subclass() == QQSK::Subclass::QQStyleKitReader) {
230
231
233 storagePath =
"[local storage] "_L1;
238 const QString _controlPathInStyle = objectPath(storage, storage->style());
239 const QString _statePath = stateToString(state);
240 storagePath = _controlPathInStyle + _statePath;
243 QString valueString = value.toString();
244 if (!value.isValid())
245 valueString =
"<undefined>"_L1;
246 else if (valueString.isEmpty())
247 valueString =
"<object>"_L1;
249 const QString output = queriedPath +
" -> "_L1 + storagePath +
" = "_L1 + valueString;
251 if (!QRegularExpression(m_filter).match(output).hasMatch())
254 qDebug().nospace().noquote() << m_outputCount++ <<
" | [read] "_L1 << output;
259 const QQSK::Property property,
260 const QQStyleKitControlProperties *storage,
261 const QQSK::State state,
262 const PropertyStorageId key,
263 const QVariant &value)
274
276 if (storage->subclass() == QQSK::Subclass::QQStyleKitReader) {
277 storagePath =
"[local storage]"_L1;
279 const QString _controlPathInStyle = objectPath(storage, storage->style());
280 const QString _statePath = stateToString(state);
281 storagePath = _controlPathInStyle + _statePath;
284 QString valueString = value.toString();
285 if (!value.isValid())
286 valueString =
"<undefined>"_L1;
287 else if (valueString.isEmpty())
288 valueString =
"<object>"_L1;
290 const QString path = propertyPath(group, property);
291 const QString output = storagePath + kDot + path +
" (storage key:"_L1 + QString::number(key) +
") = "_L1 + valueString;
293 qDebug().nospace().noquote() << m_outputCount++ <<
" | [write] "_L1 << output;
300 if (!insideControl(reader)) {
305 const QString _readerPath = objectPath(reader, m_item);
306 const QString _propertyPath = propertyPath(QQStyleKitDebug::groupBeingRead, property);
307 const QString queriedPath = _readerPath + kDot +_propertyPath;
308 const QString output = queriedPath +
" -> <property not set>"_L1;
310 if (!QRegularExpression(m_filter).match(output).hasMatch())
313 qDebug().nospace().noquote() << m_outputCount++ <<
" | [read] "_L1 << output;
318 const QQStyleKitControlProperties *storage,
319 const QQSK::State state,
320 const PropertyStorageId key)
328 const QQStyleKitControlProperties *reader = QQStyleKitDebug::groupBeingRead->controlProperties();
329 if (reader->subclass() == QQSK::Subclass::QQStyleKitState) {
331
332
336 if (!insideControl(reader)) {
341 const QString _readerPath = objectPath(reader, m_item);
342 const QString _readPropertyPath = propertyPath(QQStyleKitDebug::groupBeingRead, property);
343 const QString queriedPath = _readerPath + kDot +_readPropertyPath;
346 if (storage->subclass() == QQSK::Subclass::QQStyleKitReader) {
348
349
351 storagePath =
"[local storage]"_L1;
356 const QString _controlPathInStyle = objectPath(storage, storage->style());
357 const QString _statePath = stateToString(state);
358 storagePath = _controlPathInStyle + _statePath;
361 const QString output = queriedPath +
", checking "_L1 + storagePath +
" (storage key:"_L1 + QString::number(key)+
")"_L1;
363 if (!QRegularExpression(m_filter).match(output).hasMatch())
366 qDebug().nospace().noquote() << m_outputCount++ <<
" | [trace] "_L1 << output;
381 emit controlChanged();
391 if (m_filter == filter)
395 emit filterChanged();
402 const QObject *obj = child;
413#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.