1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-05 16:42:26 +02:00

Merge branch 'master' into playlistinterface_ptr

This commit is contained in:
Jeff Mitchell 2011-12-29 10:02:46 -05:00
commit f81db381be
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->setValue( AudioEngine::instance()->volume() );
m_phononTickCheckTimer.setSingleShot( true );
m_sliderTimeLine.setCurveShape( QTimeLine::LinearCurve );
ui->seekSlider->setTimeLine( &m_sliderTimeLine );
connect( &m_phononTickCheckTimer, SIGNAL( timeout() ), SLOT( phononTickCheckTimeout() ) );
connect( &m_sliderTimeLine, SIGNAL( frameChanged( int ) ), ui->seekSlider, SLOT( setValue( 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
AudioControls::onVolumeChanged( int volume )
{
@ -204,6 +214,8 @@ AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
ui->seekSlider->setRange( 0, duration );
ui->seekSlider->setValue( 0 );
m_phononTickCheckTimer.stop();
m_sliderTimeLine.stop();
m_sliderTimeLine.setDuration( duration );
m_sliderTimeLine.setFrameRange( 0, duration );
@ -344,6 +356,7 @@ AudioControls::onPlaybackSeeked( qint64 msec )
tDebug( LOGEXTRA ) << Q_FUNC_INFO << " setting current timer to " << msec;
m_sliderTimeLine.setPaused( true );
m_sliderTimeLine.setCurrentTime( msec );
m_lastSliderCheck = msec;
m_seekMsecs = msec;
}
@ -373,16 +386,22 @@ AudioControls::onPlaybackStopped()
void
AudioControls::onPlaybackTimer( qint64 msElapsed )
{
// 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 )
//tDebug( LOGEXTRA ) << Q_FUNC_INFO << "msElapsed =" << msElapsed << "and timer current time =" << m_sliderTimeLine.currentTime() << "and m_seekMsecs =" << m_seekMsecs;
if ( msElapsed > 0 && msElapsed != m_lastSliderCheck && m_seekMsecs == -1 && msElapsed - 500 < m_lastSliderCheck )
return;
m_lastSliderCheck = msElapsed;
if ( m_currentTrack.isNull() )
{
m_sliderTimeLine.stop();
return;
}
ui->seekSlider->blockSignals( true );
if ( sender() != &m_phononTickCheckTimer )
m_phononTickCheckTimer.start( 1000 );
const int seconds = msElapsed / 1000;
ui->timeLabel->setText( TomahawkUtils::timeToString( seconds ) );
ui->timeLeftLabel->setText( "-" + TomahawkUtils::timeToString( m_currentTrack->duration() - seconds ) );
@ -391,7 +410,10 @@ AudioControls::onPlaybackTimer( qint64 msElapsed )
{
if ( m_sliderTimeLine.currentTime() != msElapsed )
{
m_sliderTimeLine.setPaused( true );
m_noTimeChange = false;
m_sliderTimeLine.setCurrentTime( msElapsed );
m_seekMsecs = -1;
m_sliderTimeLine.resume();
}
}
@ -405,10 +427,10 @@ AudioControls::onPlaybackTimer( qint64 msElapsed )
m_sliderTimeLine.setCurrentTime( msElapsed );
m_seekMsecs = -1;
if ( AudioEngine::instance()->state() != AudioEngine::Paused )
if ( AudioEngine::instance()->state() != AudioEngine::Paused && sender() != &m_phononTickCheckTimer )
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() );
m_sliderTimeLine.start();

View File

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

View File

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

View File

@ -30,6 +30,9 @@
#include "utils/tomahawkutils.h"
#include "utils/logger.h"
#ifdef Q_OS_WIN
#include <shlwapi.h>
#endif
ScriptResolver::ScriptResolver( const QString& exe )
: Tomahawk::ExternalResolverGui( exe )
@ -377,9 +380,26 @@ void ScriptResolver::startProcess()
QString runPath = filePath();
#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
{