Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to connect last changed model to AutomationClip #7622

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions include/AutomatableModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ class LMMS_EXPORT AutomatableModel : public Model, public JournallingObject
virtual void accept(ModelVisitor& v) = 0;
virtual void accept(ConstModelVisitor& v) const = 0;

static AutomatableModel* s_lastChangedModel;
regulus79 marked this conversation as resolved.
Show resolved Hide resolved

public:
/**
@brief Return this class casted to Target
Expand Down
1 change: 1 addition & 0 deletions include/AutomationClipView.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ protected slots:
void toggleRecording();
void flipY();
void flipX();
void connectLastChangedModel();

protected:
void constructContextMenu( QMenu * ) override;
Expand Down
2 changes: 2 additions & 0 deletions src/core/AutomatableModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace lmms
{

long AutomatableModel::s_periodCounter = 0;
AutomatableModel* AutomatableModel::s_lastChangedModel = nullptr;
regulus79 marked this conversation as resolved.
Show resolved Hide resolved



Expand Down Expand Up @@ -294,6 +295,7 @@ void AutomatableModel::loadSettings( const QDomElement& element, const QString&

void AutomatableModel::setValue( const float value )
{
s_lastChangedModel = this;
m_oldValue = m_value;
++m_setValueDepth;
const float old_val = m_value;
Expand Down
22 changes: 22 additions & 0 deletions src/gui/clips/AutomationClipView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,23 @@ void AutomationClipView::changeName()



void AutomationClipView::connectLastChangedModel()
{
if (AutomatableModel::s_lastChangedModel != nullptr)
{
bool added = m_clip->addObject(AutomatableModel::s_lastChangedModel);
if (!added)
{
TextFloat::displayMessage(AutomatableModel::s_lastChangedModel->displayName(),
tr("Model is already connected to this clip."),
embed::getIconPixmap("automation"),
2000);
}
update();
regulus79 marked this conversation as resolved.
Show resolved Hide resolved
}
}



void AutomationClipView::disconnectObject( QAction * _a )
{
Expand Down Expand Up @@ -185,6 +202,11 @@ void AutomationClipView::constructContextMenu( QMenu * _cm )
_cm->addAction( embed::getIconPixmap( "flip_x" ),
tr( "Flip Horizontally (Visible)" ),
this, SLOT(flipX()));
if (AutomatableModel::s_lastChangedModel != nullptr && !AutomatableModel::s_lastChangedModel->displayName().isEmpty())
regulus79 marked this conversation as resolved.
Show resolved Hide resolved
{
_cm->addAction(tr("Connect last changed model (%1)").arg(AutomatableModel::s_lastChangedModel->fullDisplayName()),
this, &AutomationClipView::connectLastChangedModel);
}
if (!m_clip->m_objects.empty())
{
_cm->addSeparator();
Expand Down
Loading