aboutsummaryrefslogtreecommitdiffstats
path: root/utils/alsoft-config
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-08-05 04:56:51 -0700
committerChris Robinson <[email protected]>2014-08-05 04:56:51 -0700
commitbda39c5038e67bdad0c39a3c311136167aad3d15 (patch)
tree14aa4e420d52990bc4d3f671ab449a53be958252 /utils/alsoft-config
parent066a48c5fb8cee4b32bd7145dd78147ba709f067 (diff)
Filter for relative HRTF data paths and add Add/Remove label texts
Diffstat (limited to 'utils/alsoft-config')
-rw-r--r--utils/alsoft-config/mainwindow.cpp72
-rw-r--r--utils/alsoft-config/mainwindow.ui19
2 files changed, 79 insertions, 12 deletions
diff --git a/utils/alsoft-config/mainwindow.cpp b/utils/alsoft-config/mainwindow.cpp
index f009208a..c58000d9 100644
--- a/utils/alsoft-config/mainwindow.cpp
+++ b/utils/alsoft-config/mainwindow.cpp
@@ -52,6 +52,48 @@ static QString getDefaultConfigName()
return base +'/'+ fname;
return fname;
}
+
+static QString getBaseDataPath()
+{
+#ifdef Q_OS_WIN32
+ QByteArray base = qgetenv("AppData");
+#else
+ QByteArray base = qgetenv("XDG_DATA_HOME");
+ if(base.isEmpty())
+ {
+ base = qgetenv("HOME");
+ if(!base.isEmpty())
+ base += "/.local/share";
+ }
+#endif
+ return base;
+}
+
+static QStringList getAllDataPaths(QString append=QString())
+{
+ QStringList list;
+ list.append(getBaseDataPath());
+#ifdef Q_OS_WIN32
+ // TODO: Common AppData path
+#else
+ QString paths = qgetenv("XDG_DATA_DIRS");
+ if(paths.isEmpty())
+ paths = "/usr/local/share/:/usr/share/";
+ list += paths.split(QChar(':'), QString::SkipEmptyParts);
+#endif
+ QStringList::iterator iter = list.begin();
+ while(iter != list.end())
+ {
+ if(iter->isEmpty())
+ iter = list.erase(iter);
+ else
+ {
+ iter->append(append);
+ iter++;
+ }
+ }
+ return list;
+}
}
MainWindow::MainWindow(QWidget *parent) :
@@ -490,10 +532,36 @@ void MainWindow::updatePeriodCountSlider()
void MainWindow::addHrtfFile()
{
- QStringList fnames = QFileDialog::getOpenFileNames(this, tr("Select Files"), QString(),
+ const QStringList datapaths = getAllDataPaths("/openal/hrtf");
+ QStringList fnames = QFileDialog::getOpenFileNames(this, tr("Select Files"),
+ datapaths.empty() ? QString() : datapaths[0],
"HRTF Datasets(*.mhr);;All Files(*.*)");
if(fnames.isEmpty() == false)
- ui->hrtfFileList->addItems(fnames);
+ {
+ for(QStringList::iterator iter = fnames.begin();iter != fnames.end();iter++)
+ {
+ QStringList::const_iterator path = datapaths.constBegin();
+ for(;path != datapaths.constEnd();path++)
+ {
+ QDir hrtfdir(*path);
+ if(!hrtfdir.isAbsolute())
+ continue;
+
+ const QString relname = hrtfdir.relativeFilePath(*iter);
+ if(!relname.startsWith(".."))
+ {
+ // If filename is within this path, use the relative pathname
+ ui->hrtfFileList->addItem(relname);
+ break;
+ }
+ }
+ if(path == datapaths.constEnd())
+ {
+ // Filename is not within any data path, use the absolute pathname
+ ui->hrtfFileList->addItem(*iter);
+ }
+ }
+ }
}
void MainWindow::removeHrtfFile()
diff --git a/utils/alsoft-config/mainwindow.ui b/utils/alsoft-config/mainwindow.ui
index 7a0276d8..b9e9acee 100644
--- a/utils/alsoft-config/mainwindow.ui
+++ b/utils/alsoft-config/mainwindow.ui
@@ -348,15 +348,14 @@ sample rate.</string>
<rect>
<x>110</x>
<y>30</y>
- <width>361</width>
+ <width>301</width>
<height>121</height>
</rect>
</property>
<property name="toolTip">
<string>A list of files containing HRTF data sets. The listed data sets
-are used in place of or in addition to the the default sets. The
-filenames may contain these markers, which will be replaced
-as needed:
+are used in place of the default sets. The filenames may
+contain these markers, which will be replaced as needed:
%r - Device sampling rate
%% - Percent sign (%)</string>
</property>
@@ -379,14 +378,14 @@ as needed:
<widget class="QPushButton" name="hrtfAddButton">
<property name="geometry">
<rect>
- <x>475</x>
+ <x>419</x>
<y>30</y>
- <width>25</width>
+ <width>81</width>
<height>25</height>
</rect>
</property>
<property name="text">
- <string/>
+ <string>Add...</string>
</property>
<property name="icon">
<iconset theme="list-add">
@@ -400,14 +399,14 @@ as needed:
<widget class="QPushButton" name="hrtfRemoveButton">
<property name="geometry">
<rect>
- <x>475</x>
+ <x>419</x>
<y>60</y>
- <width>25</width>
+ <width>81</width>
<height>25</height>
</rect>
</property>
<property name="text">
- <string/>
+ <string>Remove</string>
</property>
<property name="icon">
<iconset theme="list-remove">