mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 21:57:41 +02:00
* Properly center spinner.
This commit is contained in:
@@ -28,6 +28,9 @@
|
|||||||
#include <QtGui/QPaintEvent>
|
#include <QtGui/QPaintEvent>
|
||||||
#include <QtGui/QShowEvent>
|
#include <QtGui/QShowEvent>
|
||||||
|
|
||||||
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
|
|
||||||
AnimatedSpinner::AnimatedSpinner( QWidget *parent )
|
AnimatedSpinner::AnimatedSpinner( QWidget *parent )
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
, m_showHide( new QTimeLine )
|
, m_showHide( new QTimeLine )
|
||||||
@@ -107,7 +110,7 @@ AnimatedSpinner::paintEvent( QPaintEvent* event )
|
|||||||
Q_UNUSED( event );
|
Q_UNUSED( event );
|
||||||
if ( m_autoCenter && parentWidget() )
|
if ( m_autoCenter && parentWidget() )
|
||||||
{
|
{
|
||||||
QPoint center = parentWidget()->contentsRect().center();
|
QPoint center = parentWidget()->contentsRect().center() - QPoint( sizeHint().width() / 2, sizeHint().height() / 2 );
|
||||||
if ( center != pos() )
|
if ( center != pos() )
|
||||||
{
|
{
|
||||||
move( center );
|
move( center );
|
||||||
@@ -144,7 +147,6 @@ AnimatedSpinner::drawFrame( QPainter* p, const QRect& rect )
|
|||||||
}
|
}
|
||||||
|
|
||||||
p->setRenderHint( QPainter::Antialiasing, true );
|
p->setRenderHint( QPainter::Antialiasing, true );
|
||||||
|
|
||||||
p->translate( rect.center() + QPoint( 0, 1 ) ); // center
|
p->translate( rect.center() + QPoint( 0, 1 ) ); // center
|
||||||
|
|
||||||
const qreal stepRadius = (360 + 2*m_armWidth) / segmentCount();
|
const qreal stepRadius = (360 + 2*m_armWidth) / segmentCount();
|
||||||
@@ -214,12 +216,10 @@ AnimatedSpinner::sizeHint() const
|
|||||||
void
|
void
|
||||||
AnimatedSpinner::frameChanged( int frame )
|
AnimatedSpinner::frameChanged( int frame )
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( m_currentIndex == frame || frame > segmentCount() - 1 )
|
if ( m_currentIndex == frame || frame > segmentCount() - 1 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_currentIndex = frame;
|
m_currentIndex = frame;
|
||||||
|
|
||||||
Q_ASSERT( frame >= 0 && frame < m_colors.size() );
|
Q_ASSERT( frame >= 0 && frame < m_colors.size() );
|
||||||
|
|
||||||
// calculate colors, save a factor from 1 to 0 behind the current item
|
// calculate colors, save a factor from 1 to 0 behind the current item
|
||||||
|
Reference in New Issue
Block a user