Skip to content

Commit

Permalink
Fix #276840, part 2.b): Show progress indicator when moving soundfonts
Browse files Browse the repository at this point in the history
similar to when adding one, rather than appearing to hang
  • Loading branch information
Jojo-Schmitz authored and vpereverzev committed Nov 14, 2020
1 parent 1990ecc commit ae54ec8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
22 changes: 16 additions & 6 deletions audio/midi/fluid/fluidgui.cpp
Expand Up @@ -163,10 +163,7 @@ void FluidGui::moveSoundfontInTheList(int currentIdx, int targetIdx)
fluid()->removeSoundFont(sfName);

sfonts.move(currentIdx, targetIdx);
fluid()->loadSoundFonts(sfonts);
sfonts = fluid()->soundFonts();
soundFonts->clear();
soundFonts->addItems(sfonts);
loadSoundFontsAsync(sfonts);
soundFonts->setCurrentRow(targetIdx);
emit sfChanged();
}
Expand Down Expand Up @@ -217,6 +214,20 @@ void FluidGui::soundFontDownClicked()
moveSoundfontInTheList(row, row + 1);
}

//---------------------------------------------------------
// loadSoundFontsAsync
//---------------------------------------------------------

void FluidGui::loadSoundFontsAsync(QStringList sfonts)
{
QFuture<bool> future = QtConcurrent::run(fluid(), &FluidS::Fluid::loadSoundFonts, sfonts);
_futureWatcher.setFuture(future);
_progressTimer->start(1000);
_progressDialog->exec();

synthesizerChanged();
}

//---------------------------------------------------------
// soundFontDeleteClicked
//---------------------------------------------------------
Expand Down Expand Up @@ -258,7 +269,7 @@ void FluidGui::soundFontAddClicked()
QFileInfoList l = FluidS::Fluid::sfFiles();

SfListDialog ld(this);
foreach (const QFileInfo& fi, l)
for (const QFileInfo& fi : l)
ld.add(fi.fileName(), fi.absoluteFilePath());
if (!ld.exec())
return;
Expand Down Expand Up @@ -316,7 +327,6 @@ void FluidGui::loadSf()
tr("SoundFont %1 already loaded").arg(sfPath));
}
else {

_loadedSfName = sfName;
_loadedSfPath = sfPath;
QFuture<bool> future = QtConcurrent::run(fluid(), &FluidS::Fluid::addSoundFont, sfPath);
Expand Down
1 change: 1 addition & 0 deletions audio/midi/fluid/fluidgui.h
Expand Up @@ -61,6 +61,7 @@ class FluidGui : public Ms::SynthesizerGui, Ui::FluidGui {
QTimer * _progressTimer;
std::list<struct SfNamePath> _sfToLoad;
void loadSf();
void loadSoundFontsAsync(QStringList sfonts);
void moveSoundfontInTheList(int currentIdx, int targetIdx);

private slots:
Expand Down
2 changes: 1 addition & 1 deletion audio/midi/zerberus/zerberus.cpp
Expand Up @@ -294,7 +294,7 @@ void Zerberus::allNotesOff(int channel)

bool Zerberus::loadSoundFonts(const QStringList& sl)
{
foreach (const QString& s, sl) {
for (const QString& s : sl) {
if (!loadInstrument(s))
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion audio/midi/zerberus/zerberusgui.cpp
Expand Up @@ -285,7 +285,7 @@ void ZerberusGui::soundFontAddClicked()
QFileInfoList l = Zerberus::sfzFiles();

SfzListDialog ld(this);
foreach (const QFileInfo& fi, l)
for (const QFileInfo& fi : l)
ld.add(fi.fileName(), fi.absoluteFilePath());
if (!ld.exec())
return;
Expand Down

0 comments on commit ae54ec8

Please sign in to comment.