mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-14 13:01:53 +02:00
* Allow seeking in songs - if possible.
This commit is contained in:
parent
b356798229
commit
c52e7e4cdb
@ -60,6 +60,7 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
|
||||
sourcetree/items/genericpageitems.cpp
|
||||
|
||||
transferview.cpp
|
||||
PipelineStatusView.cpp
|
||||
tomahawktrayicon.cpp
|
||||
audiocontrols.cpp
|
||||
settingsdialog.cpp
|
||||
@ -102,6 +103,7 @@ SET( tomahawkHeadersGui ${tomahawkHeadersGui}
|
||||
sourcetree/items/genericpageitems.h
|
||||
|
||||
transferview.h
|
||||
PipelineStatusView.h
|
||||
tomahawktrayicon.h
|
||||
audiocontrols.h
|
||||
settingsdialog.h
|
||||
|
@ -80,27 +80,23 @@ AudioControls::AudioControls( QWidget* parent )
|
||||
ui->metaDataArea->setStyleSheet( "QWidget#metaDataArea {\nborder-width: 4px;\nborder-image: url(" RESPATH "images/now-playing-panel.png) 4 4 4 4 stretch stretch; }" );
|
||||
|
||||
ui->seekSlider->setFixedHeight( 20 );
|
||||
ui->seekSlider->setEnabled( false );
|
||||
ui->seekSlider->setEnabled( true );
|
||||
ui->seekSlider->setStyleSheet( "QSlider::groove::horizontal {"
|
||||
"margin: 5px; border-width: 3px;"
|
||||
"border-image: url(" RESPATH "images/seek-slider-bkg.png) 3 3 3 3 stretch stretch;"
|
||||
"}"
|
||||
|
||||
"QSlider::handle::horizontal {"
|
||||
"margin-left: 5px; margin-right: -5px; "
|
||||
"width: 0px;"
|
||||
|
||||
//"margin-bottom: -7px; margin-top: -7px;"
|
||||
//"height: 17px; width: 16px;"
|
||||
//"background-image: url(" RESPATH "images/seek-and-volume-knob-rest.png);"
|
||||
//"background-repeat: no-repeat;"
|
||||
"}"
|
||||
|
||||
"QSlider::sub-page:horizontal {"
|
||||
"margin: 5px; border-width: 3px;"
|
||||
"border-image: url(" RESPATH "images/seek-slider-level.png) 3 3 3 3 stretch stretch;"
|
||||
"}"
|
||||
);
|
||||
|
||||
"QSlider::handle::horizontal {"
|
||||
"margin-bottom: -7px; margin-top: -7px;"
|
||||
"height: 17px; width: 16px;"
|
||||
"background-image: url(" RESPATH "images/seek-and-volume-knob-rest.png);"
|
||||
"background-repeat: no-repeat;"
|
||||
"}" );
|
||||
|
||||
ui->volumeSlider->setFixedHeight( 20 );
|
||||
ui->volumeSlider->setRange( 0, 100 );
|
||||
@ -120,9 +116,7 @@ AudioControls::AudioControls( QWidget* parent )
|
||||
"height: 17px; width: 16px;"
|
||||
"background-image: url(" RESPATH "images/seek-and-volume-knob-rest.png);"
|
||||
"background-repeat: no-repeat;"
|
||||
"}"
|
||||
|
||||
);
|
||||
"}" );
|
||||
|
||||
/* m_playAction = new QAction( this );
|
||||
m_pauseAction = new QAction( this );
|
||||
@ -134,6 +128,7 @@ AudioControls::AudioControls( QWidget* parent )
|
||||
connect( m_prevAction, SIGNAL( triggered() ), (QObject*)APP->audioEngine(), SLOT( previous() ) );
|
||||
connect( m_nextAction, SIGNAL( triggered() ), (QObject*)APP->audioEngine(), SLOT( next() ) ); */
|
||||
|
||||
connect( ui->seekSlider, SIGNAL( valueChanged( int ) ), AudioEngine::instance(), SLOT( seek( int ) ) );
|
||||
connect( ui->volumeSlider, SIGNAL( valueChanged( int ) ), AudioEngine::instance(), SLOT( setVolume( int ) ) );
|
||||
connect( ui->prevButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( previous() ) );
|
||||
connect( ui->playPauseButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( play() ) );
|
||||
@ -283,13 +278,11 @@ AudioControls::onPlaybackLoading( const Tomahawk::result_ptr& result )
|
||||
ui->ownerLabel->setText( result->friendlySource() );
|
||||
ui->coverImage->setPixmap( m_defaultCover );
|
||||
|
||||
if ( ui->timeLabel->text().isEmpty() )
|
||||
ui->timeLabel->setText( TomahawkUtils::timeToString( 0 ) );
|
||||
|
||||
if ( ui->timeLeftLabel->text().isEmpty() )
|
||||
ui->timeLeftLabel->setText( "-" + TomahawkUtils::timeToString( result->duration() ) );
|
||||
ui->timeLabel->setText( TomahawkUtils::timeToString( 0 ) );
|
||||
ui->timeLeftLabel->setText( "-" + TomahawkUtils::timeToString( result->duration() ) );
|
||||
|
||||
ui->seekSlider->setRange( 0, m_currentTrack->duration() * 1000 );
|
||||
ui->seekSlider->setValue( 0 );
|
||||
ui->seekSlider->setVisible( true );
|
||||
|
||||
/* m_playAction->setEnabled( false );
|
||||
@ -357,10 +350,14 @@ AudioControls::onPlaybackTimer( qint64 msElapsed )
|
||||
if ( m_currentTrack.isNull() )
|
||||
return;
|
||||
|
||||
ui->seekSlider->blockSignals( true );
|
||||
|
||||
const int seconds = msElapsed / 1000;
|
||||
ui->timeLabel->setText( TomahawkUtils::timeToString( seconds ) );
|
||||
ui->timeLeftLabel->setText( "-" + TomahawkUtils::timeToString( m_currentTrack->duration() - seconds ) );
|
||||
ui->seekSlider->setValue( msElapsed );
|
||||
|
||||
ui->seekSlider->blockSignals( false );
|
||||
}
|
||||
|
||||
|
||||
|
@ -136,6 +136,17 @@ AudioEngine::next()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AudioEngine::seek( int ms )
|
||||
{
|
||||
if ( isPlaying() || isPaused() )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << ms;
|
||||
m_mediaObject->seek( ms );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AudioEngine::setVolume( int percentage )
|
||||
{
|
||||
@ -176,7 +187,7 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
|
||||
{
|
||||
setCurrentTrack( result );
|
||||
|
||||
if ( !isHttpResult( m_currentTrack->url() ) )
|
||||
if ( !isHttpResult( m_currentTrack->url() ) && !isLocalResult( m_currentTrack->url() ) )
|
||||
{
|
||||
io = Servent::instance()->getIODeviceForUrl( m_currentTrack );
|
||||
|
||||
@ -204,7 +215,7 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
|
||||
m_expectStop = true;
|
||||
}
|
||||
|
||||
if ( !isHttpResult( m_currentTrack->url() ) )
|
||||
if ( !isHttpResult( m_currentTrack->url() ) && !isLocalResult( m_currentTrack->url() ) )
|
||||
{
|
||||
m_mediaObject->setCurrentSource( io.data() );
|
||||
m_mediaObject->currentSource().setAutoDelete( false );
|
||||
@ -217,7 +228,6 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
|
||||
{
|
||||
furl = QUrl( m_currentTrack->url().left( m_currentTrack->url().indexOf( '?' ) ) );
|
||||
furl.setEncodedQuery( QString( m_currentTrack->url().mid( m_currentTrack->url().indexOf( '?' ) + 1 ) ).toLocal8Bit() );
|
||||
qDebug() << Q_FUNC_INFO << furl;
|
||||
}
|
||||
m_mediaObject->setCurrentSource( furl );
|
||||
m_mediaObject->currentSource().setAutoDelete( true );
|
||||
@ -306,11 +316,22 @@ AudioEngine::onStateChanged( Phonon::State newState, Phonon::State oldState )
|
||||
{
|
||||
qDebug() << "Phonon Error:" << m_mediaObject->errorString() << m_mediaObject->errorType();
|
||||
}
|
||||
|
||||
if ( oldState == Phonon::PlayingState && newState == Phonon::StoppedState )
|
||||
{
|
||||
qDebug() << "Expecting stop?" << m_expectStop;
|
||||
if ( !m_expectStop )
|
||||
{
|
||||
qDebug() << "Loading next track.";
|
||||
m_expectStop = false;
|
||||
loadNextTrack();
|
||||
}
|
||||
}
|
||||
else if ( oldState == Phonon::PlayingState && newState == Phonon::PausedState )
|
||||
{
|
||||
qDebug() << m_mediaObject->currentTime() << m_mediaObject->totalTime();
|
||||
if ( m_mediaObject->currentTime() == m_mediaObject->totalTime() )
|
||||
{
|
||||
qDebug() << "Loading next track.";
|
||||
m_expectStop = false;
|
||||
loadNextTrack();
|
||||
}
|
||||
@ -365,8 +386,16 @@ AudioEngine::setCurrentTrack( const Tomahawk::result_ptr& result )
|
||||
m_currentTrack = result;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
AudioEngine::isHttpResult( const QString& url ) const
|
||||
{
|
||||
return url.startsWith( "http://" );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
AudioEngine::isLocalResult( const QString& url ) const
|
||||
{
|
||||
return url.startsWith( "file://" );
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ public slots:
|
||||
void previous();
|
||||
void next();
|
||||
|
||||
void seek( int ms );
|
||||
void setVolume( int percentage );
|
||||
void lowerVolume() { setVolume( volume() - AUDIO_VOLUME_STEP ); }
|
||||
void raiseVolume() { setVolume( volume() + AUDIO_VOLUME_STEP ); }
|
||||
@ -106,6 +107,7 @@ private slots:
|
||||
|
||||
private:
|
||||
bool isHttpResult( const QString& ) const;
|
||||
bool isLocalResult( const QString& ) const;
|
||||
|
||||
bool m_isPlayingHttp;
|
||||
QSharedPointer<QIODevice> m_input;
|
||||
|
@ -311,6 +311,7 @@ Pipeline::shunt( const query_ptr& q )
|
||||
|
||||
qDebug() << "Dispatching to resolver" << r->name() << q->toString() << q->solved() << q->id();
|
||||
r->resolve( q );
|
||||
emit resolving( q );
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
@ -46,6 +46,9 @@ public:
|
||||
explicit Pipeline( QObject* parent = 0 );
|
||||
virtual ~Pipeline();
|
||||
|
||||
unsigned int pendingQueryCount() const { return m_queries_pending.count(); }
|
||||
unsigned int activeQueryCount() const { return m_qidsState.count(); }
|
||||
|
||||
void reportResults( QID qid, const QList< result_ptr >& results );
|
||||
|
||||
/// sorter to rank resolver priority
|
||||
@ -75,6 +78,7 @@ public slots:
|
||||
|
||||
signals:
|
||||
void idle();
|
||||
void resolving( const Tomahawk::query_ptr& query );
|
||||
|
||||
private slots:
|
||||
void timeoutShunt( const query_ptr& q );
|
||||
|
@ -99,6 +99,7 @@ PlaylistView::setupMenus()
|
||||
|
||||
foreach( QAction* a, actions() )
|
||||
m_itemMenu.addAction( a );
|
||||
|
||||
// m_addItemsToPlaylistAction = m_itemMenu.addAction( tr( "&Add to Playlist" ) );
|
||||
// m_itemMenu.addSeparator();
|
||||
m_deleteItemsAction = m_itemMenu.addAction( i > 1 ? tr( "&Delete Items" ) : tr( "&Delete Item" ) );
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
@ -45,7 +45,7 @@ QueueView::QueueView( AnimatedSplitter* parent )
|
||||
m_queue->setFrameShape( QFrame::NoFrame );
|
||||
m_queue->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
||||
m_queue->overlay()->setEnabled( false );
|
||||
|
||||
|
||||
m_button = new QPushButton();
|
||||
m_button->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
|
||||
m_button->setText( tr( "Click to show queue" ) );
|
||||
@ -64,13 +64,13 @@ QueueView::~QueueView()
|
||||
|
||||
|
||||
void
|
||||
QueueView::onShown( QWidget* widget )
|
||||
QueueView::onShown( QWidget* widget, bool animated )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << widget;
|
||||
if ( widget != this )
|
||||
return;
|
||||
|
||||
AnimatedWidget::onShown( widget );
|
||||
AnimatedWidget::onShown( widget, animated );
|
||||
|
||||
m_button->setText( tr( "Click to hide queue" ) );
|
||||
disconnect( m_button, SIGNAL( clicked() ), this, SIGNAL( showWidget() ) );
|
||||
@ -79,14 +79,14 @@ QueueView::onShown( QWidget* widget )
|
||||
|
||||
|
||||
void
|
||||
QueueView::onHidden( QWidget* widget )
|
||||
QueueView::onHidden( QWidget* widget, bool animated )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << widget;
|
||||
if ( widget != this )
|
||||
return;
|
||||
|
||||
AnimatedWidget::onHidden( widget );
|
||||
|
||||
|
||||
AnimatedWidget::onHidden( widget, animated );
|
||||
|
||||
m_button->setText( tr( "Click to show queue" ) );
|
||||
disconnect( m_button, SIGNAL( clicked() ), this, SIGNAL( hideWidget() ) );
|
||||
connect( m_button, SIGNAL( clicked() ), SIGNAL( showWidget() ) );
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
@ -39,8 +39,8 @@ public:
|
||||
QSize sizeHint() const { return QSize( 0, 200 ); }
|
||||
|
||||
public slots:
|
||||
virtual void onShown( QWidget* );
|
||||
virtual void onHidden( QWidget* );
|
||||
virtual void onShown( QWidget*, bool animated );
|
||||
virtual void onHidden( QWidget*, bool animated );
|
||||
|
||||
private:
|
||||
PlaylistView* m_queue;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
@ -23,83 +23,25 @@
|
||||
|
||||
AnimatedSplitter::AnimatedSplitter( QWidget* parent )
|
||||
: QSplitter( parent )
|
||||
, m_animateIndex( -1 )
|
||||
, m_greedyIndex( 0 )
|
||||
{
|
||||
setHandleWidth( 1 );
|
||||
|
||||
m_timeLine = new QTimeLine( ANIMATION_TIME, this );
|
||||
m_timeLine->setUpdateInterval( 5 );
|
||||
m_timeLine->setEasingCurve( QEasingCurve::OutBack );
|
||||
|
||||
connect( m_timeLine, SIGNAL( frameChanged( int ) ), SLOT( onAnimationStep( int ) ) );
|
||||
connect( m_timeLine, SIGNAL( finished() ), SLOT( onAnimationFinished() ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AnimatedSplitter::show( int index, bool animate )
|
||||
{
|
||||
m_animateIndex = index;
|
||||
|
||||
QWidget* w = widget( index );
|
||||
QSize size = w->sizeHint();
|
||||
|
||||
if ( w->height() == size.height() )
|
||||
return;
|
||||
|
||||
emit shown( w );
|
||||
w->setMaximumHeight( QWIDGETSIZE_MAX );
|
||||
qDebug() << "animating to:" << size.height() << "from" << w->height();
|
||||
|
||||
m_animateForward = true;
|
||||
if ( animate )
|
||||
{
|
||||
if ( m_timeLine->state() == QTimeLine::Running )
|
||||
m_timeLine->stop();
|
||||
|
||||
m_timeLine->setFrameRange( w->height(), size.height() );
|
||||
m_timeLine->setDirection( QTimeLine::Forward );
|
||||
m_timeLine->start();
|
||||
}
|
||||
else
|
||||
{
|
||||
onAnimationStep( size.height() );
|
||||
onAnimationFinished();
|
||||
}
|
||||
emit shown( w, animate );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AnimatedSplitter::hide( int index, bool animate )
|
||||
{
|
||||
m_animateIndex = index;
|
||||
|
||||
QWidget* w = widget( index );
|
||||
int minHeight = m_sizes.at( index ).height();
|
||||
|
||||
if ( w->height() == minHeight )
|
||||
return;
|
||||
|
||||
emit hidden( w );
|
||||
w->setMinimumHeight( minHeight );
|
||||
// qDebug() << "animating to:" << w->height() << "from" << minHeight;
|
||||
|
||||
m_animateForward = false;
|
||||
if ( animate )
|
||||
{
|
||||
if ( m_timeLine->state() == QTimeLine::Running )
|
||||
m_timeLine->stop();
|
||||
|
||||
m_timeLine->setFrameRange( minHeight, w->height() );
|
||||
m_timeLine->setDirection( QTimeLine::Backward );
|
||||
m_timeLine->start();
|
||||
}
|
||||
else
|
||||
{
|
||||
onAnimationStep( minHeight );
|
||||
onAnimationFinished();
|
||||
}
|
||||
emit hidden( w, animate );
|
||||
}
|
||||
|
||||
|
||||
@ -107,7 +49,6 @@ void
|
||||
AnimatedSplitter::addWidget( QWidget* widget )
|
||||
{
|
||||
QSplitter::addWidget( widget );
|
||||
m_sizes << widget->minimumSize();
|
||||
}
|
||||
|
||||
|
||||
@ -116,13 +57,11 @@ AnimatedSplitter::addWidget( AnimatedWidget* widget )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << widget;
|
||||
QSplitter::addWidget( widget );
|
||||
m_sizes << widget->hiddenSize();
|
||||
|
||||
connect( widget, SIGNAL( showWidget() ), SLOT( onShowRequest() ) );
|
||||
connect( widget, SIGNAL( hideWidget() ), SLOT( onHideRequest() ) );
|
||||
connect( widget, SIGNAL( hiddenSizeChanged() ), SLOT( onHiddenSizeChanged() ) );
|
||||
connect( this, SIGNAL( shown( QWidget* ) ), widget, SLOT( onShown( QWidget* ) ) );
|
||||
connect( this, SIGNAL( hidden( QWidget* ) ), widget, SLOT( onHidden( QWidget* ) ) );
|
||||
connect( this, SIGNAL( shown( QWidget*, bool ) ), widget, SLOT( onShown( QWidget*, bool ) ) );
|
||||
connect( this, SIGNAL( hidden( QWidget*, bool ) ), widget, SLOT( onHidden( QWidget*, bool ) ) );
|
||||
}
|
||||
|
||||
|
||||
@ -131,18 +70,9 @@ AnimatedSplitter::onShowRequest()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << sender();
|
||||
|
||||
int j = -1;
|
||||
for ( int i = 0; i < count(); i ++ )
|
||||
{
|
||||
if ( widget( i ) == sender() )
|
||||
{
|
||||
j = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( j > 0 )
|
||||
show( j );
|
||||
AnimatedWidget* w = (AnimatedWidget*)(sender());
|
||||
if ( indexOf( w ) > 0 )
|
||||
show( indexOf( w ) );
|
||||
else
|
||||
qDebug() << "Could not find widget:" << sender();
|
||||
}
|
||||
@ -151,72 +81,16 @@ AnimatedSplitter::onShowRequest()
|
||||
void
|
||||
AnimatedSplitter::onHideRequest()
|
||||
{
|
||||
int j = -1;
|
||||
for ( int i = 0; i < count(); i ++ )
|
||||
{
|
||||
if ( widget( i ) == sender() )
|
||||
{
|
||||
j = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( j > 0 )
|
||||
hide( j );
|
||||
AnimatedWidget* w = (AnimatedWidget*)(sender());
|
||||
if ( indexOf( w ) > 0 )
|
||||
hide( indexOf( w ) );
|
||||
else
|
||||
qDebug() << "Could not find widget:" << sender();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AnimatedSplitter::onAnimationStep( int frame )
|
||||
{
|
||||
QList< int > sizes;
|
||||
|
||||
for ( int i = 0; i < count(); i ++ )
|
||||
{
|
||||
int j = 0;
|
||||
|
||||
if ( i == m_greedyIndex )
|
||||
{
|
||||
j = height() - frame; // FIXME
|
||||
}
|
||||
else if ( i == m_animateIndex )
|
||||
{
|
||||
j = frame;
|
||||
}
|
||||
else
|
||||
{
|
||||
j = widget( i )->height();
|
||||
}
|
||||
|
||||
sizes << j;
|
||||
}
|
||||
|
||||
setSizes( sizes );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AnimatedSplitter::onAnimationFinished()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
QWidget* w = widget( m_animateIndex );
|
||||
if ( m_animateForward )
|
||||
{
|
||||
w->setMinimumHeight( w->minimumHeight() );
|
||||
}
|
||||
else
|
||||
{
|
||||
w->setMaximumHeight( m_sizes.at( m_animateIndex ).height() );
|
||||
}
|
||||
|
||||
m_animateIndex = -1;
|
||||
}
|
||||
|
||||
void
|
||||
AnimatedSplitter::setGreedyWidget(int index)
|
||||
AnimatedSplitter::setGreedyWidget( int index )
|
||||
{
|
||||
m_greedyIndex = index;
|
||||
if( !widget( index ) )
|
||||
@ -227,17 +101,7 @@ AnimatedSplitter::setGreedyWidget(int index)
|
||||
else
|
||||
policy.setVerticalStretch( 1 );
|
||||
widget( m_greedyIndex )->setSizePolicy( policy );
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AnimatedSplitter::onHiddenSizeChanged()
|
||||
{
|
||||
AnimatedWidget* w = (AnimatedWidget*)(sender());
|
||||
int i = indexOf( w );
|
||||
|
||||
m_sizes.replace( i, w->hiddenSize() );
|
||||
}
|
||||
|
||||
|
||||
@ -246,24 +110,98 @@ AnimatedWidget::AnimatedWidget( AnimatedSplitter* parent )
|
||||
, m_isHidden( false )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
m_timeLine = new QTimeLine( ANIMATION_TIME, this );
|
||||
m_timeLine->setUpdateInterval( 5 );
|
||||
m_timeLine->setEasingCurve( QEasingCurve::OutBack );
|
||||
|
||||
connect( m_timeLine, SIGNAL( frameChanged( int ) ), SLOT( onAnimationStep( int ) ) );
|
||||
connect( m_timeLine, SIGNAL( finished() ), SLOT( onAnimationFinished() ) );
|
||||
}
|
||||
|
||||
|
||||
AnimatedWidget::~AnimatedWidget()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AnimatedWidget::onShown( QWidget* )
|
||||
AnimatedWidget::onShown( QWidget* widget, bool animated )
|
||||
{
|
||||
if ( widget != this )
|
||||
return;
|
||||
|
||||
qDebug() << Q_FUNC_INFO << this;
|
||||
|
||||
m_animateForward = true;
|
||||
if ( animated )
|
||||
{
|
||||
if ( m_timeLine->state() == QTimeLine::Running )
|
||||
m_timeLine->stop();
|
||||
|
||||
m_timeLine->setFrameRange( height(), sizeHint().height() );
|
||||
m_timeLine->setDirection( QTimeLine::Forward );
|
||||
m_timeLine->start();
|
||||
}
|
||||
else
|
||||
{
|
||||
onAnimationStep( sizeHint().height() );
|
||||
onAnimationFinished();
|
||||
}
|
||||
|
||||
m_isHidden = false;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AnimatedWidget::onHidden( QWidget* )
|
||||
AnimatedWidget::onHidden( QWidget* widget, bool animated )
|
||||
{
|
||||
if ( widget != this )
|
||||
return;
|
||||
|
||||
qDebug() << Q_FUNC_INFO << this;
|
||||
|
||||
m_animateForward = false;
|
||||
int minHeight = hiddenSize().height();
|
||||
|
||||
if ( animated )
|
||||
{
|
||||
if ( m_timeLine->state() == QTimeLine::Running )
|
||||
m_timeLine->stop();
|
||||
|
||||
m_timeLine->setFrameRange( minHeight, height() );
|
||||
m_timeLine->setDirection( QTimeLine::Backward );
|
||||
m_timeLine->start();
|
||||
}
|
||||
else
|
||||
{
|
||||
onAnimationStep( minHeight );
|
||||
onAnimationFinished();
|
||||
}
|
||||
|
||||
m_isHidden = true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AnimatedWidget::onAnimationStep( int frame )
|
||||
{
|
||||
setFixedHeight( frame );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AnimatedWidget::onAnimationFinished()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
if ( m_animateForward )
|
||||
{
|
||||
setMinimumHeight( hiddenSize().height() );
|
||||
setMaximumHeight( QWIDGETSIZE_MAX );
|
||||
}
|
||||
else
|
||||
{
|
||||
setFixedHeight( hiddenSize().height() );
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
@ -43,56 +43,52 @@ public:
|
||||
void addWidget( AnimatedWidget* widget );
|
||||
|
||||
signals:
|
||||
void shown( QWidget* );
|
||||
void hidden( QWidget* );
|
||||
void shown( QWidget*, bool animated );
|
||||
void hidden( QWidget*, bool animated );
|
||||
|
||||
private slots:
|
||||
void onShowRequest();
|
||||
void onHideRequest();
|
||||
|
||||
void onAnimationStep( int frame );
|
||||
void onAnimationFinished();
|
||||
|
||||
void onHiddenSizeChanged();
|
||||
|
||||
private:
|
||||
int m_animateIndex;
|
||||
bool m_animateForward;
|
||||
|
||||
int m_greedyIndex;
|
||||
QList<QSize> m_sizes;
|
||||
QTimeLine* m_timeLine;
|
||||
};
|
||||
|
||||
class DLLEXPORT AnimatedWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AnimatedWidget( AnimatedSplitter* parent = 0 );
|
||||
explicit AnimatedWidget( AnimatedSplitter* parent );
|
||||
virtual ~AnimatedWidget();
|
||||
|
||||
|
||||
QSize hiddenSize() const { return m_hiddenSize; }
|
||||
void setHiddenSize( const QSize& size ) { m_hiddenSize = size; emit hiddenSizeChanged(); }
|
||||
|
||||
bool isHidden() const { return m_isHidden; }
|
||||
|
||||
public slots:
|
||||
virtual void onShown( QWidget* );
|
||||
virtual void onHidden( QWidget* );
|
||||
virtual void onShown( QWidget*, bool animated );
|
||||
virtual void onHidden( QWidget*, bool animated );
|
||||
|
||||
signals:
|
||||
void showWidget();
|
||||
void hideWidget();
|
||||
|
||||
void hiddenSizeChanged();
|
||||
|
||||
private slots:
|
||||
void onAnimationStep( int frame );
|
||||
void onAnimationFinished();
|
||||
|
||||
protected:
|
||||
|
||||
AnimatedSplitter* splitter() { return m_parent; }
|
||||
|
||||
|
||||
private:
|
||||
AnimatedSplitter* m_parent;
|
||||
bool m_animateForward;
|
||||
QSize m_hiddenSize;
|
||||
bool m_isHidden;
|
||||
QTimeLine* m_timeLine;
|
||||
};
|
||||
|
||||
#endif //ANIMATEDSPLITTER_H
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include "diagnosticsdialog.h"
|
||||
#include "tomahawksettings.h"
|
||||
#include "sourcelist.h"
|
||||
#include "PipelineStatusView.h"
|
||||
#include "transferview.h"
|
||||
#include "tomahawktrayicon.h"
|
||||
#include "playlist/dynamic/GeneratorInterface.h"
|
||||
@ -107,18 +108,19 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
|
||||
sidebar->setOrientation( Qt::Vertical );
|
||||
sidebar->setChildrenCollapsible( false );
|
||||
sidebar->setGreedyWidget( 0 );
|
||||
sidebar->setStretchFactor( 0, 3 );
|
||||
sidebar->setStretchFactor( 1, 1 );
|
||||
|
||||
m_sourcetree = new SourceTreeView();
|
||||
TransferView* transferView = new TransferView();
|
||||
TransferView* transferView = new TransferView( sidebar );
|
||||
PipelineStatusView* pipelineView = new PipelineStatusView( sidebar );
|
||||
|
||||
connect( ui->actionHideOfflineSources, SIGNAL( triggered() ), m_sourcetree, SLOT( hideOfflineSources() ) );
|
||||
connect( ui->actionShowOfflineSources, SIGNAL( triggered() ), m_sourcetree, SLOT( showOfflineSources() ) );
|
||||
|
||||
sidebar->addWidget( m_sourcetree );
|
||||
sidebar->addWidget( transferView );
|
||||
sidebar->addWidget( pipelineView );
|
||||
sidebar->hide( 1, false );
|
||||
sidebar->hide( 2, false );
|
||||
|
||||
/* QWidget* buttonWidget = new QWidget();
|
||||
buttonWidget->setLayout( new QVBoxLayout() );
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
@ -80,12 +80,6 @@ TransferView::streamFinished( StreamConnection* sc )
|
||||
emit showWidget();
|
||||
else
|
||||
emit hideWidget();
|
||||
|
||||
/* if ( m_index.contains( sc ) )
|
||||
{
|
||||
int i = m_index.value( sc );
|
||||
m_tree->invisibleRootItem()->child( i )->setText( 1, tr( "Finished" ) );
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
@ -32,7 +32,7 @@ class TransferView : public AnimatedWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TransferView( AnimatedSplitter* parent = 0 );
|
||||
explicit TransferView( AnimatedSplitter* parent );
|
||||
virtual ~TransferView()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
Loading…
x
Reference in New Issue
Block a user