mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-12 00:54:20 +02:00
Expose audioEngine states to QML
This commit is contained in:
@@ -74,6 +74,12 @@ AudioEngine::AudioEngine()
|
|||||||
connect( m_audioOutput, SIGNAL( volumeChanged( qreal ) ), this, SLOT( onVolumeChanged( qreal ) ) );
|
connect( m_audioOutput, SIGNAL( volumeChanged( qreal ) ), this, SLOT( onVolumeChanged( qreal ) ) );
|
||||||
|
|
||||||
onVolumeChanged( m_audioOutput->volume() );
|
onVolumeChanged( m_audioOutput->volume() );
|
||||||
|
|
||||||
|
|
||||||
|
connect( this, SIGNAL(started(Tomahawk::result_ptr)), SIGNAL(currentTrackChanged()));
|
||||||
|
connect( this, SIGNAL(stopped()), SIGNAL(currentTrackChanged()));
|
||||||
|
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
// On mac, phonon volume is independent from system volume, so the onVolumeChanged call above just sets our volume to 100%.
|
// 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
|
// Since it's indendent, we'll set it to 75% since that's nicer
|
||||||
|
@@ -29,6 +29,8 @@
|
|||||||
#include "infosystem/infosystem.h"
|
#include "infosystem/infosystem.h"
|
||||||
|
|
||||||
#include "result.h"
|
#include "result.h"
|
||||||
|
#include "album.h"
|
||||||
|
#include "artist.h"
|
||||||
#include "typedefs.h"
|
#include "typedefs.h"
|
||||||
|
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
@@ -42,7 +44,12 @@ namespace Tomahawk
|
|||||||
|
|
||||||
class DLLEXPORT AudioEngine : public QObject
|
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:
|
public:
|
||||||
enum AudioErrorCode { StreamReadError, AudioDeviceError, DecodeError };
|
enum AudioErrorCode { StreamReadError, AudioDeviceError, DecodeError };
|
||||||
@@ -102,7 +109,13 @@ public slots:
|
|||||||
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||||
void infoSystemFinished( QString caller );
|
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:
|
signals:
|
||||||
|
void currentTrackChanged();
|
||||||
|
|
||||||
void loading( const Tomahawk::result_ptr& track );
|
void loading( const Tomahawk::result_ptr& track );
|
||||||
void started( const Tomahawk::result_ptr& track );
|
void started( const Tomahawk::result_ptr& track );
|
||||||
void finished( const Tomahawk::result_ptr& track );
|
void finished( const Tomahawk::result_ptr& track );
|
||||||
|
Reference in New Issue
Block a user