diff --git a/CMakeLists.txt b/CMakeLists.txt index 94ecb9ce26b..5690fcd391d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -780,6 +780,8 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL src/dialog/dlgkeywheel.ui src/dialog/dlgreplacecuecolor.cpp src/dialog/dlgreplacecuecolordlg.ui + src/dialog/dlgstemselect.cpp + src/dialog/dlgstemselect.ui src/effects/backends/builtin/autopaneffect.cpp src/effects/backends/builtin/balanceeffect.cpp src/effects/backends/builtin/bessel4lvmixeqeffect.cpp diff --git a/src/dialog/dlgstemselect.cpp b/src/dialog/dlgstemselect.cpp new file mode 100644 index 00000000000..f9cfaae7213 --- /dev/null +++ b/src/dialog/dlgstemselect.cpp @@ -0,0 +1,173 @@ +#include "dialog/dlgstemselect.h" + +#include +#include +#include +#include + +#include "control/controlobject.h" +#include "library/coverartcache.h" +#include "library/library_prefs.h" +#include "moc_dlgstemselect.cpp" +#include "track/track.h" +#include "widget/wcoverartlabel.h" + +namespace { + +} // namespace + +DlgStemSelect::DlgStemSelect(QWidget* parent) + : QDialog(parent) { + setupUi(this); + + // setWindowFlags(Qt::Popup); + // setAttribute(Qt::WA_StyledBackground); + + m_pWCoverArtLabel = make_parented(this); + + // Cover art + CoverArtCache* pCache = CoverArtCache::instance(); + if (pCache) { + connect(pCache, + &CoverArtCache::coverFound, + this, + &DlgStemSelect::slotCoverFound); + } + + coverLayout->setAlignment(Qt::AlignRight | Qt::AlignTop); + coverLayout->setSpacing(0); + coverLayout->setContentsMargins(0, 0, 0, 0); + coverLayout->insertWidget(0, m_pWCoverArtLabel.get()); + + installEventFilter(this); + + connect(buttonAbort, + &QAbstractButton::clicked, + this, + &QDialog::accept); + + connect(radioButtonStem, + &QRadioButton::toggled, + this, + &DlgStemSelect::slotStemMixToggled); + connect(radioButtonStereo, + &QRadioButton::toggled, + this, + &DlgStemSelect::slotStemMixToggled); + + connect(checkBoxStem1, + &QCheckBox::stateChanged, + this, + &DlgStemSelect::slotStemChecked); + connect(checkBoxStem2, + &QCheckBox::stateChanged, + this, + &DlgStemSelect::slotStemChecked); + connect(checkBoxStem3, + &QCheckBox::stateChanged, + this, + &DlgStemSelect::slotStemChecked); + connect(checkBoxStem4, + &QCheckBox::stateChanged, + this, + &DlgStemSelect::slotStemChecked); +} + +bool DlgStemSelect::eventFilter(QObject* obj, QEvent* event) { + if (event->type() == QEvent::KeyPress) { + QKeyEvent* keyEvent = static_cast(event); + if (keyEvent->key() == Qt::Key_Tab) { + return true; + } else if (keyEvent->key() == Qt::Key_Backtab) { + return true; + } + } else if (event->type() == QEvent::MouseButtonPress) { + // QMouseEvent* mouseEvent = static_cast(event); + // return true; + } + // standard event processing + return QDialog::eventFilter(obj, event); +} + +void DlgStemSelect::show(TrackPointer pTrack) { + m_pTrack = pTrack; + + DEBUG_ASSERT(pTrack->hasStem()); + + QString colorStyle; + auto stemInfoList = pTrack->getStemInfo(); + for (int stemIdx = 0; stemIdx < stemInfoList.count(); stemIdx++) { + switch (stemIdx) { + case 0: + checkBoxStem1->setText(stemInfoList.at(stemIdx).getLabel()); + colorStyle = + QString("QCheckBox { color: %1; }") + .arg(stemInfoList.at(stemIdx).getColor().name()); + checkBoxStem1->setStyleSheet(colorStyle); + break; + case 1: + checkBoxStem2->setText(stemInfoList.at(stemIdx).getLabel()); + colorStyle = + QString("QCheckBox { color: %1; }") + .arg(stemInfoList.at(stemIdx).getColor().name()); + checkBoxStem2->setStyleSheet(colorStyle); + break; + case 2: + checkBoxStem3->setText(stemInfoList.at(stemIdx).getLabel()); + colorStyle = + QString("QCheckBox { color: %1; }") + .arg(stemInfoList.at(stemIdx).getColor().name()); + checkBoxStem3->setStyleSheet(colorStyle); + break; + case 3: + checkBoxStem4->setText(stemInfoList.at(stemIdx).getLabel()); + colorStyle = + QString("QCheckBox { color: %1; }") + .arg(stemInfoList.at(stemIdx).getColor().name()); + checkBoxStem4->setStyleSheet(colorStyle); + break; + } + } + + m_pWCoverArtLabel->loadTrack(pTrack); + + const auto coverInfo = CoverInfo( + m_pTrack->getCoverInfo(), + m_pTrack->getLocation()); + m_pWCoverArtLabel->setCoverArt(coverInfo, QPixmap()); + // Executed concurrently + CoverArtCache::requestCover(this, coverInfo); + + QDialog::show(); +} + +void DlgStemSelect::slotStemMixToggled(bool checked) { + if (checked) { + checkBoxStem1->setChecked(false); + checkBoxStem2->setChecked(false); + checkBoxStem3->setChecked(false); + checkBoxStem4->setChecked(false); + } +} + +void DlgStemSelect::slotStemChecked(int state) { + if (state == Qt::Checked) { + blockSignals(true); + buttonGroup->setExclusive(false); + radioButtonStem->setChecked(false); + radioButtonStereo->setChecked(false); + buttonGroup->setExclusive(true); + blockSignals(false); + } +} + +void DlgStemSelect::slotCoverFound( + const QObject* pRequester, + const CoverInfo& coverInfo, + const QPixmap& pixmap) { + if (pRequester == this && + m_pTrack && + m_pTrack->getLocation() == coverInfo.trackLocation) { + m_pWCoverArtLabel->setCoverArt(coverInfo, pixmap); + } +} diff --git a/src/dialog/dlgstemselect.h b/src/dialog/dlgstemselect.h new file mode 100644 index 00000000000..a3eba0fb7c1 --- /dev/null +++ b/src/dialog/dlgstemselect.h @@ -0,0 +1,34 @@ +#pragma once + +#include + +#include "dialog/ui_dlgstemselect.h" +#include "track/track_decl.h" +#include "util/parented_ptr.h" + +class WCoverArtLabel; +class CoverInfo; + +class DlgStemSelect : public QDialog, public Ui::DlgStemSelect { + Q_OBJECT + + public: + explicit DlgStemSelect(QWidget* parent); + ~DlgStemSelect() = default; + void show(TrackPointer pTrack); + + protected: + bool eventFilter(QObject* obj, QEvent* event) override; + + private slots: + void slotStemMixToggled(bool checked); + void slotStemChecked(int state); + void slotCoverFound( + const QObject* pRequester, + const CoverInfo& coverInfo, + const QPixmap& pixmap); + + private: + TrackPointer m_pTrack; + parented_ptr m_pWCoverArtLabel; +}; diff --git a/src/dialog/dlgstemselect.ui b/src/dialog/dlgstemselect.ui new file mode 100644 index 00000000000..dcc4bfec9c6 --- /dev/null +++ b/src/dialog/dlgstemselect.ui @@ -0,0 +1,151 @@ + + + DlgStemSelect + + + + 0 + 0 + 393 + 264 + + + + + 0 + 0 + + + + Select Stems + + + Qt::LeftToRight + + + + + + + + Stem deck mixing + + + buttonGroup + + + + + + + Pre-mixed stereo track + + + buttonGroup + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + Stem 2 + + + + + + + + 0 + 0 + + + + Stem 1 + + + + + + + Stem 3 + + + + + + + Stem 4 + + + + + + + + + + + + + Or press the corresponding play button for loading + + + + + + + + + Abort + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Load to... + + + + + + + Load + + + + + + + + + + + + + + + diff --git a/src/widget/wtracktableview.cpp b/src/widget/wtracktableview.cpp index 427c68814ac..83bf296642b 100644 --- a/src/widget/wtracktableview.cpp +++ b/src/widget/wtracktableview.cpp @@ -7,6 +7,7 @@ #include #include "control/controlobject.h" +#include "dialog/dlgstemselect.h" #include "library/dao/trackschema.h" #include "library/library.h" #include "library/library_prefs.h" @@ -1092,6 +1093,39 @@ void WTrackTableView::keyPressEvent(QKeyEvent* event) { } return; } + case Qt::Key_Right: { +#ifdef __STEM__ + TrackModel* pTrackModel = getTrackModel(); + if (!pTrackModel) { + break; + } + const QModelIndexList indices = getSelectedRows(); + if (indices.isEmpty()) { + break; + } + TrackPointer pTrack = pTrackModel->getTrack(indices.first()); + if (!pTrack) { + break; + } + + if (!pTrack->hasStreamInfoFromSource()) { + // The stem metadata are loaded on stream info refresh, which occurs + // when the file gets loaded for the time in the session. If there is no + // stream info from source, when open the file, which lead to loading + // the stem manifest. + mixxx::AudioSource::OpenParams config; + config.setChannelCount(mixxx::kMaxEngineChannelInputCount); + SoundSourceProxy(pTrack).openAudioSource(config); + } + if (pTrack->hasStem()) { + if (!m_pDlgStemSelect) { + m_pDlgStemSelect = make_parented(this); + } + m_pDlgStemSelect->show(pTrack); + } + break; +#endif // __STEM__ + } default: break; } diff --git a/src/widget/wtracktableview.h b/src/widget/wtracktableview.h index 9a8561b3705..618513435f5 100644 --- a/src/widget/wtracktableview.h +++ b/src/widget/wtracktableview.h @@ -18,6 +18,7 @@ class DlgTrackInfo; class ExternalTrackCollection; class Library; class WTrackMenu; +class DlgStemSelect; class WTrackTableView : public WLibraryTableView { Q_OBJECT @@ -169,6 +170,8 @@ class WTrackTableView : public WLibraryTableView { // Context menu container parented_ptr m_pTrackMenu; + parented_ptr m_pDlgStemSelect; + const double m_backgroundColorOpacity; QColor m_focusBorderColor; QColor m_trackPlayedColor;