Skip to content

Commit

Permalink
obs-vst.cpp: Add alphabetical sorting to plugin name list
Browse files Browse the repository at this point in the history
Fixes github issue obsproject#18.
  • Loading branch information
c3r1c3 committed Jan 19, 2017
1 parent b87b55c commit 13e88fd
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions obs-vst.cpp
Expand Up @@ -103,8 +103,11 @@ static void fill_out_plugins(obs_property_t *list)
#endif

QStringList filters;
obs_property_list_add_string(list, "{Please select a plugin}", nullptr);
filters << "*.vst" << "*.dll" << "*.so";

QStringList vst_list;

// Read all plugins into a list...
for (int a = 0; a < dir_list.size(); ++a)
{
QDir search_dir(dir_list[a]);
Expand All @@ -114,9 +117,23 @@ static void fill_out_plugins(obs_property_t *list)
QString path = it.next();
QString name = it.fileName();
name.remove(QRegExp("(\\.dll|\\.vst|\\.so|\\.o)"));
obs_property_list_add_string(list, name.toStdString().c_str(), path.toStdString().c_str());
name.append("=").append(path);
vst_list << name;
}
}

// Now sort list alphabetically.
qStableSort(vst_list.begin(), vst_list.end());

// Now add said list to the plug-in list of OBS
obs_property_list_add_string(list, "{Please select a plug-in}", nullptr);
for (int b = 0; b < vst_list.size(); ++b)
{
QString vst_sorted = vst_list[b];
QString name = vst_sorted.left(vst_sorted.indexOf('=') - 1);
QString path = vst_sorted.right(vst_sorted.indexOf('=') + 1);
obs_property_list_add_string(list, name.toStdString().c_str(), path.toStdString().c_str());
}
}

static obs_properties_t *vst_properties(void *data)
Expand Down

0 comments on commit 13e88fd

Please sign in to comment.