From 942e6cc13ac199223068291722be344ce777000d Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Mon, 30 May 2022 20:03:56 +0200 Subject: [PATCH] iotdashboard enabled for Qt6 ( BoxShadowNode #ifdef'd for the moment ) --- examples/examples.pro | 11 ++--------- examples/iotdashboard/LightDisplaySkinlet.cpp | 11 ++++++++--- examples/iotdashboard/ShadowedBox.cpp | 7 ++++++- examples/iotdashboard/iotdashboard.pro | 11 +++++++++-- 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/examples/examples.pro b/examples/examples.pro index a2698bd4..2148d806 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -9,15 +9,8 @@ SUBDIRS += \ messagebox \ mycontrols \ thumbnails \ - tabview - -lessThan(QT_MAJOR_VERSION, 6) { - - # the shader for the drop shadows has not yet been migrated - # to work with Qt 6 - - SUBDIRS += iotdashboard -} + tabview \ + iotdashboard qtHaveModule(svg) { diff --git a/examples/iotdashboard/LightDisplaySkinlet.cpp b/examples/iotdashboard/LightDisplaySkinlet.cpp index fd560cf8..e53b11b0 100644 --- a/examples/iotdashboard/LightDisplaySkinlet.cpp +++ b/examples/iotdashboard/LightDisplaySkinlet.cpp @@ -6,7 +6,10 @@ #include "LightDisplaySkinlet.h" #include "LightDisplay.h" -#include "nodes/BoxShadowNode.h" +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) + #include "nodes/BoxShadowNode.h" +#endif + #include "nodes/RadialTickmarksNode.h" #include @@ -72,7 +75,7 @@ QRectF LightDisplaySkinlet::subControlRect( const QskSkinnable* skinnable, { QRectF valueTextRect = subControlRect( skinnable, contentsRect, LightDisplay::Panel ); const QFontMetricsF fm( skinnable->effectiveFont( subControl ) ); - const qreal fontWidth = fm.width( QStringLiteral( "100 %" ) ); + const qreal fontWidth = qskHorizontalAdvance( fm, QStringLiteral( "100 %" ) ); const QPointF center = valueTextRect.center(); const QRectF rect( center.x() - fontWidth / 2, center.y() - fm.height() / 2, fontWidth, fm.height() ); return rect; @@ -134,6 +137,7 @@ QSGNode* LightDisplaySkinlet::updateSubNode( { return updateBoxNode( skinnable, node, LightDisplay::Panel ); } +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) case GrooveRole: { const QRectF grooveRect = display->subControlRect( LightDisplay::Groove ); @@ -156,6 +160,7 @@ QSGNode* LightDisplaySkinlet::updateSubNode( return shadowNode; } +#endif case ColdAndWarmArcRole: { return updateArcNode( skinnable, node, LightDisplay::ColdAndWarmArc ); @@ -209,7 +214,7 @@ QSizeF LightDisplaySkinlet::textLabelsSize( const LightDisplay* display ) const { const QFontMetricsF fm( display->effectiveFont( LightDisplay::LeftLabel ) ); - qreal w = fm.width( QStringLiteral( " 100" ) ); + qreal w = qskHorizontalAdvance( fm, QStringLiteral( " 100" ) ); qreal h = fm.height(); return { w, h }; diff --git a/examples/iotdashboard/ShadowedBox.cpp b/examples/iotdashboard/ShadowedBox.cpp index edf8dbc7..73ab0957 100644 --- a/examples/iotdashboard/ShadowedBox.cpp +++ b/examples/iotdashboard/ShadowedBox.cpp @@ -4,7 +4,10 @@ *****************************************************************************/ #include "ShadowedBox.h" -#include "nodes/BoxShadowNode.h" + +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) + #include "nodes/BoxShadowNode.h" +#endif #include #include @@ -47,6 +50,7 @@ namespace switch ( nodeRole ) { +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) case ShadowRole: { auto shadowNode = static_cast< BoxShadowNode* >( node ); @@ -65,6 +69,7 @@ namespace return shadowNode; } +#endif case PanelRole: { auto boxNode = static_cast< QskBoxNode* >( node ); diff --git a/examples/iotdashboard/iotdashboard.pro b/examples/iotdashboard/iotdashboard.pro index 1669d26d..cd9036e3 100644 --- a/examples/iotdashboard/iotdashboard.pro +++ b/examples/iotdashboard/iotdashboard.pro @@ -30,7 +30,6 @@ SOURCES += \ main.cpp \ SOURCES += \ - nodes/BoxShadowNode.cpp \ nodes/DiagramDataNode.cpp \ nodes/DiagramSegmentsNode.cpp \ nodes/RadialTickmarksNode.cpp @@ -61,11 +60,19 @@ HEADERS += \ UsageDiagram.h HEADERS += \ - nodes/BoxShadowNode.h \ nodes/DiagramDataNode.h \ nodes/DiagramSegmentsNode.h \ nodes/RadialTickmarksNode.h +lessThan(QT_MAJOR_VERSION, 6) { + + # the shader for the drop shadows has not yet been migrated + # to work with Qt 6 + + SOURCES += nodes/BoxShadowNode.cpp + HEADERS += nodes/BoxShadowNode.h +} + RESOURCES += \ images.qrc \ fonts.qrc \