1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-05 05:37:29 +02:00

* Allow seeking in songs - if possible.

This commit is contained in:
Christian Muehlhaeuser
2011-06-01 04:21:01 +02:00
parent b356798229
commit c52e7e4cdb
14 changed files with 183 additions and 217 deletions

View File

@@ -60,6 +60,7 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
sourcetree/items/genericpageitems.cpp sourcetree/items/genericpageitems.cpp
transferview.cpp transferview.cpp
PipelineStatusView.cpp
tomahawktrayicon.cpp tomahawktrayicon.cpp
audiocontrols.cpp audiocontrols.cpp
settingsdialog.cpp settingsdialog.cpp
@@ -102,6 +103,7 @@ SET( tomahawkHeadersGui ${tomahawkHeadersGui}
sourcetree/items/genericpageitems.h sourcetree/items/genericpageitems.h
transferview.h transferview.h
PipelineStatusView.h
tomahawktrayicon.h tomahawktrayicon.h
audiocontrols.h audiocontrols.h
settingsdialog.h settingsdialog.h

View File

@@ -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->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->setFixedHeight( 20 );
ui->seekSlider->setEnabled( false ); ui->seekSlider->setEnabled( true );
ui->seekSlider->setStyleSheet( "QSlider::groove::horizontal {" ui->seekSlider->setStyleSheet( "QSlider::groove::horizontal {"
"margin: 5px; border-width: 3px;" "margin: 5px; border-width: 3px;"
"border-image: url(" RESPATH "images/seek-slider-bkg.png) 3 3 3 3 stretch stretch;" "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 {" "QSlider::sub-page:horizontal {"
"margin: 5px; border-width: 3px;" "margin: 5px; border-width: 3px;"
"border-image: url(" RESPATH "images/seek-slider-level.png) 3 3 3 3 stretch stretch;" "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->setFixedHeight( 20 );
ui->volumeSlider->setRange( 0, 100 ); ui->volumeSlider->setRange( 0, 100 );
@@ -120,9 +116,7 @@ AudioControls::AudioControls( QWidget* parent )
"height: 17px; width: 16px;" "height: 17px; width: 16px;"
"background-image: url(" RESPATH "images/seek-and-volume-knob-rest.png);" "background-image: url(" RESPATH "images/seek-and-volume-knob-rest.png);"
"background-repeat: no-repeat;" "background-repeat: no-repeat;"
"}" "}" );
);
/* m_playAction = new QAction( this ); /* m_playAction = new QAction( this );
m_pauseAction = 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_prevAction, SIGNAL( triggered() ), (QObject*)APP->audioEngine(), SLOT( previous() ) );
connect( m_nextAction, SIGNAL( triggered() ), (QObject*)APP->audioEngine(), SLOT( next() ) ); */ 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->volumeSlider, SIGNAL( valueChanged( int ) ), AudioEngine::instance(), SLOT( setVolume( int ) ) );
connect( ui->prevButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( previous() ) ); connect( ui->prevButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( previous() ) );
connect( ui->playPauseButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( play() ) ); 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->ownerLabel->setText( result->friendlySource() );
ui->coverImage->setPixmap( m_defaultCover ); ui->coverImage->setPixmap( m_defaultCover );
if ( ui->timeLabel->text().isEmpty() ) ui->timeLabel->setText( TomahawkUtils::timeToString( 0 ) );
ui->timeLabel->setText( TomahawkUtils::timeToString( 0 ) ); ui->timeLeftLabel->setText( "-" + TomahawkUtils::timeToString( result->duration() ) );
if ( ui->timeLeftLabel->text().isEmpty() )
ui->timeLeftLabel->setText( "-" + TomahawkUtils::timeToString( result->duration() ) );
ui->seekSlider->setRange( 0, m_currentTrack->duration() * 1000 ); ui->seekSlider->setRange( 0, m_currentTrack->duration() * 1000 );
ui->seekSlider->setValue( 0 );
ui->seekSlider->setVisible( true ); ui->seekSlider->setVisible( true );
/* m_playAction->setEnabled( false ); /* m_playAction->setEnabled( false );
@@ -357,10 +350,14 @@ AudioControls::onPlaybackTimer( qint64 msElapsed )
if ( m_currentTrack.isNull() ) if ( m_currentTrack.isNull() )
return; return;
ui->seekSlider->blockSignals( true );
const int seconds = msElapsed / 1000; const int seconds = msElapsed / 1000;
ui->timeLabel->setText( TomahawkUtils::timeToString( seconds ) ); ui->timeLabel->setText( TomahawkUtils::timeToString( seconds ) );
ui->timeLeftLabel->setText( "-" + TomahawkUtils::timeToString( m_currentTrack->duration() - seconds ) ); ui->timeLeftLabel->setText( "-" + TomahawkUtils::timeToString( m_currentTrack->duration() - seconds ) );
ui->seekSlider->setValue( msElapsed ); ui->seekSlider->setValue( msElapsed );
ui->seekSlider->blockSignals( false );
} }

View File

@@ -136,6 +136,17 @@ AudioEngine::next()
} }
void
AudioEngine::seek( int ms )
{
if ( isPlaying() || isPaused() )
{
qDebug() << Q_FUNC_INFO << ms;
m_mediaObject->seek( ms );
}
}
void void
AudioEngine::setVolume( int percentage ) AudioEngine::setVolume( int percentage )
{ {
@@ -176,7 +187,7 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
{ {
setCurrentTrack( result ); setCurrentTrack( result );
if ( !isHttpResult( m_currentTrack->url() ) ) if ( !isHttpResult( m_currentTrack->url() ) && !isLocalResult( m_currentTrack->url() ) )
{ {
io = Servent::instance()->getIODeviceForUrl( m_currentTrack ); io = Servent::instance()->getIODeviceForUrl( m_currentTrack );
@@ -204,7 +215,7 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
m_expectStop = true; m_expectStop = true;
} }
if ( !isHttpResult( m_currentTrack->url() ) ) if ( !isHttpResult( m_currentTrack->url() ) && !isLocalResult( m_currentTrack->url() ) )
{ {
m_mediaObject->setCurrentSource( io.data() ); m_mediaObject->setCurrentSource( io.data() );
m_mediaObject->currentSource().setAutoDelete( false ); 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 = QUrl( m_currentTrack->url().left( m_currentTrack->url().indexOf( '?' ) ) );
furl.setEncodedQuery( QString( m_currentTrack->url().mid( m_currentTrack->url().indexOf( '?' ) + 1 ) ).toLocal8Bit() ); furl.setEncodedQuery( QString( m_currentTrack->url().mid( m_currentTrack->url().indexOf( '?' ) + 1 ) ).toLocal8Bit() );
qDebug() << Q_FUNC_INFO << furl;
} }
m_mediaObject->setCurrentSource( furl ); m_mediaObject->setCurrentSource( furl );
m_mediaObject->currentSource().setAutoDelete( true ); 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(); qDebug() << "Phonon Error:" << m_mediaObject->errorString() << m_mediaObject->errorType();
} }
if ( oldState == Phonon::PlayingState && newState == Phonon::StoppedState ) if ( oldState == Phonon::PlayingState && newState == Phonon::StoppedState )
{ {
qDebug() << "Expecting stop?" << m_expectStop;
if ( !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; m_expectStop = false;
loadNextTrack(); loadNextTrack();
} }
@@ -365,8 +386,16 @@ AudioEngine::setCurrentTrack( const Tomahawk::result_ptr& result )
m_currentTrack = result; m_currentTrack = result;
} }
bool bool
AudioEngine::isHttpResult( const QString& url ) const AudioEngine::isHttpResult( const QString& url ) const
{ {
return url.startsWith( "http://" ); return url.startsWith( "http://" );
} }
bool
AudioEngine::isLocalResult( const QString& url ) const
{
return url.startsWith( "file://" );
}

View File

@@ -64,6 +64,7 @@ public slots:
void previous(); void previous();
void next(); void next();
void seek( int ms );
void setVolume( int percentage ); void setVolume( int percentage );
void lowerVolume() { setVolume( volume() - AUDIO_VOLUME_STEP ); } void lowerVolume() { setVolume( volume() - AUDIO_VOLUME_STEP ); }
void raiseVolume() { setVolume( volume() + AUDIO_VOLUME_STEP ); } void raiseVolume() { setVolume( volume() + AUDIO_VOLUME_STEP ); }
@@ -106,6 +107,7 @@ private slots:
private: private:
bool isHttpResult( const QString& ) const; bool isHttpResult( const QString& ) const;
bool isLocalResult( const QString& ) const;
bool m_isPlayingHttp; bool m_isPlayingHttp;
QSharedPointer<QIODevice> m_input; QSharedPointer<QIODevice> m_input;

View File

@@ -311,6 +311,7 @@ Pipeline::shunt( const query_ptr& q )
qDebug() << "Dispatching to resolver" << r->name() << q->toString() << q->solved() << q->id(); qDebug() << "Dispatching to resolver" << r->name() << q->toString() << q->solved() << q->id();
r->resolve( q ); r->resolve( q );
emit resolving( q );
} }
else else
break; break;

View File

@@ -46,6 +46,9 @@ public:
explicit Pipeline( QObject* parent = 0 ); explicit Pipeline( QObject* parent = 0 );
virtual ~Pipeline(); 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 ); void reportResults( QID qid, const QList< result_ptr >& results );
/// sorter to rank resolver priority /// sorter to rank resolver priority
@@ -75,6 +78,7 @@ public slots:
signals: signals:
void idle(); void idle();
void resolving( const Tomahawk::query_ptr& query );
private slots: private slots:
void timeoutShunt( const query_ptr& q ); void timeoutShunt( const query_ptr& q );

View File

@@ -99,6 +99,7 @@ PlaylistView::setupMenus()
foreach( QAction* a, actions() ) foreach( QAction* a, actions() )
m_itemMenu.addAction( a ); m_itemMenu.addAction( a );
// m_addItemsToPlaylistAction = m_itemMenu.addAction( tr( "&Add to Playlist" ) ); // m_addItemsToPlaylistAction = m_itemMenu.addAction( tr( "&Add to Playlist" ) );
// m_itemMenu.addSeparator(); // m_itemMenu.addSeparator();
m_deleteItemsAction = m_itemMenu.addAction( i > 1 ? tr( "&Delete Items" ) : tr( "&Delete Item" ) ); m_deleteItemsAction = m_itemMenu.addAction( i > 1 ? tr( "&Delete Items" ) : tr( "&Delete Item" ) );

View File

@@ -64,13 +64,13 @@ QueueView::~QueueView()
void void
QueueView::onShown( QWidget* widget ) QueueView::onShown( QWidget* widget, bool animated )
{ {
qDebug() << Q_FUNC_INFO << widget; qDebug() << Q_FUNC_INFO << widget;
if ( widget != this ) if ( widget != this )
return; return;
AnimatedWidget::onShown( widget ); AnimatedWidget::onShown( widget, animated );
m_button->setText( tr( "Click to hide queue" ) ); m_button->setText( tr( "Click to hide queue" ) );
disconnect( m_button, SIGNAL( clicked() ), this, SIGNAL( showWidget() ) ); disconnect( m_button, SIGNAL( clicked() ), this, SIGNAL( showWidget() ) );
@@ -79,13 +79,13 @@ QueueView::onShown( QWidget* widget )
void void
QueueView::onHidden( QWidget* widget ) QueueView::onHidden( QWidget* widget, bool animated )
{ {
qDebug() << Q_FUNC_INFO << widget; qDebug() << Q_FUNC_INFO << widget;
if ( widget != this ) if ( widget != this )
return; return;
AnimatedWidget::onHidden( widget ); AnimatedWidget::onHidden( widget, animated );
m_button->setText( tr( "Click to show queue" ) ); m_button->setText( tr( "Click to show queue" ) );
disconnect( m_button, SIGNAL( clicked() ), this, SIGNAL( hideWidget() ) ); disconnect( m_button, SIGNAL( clicked() ), this, SIGNAL( hideWidget() ) );

View File

@@ -39,8 +39,8 @@ public:
QSize sizeHint() const { return QSize( 0, 200 ); } QSize sizeHint() const { return QSize( 0, 200 ); }
public slots: public slots:
virtual void onShown( QWidget* ); virtual void onShown( QWidget*, bool animated );
virtual void onHidden( QWidget* ); virtual void onHidden( QWidget*, bool animated );
private: private:
PlaylistView* m_queue; PlaylistView* m_queue;

View File

@@ -23,83 +23,25 @@
AnimatedSplitter::AnimatedSplitter( QWidget* parent ) AnimatedSplitter::AnimatedSplitter( QWidget* parent )
: QSplitter( parent ) : QSplitter( parent )
, m_animateIndex( -1 )
, m_greedyIndex( 0 ) , m_greedyIndex( 0 )
{ {
setHandleWidth( 1 ); 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 void
AnimatedSplitter::show( int index, bool animate ) AnimatedSplitter::show( int index, bool animate )
{ {
m_animateIndex = index;
QWidget* w = widget( index ); QWidget* w = widget( index );
QSize size = w->sizeHint(); emit shown( w, animate );
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();
}
} }
void void
AnimatedSplitter::hide( int index, bool animate ) AnimatedSplitter::hide( int index, bool animate )
{ {
m_animateIndex = index;
QWidget* w = widget( index ); QWidget* w = widget( index );
int minHeight = m_sizes.at( index ).height(); emit hidden( w, animate );
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();
}
} }
@@ -107,7 +49,6 @@ void
AnimatedSplitter::addWidget( QWidget* widget ) AnimatedSplitter::addWidget( QWidget* widget )
{ {
QSplitter::addWidget( widget ); QSplitter::addWidget( widget );
m_sizes << widget->minimumSize();
} }
@@ -116,13 +57,11 @@ AnimatedSplitter::addWidget( AnimatedWidget* widget )
{ {
qDebug() << Q_FUNC_INFO << widget; qDebug() << Q_FUNC_INFO << widget;
QSplitter::addWidget( widget ); QSplitter::addWidget( widget );
m_sizes << widget->hiddenSize();
connect( widget, SIGNAL( showWidget() ), SLOT( onShowRequest() ) ); connect( widget, SIGNAL( showWidget() ), SLOT( onShowRequest() ) );
connect( widget, SIGNAL( hideWidget() ), SLOT( onHideRequest() ) ); connect( widget, SIGNAL( hideWidget() ), SLOT( onHideRequest() ) );
connect( widget, SIGNAL( hiddenSizeChanged() ), SLOT( onHiddenSizeChanged() ) ); connect( this, SIGNAL( shown( QWidget*, bool ) ), widget, SLOT( onShown( QWidget*, bool ) ) );
connect( this, SIGNAL( shown( QWidget* ) ), widget, SLOT( onShown( QWidget* ) ) ); connect( this, SIGNAL( hidden( QWidget*, bool ) ), widget, SLOT( onHidden( QWidget*, bool ) ) );
connect( this, SIGNAL( hidden( QWidget* ) ), widget, SLOT( onHidden( QWidget* ) ) );
} }
@@ -131,18 +70,9 @@ AnimatedSplitter::onShowRequest()
{ {
qDebug() << Q_FUNC_INFO << sender(); qDebug() << Q_FUNC_INFO << sender();
int j = -1; AnimatedWidget* w = (AnimatedWidget*)(sender());
for ( int i = 0; i < count(); i ++ ) if ( indexOf( w ) > 0 )
{ show( indexOf( w ) );
if ( widget( i ) == sender() )
{
j = i;
break;
}
}
if ( j > 0 )
show( j );
else else
qDebug() << "Could not find widget:" << sender(); qDebug() << "Could not find widget:" << sender();
} }
@@ -151,72 +81,16 @@ AnimatedSplitter::onShowRequest()
void void
AnimatedSplitter::onHideRequest() AnimatedSplitter::onHideRequest()
{ {
int j = -1; AnimatedWidget* w = (AnimatedWidget*)(sender());
for ( int i = 0; i < count(); i ++ ) if ( indexOf( w ) > 0 )
{ hide( indexOf( w ) );
if ( widget( i ) == sender() )
{
j = i;
break;
}
}
if ( j > 0 )
hide( j );
else else
qDebug() << "Could not find widget:" << sender(); qDebug() << "Could not find widget:" << sender();
} }
void void
AnimatedSplitter::onAnimationStep( int frame ) AnimatedSplitter::setGreedyWidget( int index )
{
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)
{ {
m_greedyIndex = index; m_greedyIndex = index;
if( !widget( index ) ) if( !widget( index ) )
@@ -231,39 +105,103 @@ AnimatedSplitter::setGreedyWidget(int index)
} }
void
AnimatedSplitter::onHiddenSizeChanged()
{
AnimatedWidget* w = (AnimatedWidget*)(sender());
int i = indexOf( w );
m_sizes.replace( i, w->hiddenSize() );
}
AnimatedWidget::AnimatedWidget( AnimatedSplitter* parent ) AnimatedWidget::AnimatedWidget( AnimatedSplitter* parent )
: m_parent( parent ) : m_parent( parent )
, m_isHidden( false ) , m_isHidden( false )
{ {
qDebug() << Q_FUNC_INFO; 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() AnimatedWidget::~AnimatedWidget()
{ {
} }
void void
AnimatedWidget::onShown( QWidget* ) AnimatedWidget::onShown( QWidget* widget, bool animated )
{ {
if ( widget != this )
return;
qDebug() << Q_FUNC_INFO << this; 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; m_isHidden = false;
} }
void void
AnimatedWidget::onHidden( QWidget* ) AnimatedWidget::onHidden( QWidget* widget, bool animated )
{ {
if ( widget != this )
return;
qDebug() << Q_FUNC_INFO << this; 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; 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() );
}
}

View File

@@ -43,32 +43,22 @@ public:
void addWidget( AnimatedWidget* widget ); void addWidget( AnimatedWidget* widget );
signals: signals:
void shown( QWidget* ); void shown( QWidget*, bool animated );
void hidden( QWidget* ); void hidden( QWidget*, bool animated );
private slots: private slots:
void onShowRequest(); void onShowRequest();
void onHideRequest(); void onHideRequest();
void onAnimationStep( int frame );
void onAnimationFinished();
void onHiddenSizeChanged();
private: private:
int m_animateIndex;
bool m_animateForward;
int m_greedyIndex; int m_greedyIndex;
QList<QSize> m_sizes;
QTimeLine* m_timeLine;
}; };
class DLLEXPORT AnimatedWidget : public QWidget class DLLEXPORT AnimatedWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit AnimatedWidget( AnimatedSplitter* parent = 0 ); explicit AnimatedWidget( AnimatedSplitter* parent );
virtual ~AnimatedWidget(); virtual ~AnimatedWidget();
QSize hiddenSize() const { return m_hiddenSize; } QSize hiddenSize() const { return m_hiddenSize; }
@@ -77,22 +67,28 @@ public:
bool isHidden() const { return m_isHidden; } bool isHidden() const { return m_isHidden; }
public slots: public slots:
virtual void onShown( QWidget* ); virtual void onShown( QWidget*, bool animated );
virtual void onHidden( QWidget* ); virtual void onHidden( QWidget*, bool animated );
signals: signals:
void showWidget(); void showWidget();
void hideWidget(); void hideWidget();
void hiddenSizeChanged(); void hiddenSizeChanged();
protected:
private slots:
void onAnimationStep( int frame );
void onAnimationFinished();
protected:
AnimatedSplitter* splitter() { return m_parent; } AnimatedSplitter* splitter() { return m_parent; }
private: private:
AnimatedSplitter* m_parent; AnimatedSplitter* m_parent;
bool m_animateForward;
QSize m_hiddenSize; QSize m_hiddenSize;
bool m_isHidden; bool m_isHidden;
QTimeLine* m_timeLine;
}; };
#endif //ANIMATEDSPLITTER_H #endif //ANIMATEDSPLITTER_H

View File

@@ -57,6 +57,7 @@
#include "diagnosticsdialog.h" #include "diagnosticsdialog.h"
#include "tomahawksettings.h" #include "tomahawksettings.h"
#include "sourcelist.h" #include "sourcelist.h"
#include "PipelineStatusView.h"
#include "transferview.h" #include "transferview.h"
#include "tomahawktrayicon.h" #include "tomahawktrayicon.h"
#include "playlist/dynamic/GeneratorInterface.h" #include "playlist/dynamic/GeneratorInterface.h"
@@ -107,18 +108,19 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
sidebar->setOrientation( Qt::Vertical ); sidebar->setOrientation( Qt::Vertical );
sidebar->setChildrenCollapsible( false ); sidebar->setChildrenCollapsible( false );
sidebar->setGreedyWidget( 0 ); sidebar->setGreedyWidget( 0 );
sidebar->setStretchFactor( 0, 3 );
sidebar->setStretchFactor( 1, 1 );
m_sourcetree = new SourceTreeView(); 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->actionHideOfflineSources, SIGNAL( triggered() ), m_sourcetree, SLOT( hideOfflineSources() ) );
connect( ui->actionShowOfflineSources, SIGNAL( triggered() ), m_sourcetree, SLOT( showOfflineSources() ) ); connect( ui->actionShowOfflineSources, SIGNAL( triggered() ), m_sourcetree, SLOT( showOfflineSources() ) );
sidebar->addWidget( m_sourcetree ); sidebar->addWidget( m_sourcetree );
sidebar->addWidget( transferView ); sidebar->addWidget( transferView );
sidebar->addWidget( pipelineView );
sidebar->hide( 1, false ); sidebar->hide( 1, false );
sidebar->hide( 2, false );
/* QWidget* buttonWidget = new QWidget(); /* QWidget* buttonWidget = new QWidget();
buttonWidget->setLayout( new QVBoxLayout() ); buttonWidget->setLayout( new QVBoxLayout() );

View File

@@ -80,12 +80,6 @@ TransferView::streamFinished( StreamConnection* sc )
emit showWidget(); emit showWidget();
else else
emit hideWidget(); emit hideWidget();
/* if ( m_index.contains( sc ) )
{
int i = m_index.value( sc );
m_tree->invisibleRootItem()->child( i )->setText( 1, tr( "Finished" ) );
}*/
} }

View File

@@ -32,7 +32,7 @@ class TransferView : public AnimatedWidget
Q_OBJECT Q_OBJECT
public: public:
explicit TransferView( AnimatedSplitter* parent = 0 ); explicit TransferView( AnimatedSplitter* parent );
virtual ~TransferView() virtual ~TransferView()
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;