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;
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)) {
172 path.prepend(
"Theme("_L1 + theme->style()->m_effectiveThemeName +
")"_L1);
173 }
else if (
auto *variation = qobject_cast<
const QQStyleKitVariation *>(obj)) {
174 path.prepend(
"StyleVariation("_L1 + variation->name() +
")"_L1);
175 }
else if (
auto *control = qobject_cast<
const QQStyleKitControl *>(obj)) {
176 path.prepend(controlToString(control));
177 }
else if (
auto *reader = qobject_cast<
const QQStyleKitReader *>(obj)) {
178 path.prepend(styleReaderToString(reader));
180 path.prepend(objectName(obj));
194 const QQStyleKitControlProperties *storage,
195 const QQSK::State state,
196 const QVariant &value)
201 if (reader->subclass() == QQSK::Subclass::QQStyleKitState) {
203
204
208 if (!insideControl(reader)) {
213 const QString _readerPath = objectPath(reader, m_item);
214 const QString _readPropertyPath = property.toString();
215 const QString queriedPath = _readerPath + kDot +_readPropertyPath;
218 if (storage->subclass() == QQSK::Subclass::QQStyleKitReader) {
220
221
223 storagePath =
"[local storage] "_L1;
228 const QString _controlPathInStyle = objectPath(storage, storage->style());
229 const QString _statePath = stateToString(state);
230 storagePath = _controlPathInStyle + _statePath;
233 QString valueString = value.toString();
234 if (!value.isValid())
235 valueString =
"<undefined>"_L1;
236 else if (valueString.isEmpty())
237 valueString =
"<object>"_L1;
239 const QString output = queriedPath +
" -> "_L1 + storagePath +
" = "_L1 + valueString;
241 if (!QRegularExpression(m_filter).match(output).hasMatch())
244 qDebug().nospace().noquote() << m_outputCount++ <<
" | [read] "_L1 << output;
249 const QQSK::Property property,
250 const QQStyleKitControlProperties *storage,
251 const QQSK::State state,
252 const PropertyStorageId key,
253 const QVariant &value)
264
266 if (storage->subclass() == QQSK::Subclass::QQStyleKitReader) {
267 storagePath =
"[local storage]"_L1;
269 const QString _controlPathInStyle = objectPath(storage, storage->style());
270 const QString _statePath = stateToString(state);
271 storagePath = _controlPathInStyle + _statePath;
274 QString valueString = value.toString();
275 if (!value.isValid())
276 valueString =
"<undefined>"_L1;
277 else if (valueString.isEmpty())
278 valueString =
"<object>"_L1;
280 const QString path = property.toString();
281 const QString output = storagePath + kDot + path +
" (storage key:"_L1 + QString::number(key) +
") = "_L1 + valueString;
283 qDebug().nospace().noquote() << m_outputCount++ <<
" | [write] "_L1 << output;
290 if (!insideControl(reader)) {
295 const QString _readerPath = objectPath(reader, m_item);
296 const QString _propertyPath = property.toString();
297 const QString queriedPath = _readerPath + kDot +_propertyPath;
298 const QString output = queriedPath +
" -> <property not set>"_L1;
300 if (!QRegularExpression(m_filter).match(output).hasMatch())
303 qDebug().nospace().noquote() << m_outputCount++ <<
" | [read] "_L1 << output;
308 const QQStyleKitControlProperties *storage,
309 const QQSK::State state,
310 const PropertyStorageId key)
318 const QQStyleKitControlProperties *reader = QQStyleKitDebug::groupBeingRead->controlProperties();
319 if (reader->subclass() == QQSK::Subclass::QQStyleKitState) {
321
322
326 if (!insideControl(reader)) {
331 const QString _readerPath = objectPath(reader, m_item);
332 const QString _readPropertyPath = property.toString();
333 const QString queriedPath = _readerPath + kDot +_readPropertyPath;
336 if (storage->subclass() == QQSK::Subclass::QQStyleKitReader) {
338
339
341 storagePath =
"[local storage]"_L1;
346 const QString _controlPathInStyle = objectPath(storage, storage->style());
347 const QString _statePath = stateToString(state);
348 storagePath = _controlPathInStyle + _statePath;
351 const QString output = queriedPath +
", checking "_L1 + storagePath +
" (storage key:"_L1 + QString::number(key)+
")"_L1;
353 if (!QRegularExpression(m_filter).match(output).hasMatch())
356 qDebug().nospace().noquote() << m_outputCount++ <<
" | [trace] "_L1 << output;
371 emit controlChanged();
381 if (m_filter == filter)
385 emit filterChanged();
392 const QObject *obj = child;
403#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.