2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-03-25 09:25:17 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2011-03-25 09:25:17 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-03-25 09:25:17 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2011-03-25 09:25:17 +01:00
|
|
|
**
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2011-03-25 09:25:17 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-03-25 09:25:17 +01:00
|
|
|
|
2011-03-11 12:22:57 +01:00
|
|
|
#include "qmlprofilerplugin.h"
|
2013-07-19 16:08:54 +02:00
|
|
|
#include "qmlprofilerruncontrolfactory.h"
|
2011-03-11 12:22:57 +01:00
|
|
|
|
2011-06-30 13:44:22 +02:00
|
|
|
#include "qmlprofilertool.h"
|
2014-10-28 19:01:43 +01:00
|
|
|
#include "qmlprofilertimelinemodel.h"
|
2011-03-11 12:22:57 +01:00
|
|
|
|
|
|
|
#include <analyzerbase/analyzermanager.h>
|
2013-08-08 13:28:08 +02:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2011-03-11 12:22:57 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QtPlugin>
|
2011-03-11 12:22:57 +01:00
|
|
|
|
|
|
|
using namespace Analyzer;
|
2013-08-07 19:47:30 +02:00
|
|
|
|
|
|
|
namespace QmlProfiler {
|
|
|
|
namespace Internal {
|
|
|
|
|
2011-03-11 12:22:57 +01:00
|
|
|
bool QmlProfilerPlugin::debugOutput = false;
|
2013-08-08 13:28:08 +02:00
|
|
|
QmlProfilerPlugin *QmlProfilerPlugin::instance = 0;
|
2011-03-11 12:22:57 +01:00
|
|
|
|
|
|
|
bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorString)
|
|
|
|
{
|
2011-06-30 13:44:22 +02:00
|
|
|
Q_UNUSED(arguments)
|
|
|
|
Q_UNUSED(errorString)
|
2011-12-27 22:41:31 +01:00
|
|
|
|
2015-02-18 14:35:20 +01:00
|
|
|
auto tool = new QmlProfilerTool(this);
|
|
|
|
auto toolStarter = [tool](StartMode mode) { return tool->startTool(mode); };
|
|
|
|
auto widgetCreator = [tool] { return tool->createWidgets(); };
|
|
|
|
auto runControlCreator = [tool](const AnalyzerStartParameters &sp,
|
|
|
|
ProjectExplorer::RunConfiguration *runConfiguration) {
|
|
|
|
return tool->createRunControl(sp, runConfiguration);
|
|
|
|
};
|
2013-08-07 19:47:30 +02:00
|
|
|
|
2015-02-18 09:38:13 +01:00
|
|
|
AnalyzerAction *action = 0;
|
2013-08-07 19:47:30 +02:00
|
|
|
|
|
|
|
QString description = QmlProfilerTool::tr(
|
|
|
|
"The QML Profiler can be used to find performance bottlenecks in "
|
|
|
|
"applications using QML.");
|
|
|
|
|
2015-02-18 09:38:13 +01:00
|
|
|
action = new AnalyzerAction(this);
|
2015-02-18 14:35:20 +01:00
|
|
|
action->setActionId("QmlProfiler.Local");
|
|
|
|
action->setToolId(QmlProfilerToolId);
|
|
|
|
action->setWidgetCreator(widgetCreator);
|
|
|
|
action->setRunControlCreator(runControlCreator);
|
|
|
|
action->setToolStarter(toolStarter);
|
2015-02-18 11:05:22 +01:00
|
|
|
action->setRunMode(ProjectExplorer::QmlProfilerRunMode);
|
2013-08-07 19:47:30 +02:00
|
|
|
action->setText(tr("QML Profiler"));
|
|
|
|
action->setToolTip(description);
|
|
|
|
action->setStartMode(StartLocal);
|
|
|
|
action->setMenuGroup(Constants::G_ANALYZER_TOOLS);
|
|
|
|
AnalyzerManager::addAction(action);
|
|
|
|
|
2015-02-18 09:38:13 +01:00
|
|
|
action = new AnalyzerAction(this);
|
2015-02-18 14:35:20 +01:00
|
|
|
action->setActionId("QmlProfiler.Remote");
|
|
|
|
action->setToolId(QmlProfilerToolId);
|
|
|
|
action->setWidgetCreator(widgetCreator);
|
|
|
|
action->setRunControlCreator(runControlCreator);
|
|
|
|
action->setToolStarter(toolStarter);
|
2015-02-18 11:05:22 +01:00
|
|
|
action->setRunMode(ProjectExplorer::QmlProfilerRunMode);
|
2013-08-07 19:47:30 +02:00
|
|
|
action->setText(tr("QML Profiler (External)"));
|
|
|
|
action->setToolTip(description);
|
|
|
|
action->setStartMode(StartRemote);
|
|
|
|
action->setMenuGroup(Constants::G_ANALYZER_REMOTE_TOOLS);
|
|
|
|
AnalyzerManager::addAction(action);
|
2011-12-27 22:41:31 +01:00
|
|
|
|
2013-07-19 16:08:54 +02:00
|
|
|
addAutoReleasedObject(new QmlProfilerRunControlFactory());
|
2013-08-08 13:28:08 +02:00
|
|
|
QmlProfilerPlugin::instance = this;
|
2013-07-19 16:08:54 +02:00
|
|
|
|
2011-03-11 12:22:57 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QmlProfilerPlugin::extensionsInitialized()
|
|
|
|
{
|
2014-10-28 17:37:11 +01:00
|
|
|
factory = ExtensionSystem::PluginManager::getObject<QmlProfilerTimelineModelFactory>();
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ExtensionSystem::IPlugin::ShutdownFlag QmlProfilerPlugin::aboutToShutdown()
|
|
|
|
{
|
2011-06-30 13:44:22 +02:00
|
|
|
// Save settings.
|
2011-03-11 12:22:57 +01:00
|
|
|
// Disconnect from signals that are not needed during shutdown
|
|
|
|
// Hide UI (if you add UI that is not in the main window directly)
|
|
|
|
return SynchronousShutdown;
|
|
|
|
}
|
|
|
|
|
2014-10-28 19:01:43 +01:00
|
|
|
QList<QmlProfilerTimelineModel *> QmlProfilerPlugin::getModels(QmlProfilerModelManager *manager) const
|
2013-08-08 13:28:08 +02:00
|
|
|
{
|
2014-11-27 10:36:58 +01:00
|
|
|
if (factory)
|
|
|
|
return factory->create(manager);
|
|
|
|
else
|
|
|
|
return QList<QmlProfilerTimelineModel *>();
|
2013-08-08 13:28:08 +02:00
|
|
|
}
|
|
|
|
|
2013-08-07 19:47:30 +02:00
|
|
|
} // namespace Internal
|
|
|
|
} // namespace QmlProfiler
|