1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-20 15:59:42 +01:00

* Fixed GlobalActionManager for headless.

This commit is contained in:
Christian Muehlhaeuser 2012-06-08 20:06:23 +02:00
parent b908854d59
commit c02edee100
2 changed files with 66 additions and 37 deletions

View File

@ -41,13 +41,15 @@
#include "utils/ShortenedLinkParser.h"
#include "utils/RdioParser.h"
#include "widgets/SearchWidget.h"
#include "ViewManager.h"
#include "playlist/topbar/TopBar.h"
#include "playlist/PlaylistView.h"
#ifndef ENABLE_HEADLESS
#include "ViewManager.h"
#include "playlist/topbar/TopBar.h"
#include "playlist/PlaylistView.h"
#include "widgets/SearchWidget.h"
#include <QtGui/QApplication>
#include <QtGui/QClipboard>
#include <QtGui/QApplication>
#include <QtGui/QClipboard>
#endif
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkReply>
@ -133,6 +135,8 @@ GlobalActionManager::shortenLink( const QUrl& url, const QVariant& callbackObj )
}
#ifndef ENABLE_HEADLESS
void
GlobalActionManager::getShortLink( const playlist_ptr& pl )
{
@ -178,6 +182,7 @@ GlobalActionManager::getShortLink( const playlist_ptr& pl )
connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ), SLOT( shortenLinkRequestError( QNetworkReply::NetworkError ) ) );
}
QString
GlobalActionManager::copyPlaylistToClipboard( const dynplaylist_ptr& playlist )
{
@ -423,6 +428,7 @@ GlobalActionManager::handlePlaylistCommand( const QUrl& url )
return false;
}
void
GlobalActionManager::playlistCreatedToShow( const playlist_ptr& pl )
{
@ -430,7 +436,9 @@ GlobalActionManager::playlistCreatedToShow( const playlist_ptr& pl )
pl->setProperty( "sharedptr", QVariant::fromValue<Tomahawk::playlist_ptr>( pl ) );
}
void GlobalActionManager::playlistReadyToShow()
void
GlobalActionManager::playlistReadyToShow()
{
playlist_ptr pl = sender()->property( "sharedptr" ).value<Tomahawk::playlist_ptr>();
if ( !pl.isNull() )
@ -460,7 +468,7 @@ GlobalActionManager::handleCollectionCommand( const QUrl& url )
bool
GlobalActionManager::handleOpenCommand(const QUrl& url)
GlobalActionManager::handleOpenCommand( const QUrl& url )
{
QStringList parts = url.path().split( "/" ).mid( 1 );
if ( parts.isEmpty() )
@ -474,7 +482,7 @@ GlobalActionManager::handleOpenCommand(const QUrl& url)
void
GlobalActionManager::handleOpenTrack ( const query_ptr& q )
GlobalActionManager::handleOpenTrack( const query_ptr& q )
{
ViewManager::instance()->queue()->model()->append( q );
ViewManager::instance()->showQueue();
@ -486,6 +494,7 @@ GlobalActionManager::handleOpenTrack ( const query_ptr& q )
}
}
void
GlobalActionManager::handlePlayTrack( const query_ptr& qry )
{
@ -493,7 +502,6 @@ GlobalActionManager::handlePlayTrack( const query_ptr& qry )
}
bool
GlobalActionManager::handleQueueCommand( const QUrl& url )
{
@ -996,6 +1004,8 @@ GlobalActionManager::playRdio( const QUrl& url )
return true;
}
#endif
bool GlobalActionManager::handleBookmarkCommand(const QUrl& url)
{
@ -1076,6 +1086,7 @@ GlobalActionManager::shortenLinkRequestFinished()
if ( !shortUrl.isValid() )
error = true;
#ifndef ENABLE_HEADLESS
// Success! Here is the short link
if ( m_clipboardLongUrl == reply->request().url() )
{
@ -1088,6 +1099,7 @@ GlobalActionManager::shortenLinkRequestFinished()
m_clipboardLongUrl.clear();
}
else
#endif
{
if ( !error )
emit shortLinkReady( longUrl, shortUrl, callbackObj );
@ -1099,6 +1111,8 @@ GlobalActionManager::shortenLinkRequestFinished()
}
#ifndef ENABLE_HEADLESS
void
GlobalActionManager::postShortenFinished()
{
@ -1118,6 +1132,9 @@ GlobalActionManager::postShortenFinished()
reply->deleteLater();
}
#endif
void
GlobalActionManager::shortenLinkRequestError( QNetworkReply::NetworkError error )
{
@ -1172,6 +1189,8 @@ GlobalActionManager::doBookmark( const playlist_ptr& pl, const query_ptr& q )
}
#ifndef ENABLE_HEADLESS
void
GlobalActionManager::showPlaylist()
{
@ -1214,13 +1233,6 @@ GlobalActionManager::waitingForResolved( bool /* success */ )
}
QString
GlobalActionManager::hostname() const
{
return QString( "http://toma.hk" );
}
/// SPOTIFY URL HANDLING
bool
@ -1243,3 +1255,11 @@ GlobalActionManager::openRdioLink( const QString& link )
return true;
}
#endif
QString
GlobalActionManager::hostname() const
{
return QString( "http://toma.hk" );
}

View File

@ -45,6 +45,11 @@ public:
QUrl openLinkFromQuery( const Tomahawk::query_ptr& query ) const;
QUrl openLink( const QString& title, const QString& artist, const QString& album ) const;
public slots:
void shortenLink( const QUrl& url, const QVariant &callbackObj = QVariant() );
#ifndef ENABLE_HEADLESS
/// Takes a spotify link and performs the default open action on it
bool openSpotifyLink( const QString& link );
@ -55,58 +60,62 @@ public:
QString copyPlaylistToClipboard( const Tomahawk::dynplaylist_ptr& playlist );
void savePlaylistToFile( const Tomahawk::playlist_ptr& playlist, const QString& filename );
public slots:
void shortenLink( const QUrl& url, const QVariant &callbackObj = QVariant() );
void getShortLink( const Tomahawk::playlist_ptr& playlist );
bool parseTomahawkLink( const QString& link );
void getShortLink( const Tomahawk::playlist_ptr& playlist );
void waitingForResolved( bool );
Tomahawk::dynplaylist_ptr loadDynamicPlaylist( const QUrl& url, bool station );
void handleOpenTrack( const Tomahawk::query_ptr& qry );
void handlePlayTrack( const Tomahawk::query_ptr& qry );
#endif
signals:
void shortLinkReady( const QUrl& longUrl, const QUrl& shortUrl, const QVariant& callbackObj );
private slots:
void shortenLinkRequestFinished();
void postShortenFinished();
void shortenLinkRequestError( QNetworkReply::NetworkError );
void bookmarkPlaylistCreated( const Tomahawk::playlist_ptr& pl );
#ifndef ENABLE_HEADLESS
void postShortenFinished();
void showPlaylist();
void xspfCreated( const QByteArray& xspf );
void playOrQueueNow( const Tomahawk::query_ptr& );
void playNow( const Tomahawk::query_ptr& );
void playlistCreatedToShow( const Tomahawk::playlist_ptr& pl );
void playlistReadyToShow();
void xspfCreated( const QByteArray& xspf );
void playOrQueueNow( const Tomahawk::query_ptr& );
void playNow( const Tomahawk::query_ptr& );
#endif
private:
explicit GlobalActionManager( QObject* parent = 0 );
void doBookmark( const Tomahawk::playlist_ptr& pl, const Tomahawk::query_ptr& q );
/// handle opening of urls
#ifndef ENABLE_HEADLESS
bool handlePlaylistCommand( const QUrl& url );
bool handleCollectionCommand(const QUrl& url );
bool handleQueueCommand(const QUrl& url );
bool handleStationCommand(const QUrl& url );
bool handleAutoPlaylistCommand(const QUrl& url );
bool handleSearchCommand(const QUrl& url );
bool handlePlayCommand(const QUrl& url );
bool handleBookmarkCommand(const QUrl& url );
bool handleOpenCommand(const QUrl& url );
bool handleViewCommand(const QUrl& url );
bool handleViewCommand( const QUrl& url );
bool handleStationCommand( const QUrl& url );
bool handleSearchCommand( const QUrl& url );
bool handleQueueCommand( const QUrl& url );
bool handleAutoPlaylistCommand( const QUrl& url );
bool doQueueAdd( const QStringList& parts, const QList< QPair< QString, QString > >& queryItems );
bool playSpotify( const QUrl& url );
bool queueSpotify( const QStringList& parts, const QList< QPair< QString, QString > >& queryItems );
bool playRdio( const QUrl& url );
bool queueRdio( const QStringList& parts, const QList< QPair< QString, QString > >& queryItems );
#endif
bool handleCollectionCommand( const QUrl& url );
bool handlePlayCommand( const QUrl& url );
bool handleBookmarkCommand( const QUrl& url );
bool handleOpenCommand( const QUrl& url );
QString hostname() const;