-
-
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.
findonwebfactory: refactored factory method refactored findonlastfm: lastfm added as a service. findonwebfactory: constructors initialized findonweb: compose action text added wfindonwebmenu: old findon deleted. wfindonwebfactory: all instances renamed findonservices: action's different style fixed. wfindonwebmenu: detailed search added wtrackmenu: Preferences added for Find On Web findonwebfactory: preferences added or services. findonwebmenufactory: make_parented added. reduntant lines deleted. findonwebmenufactory: services preferences deleted findon*menu: this deleted. menus moved to a main menu folder findonweb: naming refactored. dlgpreflibrary: findonweb preferences deleted.
- Loading branch information
1 parent
8be548a
commit 1ac29bf
Showing
13 changed files
with
303 additions
and
194 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,19 @@ | ||
#include "findonwebmenufactory.h" | ||
|
||
#include <QMenu> | ||
|
||
#include "findonwebmenuservices/findonwebmenudiscogs.h" | ||
#include "findonwebmenuservices/findonwebmenulastfm.h" | ||
#include "findonwebmenuservices/findonwebmenusoundcloud.h" | ||
|
||
void FindOnWebMenuFactory::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)); | ||
} |
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,11 @@ | ||
#pragma once | ||
|
||
#include <QMenu> | ||
|
||
class Track; | ||
|
||
class FindOnWebMenuFactory { | ||
public: | ||
static void createFindOnWebSubmenus(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,65 @@ | ||
#include "findonwebmenudiscogs.h" | ||
|
||
#include <QMenu> | ||
|
||
#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/?"); | ||
} //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()) { | ||
pDiscogsMenu->addAction(composeActionText(tr("Artist"), artist), | ||
this, | ||
[this, artist] { | ||
openInBrowser(artist, kQueryTypeArtist, kSearchUrl); | ||
}); | ||
} | ||
if (!trackTitle.isEmpty()) { | ||
if (!artist.isEmpty()) { | ||
const QString artistWithTrackTitle = composeSearchQuery(artist, trackTitle); | ||
pDiscogsMenu->addAction(composeActionText(tr("Artist + Title"), artistWithTrackTitle), | ||
this, | ||
[this, artistWithTrackTitle] { | ||
openInBrowser(artistWithTrackTitle, kQueryTypeRelease, kSearchUrl); | ||
}); | ||
} | ||
pDiscogsMenu->addAction(composeActionText(tr("Title"), trackTitle), | ||
this, | ||
[this, trackTitle] { | ||
openInBrowser(trackTitle, kQueryTypeRelease, kSearchUrl); | ||
}); | ||
} | ||
if (!album.isEmpty()) { | ||
if (!artist.isEmpty()) { | ||
const QString artistWithAlbum = composeSearchQuery(artist, album); | ||
pDiscogsMenu->addAction(composeActionText(tr("Artist + Album"), artistWithAlbum), | ||
this, | ||
[this, artistWithAlbum] { | ||
openInBrowser(artistWithAlbum, kSearchUrl); | ||
}); | ||
} else { | ||
pDiscogsMenu->addAction(composeActionText(tr("Album"), album), | ||
this, | ||
[this, album] { | ||
openInBrowser(album, kSearchUrl); | ||
}); | ||
} | ||
} | ||
} |
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,9 @@ | ||
#pragma once | ||
|
||
#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,64 @@ | ||
#include "findonwebmenulastfm.h" | ||
|
||
#include <QMenu> | ||
|
||
#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?"); | ||
} //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()) { | ||
pLastfmMenu->addAction(composeActionText(tr("Artist"), artist), | ||
this, | ||
[this, artist] { | ||
openInBrowser(artist, kSearchUrlArtist); | ||
}); | ||
} | ||
if (!trackTitle.isEmpty()) { | ||
if (!artist.isEmpty()) { | ||
const QString artistWithTrackTitle = composeSearchQuery(artist, trackTitle); | ||
pLastfmMenu->addAction(composeActionText(tr("Artist + Title"), artistWithTrackTitle), | ||
this, | ||
[this, artistWithTrackTitle] { | ||
openInBrowser(artistWithTrackTitle, kSearchUrlTitle); | ||
}); | ||
} | ||
pLastfmMenu->addAction(composeActionText(tr("Title"), trackTitle), | ||
this, | ||
[this, trackTitle] { | ||
openInBrowser(trackTitle, kSearchUrlTitle); | ||
}); | ||
} | ||
if (!album.isEmpty()) { | ||
if (!artist.isEmpty()) { | ||
const QString artistWithAlbum = composeSearchQuery(artist, album); | ||
pLastfmMenu->addAction(composeActionText(tr("Artist + Album"), artistWithAlbum), | ||
this, | ||
[this, artistWithAlbum] { | ||
openInBrowser(artistWithAlbum, kSearchUrlAlbum); | ||
}); | ||
} else { | ||
pLastfmMenu->addAction(composeActionText(tr("Album"), album), | ||
this, | ||
[this, album] { | ||
openInBrowser(album, kSearchUrlAlbum); | ||
}); | ||
} | ||
} | ||
} |
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,9 @@ | ||
#pragma once | ||
|
||
#include "util/parented_ptr.h" | ||
#include "widget/wfindonwebmenu.h" | ||
|
||
class FindOnWebMenuLastfm : public WFindOnWebMenu { | ||
public: | ||
FindOnWebMenuLastfm(QMenu* pFindOnWebMenu, const Track& track); | ||
}; |
66 changes: 66 additions & 0 deletions
66
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,66 @@ | ||
#include "findonwebmenusoundcloud.h" | ||
|
||
#include <QMenu> | ||
|
||
#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?"); | ||
} // 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()) { | ||
pSoundcloudMenu->addAction(composeActionText(tr("Artist"), artist), | ||
this, | ||
[this, artist] { | ||
openInBrowser(artist, kSearchUrlArtist); | ||
}); | ||
} | ||
if (!trackTitle.isEmpty()) { | ||
if (!artist.isEmpty()) { | ||
const QString artistWithTrackTitle = composeSearchQuery(artist, trackTitle); | ||
pSoundcloudMenu->addAction(composeActionText(tr("Artist + Title"), | ||
artistWithTrackTitle), | ||
this, | ||
[this, artistWithTrackTitle] { | ||
openInBrowser(artistWithTrackTitle, kSearchUrlTitle); | ||
}); | ||
} | ||
pSoundcloudMenu->addAction(composeActionText(tr("Title"), trackTitle), | ||
this, | ||
[this, trackTitle] { | ||
openInBrowser(trackTitle, kSearchUrlTitle); | ||
}); | ||
} | ||
if (!album.isEmpty()) { | ||
if (!artist.isEmpty()) { | ||
const QString artistWithAlbum = composeSearchQuery(artist, album); | ||
pSoundcloudMenu->addAction(composeActionText(tr("Artist + Album"), artistWithAlbum), | ||
this, | ||
[this, artistWithAlbum] { | ||
openInBrowser(artistWithAlbum, kSearchUrlAlbum); | ||
}); | ||
} else { | ||
pSoundcloudMenu->addAction(composeActionText(tr("Album"), album), | ||
this, | ||
[this, album] { | ||
openInBrowser(album, kSearchUrlAlbum); | ||
}); | ||
} | ||
} | ||
} |
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,9 @@ | ||
#pragma once | ||
|
||
#include "util/parented_ptr.h" | ||
#include "widget/wfindonwebmenu.h" | ||
|
||
class FindOnWebMenuSoundcloud : public WFindOnWebMenu { | ||
public: | ||
FindOnWebMenuSoundcloud(QMenu* pFindOnWebMenu, const Track& track); | ||
}; |
Oops, something went wrong.