uncrustified

This commit is contained in:
Uwe Rathmann 2022-03-23 11:54:34 +01:00
parent 9f093674ff
commit 1987a28430
27 changed files with 1514 additions and 607 deletions

File diff suppressed because it is too large Load Diff

View File

@ -165,14 +165,15 @@ bool LightDisplay::arcContainsPoint( const QRectF& rect, const QPointF& point )
const int tolerance = 20;
// 1. check angle
QPointF circlePos( point.x() - rect.center().x(),
rect.center().y() - point.y() );
QPointF circlePos(
point.x() - rect.center().x(),
rect.center().y() - point.y() );
const qreal angle = angleFromPoint( rect, point );
const bool angleWithinRange = angleInRange( metrics, angle )
|| angleDiff( angle, metrics.startAngle() ) <= tolerance
|| angleDiff( angle, metrics.endAngle() ) <= tolerance;
|| angleDiff( angle, metrics.startAngle() ) <= tolerance
|| angleDiff( angle, metrics.endAngle() ) <= tolerance;
// 2. check whether point is on arc
const qreal radiusMax = rect.width() / 2;
@ -181,7 +182,7 @@ bool LightDisplay::arcContainsPoint( const QRectF& rect, const QPointF& point )
const qreal polarRadius = qSqrt( qPow( circlePos.x(), 2 ) + qPow( circlePos.y(), 2 ) );
const bool pointOnArc = ( polarRadius + tolerance ) > radiusMin
&& ( polarRadius - tolerance ) < radiusMax;
&& ( polarRadius - tolerance ) < radiusMax;
bool ret = angleWithinRange && pointOnArc;

View File

@ -33,15 +33,15 @@ QRectF LightDisplaySkinlet::subControlRect( const QskSkinnable* skinnable,
QRectF rect = contentsRect;
const qreal ticksSpacing = 4; // space between the ticks and the arc
if( subControl == LightDisplay::Groove
|| subControl == LightDisplay::Panel )
if( subControl == LightDisplay::Groove || subControl == LightDisplay::Panel )
{
QSizeF textSize = textLabelsSize( display );
QskArcMetrics arcMetrics = display->arcMetricsHint( LightDisplay::ColdAndWarmArc );
const qreal ticksWidth = display->arcMetricsHint( LightDisplay::Tickmarks ).width() + ticksSpacing;
const qreal x = textSize.width() + arcMetrics.width() + ticksWidth;
const qreal w = contentsRect.width() - ( 2 * ( textSize.width() + arcMetrics.width() + ticksWidth ) );
const qreal w = contentsRect.width() -
( 2 * ( textSize.width() + arcMetrics.width() + ticksWidth ) );
const qreal y = arcMetrics.width() + ticksWidth;
const qreal h = contentsRect.height() - 2 * ( arcMetrics.width() + ticksWidth );
@ -52,24 +52,24 @@ QRectF LightDisplaySkinlet::subControlRect( const QskSkinnable* skinnable,
}
else if( subControl == LightDisplay::ColdAndWarmArc )
{
const QRectF panelRect = subControlRect( skinnable, contentsRect,
LightDisplay::Panel );
const QRectF panelRect = subControlRect( skinnable, contentsRect, LightDisplay::Panel );
auto barWidth = display->arcMetricsHint( LightDisplay::ColdAndWarmArc ).width();
auto rect = panelRect.marginsAdded( { barWidth, barWidth, barWidth, barWidth } );
return rect;
}
else if( subControl == LightDisplay::Tickmarks )
{
const QRectF arcRect = subControlRect( skinnable, contentsRect,
LightDisplay::ColdAndWarmArc );
const qreal ticksWidth = display->arcMetricsHint( LightDisplay::Tickmarks ).width() + ticksSpacing;
const QRectF rect = arcRect.marginsAdded( { ticksWidth, ticksWidth, ticksWidth, ticksWidth } );
const QRectF arcRect = subControlRect(
skinnable, contentsRect, LightDisplay::ColdAndWarmArc );
const qreal ticksWidth = display->arcMetricsHint(
LightDisplay::Tickmarks ).width() + ticksSpacing;
const QRectF rect =
arcRect.marginsAdded( { ticksWidth, ticksWidth, ticksWidth, ticksWidth } );
return rect;
}
else if( subControl == LightDisplay::ValueText )
{
QRectF valueTextRect = subControlRect( skinnable, contentsRect,
LightDisplay::Panel );
QRectF valueTextRect = subControlRect( skinnable, contentsRect, LightDisplay::Panel );
const QFontMetricsF fm( skinnable->effectiveFont( subControl ) );
const qreal fontWidth = fm.width( QStringLiteral( "100 %" ) );
const QPointF center = valueTextRect.center();
@ -175,7 +175,7 @@ QSGNode* LightDisplaySkinlet::updateSubNode(
int tickLineWidth = display->metric( LightDisplay::Tickmarks );
ticksNode->update( color, ticksRect, arcMetrics, boundaries,
tickmarks, tickLineWidth, Qt::Horizontal );
tickmarks, tickLineWidth, Qt::Horizontal );
return ticksNode;
}

View File

@ -125,7 +125,7 @@ QColor ShadowedBox::shadowColor() const
return m_shadowColor;
}
QRectF ShadowedBox::layoutRectForSize( const QSizeF &size ) const
QRectF ShadowedBox::layoutRectForSize( const QSizeF& size ) const
{
auto padding = paddingHint( Panel );
return { padding.left() / 2, padding.top() / 2,

View File

@ -46,9 +46,9 @@ namespace
int compare( const QSGMaterial* other ) const override;
QVector2D aspect = QVector2D{1.0, 1.0};
QVector2D aspect = QVector2D{ 1.0, 1.0 };
float blurExtent = 0.0;
QVector4D radius = QVector4D{0.0, 0.0, 0.0, 0.0};
QVector4D radius = QVector4D{ 0.0, 0.0, 0.0, 0.0 };
QColor color = Qt::black;
};

View File

@ -46,9 +46,9 @@ namespace
int compare( const QSGMaterial* other ) const override;
QVector2D aspect = QVector2D{1.0, 1.0};
QVector2D aspect = QVector2D{ 1.0, 1.0 };
float blurExtent = 0.0;
QVector4D radius = QVector4D{0.0, 0.0, 0.0, 0.0};
QVector4D radius = QVector4D{ 0.0, 0.0, 0.0, 0.0 };
QColor color = Qt::black;
};

View File

@ -24,7 +24,7 @@ class QSK_EXPORT QskArcMetrics
public:
constexpr QskArcMetrics() noexcept;
constexpr QskArcMetrics( qreal width, qreal startAngle, qreal spanAngle,
Qt::SizeMode = Qt::AbsoluteSize ) noexcept;
Qt::SizeMode = Qt::AbsoluteSize ) noexcept;
bool operator==( const QskArcMetrics& ) const noexcept;
bool operator!=( const QskArcMetrics& ) const noexcept;

View File

@ -122,7 +122,7 @@ QRectF qskValidOrEmptyInnerRect( const QRectF& rect, const QMarginsF& margins )
return QRectF( x, y, w, h );
}
QRectF qskInterpolatedRect( const QRectF &from, const QRectF &to, qreal progress )
QRectF qskInterpolatedRect( const QRectF& from, const QRectF& to, qreal progress )
{
if ( progress <= 0.0 )
return from;
@ -138,7 +138,7 @@ QRectF qskInterpolatedRect( const QRectF &from, const QRectF &to, qreal progress
return QRectF( x, y, w, h );
}
QSizeF qskInterpolatedSize( const QSizeF &from, const QSizeF &to, qreal progress )
QSizeF qskInterpolatedSize( const QSizeF& from, const QSizeF& to, qreal progress )
{
if ( progress <= 0.0 )
return from;

View File

@ -119,7 +119,7 @@ bool qskIsStandardKeyInput( const QKeyEvent* event, QKeySequence::StandardKey ke
#if 1
return event->matches( key );
#else
constexpr auto mask = ~(Qt::KeypadModifier | Qt::GroupSwitchModifier);
constexpr auto mask = ~( Qt::KeypadModifier | Qt::GroupSwitchModifier );
// We should route this call through the skin. TODO
const auto theme = QGuiApplicationPrivate::platformTheme();

View File

@ -52,7 +52,8 @@ class QskMenuSkinlet::PrivateData
{
m_data->enableCache( false );
}
private:
private:
PrivateData* m_data;
};

View File

@ -382,7 +382,7 @@ bool QskPopup::hasFaderEffect() const
void QskPopup::setPopupFlags( PopupFlags flags )
{
if ( static_cast<int>(flags) != m_data->flags )
if ( static_cast< int >( flags ) != m_data->flags )
{
m_data->flags = flags;
updateInputGrabber();

View File

@ -209,8 +209,7 @@ static inline QskAspect qskSubstitutedAspect(
if ( aspect.hasStates() )
{
qWarning() << "QskSkinnable::(re)setSkinHint: setting hints with states "
"is discouraged - use QskSkinTableEditor if you are "
"sure, that you need this.";
"is discouraged - use QskSkinTableEditor if you are sure, that you need this.";
qWarning() << "QskAspect:" << aspect.stateless()
<< skinnable->skinStatesAsPrintable( aspect.states() );

View File

@ -572,8 +572,8 @@ bool QskDialogButtonBox::isDefaultButtonKeyEvent( const QKeyEvent* event )
}
else
{
return ( event->key() == Qt::Key_Enter ) ||
( event->key() == Qt::Key_Return );
return ( event->key() == Qt::Key_Enter )
|| ( event->key() == Qt::Key_Return );
}
}

View File

@ -19,7 +19,8 @@ class QskHunspellTextPredictor::PrivateData
QLocale locale;
};
QskHunspellTextPredictor::QskHunspellTextPredictor( const QLocale &locale, QObject* object )
QskHunspellTextPredictor::QskHunspellTextPredictor(
const QLocale& locale, QObject* object )
: Inherited( object )
, m_data( new PrivateData() )
{
@ -43,7 +44,8 @@ void QskHunspellTextPredictor::reset()
}
}
QPair< QString, QString > QskHunspellTextPredictor::affAndDicFile( const QString& path, const QLocale& locale )
QPair< QString, QString > QskHunspellTextPredictor::affAndDicFile(
const QString& path, const QLocale& locale )
{
QString prefix = QStringLiteral( "%1/%2" ).arg( path, locale.name() );
QString affFile = prefix + QStringLiteral( ".aff" );
@ -63,7 +65,7 @@ void QskHunspellTextPredictor::loadDictionaries()
{
QString userPaths = QString::fromUtf8( qgetenv( "QSK_HUNSPELL_PATH" ) );
#if defined(Q_OS_WIN32)
#if defined( Q_OS_WIN32 )
QChar separator( ';' );
QStringList defaultPaths;
#else
@ -106,7 +108,7 @@ void QskHunspellTextPredictor::request( const QString& text )
char** suggestions;
QTextCodec *codec = QTextCodec::codecForName( m_data->hunspellEncoding );
const auto codec = QTextCodec::codecForName( m_data->hunspellEncoding );
const QByteArray word = codec ? codec->fromUnicode( text ) : text.toUtf8();
const int count = Hunspell_suggest(

View File

@ -318,7 +318,7 @@ QskInputContextFactory* QskInputContext::factory() const
return m_data->factory;
}
std::shared_ptr<QskTextPredictor> QskInputContext::textPredictor( const QLocale& locale )
std::shared_ptr< QskTextPredictor > QskInputContext::textPredictor( const QLocale& locale )
{
if ( m_data->factory )
return m_data->factory->setupPredictor( locale );
@ -550,12 +550,12 @@ std::shared_ptr< QskTextPredictor > QskInputContextFactory::setupPredictor( cons
QskTextPredictor* QskInputContextFactory::createPredictor( const QLocale& locale )
{
#if HUNSPELL
return new QskHunspellTextPredictor( locale );
return new QskHunspellTextPredictor( locale );
#else
Q_UNUSED( locale );
#endif
return nullptr;
return nullptr;
}
QskInputPanel* QskInputContextFactory::createPanel() const

View File

@ -369,10 +369,7 @@ QskInputPanel::QskInputPanel( QQuickItem* parent )
this, &QskInputPanel::updateLocale );
connect( &m_data->keyProcessor, &KeyProcessor::keyProcessingFinished,
this, [this]( const Result& result )
{
m_data->handleKeyProcessingFinished( result );
} );
this, [this]( const Result& result ) { m_data->handleKeyProcessingFinished( result ); } );
updateLocale( locale() );
}
@ -489,9 +486,9 @@ void QskInputPanel::resetPredictor( const QLocale& locale )
{
// text predictor lives in another thread, so these will all be QueuedConnections:
connect( this, &QskInputPanel::predictionReset,
predictor.get(), &QskTextPredictor::reset );
predictor.get(), &QskTextPredictor::reset );
connect( this, &QskInputPanel::predictionRequested,
predictor.get(), &QskTextPredictor::request );
predictor.get(), &QskTextPredictor::request );
connect( predictor.get(), &QskTextPredictor::predictionChanged,
this, &QskInputPanel::updatePrediction );

View File

@ -53,7 +53,7 @@ class QSK_EXPORT QskInputPanel : public QskControl
virtual void attachItem( QQuickItem* ) = 0;
private:
void updatePrediction( const QString &text, const QStringList &candidates );
void updatePrediction( const QString&, const QStringList& candidates );
void resetPredictor( const QLocale& );
void updateLocale( const QLocale& );

View File

@ -118,7 +118,7 @@ void QskBoxNode::setBoxData( const QRectF& rect,
if ( isFillMonochrome && isBorderMonochrome )
{
if ( borderColors.gradient( Qsk::Left ).startColor()
== fillGradient.startColor() )
== fillGradient.startColor() )
{
// we can draw border and background in one
hasBorder = false;

View File

@ -561,9 +561,10 @@ namespace
{
}
void addAdditionalLines( float x11, float y11, float x12, float y12, // start line
float x21,float y21, float x22, float y22, // end line
const QskGradient& gradient, Line* lines )
void addAdditionalLines(
float x11, float y11, float x12, float y12, // start line
float x21, float y21, float x22, float y22, // end line
const QskGradient& gradient, Line* lines )
{
int additionalStopCount = additionalGradientStops( gradient );
@ -712,35 +713,37 @@ namespace
if( additionalGradientStops( borderMapTR.gradient() ) > 0 )
{
float x1TR = c[ TopRight ].centerX + v.dx1( TopRight ),
y1TR = c[ TopRight ].centerY - v.dy1( TopRight ),
x2TR = c[ TopRight ].centerX + v.dx2( TopRight ),
y2TR = c[ TopRight ].centerY - v.dy2( TopRight ),
y1TR = c[ TopRight ].centerY - v.dy1( TopRight ),
x2TR = c[ TopRight ].centerX + v.dx2( TopRight ),
y2TR = c[ TopRight ].centerY - v.dy2( TopRight ),
x1TL = c[ TopLeft ].centerX - v.dx1( TopLeft ),
y1TL = c[ TopLeft ].centerY - v.dy1( TopLeft ),
x2TL = c[ TopLeft ].centerX - v.dx2( TopLeft ),
y2TL = c[ TopLeft ].centerY - v.dy2( TopLeft );
x1TL = c[ TopLeft ].centerX - v.dx1( TopLeft ),
y1TL = c[ TopLeft ].centerY - v.dy1( TopLeft ),
x2TL = c[ TopLeft ].centerX - v.dx2( TopLeft ),
y2TL = c[ TopLeft ].centerY - v.dy2( TopLeft );
addAdditionalLines( x1TR, y1TR, x2TR, y2TR,
x1TL, y1TL, x2TL, y2TL,
borderMapTR.gradient(), linesTR + k );
addAdditionalLines(
x1TR, y1TR, x2TR, y2TR,
x1TL, y1TL, x2TL, y2TL,
borderMapTR.gradient(), linesTR + k );
}
if( additionalGradientStops( borderMapBL.gradient() ) > 0 )
{
float x1BL = c[ BottomLeft ].centerX - v.dx1( BottomLeft ),
y1BL = c[ BottomLeft ].centerY + v.dy1( BottomLeft ),
x2BL = c[ BottomLeft ].centerX - v.dx2( BottomLeft ),
y2BL = c[ BottomLeft ].centerY + v.dy2( BottomLeft ),
y1BL = c[ BottomLeft ].centerY + v.dy1( BottomLeft ),
x2BL = c[ BottomLeft ].centerX - v.dx2( BottomLeft ),
y2BL = c[ BottomLeft ].centerY + v.dy2( BottomLeft ),
x1BR = c[ BottomRight ].centerX + v.dx1( BottomRight ),
y1BR = c[ BottomRight ].centerY + v.dy1( BottomRight ),
x2BR = c[ BottomRight ].centerX + v.dx2( BottomRight ),
y2BR = c[ BottomRight ].centerY + v.dy2( BottomRight );
x1BR = c[ BottomRight ].centerX + v.dx1( BottomRight ),
y1BR = c[ BottomRight ].centerY + v.dy1( BottomRight ),
x2BR = c[ BottomRight ].centerX + v.dx2( BottomRight ),
y2BR = c[ BottomRight ].centerY + v.dy2( BottomRight );
addAdditionalLines( x1BL, y1BL, x2BL, y2BL,
x1BR, y1BR, x2BR, y2BR,
borderMapBL.gradient(), linesBL + k );
addAdditionalLines(
x1BL, y1BL, x2BL, y2BL,
x1BR, y1BR, x2BR, y2BR,
borderMapBL.gradient(), linesBL + k );
}
}
@ -749,35 +752,37 @@ namespace
if( additionalGradientStops( borderMapTL.gradient() ) > 0 )
{
float x1TL = c[ TopLeft ].centerX - v.dx1( TopLeft ),
y1TL = c[ TopLeft ].centerY - v.dy1( TopLeft ),
x2TL = c[ TopLeft ].centerX - v.dx2( TopLeft ),
y2TL = c[ TopLeft ].centerY - v.dy2( TopLeft ),
y1TL = c[ TopLeft ].centerY - v.dy1( TopLeft ),
x2TL = c[ TopLeft ].centerX - v.dx2( TopLeft ),
y2TL = c[ TopLeft ].centerY - v.dy2( TopLeft ),
x1BL = c[ BottomLeft ].centerX - v.dx1( BottomLeft ),
y1BL = c[ BottomLeft ].centerY + v.dy1( BottomLeft ),
x2BL = c[ BottomLeft ].centerX - v.dx2( BottomLeft ),
y2BL = c[ BottomLeft ].centerY + v.dy2( BottomLeft );
x1BL = c[ BottomLeft ].centerX - v.dx1( BottomLeft ),
y1BL = c[ BottomLeft ].centerY + v.dy1( BottomLeft ),
x2BL = c[ BottomLeft ].centerX - v.dx2( BottomLeft ),
y2BL = c[ BottomLeft ].centerY + v.dy2( BottomLeft );
addAdditionalLines( x1TL, y1TL, x2TL, y2TL,
x1BL, y1BL, x2BL, y2BL,
borderMapTL.gradient(), linesTL + j );
addAdditionalLines(
x1TL, y1TL, x2TL, y2TL,
x1BL, y1BL, x2BL, y2BL,
borderMapTL.gradient(), linesTL + j );
}
if( additionalGradientStops( borderMapBR.gradient() ) > 0 )
{
float x1BR = c[ BottomRight ].centerX + v.dx1( BottomRight ),
y1BR = c[ BottomRight ].centerY + v.dy1( BottomRight ),
x2BR = c[ BottomRight ].centerX + v.dx2( BottomRight ),
y2BR = c[ BottomRight ].centerY + v.dy2( BottomRight ),
y1BR = c[ BottomRight ].centerY + v.dy1( BottomRight ),
x2BR = c[ BottomRight ].centerX + v.dx2( BottomRight ),
y2BR = c[ BottomRight ].centerY + v.dy2( BottomRight ),
x1TR = c[ TopRight ].centerX + v.dx1( TopRight ),
y1TR = c[ TopRight ].centerY - v.dy1( TopRight ),
x2TR = c[ TopRight ].centerX + v.dx2( TopRight ),
y2TR = c[ TopRight ].centerY - v.dy2( TopRight );
x1TR = c[ TopRight ].centerX + v.dx1( TopRight ),
y1TR = c[ TopRight ].centerY - v.dy1( TopRight ),
x2TR = c[ TopRight ].centerX + v.dx2( TopRight ),
y2TR = c[ TopRight ].centerY - v.dy2( TopRight );
addAdditionalLines( x1BR, y1BR, x2BR, y2BR,
x1TR, y1TR, x2TR, y2TR,
borderMapBR.gradient(), linesBR + j );
addAdditionalLines(
x1BR, y1BR, x2BR, y2BR,
x1TR, y1TR, x2TR, y2TR,
borderMapBR.gradient(), linesBR + j );
}
}
}
@ -1011,17 +1016,13 @@ static inline void qskRenderBorder( const QskBoxRenderer::Metrics& metrics,
const int stepCount = metrics.corner[ 0 ].stepCount;
auto left = c.gradient( Qsk::Left ), top = c.gradient( Qsk::Top ),
right = c.gradient( Qsk::Right ), bottom = c.gradient( Qsk::Bottom );
right = c.gradient( Qsk::Right ), bottom = c.gradient( Qsk::Bottom );
qskRenderBorderLines( metrics, orientation, line,
BorderMapGradient( stepCount, qskRgbGradientStart( top ),
qskRgbGradientEnd( left ), left ),
BorderMapGradient( stepCount, qskRgbGradientStart( right ),
qskRgbGradientEnd( top ), top ),
BorderMapGradient( stepCount, qskRgbGradientStart( left ),
qskRgbGradientEnd( bottom ), bottom ),
BorderMapGradient( stepCount, qskRgbGradientStart( bottom ),
qskRgbGradientEnd( right ), right ) );
BorderMapGradient( stepCount, qskRgbGradientStart( top ), qskRgbGradientEnd( left ), left ),
BorderMapGradient( stepCount, qskRgbGradientStart( right ), qskRgbGradientEnd( top ), top ),
BorderMapGradient( stepCount, qskRgbGradientStart( left ), qskRgbGradientEnd( bottom ), bottom ),
BorderMapGradient( stepCount, qskRgbGradientStart( bottom ), qskRgbGradientEnd( right ), right ) );
}
}
@ -1071,16 +1072,12 @@ static inline void qskRenderBoxRandom(
const int n = metrics.corner[ 0 ].stepCount;
auto left = bc.gradient( Qsk::Left ), top = bc.gradient( Qsk::Top ),
right = bc.gradient( Qsk::Right ), bottom = bc.gradient( Qsk::Bottom );
right = bc.gradient( Qsk::Right ), bottom = bc.gradient( Qsk::Bottom );
const BorderMapGradient tl( n, qskRgbGradientStart( top.startColor() ),
qskRgbGradientEnd( left.endColor() ), left );
const BorderMapGradient tr( n, qskRgbGradientStart( right ),
qskRgbGradientEnd( top ), top );
const BorderMapGradient bl( n, qskRgbGradientStart( left ),
qskRgbGradientEnd( bottom ), bottom );
const BorderMapGradient br( n, qskRgbGradientStart( bottom ),
qskRgbGradientEnd( right ), right );
const BorderMapGradient tl( n, qskRgbGradientStart( top.startColor() ), qskRgbGradientEnd( left.endColor() ), left );
const BorderMapGradient tr( n, qskRgbGradientStart( right ), qskRgbGradientEnd( top ), top );
const BorderMapGradient bl( n, qskRgbGradientStart( left ), qskRgbGradientEnd( bottom ), bottom );
const BorderMapGradient br( n, qskRgbGradientStart( bottom ), qskRgbGradientEnd( right ), right );
if ( gradient.isMonochrome() )
{

View File

@ -623,9 +623,14 @@ void QskBoxRenderer::renderRect(
auto fillLines = line + fillLineCount;
if ( bc.isMonochrome() )
qskCreateBorderMonochrome( rect, in, bc.gradient( Qsk::Left ).startColor().rgba(), fillLines );
{
const auto rgb = bc.gradient( Qsk::Left ).startColor().rgba();
qskCreateBorderMonochrome( rect, in, rgb, fillLines );
}
else
{
qskCreateBorder( rect, in, bc, fillLines );
}
}
}