forked from qt-creator/qt-creator
Make PluginManager mostly static.
Change-Id: Ib938aa4999c7c418a82304c5cca2e8748ef9d228 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -61,6 +61,8 @@
|
||||
#include <qtsystemexceptionhandler.h>
|
||||
#endif
|
||||
|
||||
using namespace ExtensionSystem;
|
||||
|
||||
enum { OptionIndent = 4, DescriptionIndent = 34 };
|
||||
|
||||
static const char appNameC[] = "Qt Creator";
|
||||
@@ -89,7 +91,7 @@ static const char SETTINGS_OPTION[] = "-settingspath";
|
||||
static const char PID_OPTION[] = "-pid";
|
||||
#endif
|
||||
|
||||
typedef QList<ExtensionSystem::PluginSpec *> PluginSpecSet;
|
||||
typedef QList<PluginSpec *> PluginSpecSet;
|
||||
|
||||
// Helpers for displaying messages. Note that there is no console on Windows.
|
||||
#ifdef Q_OS_WIN
|
||||
@@ -128,24 +130,23 @@ static void displayError(const QString &t)
|
||||
|
||||
#endif
|
||||
|
||||
static void printVersion(const ExtensionSystem::PluginSpec *coreplugin,
|
||||
const ExtensionSystem::PluginManager &pm)
|
||||
static void printVersion(const PluginSpec *coreplugin)
|
||||
{
|
||||
QString version;
|
||||
QTextStream str(&version);
|
||||
str << '\n' << appNameC << ' ' << coreplugin->version()<< " based on Qt " << qVersion() << "\n\n";
|
||||
pm.formatPluginVersions(str);
|
||||
PluginManager::formatPluginVersions(str);
|
||||
str << '\n' << coreplugin->copyright() << '\n';
|
||||
displayHelpText(version);
|
||||
}
|
||||
|
||||
static void printHelp(const QString &a0, const ExtensionSystem::PluginManager &pm)
|
||||
static void printHelp(const QString &a0)
|
||||
{
|
||||
QString help;
|
||||
QTextStream str(&help);
|
||||
str << "Usage: " << a0 << fixedOptionsC;
|
||||
ExtensionSystem::PluginManager::formatOptions(str, OptionIndent, DescriptionIndent);
|
||||
pm.formatPluginOptions(str, OptionIndent, DescriptionIndent);
|
||||
PluginManager::formatOptions(str, OptionIndent, DescriptionIndent);
|
||||
PluginManager::formatPluginOptions(str, OptionIndent, DescriptionIndent);
|
||||
displayHelpText(help);
|
||||
}
|
||||
|
||||
@@ -264,10 +265,10 @@ int main(int argc, char **argv)
|
||||
QSettings *globalSettings = new QSettings(QSettings::IniFormat, QSettings::SystemScope,
|
||||
QLatin1String(Core::Constants::IDE_SETTINGSVARIANT_STR),
|
||||
QLatin1String("QtCreator"));
|
||||
ExtensionSystem::PluginManager pluginManager;
|
||||
pluginManager.setFileExtension(QLatin1String("pluginspec"));
|
||||
pluginManager.setGlobalSettings(globalSettings);
|
||||
pluginManager.setSettings(settings);
|
||||
PluginManager pluginManager;
|
||||
PluginManager::setFileExtension(QLatin1String("pluginspec"));
|
||||
PluginManager::setGlobalSettings(globalSettings);
|
||||
PluginManager::setSettings(settings);
|
||||
|
||||
QTranslator translator;
|
||||
QTranslator qtTranslator;
|
||||
@@ -323,7 +324,7 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
// Load
|
||||
const QStringList pluginPaths = getPluginPaths();
|
||||
pluginManager.setPluginPaths(pluginPaths);
|
||||
PluginManager::setPluginPaths(pluginPaths);
|
||||
|
||||
QMap<QString, QString> foundAppOptions;
|
||||
if (arguments.size() > 1) {
|
||||
@@ -338,16 +339,16 @@ int main(int argc, char **argv)
|
||||
appOptions.insert(QLatin1String(PID_OPTION), true);
|
||||
#endif
|
||||
QString errorMessage;
|
||||
if (!pluginManager.parseOptions(arguments, appOptions, &foundAppOptions, &errorMessage)) {
|
||||
if (!PluginManager::parseOptions(arguments, appOptions, &foundAppOptions, &errorMessage)) {
|
||||
displayError(errorMessage);
|
||||
printHelp(QFileInfo(app.applicationFilePath()).baseName(), pluginManager);
|
||||
printHelp(QFileInfo(app.applicationFilePath()).baseName());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
const PluginSpecSet plugins = pluginManager.plugins();
|
||||
ExtensionSystem::PluginSpec *coreplugin = 0;
|
||||
foreach (ExtensionSystem::PluginSpec *spec, plugins) {
|
||||
const PluginSpecSet plugins = PluginManager::plugins();
|
||||
PluginSpec *coreplugin = 0;
|
||||
foreach (PluginSpec *spec, plugins) {
|
||||
if (spec->name() == QLatin1String(corePluginNameC)) {
|
||||
coreplugin = spec;
|
||||
break;
|
||||
@@ -364,14 +365,14 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
if (foundAppOptions.contains(QLatin1String(VERSION_OPTION))) {
|
||||
printVersion(coreplugin, pluginManager);
|
||||
printVersion(coreplugin);
|
||||
return 0;
|
||||
}
|
||||
if (foundAppOptions.contains(QLatin1String(HELP_OPTION1))
|
||||
|| foundAppOptions.contains(QLatin1String(HELP_OPTION2))
|
||||
|| foundAppOptions.contains(QLatin1String(HELP_OPTION3))
|
||||
|| foundAppOptions.contains(QLatin1String(HELP_OPTION4))) {
|
||||
printHelp(QFileInfo(app.applicationFilePath()).baseName(), pluginManager);
|
||||
printHelp(QFileInfo(app.applicationFilePath()).baseName());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -387,7 +388,7 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
|
||||
if (app.isRunning() && (pid != -1 || foundAppOptions.contains(QLatin1String(CLIENT_OPTION)))) {
|
||||
if (app.sendMessage(pluginManager.serializedArguments(), 5000 /*timeout*/, pid))
|
||||
if (app.sendMessage(PluginManager::serializedArguments(), 5000 /*timeout*/, pid))
|
||||
return 0;
|
||||
|
||||
// Message could not be send, maybe it was in the process of quitting
|
||||
@@ -395,7 +396,7 @@ int main(int argc, char **argv)
|
||||
// Nah app is still running, ask the user
|
||||
int button = askMsgSendFailed();
|
||||
while(button == QMessageBox::Retry) {
|
||||
if (app.sendMessage(pluginManager.serializedArguments(), 5000 /*timeout*/, pid))
|
||||
if (app.sendMessage(PluginManager::serializedArguments(), 5000 /*timeout*/, pid))
|
||||
return 0;
|
||||
if (!app.isRunning(pid)) // App quit while we were trying so start a new creator
|
||||
button = QMessageBox::Yes;
|
||||
@@ -407,13 +408,13 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
pluginManager.loadPlugins();
|
||||
PluginManager::loadPlugins();
|
||||
if (coreplugin->hasError()) {
|
||||
displayError(msgCoreLoadFailure(coreplugin->errorString()));
|
||||
return 1;
|
||||
}
|
||||
if (pluginManager.hasError()) {
|
||||
ExtensionSystem::PluginErrorOverview errorOverview(&pluginManager);
|
||||
if (PluginManager::hasError()) {
|
||||
PluginErrorOverview errorOverview;
|
||||
errorOverview.exec();
|
||||
}
|
||||
|
||||
@@ -430,7 +431,7 @@ int main(int argc, char **argv)
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
// Do this after the event loop has started
|
||||
if (pluginManager.runningTests())
|
||||
if (PluginManager::runningTests())
|
||||
QTimer::singleShot(100, &pluginManager, SLOT(startTests()));
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user