Skip to content

Commit

Permalink
WTrackMenu: Qaction deleted, Find On class added
Browse files Browse the repository at this point in the history
  • Loading branch information
fatihemreyildiz committed Jun 14, 2022
1 parent 890976e commit 09765ba
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 26 deletions.
50 changes: 30 additions & 20 deletions src/widget/wtrackmenu.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#include "widget/wtrackmenu.h"

#include <QCheckBox>
#include <QDesktopServices>
#include <QDialogButtonBox>
#include <QInputDialog>
#include <QListWidget>
#include <QModelIndex>
#include <QUrl>
#include <QVBoxLayout>

#include "control/controlobject.h"
Expand Down Expand Up @@ -39,6 +37,7 @@
#include "widget/wcolorpickeraction.h"
#include "widget/wcoverartlabel.h"
#include "widget/wcoverartmenu.h"
#include "widget/wfindonmenu.h"
#include "widget/wsearchrelatedtracksmenu.h"
#include "widget/wskincolor.h"
#include "widget/wstarrating.h"
Expand Down Expand Up @@ -182,6 +181,33 @@ void WTrackMenu::createMenus() {
});
}

if (featureIsEnabled(Feature::FindOn)) {
DEBUG_ASSERT(!m_pFindOnMenu);
m_pFindOnMenu =
make_parented<WFindOnMenu>(this);

connect(m_pFindOnMenu,
&QMenu::aboutToShow,
this,
[this] {
m_pFindOnMenu->clear();
const auto pTrack = getFirstTrackPointer();
if (pTrack) {
m_pFindOnMenu->createAllServices(*pTrack);
}
m_pFindOnMenu->setEnabled(
!m_pFindOnMenu->isEmpty());
});

connect(m_pFindOnMenu,
&WFindOnMenu::triggerBrowser,
this,
[this](const QString& serviceUrl, const QString& query) {
m_pFindOnMenu->openTheBrowser(serviceUrl,
query);
});
}

if (featureIsEnabled(Feature::RemoveFromDisk)) {
m_pRemoveFromDiskMenu = new QMenu(this);
m_pRemoveFromDiskMenu->setTitle(tr("Delete Track Files"));
Expand Down Expand Up @@ -270,14 +296,6 @@ void WTrackMenu::createActions() {
connect(m_pSelectInLibraryAct, &QAction::triggered, this, &WTrackMenu::slotSelectInLibrary);
}

if (featureIsEnabled(Feature::FindOn)) {
m_pFindOnSoundcloudAct = new QAction(tr("Find the Artist on SoundCloud"), this);
connect(m_pFindOnSoundcloudAct,
&QAction::triggered,
this,
&WTrackMenu::slotFindOnSoundcloud);
}

if (featureIsEnabled(Feature::Metadata)) {
m_pImportMetadataFromFileAct =
new QAction(tr("Import From File Tags"), m_pMetadataMenu);
Expand Down Expand Up @@ -586,7 +604,8 @@ void WTrackMenu::setupActions() {
}

if (featureIsEnabled(Feature::FindOn)) {
addAction(m_pFindOnSoundcloudAct);
addSeparator();
addMenu(m_pFindOnMenu);
}

if (featureIsEnabled(Feature::Properties)) {
Expand Down Expand Up @@ -807,9 +826,6 @@ void WTrackMenu::updateMenus() {
m_pUpdateReplayGainAct->setEnabled(!m_deckGroup.isEmpty());
}

if (featureIsEnabled(Feature::FindOn)) {
m_pFindOnSoundcloudAct->setEnabled(singleTrackSelected);
}

if (featureIsEnabled(Feature::Color)) {
m_pColorPickerAction->setColorPalette(
Expand Down Expand Up @@ -1015,12 +1031,6 @@ void WTrackMenu::slotSelectInLibrary() {
}
}

void WTrackMenu::slotFindOnSoundcloud() {
const TrackPointer pTrack = getFirstTrackPointer();
QString artistName = pTrack->getArtist();
QDesktopServices::openUrl(QUrl("https://soundcloud.com/search/people?q=" + artistName));
}

namespace {

class ImportMetadataFromFileTagsTrackPointerOperation : public mixxx::TrackPointerOperation {
Expand Down
8 changes: 2 additions & 6 deletions src/widget/wtrackmenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class TrackModel;
class WColorPickerAction;
class WCoverArtMenu;
class WSearchRelatedTracksMenu;
class WFindOnMenu;

/// A context menu for track(s).
/// Can be used with individual track type widgets based on TrackPointer
Expand Down Expand Up @@ -93,9 +94,6 @@ class WTrackMenu : public QMenu {
void slotOpenInFileBrowser();
void slotSelectInLibrary();

// Web Browser
void slotFindOnSoundcloud();

// Row color
void slotColorPicked(const mixxx::RgbColor::optional_t& color);

Expand Down Expand Up @@ -223,9 +221,9 @@ class WTrackMenu : public QMenu {
QMenu* m_pClearMetadataMenu{};
QMenu* m_pBPMMenu{};
QMenu* m_pColorMenu{};
QMenu* m_pFindOnMenu{};
WCoverArtMenu* m_pCoverMenu{};
parented_ptr<WSearchRelatedTracksMenu> m_pSearchRelatedMenu;
parented_ptr<WFindOnMenu> m_pFindOnMenu;
QMenu* m_pRemoveFromDiskMenu{};

// Update ReplayGain from Track
Expand Down Expand Up @@ -264,8 +262,6 @@ class WTrackMenu : public QMenu {
// Select track in library
QAction* m_pSelectInLibraryAct{};

// Open default browser
QAction* m_pFindOnSoundcloudAct{};

// BPM feature
QAction* m_pBpmLockAction{};
Expand Down

0 comments on commit 09765ba

Please sign in to comment.