mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 05:37:29 +02:00
* Fixed GlobalActionManager for headless.
This commit is contained in:
@@ -41,13 +41,15 @@
|
|||||||
#include "utils/ShortenedLinkParser.h"
|
#include "utils/ShortenedLinkParser.h"
|
||||||
#include "utils/RdioParser.h"
|
#include "utils/RdioParser.h"
|
||||||
|
|
||||||
#include "widgets/SearchWidget.h"
|
#ifndef ENABLE_HEADLESS
|
||||||
#include "ViewManager.h"
|
#include "ViewManager.h"
|
||||||
#include "playlist/topbar/TopBar.h"
|
#include "playlist/topbar/TopBar.h"
|
||||||
#include "playlist/PlaylistView.h"
|
#include "playlist/PlaylistView.h"
|
||||||
|
#include "widgets/SearchWidget.h"
|
||||||
|
|
||||||
#include <QtGui/QApplication>
|
#include <QtGui/QApplication>
|
||||||
#include <QtGui/QClipboard>
|
#include <QtGui/QClipboard>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <QtNetwork/QNetworkAccessManager>
|
#include <QtNetwork/QNetworkAccessManager>
|
||||||
#include <QtNetwork/QNetworkReply>
|
#include <QtNetwork/QNetworkReply>
|
||||||
@@ -133,6 +135,8 @@ GlobalActionManager::shortenLink( const QUrl& url, const QVariant& callbackObj )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef ENABLE_HEADLESS
|
||||||
|
|
||||||
void
|
void
|
||||||
GlobalActionManager::getShortLink( const playlist_ptr& pl )
|
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 ) ) );
|
connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ), SLOT( shortenLinkRequestError( QNetworkReply::NetworkError ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
GlobalActionManager::copyPlaylistToClipboard( const dynplaylist_ptr& playlist )
|
GlobalActionManager::copyPlaylistToClipboard( const dynplaylist_ptr& playlist )
|
||||||
{
|
{
|
||||||
@@ -423,6 +428,7 @@ GlobalActionManager::handlePlaylistCommand( const QUrl& url )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GlobalActionManager::playlistCreatedToShow( const playlist_ptr& pl )
|
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 ) );
|
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>();
|
playlist_ptr pl = sender()->property( "sharedptr" ).value<Tomahawk::playlist_ptr>();
|
||||||
if ( !pl.isNull() )
|
if ( !pl.isNull() )
|
||||||
@@ -460,7 +468,7 @@ GlobalActionManager::handleCollectionCommand( const QUrl& url )
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
GlobalActionManager::handleOpenCommand(const QUrl& url)
|
GlobalActionManager::handleOpenCommand( const QUrl& url )
|
||||||
{
|
{
|
||||||
QStringList parts = url.path().split( "/" ).mid( 1 );
|
QStringList parts = url.path().split( "/" ).mid( 1 );
|
||||||
if ( parts.isEmpty() )
|
if ( parts.isEmpty() )
|
||||||
@@ -474,7 +482,7 @@ GlobalActionManager::handleOpenCommand(const QUrl& url)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GlobalActionManager::handleOpenTrack ( const query_ptr& q )
|
GlobalActionManager::handleOpenTrack( const query_ptr& q )
|
||||||
{
|
{
|
||||||
ViewManager::instance()->queue()->model()->append( q );
|
ViewManager::instance()->queue()->model()->append( q );
|
||||||
ViewManager::instance()->showQueue();
|
ViewManager::instance()->showQueue();
|
||||||
@@ -486,6 +494,7 @@ GlobalActionManager::handleOpenTrack ( const query_ptr& q )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GlobalActionManager::handlePlayTrack( const query_ptr& qry )
|
GlobalActionManager::handlePlayTrack( const query_ptr& qry )
|
||||||
{
|
{
|
||||||
@@ -493,7 +502,6 @@ GlobalActionManager::handlePlayTrack( const query_ptr& qry )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
GlobalActionManager::handleQueueCommand( const QUrl& url )
|
GlobalActionManager::handleQueueCommand( const QUrl& url )
|
||||||
{
|
{
|
||||||
@@ -996,6 +1004,8 @@ GlobalActionManager::playRdio( const QUrl& url )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
bool GlobalActionManager::handleBookmarkCommand(const QUrl& url)
|
bool GlobalActionManager::handleBookmarkCommand(const QUrl& url)
|
||||||
{
|
{
|
||||||
@@ -1076,6 +1086,7 @@ GlobalActionManager::shortenLinkRequestFinished()
|
|||||||
if ( !shortUrl.isValid() )
|
if ( !shortUrl.isValid() )
|
||||||
error = true;
|
error = true;
|
||||||
|
|
||||||
|
#ifndef ENABLE_HEADLESS
|
||||||
// Success! Here is the short link
|
// Success! Here is the short link
|
||||||
if ( m_clipboardLongUrl == reply->request().url() )
|
if ( m_clipboardLongUrl == reply->request().url() )
|
||||||
{
|
{
|
||||||
@@ -1088,6 +1099,7 @@ GlobalActionManager::shortenLinkRequestFinished()
|
|||||||
m_clipboardLongUrl.clear();
|
m_clipboardLongUrl.clear();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if ( !error )
|
if ( !error )
|
||||||
emit shortLinkReady( longUrl, shortUrl, callbackObj );
|
emit shortLinkReady( longUrl, shortUrl, callbackObj );
|
||||||
@@ -1099,6 +1111,8 @@ GlobalActionManager::shortenLinkRequestFinished()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef ENABLE_HEADLESS
|
||||||
|
|
||||||
void
|
void
|
||||||
GlobalActionManager::postShortenFinished()
|
GlobalActionManager::postShortenFinished()
|
||||||
{
|
{
|
||||||
@@ -1118,6 +1132,9 @@ GlobalActionManager::postShortenFinished()
|
|||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GlobalActionManager::shortenLinkRequestError( QNetworkReply::NetworkError error )
|
GlobalActionManager::shortenLinkRequestError( QNetworkReply::NetworkError error )
|
||||||
{
|
{
|
||||||
@@ -1172,6 +1189,8 @@ GlobalActionManager::doBookmark( const playlist_ptr& pl, const query_ptr& q )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef ENABLE_HEADLESS
|
||||||
|
|
||||||
void
|
void
|
||||||
GlobalActionManager::showPlaylist()
|
GlobalActionManager::showPlaylist()
|
||||||
{
|
{
|
||||||
@@ -1214,13 +1233,6 @@ GlobalActionManager::waitingForResolved( bool /* success */ )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
|
||||||
GlobalActionManager::hostname() const
|
|
||||||
{
|
|
||||||
return QString( "http://toma.hk" );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// SPOTIFY URL HANDLING
|
/// SPOTIFY URL HANDLING
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -1243,3 +1255,11 @@ GlobalActionManager::openRdioLink( const QString& link )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
GlobalActionManager::hostname() const
|
||||||
|
{
|
||||||
|
return QString( "http://toma.hk" );
|
||||||
|
}
|
||||||
|
@@ -45,6 +45,11 @@ public:
|
|||||||
QUrl openLinkFromQuery( const Tomahawk::query_ptr& query ) const;
|
QUrl openLinkFromQuery( const Tomahawk::query_ptr& query ) const;
|
||||||
QUrl openLink( const QString& title, const QString& artist, const QString& album ) 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
|
/// Takes a spotify link and performs the default open action on it
|
||||||
bool openSpotifyLink( const QString& link );
|
bool openSpotifyLink( const QString& link );
|
||||||
|
|
||||||
@@ -55,58 +60,62 @@ public:
|
|||||||
QString copyPlaylistToClipboard( const Tomahawk::dynplaylist_ptr& playlist );
|
QString copyPlaylistToClipboard( const Tomahawk::dynplaylist_ptr& playlist );
|
||||||
void savePlaylistToFile( const Tomahawk::playlist_ptr& playlist, const QString& filename );
|
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 );
|
bool parseTomahawkLink( const QString& link );
|
||||||
|
void getShortLink( const Tomahawk::playlist_ptr& playlist );
|
||||||
void waitingForResolved( bool );
|
void waitingForResolved( bool );
|
||||||
|
|
||||||
Tomahawk::dynplaylist_ptr loadDynamicPlaylist( const QUrl& url, bool station );
|
Tomahawk::dynplaylist_ptr loadDynamicPlaylist( const QUrl& url, bool station );
|
||||||
|
|
||||||
void handleOpenTrack( const Tomahawk::query_ptr& qry );
|
void handleOpenTrack( const Tomahawk::query_ptr& qry );
|
||||||
void handlePlayTrack( const Tomahawk::query_ptr& qry );
|
void handlePlayTrack( const Tomahawk::query_ptr& qry );
|
||||||
|
#endif
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void shortLinkReady( const QUrl& longUrl, const QUrl& shortUrl, const QVariant& callbackObj );
|
void shortLinkReady( const QUrl& longUrl, const QUrl& shortUrl, const QVariant& callbackObj );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void shortenLinkRequestFinished();
|
void shortenLinkRequestFinished();
|
||||||
void postShortenFinished();
|
|
||||||
void shortenLinkRequestError( QNetworkReply::NetworkError );
|
void shortenLinkRequestError( QNetworkReply::NetworkError );
|
||||||
|
|
||||||
void bookmarkPlaylistCreated( const Tomahawk::playlist_ptr& pl );
|
void bookmarkPlaylistCreated( const Tomahawk::playlist_ptr& pl );
|
||||||
|
|
||||||
|
#ifndef ENABLE_HEADLESS
|
||||||
|
void postShortenFinished();
|
||||||
void showPlaylist();
|
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 playlistCreatedToShow( const Tomahawk::playlist_ptr& pl );
|
||||||
void playlistReadyToShow();
|
void playlistReadyToShow();
|
||||||
|
|
||||||
|
void xspfCreated( const QByteArray& xspf );
|
||||||
|
|
||||||
|
void playOrQueueNow( const Tomahawk::query_ptr& );
|
||||||
|
void playNow( const Tomahawk::query_ptr& );
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit GlobalActionManager( QObject* parent = 0 );
|
explicit GlobalActionManager( QObject* parent = 0 );
|
||||||
void doBookmark( const Tomahawk::playlist_ptr& pl, const Tomahawk::query_ptr& q );
|
void doBookmark( const Tomahawk::playlist_ptr& pl, const Tomahawk::query_ptr& q );
|
||||||
|
|
||||||
/// handle opening of urls
|
/// handle opening of urls
|
||||||
|
#ifndef ENABLE_HEADLESS
|
||||||
bool handlePlaylistCommand( const QUrl& url );
|
bool handlePlaylistCommand( const QUrl& url );
|
||||||
bool handleCollectionCommand(const QUrl& url );
|
bool handleViewCommand( const QUrl& url );
|
||||||
bool handleQueueCommand(const QUrl& url );
|
bool handleStationCommand( const QUrl& url );
|
||||||
bool handleStationCommand(const QUrl& url );
|
bool handleSearchCommand( const QUrl& url );
|
||||||
bool handleAutoPlaylistCommand(const QUrl& url );
|
bool handleQueueCommand( const QUrl& url );
|
||||||
bool handleSearchCommand(const QUrl& url );
|
bool handleAutoPlaylistCommand( const QUrl& url );
|
||||||
bool handlePlayCommand(const QUrl& url );
|
|
||||||
bool handleBookmarkCommand(const QUrl& url );
|
|
||||||
bool handleOpenCommand(const QUrl& url );
|
|
||||||
bool handleViewCommand(const QUrl& url );
|
|
||||||
bool doQueueAdd( const QStringList& parts, const QList< QPair< QString, QString > >& queryItems );
|
bool doQueueAdd( const QStringList& parts, const QList< QPair< QString, QString > >& queryItems );
|
||||||
|
|
||||||
bool playSpotify( const QUrl& url );
|
bool playSpotify( const QUrl& url );
|
||||||
bool queueSpotify( const QStringList& parts, const QList< QPair< QString, QString > >& queryItems );
|
bool queueSpotify( const QStringList& parts, const QList< QPair< QString, QString > >& queryItems );
|
||||||
bool playRdio( const QUrl& url );
|
bool playRdio( const QUrl& url );
|
||||||
bool queueRdio( const QStringList& parts, const QList< QPair< QString, QString > >& queryItems );
|
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;
|
QString hostname() const;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user