summaryrefslogtreecommitdiffhomepage
path: root/facetracknoir
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2013-09-13 15:20:48 +0200
committerStanislaw Halik <sthalik@misaki.pl>2013-09-13 15:20:48 +0200
commit330ec26d2e045d292e28fb814ebb6587dc977b5c (patch)
tree8415e758312336f5af7a426ee225b287b02fbbcb /facetracknoir
parentd6506963fa18ba8344d32668649c9cd1e6be9606 (diff)
Remove copypasta entirely in shared object loading
Diffstat (limited to 'facetracknoir')
-rw-r--r--facetracknoir/facetracknoir.cpp83
1 files changed, 29 insertions, 54 deletions
diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp
index 47ef1787..2d8b9252 100644
--- a/facetracknoir/facetracknoir.cpp
+++ b/facetracknoir/facetracknoir.cpp
@@ -1002,64 +1002,39 @@ static bool get_metadata(DynamicLibrary* lib, QString& longName, QIcon& icon)
return true;
}
-//
-// Setup the icons for the comboBoxes
-//
-void FaceTrackNoIR::createIconGroupBox()
+static void fill_combobox(const QString& filter, QList<DynamicLibrary*>& list, QComboBox* cbx)
{
- QDir settingsDir( QCoreApplication::applicationDirPath() );
-
- {
- QStringList protocols = settingsDir.entryList( QStringList() << (LIB_PREFIX "opentrack-proto-*." SONAME), QDir::Files, QDir::Name );
- for ( int i = 0; i < protocols.size(); i++) {
- QIcon icon;
- QString longName;
- QString str = protocols.at(i);
- DynamicLibrary* lib = new DynamicLibrary(str);
- qDebug() << "Loading" << str;
- std::cout.flush();
- if (!get_metadata(lib, longName, icon))
- continue;
- dlopen_protocols.push_back(lib);
- ui.iconcomboProtocol->addItem(icon, longName);
- }
- }
-
- {
- ui.cbxSecondTrackerSource->addItem(QIcon(), "None");
- QStringList trackers = settingsDir.entryList( QStringList() << (LIB_PREFIX "opentrack-tracker-*." SONAME), QDir::Files, QDir::Name );
- for ( int i = 0; i < trackers.size(); i++) {
- QIcon icon;
- QString longName;
- QString str = trackers.at(i);
- DynamicLibrary* lib = new DynamicLibrary(str);
- qDebug() << "Loading" << str;
- std::cout.flush();
- if (!get_metadata(lib, longName, icon))
- continue;
- dlopen_trackers.push_back(lib);
- ui.iconcomboTrackerSource->addItem(icon, longName);
- ui.cbxSecondTrackerSource->addItem(icon, longName);
+ QDir settingsDir( QCoreApplication::applicationDirPath() );
+ QStringList filenames = settingsDir.entryList( QStringList() << (LIB_PREFIX + filter + SONAME), QDir::Files, QDir::Name );
+ for ( int i = 0; i < filenames.size(); i++) {
+ QIcon icon;
+ QString longName;
+ QString str = filenames.at(i);
+ DynamicLibrary* lib = new DynamicLibrary(str);
+ qDebug() << "Loading" << str;
+ std::cout.flush();
+ if (!get_metadata(lib, longName, icon))
+ {
+ delete lib;
+ continue;
}
+ list.push_back(lib);
+ cbx->addItem(icon, longName);
}
+}
- {
- dlopen_filters.push_back((DynamicLibrary*) NULL);
- ui.iconcomboFilter->addItem(QIcon(), "None");
- QStringList filters = settingsDir.entryList( QStringList() << (LIB_PREFIX "opentrack-filter-*." SONAME), QDir::Files, QDir::Name );
- for ( int i = 0; i < filters.size(); i++) {
- QIcon icon;
- QString longName;
- QString str = filters.at(i);
- DynamicLibrary* lib = new DynamicLibrary(str);
- qDebug() << "Loading" << str;
- std::cout.flush();
- if (!get_metadata(lib, longName, icon))
- continue;
- dlopen_filters.push_back(lib);
- ui.iconcomboFilter->addItem(icon, longName);
- }
- }
+//
+// Setup the icons for the comboBoxes
+//
+void FaceTrackNoIR::createIconGroupBox()
+{
+ ui.cbxSecondTrackerSource->addItem(QIcon(), "None");
+ dlopen_filters.push_back((DynamicLibrary*) NULL);
+ ui.iconcomboFilter->addItem(QIcon(), "None");
+
+ fill_combobox("opentrack-proto-*.", dlopen_protocols, ui.iconcomboProtocol);
+ fill_combobox("opentrack-tracker-*.", dlopen_trackers, ui.iconcomboTrackerSource);
+ fill_combobox("opentrack-filter-*.", dlopen_filters, ui.iconcomboFilter);
connect(ui.iconcomboProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolSelected(int)));
connect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int)));