Skip to content

Commit

Permalink
fix #43476
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Jan 7, 2015
1 parent 1d4556b commit 4bd8a8e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
2 changes: 1 addition & 1 deletion zerberus/zerberus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ QStringList Zerberus::soundFonts() const
{
QStringList sl;
for (ZInstrument* i : instruments)
sl.append(QFileInfo(i->path()).fileName());
sl.append(i->path());
return sl;
}

Expand Down
48 changes: 41 additions & 7 deletions zerberus/zerberusgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ SfzListDialog::SfzListDialog(QWidget* parent)
connect(list, SIGNAL(itemClicked(QListWidgetItem*)), SLOT(itemSelected(QListWidgetItem*)));
}

//---------------------------------------------------------
// add
//---------------------------------------------------------

void SfzListDialog::add(const QString& name, const QString& path)
{
QListWidgetItem* item = new QListWidgetItem;
Expand All @@ -48,13 +52,21 @@ void SfzListDialog::itemSelected(QListWidgetItem* item)
accept();
}

//---------------------------------------------------------
// name
//---------------------------------------------------------

QString SfzListDialog::name()
{
if (_idx == -1)
return QString();
return list->item(_idx)->text();
}

//---------------------------------------------------------
// path
//---------------------------------------------------------

QString SfzListDialog::path()
{
if (_idx == -1)
Expand Down Expand Up @@ -150,9 +162,8 @@ void ZerberusGui::addClicked()
QString sfName = ld.name();
QString sfPath = ld.path();

int n = files->count();
QStringList sl;
for (int i = 0; i < n; ++i) {
for (int i = 0; i < files->count(); ++i) {
QListWidgetItem* item = files->item(i);
sl.append(item->text());
}
Expand All @@ -172,17 +183,29 @@ void ZerberusGui::addClicked()
}
}

//---------------------------------------------------------
// updateProgress
//---------------------------------------------------------

void ZerberusGui::updateProgress()
{
_progressDialog->setValue(zerberus()->loadProgress());
}

//---------------------------------------------------------
// updateButtons
//---------------------------------------------------------

void ZerberusGui::updateButtons()
{
int row = files->currentRow();
remove->setEnabled(row != -1);
}

//---------------------------------------------------------
// onSoundFontLoaded
//---------------------------------------------------------

void ZerberusGui::onSoundFontLoaded()
{
bool loaded = _futureWatcher.result();
Expand All @@ -194,9 +217,13 @@ void ZerberusGui::onSoundFontLoaded()
tr("cannot load soundfont %1").arg(_loadedSfPath));
}
else {
files->insertItem(0, _loadedSfName);
QListWidgetItem* item = new QListWidgetItem;
item->setText(_loadedSfName);
item->setData(Qt::UserRole, _loadedSfPath);
files->insertItem(0, item);
}
emit valueChanged();
emit sfChanged();
}

//---------------------------------------------------------
Expand All @@ -207,10 +234,12 @@ void ZerberusGui::removeClicked()
{
int row = files->currentRow();
if (row >= 0) {
QString s(files->item(row)->text());
zerberus()->removeSoundFont(s);
QString path(files->item(row)->data(Qt::UserRole).toString());
if (!zerberus()->removeSoundFont(path))
qDebug("ZerberusGui::removeClicked: cannot remove sf %s", qPrintable(files->item(row)->text()));
delete files->takeItem(row);
emit valueChanged();
emit sfChanged();
updateButtons();
}
}
Expand All @@ -221,9 +250,14 @@ void ZerberusGui::removeClicked()

void ZerberusGui::synthesizerChanged()
{
QStringList sfonts = zerberus()->soundFonts();
files->clear();
files->addItems(sfonts);
QStringList sfonts = zerberus()->soundFonts();
for (QString path : sfonts) {
QListWidgetItem* item = new QListWidgetItem;
item->setText(QFileInfo(path).fileName());
item->setData(Qt::UserRole, path);
files->addItem(item);
}
}


0 comments on commit 4bd8a8e

Please sign in to comment.