mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-21 00:09:47 +01:00
closer to working manual animated spinner
This commit is contained in:
parent
db07be002d
commit
6557b3fb0f
@ -143,6 +143,5 @@
|
||||
<file>data/images/process-stop.png</file>
|
||||
<file>data/icons/tomahawk-icon-128x128-grayscale.png</file>
|
||||
<file>data/images/collection.png</file>
|
||||
<file>data/images/loading-animation-dark.gif</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
#include "utils/tomahawkutils.h"
|
||||
#include "utils/logger.h"
|
||||
#include "utils/chasewidget.h"
|
||||
#include "utils/AnimatedSpinner.h"
|
||||
#include "utils/closure.h"
|
||||
|
||||
#define CHILD_ACCOUNT_HEIGHT 24
|
||||
@ -681,7 +681,7 @@ void
|
||||
AccountDelegate::startInstalling( const QPersistentModelIndex& idx )
|
||||
{
|
||||
qDebug() << "START INSTALLING:" << idx.data( Qt::DisplayRole ).toString();
|
||||
ChaseWidget* anim = new ChaseWidget( QApplication::topLevelWidgets().first() );
|
||||
AnimatedSpinner* anim = new AnimatedSpinner( 0 );
|
||||
_detail::Closure* closure = NewClosure( anim, SIGNAL( requestUpdate() ), this, SLOT( doUpdateIndex( const QPersistentModelIndex& ) ), idx );
|
||||
closure->setAutoDelete( false );
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <QStyledItemDelegate>
|
||||
#include "accounts/AccountModel.h"
|
||||
|
||||
class ChaseWidget;
|
||||
class AnimatedSpinner;
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
@ -72,7 +72,7 @@ private:
|
||||
mutable QHash< QPersistentModelIndex, QRect > m_cachedStarRects;
|
||||
mutable QHash< QPersistentModelIndex, QRect > m_cachedConfigRects;
|
||||
mutable QHash< QPersistentModelIndex, QSize > m_sizeHints;
|
||||
mutable QHash< QPersistentModelIndex, ChaseWidget* > m_loadingSpinners;
|
||||
mutable QHash< QPersistentModelIndex, AnimatedSpinner* > m_loadingSpinners;
|
||||
mutable int m_accountRowHeight;
|
||||
};
|
||||
|
||||
|
@ -122,7 +122,7 @@ set( libGuiSources
|
||||
utils/closure.cpp
|
||||
utils/PixmapDelegateFader.cpp
|
||||
utils/SmartPointerList.h
|
||||
utils/chasewidget.cpp
|
||||
utils/AnimatedSpinner.cpp
|
||||
|
||||
widgets/animatedcounterlabel.cpp
|
||||
widgets/checkdirtree.cpp
|
||||
|
@ -266,7 +266,7 @@ void
|
||||
AccountManager::loadFromConfig()
|
||||
{
|
||||
QStringList accountIds = TomahawkSettings::instance()->accounts();
|
||||
|
||||
qDebug() << "LOADING ALL ACCOUNTS" << accountIds;
|
||||
foreach( const QString& accountId, accountIds )
|
||||
{
|
||||
QString pluginFactory = factoryFromId( accountId );
|
||||
|
@ -29,7 +29,7 @@
|
||||
using namespace Tomahawk;
|
||||
using namespace Accounts;
|
||||
|
||||
#define ACCOUNTMODEL_DEBUG 0
|
||||
#define ACCOUNTMODEL_DEBUG 1
|
||||
|
||||
AccountModel::AccountModel( QObject* parent )
|
||||
: QAbstractListModel( parent )
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include <attica/content.h>
|
||||
|
||||
#define ACCOUNTMODELNODE_DEBUG 0
|
||||
#define ACCOUNTMODELNODE_DEBUG 1
|
||||
|
||||
namespace Tomahawk {
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "context/ContextWidget.h"
|
||||
#include "widgets/overlaywidget.h"
|
||||
#include "dynamic/widgets/LoadingSpinner.h"
|
||||
#include "utils/chasewidget.h"
|
||||
#include "utils/AnimatedSpinner.h"
|
||||
#include "utils/tomahawkutils.h"
|
||||
#include "utils/logger.h"
|
||||
#include "utils/closure.h"
|
||||
@ -51,7 +51,7 @@ TrackView::TrackView( QWidget* parent )
|
||||
, m_delegate( 0 )
|
||||
, m_header( new TrackHeader( this ) )
|
||||
, m_overlay( new OverlayWidget( this ) )
|
||||
, m_loadingSpinner( new ChaseWidget( this ) )
|
||||
, m_loadingSpinner( new AnimatedSpinner( this ) )
|
||||
, m_resizing( false )
|
||||
, m_dragging( false )
|
||||
, m_updateContextView( true )
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
class QAction;
|
||||
class LoadingSpinner;
|
||||
class ChaseWidget;
|
||||
class AnimatedSpinner;
|
||||
class TrackHeader;
|
||||
class TrackModel;
|
||||
class TrackProxyModel;
|
||||
@ -58,7 +58,7 @@ public:
|
||||
TrackHeader* header() const { return m_header; }
|
||||
OverlayWidget* overlay() const { return m_overlay; }
|
||||
Tomahawk::ContextMenu* contextMenu() const { return m_contextMenu; }
|
||||
ChaseWidget* loadingSpinner() const { return m_loadingSpinner; }
|
||||
AnimatedSpinner* loadingSpinner() const { return m_loadingSpinner; }
|
||||
|
||||
QModelIndex hoveredIndex() const { return m_hoveredIndex; }
|
||||
QModelIndex contextMenuIndex() const { return m_contextMenuIndex; }
|
||||
@ -120,7 +120,7 @@ private:
|
||||
PlaylistItemDelegate* m_delegate;
|
||||
TrackHeader* m_header;
|
||||
OverlayWidget* m_overlay;
|
||||
ChaseWidget* m_loadingSpinner;
|
||||
AnimatedSpinner* m_loadingSpinner;
|
||||
|
||||
bool m_resizing;
|
||||
bool m_dragging;
|
||||
|
@ -1,203 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the demonstration applications of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "chasewidget.h"
|
||||
|
||||
#include <QtCore/QPoint>
|
||||
#include <QTimeLine>
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QHideEvent>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QPaintEvent>
|
||||
#include <QtGui/QShowEvent>
|
||||
|
||||
ChaseWidget::ChaseWidget(QWidget *parent, QPixmap pixmap, bool pixmapEnabled)
|
||||
: QWidget(parent)
|
||||
, m_segment(0)
|
||||
, m_delay(100)
|
||||
, m_step(40)
|
||||
, m_timerId(-1)
|
||||
, m_animated(false)
|
||||
, m_pixmap(pixmap)
|
||||
, m_pixmapEnabled(pixmapEnabled)
|
||||
, m_showHide( new QTimeLine )
|
||||
{
|
||||
m_showHide->setDuration( 300 );
|
||||
m_showHide->setStartFrame( 0 );
|
||||
m_showHide->setEndFrame( 100 );
|
||||
m_showHide->setUpdateInterval( 20 );
|
||||
connect( m_showHide, SIGNAL( frameChanged( int ) ), this, SLOT( update() ) );
|
||||
connect( m_showHide, SIGNAL( finished() ), this, SLOT( hideFinished() ) );
|
||||
|
||||
hide();
|
||||
|
||||
}
|
||||
|
||||
void ChaseWidget::setAnimated(bool value)
|
||||
{
|
||||
if (m_animated == value)
|
||||
return;
|
||||
m_animated = value;
|
||||
if (m_timerId != -1) {
|
||||
killTimer(m_timerId);
|
||||
m_timerId = -1;
|
||||
}
|
||||
if (m_animated) {
|
||||
m_segment = 0;
|
||||
m_timerId = startTimer(m_delay);
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
void ChaseWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
if ( parentWidget() )
|
||||
{
|
||||
QPoint center( ( parentWidget()->width() / 2 ) - ( width() / 2 ), ( parentWidget()->height() / 2 ) - ( height() / 2 ) );
|
||||
if ( center != pos() )
|
||||
{
|
||||
move( center );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QPainter p(this);
|
||||
|
||||
if ( m_showHide->state() == QTimeLine::Running )
|
||||
{
|
||||
// showing or hiding
|
||||
p.setOpacity( (qreal)m_showHide->currentValue() );
|
||||
}
|
||||
|
||||
if (m_pixmapEnabled && !m_pixmap.isNull()) {
|
||||
p.drawPixmap(0, 0, m_pixmap);
|
||||
return;
|
||||
}
|
||||
|
||||
const int extent = qMin(width() - 8, height() - 8);
|
||||
const int displ = extent / 4;
|
||||
const int ext = extent / 4 - 1;
|
||||
|
||||
p.setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
if(m_animated)
|
||||
p.setPen(Qt::gray);
|
||||
else
|
||||
p.setPen(QPen(palette().dark().color()));
|
||||
|
||||
p.translate(width() / 2, height() / 2); // center
|
||||
|
||||
for (int segment = 0; segment < segmentCount(); ++segment) {
|
||||
p.rotate(QApplication::isRightToLeft() ? m_step : -m_step);
|
||||
if(m_animated)
|
||||
p.setBrush(colorForSegment(segment));
|
||||
else
|
||||
p.setBrush(palette().background());
|
||||
p.drawEllipse(QRect(displ, -ext / 2, ext, ext));
|
||||
}
|
||||
}
|
||||
|
||||
void ChaseWidget::fadeIn()
|
||||
{
|
||||
if ( isVisible() )
|
||||
return;
|
||||
|
||||
show();
|
||||
|
||||
setAnimated( true );
|
||||
m_showHide->setDirection( QTimeLine::Forward );
|
||||
|
||||
if ( m_showHide->state() != QTimeLine::Running )
|
||||
m_showHide->start();
|
||||
}
|
||||
|
||||
void ChaseWidget::fadeOut()
|
||||
{
|
||||
m_showHide->setDirection( QTimeLine::Backward );
|
||||
|
||||
if ( m_showHide->state() != QTimeLine::Running )
|
||||
m_showHide->start();
|
||||
}
|
||||
|
||||
void ChaseWidget::hideFinished()
|
||||
{
|
||||
if ( m_showHide->direction() == QTimeLine::Backward )
|
||||
{
|
||||
hide();
|
||||
setAnimated(false);
|
||||
}
|
||||
}
|
||||
|
||||
QSize ChaseWidget::sizeHint() const
|
||||
{
|
||||
return QSize(64, 64);
|
||||
}
|
||||
|
||||
void ChaseWidget::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
if (event->timerId() == m_timerId) {
|
||||
++m_segment;
|
||||
update();
|
||||
emit requestUpdate();
|
||||
}
|
||||
QWidget::timerEvent(event);
|
||||
}
|
||||
|
||||
QColor ChaseWidget::colorForSegment(int seg) const
|
||||
{
|
||||
int index = ((seg + m_segment) % segmentCount());
|
||||
int comp = qMax(0, 255 - (index * (255 / segmentCount())));
|
||||
return QColor(comp, comp, comp, 255);
|
||||
}
|
||||
|
||||
int ChaseWidget::segmentCount() const
|
||||
{
|
||||
return 360 / m_step;
|
||||
}
|
||||
|
||||
void ChaseWidget::setPixmapEnabled(bool enable)
|
||||
{
|
||||
m_pixmapEnabled = enable;
|
||||
}
|
||||
|
@ -1,98 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the demonstration applications of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CHASEWIDGET_H
|
||||
#define CHASEWIDGET_H
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
#include <QtCore/QSize>
|
||||
#include <QtGui/QColor>
|
||||
#include <QtGui/QPixmap>
|
||||
|
||||
class QTimeLine;
|
||||
class QHideEvent;
|
||||
class QShowEvent;
|
||||
class QPaintEvent;
|
||||
class QTimerEvent;
|
||||
|
||||
class DLLEXPORT ChaseWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ChaseWidget(QWidget *parent = 0, QPixmap pixmap = QPixmap(), bool pixmapEnabled = false);
|
||||
|
||||
void setPixmapEnabled(bool enable);
|
||||
QSize sizeHint() const;
|
||||
|
||||
public slots:
|
||||
void fadeIn();
|
||||
void fadeOut();
|
||||
|
||||
signals:
|
||||
void requestUpdate();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void timerEvent(QTimerEvent *event);
|
||||
|
||||
private slots:
|
||||
void hideFinished();
|
||||
|
||||
private:
|
||||
void setAnimated(bool value);
|
||||
int segmentCount() const;
|
||||
QColor colorForSegment(int segment) const;
|
||||
|
||||
QTimeLine* m_showHide;
|
||||
|
||||
int m_segment;
|
||||
int m_delay;
|
||||
int m_step;
|
||||
int m_timerId;
|
||||
bool m_animated;
|
||||
QPixmap m_pixmap;
|
||||
bool m_pixmapEnabled;
|
||||
};
|
||||
|
||||
#endif
|
@ -26,7 +26,7 @@
|
||||
#include "sourcelist.h"
|
||||
#include "viewmanager.h"
|
||||
#include "dynamic/widgets/LoadingSpinner.h"
|
||||
#include "utils/chasewidget.h"
|
||||
#include "utils/AnimatedSpinner.h"
|
||||
#include "playlist/albummodel.h"
|
||||
#include "playlist/playlistmodel.h"
|
||||
#include "widgets/overlaywidget.h"
|
||||
|
@ -127,7 +127,7 @@ main( int argc, char *argv[] )
|
||||
|
||||
#ifndef ENABLE_HEADLESSs
|
||||
#ifdef WITH_BREAKPAD
|
||||
new BreakPad( QDir::tempPath(), TomahawkSettings::instance()->crashReporterEnabled() );
|
||||
//new BreakPad( QDir::tempPath(), TomahawkSettings::instance()->crashReporterEnabled() );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user