Skip to content

Commit

Permalink
Require name when adding pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
sakertooth committed Mar 3, 2025
1 parent af726a0 commit bc8f657
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions include/PatternStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class LMMS_EXPORT PatternStore : public TrackContainer

int numOfPatterns() const;

void addPattern(int pattern);
void addPattern(int pattern, const QString& name);
void removePattern(int pattern);

void swapPattern(int p1, int p2);
Expand All @@ -104,7 +104,7 @@ public slots:
void stop();

signals:
void patternAdded(int pattern);
void patternAdded(int pattern, const QString& name);
void patternRemoved(int pattern);
void patternsSwapped(int first, int second);
void patternNameChanged(int pattern, const QString& name);
Expand Down
4 changes: 2 additions & 2 deletions src/core/PatternStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ int PatternStore::numOfPatterns() const
return Engine::getSong()->countTracks(Track::Type::Pattern);
}

void PatternStore::addPattern(int pattern)
void PatternStore::addPattern(int pattern, const QString& name)
{
createClipsForPattern(pattern);
emit patternAdded(pattern);
emit patternAdded(pattern, name);
setCurrentPattern(pattern);
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/editors/PatternEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ PatternEditorWindow::PatternEditorWindow(PatternStore* ps) :
m_patternComboBox->setFixedSize(200, ComboBox::DEFAULT_HEIGHT);

connect(Engine::patternStore(), &PatternStore::patternAdded, this,
[this](int pattern) { m_patternComboBox->addItem(tr("Pattern %1").arg(pattern), pattern); });
[this](int pattern, const QString& name) { m_patternComboBox->addItem(name, pattern); });

connect(Engine::patternStore(), &PatternStore::patternRemoved, this,
[this](int pattern) { m_patternComboBox->removeItem(pattern); });
Expand Down
3 changes: 1 addition & 2 deletions src/tracks/PatternTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ PatternTrack::PatternTrack() :
s_infoMap[this] = patternNum;

setName(tr("Pattern %1").arg(patternNum));
Engine::patternStore()->addPattern(patternNum, name());

connect(this, &Track::nameChanged, this,
[this, patternNum] { emit Engine::patternStore() -> patternNameChanged(patternNum, name()); });

Engine::patternStore()->addPattern(patternNum);
}


Expand Down

0 comments on commit bc8f657

Please sign in to comment.