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 return "["_L1 + enumToString(state) +
"]"_L1;
123QString
QQStyleKitDebug::styleReaderToString(
const QQStyleKitReader *reader)
125 return "StyleKitReader"_L1 + stateToString(reader->controlState());
128QString
QQStyleKitDebug::controlToString(
const QQStyleKitControlProperties *control)
130 if (!control->objectName().isEmpty())
131 return control->objectName();
133 const QObject *parentObj = control->parent();
135 return "<no parent>"_L1;
137 auto *controls = qobject_cast<
const QQStyleKitControls *>(parentObj);
139 return "<"_L1 + QString::fromUtf8(parentObj->metaObject()->className()) +
">"_L1;
141 const int startIndex = QQStyleKitControls::staticMetaObject.propertyOffset();
142 const int endIndex = QQStyleKitControls::staticMetaObject.propertyCount();
144 const QMetaObject* parentMeta = parentObj->metaObject();
145 for (
int i = startIndex; i < endIndex; ++i) {
146 const QMetaProperty prop = parentMeta->property(i);
147 const QMetaObject* typeMeta = QMetaType::fromName(prop.typeName()).metaObject();
148 if (!typeMeta || !typeMeta->inherits(&QQStyleKitControl::staticMetaObject))
151 QObject *propObj = prop.read(parentObj).value<QObject *>();
152 if (propObj == control)
153 return QString::fromUtf8(prop.name());
156 return "<unknown control>"_L1;
159QString
QQStyleKitDebug::objectPath(
const QQStyleKitControlProperties *properties, QObject *from)
162 const QObject *obj = properties;
168 if (
auto *theme = qobject_cast<
const QQStyleKitCustomTheme *>(obj)) {
169 path.prepend(theme->name() + kDot);
170 }
else if (
auto *theme = qobject_cast<
const QQStyleKitTheme *>(obj)) {
173 path.prepend(
"Theme("_L1 + theme->style()->m_effectiveThemeName +
")"_L1);
175 path.prepend(
"Theme(Unknown Style)"_L1);
176 }
else if (
auto *variation = qobject_cast<
const QQStyleKitVariation *>(obj)) {
177 path.prepend(
"StyleVariation("_L1 + variation->name() +
")"_L1);
178 }
else if (
auto *control = qobject_cast<
const QQStyleKitControl *>(obj)) {
179 path.prepend(controlToString(control));
180 }
else if (
auto *reader = qobject_cast<
const QQStyleKitReader *>(obj)) {
181 path.prepend(styleReaderToString(reader));
183 path.prepend(objectName(obj));
197 const QQStyleKitControlProperties *storage,
198 const QQSK::State state,
199 const QVariant &value)
204 if (reader->subclass() == QQSK::Subclass::QQStyleKitState) {
206
207
211 if (!insideControl(reader)) {
216 const QString _readerPath = objectPath(reader, m_item);
217 const QString _readPropertyPath = property.toString();
218 const QString queriedPath = _readerPath + kDot +_readPropertyPath;
221 if (storage->subclass() == QQSK::Subclass::QQStyleKitReader) {
223
224
226 storagePath =
"[local storage] "_L1;
231 const QString _controlPathInStyle = objectPath(storage, storage->style());
232 const QString _statePath = stateToString(state);
233 storagePath = _controlPathInStyle + _statePath;
236 QString valueString = value.toString();
237 if (!value.isValid())
238 valueString =
"<undefined>"_L1;
239 else if (valueString.isEmpty())
240 valueString =
"<object>"_L1;
242 const QString output = queriedPath +
" -> "_L1 + storagePath +
" = "_L1 + valueString;
244 if (!QRegularExpression(m_filter).match(output).hasMatch())
247 qDebug().nospace().noquote() << m_outputCount++ <<
" | [read] "_L1 << output;
252 const QQSK::Property property,
253 const QQStyleKitControlProperties *storage,
254 const QQSK::State state,
255 const PropertyStorageId key,
256 const QVariant &value)
267
269 if (storage->subclass() == QQSK::Subclass::QQStyleKitReader) {
270 storagePath =
"[local storage]"_L1;
272 const QString _controlPathInStyle = objectPath(storage, storage->style());
273 const QString _statePath = stateToString(state);
274 storagePath = _controlPathInStyle + _statePath;
277 QString valueString = value.toString();
278 if (!value.isValid())
279 valueString =
"<undefined>"_L1;
280 else if (valueString.isEmpty())
281 valueString =
"<object>"_L1;
283 const QString path = property.toString();
284 const QString output = storagePath + kDot + path +
" (storage key:"_L1 + QString::number(key) +
") = "_L1 + valueString;
286 qDebug().nospace().noquote() << m_outputCount++ <<
" | [write] "_L1 << output;
293 if (!insideControl(reader)) {
298 const QString _readerPath = objectPath(reader, m_item);
299 const QString _propertyPath = property.toString();
300 const QString queriedPath = _readerPath + kDot +_propertyPath;
301 const QString output = queriedPath +
" -> <property not set>"_L1;
303 if (!QRegularExpression(m_filter).match(output).hasMatch())
306 qDebug().nospace().noquote() << m_outputCount++ <<
" | [read] "_L1 << output;
311 const QQStyleKitControlProperties *storage,
312 const QQSK::State state,
313 const PropertyStorageId key)
321 const QQStyleKitControlProperties *reader = QQStyleKitDebug::groupBeingRead->controlProperties();
322 if (reader->subclass() == QQSK::Subclass::QQStyleKitState) {
324
325
329 if (!insideControl(reader)) {
334 const QString _readerPath = objectPath(reader, m_item);
335 const QString _readPropertyPath = property.toString();
336 const QString queriedPath = _readerPath + kDot +_readPropertyPath;
339 if (storage->subclass() == QQSK::Subclass::QQStyleKitReader) {
341
342
344 storagePath =
"[local storage]"_L1;
349 const QString _controlPathInStyle = objectPath(storage, storage->style());
350 const QString _statePath = stateToString(state);
351 storagePath = _controlPathInStyle + _statePath;
354 const QString output = queriedPath +
", checking "_L1 + storagePath +
" (storage key:"_L1 + QString::number(key)+
")"_L1;
356 if (!QRegularExpression(m_filter).match(output).hasMatch())
359 qDebug().nospace().noquote() << m_outputCount++ <<
" | [trace] "_L1 << output;
374 emit controlChanged();
384 if (m_filter == filter)
388 emit filterChanged();
395 const QObject *obj = child;
406#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.