TextEditorSettings::~TextEditorSettings() { ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); pm->removeObject(m_fontSettingsPage); pm->removeObject(m_behaviorSettingsPage); pm->removeObject(m_displaySettingsPage); m_instance = 0; }
MessageManager::~MessageManager() { ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); if (pm && m_messageOutputWindow) { pm->removeObject(m_messageOutputWindow); delete m_messageOutputWindow; } m_instance = 0; }
int main(int argc, char *argv[]) { ExtensionSystem::PluginManager manager; QApplication app(argc, argv); PluginDialog dialog(&manager); manager.setPluginPaths(QStringList() << "plugins"); manager.loadPlugins(); dialog.show(); app.exec(); }
void QtTestPlugin::extensionsInitialized() { ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); Core::ICore *core = Core::ICore::instance(); Core::ActionManager *am = core->actionManager(); m_messageOutputWindow = new TestOutputWindow(); pm->addObject(m_messageOutputWindow); m_testResultsWindow = TestResultsWindow::instance(); connect(m_testResultsWindow, SIGNAL(stopTest()), this, SLOT(stopTesting())); connect(m_testResultsWindow, SIGNAL(retryFailedTests(QStringList)), this, SLOT(retryTests(QStringList))); connect(TestExecuter::instance(), SIGNAL(testStarted()), m_testResultsWindow, SLOT(onTestStarted())); connect(TestExecuter::instance(), SIGNAL(testStop()), m_testResultsWindow, SLOT(onTestStopped())); connect(TestExecuter::instance(), SIGNAL(testFinished()), m_testResultsWindow, SLOT(onTestFinished())); pm->addObject(m_testResultsWindow); connect(testResultsPane(), SIGNAL(defectSelected(TestCaseRec)), this, SLOT(onDefectSelected(TestCaseRec))); // Add context menu to CPP editor Core::ActionContainer *mcontext = am->actionContainer(CppEditor::Constants::M_CONTEXT); m_contextMenu->init(mcontext->menu(), 2, this); // Add context menu to JS editor mcontext = am->actionContainer(QmlJSEditor::Constants::M_CONTEXT); m_contextMenu->init(mcontext->menu(), 2, this); // Add a Test menu to the menu bar Core::ActionContainer* ac = am->createMenu("QtTestPlugin.TestMenu"); ac->menu()->setTitle(tr("&Test")); m_contextMenu->init(ac->menu(), 0, 0); // Insert the "Test" menu between "Window" and "Help". QMenu *windowMenu = am->actionContainer(Core::Constants::M_TOOLS)->menu(); QMenuBar *menuBar = am->actionContainer(Core::Constants::MENU_BAR)->menuBar(); menuBar->insertMenu(windowMenu->menuAction(), ac->menu()); ProjectExplorer::ProjectExplorerPlugin *explorer = ProjectExplorer::ProjectExplorerPlugin::instance(); connect(explorer->session(), SIGNAL(startupProjectChanged(ProjectExplorer::Project*)), this, SLOT(onStartupProjectChanged(ProjectExplorer::Project *))); connect(core->progressManager(), SIGNAL(allTasksFinished(QString)), this, SLOT(onAllTasksFinished(QString))); connect(explorer->session(), SIGNAL(aboutToRemoveProject(ProjectExplorer::Project *)), this, SLOT(onProjectRemoved(ProjectExplorer::Project *))); m_contextMenu->init(0, 3, this); }
QtTestPlugin::~QtTestPlugin() { ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); pm->removeObject(m_messageOutputWindow); delete m_messageOutputWindow; pm->removeObject(m_testResultsWindow); delete m_testResultsWindow; delete TestExecuter::instance(); delete m_contextMenu; }
MainWindow::~MainWindow() { ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); pm->removeObject(m_shortcutSettings); pm->removeObject(m_generalSettings); pm->removeObject(m_toolSettings); pm->removeObject(m_mimeTypeSettings); pm->removeObject(m_systemEditor); delete m_externalToolManager; m_externalToolManager = 0; delete m_messageManager; m_messageManager = 0; delete m_shortcutSettings; m_shortcutSettings = 0; delete m_generalSettings; m_generalSettings = 0; delete m_toolSettings; m_toolSettings = 0; delete m_mimeTypeSettings; m_mimeTypeSettings = 0; delete m_systemEditor; m_systemEditor = 0; delete m_settings; m_settings = 0; delete m_printer; m_printer = 0; delete m_vcsManager; m_vcsManager = 0; //we need to delete editormanager and statusbarmanager explicitly before the end of the destructor, //because they might trigger stuff that tries to access data from editorwindow, like removeContextWidget // All modes are now gone OutputPaneManager::destroy(); // Now that the OutputPaneManager is gone, is a good time to delete the view pm->removeObject(m_outputView); delete m_outputView; delete m_editorManager; m_editorManager = 0; delete m_statusBarManager; m_statusBarManager = 0; delete m_progressManager; m_progressManager = 0; pm->removeObject(m_coreImpl); delete m_coreImpl; m_coreImpl = 0; delete m_rightPaneWidget; m_rightPaneWidget = 0; delete m_modeManager; m_modeManager = 0; delete m_mimeDatabase; m_mimeDatabase = 0; delete m_helpManager; m_helpManager = 0; }
static void printHelp(const QString &a0, const ExtensionSystem::PluginManager &pm) { QString help; QTextStream str(&help); str << "Usage: " << a0 << fixedOptionsC; ExtensionSystem::PluginManager::formatOptions(str, OptionIndent, DescriptionIndent); pm.formatPluginOptions(str, OptionIndent, DescriptionIndent); displayHelpText(help); }
static void printVersion(const ExtensionSystem::PluginSpec *coreplugin, const ExtensionSystem::PluginManager &pm) { QString version; QTextStream str(&version); str << '\n' << appNameC << ' ' << coreplugin->version()<< " based on Qt " << qVersion() << "\n\n"; pm.formatPluginVersions(str); str << '\n' << coreplugin->copyright() << '\n'; displayHelpText(version); }
TextEditorSettings::~TextEditorSettings() { ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); pm->removeObject(m_d->m_fontSettingsPage); pm->removeObject(m_d->m_behaviorSettingsPage); pm->removeObject(m_d->m_displaySettingsPage); pm->removeObject(m_d->m_highlighterSettingsPage); pm->removeObject(m_d->m_snippetsSettingsPage); delete m_d; m_instance = 0; }
TextEditorSettings::TextEditorSettings(QObject *parent) : QObject(parent) , m_d(new Internal::TextEditorSettingsPrivate) { QTC_ASSERT(!m_instance, return); m_instance = this; ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); // Note: default background colors are coming from FormatDescription::background() // Add font preference page FormatDescriptions formatDescriptions; formatDescriptions.append(FormatDescription(QLatin1String(C_TEXT), tr("Text"))); // Special categories const QPalette p = QApplication::palette(); formatDescriptions.append(FormatDescription(QLatin1String(C_LINK), tr("Link"), Qt::blue)); formatDescriptions.append(FormatDescription(QLatin1String(C_SELECTION), tr("Selection"), p.color(QPalette::HighlightedText))); formatDescriptions.append(FormatDescription(QLatin1String(C_LINE_NUMBER), tr("Line Number"))); formatDescriptions.append(FormatDescription(QLatin1String(C_SEARCH_RESULT), tr("Search Result"))); formatDescriptions.append(FormatDescription(QLatin1String(C_SEARCH_SCOPE), tr("Search Scope"))); formatDescriptions.append(FormatDescription(QLatin1String(C_PARENTHESES), tr("Parentheses"))); formatDescriptions.append(FormatDescription(QLatin1String(C_CURRENT_LINE), tr("Current Line"))); FormatDescription currentLineNumber = FormatDescription(QLatin1String(C_CURRENT_LINE_NUMBER), tr("Current Line Number"), Qt::darkGray); currentLineNumber.format().setBold(true); formatDescriptions.append(currentLineNumber); formatDescriptions.append(FormatDescription(QLatin1String(C_OCCURRENCES), tr("Occurrences"))); formatDescriptions.append(FormatDescription(QLatin1String(C_OCCURRENCES_UNUSED), tr("Unused Occurrence"))); formatDescriptions.append(FormatDescription(QLatin1String(C_OCCURRENCES_RENAME), tr("Renaming Occurrence"))); // Standard categories formatDescriptions.append(FormatDescription(QLatin1String(C_NUMBER), tr("Number"), Qt::darkBlue)); formatDescriptions.append(FormatDescription(QLatin1String(C_STRING), tr("String"), Qt::darkGreen)); formatDescriptions.append(FormatDescription(QLatin1String(C_TYPE), tr("Type"), Qt::darkMagenta)); formatDescriptions.append(FormatDescription(QLatin1String(C_LOCAL), tr("Local"))); formatDescriptions.append(FormatDescription(QLatin1String(C_FIELD), tr("Field"), Qt::darkRed)); formatDescriptions.append(FormatDescription(QLatin1String(C_STATIC), tr("Static"), Qt::darkMagenta)); FormatDescription virtualMethodFormatDescriptor(QLatin1String(C_VIRTUAL_METHOD), tr("Virtual Method")); virtualMethodFormatDescriptor.format().setItalic(true); formatDescriptions.append(virtualMethodFormatDescriptor); formatDescriptions.append(FormatDescription(QLatin1String(C_KEYWORD), tr("Keyword"), Qt::darkYellow)); formatDescriptions.append(FormatDescription(QLatin1String(C_OPERATOR), tr("Operator"))); formatDescriptions.append(FormatDescription(QLatin1String(C_PREPROCESSOR), tr("Preprocessor"), Qt::darkBlue)); formatDescriptions.append(FormatDescription(QLatin1String(C_LABEL), tr("Label"), Qt::darkRed)); formatDescriptions.append(FormatDescription(QLatin1String(C_COMMENT), tr("Comment"), Qt::darkGreen)); formatDescriptions.append(FormatDescription(QLatin1String(C_DOXYGEN_COMMENT), tr("Doxygen Comment"), Qt::darkBlue)); formatDescriptions.append(FormatDescription(QLatin1String(C_DOXYGEN_TAG), tr("Doxygen Tag"), Qt::blue)); formatDescriptions.append(FormatDescription(QLatin1String(C_VISUAL_WHITESPACE), tr("Visual Whitespace"), Qt::lightGray)); formatDescriptions.append(FormatDescription(QLatin1String(C_DISABLED_CODE), tr("Disabled Code"))); // Diff categories formatDescriptions.append(FormatDescription(QLatin1String(C_ADDED_LINE), tr("Added Line"), QColor(0, 170, 0))); formatDescriptions.append(FormatDescription(QLatin1String(C_REMOVED_LINE), tr("Removed Line"), Qt::red)); formatDescriptions.append(FormatDescription(QLatin1String(C_DIFF_FILE), tr("Diff File"), Qt::darkBlue)); formatDescriptions.append(FormatDescription(QLatin1String(C_DIFF_LOCATION), tr("Diff Location"), Qt::blue)); m_d->m_fontSettingsPage = new FontSettingsPage(formatDescriptions, QLatin1String(Constants::TEXT_EDITOR_FONT_SETTINGS), this); pm->addObject(m_d->m_fontSettingsPage); // Add the GUI used to configure the tab, storage and interaction settings TextEditor::BehaviorSettingsPageParameters behaviorSettingsPageParameters; behaviorSettingsPageParameters.id = QLatin1String(Constants::TEXT_EDITOR_BEHAVIOR_SETTINGS); behaviorSettingsPageParameters.displayName = tr("Behavior"); behaviorSettingsPageParameters.settingsPrefix = QLatin1String("text"); m_d->m_behaviorSettingsPage = new BehaviorSettingsPage(behaviorSettingsPageParameters, this); pm->addObject(m_d->m_behaviorSettingsPage); TextEditor::DisplaySettingsPageParameters displaySettingsPageParameters; displaySettingsPageParameters.id = QLatin1String(Constants::TEXT_EDITOR_DISPLAY_SETTINGS), displaySettingsPageParameters.displayName = tr("Display"); displaySettingsPageParameters.settingsPrefix = QLatin1String("text"); m_d->m_displaySettingsPage = new DisplaySettingsPage(displaySettingsPageParameters, this); pm->addObject(m_d->m_displaySettingsPage); m_d->m_highlighterSettingsPage = new HighlighterSettingsPage(QLatin1String(Constants::TEXT_EDITOR_HIGHLIGHTER_SETTINGS), this); pm->addObject(m_d->m_highlighterSettingsPage); m_d->m_snippetsSettingsPage = new SnippetsSettingsPage(QLatin1String(Constants::TEXT_EDITOR_SNIPPETS_SETTINGS), this); pm->addObject(m_d->m_snippetsSettingsPage); connect(m_d->m_fontSettingsPage, SIGNAL(changed(TextEditor::FontSettings)), this, SIGNAL(fontSettingsChanged(TextEditor::FontSettings))); connect(m_d->m_behaviorSettingsPage, SIGNAL(tabSettingsChanged(TextEditor::TabSettings)), this, SIGNAL(tabSettingsChanged(TextEditor::TabSettings))); connect(m_d->m_behaviorSettingsPage, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings)), this, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings))); connect(m_d->m_behaviorSettingsPage, SIGNAL(behaviorSettingsChanged(TextEditor::BehaviorSettings)), this, SIGNAL(behaviorSettingsChanged(TextEditor::BehaviorSettings))); connect(m_d->m_displaySettingsPage, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)), this, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings))); // TODO: Move these settings to TextEditor category if (QSettings *s = Core::ICore::instance()->settings()) m_d->m_completionSettings.fromSettings(QLatin1String("CppTools/"), s); }
/*! * \brief 该函数最初是在子线程中完成的,但是由于在子线程中完成创建对象的任务后,还需要将该对象moveToThread到 * 主线,给很多操作带来不小的麻烦,所以这里还是在主线程中完成的。 * \param[] receiver 用来传输数据 * \return 返回0表示成功 */ int loadPluginThread(MainApp *receiver) { QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, QCoreApplication::applicationDirPath() + QLatin1String(SHARE_PATH)); QSettings::setDefaultFormat(QSettings::IniFormat); QSettings *settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, QLatin1String(Core::Constants::TOTEM_SETTINGSVARIANT_STR), QLatin1String("Totem")); QSettings *globalSettings = new QSettings(QSettings::IniFormat, QSettings::SystemScope, QLatin1String(Core::Constants::TOTEM_SETTINGSVARIANT_STR), QLatin1String("Totem")); ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); pm->setFileExtension(QLatin1String(PLUGINSPEC_FILE_EXTENTION)); pm->setGlobalSettings(globalSettings); pm->setSettings(settings); QTranslator translator; QTranslator qtTranslator; QStringList uiLanguages; #if (QT_VERSION >= 0x040801) || (QT_VERSION >= 0x040800 && !defined(Q_OS_WIN)) uiLanguages = QLocale::system().uiLanguages(); #else uiLanguages << QLocale::system().name(); #endif // QString overrideLanguage = settings->value("General/OverrideLanguage").toString(); // if (!overrideLanguage.isEmpty()) // uiLanguages.prepend(overrideLanguage); const QString &totemTrPath = QCoreApplication::applicationDirPath() + QLatin1String(SHARE_PATH "/translations"); foreach (const QString &locale, uiLanguages) { if (translator.load(QLatin1String("totem_") + locale, totemTrPath)) { const QString &qtTrPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath); const QString &qtTrFile = QLatin1String("qt_") + locale; if (qtTranslator.load(qtTrFile, qtTrPath) || qtTranslator.load(qtTrFile, totemTrPath)) { receiver->app.installTranslator(&translator); receiver->app.installTranslator(&qtTranslator); receiver->app.setProperty("qtc_locale", locale); break; } translator.load(QString()); // unload() } else if (locale == QLatin1String("C") /* overrideLanguage == "English" */) { break; } else if (locale.startsWith(QLatin1String("en")) /* "English" is built-in */) { break; } } //这里没有考虑MacOS,Unix QNetworkProxyFactory::setUseSystemConfiguration(true); //设置插件搜索路径 const QStringList pluginPaths = getPluginPaths(); pm->setPluginPaths(pluginPaths); //检查核心插件 const PluginSpecSet plugins = pm->plugins(); ExtensionSystem::PluginSpec *coreplugin = 0; foreach(ExtensionSystem::PluginSpec *spec, plugins) { if(spec->name() == QLatin1String(corePluginNameC)) { coreplugin = spec; break; } } int status; if( status = checkPlugin(coreplugin, QLatin1String(corePluginNameC)))//如果核心插件检查有问题 { return status; } //载入皮肤 receiver->loadSkin(defaultQssFileC); QList<ExtensionSystem::PluginSpec *> queue = pm->loadQueue(); receiver->m_futureInterface->setProgressRange(0, queue.size()); QMetaObject::invokeMethod(receiver, "onStart", Qt::QueuedConnection); receiver->m_futureInterface->reportStarted(); foreach(ExtensionSystem::PluginSpec *spec, queue) { pm->loadPlugin(spec,ExtensionSystem::PluginSpec::Loaded); receiver->m_futureInterface->setProgressValue( receiver->m_futureInterface->progressValue() + 1); }
int main(int argc, char *argv[]) { QApplication app(argc, argv); #if QT_VERSION < 0x050000 // Removed in Qt5 QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); #endif app.setApplicationName(BINARY_NAME); app.setOrganizationName(BINARY_NAME); app.setApplicationVersion(PACKAGE_VERSION); QStringList args = qApp->arguments(); if (args.contains("--version") || args.contains("-version") || args.contains("-v")) { std::cout << qPrintable(VERSION_MESSAGE); return 0; } if (args.contains("--help") || args.contains("-help") || args.contains("-h")) { std::cout << qPrintable(HELP_MESSAGE); return 0; } // Create plugins manager ExtensionSystem::PluginManager pluginManager; pluginManager.setFileExtension(QString("pluginspec")); // Getting & feeding libraries/plugins path QStringList libpath; #ifdef LIBRARY_BASENAME libpath << Utils::applicationPluginsPath(QString(BINARY_NAME), QString(LIBRARY_BASENAME)); #else libpath << Utils::applicationPluginsPath(QString(BINARY_NAME), ""); #endif if (libpath.isEmpty()) return 123; pluginManager.setPluginPaths(libpath); // Add some debugging information Utils::Log::logCompilationConfiguration(); const PluginSpecSet plugins = pluginManager.plugins(); ExtensionSystem::PluginSpec *coreplugin = 0; if (WarnAllPluginSpecs) { foreach (ExtensionSystem::PluginSpec *spec, plugins) { qWarning() << "PluginSpecs :::"<< spec->filePath() << spec->name() << spec->version(); } } foreach (ExtensionSystem::PluginSpec *spec, plugins) { if (spec->name() == QString(COREPLUGINSNAME)) { coreplugin = spec; break; } } if (!coreplugin) { const QString reason = QCoreApplication::translate("Application", "Couldn't find 'Core.pluginspec' in %1").arg(qApp->libraryPaths().join("; ")); qWarning() << reason; return 1; } if (coreplugin->hasError()) { qWarning() << coreplugin->errorString(); return 1; } pluginManager.loadPlugins(); if (WarnAllPluginSpecs) { foreach (ExtensionSystem::PluginSpec *spec, plugins) { qWarning() << "PluginSpecs :::"<< spec->name() << "hasError:" << spec->hasError() << spec->errorString(); } } if (coreplugin->hasError()) { qWarning() << coreplugin->errorString(); return 1; } // shutdown plugin manager on the exit QObject::connect(&app, SIGNAL(aboutToQuit()), &pluginManager, SLOT(shutdown())); int r = app.exec(); // Utils::Log::saveLog(); return r; }
int main(int argc, char *argv[]) { QApplication app(argc, argv); #if QT_VERSION < 0x050000 // Removed in Qt5 QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); #endif app.setApplicationName(BINARY_NAME); app.setOrganizationName(BINARY_NAME); app.setApplicationVersion(PACKAGE_VERSION); QStringList args = qApp->arguments(); if (args.contains("--version") || args.contains("-version") || args.contains("-v")) { std::cout << qPrintable(VERSION_MESSAGE); return 0; } if (args.contains("--help") || args.contains("-help") || args.contains("-h")) { std::cout << qPrintable(HELP_MESSAGE); return 0; } // Create plugins manager ExtensionSystem::PluginManager pluginManager; pluginManager.setFileExtension(QString("pluginspec")); // Getting & feeding libraries/plugins path QStringList libpath; #ifdef LIBRARY_BASENAME libpath << Utils::applicationPluginsPath(QString(BINARY_NAME), QString(LIBRARY_BASENAME)); #else libpath << Utils::applicationPluginsPath(QString(BINARY_NAME), ""); #endif if (libpath.isEmpty()) return 123; pluginManager.setPluginPaths(libpath); // Add some debugging information Utils::Log::logCompilationConfiguration(); // Manage plugin manager options QStringList arguments = app.arguments(); // adapted arguments list is passed to plugin manager later QMap<QString, QString> foundAppOptions; if (arguments.size() > 1) { QMap<QString, bool> appOptions; QString errorMessage; if (!pluginManager.parseOptions(arguments, appOptions, &foundAppOptions, &errorMessage)) { // qWarning() << errorMessage; // qWarning() << HELP_MESSAGE; // return -1; } } const PluginSpecSet plugins = pluginManager.plugins(); ExtensionSystem::PluginSpec *coreplugin = 0; if (WarnAllPluginSpecs) { foreach (ExtensionSystem::PluginSpec *spec, plugins) { qWarning() << "PluginSpecs :::"<< spec->filePath() << spec->name() << spec->version(); } } foreach (ExtensionSystem::PluginSpec *spec, plugins) { if (spec->name() == QString(COREPLUGINSNAME)) { coreplugin = spec; break; } } ExtensionSystem::PluginSpec *userplugin = 0; foreach (ExtensionSystem::PluginSpec *spec, plugins) { if (spec->name() == QString(USERPLUGINSNAME)) { userplugin = spec; break; } } if (!coreplugin) { const QString reason = QCoreApplication::translate("Application", "Couldn't find 'Core.pluginspec' in %1").arg(qApp->libraryPaths().join("; ")); qWarning() << reason; // displayError(msgCoreLoadFailure(reason)); return 1; } if (!userplugin) { const QString reason = QCoreApplication::translate("Application", "Couldn't find 'UserManager.pluginspec' in %1").arg(qApp->libraryPaths().join("; ")); qWarning() << reason; // displayError(msgCoreLoadFailure(reason)); return 1; } if (coreplugin->hasError()) { qWarning() << coreplugin->errorString(); // displayError(msgCoreLoadFailure(coreplugin->errorString())); return 1; } if (userplugin->hasError()) { qWarning() << userplugin->errorString(); // displayError(msgCoreLoadFailure(coreplugin->errorString())); return 1; } // if (foundAppOptions.contains(QLatin1String(VERSION_OPTION))) { // printVersion(coreplugin, pluginManager); // 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); // return 0; // } // const bool isFirstInstance = !app.isRunning(); // if (!isFirstInstance && foundAppOptions.contains(QLatin1String(CLIENT_OPTION))) // return sendArguments(app, pluginManager.arguments()) ? 0 : -1; // foreach (ExtensionSystem::PluginSpec *spec, plugins) { // qWarning() << "PlugInSpec" << spec->name() << spec->errorString() << spec->state(); // } pluginManager.loadPlugins(); if (WarnAllPluginSpecs) { foreach (ExtensionSystem::PluginSpec *spec, plugins) { qWarning() << "PluginSpecs :::"<< spec->name() << "hasError:" << spec->hasError() << spec->errorString(); } } if (coreplugin->hasError()) { qWarning() << coreplugin->errorString(); return 1; } if (userplugin->hasError()) { qWarning() << userplugin->errorString(); // displayError(msgCoreLoadFailure(coreplugin->errorString())); return 1; } // if (isFirstInstance) { // // Set up lock and remote arguments for the first instance only. // // Silently fallback to unconnected instances for any subsequent // // instances. // app.initialize(); // QObject::connect(&app, SIGNAL(messageReceived(QString)), coreplugin->plugin(), SLOT(remoteArgument(QString))); // } // QObject::connect(&app, SIGNAL(fileOpenRequest(QString)), coreplugin->plugin(), SLOT(remoteArgument(QString))); // shutdown plugin manager on the exit QObject::connect(&app, SIGNAL(aboutToQuit()), &pluginManager, SLOT(shutdown())); #ifdef WITH_TESTS // Do this after the event loop has started if (pluginManager.runningTests()) QTimer::singleShot(100, &pluginManager, SLOT(startTests())); #endif int r = app.exec(); // Utils::Log::saveLog(); return r; }
TextEditorSettings::TextEditorSettings(QObject *parent) : QObject(parent) { QTC_ASSERT(!m_instance, return); m_instance = this; ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); // Note: default background colors are coming from FormatDescription::background() // Add font preference page FormatDescriptions formatDescriptions; formatDescriptions.push_back(FormatDescription(QLatin1String(C_TEXT), tr("Text"))); // Special categories const QPalette p = QApplication::palette(); formatDescriptions.push_back(FormatDescription(QLatin1String(C_LINK), tr("Link"), Qt::blue)); formatDescriptions.push_back(FormatDescription(QLatin1String(C_SELECTION), tr("Selection"), p.color(QPalette::HighlightedText))); formatDescriptions.push_back(FormatDescription(QLatin1String(C_LINE_NUMBER), tr("Line Number"))); formatDescriptions.push_back(FormatDescription(QLatin1String(C_SEARCH_RESULT), tr("Search Result"))); formatDescriptions.push_back(FormatDescription(QLatin1String(C_SEARCH_SCOPE), tr("Search Scope"))); formatDescriptions.push_back(FormatDescription(QLatin1String(C_PARENTHESES), tr("Parentheses"))); formatDescriptions.push_back(FormatDescription(QLatin1String(C_CURRENT_LINE), tr("Current Line"))); // Standard categories formatDescriptions.push_back(FormatDescription(QLatin1String(C_NUMBER), tr("Number"), Qt::darkBlue)); formatDescriptions.push_back(FormatDescription(QLatin1String(C_STRING), tr("String"), Qt::darkGreen)); formatDescriptions.push_back(FormatDescription(QLatin1String(C_TYPE), tr("Type"), Qt::darkMagenta)); formatDescriptions.push_back(FormatDescription(QLatin1String(C_KEYWORD), tr("Keyword"), Qt::darkYellow)); formatDescriptions.push_back(FormatDescription(QLatin1String(C_OPERATOR), tr("Operator"))); formatDescriptions.push_back(FormatDescription(QLatin1String(C_PREPROCESSOR), tr("Preprocessor"), Qt::darkBlue)); formatDescriptions.push_back(FormatDescription(QLatin1String(C_LABEL), tr("Label"), Qt::darkRed)); formatDescriptions.push_back(FormatDescription(QLatin1String(C_COMMENT), tr("Comment"), Qt::darkGreen)); formatDescriptions.push_back(FormatDescription(QLatin1String(C_DOXYGEN_COMMENT), tr("Doxygen Comment"), Qt::darkBlue)); formatDescriptions.push_back(FormatDescription(QLatin1String(C_DOXYGEN_TAG), tr("Doxygen Tag"), Qt::blue)); formatDescriptions.push_back(FormatDescription(QLatin1String(C_DISABLED_CODE), tr("Disabled Code"), Qt::gray)); // Diff categories formatDescriptions.push_back(FormatDescription(QLatin1String(C_ADDED_LINE), tr("Added Line"), QColor(0, 170, 0))); formatDescriptions.push_back(FormatDescription(QLatin1String(C_REMOVED_LINE), tr("Removed Line"), Qt::red)); formatDescriptions.push_back(FormatDescription(QLatin1String(C_DIFF_FILE), tr("Diff File"), Qt::darkBlue)); formatDescriptions.push_back(FormatDescription(QLatin1String(C_DIFF_LOCATION), tr("Diff Location"), Qt::blue)); m_fontSettingsPage = new FontSettingsPage(formatDescriptions, QLatin1String("TextEditor"), tr("Text Editor"), this); pm->addObject(m_fontSettingsPage); // Add the GUI used to configure the tab, storage and interaction settings TextEditor::BehaviorSettingsPageParameters behaviorSettingsPageParameters; behaviorSettingsPageParameters.name = tr("Behavior"); behaviorSettingsPageParameters.category = QLatin1String("TextEditor"); behaviorSettingsPageParameters.trCategory = tr("Text Editor"); behaviorSettingsPageParameters.settingsPrefix = QLatin1String("text"); m_behaviorSettingsPage = new BehaviorSettingsPage(behaviorSettingsPageParameters, this); pm->addObject(m_behaviorSettingsPage); TextEditor::DisplaySettingsPageParameters displaySettingsPageParameters; displaySettingsPageParameters.name = tr("Display"); displaySettingsPageParameters.category = QLatin1String("TextEditor"); displaySettingsPageParameters.trCategory = tr("Text Editor"); displaySettingsPageParameters.settingsPrefix = QLatin1String("text"); m_displaySettingsPage = new DisplaySettingsPage(displaySettingsPageParameters, this); pm->addObject(m_displaySettingsPage); connect(m_fontSettingsPage, SIGNAL(changed(TextEditor::FontSettings)), this, SIGNAL(fontSettingsChanged(TextEditor::FontSettings))); connect(m_behaviorSettingsPage, SIGNAL(tabSettingsChanged(TextEditor::TabSettings)), this, SIGNAL(tabSettingsChanged(TextEditor::TabSettings))); connect(m_behaviorSettingsPage, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings)), this, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings))); connect(m_displaySettingsPage, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)), this, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings))); }
static QString settingsFileName(const QString &path) { ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); QFileInfo settingsLocation(pm->settings()->fileName()); return settingsLocation.absolutePath() + path; }
int main(int argc, char *argv[]) { QApplication app(argc, argv); #if QT_VERSION < 0x050000 // Removed in Qt5 QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); #endif app.setApplicationName(BINARY_NAME); app.setOrganizationName(BINARY_NAME); app.setApplicationVersion(PACKAGE_VERSION); QStringList args = qApp->arguments(); if (args.contains("--version") || args.contains("-version") || args.contains("-v")) { std::cout << qPrintable(VERSION_MESSAGE); return 0; } if (args.contains("--help") || args.contains("-help") || args.contains("-h")) { std::cout << qPrintable(HELP_MESSAGE); return 0; } // Create plugins manager ExtensionSystem::PluginManager pluginManager; pluginManager.setFileExtension(QString("pluginspec")); // Getting & feeding libraries/plugins path QStringList libpath; #ifdef LIBRARY_BASENAME libpath << Utils::applicationPluginsPath(QString(BINARY_NAME), QString(LIBRARY_BASENAME)); #else libpath << Utils::applicationPluginsPath(QString(BINARY_NAME), ""); #endif if (libpath.isEmpty()) return 123; pluginManager.setPluginPaths(libpath); // Add some debugging information Utils::Log::logCompilationConfiguration(); // Manage plugin manager options QStringList arguments = app.arguments(); // adapted arguments list is passed to plugin manager later QMap<QString, QString> foundAppOptions; if (arguments.size() > 1) { QMap<QString, bool> appOptions; QString errorMessage; if (!pluginManager.parseOptions(arguments, appOptions, &foundAppOptions, &errorMessage)) { qWarning() << errorMessage; qWarning() << HELP_MESSAGE; return -1; } } const PluginSpecSet plugins = pluginManager.plugins(); ExtensionSystem::PluginSpec *coreplugin = 0; if (WarnAllPluginSpecs) { foreach (ExtensionSystem::PluginSpec *spec, plugins) { qWarning() << "PluginSpecs :::"<< spec->filePath() << spec->name() << spec->version(); } } foreach (ExtensionSystem::PluginSpec *spec, plugins) { if (spec->name() == QString(COREPLUGINSNAME)) { coreplugin = spec; break; } } // ExtensionSystem::PluginSpec *userplugin = 0; // foreach (ExtensionSystem::PluginSpec *spec, plugins) { // if (spec->name() == QString(USERPLUGINSNAME)) { // userplugin = spec; // break; // } // } if (!coreplugin) { const QString reason = QCoreApplication::translate("Application", "Couldn't find 'Core.pluginspec' in %1").arg(qApp->libraryPaths().join("; ")); qWarning() << reason; return 1; } // if (!userplugin) { // const QString reason = QCoreApplication::translate("Application", "Couldn't find 'UserManager.pluginspec' in %1").arg(qApp->libraryPaths().join("; ")); // qWarning() << reason; // return 1; // } if (coreplugin->hasError()) { qWarning() << coreplugin->errorString(); return 1; } // if (userplugin->hasError()) { // qWarning() << userplugin->errorString(); // return 1; // } pluginManager.loadPlugins(); if (WarnAllPluginSpecs) { foreach (ExtensionSystem::PluginSpec *spec, plugins) { qWarning() << "PluginSpecs :::"<< spec->name() << "hasError:" << spec->hasError() << spec->errorString(); } } if (coreplugin->hasError()) { qWarning() << coreplugin->errorString(); return 1; } // if (userplugin->hasError()) { // qWarning() << userplugin->errorString(); // return 1; // } // shutdown plugin manager on the exit QObject::connect(&app, SIGNAL(aboutToQuit()), &pluginManager, SLOT(shutdown())); #ifdef WITH_TESTS // Do this after the event loop has started if (pluginManager.runningTests()) QTimer::singleShot(100, &pluginManager, SLOT(startTests())); #endif int r = app.exec(); // Utils::Log::saveLog(); return r; }