Add commandline parameter -pluginpath to add plugin search path

One or more commandline parameters -pluginpath allows to add custom search paths
for plugins to PluginManager::pluginPaths

Change-Id: I6d2702f1713b99000679ae577ce0978b3de51354
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
Guido Seifert
2013-06-25 14:20:45 +02:00
parent a0ee1300c3
commit 1c6cb92958

View File

@@ -72,8 +72,8 @@ static const char fixedOptionsC[] =
" -client Attempt to connect to already running first instance\n" " -client Attempt to connect to already running first instance\n"
" -settingspath <path> Override the default path where user settings are stored\n" " -settingspath <path> Override the default path where user settings are stored\n"
" -pid <pid> Attempt to connect to instance given by pid\n" " -pid <pid> Attempt to connect to instance given by pid\n"
" -block Block until editor is closed\n"; " -block Block until editor is closed\n"
" -pluginpath <path> Add a custom search path for plugins\n";
static const char HELP_OPTION1[] = "-h"; static const char HELP_OPTION1[] = "-h";
static const char HELP_OPTION2[] = "-help"; static const char HELP_OPTION2[] = "-help";
@@ -84,6 +84,7 @@ static const char CLIENT_OPTION[] = "-client";
static const char SETTINGS_OPTION[] = "-settingspath"; static const char SETTINGS_OPTION[] = "-settingspath";
static const char PID_OPTION[] = "-pid"; static const char PID_OPTION[] = "-pid";
static const char BLOCK_OPTION[] = "-block"; static const char BLOCK_OPTION[] = "-block";
static const char PLUGINPATH_OPTION[] = "-pluginpath";
typedef QList<PluginSpec *> PluginSpecSet; typedef QList<PluginSpec *> PluginSpecSet;
@@ -315,6 +316,7 @@ int main(int argc, char **argv)
// We can't use the regular way of the plugin manager, because that needs to parse pluginspecs // We can't use the regular way of the plugin manager, because that needs to parse pluginspecs
// but the settings path can influence which plugins are enabled // but the settings path can influence which plugins are enabled
QString settingsPath; QString settingsPath;
QStringList customPluginPaths;
QStringList arguments = app.arguments(); // adapted arguments list is passed to plugin manager later QStringList arguments = app.arguments(); // adapted arguments list is passed to plugin manager later
QMutableStringListIterator it(arguments); QMutableStringListIterator it(arguments);
while (it.hasNext()) { while (it.hasNext()) {
@@ -325,6 +327,12 @@ int main(int argc, char **argv)
settingsPath = QDir::fromNativeSeparators(it.next()); settingsPath = QDir::fromNativeSeparators(it.next());
it.remove(); it.remove();
} }
} else if (arg == QLatin1String(PLUGINPATH_OPTION)) {
it.remove();
if (it.hasNext()) {
customPluginPaths << QDir::fromNativeSeparators(it.next());
it.remove();
}
} }
} }
if (!settingsPath.isEmpty()) if (!settingsPath.isEmpty())
@@ -402,9 +410,8 @@ int main(int argc, char **argv)
QNetworkProxyFactory::setUseSystemConfiguration(true); QNetworkProxyFactory::setUseSystemConfiguration(true);
#endif #endif
// Load // Load
const QStringList pluginPaths = getPluginPaths(); const QStringList pluginPaths = getPluginPaths() + customPluginPaths;
PluginManager::setPluginPaths(pluginPaths); PluginManager::setPluginPaths(pluginPaths);
QMap<QString, QString> foundAppOptions; QMap<QString, QString> foundAppOptions;
if (arguments.size() > 1) { if (arguments.size() > 1) {
QMap<QString, bool> appOptions; QMap<QString, bool> appOptions;