2011-03-25 09:25:17 +01:00
|
|
|
/**************************************************************************
|
|
|
|
**
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
**
|
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
|
**
|
2011-05-06 15:05:37 +02:00
|
|
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
2011-03-25 09:25:17 +01:00
|
|
|
**
|
|
|
|
** No Commercial Usage
|
|
|
|
**
|
|
|
|
** This file contains pre-release code and may not be distributed.
|
|
|
|
** You may use this file in accordance with the terms and conditions
|
|
|
|
** contained in the Technology Preview License Agreement accompanying
|
|
|
|
** this package.
|
|
|
|
**
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
**
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
**
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-05-06 15:05:37 +02:00
|
|
|
** Nokia at info@qt.nokia.com.
|
2011-03-25 09:25:17 +01:00
|
|
|
**
|
|
|
|
**************************************************************************/
|
|
|
|
|
2011-03-11 12:22:57 +01:00
|
|
|
#include "qmlprofilertool.h"
|
|
|
|
#include "qmlprofilerengine.h"
|
|
|
|
#include "qmlprofilerplugin.h"
|
2011-04-04 15:03:31 +02:00
|
|
|
#include "qmlprofilerconstants.h"
|
|
|
|
#include "qmlprofilerattachdialog.h"
|
2011-05-20 09:12:34 +02:00
|
|
|
#include "qmlprofilersummaryview.h"
|
2011-03-11 12:22:57 +01:00
|
|
|
|
|
|
|
#include "tracewindow.h"
|
2011-05-20 09:12:34 +02:00
|
|
|
#include "timelineview.h"
|
|
|
|
|
2011-04-14 15:49:12 +02:00
|
|
|
#include <qmljsdebugclient/qdeclarativedebugclient_p.h>
|
2011-03-11 12:22:57 +01:00
|
|
|
|
|
|
|
#include <analyzerbase/analyzermanager.h>
|
|
|
|
#include <analyzerbase/analyzerconstants.h>
|
|
|
|
|
|
|
|
#include "canvas/qdeclarativecanvas_p.h"
|
|
|
|
#include "canvas/qdeclarativecontext2d_p.h"
|
|
|
|
#include "canvas/qdeclarativetiledcanvas_p.h"
|
|
|
|
|
|
|
|
#include <qmlprojectmanager/qmlprojectrunconfiguration.h>
|
2011-05-20 12:43:29 +02:00
|
|
|
#include <utils/fancymainwindow.h>
|
2011-03-11 12:22:57 +01:00
|
|
|
#include <utils/fileinprojectfinder.h>
|
2011-04-14 17:19:28 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2011-03-11 12:22:57 +01:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
|
|
|
#include <projectexplorer/project.h>
|
2011-04-01 13:48:10 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2011-03-11 12:22:57 +01:00
|
|
|
|
|
|
|
#include <texteditor/itexteditor.h>
|
2011-04-04 15:03:31 +02:00
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
|
|
|
#include <coreplugin/coreconstants.h>
|
2011-03-11 12:22:57 +01:00
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
2011-04-04 15:03:31 +02:00
|
|
|
#include <coreplugin/icore.h>
|
2011-03-11 12:22:57 +01:00
|
|
|
|
|
|
|
#include <QtCore/QFile>
|
|
|
|
|
2011-03-24 12:42:15 +01:00
|
|
|
#include <QtGui/QHBoxLayout>
|
|
|
|
#include <QtGui/QLabel>
|
2011-04-08 13:05:39 +02:00
|
|
|
#include <QtGui/QTabWidget>
|
2011-05-20 09:12:34 +02:00
|
|
|
#include <QtGui/QToolButton>
|
2011-04-08 13:05:39 +02:00
|
|
|
|
2011-03-11 12:22:57 +01:00
|
|
|
using namespace Analyzer;
|
2011-03-25 09:21:00 +01:00
|
|
|
using namespace QmlProfiler::Internal;
|
2011-03-11 12:22:57 +01:00
|
|
|
|
|
|
|
class QmlProfilerTool::QmlProfilerToolPrivate
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
QmlProfilerToolPrivate(QmlProfilerTool *qq) : q(qq) {}
|
|
|
|
~QmlProfilerToolPrivate() {}
|
|
|
|
|
|
|
|
QmlProfilerTool *q;
|
|
|
|
|
|
|
|
QDeclarativeDebugConnection *m_client;
|
2011-04-12 17:24:56 +02:00
|
|
|
QTimer m_connectionTimer;
|
|
|
|
int m_connectionAttempts;
|
2011-03-11 12:22:57 +01:00
|
|
|
TraceWindow *m_traceWindow;
|
2011-04-08 13:05:39 +02:00
|
|
|
QmlProfilerSummaryView *m_summary;
|
2011-04-01 13:48:10 +02:00
|
|
|
ProjectExplorer::Project *m_project;
|
|
|
|
Utils::FileInProjectFinder m_projectFinder;
|
2011-04-04 15:03:31 +02:00
|
|
|
ProjectExplorer::RunConfiguration *m_runConfiguration;
|
|
|
|
bool m_isAttached;
|
|
|
|
QAction *m_attachAction;
|
2011-04-06 12:26:19 +02:00
|
|
|
QToolButton *m_recordButton;
|
2011-04-14 15:23:17 +02:00
|
|
|
bool m_recordingEnabled;
|
2011-04-14 15:44:43 +02:00
|
|
|
QString m_host;
|
|
|
|
quint64 m_port;
|
2011-03-11 12:22:57 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
QmlProfilerTool::QmlProfilerTool(QObject *parent)
|
|
|
|
: IAnalyzerTool(parent), d(new QmlProfilerToolPrivate(this))
|
|
|
|
{
|
2011-05-20 13:36:16 +02:00
|
|
|
d->m_client = 0;
|
|
|
|
d->m_connectionAttempts = 0;
|
|
|
|
d->m_traceWindow = 0;
|
|
|
|
d->m_project = 0;
|
|
|
|
d->m_runConfiguration = 0;
|
|
|
|
d->m_isAttached = false;
|
|
|
|
d->m_attachAction = 0;
|
|
|
|
d->m_recordingEnabled = true;
|
|
|
|
|
|
|
|
d->m_connectionTimer.setInterval(200);
|
|
|
|
connect(&d->m_connectionTimer, SIGNAL(timeout()), SLOT(tryToConnect()));
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QmlProfilerTool::~QmlProfilerTool()
|
|
|
|
{
|
2011-05-20 12:43:29 +02:00
|
|
|
delete d->m_client;
|
2011-03-11 12:22:57 +01:00
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString QmlProfilerTool::id() const
|
|
|
|
{
|
|
|
|
return "QmlProfiler";
|
|
|
|
}
|
|
|
|
|
|
|
|
QString QmlProfilerTool::displayName() const
|
|
|
|
{
|
2011-04-26 14:08:09 +02:00
|
|
|
return tr("QML Performance Monitor");
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
IAnalyzerTool::ToolMode QmlProfilerTool::mode() const
|
|
|
|
{
|
2011-05-03 16:44:41 +02:00
|
|
|
return AnyMode;
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
2011-04-04 14:39:28 +02:00
|
|
|
IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp,
|
|
|
|
ProjectExplorer::RunConfiguration *runConfiguration)
|
2011-03-11 12:22:57 +01:00
|
|
|
{
|
2011-04-04 14:39:28 +02:00
|
|
|
QmlProfilerEngine *engine = new QmlProfilerEngine(sp, runConfiguration);
|
2011-03-11 12:22:57 +01:00
|
|
|
|
2011-04-14 15:44:43 +02:00
|
|
|
d->m_host = sp.connParams.host;
|
|
|
|
d->m_port = sp.connParams.port;
|
|
|
|
|
2011-04-04 15:03:31 +02:00
|
|
|
d->m_runConfiguration = runConfiguration;
|
2011-04-01 13:48:10 +02:00
|
|
|
d->m_project = runConfiguration->target()->project();
|
|
|
|
if (d->m_project) {
|
|
|
|
d->m_projectFinder.setProjectDirectory(d->m_project->projectDirectory());
|
|
|
|
updateProjectFileList();
|
|
|
|
connect(d->m_project, SIGNAL(fileListChanged()), this, SLOT(updateProjectFileList()));
|
|
|
|
}
|
|
|
|
|
2011-03-11 12:22:57 +01:00
|
|
|
connect(engine, SIGNAL(processRunning()), this, SLOT(connectClient()));
|
2011-04-06 12:26:19 +02:00
|
|
|
connect(engine, SIGNAL(finished()), this, SLOT(disconnectClient()));
|
2011-03-11 12:22:57 +01:00
|
|
|
connect(engine, SIGNAL(stopRecording()), this, SLOT(stopRecording()));
|
2011-04-14 16:05:41 +02:00
|
|
|
connect(d->m_traceWindow, SIGNAL(viewUpdated()), engine, SLOT(dataReceived()));
|
2011-04-14 15:23:17 +02:00
|
|
|
connect(this, SIGNAL(connectionFailed()), engine, SLOT(finishProcess()));
|
2011-04-06 12:26:19 +02:00
|
|
|
connect(this, SIGNAL(fetchingData(bool)), engine, SLOT(setFetchingData(bool)));
|
|
|
|
emit fetchingData(d->m_recordButton->isChecked());
|
2011-03-11 12:22:57 +01:00
|
|
|
|
|
|
|
return engine;
|
|
|
|
}
|
|
|
|
|
2011-05-18 15:56:01 +02:00
|
|
|
void QmlProfilerTool::initialize()
|
2011-03-11 12:22:57 +01:00
|
|
|
{
|
2011-04-01 13:49:36 +02:00
|
|
|
qmlRegisterType<Canvas>("Monitor", 1, 0, "Canvas");
|
2011-03-25 09:26:55 +01:00
|
|
|
qmlRegisterType<TiledCanvas>("Monitor", 1, 0, "TiledCanvas");
|
2011-03-11 12:22:57 +01:00
|
|
|
qmlRegisterType<Context2D>();
|
|
|
|
qmlRegisterType<CanvasImage>();
|
|
|
|
qmlRegisterType<CanvasGradient>();
|
2011-03-25 09:26:55 +01:00
|
|
|
qmlRegisterType<TimelineView>("Monitor", 1, 0,"TimelineView");
|
2011-05-20 12:43:29 +02:00
|
|
|
}
|
2011-03-11 12:22:57 +01:00
|
|
|
|
2011-05-20 12:43:29 +02:00
|
|
|
void QmlProfilerTool::extensionsInitialized()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void QmlProfilerTool::initializeDockWidgets()
|
|
|
|
{
|
|
|
|
Analyzer::AnalyzerManager *analyzerMgr = Analyzer::AnalyzerManager::instance();
|
2011-05-20 18:47:28 +02:00
|
|
|
Utils::FancyMainWindow *mw = analyzerMgr->mainWindow();
|
2011-04-08 13:05:39 +02:00
|
|
|
|
2011-05-20 12:43:29 +02:00
|
|
|
d->m_traceWindow = new TraceWindow(mw);
|
2011-03-11 12:22:57 +01:00
|
|
|
d->m_traceWindow->reset(d->m_client);
|
2011-04-04 15:03:31 +02:00
|
|
|
|
2011-05-20 12:43:29 +02:00
|
|
|
connect(d->m_traceWindow, SIGNAL(gotoSourceLocation(QString,int)),this, SLOT(gotoSourceLocation(QString,int)));
|
2011-04-04 15:03:31 +02:00
|
|
|
connect(d->m_traceWindow, SIGNAL(timeChanged(qreal)), this, SLOT(updateTimer(qreal)));
|
|
|
|
|
2011-05-20 12:43:29 +02:00
|
|
|
d->m_summary = new QmlProfilerSummaryView(mw);
|
2011-04-08 13:05:39 +02:00
|
|
|
|
2011-05-20 12:43:29 +02:00
|
|
|
connect(d->m_traceWindow, SIGNAL(range(int,qint64,qint64,QStringList,QString,int)),
|
|
|
|
d->m_summary, SLOT(addRangedEvent(int,qint64,qint64,QStringList,QString,int)));
|
|
|
|
connect(d->m_traceWindow, SIGNAL(viewUpdated()),
|
|
|
|
d->m_summary, SLOT(complete()));
|
|
|
|
connect(d->m_summary, SIGNAL(gotoSourceLocation(QString,int)),
|
|
|
|
this, SLOT(gotoSourceLocation(QString,int)));
|
2011-04-08 13:05:39 +02:00
|
|
|
|
2011-04-04 15:03:31 +02:00
|
|
|
Core::ICore *core = Core::ICore::instance();
|
|
|
|
Core::ActionManager *am = core->actionManager();
|
|
|
|
Core::ActionContainer *manalyzer = am->actionContainer(Analyzer::Constants::M_DEBUG_ANALYZER);
|
|
|
|
const Core::Context globalcontext(Core::Constants::C_GLOBAL);
|
|
|
|
|
2011-04-14 20:32:13 +02:00
|
|
|
d->m_attachAction = new QAction(tr("Attach..."), manalyzer);
|
2011-04-04 15:03:31 +02:00
|
|
|
Core::Command *command = am->registerAction(d->m_attachAction,
|
|
|
|
Constants::ATTACH, globalcontext);
|
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
|
|
|
manalyzer->addAction(command, Analyzer::Constants::G_ANALYZER_STARTSTOP);
|
|
|
|
connect(d->m_attachAction, SIGNAL(triggered()), this, SLOT(attach()));
|
2011-04-04 15:56:34 +02:00
|
|
|
|
|
|
|
connect(analyzerMgr, SIGNAL(currentToolChanged(Analyzer::IAnalyzerTool*)),
|
|
|
|
this, SLOT(updateAttachAction()));
|
|
|
|
|
2011-04-04 15:03:31 +02:00
|
|
|
updateAttachAction();
|
2011-03-11 12:22:57 +01:00
|
|
|
|
2011-05-20 12:43:29 +02:00
|
|
|
QDockWidget *summaryDock =
|
|
|
|
analyzerMgr->createDockWidget(this, tr("Summary"),
|
|
|
|
d->m_summary, Qt::BottomDockWidgetArea);
|
2011-04-04 14:39:28 +02:00
|
|
|
|
2011-05-20 12:43:29 +02:00
|
|
|
QDockWidget *timelineDock =
|
|
|
|
analyzerMgr->createDockWidget(this, tr("Timeline"),
|
|
|
|
d->m_traceWindow, Qt::BottomDockWidgetArea);
|
|
|
|
|
2011-05-20 18:47:28 +02:00
|
|
|
mw->splitDockWidget(mw->toolBarDockWidget(), summaryDock, Qt::Vertical);
|
2011-05-20 12:43:29 +02:00
|
|
|
mw->tabifyDockWidget(summaryDock, timelineDock);
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
2011-05-20 12:43:29 +02:00
|
|
|
|
|
|
|
QWidget *QmlProfilerTool::createControlWidget()
|
2011-03-11 12:22:57 +01:00
|
|
|
{
|
|
|
|
// custom toolbar (TODO)
|
2011-03-24 12:42:15 +01:00
|
|
|
QWidget *toolbarWidget = new QWidget;
|
|
|
|
toolbarWidget->setObjectName(QLatin1String("QmlProfilerToolBarWidget"));
|
|
|
|
|
|
|
|
QHBoxLayout *layout = new QHBoxLayout;
|
|
|
|
layout->setMargin(0);
|
|
|
|
layout->setSpacing(0);
|
|
|
|
|
2011-04-06 12:26:19 +02:00
|
|
|
d->m_recordButton = new QToolButton(toolbarWidget);
|
|
|
|
|
|
|
|
d->m_recordButton->setIcon(QIcon(QLatin1String(":/qmlprofiler/analyzer_category_small.png")));
|
|
|
|
d->m_recordButton->setCheckable(true);
|
|
|
|
|
|
|
|
connect(d->m_recordButton,SIGNAL(toggled(bool)), this, SLOT(setRecording(bool)));
|
|
|
|
d->m_recordButton->setChecked(true);
|
|
|
|
layout->addWidget(d->m_recordButton);
|
|
|
|
|
2011-05-20 13:36:16 +02:00
|
|
|
QLabel *timeLabel = new QLabel(QLatin1Char(' ') + tr("Elapsed: 0 s"));
|
2011-03-24 12:42:15 +01:00
|
|
|
QPalette palette = timeLabel->palette();
|
|
|
|
palette.setColor(QPalette::WindowText, Qt::white);
|
|
|
|
timeLabel->setPalette(palette);
|
|
|
|
|
2011-05-20 13:36:16 +02:00
|
|
|
connect(this, SIGNAL(setTimeLabel(QString)), timeLabel, SLOT(setText(QString)));
|
2011-03-24 12:42:15 +01:00
|
|
|
layout->addWidget(timeLabel);
|
|
|
|
toolbarWidget->setLayout(layout);
|
|
|
|
|
|
|
|
return toolbarWidget;
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void QmlProfilerTool::connectClient()
|
2011-04-12 17:24:56 +02:00
|
|
|
{
|
2011-04-14 17:19:28 +02:00
|
|
|
QTC_ASSERT(!d->m_client, return;)
|
|
|
|
d->m_client = new QDeclarativeDebugConnection;
|
2011-04-15 14:51:49 +02:00
|
|
|
d->m_traceWindow->reset(d->m_client);
|
2011-04-14 17:19:28 +02:00
|
|
|
connect(d->m_client, SIGNAL(stateChanged(QAbstractSocket::SocketState)),
|
|
|
|
this, SLOT(connectionStateChanged()));
|
2011-04-12 17:24:56 +02:00
|
|
|
d->m_connectionTimer.start();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QmlProfilerTool::connectToClient()
|
2011-03-11 12:22:57 +01:00
|
|
|
{
|
2011-04-14 17:19:28 +02:00
|
|
|
if (!d->m_client || d->m_client->state() != QAbstractSocket::UnconnectedState)
|
|
|
|
return;
|
|
|
|
if (QmlProfilerPlugin::debugOutput)
|
2011-04-15 08:55:55 +02:00
|
|
|
qWarning("QmlProfiler: Connecting to %s:%lld ...", qPrintable(d->m_host), d->m_port);
|
2011-03-11 12:22:57 +01:00
|
|
|
|
2011-04-14 17:19:28 +02:00
|
|
|
d->m_client->connectToHost(d->m_host, d->m_port);
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void QmlProfilerTool::disconnectClient()
|
|
|
|
{
|
2011-04-15 09:35:54 +02:00
|
|
|
// this might be actually be called indirectly by QDDConnectionPrivate::readyRead(), therefore allow
|
|
|
|
// method to complete before deleting object
|
2011-05-04 16:50:24 +02:00
|
|
|
if (d->m_client) {
|
|
|
|
d->m_client->deleteLater();
|
|
|
|
d->m_client = 0;
|
|
|
|
}
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
2011-04-06 12:26:19 +02:00
|
|
|
void QmlProfilerTool::startRecording()
|
|
|
|
{
|
2011-04-14 17:19:28 +02:00
|
|
|
if (d->m_client && d->m_client->isConnected()) {
|
2011-04-08 14:39:55 +02:00
|
|
|
clearDisplay();
|
2011-04-06 12:26:19 +02:00
|
|
|
d->m_traceWindow->setRecording(true);
|
2011-04-08 14:39:55 +02:00
|
|
|
}
|
2011-04-06 12:26:19 +02:00
|
|
|
emit fetchingData(true);
|
|
|
|
}
|
|
|
|
|
2011-03-11 12:22:57 +01:00
|
|
|
void QmlProfilerTool::stopRecording()
|
|
|
|
{
|
2011-04-14 15:23:17 +02:00
|
|
|
d->m_traceWindow->setRecording(false);
|
2011-04-06 12:26:19 +02:00
|
|
|
emit fetchingData(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QmlProfilerTool::setRecording(bool recording)
|
|
|
|
{
|
2011-04-14 15:23:17 +02:00
|
|
|
d->m_recordingEnabled = recording;
|
2011-04-06 12:26:19 +02:00
|
|
|
if (recording)
|
|
|
|
startRecording();
|
|
|
|
else
|
|
|
|
stopRecording();
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
2011-04-01 13:57:49 +02:00
|
|
|
void QmlProfilerTool::gotoSourceLocation(const QString &fileUrl, int lineNumber)
|
2011-03-11 12:22:57 +01:00
|
|
|
{
|
2011-04-01 13:57:49 +02:00
|
|
|
if (lineNumber < 0 || fileUrl.isEmpty())
|
2011-03-11 12:22:57 +01:00
|
|
|
return;
|
|
|
|
|
2011-04-01 13:57:49 +02:00
|
|
|
const QString fileName = QUrl(fileUrl).toLocalFile();
|
|
|
|
const QString projectFileName = d->m_projectFinder.findFile(fileName);
|
2011-03-11 12:22:57 +01:00
|
|
|
|
|
|
|
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
|
|
|
Core::IEditor *editor = editorManager->openEditor(projectFileName);
|
|
|
|
TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor*>(editor);
|
|
|
|
|
|
|
|
if (textEditor) {
|
|
|
|
editorManager->addCurrentPositionToNavigationHistory();
|
|
|
|
textEditor->gotoLine(lineNumber);
|
|
|
|
textEditor->widget()->setFocus();
|
|
|
|
}
|
|
|
|
}
|
2011-03-24 12:42:15 +01:00
|
|
|
|
|
|
|
void QmlProfilerTool::updateTimer(qreal elapsedSeconds)
|
|
|
|
{
|
|
|
|
QString timeString = QString::number(elapsedSeconds,'f',1);
|
|
|
|
timeString = QString(" ").left(6-timeString.length()) + timeString;
|
|
|
|
emit setTimeLabel(tr("elapsed: ")+timeString+QLatin1String(" s"));
|
|
|
|
}
|
2011-04-01 13:48:10 +02:00
|
|
|
|
|
|
|
void QmlProfilerTool::updateProjectFileList()
|
|
|
|
{
|
|
|
|
d->m_projectFinder.setProjectFiles(
|
|
|
|
d->m_project->files(ProjectExplorer::Project::ExcludeGeneratedFiles));
|
|
|
|
}
|
2011-04-04 14:39:28 +02:00
|
|
|
|
|
|
|
bool QmlProfilerTool::canRunRemotely() const
|
|
|
|
{
|
|
|
|
// TODO: Is this correct?
|
|
|
|
return true;
|
|
|
|
}
|
2011-04-04 15:03:31 +02:00
|
|
|
|
2011-04-06 16:04:18 +02:00
|
|
|
void QmlProfilerTool::clearDisplay()
|
|
|
|
{
|
|
|
|
d->m_traceWindow->clearDisplay();
|
2011-04-08 13:05:39 +02:00
|
|
|
d->m_summary->clean();
|
2011-04-06 16:04:18 +02:00
|
|
|
}
|
|
|
|
|
2011-04-04 15:03:31 +02:00
|
|
|
void QmlProfilerTool::attach()
|
|
|
|
{
|
|
|
|
if (!d->m_isAttached) {
|
|
|
|
QmlProfilerAttachDialog dialog;
|
|
|
|
int result = dialog.exec();
|
|
|
|
|
|
|
|
if (result == QDialog::Rejected)
|
|
|
|
return;
|
|
|
|
|
2011-04-14 15:44:43 +02:00
|
|
|
d->m_port = dialog.port();
|
|
|
|
d->m_host = dialog.address();
|
2011-04-04 15:03:31 +02:00
|
|
|
|
|
|
|
connectClient();
|
|
|
|
AnalyzerManager::instance()->showMode();
|
2011-05-20 09:12:34 +02:00
|
|
|
AnalyzerManager::instance()->popupOutputPane();
|
2011-04-04 15:03:31 +02:00
|
|
|
} else {
|
|
|
|
stopRecording();
|
|
|
|
}
|
|
|
|
|
|
|
|
d->m_isAttached = !d->m_isAttached;
|
|
|
|
updateAttachAction();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QmlProfilerTool::updateAttachAction()
|
|
|
|
{
|
|
|
|
if (d->m_attachAction) {
|
|
|
|
if (d->m_isAttached) {
|
|
|
|
d->m_attachAction->setText(tr("Detach"));
|
|
|
|
} else {
|
|
|
|
d->m_attachAction->setText(tr("Attach..."));
|
|
|
|
}
|
|
|
|
}
|
2011-04-04 15:56:34 +02:00
|
|
|
|
|
|
|
d->m_attachAction->setEnabled(Analyzer::AnalyzerManager::instance()->currentTool() == this);
|
2011-04-04 15:03:31 +02:00
|
|
|
}
|
2011-04-04 15:56:34 +02:00
|
|
|
|
2011-04-12 17:24:56 +02:00
|
|
|
void QmlProfilerTool::tryToConnect()
|
|
|
|
{
|
|
|
|
++d->m_connectionAttempts;
|
|
|
|
|
2011-04-14 17:19:28 +02:00
|
|
|
if (d->m_client && d->m_client->isConnected()) {
|
2011-04-12 17:24:56 +02:00
|
|
|
d->m_connectionTimer.stop();
|
|
|
|
d->m_connectionAttempts = 0;
|
|
|
|
} else if (d->m_connectionAttempts == 50) {
|
|
|
|
d->m_connectionTimer.stop();
|
|
|
|
d->m_connectionAttempts = 0;
|
2011-05-03 16:45:46 +02:00
|
|
|
if (QmlProfilerPlugin::debugOutput) {
|
|
|
|
if (d->m_client) {
|
|
|
|
qWarning("QmlProfiler: Failed to connect: %s", qPrintable(d->m_client->errorString()));
|
|
|
|
} else {
|
|
|
|
qWarning("QmlProfiler: Failed to connect.");
|
|
|
|
}
|
|
|
|
}
|
2011-04-14 17:19:28 +02:00
|
|
|
emit connectionFailed();
|
2011-04-12 17:24:56 +02:00
|
|
|
} else {
|
|
|
|
connectToClient();
|
|
|
|
}
|
|
|
|
}
|
2011-04-14 17:19:28 +02:00
|
|
|
|
|
|
|
void QmlProfilerTool::connectionStateChanged()
|
|
|
|
{
|
|
|
|
if (!d->m_client)
|
|
|
|
return;
|
|
|
|
switch (d->m_client->state()) {
|
|
|
|
case QAbstractSocket::UnconnectedState:
|
|
|
|
{
|
|
|
|
if (QmlProfilerPlugin::debugOutput)
|
|
|
|
qWarning("QmlProfiler: disconnected");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case QAbstractSocket::HostLookupState:
|
|
|
|
break;
|
|
|
|
case QAbstractSocket::ConnectingState: {
|
|
|
|
if (QmlProfilerPlugin::debugOutput)
|
|
|
|
qWarning("QmlProfiler: Connecting to debug server ...");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case QAbstractSocket::ConnectedState:
|
|
|
|
{
|
|
|
|
if (QmlProfilerPlugin::debugOutput)
|
|
|
|
qWarning("QmlProfiler: connected and running");
|
2011-04-15 14:51:49 +02:00
|
|
|
updateRecordingState();
|
2011-04-14 17:19:28 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case QAbstractSocket::ClosingState:
|
|
|
|
if (QmlProfilerPlugin::debugOutput)
|
|
|
|
qWarning("QmlProfiler: closing ...");
|
|
|
|
break;
|
|
|
|
case QAbstractSocket::BoundState:
|
|
|
|
case QAbstractSocket::ListeningState:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-15 14:51:49 +02:00
|
|
|
void QmlProfilerTool::updateRecordingState()
|
2011-04-14 17:19:28 +02:00
|
|
|
{
|
|
|
|
if (d->m_client->isConnected()) {
|
|
|
|
d->m_traceWindow->setRecording(d->m_recordingEnabled);
|
|
|
|
} else {
|
|
|
|
d->m_traceWindow->setRecording(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (d->m_traceWindow->isRecording())
|
|
|
|
clearDisplay();
|
|
|
|
}
|