1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Author: Nicolas Arnaud-Cormos, KDAB (nicolas.arnaud-cormos@kdab.com)
9 ** Contact: Nokia Corporation (info@qt.nokia.com)
12 ** GNU Lesser General Public License Usage
14 ** This file may be used under the terms of the GNU Lesser General Public
15 ** License version 2.1 as published by the Free Software Foundation and
16 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
17 ** Please review the following information to ensure the GNU Lesser General
18 ** Public License version 2.1 requirements will be met:
19 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
21 ** In addition, as a special exception, Nokia gives you certain additional
22 ** rights. These rights are described in the Nokia Qt LGPL Exception
23 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27 ** Alternatively, this file may be used in accordance with the terms and
28 ** conditions contained in a signed written agreement between you and Nokia.
30 ** If you have questions regarding the use of this file, please contact
31 ** Nokia at qt-info@nokia.com.
33 **************************************************************************/
35 #include "analyzerplugin.h"
36 #include "analyzerconstants.h"
37 #include "analyzermanager.h"
38 #include "analyzeroutputpane.h"
40 #include <coreplugin/imode.h>
41 #include <coreplugin/coreconstants.h>
42 #include <coreplugin/editormanager/editormanager.h>
44 #include <extensionsystem/pluginmanager.h>
45 #include <projectexplorer/task.h>
46 #include <projectexplorer/taskhub.h>
48 #include <QtCore/QtPlugin>
49 #include <QtGui/QMessageBox>
50 #include <QtGui/QMainWindow>
51 #include <QtGui/QApplication>
53 using namespace Analyzer;
54 using namespace Analyzer::Internal;
57 AnalyzerPlugin *AnalyzerPlugin::m_instance = 0;
60 // AnalyzerPluginPrivate ////////////////////////////////////////////////////
61 class AnalyzerPlugin::AnalyzerPluginPrivate
64 AnalyzerPluginPrivate(AnalyzerPlugin *qq):
69 void initialize(const QStringList &arguments, QString *errorString);
72 AnalyzerManager *m_manager;
75 void AnalyzerPlugin::AnalyzerPluginPrivate::initialize(const QStringList &arguments, QString *errorString)
79 AnalyzerOutputPane *outputPane = new AnalyzerOutputPane;
80 q->addAutoReleasedObject(outputPane);
81 m_manager = new AnalyzerManager(outputPane, q);
85 // AnalyzerPlugin ////////////////////////////////////////////////////
86 AnalyzerPlugin::AnalyzerPlugin()
87 : d(new AnalyzerPluginPrivate(this))
92 AnalyzerPlugin::~AnalyzerPlugin()
94 // Unregister objects from the plugin manager's object pool
100 bool AnalyzerPlugin::initialize(const QStringList &arguments, QString *errorString)
102 // Register objects in the plugin manager's object pool
104 // connect to other plugins' signals
105 // "In the initialize method, a plugin can be sure that the plugins it
106 // depends on have initialized their members."
109 Q_UNUSED(errorString)
111 d->initialize(arguments, errorString);
114 ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
115 ProjectExplorer::TaskHub *hub = pm->getObject<ProjectExplorer::TaskHub>();
116 //: Category under which Analyzer tasks are listed in build issues view
117 hub->addCategory(QLatin1String(Constants::ANALYZERTASK_ID), tr("Analyzer"));
119 ///TODO: select last used tool or default tool
120 // d->m_manager->selectTool(memcheckTool);
125 void AnalyzerPlugin::extensionsInitialized()
127 // Retrieve objects from the plugin manager's object pool
128 // "In the extensionsInitialized method, a plugin can be sure that all
129 // plugins that depend on it are completely initialized."
132 ExtensionSystem::IPlugin::ShutdownFlag AnalyzerPlugin::aboutToShutdown()
134 d->m_manager->shutdown();
136 // Disconnect from signals that are not needed during shutdown
137 // Hide UI (if you add UI that is not in the main window directly)
138 return SynchronousShutdown;
141 AnalyzerPlugin *AnalyzerPlugin::instance()
146 Q_EXPORT_PLUGIN(AnalyzerPlugin)