diff --git a/src/AudioControls.cpp b/src/AudioControls.cpp index ebc2e96e7..9b744ee8c 100644 --- a/src/AudioControls.cpp +++ b/src/AudioControls.cpp @@ -2,6 +2,7 @@ * * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org> * Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org> + * Copyright 2013, Teo Mrnjavac <teo@kde.org> * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -151,6 +152,10 @@ AudioControls::AudioControls( QWidget* parent ) ui->pauseButton->setContentsMargins( 0, 0, 0, 0 ); ui->stackedLayout->setSizeConstraint( QLayout::SetFixedSize ); + connect( InfoSystem::InfoSystem::instance(), SIGNAL( updatedSupportedPushTypes( Tomahawk::InfoSystem::InfoTypeSet ) ), + this, SLOT( onInfoSystemPushTypesUpdated( Tomahawk::InfoSystem::InfoTypeSet ) ) ); + onInfoSystemPushTypesUpdated( InfoSystem::InfoSystem::instance()->supportedPushTypes() ); + onPlaybackStopped(); // initial state } @@ -272,7 +277,7 @@ AudioControls::onPlaybackLoading( const Tomahawk::result_ptr& result ) ui->loveButton->setEnabled( true ); ui->loveButton->setVisible( true ); ui->socialButton->setEnabled( true ); - ui->socialButton->setVisible( true ); + ui->socialButton->setVisible( m_shouldShowShareAction ); ui->ownerButton->setEnabled( true ); ui->ownerButton->setVisible( true ); @@ -351,6 +356,25 @@ AudioControls::onSocialActionsLoaded() } +void +AudioControls::onInfoSystemPushTypesUpdated( InfoSystem::InfoTypeSet supportedTypes ) +{ + if ( supportedTypes.contains( InfoSystem::InfoShareTrack ) ) + { + m_shouldShowShareAction = true; + } + else + { + m_shouldShowShareAction = false; + } + + if ( AudioEngine::instance()->state() == AudioEngine::Stopped ) + ui->socialButton->setVisible( false ); + else + ui->socialButton->setVisible( m_shouldShowShareAction ); +} + + void AudioControls::setSocialActions() { diff --git a/src/AudioControls.h b/src/AudioControls.h index a4797c7aa..cacfb4737 100644 --- a/src/AudioControls.h +++ b/src/AudioControls.h @@ -89,6 +89,8 @@ private slots: void onCoverUpdated(); void onSocialActionsLoaded(); + void onInfoSystemPushTypesUpdated( Tomahawk::InfoSystem::InfoTypeSet supportedTypes ); + private: void setCover(); void setSocialActions(); @@ -100,6 +102,7 @@ private: Tomahawk::result_ptr m_currentTrack; Tomahawk::PlaylistModes::RepeatMode m_repeatMode; bool m_shuffled; + bool m_shouldShowShareAction; QTimer m_phononTickCheckTimer; QTimeLine m_sliderTimeLine; diff --git a/src/libtomahawk/infosystem/InfoSystem.cpp b/src/libtomahawk/infosystem/InfoSystem.cpp index fc6c56b22..f49857b2d 100644 --- a/src/libtomahawk/infosystem/InfoSystem.cpp +++ b/src/libtomahawk/infosystem/InfoSystem.cpp @@ -173,6 +173,12 @@ InfoSystem::init() connect( worker, SIGNAL( finished( QString, Tomahawk::InfoSystem::InfoType ) ), this, SIGNAL( finished( QString, Tomahawk::InfoSystem::InfoType ) ), Qt::UniqueConnection ); + qRegisterMetaType< Tomahawk::InfoSystem::InfoTypeSet >(); + connect( worker, SIGNAL( updatedSupportedGetTypes( Tomahawk::InfoSystem::InfoTypeSet ) ), + this, SLOT( receiveUpdatedSupportedGetTypes( Tomahawk::InfoSystem::InfoTypeSet ) ) ); + connect( worker, SIGNAL( updatedSupportedPushTypes( Tomahawk::InfoSystem::InfoTypeSet ) ), + this, SLOT( receiveUpdatedSupportedPushTypes( Tomahawk::InfoSystem::InfoTypeSet ) ) ); + QMetaObject::invokeMethod( worker, "init", Qt::QueuedConnection, Q_ARG( Tomahawk::InfoSystem::InfoSystemCache*, cache ) ); m_inited = true; diff --git a/src/libtomahawk/infosystem/InfoSystem.h b/src/libtomahawk/infosystem/InfoSystem.h index 97ec9c99e..6a9e7f527 100644 --- a/src/libtomahawk/infosystem/InfoSystem.h +++ b/src/libtomahawk/infosystem/InfoSystem.h @@ -269,6 +269,7 @@ Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoType ); Q_DECLARE_METATYPE( QList< Tomahawk::InfoSystem::InfoStringHash > ); Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoPluginPtr ); Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoPlugin* ); +Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoTypeSet ); Q_DECLARE_INTERFACE( Tomahawk::InfoSystem::InfoPlugin, "tomahawk.InfoPlugin/1.0" )