1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-02 04:10:20 +02:00

Merge branch 'master' into playlistinterface_ptr

This commit is contained in:
Jeff Mitchell
2011-12-29 10:02:46 -05:00
4 changed files with 55 additions and 8 deletions

View File

@@ -98,9 +98,12 @@ AudioControls::AudioControls( QWidget* parent )
ui->volumeSlider->setRange( 0, 100 ); ui->volumeSlider->setRange( 0, 100 );
ui->volumeSlider->setValue( AudioEngine::instance()->volume() ); ui->volumeSlider->setValue( AudioEngine::instance()->volume() );
m_phononTickCheckTimer.setSingleShot( true );
m_sliderTimeLine.setCurveShape( QTimeLine::LinearCurve ); m_sliderTimeLine.setCurveShape( QTimeLine::LinearCurve );
ui->seekSlider->setTimeLine( &m_sliderTimeLine ); ui->seekSlider->setTimeLine( &m_sliderTimeLine );
connect( &m_phononTickCheckTimer, SIGNAL( timeout() ), SLOT( phononTickCheckTimeout() ) );
connect( &m_sliderTimeLine, SIGNAL( frameChanged( int ) ), ui->seekSlider, SLOT( setValue( int ) ) ); connect( &m_sliderTimeLine, SIGNAL( frameChanged( int ) ), ui->seekSlider, SLOT( setValue( int ) ) );
connect( ui->seekSlider, SIGNAL( valueChanged( int ) ), AudioEngine::instance(), SLOT( seek( int ) ) ); connect( ui->seekSlider, SIGNAL( valueChanged( int ) ), AudioEngine::instance(), SLOT( seek( int ) ) );
@@ -176,6 +179,13 @@ AudioControls::changeEvent( QEvent* e )
} }
void
AudioControls::phononTickCheckTimeout()
{
onPlaybackTimer( m_lastSliderCheck );
}
void void
AudioControls::onVolumeChanged( int volume ) AudioControls::onVolumeChanged( int volume )
{ {
@@ -204,6 +214,8 @@ AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
ui->seekSlider->setRange( 0, duration ); ui->seekSlider->setRange( 0, duration );
ui->seekSlider->setValue( 0 ); ui->seekSlider->setValue( 0 );
m_phononTickCheckTimer.stop();
m_sliderTimeLine.stop(); m_sliderTimeLine.stop();
m_sliderTimeLine.setDuration( duration ); m_sliderTimeLine.setDuration( duration );
m_sliderTimeLine.setFrameRange( 0, duration ); m_sliderTimeLine.setFrameRange( 0, duration );
@@ -344,6 +356,7 @@ AudioControls::onPlaybackSeeked( qint64 msec )
tDebug( LOGEXTRA ) << Q_FUNC_INFO << " setting current timer to " << msec; tDebug( LOGEXTRA ) << Q_FUNC_INFO << " setting current timer to " << msec;
m_sliderTimeLine.setPaused( true ); m_sliderTimeLine.setPaused( true );
m_sliderTimeLine.setCurrentTime( msec ); m_sliderTimeLine.setCurrentTime( msec );
m_lastSliderCheck = msec;
m_seekMsecs = msec; m_seekMsecs = msec;
} }
@@ -374,15 +387,21 @@ void
AudioControls::onPlaybackTimer( qint64 msElapsed ) AudioControls::onPlaybackTimer( qint64 msElapsed )
{ {
//tDebug( LOGEXTRA ) << Q_FUNC_INFO << "msElapsed =" << msElapsed << "and timer current time =" << m_sliderTimeLine.currentTime() << "and m_seekMsecs =" << m_seekMsecs; //tDebug( LOGEXTRA ) << Q_FUNC_INFO << "msElapsed =" << msElapsed << "and timer current time =" << m_sliderTimeLine.currentTime() << "and m_seekMsecs =" << m_seekMsecs;
if ( msElapsed > 0 && msElapsed - 500 < m_lastSliderCheck ) if ( msElapsed > 0 && msElapsed != m_lastSliderCheck && m_seekMsecs == -1 && msElapsed - 500 < m_lastSliderCheck )
return; return;
m_lastSliderCheck = msElapsed; m_lastSliderCheck = msElapsed;
if ( m_currentTrack.isNull() ) if ( m_currentTrack.isNull() )
{
m_sliderTimeLine.stop();
return; return;
}
ui->seekSlider->blockSignals( true ); ui->seekSlider->blockSignals( true );
if ( sender() != &m_phononTickCheckTimer )
m_phononTickCheckTimer.start( 1000 );
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 ) );
@@ -391,7 +410,10 @@ AudioControls::onPlaybackTimer( qint64 msElapsed )
{ {
if ( m_sliderTimeLine.currentTime() != msElapsed ) if ( m_sliderTimeLine.currentTime() != msElapsed )
{ {
m_sliderTimeLine.setPaused( true );
m_noTimeChange = false; m_noTimeChange = false;
m_sliderTimeLine.setCurrentTime( msElapsed );
m_seekMsecs = -1;
m_sliderTimeLine.resume(); m_sliderTimeLine.resume();
} }
} }
@@ -405,10 +427,10 @@ AudioControls::onPlaybackTimer( qint64 msElapsed )
m_sliderTimeLine.setCurrentTime( msElapsed ); m_sliderTimeLine.setCurrentTime( msElapsed );
m_seekMsecs = -1; m_seekMsecs = -1;
if ( AudioEngine::instance()->state() != AudioEngine::Paused ) if ( AudioEngine::instance()->state() != AudioEngine::Paused && sender() != &m_phononTickCheckTimer )
m_sliderTimeLine.resume(); m_sliderTimeLine.resume();
} }
else if ( m_sliderTimeLine.duration() > msElapsed && m_sliderTimeLine.state() == QTimeLine::NotRunning ) else if ( m_sliderTimeLine.duration() > msElapsed && m_sliderTimeLine.state() == QTimeLine::NotRunning && AudioEngine::instance()->state() == AudioEngine::Playing )
{ {
ui->seekSlider->setEnabled( AudioEngine::instance()->canSeek() ); ui->seekSlider->setEnabled( AudioEngine::instance()->canSeek() );
m_sliderTimeLine.start(); m_sliderTimeLine.start();

View File

@@ -20,6 +20,7 @@
#define AUDIOCONTROLS_H #define AUDIOCONTROLS_H
#include <QtGui/QWidget> #include <QtGui/QWidget>
#include <QtCore/QTimer>
#include <QtCore/QTimeLine> #include <QtCore/QTimeLine>
#include "result.h" #include "result.h"
@@ -59,6 +60,8 @@ protected:
void dropEvent ( QDropEvent* ); void dropEvent ( QDropEvent* );
private slots: private slots:
void phononTickCheckTimeout();
void onPlaybackStarted( const Tomahawk::result_ptr& result ); void onPlaybackStarted( const Tomahawk::result_ptr& result );
void onPlaybackLoading( const Tomahawk::result_ptr& result ); void onPlaybackLoading( const Tomahawk::result_ptr& result );
void onPlaybackPaused(); void onPlaybackPaused();
@@ -93,6 +96,7 @@ private:
Tomahawk::PlaylistInterface::RepeatMode m_repeatMode; Tomahawk::PlaylistInterface::RepeatMode m_repeatMode;
bool m_shuffled; bool m_shuffled;
QTimer m_phononTickCheckTimer;
QTimeLine m_sliderTimeLine; QTimeLine m_sliderTimeLine;
qint64 m_seekMsecs; qint64 m_seekMsecs;
qint64 m_lastSliderCheck; qint64 m_lastSliderCheck;

View File

@@ -598,6 +598,7 @@ IF( WIN32 )
"dsound.dll" "dsound.dll"
"winmm.dll" "winmm.dll"
"advapi32.dll" "advapi32.dll"
"shlwapi.dll"
) )
ENDIF( WIN32 ) ENDIF( WIN32 )

View File

@@ -30,6 +30,9 @@
#include "utils/tomahawkutils.h" #include "utils/tomahawkutils.h"
#include "utils/logger.h" #include "utils/logger.h"
#ifdef Q_OS_WIN
#include <shlwapi.h>
#endif
ScriptResolver::ScriptResolver( const QString& exe ) ScriptResolver::ScriptResolver( const QString& exe )
: Tomahawk::ExternalResolverGui( exe ) : Tomahawk::ExternalResolverGui( exe )
@@ -377,9 +380,26 @@ void ScriptResolver::startProcess()
QString runPath = filePath(); QString runPath = filePath();
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
if(fi.completeSuffix() == "py") if ( fi.suffix().toLower() != "exe" )
{ {
interpreter = "python.exe"; DWORD dwSize = MAX_PATH;
wchar_t path[MAX_PATH] = { 0 };
wchar_t *ext = (wchar_t *) ("." + fi.suffix()).utf16();
HRESULT hr = AssocQueryStringW(
(ASSOCF) 0,
ASSOCSTR_EXECUTABLE,
ext,
L"open",
path,
&dwSize
);
if ( ! FAILED( hr ) )
{
interpreter = QString( "\"%1\"" ).arg(QString::fromUtf16((const ushort *) path));
}
} }
else else
{ {