diff --git a/src/core/snore.cpp b/src/core/snore.cpp index 88c2548..881e95e 100644 --- a/src/core/snore.cpp +++ b/src/core/snore.cpp @@ -36,7 +36,7 @@ namespace Snore{ QHash SnoreCore::s_pluginCache = QHash() ; -QString SnoreCore::s_pluginPath = QString(qApp->applicationDirPath()+"/snoreplugins"); +QDir *SnoreCore::s_pluginDir = NULL; QString const SnoreCore::version(){ return QString().append(Version::major()).append(".").append(Version::minor()).append(Version::suffix()); @@ -80,9 +80,7 @@ QHash SnoreCore::pluginCache(){ return s_pluginCache; } -void SnoreCore::updatePluginCache(const QString &pluginPath){ - if(!pluginPath.isEmpty()) - s_pluginPath = pluginPath; +void SnoreCore::updatePluginCache(){ QSettings cache(SnoreCore::pluginDir().absoluteFilePath("plugin.cache"),QSettings::IniFormat); qDebug()<<"Updating plugin cache"<exists()) - plDir = new QDir(LIBSNORE_PLUGIN_PATH); +const QDir &SnoreCore::pluginDir(){ + if(s_pluginDir == NULL) + setPluginDir(); + qDebug()<<"SnorePluginDir:"<path(); + return *s_pluginDir; +} + +void SnoreCore::setPluginDir(const QString &path){ + if(!path.isEmpty()){//path is not empty + QDir *tmp = new QDir(path); + if(tmp->exists()){//path exists + s_pluginDir = tmp; + }else{ + delete tmp; + } + } + //if pluginpath is not initialized try snoreplugins/ in application dir + if(s_pluginDir == NULL){ + s_pluginDir = new QDir(qApp->applicationDirPath()+"/snoreplugins"); + qDebug()<<"PluginDir"<absolutePath(); + if(!s_pluginDir->exists())//still not existing? use the path defined on compile time + s_pluginDir = new QDir(LIBSNORE_PLUGIN_PATH); } - qDebug()<<"SnorePluginDir:"<path(); - return *plDir; } void SnoreCore::publicatePlugin ( PluginContainer::PluginTypes types ) diff --git a/src/core/snore.h b/src/core/snore.h index 646e36e..fbed10b 100644 --- a/src/core/snore.h +++ b/src/core/snore.h @@ -34,8 +34,9 @@ class SNORE_EXPORT SnoreCore:public QObject public: static const QString version(); static const QString snoreTMP(); - static void updatePluginCache(const QString &pluginPath = ""); + static void updatePluginCache(); static const QDir &pluginDir(); + static void setPluginDir(const QString &path = ""); public: SnoreCore (QSystemTrayIcon *trayIcon=0 ); @@ -65,6 +66,7 @@ private: static QHash pluginCache(); static QHash s_pluginCache; + static QDir *s_pluginDir; ApplicationsList m_applications; @@ -76,7 +78,6 @@ private: QPointer m_notificationBackend; QSystemTrayIcon *m_trayIcon; - static QString s_pluginPath; signals: