]> vaikene.ee Git - evaf/blobdiff - src/libs/Common/env.cpp
Doxygen documentation fixes.
[evaf] / src / libs / Common / env.cpp
index e0c08348628741c1723d31a2b694ebfbd6a26eee..9f72a8cebdaedcea415a8134eaccd546b8221131 100644 (file)
@@ -24,7 +24,6 @@
 #include "iapp.h"
 
 #include <QtCore>
-#include <QDesktopServices>
 
 
 //-------------------------------------------------------------------
@@ -75,8 +74,20 @@ bool Env::init()
     mLogDir.clear();
     mDocDir.clear();
 
+    // Set the data root directory
+#ifdef Q_OS_LINUX
+    QString dataLoc = QDir::homePath();
+    if (!dataLoc.endsWith('/'))
+        dataLoc.append('/');
+    dataLoc.append(".local/share/data/");
+    mDataRootDir = dataLoc + iApp::instance()->name();
+    if (!mDataRootDir.endsWith('/'))
+        mDataRootDir.append('/');
+#endif
+    /// @TODO: Needs local data directory on Windows
+
     // Process the environment
-    QStringList env = QProcess::systemEnvironment();
+    QStringList env = QProcessEnvironment::systemEnvironment().toStringList();
     int sz = env.size();
     for (int i = 0; i < sz; ++i) {
         // Get the name/value pair
@@ -159,15 +170,9 @@ bool Env::init()
 
 QString const Env::dataRootDir() const
 {
-    if (mDataRootDir.isEmpty()) {
-        QString dataLoc = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
-        if (!dataLoc.endsWith('/'))
-            dataLoc.append('/');
-        mDataRootDir = dataLoc.append(iApp::instance()->name());
-        if (!mDataRootDir.endsWith('/'))
-            mDataRootDir.append('/');
-    }
-
+    // Fall-back to the application's root directory if the data root directory is empty
+    if (mDataRootDir.isEmpty())
+        mDataRootDir = rootDir();
     return mDataRootDir;
 }