-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wfindonwebmenu: includes changes. wfindonwebmenu: service url composer added. findonwebmenufactory: class moved in namespace. wfindonwebmenu: addActionServiceMenu add, for DRY wfindonwebmenu: url composer added to each service
- Loading branch information
1 parent
b58dd5b
commit a932ff5
Showing
13 changed files
with
339 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include "findonwebmenufactory.h" | ||
|
||
#include <QMenu> | ||
|
||
#include "findonwebmenuservices/findonwebmenudiscogs.h" | ||
#include "findonwebmenuservices/findonwebmenulastfm.h" | ||
#include "findonwebmenuservices/findonwebmenusoundcloud.h" | ||
|
||
namespace mixxx { | ||
|
||
namespace library { | ||
|
||
void createFindOnWebSubmenus(QMenu* pFindOnWebMenu, const Track& track) { | ||
auto pFindOnWebMenuSoundcloud = make_parented<QMenu>( | ||
new FindOnWebMenuSoundcloud(pFindOnWebMenu, track)); | ||
|
||
auto pFindOnWebMenuDiscogs = make_parented<QMenu>( | ||
new FindOnWebMenuDiscogs(pFindOnWebMenu, track)); | ||
|
||
auto pFindOnWebMenuLastfm = make_parented<QMenu>( | ||
new FindOnWebMenuLastfm(pFindOnWebMenu, track)); | ||
} | ||
|
||
} // namespace library | ||
|
||
} // namespace mixxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include <QMenu> | ||
|
||
class Track; | ||
|
||
namespace mixxx { | ||
|
||
namespace library { | ||
|
||
void createFindOnWebSubmenus(QMenu* pFindOnWebMenu, const Track& track); | ||
|
||
} // namespace library | ||
|
||
} // namespace mixxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#include "findonwebmenudiscogs.h" | ||
|
||
#include <QMenu> | ||
#include <QUrlQuery> | ||
|
||
#include "track/track.h" | ||
#include "util/parented_ptr.h" | ||
|
||
namespace { | ||
const QString kServiceTitle = QStringLiteral("Discogs"); | ||
|
||
const QString kQueryTypeRelease = QStringLiteral("release"); | ||
|
||
const QString kQueryTypeArtist = QStringLiteral("artist"); | ||
|
||
const QString kSearchUrl = QStringLiteral( | ||
"https://www.discogs.com/search/?"); | ||
|
||
const QUrl composeDiscogsUrl(const QString& serviceDefaultUrl, | ||
const QString& query, | ||
const QString& queryType) { | ||
QUrlQuery urlQuery; | ||
urlQuery.addQueryItem("q", query); | ||
urlQuery.addQueryItem("type", queryType); | ||
QUrl url(serviceDefaultUrl); | ||
url.setQuery(urlQuery); | ||
return url; | ||
} | ||
} //namespace | ||
|
||
FindOnWebMenuDiscogs::FindOnWebMenuDiscogs(QMenu* pFindOnWebMenu, const Track& track) { | ||
const QString artist = track.getArtist(); | ||
const QString trackTitle = track.getTitle(); | ||
const QString album = track.getAlbum(); | ||
auto pDiscogsMenu = make_parented<QMenu>(pFindOnWebMenu); | ||
pDiscogsMenu->setTitle(kServiceTitle); | ||
pFindOnWebMenu->addMenu(pDiscogsMenu); | ||
addSeparator(); | ||
if (!artist.isEmpty()) { | ||
const QUrl discogsUrlArtist = composeDiscogsUrl(kSearchUrl, artist, kQueryTypeArtist); | ||
addActionToServiceMenu(pDiscogsMenu, | ||
composeActionText(tr("Artist"), artist), | ||
discogsUrlArtist); | ||
} | ||
if (!trackTitle.isEmpty()) { | ||
if (!artist.isEmpty()) { | ||
const QString artistWithTrackTitle = composeSearchQuery(artist, trackTitle); | ||
const QUrl discogsUrlArtistWithTrackTitle = composeDiscogsUrl( | ||
kSearchUrl, artistWithTrackTitle, kQueryTypeRelease); | ||
addActionToServiceMenu(pDiscogsMenu, | ||
composeActionText( | ||
tr("Artist + Title"), artistWithTrackTitle), | ||
discogsUrlArtistWithTrackTitle); | ||
} | ||
const QUrl discogsUrlTrackTitle = | ||
composeDiscogsUrl(kSearchUrl, trackTitle, kQueryTypeRelease); | ||
addActionToServiceMenu(pDiscogsMenu, | ||
composeActionText(tr("Title"), trackTitle), | ||
discogsUrlTrackTitle); | ||
} | ||
if (!album.isEmpty()) { | ||
if (!artist.isEmpty()) { | ||
const QString artistWithAlbum = composeSearchQuery(artist, album); | ||
const QUrl discogsUrlArtistWithAlbum = composeDiscogsUrl( | ||
kSearchUrl, artistWithAlbum, kQueryTypeRelease); | ||
addActionToServiceMenu(pDiscogsMenu, | ||
composeActionText(tr("Artist + Album"), artistWithAlbum), | ||
discogsUrlArtistWithAlbum); | ||
} else { | ||
const QUrl discogsUrlAlbum = composeDiscogsUrl(kSearchUrl, album, kQueryTypeRelease); | ||
addActionToServiceMenu(pDiscogsMenu, | ||
composeActionText(tr("Album"), album), | ||
discogsUrlAlbum); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
|
||
#include "track/track.h" | ||
#include "util/parented_ptr.h" | ||
#include "widget/wfindonwebmenu.h" | ||
|
||
class FindOnWebMenuDiscogs : public WFindOnWebMenu { | ||
public: | ||
FindOnWebMenuDiscogs(QMenu* pFindOnWebMenu, const Track& track); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include "findonwebmenulastfm.h" | ||
|
||
#include <QMenu> | ||
#include <QUrlQuery> | ||
|
||
#include "track/track.h" | ||
#include "util/parented_ptr.h" | ||
|
||
namespace { | ||
const QString kServiceTitle = QStringLiteral("LastFm"); | ||
|
||
const QString kSearchUrlArtist = QStringLiteral("https://www.last.fm/search/artists?"); | ||
|
||
const QString kSearchUrlTitle = QStringLiteral("https://www.last.fm/search/tracks?"); | ||
|
||
const QString kSearchUrlAlbum = QStringLiteral("https://www.last.fm/search/albums?"); | ||
|
||
const QUrl composeLastfmUrl(const QString& serviceSearchUrl, | ||
const QString& query) { | ||
QUrlQuery urlQuery; | ||
urlQuery.addQueryItem("q", query); | ||
QUrl url(serviceSearchUrl); | ||
url.setQuery(urlQuery); | ||
return url; | ||
} | ||
|
||
} //namespace | ||
|
||
FindOnWebMenuLastfm::FindOnWebMenuLastfm(QMenu* pFindOnWebMenu, const Track& track) { | ||
const QString artist = track.getArtist(); | ||
const QString trackTitle = track.getTitle(); | ||
const QString album = track.getAlbum(); | ||
auto pLastfmMenu = make_parented<QMenu>(pFindOnWebMenu); | ||
pLastfmMenu->setTitle(kServiceTitle); | ||
pFindOnWebMenu->addMenu(pLastfmMenu); | ||
pLastfmMenu->addSeparator(); | ||
if (!artist.isEmpty()) { | ||
const QUrl lastfmUrlArtist = composeLastfmUrl(kSearchUrlArtist, artist); | ||
addActionToServiceMenu(pLastfmMenu, | ||
composeActionText(tr("Artist"), artist), | ||
lastfmUrlArtist); | ||
} | ||
if (!trackTitle.isEmpty()) { | ||
if (!artist.isEmpty()) { | ||
const QString artistWithTrackTitle = composeSearchQuery(artist, trackTitle); | ||
const QUrl lastfmUrlArtistWithTrackTitle = | ||
composeLastfmUrl(kSearchUrlTitle, artistWithTrackTitle); | ||
addActionToServiceMenu(pLastfmMenu, | ||
composeActionText( | ||
tr("Artist + Title"), artistWithTrackTitle), | ||
lastfmUrlArtistWithTrackTitle); | ||
} | ||
const QUrl lastfmUrlTrackTitle = composeLastfmUrl(kSearchUrlTitle, trackTitle); | ||
addActionToServiceMenu(pLastfmMenu, | ||
composeActionText(tr("Title"), trackTitle), | ||
lastfmUrlTrackTitle); | ||
} | ||
if (!album.isEmpty()) { | ||
if (!artist.isEmpty()) { | ||
const QString artistWithAlbum = composeSearchQuery(artist, album); | ||
const QUrl lastfmUrlArtistWithAlbum = | ||
composeLastfmUrl(kSearchUrlAlbum, artistWithAlbum); | ||
addActionToServiceMenu(pLastfmMenu, | ||
composeActionText(tr("Artist + Album"), artistWithAlbum), | ||
lastfmUrlArtistWithAlbum); | ||
} else { | ||
const QUrl lastfmUrlAlbum = composeLastfmUrl(kSearchUrlAlbum, album); | ||
addActionToServiceMenu(pLastfmMenu, | ||
composeActionText(tr("Album"), album), | ||
lastfmUrlAlbum); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
|
||
#include "track/track.h" | ||
#include "util/parented_ptr.h" | ||
#include "widget/wfindonwebmenu.h" | ||
|
||
class FindOnWebMenuLastfm : public WFindOnWebMenu { | ||
public: | ||
FindOnWebMenuLastfm(QMenu* pFindOnWebMenu, const Track& track); | ||
}; |
73 changes: 73 additions & 0 deletions
73
src/widget/findonwebmenuservices/findonwebmenusoundcloud.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include "findonwebmenusoundcloud.h" | ||
|
||
#include <QMenu> | ||
#include <QUrlQuery> | ||
|
||
#include "track/track.h" | ||
#include "util/parented_ptr.h" | ||
|
||
namespace { | ||
const QString kServiceTitle = QStringLiteral("Soundcloud"); | ||
|
||
const QString kSearchUrlArtist = QStringLiteral("https://soundcloud.com/search/people?"); | ||
|
||
const QString kSearchUrlTitle = QStringLiteral("https://soundcloud.com/search/sounds?"); | ||
|
||
const QString kSearchUrlAlbum = QStringLiteral("https://soundcloud.com/search/albums?"); | ||
|
||
const QUrl composeSoundcloudUrl(const QString& serviceSearchUrl, | ||
const QString& query) { | ||
QUrlQuery urlQuery; | ||
urlQuery.addQueryItem("q", query); | ||
QUrl url(serviceSearchUrl); | ||
url.setQuery(urlQuery); | ||
return url; | ||
} | ||
} // namespace | ||
|
||
FindOnWebMenuSoundcloud::FindOnWebMenuSoundcloud( | ||
QMenu* pFindOnWebMenu, const Track& track) { | ||
const QString artist = track.getArtist(); | ||
const QString trackTitle = track.getTitle(); | ||
const QString album = track.getAlbum(); | ||
auto pSoundcloudMenu = make_parented<QMenu>(pFindOnWebMenu); | ||
pSoundcloudMenu->setTitle(kServiceTitle); | ||
pFindOnWebMenu->addMenu(pSoundcloudMenu); | ||
pSoundcloudMenu->addSeparator(); | ||
if (!artist.isEmpty()) { | ||
const QUrl SoundcloudUrlArtist = composeSoundcloudUrl(kSearchUrlArtist, artist); | ||
addActionToServiceMenu(pSoundcloudMenu, | ||
composeActionText(tr("Artist"), artist), | ||
SoundcloudUrlArtist); | ||
} | ||
if (!trackTitle.isEmpty()) { | ||
if (!artist.isEmpty()) { | ||
const QString artistWithTrackTitle = composeSearchQuery(artist, trackTitle); | ||
const QUrl SoundcloudUrlArtistWithTrackTitle = | ||
composeSoundcloudUrl(kSearchUrlTitle, artistWithTrackTitle); | ||
addActionToServiceMenu(pSoundcloudMenu, | ||
composeActionText( | ||
tr("Artist + Title"), artistWithTrackTitle), | ||
SoundcloudUrlArtistWithTrackTitle); | ||
} | ||
const QUrl SoundcloudUrlTrackTitle = composeSoundcloudUrl(kSearchUrlTitle, trackTitle); | ||
addActionToServiceMenu(pSoundcloudMenu, | ||
composeActionText(tr("Title"), trackTitle), | ||
SoundcloudUrlTrackTitle); | ||
} | ||
if (!album.isEmpty()) { | ||
if (!artist.isEmpty()) { | ||
const QString artistWithAlbum = composeSearchQuery(artist, album); | ||
const QUrl SoundcloudUrlArtistWithAlbum = | ||
composeSoundcloudUrl(kSearchUrlAlbum, artistWithAlbum); | ||
addActionToServiceMenu(pSoundcloudMenu, | ||
composeActionText(tr("Artist + Album"), artistWithAlbum), | ||
SoundcloudUrlArtistWithAlbum); | ||
} else { | ||
const QUrl SoundcloudUrlAlbum = composeSoundcloudUrl(kSearchUrlAlbum, album); | ||
addActionToServiceMenu(pSoundcloudMenu, | ||
composeActionText(tr("Album"), album), | ||
SoundcloudUrlAlbum); | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/widget/findonwebmenuservices/findonwebmenusoundcloud.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
|
||
#include "track/track.h" | ||
#include "util/parented_ptr.h" | ||
#include "widget/wfindonwebmenu.h" | ||
|
||
class FindOnWebMenuSoundcloud : public WFindOnWebMenu { | ||
public: | ||
FindOnWebMenuSoundcloud(QMenu* pFindOnWebMenu, const Track& track); | ||
}; |
Oops, something went wrong.