Przeglądaj źródła

ENH: PluginFramework: App individual plugin databases

The plugin database filename now corresponds to the
application name set by calling QCoreApplication::setApplicationName()
(cherry picked from commit c92079ab12654b37c1ee91ac62dee64b5324c19b)
Sascha Zelzer 14 lat temu
rodzic
commit
3b86f353e8
1 zmienionych plików z 16 dodań i 12 usunięć
  1. 16 12
      Libs/PluginFramework/ctkPluginDatabase.cpp

+ 16 - 12
Libs/PluginFramework/ctkPluginDatabase.cpp

@@ -35,17 +35,10 @@
 
 #include <QDebug>
 
-//database name
-#define PLUGINDATABASE "pluginfw.db"
-
 //database table names
 #define PLUGINS_TABLE "Plugins"
 #define PLUGIN_RESOURCES_TABLE "PluginResources"
 
-//separator
-#define PLUGINDATABASE_PATH_SEPARATOR "//"
-
-
 
 enum TBindIndexes
 {
@@ -527,16 +520,27 @@ QString ctkPluginDatabase::getDatabasePath() const
     QString path;
     if(m_databasePath.isEmpty())
     {
-      QSettings settings(QSettings::UserScope, "commontk", QApplication::applicationName());
+      QSettings settings;
       path = settings.value("PluginDB/Path").toString();
       if (path.isEmpty())
       {
-        path = QDir::currentPath();
-        if (path.lastIndexOf(PLUGINDATABASE_PATH_SEPARATOR) != path.length() -1)
+        path = QApplication::applicationDirPath();
+        if (path.lastIndexOf("/") != path.length() -1)
+        {
+          path.append("/");
+        }
+        QString appName = QApplication::applicationName();
+        appName.replace(" ", "");
+        if (!appName.isEmpty())
+        {
+          path.append(appName + "_plugins.db");
+        }
+        else
         {
-          path.append(PLUGINDATABASE_PATH_SEPARATOR);
+          path.append("pluginfw.db");
+          qWarning() << "Warning: Using generic plugin database name. You should "
+              "set an application name via QCoreApplication::setApplicationName()";
         }
-        path.append(PLUGINDATABASE);
       }
       path = QDir::toNativeSeparators(path);
     }