From 658bc71891f4f7120967b4d592627086b4dc241b Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Tue, 4 Apr 2023 09:05:16 +0200 Subject: [PATCH] fixig pedantic compiler warnings --- playground/shapes/Stroke.cpp | 2 +- skins/material3/QskMaterial3Skin.cpp | 16 ++++++++-------- skins/squiek/QskSquiekSkin.cpp | 6 +++--- src/common/QskGradient.cpp | 2 +- src/common/QskGradientStop.cpp | 8 +++++--- src/common/QskScaleTickmarks.cpp | 6 ++++-- src/controls/QskPopup.cpp | 6 ++++-- src/controls/QskRadioBoxSkinlet.cpp | 3 ++- src/controls/QskSkin.cpp | 2 +- src/controls/QskSkinnable.cpp | 4 ++-- src/layouts/QskGridLayoutEngine.cpp | 12 ++++++------ src/nodes/QskBoxGradientStroker.cpp | 24 ++++++++++++------------ src/nodes/QskGradientMaterial.cpp | 8 ++++---- src/nodes/QskScaleRenderer.cpp | 6 +++++- 14 files changed, 58 insertions(+), 47 deletions(-) diff --git a/playground/shapes/Stroke.cpp b/playground/shapes/Stroke.cpp index 0336ee78..4e60725a 100644 --- a/playground/shapes/Stroke.cpp +++ b/playground/shapes/Stroke.cpp @@ -8,7 +8,7 @@ Stroke::Stroke( const QPen& pen ) noexcept : m_width( pen.widthF() ) - , m_miterLimit( pen.miterLimit() ) + , m_miterLimit( qRound( pen.miterLimit() ) ) , m_color( pen.color() ) , m_lineStyle( ( pen.style() == Qt::DashLine ) ? DashLine : SolidLine ) , m_joinStyle( static_cast< JoinStyle >( pen.joinStyle() ) ) diff --git a/skins/material3/QskMaterial3Skin.cpp b/skins/material3/QskMaterial3Skin.cpp index 32c3e4d2..9b889ebd 100644 --- a/skins/material3/QskMaterial3Skin.cpp +++ b/skins/material3/QskMaterial3Skin.cpp @@ -58,12 +58,12 @@ static const int qskDuration = 150; namespace { - inline double operator ""_dp( long double value ) + Q_DECL_UNUSED inline double operator ""_dp( long double value ) { return qskDpToPixels( static_cast< qreal >( value ) ); } - inline double operator ""_dp( unsigned long long value ) + Q_DECL_UNUSED inline double operator ""_dp( unsigned long long value ) { return qskDpToPixels( value ); } @@ -118,11 +118,11 @@ namespace const QskMaterial3Theme& m_pal; }; - QFont createFont( const QString& name, int lineHeight, - int size, qreal tracking, QFont::Weight weight ) + QFont createFont( const QString& name, qreal lineHeight, + qreal size, qreal tracking, QFont::Weight weight ) { - QFont font( name, size ); - font.setPixelSize( lineHeight ); + QFont font( name, qRound( size ) ); + font.setPixelSize( qRound( lineHeight ) ); if( !qskFuzzyCompare( tracking, 0.0 ) ) font.setLetterSpacing( QFont::AbsoluteSpacing, tracking ); @@ -490,8 +490,8 @@ void Editor::setupSegmentedBar() using A = QskAspect; using Q = QskSegmentedBar; - const QSize panelStrutSize( -1, 48_dp ); - const QSize segmentStrutSize( 48_dp, 40_dp ); + const QSizeF panelStrutSize( -1, 48_dp ); + const QSizeF segmentStrutSize( 48_dp, 40_dp ); { // Container diff --git a/skins/squiek/QskSquiekSkin.cpp b/skins/squiek/QskSquiekSkin.cpp index 7364a52a..a720ae53 100644 --- a/skins/squiek/QskSquiekSkin.cpp +++ b/skins/squiek/QskSquiekSkin.cpp @@ -53,12 +53,12 @@ static const int qskDuration = 200; namespace { - inline double operator ""_dp( long double value ) + Q_DECL_UNUSED inline double operator ""_dp( long double value ) { return qskDpToPixels( static_cast< qreal >( value ) ); } - inline double operator ""_dp( unsigned long long value ) + Q_DECL_UNUSED inline double operator ""_dp( unsigned long long value ) { return qskDpToPixels( value ); } @@ -571,7 +571,7 @@ void Editor::setupSegmentedBar() setBoxBorderColors( Q::Panel, borderColors ); - const QSize strutSize( 100_dp, 50_dp ); + const QSizeF strutSize( 100_dp, 50_dp ); setStrutSize( Q::Panel | A::Horizontal, strutSize ); setStrutSize( Q::Panel | A::Vertical, strutSize.transposed() ); diff --git a/src/common/QskGradient.cpp b/src/common/QskGradient.cpp index ff0d9b2e..c317aadf 100644 --- a/src/common/QskGradient.cpp +++ b/src/common/QskGradient.cpp @@ -327,7 +327,7 @@ int QskGradient::stepCount() const noexcept if ( !isValid() ) return 0; - int steps = m_stops.count() - 1; + auto steps = static_cast< int >( m_stops.count() ) - 1; if ( m_stops.first().position() > 0.0 ) steps++; diff --git a/src/common/QskGradientStop.cpp b/src/common/QskGradientStop.cpp index 94854c68..1181d621 100644 --- a/src/common/QskGradientStop.cpp +++ b/src/common/QskGradientStop.cpp @@ -102,8 +102,10 @@ QDebug operator<<( QDebug debug, const QskGradientStop& stop ) static inline QColor qskInterpolatedColor( const QskGradientStops& stops, int index1, int index2, qreal position ) { - index1 = qBound( 0, index1, stops.count() - 1 ); - index2 = qBound( 0, index2, stops.count() - 1 ); + const auto max = static_cast< int >( stops.count() ) - 1; + + index1 = qBound( 0, index1, max ); + index2 = qBound( 0, index2, max ); return QskGradientStop::interpolated( stops[ index1 ], stops[ index2 ], position ); } @@ -138,7 +140,7 @@ QskGradientStops qskTransparentGradientStops( const QskGradientStops& stops, qre for ( auto& stop : newStops ) { auto c = stop.color(); - c.setAlpha( c.alpha() * ratio ); + c.setAlpha( qRound( c.alpha() * ratio ) ); stop.setColor( c ); } diff --git a/src/common/QskScaleTickmarks.cpp b/src/common/QskScaleTickmarks.cpp index 65f67089..7673920a 100644 --- a/src/common/QskScaleTickmarks.cpp +++ b/src/common/QskScaleTickmarks.cpp @@ -27,15 +27,17 @@ QskScaleTickmarks::~QskScaleTickmarks() int QskScaleTickmarks::tickCount() const noexcept { - return m_ticks[ MajorTick ].count() + const auto count = m_ticks[ MajorTick ].count() + m_ticks[ MediumTick ].count() + m_ticks[ MinorTick ].count(); + + return static_cast< int >( count ); } int QskScaleTickmarks::tickCount( TickType type ) const noexcept { - return m_ticks[ type ].count(); + return static_cast< int >( m_ticks[ type ].count() ); } QVector< qreal > QskScaleTickmarks::ticks( TickType type ) const noexcept diff --git a/src/controls/QskPopup.cpp b/src/controls/QskPopup.cpp index af88d277..496e3f55 100644 --- a/src/controls/QskPopup.cpp +++ b/src/controls/QskPopup.cpp @@ -382,9 +382,11 @@ bool QskPopup::hasFaderEffect() const void QskPopup::setPopupFlags( PopupFlags flags ) { - if ( static_cast< int >( flags ) != m_data->flags ) + const auto newFlags = static_cast< int >( m_data->flags ); + + if ( newFlags != m_data->flags ) { - m_data->flags = flags; + m_data->flags = newFlags; updateInputGrabber(); } } diff --git a/src/controls/QskRadioBoxSkinlet.cpp b/src/controls/QskRadioBoxSkinlet.cpp index 201752a9..46a6f374 100644 --- a/src/controls/QskRadioBoxSkinlet.cpp +++ b/src/controls/QskRadioBoxSkinlet.cpp @@ -9,6 +9,7 @@ #include "QskFunctions.h" #include +#include namespace { @@ -100,7 +101,7 @@ QRectF QskRadioBoxSkinlet::rippleRect( { using Q = QskRadioBox; - const auto index = radioBox->positionHint( Q::Ripple ); + const auto index = qFloor( radioBox->positionHint( Q::Ripple ) ); if( index < 0 ) return QRectF(); diff --git a/src/controls/QskSkin.cpp b/src/controls/QskSkin.cpp index 8015fe6e..a350f83c 100644 --- a/src/controls/QskSkin.cpp +++ b/src/controls/QskSkin.cpp @@ -251,7 +251,7 @@ void QskSkin::setupFonts( const QString& family, int weight, bool italic ) for ( int i = TinyFont; i <= HugeFont; i++ ) { - font.setPixelSize( qskDpToPixels( sizes[i - 1] ) ); + font.setPixelSize( qRound( qskDpToPixels( sizes[i - 1] ) ) ); m_data->fonts[ i ] = font; } diff --git a/src/controls/QskSkinnable.cpp b/src/controls/QskSkinnable.cpp index 89e25b0d..bfacfce4 100644 --- a/src/controls/QskSkinnable.cpp +++ b/src/controls/QskSkinnable.cpp @@ -1390,9 +1390,9 @@ bool QskSkinnable::startHintTransitions( that differ between the states */ - for ( uint i = 0; i < primitiveCount; i++ ) + for ( uint j = 0; j < primitiveCount; j++ ) { - const auto primitive = static_cast< QskAspect::Primitive >( i ); + const auto primitive = static_cast< QskAspect::Primitive >( j ); aspect.setPrimitive( type, primitive ); const auto a1 = aspect | oldStates; diff --git a/src/layouts/QskGridLayoutEngine.cpp b/src/layouts/QskGridLayoutEngine.cpp index 92cce6bd..75f1cd6e 100644 --- a/src/layouts/QskGridLayoutEngine.cpp +++ b/src/layouts/QskGridLayoutEngine.cpp @@ -485,11 +485,11 @@ int QskGridLayoutEngine::insertSpacer( const QSizeF& spacing, const QRect& grid bool QskGridLayoutEngine::removeAt( int index ) { - const auto element = m_data->elementAt( index ); - if ( element == nullptr ) + const auto elementAt = m_data->elementAt( index ); + if ( elementAt == nullptr ) return false; - const auto grid = element->minimumGrid(); + const auto grid = elementAt->minimumGrid(); auto& elements = m_data->elements; elements.erase( elements.begin() + index ); @@ -504,10 +504,10 @@ bool QskGridLayoutEngine::removeAt( int index ) for ( const auto& element : elements ) { - const auto grid = element.minimumGrid(); + const auto minGrid = element.minimumGrid(); - maxRow = qMax( maxRow, grid.bottom() ); - maxColumn = qMax( maxColumn, grid.right() ); + maxRow = qMax( maxRow, minGrid.bottom() ); + maxColumn = qMax( maxColumn, minGrid.right() ); } m_data->rowCount = maxRow + 1; diff --git a/src/nodes/QskBoxGradientStroker.cpp b/src/nodes/QskBoxGradientStroker.cpp index d0c59ea7..f7970507 100644 --- a/src/nodes/QskBoxGradientStroker.cpp +++ b/src/nodes/QskBoxGradientStroker.cpp @@ -625,10 +625,10 @@ namespace { const auto p = vec.pointAt( it.position() ); - const qreal y1 = p.y() + ( p.x() - c1.x ) / m; - const qreal x2 = p.x() + ( p.y() - c1.y ) * m; + const qreal ly1 = p.y() + ( p.x() - c1.x ) / m; + const qreal lx2 = p.x() + ( p.y() - c1.y ) * m; - setLine( c1.x, y1, x2, c1.y, it.color(), l++ ); + setLine( c1.x, ly1, lx2, c1.y, it.color(), l++ ); it.advance(); } @@ -642,10 +642,10 @@ namespace { const auto p = vec.pointAt( it.position() ); - const qreal y1 = p.y() + ( p.x() - c2.x ) / m; - const qreal y2 = p.y() + ( p.x() - c3.x ) / m; + const qreal ly1 = p.y() + ( p.x() - c2.x ) / m; + const qreal ly2 = p.y() + ( p.x() - c3.x ) / m; - setLine( c2.x, y1, c3.x, y2, it.color(), l++ ); + setLine( c2.x, ly1, c3.x, ly2, it.color(), l++ ); it.advance(); } @@ -661,10 +661,10 @@ namespace { const auto p = vec.pointAt( it.position() ); - const qreal x1 = p.x() + ( p.y() - c2.y ) * m; - const qreal x2 = p.x() + ( p.y() - c3.y ) * m; + const qreal lx1 = p.x() + ( p.y() - c2.y ) * m; + const qreal lx2 = p.x() + ( p.y() - c3.y ) * m; - setLine( x1, c2.y, x2, c3.y, it.color(), l++ ); + setLine( lx1, c2.y, lx2, c3.y, it.color(), l++ ); it.advance(); } @@ -675,10 +675,10 @@ namespace { const auto p = vec.pointAt( it.position() ); - const qreal y1 = p.y() + ( p.x() - c4.x ) / m; - const qreal x2 = p.x() + ( p.y() - c4.y ) * m; + const qreal ly1 = p.y() + ( p.x() - c4.x ) / m; + const qreal lx2 = p.x() + ( p.y() - c4.y ) * m; - setLine( c4.x, y1, x2, c4.y, it.color(), l++ ); + setLine( c4.x, ly1, lx2, c4.y, it.color(), l++ ); it.advance(); } diff --git a/src/nodes/QskGradientMaterial.cpp b/src/nodes/QskGradientMaterial.cpp index 3f23e777..9d9e3b66 100644 --- a/src/nodes/QskGradientMaterial.cpp +++ b/src/nodes/QskGradientMaterial.cpp @@ -526,18 +526,18 @@ namespace // Angles as ratio of a rotation float start = fmod( dir.startAngle(), 360.0 ) / 360.0; - if ( start < 0.0) - start += 1.0; + if ( start < 0.0f) + start += 1.0f; float span; if ( dir.spanAngle() >= 360.0 ) { - span = 1.0; + span = 1.0f; } else if ( dir.spanAngle() <= -360.0 ) { - span = -1.0; + span = -1.0f; } else { diff --git a/src/nodes/QskScaleRenderer.cpp b/src/nodes/QskScaleRenderer.cpp index 452bc422..2960d908 100644 --- a/src/nodes/QskScaleRenderer.cpp +++ b/src/nodes/QskScaleRenderer.cpp @@ -174,8 +174,12 @@ QSGNode* QskScaleRenderer::updateTicksNode( if( ticksNode == nullptr ) ticksNode = new QskTickmarksNode; +#if 1 + const int tickWidth = qRound( m_data->tickWidth ); +#endif + ticksNode->update( m_data->tickColor, rect, m_data->boundaries, - m_data->tickmarks, m_data->tickWidth, m_data->orientation, + m_data->tickmarks, tickWidth, m_data->orientation, m_data->alignment ); return ticksNode;