diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2020-06-11 15:40:10 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2020-06-12 08:01:14 +0000 |
commit | 6e1fed645d6461f5d1f49f91a8ce32b66638a004 (patch) | |
tree | 3bc87cd28aef40925894c86f21eb7ad5de6eaf18 | |
parent | 855475a8351b4619c272355371ef30ac771a01b7 (diff) |
Native style: remove prefix ('show', 'print') from the debug flags
Having them just complicates setting debug flags from QML.
Add a separate debug flag "NinePatchMargins" in the drive-by.
Change-Id: I56e1cc6f36368976b9325829816ab5a1bdb1f4ba
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
-rw-r--r-- | src/imports/nativestyle/items/qquickstyleitem.cpp | 31 | ||||
-rw-r--r-- | src/imports/nativestyle/items/qquickstyleitem.h | 13 |
2 files changed, 25 insertions, 19 deletions
diff --git a/src/imports/nativestyle/items/qquickstyleitem.cpp b/src/imports/nativestyle/items/qquickstyleitem.cpp index 350a143b..8c6df605 100644 --- a/src/imports/nativestyle/items/qquickstyleitem.cpp +++ b/src/imports/nativestyle/items/qquickstyleitem.cpp @@ -119,7 +119,7 @@ QSGNode *QQuickStyleItem::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePa const qreal scale = window()->devicePixelRatio(); const QSizeF ninePatchImageSize = m_paintedImage.rect().size() / scale; #ifdef QT_DEBUG - if (m_debugFlags.testFlag(ShowUnscaled)) { + if (m_debugFlags.testFlag(Unscaled)) { bounds = QRectF(QPointF(), ninePatchImageSize); qqc2Debug() << "Setting paint node bounds to size of image:" << bounds; } @@ -262,27 +262,27 @@ void QQuickStyleItem::paintControlToImage() #ifdef QT_DEBUG if (m_debugFlags != NoDebug) { painter.setPen(QColor(255, 0, 0, 255)); - if (m_debugFlags.testFlag(ShowImageRect)) + if (m_debugFlags.testFlag(ImageRect)) painter.drawRect(QRect(QPoint(0, 0), m_paintedImage.size() / scale)); - if (m_debugFlags.testFlag(ShowLayoutRect)) { + if (m_debugFlags.testFlag(LayoutRect)) { const auto m = layoutMargins(); QRect rect = QRect(QPoint(0, 0), m_paintedImage.size() / scale); rect.adjust(m.left(), m.top(), -m.right(), -m.bottom()); painter.drawRect(rect); } - if (m_debugFlags.testFlag(ShowContentRect)) { + if (m_debugFlags.testFlag(ContentRect)) { const auto p = contentPadding(); QRect rect = QRect(QPoint(0, 0), m_paintedImage.size() / scale); rect.adjust(p.left(), p.top(), -p.right(), -p.bottom()); painter.drawRect(rect); } - if (m_debugFlags.testFlag(ShowInputContentSize)) { + if (m_debugFlags.testFlag(InputContentSize)) { const int offset = 2; const QPoint p = m_styleItemGeometry.contentRect.topLeft(); painter.drawLine(p.x() - offset, p.y() - offset, p.x() + m_contentSize.width(), p.y() - offset); painter.drawLine(p.x() - offset, p.y() - offset, p.x() - offset, p.y() + m_contentSize.height()); } - if (m_debugFlags.testFlag(ShowUnscaled)) { + if (m_debugFlags.testFlag(NinePatchMargins)) { const QMargins m = m_styleItemGeometry.ninePatchMargins; const int w = int(m_paintedImage.rect().width() / scale); const int h = int(m_paintedImage.rect().height() / scale); @@ -329,14 +329,19 @@ void QQuickStyleItem::componentComplete() 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(ImageRect); + QQC2_DEBUG_FLAG(ContentRect); + QQC2_DEBUG_FLAG(LayoutRect); + QQC2_DEBUG_FLAG(InputContentSize); QQC2_DEBUG_FLAG(DontUseNinePatchImage); - QQC2_DEBUG_FLAG(ShowUnscaled); - - if (m_debugFlags & (DontUseNinePatchImage | ShowInputContentSize | ShowContentRect | ShowLayoutRect)) { + QQC2_DEBUG_FLAG(NinePatchMargins); + QQC2_DEBUG_FLAG(Unscaled); + + if (m_debugFlags & (DontUseNinePatchImage + | InputContentSize + | ContentRect + | LayoutRect + | NinePatchMargins)) { // Some rects will not fit inside the drawn image unless // we switch off (nine patch) image scaling. m_debugFlags |= DontUseNinePatchImage; diff --git a/src/imports/nativestyle/items/qquickstyleitem.h b/src/imports/nativestyle/items/qquickstyleitem.h index bf77c800..37e9dc3d 100644 --- a/src/imports/nativestyle/items/qquickstyleitem.h +++ b/src/imports/nativestyle/items/qquickstyleitem.h @@ -179,12 +179,13 @@ public: enum DebugFlag { NoDebug = 0x00, Output = 0x01, - ShowImageRect = 0x02, - ShowContentRect = 0x04, - ShowLayoutRect = 0x08, - ShowUnscaled = 0x10, - ShowInputContentSize = 0x20, - DontUseNinePatchImage = 0x40 + ImageRect = 0x02, + ContentRect = 0x04, + LayoutRect = 0x08, + Unscaled = 0x10, + InputContentSize = 0x20, + DontUseNinePatchImage = 0x40, + NinePatchMargins = 0x80 }; Q_FLAG(DebugFlag) Q_DECLARE_FLAGS(DebugFlags, DebugFlag) |