fixig pedantic compiler warnings

This commit is contained in:
Uwe Rathmann 2023-04-04 09:05:16 +02:00
parent 91834513a6
commit 658bc71891
14 changed files with 58 additions and 47 deletions

View File

@ -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() ) )

View File

@ -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

View File

@ -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() );

View File

@ -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++;

View File

@ -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 );
}

View File

@ -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

View File

@ -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();
}
}

View File

@ -9,6 +9,7 @@
#include "QskFunctions.h"
#include <qfontmetrics.h>
#include <qmath.h>
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();

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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();
}

View File

@ -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
{

View File

@ -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;