[libcalamaresui] Private static methods can be hidden
This commit is contained in:
parent
56c27c4255
commit
58306de28a
@ -45,6 +45,43 @@ isAlignCenter( Qt::AlignmentFlag a )
|
||||
return a == Qt::AlignmentFlag::AlignVCenter;
|
||||
}
|
||||
|
||||
static int
|
||||
lineCountDistanceFromPrimary( int current, int primary, int totalNrOfLines )
|
||||
{
|
||||
int distance = primary - current;
|
||||
if ( distance < 0 )
|
||||
{
|
||||
distance += totalNrOfLines;
|
||||
}
|
||||
return distance;
|
||||
}
|
||||
|
||||
static QColor
|
||||
currentLineColor( int countDistance, int totalNrOfLines, qreal trailFadePerc, qreal minOpacity, QColor color )
|
||||
{
|
||||
if ( countDistance == 0 )
|
||||
{
|
||||
return color;
|
||||
}
|
||||
const qreal minAlphaF = minOpacity / 100.0;
|
||||
int distanceThreshold = static_cast< int >( ceil( ( totalNrOfLines - 1 ) * trailFadePerc / 100.0 ) );
|
||||
if ( countDistance > distanceThreshold )
|
||||
{
|
||||
color.setAlphaF( minAlphaF );
|
||||
}
|
||||
else
|
||||
{
|
||||
qreal alphaDiff = color.alphaF() - minAlphaF;
|
||||
qreal gradient = alphaDiff / static_cast< qreal >( distanceThreshold + 1 );
|
||||
qreal resultAlpha = color.alphaF() - gradient * countDistance;
|
||||
|
||||
// If alpha is out of bounds, clip it.
|
||||
resultAlpha = std::min( 1.0, std::max( 0.0, resultAlpha ) );
|
||||
color.setAlphaF( resultAlpha );
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
WaitingSpinnerWidget::WaitingSpinnerWidget( QWidget* parent, bool centerOnParent, bool disableParentWhenSpinning )
|
||||
: WaitingSpinnerWidget( Qt::WindowModality::NonModal, parent, centerOnParent, disableParentWhenSpinning )
|
||||
{
|
||||
@ -356,44 +393,3 @@ WaitingSpinnerWidget::updatePosition()
|
||||
move( parentWidget()->width() / 2 - width() / 2, parentWidget()->height() / 2 - height() / 2 );
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
WaitingSpinnerWidget::lineCountDistanceFromPrimary( int current, int primary, int totalNrOfLines )
|
||||
{
|
||||
int distance = primary - current;
|
||||
if ( distance < 0 )
|
||||
{
|
||||
distance += totalNrOfLines;
|
||||
}
|
||||
return distance;
|
||||
}
|
||||
|
||||
QColor
|
||||
WaitingSpinnerWidget::currentLineColor( int countDistance,
|
||||
int totalNrOfLines,
|
||||
qreal trailFadePerc,
|
||||
qreal minOpacity,
|
||||
QColor color )
|
||||
{
|
||||
if ( countDistance == 0 )
|
||||
{
|
||||
return color;
|
||||
}
|
||||
const qreal minAlphaF = minOpacity / 100.0;
|
||||
int distanceThreshold = static_cast< int >( ceil( ( totalNrOfLines - 1 ) * trailFadePerc / 100.0 ) );
|
||||
if ( countDistance > distanceThreshold )
|
||||
{
|
||||
color.setAlphaF( minAlphaF );
|
||||
}
|
||||
else
|
||||
{
|
||||
qreal alphaDiff = color.alphaF() - minAlphaF;
|
||||
qreal gradient = alphaDiff / static_cast< qreal >( distanceThreshold + 1 );
|
||||
qreal resultAlpha = color.alphaF() - gradient * countDistance;
|
||||
|
||||
// If alpha is out of bounds, clip it.
|
||||
resultAlpha = std::min( 1.0, std::max( 0.0, resultAlpha ) );
|
||||
color.setAlphaF( resultAlpha );
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
@ -121,10 +121,6 @@ protected:
|
||||
void paintEvent( QPaintEvent* paintEvent ) override;
|
||||
|
||||
private:
|
||||
static int lineCountDistanceFromPrimary( int current, int primary, int totalNrOfLines );
|
||||
static QColor
|
||||
currentLineColor( int distance, int totalNrOfLines, qreal trailFadePerc, qreal minOpacity, QColor color );
|
||||
|
||||
void updateSize();
|
||||
void updateTimer();
|
||||
void updatePosition();
|
||||
|
Loading…
Reference in New Issue
Block a user