1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-11 00:24:12 +02:00

Expose audioEngine states to QML

This commit is contained in:
Dominik Schmidt
2011-09-03 16:42:00 +02:00
parent fca061d9bc
commit 9fdb0c9393
2 changed files with 20 additions and 1 deletions

View File

@@ -74,6 +74,12 @@ AudioEngine::AudioEngine()
connect( m_audioOutput, SIGNAL( volumeChanged( qreal ) ), this, SLOT( onVolumeChanged( qreal ) ) );
onVolumeChanged( m_audioOutput->volume() );
connect( this, SIGNAL(started(Tomahawk::result_ptr)), SIGNAL(currentTrackChanged()));
connect( this, SIGNAL(stopped()), SIGNAL(currentTrackChanged()));
#ifdef Q_OS_MAC
// On mac, phonon volume is independent from system volume, so the onVolumeChanged call above just sets our volume to 100%.
// Since it's indendent, we'll set it to 75% since that's nicer

View File

@@ -29,6 +29,8 @@
#include "infosystem/infosystem.h"
#include "result.h"
#include "album.h"
#include "artist.h"
#include "typedefs.h"
#include "dllmacro.h"
@@ -42,7 +44,12 @@ namespace Tomahawk
class DLLEXPORT AudioEngine : public QObject
{
Q_OBJECT
Q_OBJECT
Q_ENUMS( AudioState )
Q_PROPERTY(AudioState audioState READ state NOTIFY stateChanged)
Q_PROPERTY(QString currentArtist READ currentArtist NOTIFY currentTrackChanged)
Q_PROPERTY(QString currentAlbum READ currentAlbum NOTIFY currentTrackChanged)
Q_PROPERTY(QString currentTitle READ currentTitle NOTIFY currentTrackChanged)
public:
enum AudioErrorCode { StreamReadError, AudioDeviceError, DecodeError };
@@ -102,7 +109,13 @@ public slots:
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
void infoSystemFinished( QString caller );
const QString currentArtist() const { return !m_currentTrack.isNull() ? m_currentTrack->artist()->name() : QString(); }
const QString currentAlbum() const { return !m_currentTrack.isNull() ? currentTrack()->album()->name() : QString(); }
const QString currentTitle() const { return !m_currentTrack.isNull() ? currentTrack()->track() : QString(); }
signals:
void currentTrackChanged();
void loading( const Tomahawk::result_ptr& track );
void started( const Tomahawk::result_ptr& track );
void finished( const Tomahawk::result_ptr& track );