]> vaikene.ee Git - evaf/blobdiff - src/libs/Common/env.cpp
Seems that Windows did not like exporting/importing the eVaf::PswGen::Storage::Data...
[evaf] / src / libs / Common / env.cpp
index 55b133ed3814a10fcbd79879b8601b2223ec40b6..9f72a8cebdaedcea415a8134eaccd546b8221131 100644 (file)
@@ -24,7 +24,6 @@
 #include "iapp.h"
 
 #include <QtCore>
-#include <QDesktopServices>
 
 
 //-------------------------------------------------------------------
@@ -33,7 +32,7 @@ using namespace eVaf::Common;
 
 iEnv * iEnv::instance()
 {
-    static Internal::Env singleton;
+    static eVaf::Common::Internal::Env singleton;
     return &singleton;
 }
 
@@ -46,6 +45,16 @@ Env::Env()
     : iEnv()
 {
     setObjectName(QString("%1-iEnv").arg(VER_MODULE_NAME_STR));
+}
+
+Env::~Env()
+{
+}
+
+bool Env::init()
+{
+    // Register out interface
+    iRegistry::instance()->registerInterface("iEnv", this);
 
     // Set initial bin and root directories
     mRootDir = mBinDir = qApp->applicationDirPath();
@@ -57,26 +66,28 @@ Env::Env()
         mBinDir.append('/');
     if (!mRootDir.endsWith('/'))
         mRootDir.append('/');
-}
 
-Env::~Env()
-{
-}
-
-bool Env::init()
-{
-    // Register out interface
-    iRegistry::instance()->registerInterface("iEnv", this);
-
-    // Clear directories
+    // Clear other directories
     mDataRootDir.clear();
     mQtPluginsDir.clear();
     mEtcDir.clear();
     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;
 }