diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index aff80c92d..85d81ef8a 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -122,7 +122,6 @@ set( libGuiSources viewpages/TrackViewPage.cpp viewpages/PlaylistViewPage.cpp - widgets/AnimatedCounterLabel.cpp widgets/AnimatedSplitter.cpp widgets/BasicHeader.cpp widgets/HoverControls.cpp diff --git a/src/libtomahawk/widgets/AnimatedCounterLabel.cpp b/src/libtomahawk/widgets/AnimatedCounterLabel.cpp deleted file mode 100644 index 44ed9c581..000000000 --- a/src/libtomahawk/widgets/AnimatedCounterLabel.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - - -#include "AnimatedCounterLabel.h" - - -AnimatedCounterLabel::AnimatedCounterLabel(QWidget* parent, Qt::WindowFlags f) - : QLabel( parent, f ) - , m_displayed( 0 ) - , m_val( 0 ) - , m_oldval( 0 ) - , m_format( "%L1" ) -{ - connect( &m_timer, SIGNAL( frameChanged( int ) ), SLOT( frame( int ) ) ); - connect( &m_timer, SIGNAL( finished() ), SLOT( showDiff() ) ); -} - - -void AnimatedCounterLabel::setFormat(const QString& f) -{ - m_format = f; - setText( m_format.arg( m_displayed ) ); -} - - -void AnimatedCounterLabel::setVisible(bool b) -{ - QLabel::setVisible( b ); - if ( !m_diff.isNull() ) - m_diff.data()->setVisible( b ); -} - - -void AnimatedCounterLabel::frame(int f) -{ - m_displayed = f; - QLabel::setText( m_format.arg( m_displayed ) ); - QLabel::update(); -} - - -void AnimatedCounterLabel::setVal(unsigned int v) -{ - if( v == m_val ) - return; - - m_oldval = m_val; - m_val = v; - m_timer.stop(); - unsigned int dur = 1000; - unsigned int r = abs( v - m_oldval ); - - if( r > 1000 ) dur = 1500; - else if( r > 10000 ) dur = 2000; - else if( r > 25000 ) dur = 2250; - else if( r > 50000 ) dur = 2750; - else if( r > 100000 ) dur = 3000; - else if( r > 500000 ) dur = 5000; - - m_timer.setDuration( dur ); - m_timer.setFrameRange( m_displayed, v ); - m_timer.setEasingCurve( QEasingCurve( QEasingCurve::OutCubic ) ); - m_timer.start(); -} - - -void AnimatedCounterLabel::showDiff() -{ - int differ = m_val - m_oldval; - m_diff = new QLabel( QString("%1 %L2" ).arg( differ > 0 ? "+" : "" ) - .arg( (int)m_val - (int)m_oldval ), - this->parentWidget() ); - - m_diff.data()->setStyleSheet( "font-size:9px; color:grey;" ); - m_diff.data()->move( QPoint( this->pos().x(), this->pos().y() ) ); - QPropertyAnimation* a = new QPropertyAnimation( m_diff.data(), "pos" ); - a->setEasingCurve( QEasingCurve( QEasingCurve::InQuad ) ); - a->setStartValue( m_diff.data()->pos() + QPoint( 0, -10 ) ); - a->setEndValue( QPoint( m_diff.data()->pos().x(), m_diff.data()->pos().y() - 25 ) ); - a->setDuration( 1000 ); - // qDebug() << "ANIMATING DIFF:" << a->startValue() << a->endValue(); - - connect( a, SIGNAL( finished() ), m_diff.data(), SLOT( hide() ) ); - connect( a, SIGNAL( finished() ), m_diff.data(), SLOT( deleteLater() ) ); - connect( a, SIGNAL( finished() ), a, SLOT( deleteLater() ) ); - - m_diff.data()->show(); - m_diff.data()->setVisible( this->isVisible() ); - a->start(); -} diff --git a/src/libtomahawk/widgets/AnimatedCounterLabel.h b/src/libtomahawk/widgets/AnimatedCounterLabel.h deleted file mode 100644 index 6e34736e0..000000000 --- a/src/libtomahawk/widgets/AnimatedCounterLabel.h +++ /dev/null @@ -1,58 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#ifndef ANIMATEDCOUNTERLABEL_H -#define ANIMATEDCOUNTERLABEL_H - -#include -#include -#include -#include -#include - -#include "DllMacro.h" - -class DLLEXPORT AnimatedCounterLabel : public QLabel -{ -Q_OBJECT - -public: - explicit AnimatedCounterLabel( QWidget* parent = 0, Qt::WindowFlags f = 0 ); - - void setFormat( const QString& f ); - -public slots: - void setVisible( bool b ); - void frame( int f ); - void setVal( unsigned int v ); - void showDiff(); - -private: - QTimeLine m_timer; - - // what's in the label text: - unsigned int m_displayed; - - // current value we are storing (and displaying, or animating towards displaying) - unsigned int m_val, m_oldval; - - QString m_format; - QPointer m_diff; -}; - -#endif // ANIMATEDCOUNTERLABEL_H