PageRenderTime 163ms CodeModel.GetById 81ms app.highlight 8ms RepoModel.GetById 72ms app.codeStats 0ms

/src/libtomahawk/GlobalActionManager.h

http://github.com/tomahawk-player/tomahawk
C Header | 109 lines | 57 code | 26 blank | 26 comment | 0 complexity | c29bf072d97fc28fd9d3ecea6b168574 MD5 | raw file
  1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
  2 *
  3 *   Copyright 2011,      Leo Franchi <lfranchi@kde.org>
  4 *   Copyright 2011-2016, Christian Muehlhaeuser <muesli@tomahawk-player.org>
  5 *
  6 *   Tomahawk is free software: you can redistribute it and/or modify
  7 *   it under the terms of the GNU General Public License as published by
  8 *   the Free Software Foundation, either version 3 of the License, or
  9 *   (at your option) any later version.
 10 *
 11 *   Tomahawk is distributed in the hope that it will be useful,
 12 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 13 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 14 *   GNU General Public License for more details.
 15 *
 16 *   You should have received a copy of the GNU General Public License
 17 *   along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
 18 */
 19
 20#ifndef GLOBALACTIONMANAGER_H
 21#define GLOBALACTIONMANAGER_H
 22
 23#include "Playlist.h"
 24#include "playlist/dynamic/DynamicPlaylist.h"
 25#include "DllMacro.h"
 26
 27#include <QNetworkAccessManager>
 28#include <QNetworkReply>
 29#include <QObject>
 30#include <QUrl>
 31
 32/**
 33 * Handles global actions such as parsing and creation of links, mime data handling, etc
 34 */
 35class DLLEXPORT GlobalActionManager : public QObject
 36{
 37    Q_OBJECT
 38public:
 39    static GlobalActionManager* instance();
 40    virtual ~GlobalActionManager();
 41
 42    void installResolverFromFile( const QString& resolverPath );
 43
 44public slots:
 45
 46    /**
 47     * Try to open a URL as Playlist/Album/Artist/Track
 48     */
 49    bool openUrl( const QString& url );
 50
 51    /// Takes a spotify link and performs the default open action on it
 52    bool openSpotifyLink( const QString& link );
 53
 54    void savePlaylistToFile( const Tomahawk::playlist_ptr& playlist, const QString& filename );
 55
 56    bool parseTomahawkLink( const QString& link );
 57    void waitingForResolved( bool );
 58
 59    Tomahawk::dynplaylist_ptr loadDynamicPlaylist( const QUrl& url, bool station );
 60
 61    void handleOpenTrack( const Tomahawk::query_ptr& qry );
 62    void handleOpenTracks( const QList< Tomahawk::query_ptr >& queries );
 63
 64    void handlePlayTrack( const Tomahawk::query_ptr& qry );
 65
 66private slots:
 67    void informationForUrl( const QString& url, const QSharedPointer<QObject>& information );
 68
 69    void showPlaylist();
 70
 71    void playlistCreatedToShow( const Tomahawk::playlist_ptr& pl );
 72    void playlistReadyToShow();
 73
 74    void xspfCreated( const QByteArray& xspf );
 75
 76    void playOrQueueNow( const Tomahawk::query_ptr& );
 77    void playNow( const Tomahawk::query_ptr& );
 78
 79private:
 80    explicit GlobalActionManager( QObject* parent = 0 );
 81
 82    /// handle opening of urls
 83    bool handlePlaylistCommand( const QUrl& url );
 84    bool handleViewCommand( const QUrl& url );
 85    bool handleStationCommand( const QUrl& url );
 86    bool handleSearchCommand( const QUrl& url );
 87    bool handleQueueCommand( const QUrl& url );
 88    bool handleAutoPlaylistCommand( const QUrl& url );
 89    bool handleImportCommand( const QUrl& url );
 90    bool doQueueAdd( const QStringList& parts, const QList< QPair< QString, QString > >& queryItems );
 91
 92    bool playSpotify( const QUrl& url );
 93    bool queueSpotify( const QStringList& parts, const QList< QPair< QString, QString > >& queryItems );
 94
 95    bool handleCollectionCommand( const QUrl& url );
 96    bool handlePlayCommand( const QUrl& url );
 97    bool handleOpenCommand( const QUrl& url );
 98    bool handleLoveCommand( const QUrl& url );
 99
100    void createPlaylistFromUrl( const QString& type, const QString& url, const QString& title );
101
102    Tomahawk::playlist_ptr m_toShow;
103    Tomahawk::query_ptr m_waitingToPlay;
104    QString m_queuedUrl;
105
106    static GlobalActionManager* s_instance;
107};
108
109#endif // GLOBALACTIONMANAGER_H