mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-23 17:29:42 +01:00
allow dropping onto AudioControls to start playing
This commit is contained in:
parent
98030c9b05
commit
0e2dd37559
@ -20,9 +20,12 @@
|
||||
#include "ui_audiocontrols.h"
|
||||
|
||||
#include <QNetworkReply>
|
||||
#include <QDropEvent>
|
||||
#include <QMouseEvent>
|
||||
|
||||
#include "audio/audioengine.h"
|
||||
#include "viewmanager.h"
|
||||
#include "playlist/playlistview.h"
|
||||
#include "database/database.h"
|
||||
#include "database/databasecommand_socialaction.h"
|
||||
|
||||
@ -31,6 +34,7 @@
|
||||
#include "utils/imagebutton.h"
|
||||
#include "utils/tomahawkutils.h"
|
||||
#include "utils/logger.h"
|
||||
#include <globalactionmanager.h>
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
@ -44,6 +48,7 @@ AudioControls::AudioControls( QWidget* parent )
|
||||
, m_shuffled( false )
|
||||
{
|
||||
ui->setupUi( this );
|
||||
setAcceptDrops( true );
|
||||
|
||||
ui->buttonAreaLayout->setSpacing( 2 );
|
||||
|
||||
@ -503,6 +508,51 @@ AudioControls::onTrackClicked()
|
||||
ViewManager::instance()->showCurrentTrack();
|
||||
}
|
||||
|
||||
void
|
||||
AudioControls::dragEnterEvent( QDragEnterEvent* e )
|
||||
{
|
||||
if ( GlobalActionManager::instance()->acceptsMimeData( e->mimeData() ) )
|
||||
e->acceptProposedAction();
|
||||
}
|
||||
|
||||
void
|
||||
AudioControls::dragMoveEvent( QDragMoveEvent* e )
|
||||
{
|
||||
// if ( GlobalActionManager::instance()->acceptsMimeData( e->mimeData() ) )
|
||||
// e->acceptProposedAction();
|
||||
}
|
||||
|
||||
void
|
||||
AudioControls::dropEvent( QDropEvent* e )
|
||||
{
|
||||
tDebug() << "AudioControls got drop:" << e->mimeData()->formats();
|
||||
if ( GlobalActionManager::instance()->acceptsMimeData( e->mimeData() ) )
|
||||
{
|
||||
connect( GlobalActionManager::instance(), SIGNAL( tracks( QList<Tomahawk::query_ptr> ) ), this, SLOT( droppedTracks( QList<Tomahawk::query_ptr> ) ) );
|
||||
GlobalActionManager::instance()->tracksFromMimeData( e->mimeData() );
|
||||
|
||||
e->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AudioControls::droppedTracks( QList< query_ptr > tracks )
|
||||
{
|
||||
disconnect( GlobalActionManager::instance(), SIGNAL( tracks( QList<Tomahawk::query_ptr> ) ), this, SLOT( droppedTracks( QList<Tomahawk::query_ptr> ) ) );
|
||||
|
||||
if ( !tracks.isEmpty() )
|
||||
{
|
||||
// queue and play the first if nothign is playing
|
||||
GlobalActionManager::instance()->handleOpenTrack( tracks.first() );
|
||||
|
||||
// just queue the rest
|
||||
for ( int i = 1; i < tracks.size(); i++ )
|
||||
{
|
||||
ViewManager::instance()->queue()->model()->append( tracks[ i ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AudioControls::onLoveButtonClicked( bool checked )
|
||||
|
@ -25,6 +25,9 @@
|
||||
#include "playlistinterface.h"
|
||||
#include "infosystem/infosystem.h"
|
||||
|
||||
class QDropEvent;
|
||||
class QDragEnterEvent;
|
||||
class QDragMoveEvent;
|
||||
namespace Ui
|
||||
{
|
||||
class AudioControls;
|
||||
@ -48,6 +51,9 @@ public slots:
|
||||
|
||||
protected:
|
||||
void changeEvent( QEvent* e );
|
||||
void dragEnterEvent ( QDragEnterEvent* );
|
||||
void dragMoveEvent ( QDragMoveEvent* );
|
||||
void dropEvent ( QDropEvent* );
|
||||
|
||||
private slots:
|
||||
void onPlaybackStarted( const Tomahawk::result_ptr& result );
|
||||
@ -70,6 +76,7 @@ private slots:
|
||||
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||
void infoSystemFinished( QString target );
|
||||
|
||||
void droppedTracks ( QList<Tomahawk::query_ptr> );
|
||||
private:
|
||||
Ui::AudioControls *ui;
|
||||
|
||||
|
@ -66,6 +66,7 @@ public slots:
|
||||
|
||||
Tomahawk::dynplaylist_ptr loadDynamicPlaylist( const QUrl& url, bool station );
|
||||
|
||||
void handleOpenTrack( const Tomahawk::query_ptr& qry );
|
||||
signals:
|
||||
/// QMimeData parsing results
|
||||
void tracks( const QList< Tomahawk::query_ptr >& tracks );
|
||||
@ -75,8 +76,6 @@ private slots:
|
||||
void showPlaylist();
|
||||
|
||||
void xspfCreated( const QByteArray& xspf );
|
||||
|
||||
void handleOpenTrack( const Tomahawk::query_ptr& qry );
|
||||
private:
|
||||
explicit GlobalActionManager( QObject* parent = 0 );
|
||||
void doBookmark( const Tomahawk::playlist_ptr& pl, const Tomahawk::query_ptr& q );
|
||||
|
Loading…
x
Reference in New Issue
Block a user