aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/nativestyle/items/qquickstyleitem.cpp
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2020-06-10 21:19:50 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2020-06-11 11:53:28 +0000
commit5c48daa014171e0c40a2511750a9d9a27d057399 (patch)
tree60a149d216616790fa8d1a2663406e3056ff5f4d /src/imports/nativestyle/items/qquickstyleitem.cpp
parent501dfdfe77213a32d29cd14612f30834f83dceed (diff)
Native style: make the debug flags more type safe
Take the opportunity to clean up the flags a bit, and improve how we print the options to the console. Change-Id: Ia6e81453bfd53a5bfe6328b7cb8f6abcbf2dbed1 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/imports/nativestyle/items/qquickstyleitem.cpp')
-rw-r--r--src/imports/nativestyle/items/qquickstyleitem.cpp64
1 files changed, 24 insertions, 40 deletions
diff --git a/src/imports/nativestyle/items/qquickstyleitem.cpp b/src/imports/nativestyle/items/qquickstyleitem.cpp
index c536c3d0..c3aaa9a9 100644
--- a/src/imports/nativestyle/items/qquickstyleitem.cpp
+++ b/src/imports/nativestyle/items/qquickstyleitem.cpp
@@ -313,48 +313,32 @@ void QQuickStyleItem::componentComplete()
#ifdef QT_DEBUG
if (!qEnvironmentVariable("QQC2_NATIVESTYLE_DEBUG").isEmpty()) {
// Set objectName to "debug" pluss one or more options separated
- // by space to show extra information about this item. Note that
- // some of the options cannot be shown unless we switch off using
- // nine patch image scaling.
- const QString name = m_control->objectName();
- if (name.startsWith(QLatin1String("debug"))) {
- if (name.contains(QStringLiteral("output"))) {
- m_debugFlags.setFlag(PrintOutput);
- qDebug() << "debug: setting PrintOutput";
- }
- if (name.contains(QStringLiteral("imagerect"))) {
- m_debugFlags.setFlag(ShowImageRect);
- qDebug() << "debug: setting ShowImageRect";
- }
- if (name.contains(QStringLiteral("contentrect"))) {
- m_debugFlags.setFlag(ShowContentRect);
- m_useNinePatchImage = false;
- qDebug() << "debug: setting ShowContentRect";
- qDebug() << "debug: setting useNinePatchImage to false";
- }
- if (name.contains(QStringLiteral("layoutrect"))) {
- m_debugFlags.setFlag(ShowLayoutRect);
- m_useNinePatchImage = false;
- qDebug() << "debug: setting ShowLayoutRect";
- qDebug() << "debug: setting useNinePatchImage to false";
- }
- if (name.contains(QStringLiteral("inputcontentsize"))) {
- m_debugFlags.setFlag(ShowInputContentSize);
- m_useNinePatchImage = false;
- qDebug() << "debug: setting ShowInputContentSize";
- qDebug() << "debug: setting useNinePatchImage to false";
- }
- if (name.contains(QStringLiteral("dontuseninepatchimage"))) {
+ // by space to show extra information about this item.
+
+#define QQC2_DEBUG_FLAG(FLAG) \
+ if (name.contains(QString(QLatin1String(#FLAG)).toLower())) m_debugFlags |= FLAG
+
+ const QString name = m_control->objectName().toLower();
+ if (name.startsWith(QString(QLatin1String("debug")).toLower())) {
+ QQC2_DEBUG_FLAG(Output);
+ QQC2_DEBUG_FLAG(ShowImageRect);
+ QQC2_DEBUG_FLAG(ShowContentRect);
+ QQC2_DEBUG_FLAG(ShowLayoutRect);
+ QQC2_DEBUG_FLAG(ShowInputContentSize);
+ QQC2_DEBUG_FLAG(DontUseNinePatchImage);
+ QQC2_DEBUG_FLAG(ShowUnscaled);
+
+ if (m_debugFlags & (DontUseNinePatchImage | ShowInputContentSize | ShowContentRect | ShowLayoutRect)) {
+ // Some rects will not fit inside the drawn image unless
+ // we switch off (nine patch) image scaling.
+ m_debugFlags |= DontUseNinePatchImage;
m_useNinePatchImage = false;
- qDebug() << "debug: setting useNinePatchImage to false";
}
- if (name.contains(QStringLiteral("unscaled"))) {
- m_debugFlags.setFlag(ShowUnscaled);
- qDebug() << "debug: setting ShowUnscaled";
- }
- if (m_debugFlags == NoDebug)
- qDebug() << "debug options: output, imagerect, contentrect"
- << "layoutrect, unscaled, inputcontentsize, dontuseninepatchimage";
+
+ if (m_debugFlags != NoDebug)
+ qDebug() << "debug options set:" << m_debugFlags;
+ else
+ qDebug() << "available debug options:" << DebugFlags(0xFFFF);
}
}
#endif