Skip to content

Commit

Permalink
FindOnWebFactory implementation.
Browse files Browse the repository at this point in the history
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
fatihemreyildiz committed Jul 3, 2022
1 parent 8be548a commit 1ac29bf
Show file tree
Hide file tree
Showing 13 changed files with 303 additions and 194 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,10 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL
src/waveform/waveform.cpp
src/waveform/waveformfactory.cpp
src/widget/controlwidgetconnection.cpp
src/widget/findonwebmenufactory.cpp
src/widget/findonwebmenuservices/findonwebmenudiscogs.cpp
src/widget/findonwebmenuservices/findonwebmenulastfm.cpp
src/widget/findonwebmenuservices/findonwebmenusoundcloud.cpp
src/widget/hexspinbox.cpp
src/widget/paintable.cpp
src/widget/wanalysislibrarytableview.cpp
Expand Down
19 changes: 19 additions & 0 deletions src/widget/findonwebmenufactory.cpp
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));
}
11 changes: 11 additions & 0 deletions src/widget/findonwebmenufactory.h
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);
};
65 changes: 65 additions & 0 deletions src/widget/findonwebmenuservices/findonwebmenudiscogs.cpp
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);
});
}
}
}
9 changes: 9 additions & 0 deletions src/widget/findonwebmenuservices/findonwebmenudiscogs.h
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);
};
64 changes: 64 additions & 0 deletions src/widget/findonwebmenuservices/findonwebmenulastfm.cpp
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);
});
}
}
}
9 changes: 9 additions & 0 deletions src/widget/findonwebmenuservices/findonwebmenulastfm.h
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 src/widget/findonwebmenuservices/findonwebmenusoundcloud.cpp
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);
});
}
}
}
9 changes: 9 additions & 0 deletions src/widget/findonwebmenuservices/findonwebmenusoundcloud.h
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);
};
Loading

0 comments on commit 1ac29bf

Please sign in to comment.