/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. #ifndef GLOBALACTIONMANAGER_H
  20. #define GLOBALACTIONMANAGER_H
  21. #include "Playlist.h"
  22. #include "playlist/dynamic/DynamicPlaylist.h"
  23. #include "DllMacro.h"
  24. #include <QNetworkAccessManager>
  25. #include <QNetworkReply>
  26. #include <QObject>
  27. #include <QUrl>
  28. /**
  29. * Handles global actions such as parsing and creation of links, mime data handling, etc
  30. */
  31. class DLLEXPORT GlobalActionManager : public QObject
  32. {
  33. Q_OBJECT
  34. public:
  35. static GlobalActionManager* instance();
  36. virtual ~GlobalActionManager();
  37. void installResolverFromFile( const QString& resolverPath );
  38. public slots:
  39. /**
  40. * Try to open a URL as Playlist/Album/Artist/Track
  41. */
  42. bool openUrl( const QString& url );
  43. /// Takes a spotify link and performs the default open action on it
  44. bool openSpotifyLink( const QString& link );
  45. void savePlaylistToFile( const Tomahawk::playlist_ptr& playlist, const QString& filename );
  46. bool parseTomahawkLink( const QString& link );
  47. void waitingForResolved( bool );
  48. Tomahawk::dynplaylist_ptr loadDynamicPlaylist( const QUrl& url, bool station );
  49. void handleOpenTrack( const Tomahawk::query_ptr& qry );
  50. void handleOpenTracks( const QList< Tomahawk::query_ptr >& queries );
  51. void handlePlayTrack( const Tomahawk::query_ptr& qry );
  52. private slots:
  53. void informationForUrl( const QString& url, const QSharedPointer<QObject>& information );
  54. void showPlaylist();
  55. void playlistCreatedToShow( const Tomahawk::playlist_ptr& pl );
  56. void playlistReadyToShow();
  57. void xspfCreated( const QByteArray& xspf );
  58. void playOrQueueNow( const Tomahawk::query_ptr& );
  59. void playNow( const Tomahawk::query_ptr& );
  60. private:
  61. explicit GlobalActionManager( QObject* parent = 0 );
  62. /// handle opening of urls
  63. bool handlePlaylistCommand( const QUrl& url );
  64. bool handleViewCommand( const QUrl& url );
  65. bool handleStationCommand( const QUrl& url );
  66. bool handleSearchCommand( const QUrl& url );
  67. bool handleQueueCommand( const QUrl& url );
  68. bool handleAutoPlaylistCommand( const QUrl& url );
  69. bool handleImportCommand( const QUrl& url );
  70. bool doQueueAdd( const QStringList& parts, const QList< QPair< QString, QString > >& queryItems );
  71. bool playSpotify( const QUrl& url );
  72. bool queueSpotify( const QStringList& parts, const QList< QPair< QString, QString > >& queryItems );
  73. bool handleCollectionCommand( const QUrl& url );
  74. bool handlePlayCommand( const QUrl& url );
  75. bool handleOpenCommand( const QUrl& url );
  76. bool handleLoveCommand( const QUrl& url );
  77. void createPlaylistFromUrl( const QString& type, const QString& url, const QString& title );
  78. Tomahawk::playlist_ptr m_toShow;
  79. Tomahawk::query_ptr m_waitingToPlay;
  80. QString m_queuedUrl;
  81. static GlobalActionManager* s_instance;
  82. };
  83. #endif // GLOBALACTIONMANAGER_H