2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-03-25 09:25:17 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://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
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2011-03-25 09:25:17 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2011-03-25 09:25:17 +01:00
|
|
|
**
|
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"
|
2015-08-28 12:50:46 +02:00
|
|
|
#include "qmlprofileroptionspage.h"
|
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>
|
2015-09-29 16:43:42 +02:00
|
|
|
#include <utils/hostosinfo.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 {
|
|
|
|
|
|
2015-08-28 12:50:46 +02:00
|
|
|
Q_GLOBAL_STATIC(QmlProfilerSettings, qmlProfilerGlobalSettings)
|
|
|
|
|
|
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)
|
2015-09-25 13:14:31 +02:00
|
|
|
|
2015-09-29 16:43:42 +02:00
|
|
|
if (!Utils::HostOsInfo::canCreateOpenGLContext(errorString))
|
2015-09-25 13:14:31 +02:00
|
|
|
return false;
|
2011-12-27 22:41:31 +01:00
|
|
|
|
2015-02-18 14:35:20 +01:00
|
|
|
auto tool = new QmlProfilerTool(this);
|
|
|
|
|
auto widgetCreator = [tool] { return tool->createWidgets(); };
|
|
|
|
|
auto runControlCreator = [tool](const AnalyzerStartParameters &sp,
|
2016-01-06 11:40:52 +01:00
|
|
|
ProjectExplorer::RunConfiguration *runConfiguration, Core::Id) {
|
2015-02-18 14:35:20 +01:00
|
|
|
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-12-10 16:49:47 +01:00
|
|
|
action->setActionId(Constants::QmlProfilerLocalActionId);
|
|
|
|
|
action->setToolId(Constants::QmlProfilerToolId);
|
2015-02-18 14:35:20 +01:00
|
|
|
action->setWidgetCreator(widgetCreator);
|
|
|
|
|
action->setRunControlCreator(runControlCreator);
|
2015-06-18 16:26:58 +02:00
|
|
|
action->setToolPreparer([tool] { return tool->prepareTool(); });
|
2015-06-29 10:36:29 +03:00
|
|
|
action->setRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
2013-08-07 19:47:30 +02:00
|
|
|
action->setText(tr("QML Profiler"));
|
|
|
|
|
action->setToolTip(description);
|
2015-12-10 16:49:47 +01:00
|
|
|
action->setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS);
|
2013-08-07 19:47:30 +02:00
|
|
|
AnalyzerManager::addAction(action);
|
|
|
|
|
|
2015-02-18 09:38:13 +01:00
|
|
|
action = new AnalyzerAction(this);
|
2015-12-10 16:49:47 +01:00
|
|
|
action->setActionId(Constants::QmlProfilerRemoteActionId);
|
|
|
|
|
action->setToolId(Constants::QmlProfilerToolId);
|
2015-02-18 14:35:20 +01:00
|
|
|
action->setWidgetCreator(widgetCreator);
|
|
|
|
|
action->setRunControlCreator(runControlCreator);
|
2015-06-18 16:50:42 +02:00
|
|
|
action->setCustomToolStarter([tool] { tool->startRemoteTool(); });
|
2015-06-18 16:26:58 +02:00
|
|
|
action->setToolPreparer([tool] { return tool->prepareTool(); });
|
2015-06-29 10:36:29 +03:00
|
|
|
action->setRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
2013-08-07 19:47:30 +02:00
|
|
|
action->setText(tr("QML Profiler (External)"));
|
|
|
|
|
action->setToolTip(description);
|
2015-12-10 16:49:47 +01:00
|
|
|
action->setMenuGroup(Analyzer::Constants::G_ANALYZER_REMOTE_TOOLS);
|
2013-08-07 19:47:30 +02:00
|
|
|
AnalyzerManager::addAction(action);
|
2011-12-27 22:41:31 +01:00
|
|
|
|
2013-07-19 16:08:54 +02:00
|
|
|
addAutoReleasedObject(new QmlProfilerRunControlFactory());
|
2015-08-28 12:50:46 +02:00
|
|
|
addAutoReleasedObject(new Internal::QmlProfilerOptionsPage());
|
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
|
|
|
}
|
|
|
|
|
|
2015-08-28 12:50:46 +02:00
|
|
|
QmlProfilerSettings *QmlProfilerPlugin::globalSettings()
|
|
|
|
|
{
|
|
|
|
|
return qmlProfilerGlobalSettings();
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-07 19:47:30 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QmlProfiler
|