Implemented loopstation color settings
This commit is contained in:
@ -44,6 +44,7 @@ SOURCES += \
|
||||
widgets/loopstationpresetdetailwidget.cpp \
|
||||
widgets/loopstationsampleswidget.cpp \
|
||||
widgets/loopstationsamplewidget.cpp \
|
||||
widgets/loopstationsettingsdialog.cpp \
|
||||
widgets/loopstationwidget.cpp \
|
||||
widgets/mainwindow.cpp \
|
||||
widgets/midibutton.cpp \
|
||||
@ -87,6 +88,7 @@ HEADERS += \
|
||||
widgets/loopstationpresetdetailwidget.h \
|
||||
widgets/loopstationsampleswidget.h \
|
||||
widgets/loopstationsamplewidget.h \
|
||||
widgets/loopstationsettingsdialog.h \
|
||||
widgets/loopstationwidget.h \
|
||||
widgets/mainwindow.h \
|
||||
widgets/midibutton.h \
|
||||
@ -108,6 +110,7 @@ FORMS += \
|
||||
widgets/loopstationpresetdetailwidget.ui \
|
||||
widgets/loopstationsampleswidget.ui \
|
||||
widgets/loopstationsamplewidget.ui \
|
||||
widgets/loopstationsettingsdialog.ui \
|
||||
widgets/loopstationwidget.ui \
|
||||
widgets/mainwindow.ui \
|
||||
widgets/settingsdialog.ui \
|
||||
|
@ -386,6 +386,21 @@ void DrumMachineSettings::setLoopstationPrevPreset(const MidiLearnSetting &value
|
||||
setLearnSetting("loopstation/prevPreset", value);
|
||||
}
|
||||
|
||||
quint8 DrumMachineSettings::loopstationColorPrevPreset() const
|
||||
{
|
||||
return value("loopstation/colorPrevPreset", defaultLoopstationColorPrevPreset()).value<quint8>();
|
||||
}
|
||||
|
||||
quint8 DrumMachineSettings::defaultLoopstationColorPrevPreset() const
|
||||
{
|
||||
return 127;
|
||||
}
|
||||
|
||||
void DrumMachineSettings::setLoopstationColorPrevPreset(quint8 loopstationColorPrevPreset)
|
||||
{
|
||||
setValue("loopstation/colorPrevPreset", loopstationColorPrevPreset);
|
||||
}
|
||||
|
||||
MidiLearnSetting DrumMachineSettings::loopstationNextPreset() const
|
||||
{
|
||||
return learnSetting("loopstation/nextPreset");
|
||||
@ -396,6 +411,21 @@ void DrumMachineSettings::setLoopstationNextPreset(const MidiLearnSetting &value
|
||||
setLearnSetting("loopstation/nextPreset", value);
|
||||
}
|
||||
|
||||
quint8 DrumMachineSettings::loopstationColorNextPreset() const
|
||||
{
|
||||
return value("loopstation/colorNextPreset", defaultLoopstationColorNextPreset()).value<quint8>();
|
||||
}
|
||||
|
||||
quint8 DrumMachineSettings::defaultLoopstationColorNextPreset() const
|
||||
{
|
||||
return 127;
|
||||
}
|
||||
|
||||
void DrumMachineSettings::setLoopstationColorNextPreset(quint8 loopstationColorNextPreset)
|
||||
{
|
||||
setValue("loopstation/colorNextPreset", loopstationColorNextPreset);
|
||||
}
|
||||
|
||||
MidiLearnSetting DrumMachineSettings::loopstationPlayPause() const
|
||||
{
|
||||
return learnSetting("loopstation/playPause");
|
||||
@ -406,6 +436,21 @@ void DrumMachineSettings::setLoopstationPlayPause(const MidiLearnSetting &value)
|
||||
setLearnSetting("loopstation/playPause", value);
|
||||
}
|
||||
|
||||
quint8 DrumMachineSettings::loopstationColorPlayPause() const
|
||||
{
|
||||
return value("loopstation/colorPlayPause", defaultLoopstationColorPlayPause()).value<quint8>();
|
||||
}
|
||||
|
||||
quint8 DrumMachineSettings::defaultLoopstationColorPlayPause() const
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
void DrumMachineSettings::setLoopstationColorPlayPause(quint8 loopstationColorPlayPause)
|
||||
{
|
||||
setValue("loopstation/colorPlayPause", loopstationColorPlayPause);
|
||||
}
|
||||
|
||||
MidiLearnSetting DrumMachineSettings::loopstationStop() const
|
||||
{
|
||||
return learnSetting("loopstation/stop");
|
||||
@ -416,6 +461,21 @@ void DrumMachineSettings::setLoopstationStop(const MidiLearnSetting &value)
|
||||
setLearnSetting("loopstation/stop", value);
|
||||
}
|
||||
|
||||
quint8 DrumMachineSettings::loopstationColorStop() const
|
||||
{
|
||||
return value("loopstation/colorStop", defaultLoopstationColorStop()).value<quint8>();
|
||||
}
|
||||
|
||||
quint8 DrumMachineSettings::defaultLoopstationColorStop() const
|
||||
{
|
||||
return 60;
|
||||
}
|
||||
|
||||
void DrumMachineSettings::setLoopstationColorStop(quint8 loopstationColorStop)
|
||||
{
|
||||
setValue("loopstation/colorStop", loopstationColorStop);
|
||||
}
|
||||
|
||||
MidiLearnSetting DrumMachineSettings::loopstationSample(quint8 pad) const
|
||||
{
|
||||
return learnSetting(QString{"loopstation/pad%0"}.arg(pad));
|
||||
|
@ -121,15 +121,31 @@ public:
|
||||
MidiLearnSetting loopstationPrevPreset() const;
|
||||
void setLoopstationPrevPreset(const MidiLearnSetting &value);
|
||||
|
||||
quint8 loopstationColorPrevPreset() const;
|
||||
quint8 defaultLoopstationColorPrevPreset() const;
|
||||
void setLoopstationColorPrevPreset(quint8 loopstationColorPrevPreset);
|
||||
|
||||
MidiLearnSetting loopstationNextPreset() const;
|
||||
void setLoopstationNextPreset(const MidiLearnSetting &value);
|
||||
|
||||
quint8 loopstationColorNextPreset() const;
|
||||
quint8 defaultLoopstationColorNextPreset() const;
|
||||
void setLoopstationColorNextPreset(quint8 loopstationColorNextPreset);
|
||||
|
||||
MidiLearnSetting loopstationPlayPause() const;
|
||||
void setLoopstationPlayPause(const MidiLearnSetting &value);
|
||||
|
||||
quint8 loopstationColorPlayPause() const;
|
||||
quint8 defaultLoopstationColorPlayPause() const;
|
||||
void setLoopstationColorPlayPause(quint8 loopstationColorPlayPause);
|
||||
|
||||
MidiLearnSetting loopstationStop() const;
|
||||
void setLoopstationStop(const MidiLearnSetting &value);
|
||||
|
||||
quint8 loopstationColorStop() const;
|
||||
quint8 defaultLoopstationColorStop() const;
|
||||
void setLoopstationColorStop(quint8 loopstationColorStop);
|
||||
|
||||
MidiLearnSetting loopstationSample(quint8 pad) const;
|
||||
void setLoopstationSample(quint8 pad, const MidiLearnSetting &value);
|
||||
|
||||
|
@ -296,7 +296,7 @@
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset|QDialogButtonBox::RestoreDefaults</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "loopstationpresets.h"
|
||||
#include "drummachinesettings.h"
|
||||
#include "loopstationsettingsdialog.h"
|
||||
|
||||
LoopStationSamplesWidget::LoopStationSamplesWidget(QWidget *parent) :
|
||||
QWidget{parent},
|
||||
@ -152,14 +153,14 @@ void LoopStationSamplesWidget::sendColors()
|
||||
.cmd = m_ui->pushButtonPlayPause->learnSetting().cmd,
|
||||
.flag = true,
|
||||
.note = m_ui->pushButtonPlayPause->learnSetting().note,
|
||||
.velocity = 3
|
||||
.velocity = m_settings ? m_settings->loopstationColorPlayPause() : quint8{3}
|
||||
});
|
||||
emit sendMidi(midi::MidiMessage {
|
||||
.channel = m_ui->pushButtonStop->learnSetting().channel,
|
||||
.cmd = m_ui->pushButtonStop->learnSetting().cmd,
|
||||
.flag = true,
|
||||
.note = m_ui->pushButtonStop->learnSetting().note,
|
||||
.velocity = 60
|
||||
.velocity = m_settings ? m_settings->loopstationColorStop() : quint8{60}
|
||||
});
|
||||
|
||||
for (LoopStationSampleWidget &widget : getWidgets())
|
||||
@ -168,7 +169,14 @@ void LoopStationSamplesWidget::sendColors()
|
||||
|
||||
void LoopStationSamplesWidget::showSettings()
|
||||
{
|
||||
if (!m_settings)
|
||||
{
|
||||
qWarning() << "settings are missing";
|
||||
return;
|
||||
}
|
||||
|
||||
LoopStationSettingsDialog dialog{*m_settings, this};
|
||||
dialog.exec();
|
||||
}
|
||||
|
||||
void LoopStationSamplesWidget::timeout()
|
||||
|
78
widgets/loopstationsettingsdialog.cpp
Normal file
78
widgets/loopstationsettingsdialog.cpp
Normal file
@ -0,0 +1,78 @@
|
||||
#include "loopstationsettingsdialog.h"
|
||||
#include "ui_loopstationsettingsdialog.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QAbstractButton>
|
||||
|
||||
#include "drummachinesettings.h"
|
||||
|
||||
LoopStationSettingsDialog::LoopStationSettingsDialog(DrumMachineSettings &settings, QWidget *parent) :
|
||||
QDialog{parent},
|
||||
m_ui{std::make_unique<Ui::LoopStationSettingsDialog>()},
|
||||
m_settings{settings}
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->buttonBox, &QDialogButtonBox::clicked, this, &LoopStationSettingsDialog::buttonClicked);
|
||||
|
||||
resetFields();
|
||||
}
|
||||
|
||||
LoopStationSettingsDialog::~LoopStationSettingsDialog() = default;
|
||||
|
||||
void LoopStationSettingsDialog::accept()
|
||||
{
|
||||
if (const quint8 colorPrevPreset = m_ui->spinBoxColorPrevPreset->value();
|
||||
m_settings.loopstationColorPrevPreset() != colorPrevPreset)
|
||||
m_settings.setLoopstationColorPrevPreset(colorPrevPreset);
|
||||
|
||||
if (const quint8 colorNextPreset = m_ui->spinBoxColorNextPreset->value();
|
||||
m_settings.loopstationColorNextPreset() != colorNextPreset)
|
||||
m_settings.setLoopstationColorNextPreset(colorNextPreset);
|
||||
|
||||
if (const quint8 colorPlayPause = m_ui->spinBoxColorPlayPause->value();
|
||||
m_settings.loopstationColorPlayPause() != colorPlayPause)
|
||||
m_settings.setLoopstationColorPlayPause(colorPlayPause);
|
||||
|
||||
if (const quint8 colorStop = m_ui->spinBoxColorStop->value();
|
||||
m_settings.loopstationColorStop() != colorStop)
|
||||
m_settings.setLoopstationColorStop(colorStop);
|
||||
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void LoopStationSettingsDialog::buttonClicked(QAbstractButton *button)
|
||||
{
|
||||
if (!button)
|
||||
{
|
||||
qWarning() << "invalid button";
|
||||
return;
|
||||
}
|
||||
|
||||
switch (m_ui->buttonBox->standardButton(button))
|
||||
{
|
||||
case QDialogButtonBox::Reset:
|
||||
resetFields();
|
||||
return;
|
||||
case QDialogButtonBox::RestoreDefaults:
|
||||
restoreDefaults();
|
||||
return;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
|
||||
void LoopStationSettingsDialog::resetFields()
|
||||
{
|
||||
m_ui->spinBoxColorPrevPreset->setValue(m_settings.loopstationColorPrevPreset());
|
||||
m_ui->spinBoxColorNextPreset->setValue(m_settings.loopstationColorNextPreset());
|
||||
m_ui->spinBoxColorPlayPause->setValue(m_settings.loopstationColorPlayPause());
|
||||
m_ui->spinBoxColorStop->setValue(m_settings.loopstationColorStop());
|
||||
}
|
||||
|
||||
void LoopStationSettingsDialog::restoreDefaults()
|
||||
{
|
||||
m_ui->spinBoxColorPrevPreset->setValue(m_settings.defaultLoopstationColorPrevPreset());
|
||||
m_ui->spinBoxColorNextPreset->setValue(m_settings.defaultLoopstationColorNextPreset());
|
||||
m_ui->spinBoxColorPlayPause->setValue(m_settings.defaultLoopstationColorPlayPause());
|
||||
m_ui->spinBoxColorStop->setValue(m_settings.defaultLoopstationColorStop());
|
||||
}
|
31
widgets/loopstationsettingsdialog.h
Normal file
31
widgets/loopstationsettingsdialog.h
Normal file
@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Ui { class LoopStationSettingsDialog; }
|
||||
class DrumMachineSettings;
|
||||
class QAbstractButton;
|
||||
|
||||
class LoopStationSettingsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LoopStationSettingsDialog(DrumMachineSettings &settings, QWidget *parent = nullptr);
|
||||
~LoopStationSettingsDialog() override;
|
||||
|
||||
public slots:
|
||||
void accept() override;
|
||||
|
||||
private slots:
|
||||
void buttonClicked(QAbstractButton *button);
|
||||
void resetFields();
|
||||
void restoreDefaults();
|
||||
|
||||
private:
|
||||
const std::unique_ptr<Ui::LoopStationSettingsDialog> m_ui;
|
||||
|
||||
DrumMachineSettings &m_settings;
|
||||
};
|
204
widgets/loopstationsettingsdialog.ui
Normal file
204
widgets/loopstationsettingsdialog.ui
Normal file
@ -0,0 +1,204 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>LoopStationSettingsDialog</class>
|
||||
<widget class="QDialog" name="LoopStationSettingsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>439</width>
|
||||
<height>230</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelColorPrevPreset">
|
||||
<property name="text">
|
||||
<string>Color Prev Preset:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinBoxColorPrevPreset</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBoxColorPrevPreset">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelColorNextPreset">
|
||||
<property name="text">
|
||||
<string>Color Next Preset:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinBoxColorNextPreset</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelColorPlayPause">
|
||||
<property name="text">
|
||||
<string>Color Play Pause:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinBoxColorPlayPause</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="labelColorStop">
|
||||
<property name="text">
|
||||
<string>Color Stop:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinBoxColorStop</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBoxColorNextPreset">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBoxColorPlayPause">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBoxColorStop">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</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>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset|QDialogButtonBox::RestoreDefaults</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>LoopStationSettingsDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>LoopStationSettingsDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -97,14 +97,14 @@ void LoopStationWidget::sendColors()
|
||||
.cmd = m_ui->pushButtonUp->learnSetting().cmd,
|
||||
.flag = true,
|
||||
.note = m_ui->pushButtonUp->learnSetting().note,
|
||||
.velocity = 127
|
||||
.velocity = m_settings ? m_settings->loopstationColorPrevPreset() : quint8{127}
|
||||
});
|
||||
emit sendMidi(midi::MidiMessage {
|
||||
.channel = m_ui->pushButtonDown->learnSetting().channel,
|
||||
.cmd = m_ui->pushButtonDown->learnSetting().cmd,
|
||||
.flag = true,
|
||||
.note = m_ui->pushButtonDown->learnSetting().note,
|
||||
.velocity = 127
|
||||
.velocity = m_settings ? m_settings->loopstationColorNextPreset() : quint8{127}
|
||||
});
|
||||
|
||||
m_ui->samplesWidget->sendColors();
|
||||
|
Reference in New Issue
Block a user