Skip to content

Commit

Permalink
Add sync button and adjust formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
sakertooth committed Aug 24, 2023
1 parent d5a3d28 commit fe7d3dc
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions plugins/TapTempo/TapTempoView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ TapTempoView::TapTempoView(TapTempo* plugin)
precisionCheckBox->setText(tr("Precision"));

auto muteCheckBox = new QCheckBox(tr("0.0 ms"));
muteCheckBox->setFocusPolicy(Qt::NoFocus);
muteCheckBox->setFocusPolicy(Qt::NoFocus);
muteCheckBox->setToolTip(tr("Mute metronome"));
muteCheckBox->setText(tr("Mute"));

Expand All @@ -78,6 +78,10 @@ TapTempoView::TapTempoView(TapTempo* plugin)
resetButton->setFocusPolicy(Qt::NoFocus);
resetButton->setToolTip(tr("Reset counter and sidebar information"));

auto syncButton = new QPushButton(tr("Sync"));
syncButton->setFocusPolicy(Qt::NoFocus);
syncButton->setToolTip(tr("Sync with project tempo"));

auto optionLayout = new QVBoxLayout();
optionLayout->addWidget(precisionCheckBox);
optionLayout->addWidget(muteCheckBox);
Expand All @@ -90,9 +94,13 @@ TapTempoView::TapTempoView(TapTempo* plugin)
sidebarLayout->addLayout(optionLayout);
sidebarLayout->addLayout(bpmInfoLayout);

auto buttonsLayout = new QHBoxLayout();
buttonsLayout->addWidget(resetButton, 0, Qt::AlignCenter);
buttonsLayout->addWidget(syncButton, 0, Qt::AlignCenter);

auto mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(m_tapButton, 0, Qt::AlignCenter);
mainLayout->addWidget(resetButton, 0, Qt::AlignCenter);
mainLayout->addLayout(buttonsLayout);
mainLayout->addLayout(sidebarLayout);

connect(m_tapButton, &QPushButton::pressed, this, [this, muteCheckBox]() {
Expand All @@ -115,6 +123,12 @@ TapTempoView::TapTempoView(TapTempo* plugin)
updateLabels();
});

connect(syncButton, &QPushButton::clicked, this, [this]() {
const auto& tempoModel = Engine::getSong()->tempoModel();
if (m_plugin->m_bpm < tempoModel.minValue() || m_plugin->m_bpm > tempoModel.maxValue()) { return; }
Engine::getSong()->setTempo(m_plugin->m_bpm);
});

hide();
if (parentWidget())
{
Expand Down

0 comments on commit fe7d3dc

Please sign in to comment.