From 9542aaffb4be638f6289073b774edb4cc2e3afd7 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Sat, 29 Nov 2014 17:58:10 +0100 Subject: [PATCH] Pull link generation out of GlobalActionManager --- src/accounts/xmpp/XmppInfoPlugin.cpp | 4 +- src/libtomahawk/CMakeLists.txt | 1 + src/libtomahawk/ContextMenu.cpp | 8 +- src/libtomahawk/GlobalActionManager.cpp | 159 +------------ src/libtomahawk/GlobalActionManager.h | 16 -- .../infosystem/InfoSystemWorker.cpp | 6 +- src/libtomahawk/utils/LinkGenerator.cpp | 208 ++++++++++++++++++ src/libtomahawk/utils/LinkGenerator.h | 68 ++++++ src/tomahawk/sourcetree/SourceTreeView.cpp | 5 +- .../sourcetree/items/TemporaryPageItem.cpp | 8 +- src/tomahawk/widgets/SocialWidget.cpp | 4 +- 11 files changed, 297 insertions(+), 190 deletions(-) create mode 100644 src/libtomahawk/utils/LinkGenerator.cpp create mode 100644 src/libtomahawk/utils/LinkGenerator.h diff --git a/src/accounts/xmpp/XmppInfoPlugin.cpp b/src/accounts/xmpp/XmppInfoPlugin.cpp index fdeff5d8b..141ca4869 100644 --- a/src/accounts/xmpp/XmppInfoPlugin.cpp +++ b/src/accounts/xmpp/XmppInfoPlugin.cpp @@ -20,7 +20,7 @@ #include "XmppInfoPlugin.h" -#include "GlobalActionManager.h" +#include "utils/LinkGenerator.h" #include "sip/XmppSip.h" #include "utils/Logger.h" #include "TomahawkSettings.h" @@ -122,7 +122,7 @@ Tomahawk::InfoSystem::XmppInfoPlugin::audioStarted( const Tomahawk::InfoSystem:: if ( pushInfoPair.first.contains( "shorturl" ) ) url = pushInfoPair.first[ "shorturl" ].toUrl(); else - url = GlobalActionManager::instance()->openLink( info.value( "title" ), info.value( "artist" ), info.value( "album" ) ); + url = Utils::LinkGenerator::instance()->openLink( info.value( "title" ), info.value( "artist" ), info.value( "album" ) ); emit publishTune( url, info ); } diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index 532619be8..e449a6522 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -117,6 +117,7 @@ set( libGuiSources utils/NetworkProxyFactory.cpp utils/NetworkAccessManager.cpp utils/ShortLinkHelper.cpp + utils/LinkGenerator.cpp viewpages/SearchViewPage.cpp viewpages/SourceViewPage.cpp diff --git a/src/libtomahawk/ContextMenu.cpp b/src/libtomahawk/ContextMenu.cpp index a1904345f..e5f82565d 100644 --- a/src/libtomahawk/ContextMenu.cpp +++ b/src/libtomahawk/ContextMenu.cpp @@ -24,7 +24,7 @@ #include "playlist/TrackView.h" #include "playlist/PlayableModel.h" #include "filemetadata/MetadataEditor.h" -#include "GlobalActionManager.h" +#include "utils/LinkGenerator.h" #include "ViewManager.h" #include "Query.h" #include "Result.h" @@ -421,15 +421,15 @@ ContextMenu::copyLink() { if ( m_queries.count() ) { - GlobalActionManager::instance()->copyToClipboard( m_queries.first() ); + Utils::LinkGenerator::instance()->copyToClipboard( m_queries.first() ); } else if ( m_albums.count() ) { - GlobalActionManager::instance()->copyOpenLink( m_albums.first() ); + Utils::LinkGenerator::instance()->copyOpenLink( m_albums.first() ); } else if ( m_artists.count() ) { - GlobalActionManager::instance()->copyOpenLink( m_artists.first() ); + Utils::LinkGenerator::instance()->copyOpenLink( m_artists.first() ); } } diff --git a/src/libtomahawk/GlobalActionManager.cpp b/src/libtomahawk/GlobalActionManager.cpp index 1b14bb2ca..318b85887 100644 --- a/src/libtomahawk/GlobalActionManager.cpp +++ b/src/libtomahawk/GlobalActionManager.cpp @@ -25,9 +25,7 @@ #include "accounts/AccountManager.h" #include "accounts/spotify/SpotifyAccount.h" -#include "accounts/ResolverAccount.h" #include "audio/AudioEngine.h" -#include "database/LocalCollection.h" #include "jobview/ErrorStatusMessage.h" #include "jobview/JobStatusModel.h" #include "jobview/JobStatusView.h" @@ -40,29 +38,19 @@ #include "resolvers/ScriptCommand_LookupUrl.h" #include "utils/JspfLoader.h" #include "utils/Logger.h" -#include "utils/NetworkAccessManager.h" -#include "utils/ShortenedLinkParser.h" -#include "utils/ShortLinkHelper.h" #include "utils/SpotifyParser.h" -#include "utils/TomahawkUtils.h" #include "utils/XspfLoader.h" #include "utils/XspfGenerator.h" #include "viewpages/SearchViewPage.h" -#include "Album.h" -#include "Artist.h" #include "Pipeline.h" -#include "PlaylistEntry.h" -#include "SourceList.h" #include "TomahawkSettings.h" #include "ViewManager.h" -#include -#include -#include - #include +#include +#include GlobalActionManager* GlobalActionManager::s_instance = 0; @@ -91,61 +79,6 @@ GlobalActionManager::~GlobalActionManager() } -QUrl -GlobalActionManager::openLinkFromQuery( const query_ptr& query ) const -{ - QString title = query->track()->track(); - QString artist = query->track()->artist(); - QString album = query->track()->album(); - - return openLink( title, artist, album ); -} - - -QUrl -GlobalActionManager::copyOpenLink( const artist_ptr& artist ) const -{ - const QUrl link( QString( "%1/artist/%2" ).arg( hostname() ).arg( artist->name() ) ); - - QClipboard* cb = QApplication::clipboard(); - QByteArray data = percentEncode( link ); - cb->setText( data ); - - return link; -} - - -QUrl -GlobalActionManager::copyOpenLink( const album_ptr& album ) const -{ - const QUrl link = QUrl::fromUserInput( QString( "%1/album/%2/%3" ).arg( hostname() ).arg( album->artist().isNull() ? QString() : album->artist()->name() ).arg( album->name() ) ); - - QClipboard* cb = QApplication::clipboard(); - QByteArray data = percentEncode( link ); - - cb->setText( data ); - - return link; -} - - -QUrl -GlobalActionManager::openLink( const QString& title, const QString& artist, const QString& album ) const -{ - QUrl link( QString( "%1/open/track/" ).arg( hostname() ) ); - - if ( !artist.isEmpty() ) - TomahawkUtils::urlAddQueryItem( link, "artist", artist ); - if ( !title.isEmpty() ) - TomahawkUtils::urlAddQueryItem( link, "title", title ); - if ( !album.isEmpty() ) - TomahawkUtils::urlAddQueryItem( link, "album", album ); - - return link; -} - - - void GlobalActionManager::installResolverFromFile( const QString& resolverPath ) { @@ -252,57 +185,6 @@ GlobalActionManager::openUrl( const QString& url ) } -QString -GlobalActionManager::copyPlaylistToClipboard( const dynplaylist_ptr& playlist ) -{ - QUrl link( QString( "%1/%2/create/" ).arg( hostname() ).arg( playlist->mode() == OnDemand ? "station" : "autoplaylist" ) ); - - if ( playlist->generator()->type() != "echonest" ) - { - tLog() << "Only echonest generators are supported"; - return QString(); - } - - TomahawkUtils::urlAddQueryItem( link, "type", "echonest" ); - TomahawkUtils::urlAddQueryItem( link, "title", playlist->title() ); - - QList< dyncontrol_ptr > controls = playlist->generator()->controls(); - foreach ( const dyncontrol_ptr& c, controls ) - { - if ( c->selectedType() == "Artist" ) - { - if ( c->match().toInt() == Echonest::DynamicPlaylist::ArtistType ) - TomahawkUtils::urlAddQueryItem( link, "artist_limitto", c->input() ); - else - TomahawkUtils::urlAddQueryItem( link, "artist", c->input() ); - } - else if ( c->selectedType() == "Artist Description" ) - { - TomahawkUtils::urlAddQueryItem( link, "description", c->input() ); - } - else - { - QString name = c->selectedType().toLower().replace( " ", "_" ); - Echonest::DynamicPlaylist::PlaylistParam p = static_cast< Echonest::DynamicPlaylist::PlaylistParam >( c->match().toInt() ); - // if it is a max, set that too - if ( p == Echonest::DynamicPlaylist::MaxTempo || p == Echonest::DynamicPlaylist::MaxDuration || p == Echonest::DynamicPlaylist::MaxLoudness - || p == Echonest::DynamicPlaylist::MaxDanceability || p == Echonest::DynamicPlaylist::MaxEnergy || p == Echonest::DynamicPlaylist::ArtistMaxFamiliarity - || p == Echonest::DynamicPlaylist::ArtistMaxHotttnesss || p == Echonest::DynamicPlaylist::SongMaxHotttnesss || p == Echonest::DynamicPlaylist::ArtistMaxLatitude - || p == Echonest::DynamicPlaylist::ArtistMaxLongitude ) - name += "_max"; - - TomahawkUtils::urlAddQueryItem( link, name, c->input() ); - } - } - - QClipboard* cb = QApplication::clipboard(); - QByteArray data = percentEncode( link ); - cb->setText( data ); - - return link.toString(); -} - - void GlobalActionManager::savePlaylistToFile( const playlist_ptr& playlist, const QString& filename ) { @@ -332,20 +214,6 @@ GlobalActionManager::xspfCreated( const QByteArray& xspf ) } -void -GlobalActionManager::copyToClipboard( const query_ptr& query ) -{ - m_clipboardLongUrl = openLinkFromQuery( query ); - Tomahawk::Utils::ShortLinkHelper* slh = new Tomahawk::Utils::ShortLinkHelper(); - connect( slh, SIGNAL( shortLinkReady( QUrl, QUrl, QVariant ) ), - SLOT( copyToClipboardReady( QUrl, QUrl, QVariant ) ) ); - connect( slh, SIGNAL( done() ), - slh, SLOT( deleteLater() ), - Qt::QueuedConnection ); - slh->shortenLink( m_clipboardLongUrl ); -} - - bool GlobalActionManager::parseTomahawkLink( const QString& urlIn ) { @@ -741,22 +609,6 @@ GlobalActionManager::informationForUrl(const QString& url, const QSharedPointer< } -void -GlobalActionManager::copyToClipboardReady( const QUrl& longUrl, const QUrl& shortUrl, const QVariant& ) -{ - // Copy resulting url to clipboard - if ( m_clipboardLongUrl == longUrl ) - { - QClipboard* cb = QApplication::clipboard(); - - QByteArray data = TomahawkUtils::percentEncode( shortUrl.isEmpty() ? longUrl : shortUrl ); - cb->setText( data ); - - m_clipboardLongUrl.clear(); - } -} - - bool GlobalActionManager::handleQueueCommand( const QUrl& url ) { @@ -1352,10 +1204,3 @@ GlobalActionManager::openSpotifyLink( const QString& link ) return true; } - - -QString -GlobalActionManager::hostname() const -{ - return QString( "http://toma.hk" ); -} diff --git a/src/libtomahawk/GlobalActionManager.h b/src/libtomahawk/GlobalActionManager.h index 09e7d94b2..e955e49c9 100644 --- a/src/libtomahawk/GlobalActionManager.h +++ b/src/libtomahawk/GlobalActionManager.h @@ -39,13 +39,6 @@ public: static GlobalActionManager* instance(); virtual ~GlobalActionManager(); - QUrl openLinkFromQuery( const Tomahawk::query_ptr& query ) const; - - QUrl copyOpenLink( const Tomahawk::artist_ptr& artist ) const; - QUrl copyOpenLink( const Tomahawk::album_ptr& album ) const; - - QUrl openLink( const QString& title, const QString& artist, const QString& album ) const; - void installResolverFromFile( const QString& resolverPath ); public slots: @@ -58,11 +51,6 @@ public slots: /// Takes a spotify link and performs the default open action on it bool openSpotifyLink( const QString& link ); - /// Creates a link from the requested data and copies it to the clipboard - void copyToClipboard( const Tomahawk::query_ptr& query ); - - - QString copyPlaylistToClipboard( const Tomahawk::dynplaylist_ptr& playlist ); void savePlaylistToFile( const Tomahawk::playlist_ptr& playlist, const QString& filename ); bool parseTomahawkLink( const QString& link ); @@ -77,7 +65,6 @@ public slots: private slots: void informationForUrl( const QString& url, const QSharedPointer& information ); - void copyToClipboardReady( const QUrl& longUrl, const QUrl& shortUrl, const QVariant& callbackObj ); void showPlaylist(); @@ -112,11 +99,8 @@ private: void createPlaylistFromUrl( const QString& type, const QString& url, const QString& title ); - QString hostname() const; - Tomahawk::playlist_ptr m_toShow; Tomahawk::query_ptr m_waitingToPlay; - QUrl m_clipboardLongUrl; QString m_queuedUrl; static GlobalActionManager* s_instance; diff --git a/src/libtomahawk/infosystem/InfoSystemWorker.cpp b/src/libtomahawk/infosystem/InfoSystemWorker.cpp index d0c8ee36b..db76e5358 100644 --- a/src/libtomahawk/infosystem/InfoSystemWorker.cpp +++ b/src/libtomahawk/infosystem/InfoSystemWorker.cpp @@ -24,7 +24,7 @@ #include "utils/ShortLinkHelper.h" #include "utils/TomahawkUtils.h" #include "config.h" -#include "GlobalActionManager.h" +#include "utils/LinkGenerator.h" #include "InfoSystemCache.h" #include "PlaylistEntry.h" #include "utils/TomahawkUtils.h" @@ -337,7 +337,7 @@ InfoSystemWorker::getShortUrl( Tomahawk::InfoSystem::InfoPushData pushData ) if( hash.contains( "album" ) ) album = hash[ "album" ]; - QUrl longUrl = GlobalActionManager::instance()->openLink( title, artist, album ); + QUrl longUrl = Utils::LinkGenerator::instance()->openLink( title, artist, album ); Tomahawk::Utils::ShortLinkHelper* slh = new Tomahawk::Utils::ShortLinkHelper(); connect( slh, SIGNAL( shortLinkReady( QUrl, QUrl, QVariant ) ), @@ -356,7 +356,7 @@ InfoSystemWorker::shortLinkReady( QUrl longUrl, QUrl shortUrl, QVariant callback tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "long url = " << longUrl << ", shortUrl = " << shortUrl; m_shortLinksWaiting--; if ( !m_shortLinksWaiting ) - disconnect( GlobalActionManager::instance(), SIGNAL( shortLinkReady( QUrl, QUrl, QVariant ) ) ); + disconnect( Utils::LinkGenerator::instance(), SIGNAL( shortLinkReady( QUrl, QUrl, QVariant ) ) ); if ( !callbackObj.isValid() ) { diff --git a/src/libtomahawk/utils/LinkGenerator.cpp b/src/libtomahawk/utils/LinkGenerator.cpp new file mode 100644 index 000000000..328942cfb --- /dev/null +++ b/src/libtomahawk/utils/LinkGenerator.cpp @@ -0,0 +1,208 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright (C) 2011 Leo Franchi + * Copyright (C) 2011, Jeff Mitchell + * Copyright (C) 2011-2014, Christian Muehlhaeuser + * Copyright (C) 2013, Uwe L. Korn + * Copyright (C) 2013, Teo Mrnjavac + * Copyright (C) 2014, Dominik Schmidt + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#include "LinkGenerator.h" + +#include "TomahawkUtils.h" +#include "Logger.h" +#include "ShortLinkHelper.h" + +#include "playlist/dynamic/GeneratorInterface.h" +#include "playlist/dynamic/DynamicPlaylist.h" +#include "../Track.h" +#include "../Artist.h" +#include "../Album.h" + +#include + +#include +#include + + +using namespace Tomahawk; +using namespace Tomahawk::Utils; + +LinkGenerator* LinkGenerator::s_instance = 0; + + +LinkGenerator* +LinkGenerator::instance() +{ + if ( !s_instance ) + s_instance = new LinkGenerator; + + return s_instance; +} + + +LinkGenerator::LinkGenerator( QObject* parent ) + : QObject( parent ) +{ +} + + +LinkGenerator::~LinkGenerator() +{ +} + + +QString +LinkGenerator::hostname() const +{ + return QString( "http://toma.hk" ); +} + + +QUrl +LinkGenerator::openLinkFromQuery( const query_ptr& query ) const +{ + QString title = query->track()->track(); + QString artist = query->track()->artist(); + QString album = query->track()->album(); + + return openLink( title, artist, album ); +} + + +QUrl +LinkGenerator::copyOpenLink( const artist_ptr& artist ) const +{ + const QUrl link( QString( "%1/artist/%2" ).arg( hostname() ).arg( artist->name() ) ); + + QClipboard* cb = QApplication::clipboard(); + QByteArray data = TomahawkUtils::percentEncode( link ); + cb->setText( data ); + + return link; +} + + +QUrl +LinkGenerator::copyOpenLink( const album_ptr& album ) const +{ + const QUrl link = QUrl::fromUserInput( QString( "%1/album/%2/%3" ).arg( hostname() ).arg( album->artist().isNull() ? QString() : album->artist()->name() ).arg( album->name() ) ); + + QClipboard* cb = QApplication::clipboard(); + QByteArray data = TomahawkUtils::percentEncode( link ); + + cb->setText( data ); + + return link; +} + + +QUrl +LinkGenerator::openLink( const QString& title, const QString& artist, const QString& album ) const +{ + QUrl link( QString( "%1/open/track/" ).arg( hostname() ) ); + + if ( !artist.isEmpty() ) + TomahawkUtils::urlAddQueryItem( link, "artist", artist ); + if ( !title.isEmpty() ) + TomahawkUtils::urlAddQueryItem( link, "title", title ); + if ( !album.isEmpty() ) + TomahawkUtils::urlAddQueryItem( link, "album", album ); + + return link; +} + + +QString +LinkGenerator::copyPlaylistToClipboard( const dynplaylist_ptr& playlist ) +{ + QUrl link( QString( "%1/%2/create/" ).arg( hostname() ).arg( playlist->mode() == OnDemand ? "station" : "autoplaylist" ) ); + + if ( playlist->generator()->type() != "echonest" ) + { + tLog() << "Only echonest generators are supported"; + return QString(); + } + + TomahawkUtils::urlAddQueryItem( link, "type", "echonest" ); + TomahawkUtils::urlAddQueryItem( link, "title", playlist->title() ); + + QList< dyncontrol_ptr > controls = playlist->generator()->controls(); + foreach ( const dyncontrol_ptr& c, controls ) + { + if ( c->selectedType() == "Artist" ) + { + if ( c->match().toInt() == Echonest::DynamicPlaylist::ArtistType ) + TomahawkUtils::urlAddQueryItem( link, "artist_limitto", c->input() ); + else + TomahawkUtils::urlAddQueryItem( link, "artist", c->input() ); + } + else if ( c->selectedType() == "Artist Description" ) + { + TomahawkUtils::urlAddQueryItem( link, "description", c->input() ); + } + else + { + QString name = c->selectedType().toLower().replace( " ", "_" ); + Echonest::DynamicPlaylist::PlaylistParam p = static_cast< Echonest::DynamicPlaylist::PlaylistParam >( c->match().toInt() ); + // if it is a max, set that too + if ( p == Echonest::DynamicPlaylist::MaxTempo || p == Echonest::DynamicPlaylist::MaxDuration || p == Echonest::DynamicPlaylist::MaxLoudness + || p == Echonest::DynamicPlaylist::MaxDanceability || p == Echonest::DynamicPlaylist::MaxEnergy || p == Echonest::DynamicPlaylist::ArtistMaxFamiliarity + || p == Echonest::DynamicPlaylist::ArtistMaxHotttnesss || p == Echonest::DynamicPlaylist::SongMaxHotttnesss || p == Echonest::DynamicPlaylist::ArtistMaxLatitude + || p == Echonest::DynamicPlaylist::ArtistMaxLongitude ) + name += "_max"; + + TomahawkUtils::urlAddQueryItem( link, name, c->input() ); + } + } + + QClipboard* cb = QApplication::clipboard(); + QByteArray data = TomahawkUtils::percentEncode( link ); + cb->setText( data ); + + return link.toString(); +} + + +void +LinkGenerator::copyToClipboard( const query_ptr& query ) +{ + m_clipboardLongUrl = openLinkFromQuery( query ); + Tomahawk::Utils::ShortLinkHelper* slh = new Tomahawk::Utils::ShortLinkHelper(); + connect( slh, SIGNAL( shortLinkReady( QUrl, QUrl, QVariant ) ), + SLOT( copyToClipboardReady( QUrl, QUrl, QVariant ) ) ); + connect( slh, SIGNAL( done() ), + slh, SLOT( deleteLater() ), + Qt::QueuedConnection ); + slh->shortenLink( m_clipboardLongUrl ); +} + + +void +LinkGenerator::copyToClipboardReady( const QUrl& longUrl, const QUrl& shortUrl, const QVariant& ) +{ + // Copy resulting url to clipboard + if ( m_clipboardLongUrl == longUrl ) + { + QClipboard* cb = QApplication::clipboard(); + + QByteArray data = TomahawkUtils::percentEncode( shortUrl.isEmpty() ? longUrl : shortUrl ); + cb->setText( data ); + + m_clipboardLongUrl.clear(); + } +} diff --git a/src/libtomahawk/utils/LinkGenerator.h b/src/libtomahawk/utils/LinkGenerator.h new file mode 100644 index 000000000..94e9028da --- /dev/null +++ b/src/libtomahawk/utils/LinkGenerator.h @@ -0,0 +1,68 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright (C) 2011 Leo Franchi + * Copyright (C) 2014 Dominik Schmidt + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#pragma once +#ifndef TOMAHAWK_UTILS_LINKGENERATOR_H +#define TOMAHAWK_UTILS_LINKGENERATOR_H + +#include "DllMacro.h" +#include "Typedefs.h" + +namespace Tomahawk { +namespace Utils { + +class ShortLinkHelperPrivate; + +class DLLEXPORT LinkGenerator : public QObject +{ + Q_OBJECT +public: + static LinkGenerator* instance(); + virtual ~LinkGenerator(); + + QUrl openLinkFromQuery( const Tomahawk::query_ptr& query ) const; + + QUrl copyOpenLink( const Tomahawk::artist_ptr& artist ) const; + QUrl copyOpenLink( const Tomahawk::album_ptr& album ) const; + + QUrl openLink( const QString& title, const QString& artist, const QString& album ) const; + + QString copyPlaylistToClipboard( const Tomahawk::dynplaylist_ptr& playlist ); + + +public slots: + /// Creates a link from the requested data and copies it to the clipboard + void copyToClipboard( const Tomahawk::query_ptr& query ); + +private slots: + void copyToClipboardReady( const QUrl& longUrl, const QUrl& shortUrl, const QVariant& callbackObj ); + +private: + explicit LinkGenerator( QObject* parent = 0 ); + QString hostname() const; + + QUrl m_clipboardLongUrl; + + static LinkGenerator* s_instance; +}; + +} // namespace Utils +} // namespace Tomahawk + +#endif // TOMAHAWK_UTILS_LINKGENERATOR_H diff --git a/src/tomahawk/sourcetree/SourceTreeView.cpp b/src/tomahawk/sourcetree/SourceTreeView.cpp index 2634aff06..a98c1049c 100644 --- a/src/tomahawk/sourcetree/SourceTreeView.cpp +++ b/src/tomahawk/sourcetree/SourceTreeView.cpp @@ -38,6 +38,7 @@ #include "database/Database.h" #include "LatchManager.h" #include "GlobalActionManager.h" +#include "utils/LinkGenerator.h" #include "utils/Closure.h" #include "utils/Logger.h" #include "utils/ShortLinkHelper.h" @@ -502,7 +503,7 @@ SourceTreeView::copyPlaylistLink() { DynamicPlaylistItem* item = itemFromIndex< DynamicPlaylistItem >( m_contextMenuIndex ); dynplaylist_ptr playlist = item->dynPlaylist(); - GlobalActionManager::instance()->copyPlaylistToClipboard( playlist ); + Utils::LinkGenerator::instance()->copyPlaylistToClipboard( playlist ); } else if ( type == SourcesModel::StaticPlaylist ) { @@ -562,7 +563,7 @@ SourceTreeView::addToLocal() // copy to a link and then generate a new playlist from that // this way we cheaply regenerate the needed controls - QString link = GlobalActionManager::instance()->copyPlaylistToClipboard( playlist ); + QString link = Utils::LinkGenerator::instance()->copyPlaylistToClipboard( playlist ); GlobalActionManager::instance()->parseTomahawkLink( link ); } else if ( type == SourcesModel::StaticPlaylist ) diff --git a/src/tomahawk/sourcetree/items/TemporaryPageItem.cpp b/src/tomahawk/sourcetree/items/TemporaryPageItem.cpp index 7f8b48cd9..2c43f99ec 100644 --- a/src/tomahawk/sourcetree/items/TemporaryPageItem.cpp +++ b/src/tomahawk/sourcetree/items/TemporaryPageItem.cpp @@ -19,7 +19,7 @@ #include "TemporaryPageItem.h" -#include "GlobalActionManager.h" +#include "utils/LinkGenerator.h" #include "ViewManager.h" #include "viewpages/AlbumViewPage.h" #include "viewpages/ArtistViewPage.h" @@ -139,7 +139,7 @@ TemporaryPageItem::linkActionTriggered( QAction* action ) { ArtistInfoWidget* aPage = dynamic_cast< ArtistInfoWidget* >( m_page ); Q_ASSERT( aPage ); - GlobalActionManager::instance()->copyOpenLink( aPage->artist() ); + Utils::LinkGenerator::instance()->copyOpenLink( aPage->artist() ); break; } @@ -147,7 +147,7 @@ TemporaryPageItem::linkActionTriggered( QAction* action ) { AlbumInfoWidget* aPage = dynamic_cast< AlbumInfoWidget* >( m_page ); Q_ASSERT( aPage ); - GlobalActionManager::instance()->copyOpenLink( aPage->album() ); + Utils::LinkGenerator::instance()->copyOpenLink( aPage->album() ); break; } @@ -155,7 +155,7 @@ TemporaryPageItem::linkActionTriggered( QAction* action ) { TrackInfoWidget* tPage = dynamic_cast< TrackInfoWidget* >( m_page ); Q_ASSERT( tPage ); - GlobalActionManager::instance()->copyToClipboard( tPage->query() ); + Utils::LinkGenerator::instance()->copyToClipboard( tPage->query() ); break; } diff --git a/src/tomahawk/widgets/SocialWidget.cpp b/src/tomahawk/widgets/SocialWidget.cpp index 0076373f4..b3b75fc12 100644 --- a/src/tomahawk/widgets/SocialWidget.cpp +++ b/src/tomahawk/widgets/SocialWidget.cpp @@ -25,7 +25,7 @@ #include "utils/TomahawkUtilsGui.h" #include "utils/Logger.h" -#include "GlobalActionManager.h" +#include "utils/LinkGenerator.h" #include "Source.h" #include "Track.h" @@ -180,7 +180,7 @@ SocialWidget::setQuery( const Tomahawk::query_ptr& query ) onShortLinkReady( QString(), QString(), QVariant() ); onChanged(); - QUrl longUrl = GlobalActionManager::instance()->openLinkFromQuery( query ); + QUrl longUrl = Tomahawk::Utils::LinkGenerator::instance()->openLinkFromQuery( query ); m_slh.shortenLink( longUrl ); }