mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
* LoadingSpinner inherits AnimatedSpinner and automatically connects to a QAbstractItemView.
This commit is contained in:
@@ -31,7 +31,7 @@
|
|||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
|
|
||||||
AnimatedSpinner::AnimatedSpinner( QWidget *parent )
|
AnimatedSpinner::AnimatedSpinner( QWidget* parent )
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
, m_showHide( new QTimeLine )
|
, m_showHide( new QTimeLine )
|
||||||
, m_animation( new QTimeLine )
|
, m_animation( new QTimeLine )
|
||||||
@@ -41,7 +41,7 @@ AnimatedSpinner::AnimatedSpinner( QWidget *parent )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AnimatedSpinner::AnimatedSpinner( const QSize size, bool autoStart )
|
AnimatedSpinner::AnimatedSpinner( const QSize& size, bool autoStart )
|
||||||
: QWidget()
|
: QWidget()
|
||||||
, m_showHide( new QTimeLine )
|
, m_showHide( new QTimeLine )
|
||||||
, m_animation( new QTimeLine )
|
, m_animation( new QTimeLine )
|
||||||
@@ -260,3 +260,27 @@ AnimatedSpinner::segmentCount() const
|
|||||||
{
|
{
|
||||||
return 11;
|
return 11;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LoadingSpinner::LoadingSpinner( QAbstractItemView* parent )
|
||||||
|
: AnimatedSpinner( parent )
|
||||||
|
, m_parent( parent )
|
||||||
|
{
|
||||||
|
if ( m_parent->model() )
|
||||||
|
{
|
||||||
|
connect( m_parent->model(), SIGNAL( loadingStarted() ), SLOT( fadeIn() ), Qt::UniqueConnection );
|
||||||
|
connect( m_parent->model(), SIGNAL( loadingFinished() ), SLOT( fadeOut() ), Qt::UniqueConnection );
|
||||||
|
}
|
||||||
|
connect( m_parent, SIGNAL( modelChanged() ), SLOT( onViewModelChanged() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
LoadingSpinner::onViewModelChanged()
|
||||||
|
{
|
||||||
|
if ( m_parent->model() )
|
||||||
|
{
|
||||||
|
connect( m_parent->model(), SIGNAL( loadingStarted() ), SLOT( fadeIn() ), Qt::UniqueConnection );
|
||||||
|
connect( m_parent->model(), SIGNAL( loadingFinished() ), SLOT( fadeOut() ), Qt::UniqueConnection );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#include <QtGui/QColor>
|
#include <QtGui/QColor>
|
||||||
#include <QtGui/QPixmap>
|
#include <QtGui/QPixmap>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QAbstractItemView>
|
||||||
|
|
||||||
class QTimeLine;
|
class QTimeLine;
|
||||||
class QHideEvent;
|
class QHideEvent;
|
||||||
@@ -42,9 +43,10 @@ class QTimerEvent;
|
|||||||
class DLLEXPORT AnimatedSpinner : public QWidget
|
class DLLEXPORT AnimatedSpinner : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AnimatedSpinner( QWidget *parent = 0 ); // widget mode
|
explicit AnimatedSpinner( QWidget* parent = 0 ); // widget mode
|
||||||
AnimatedSpinner( const QSize size, bool autoStart ); // pixmap mode
|
AnimatedSpinner( const QSize& size, bool autoStart ); // pixmap mode
|
||||||
|
|
||||||
QSize sizeHint() const;
|
QSize sizeHint() const;
|
||||||
|
|
||||||
@@ -87,4 +89,19 @@ private:
|
|||||||
bool m_autoCenter;
|
bool m_autoCenter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class LoadingSpinner : public AnimatedSpinner
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit LoadingSpinner( QAbstractItemView* parent = 0 ); // widget mode
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onViewModelChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QAbstractItemView* m_parent;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user