From 3763bd5bad6751a4f11ecfc3d9a318003255c933 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Wed, 3 Aug 2022 09:40:18 +0200 Subject: [PATCH] minor changes --- .../CircularProgressBarSkinlet.cpp | 9 ++---- examples/iotdashboard/MainItem.cpp | 29 ++++++++++--------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/examples/iotdashboard/CircularProgressBarSkinlet.cpp b/examples/iotdashboard/CircularProgressBarSkinlet.cpp index 737cedd3..02804dcd 100644 --- a/examples/iotdashboard/CircularProgressBarSkinlet.cpp +++ b/examples/iotdashboard/CircularProgressBarSkinlet.cpp @@ -6,11 +6,6 @@ #include "CircularProgressBarSkinlet.h" #include "CircularProgressBar.h" -#include - -#include -#include - CircularProgressBarSkinlet::CircularProgressBarSkinlet( QskSkin* skin ) : QskSkinlet( skin ) { @@ -38,9 +33,11 @@ QSGNode* CircularProgressBarSkinlet::updateSubNode( } case BarRole: { - const qreal startAngle = 90.0; const auto bar = static_cast< const CircularProgressBar* >( skinnable ); + + const qreal startAngle = 90.0; const qreal spanAngle = 360.0 * bar->valueAsRatio(); + return updateArcNode( skinnable, node, startAngle, -spanAngle, CircularProgressBar::Bar ); } diff --git a/examples/iotdashboard/MainItem.cpp b/examples/iotdashboard/MainItem.cpp index 6e283c24..9d483994 100644 --- a/examples/iotdashboard/MainItem.cpp +++ b/examples/iotdashboard/MainItem.cpp @@ -20,13 +20,17 @@ Cube::Cube( QQuickItem* parent ) void Cube::startAnimation( Qsk::Direction direction ) { - auto animator = dynamic_cast< QskStackBoxAnimator4* >( this->animator() ); + using Animator = QskStackBoxAnimator4; + + auto animator = qobject_cast< Animator* >( this->animator() ); if ( animator == nullptr ) { - animator = new QskStackBoxAnimator4( this ); + animator = new Animator( this ); animator->setEasingCurve( QEasingCurve::InOutQuad ); animator->setDuration( 1000 ); + + setAnimator( animator ); } const auto orientation = ( direction == Qsk::LeftToRight || direction == Qsk::RightToLeft ) @@ -36,20 +40,18 @@ void Cube::startAnimation( Qsk::Direction direction ) const bool inverted = ( direction == Qsk::LeftToRight || direction == Qsk::TopToBottom ); animator->setInverted( inverted ); - setAnimator( animator ); - int newIndex; switch( direction ) { - case Qsk::LeftToRight: - case Qsk::TopToBottom: - newIndex = currentIndex() + 1; - break; - case Qsk::RightToLeft: - case Qsk::BottomToTop: - newIndex = currentIndex() - 1; - break; + case Qsk::LeftToRight: + case Qsk::TopToBottom: + newIndex = currentIndex() + 1; + break; + case Qsk::RightToLeft: + case Qsk::BottomToTop: + newIndex = currentIndex() - 1; + break; } newIndex %= itemCount(); @@ -109,8 +111,7 @@ void MainItem::gestureEvent( QskGestureEvent* event ) direction = ( delta.y() < 0 ) ? Qsk::TopToBottom : Qsk::BottomToTop; } - // ### uncomment once animations are working: -// m_cube->startAnimation( direction ); + m_cube->startAnimation( direction ); } }