diff --git a/src/widget/wtracktext.cpp b/src/widget/wtracktext.cpp deleted file mode 100644 index 74451b92f9a..00000000000 --- a/src/widget/wtracktext.cpp +++ /dev/null @@ -1,112 +0,0 @@ -#include "widget/wtracktext.h" - -#include "moc_wtracktext.cpp" -#include "track/track.h" -#include "util/dnd.h" -#include "widget/wtrackmenu.h" - -namespace { -constexpr WTrackMenu::Features kTrackMenuFeatures = - WTrackMenu::Feature::SearchRelated | - WTrackMenu::Feature::Playlist | - WTrackMenu::Feature::Crate | - WTrackMenu::Feature::Metadata | - WTrackMenu::Feature::Reset | - WTrackMenu::Feature::Analyze | - WTrackMenu::Feature::BPM | - WTrackMenu::Feature::Color | - WTrackMenu::Feature::FileBrowser | - WTrackMenu::Feature::Properties | - WTrackMenu::Feature::UpdateReplayGainFromPregain | - WTrackMenu::Feature::FindOnWeb | - WTrackMenu::Feature::SelectInLibrary; -} // namespace - -WTrackText::WTrackText(QWidget* pParent, - UserSettingsPointer pConfig, - Library* pLibrary, - const QString& group) - : WLabel(pParent), - m_group(group), - m_pConfig(pConfig), - m_pLibrary(pLibrary) { - setAcceptDrops(true); -} - -WTrackText::~WTrackText() { - // Required to allow forward declaration of WTrackMenu in header -} - -void WTrackText::slotTrackLoaded(TrackPointer pTrack) { - if (!pTrack) { - return; - } - m_pCurrentTrack = pTrack; - connect(pTrack.get(), - &Track::changed, - this, - &WTrackText::slotTrackChanged); - updateLabel(); -} - -void WTrackText::slotLoadingTrack(TrackPointer pNewTrack, TrackPointer pOldTrack) { - Q_UNUSED(pNewTrack); - Q_UNUSED(pOldTrack); - if (m_pCurrentTrack) { - disconnect(m_pCurrentTrack.get(), nullptr, this, nullptr); - } - m_pCurrentTrack.reset(); - updateLabel(); -} - -void WTrackText::slotTrackChanged(TrackId trackId) { - Q_UNUSED(trackId); - updateLabel(); -} - -void WTrackText::updateLabel() { - if (m_pCurrentTrack) { - setText(m_pCurrentTrack->getInfo()); - } else { - setText(""); - } -} - -void WTrackText::mouseMoveEvent(QMouseEvent *event) { - if (event->buttons().testFlag(Qt::LeftButton) && m_pCurrentTrack) { - DragAndDropHelper::dragTrack(m_pCurrentTrack, this, m_group); - } -} - -void WTrackText::mouseDoubleClickEvent(QMouseEvent* event) { - Q_UNUSED(event); - if (m_pCurrentTrack) { - ensureTrackMenuIsCreated(); - m_pTrackMenu->loadTrack(m_pCurrentTrack, m_group); - m_pTrackMenu->slotShowDlgTrackInfo(); - } -} - -void WTrackText::dragEnterEvent(QDragEnterEvent *event) { - DragAndDropHelper::handleTrackDragEnterEvent(event, m_group, m_pConfig); -} - -void WTrackText::dropEvent(QDropEvent *event) { - DragAndDropHelper::handleTrackDropEvent(event, *this, m_group, m_pConfig); -} - -void WTrackText::contextMenuEvent(QContextMenuEvent* event) { - event->accept(); - if (m_pCurrentTrack) { - ensureTrackMenuIsCreated(); - m_pTrackMenu->loadTrack(m_pCurrentTrack, m_group); - m_pTrackMenu->popup(event->globalPos()); - } -} - -void WTrackText::ensureTrackMenuIsCreated() { - if (m_pTrackMenu.get() == nullptr) { - m_pTrackMenu = make_parented( - this, m_pConfig, m_pLibrary, kTrackMenuFeatures); - } -} diff --git a/src/widget/wtracktext.h b/src/widget/wtracktext.h deleted file mode 100644 index 4f30036cba0..00000000000 --- a/src/widget/wtracktext.h +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once - -#include "preferences/usersettings.h" -#include "track/track_decl.h" -#include "track/trackid.h" -#include "util/parented_ptr.h" -#include "widget/trackdroptarget.h" -#include "widget/wlabel.h" - -class Library; -class WTrackMenu; - -class WTrackText : public WLabel, public TrackDropTarget { - Q_OBJECT - public: - WTrackText( - QWidget* pParent, - UserSettingsPointer pConfig, - Library* pLibrary, - const QString& group); - ~WTrackText() override; - - signals: - void trackDropped(const QString& fileName, const QString& group) override; - void cloneDeck(const QString& sourceGroup, const QString& targetGroup) override; - - public slots: - void slotTrackLoaded(TrackPointer track); - void slotLoadingTrack(TrackPointer pNewTrack, TrackPointer pOldTrack); - - protected: - void contextMenuEvent(QContextMenuEvent* event) override; - - private slots: - void slotTrackChanged(TrackId); - - private: - void dragEnterEvent(QDragEnterEvent *event) override; - void dropEvent(QDropEvent *event) override; - void mouseMoveEvent(QMouseEvent *event) override; - void mouseDoubleClickEvent(QMouseEvent* event) override; - - void updateLabel(); - - void ensureTrackMenuIsCreated(); - - const QString m_group; - UserSettingsPointer m_pConfig; - Library* m_pLibrary; - TrackPointer m_pCurrentTrack; - parented_ptr m_pTrackMenu; -};