Skip to content

Commit

Permalink
Add initial version of the stem selection menu
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Nov 24, 2024
1 parent 2f04ffc commit 6f3c23c
Show file tree
Hide file tree
Showing 6 changed files with 397 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
173 changes: 173 additions & 0 deletions src/dialog/dlgstemselect.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
#include "dialog/dlgstemselect.h"

#include <QDir>
#include <QKeyEvent>
#include <QMouseEvent>
#include <QSvgRenderer>

#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<WCoverArtLabel>(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<QKeyEvent*>(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<QMouseEvent*>(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();

Check failure on line 98 in src/dialog/dlgstemselect.cpp

View workflow job for this annotation

GitHub Actions / Windows 2019 (MSVC)

'getStemInfo': is not a member of 'Track'
for (int stemIdx = 0; stemIdx < stemInfoList.count(); stemIdx++) {

Check failure on line 99 in src/dialog/dlgstemselect.cpp

View workflow job for this annotation

GitHub Actions / Windows 2019 (MSVC)

'stemInfoList': cannot be used before it is initialized
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);
}
}
34 changes: 34 additions & 0 deletions src/dialog/dlgstemselect.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma once

#include <QDialog>

#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<WCoverArtLabel> m_pWCoverArtLabel;
};
151 changes: 151 additions & 0 deletions src/dialog/dlgstemselect.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DlgStemSelect</class>
<widget class="QDialog" name="DlgStemSelect">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>393</width>
<height>264</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Select Stems</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QRadioButton" name="radioButtonStem">
<property name="text">
<string>Stem deck mixing</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonStereo">
<property name="text">
<string>Pre-mixed stereo track</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QCheckBox" name="checkBoxStem2">
<property name="text">
<string>Stem 2</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="checkBoxStem1">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Stem 1</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkBoxStem3">
<property name="text">
<string>Stem 3</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkBoxStem4">
<property name="text">
<string>Stem 4</string>
</property>
</widget>
</item>
<item row="0" column="1" rowspan="4">
<layout class="QVBoxLayout" name="coverLayout"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Or press the corresponding play button for loading</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="buttonAbort">
<property name="text">
<string>Abort</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="buttonLoadTo">
<property name="text">
<string>Load to...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonLoad">
<property name="text">
<string>Load</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
<buttongroups>
<buttongroup name="buttonGroup"/>
</buttongroups>
</ui>
Loading

0 comments on commit 6f3c23c

Please sign in to comment.