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
|
|
|
**
|
|
|
|
**
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
**
|
2011-07-06 15:48:52 +00:00
|
|
|
** 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.
|
2011-03-25 09:25:17 +01:00
|
|
|
**
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-07-06 15:48:52 +00:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2011-03-25 09:25:17 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
2011-07-06 15:48:52 +00:00
|
|
|
** Other Usage
|
|
|
|
**
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
**
|
2011-03-25 09:25:17 +01:00
|
|
|
** 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-06-29 15:05:45 +02:00
|
|
|
#include "qmlprofilereventview.h"
|
2011-03-11 12:22:57 +01:00
|
|
|
|
|
|
|
#include "tracewindow.h"
|
2011-05-20 09:12:34 +02:00
|
|
|
#include "timelineview.h"
|
|
|
|
|
2011-08-18 16:10:33 +02:00
|
|
|
#include <qmljsdebugclient/qmlprofilereventlist.h>
|
2011-08-05 10:18:32 +02:00
|
|
|
#include <qmljsdebugclient/qdeclarativedebugclient.h>
|
2011-03-11 12:22:57 +01:00
|
|
|
|
|
|
|
#include <analyzerbase/analyzermanager.h>
|
|
|
|
#include <analyzerbase/analyzerconstants.h>
|
2011-09-14 13:12:25 +02:00
|
|
|
#include <analyzerbase/analyzerruncontrol.h>
|
2011-03-11 12:22:57 +01:00
|
|
|
|
|
|
|
#include "canvas/qdeclarativecanvas_p.h"
|
2011-10-28 16:22:45 +02:00
|
|
|
#include "canvas/qdeclarativecanvastimer_p.h"
|
|
|
|
#include "canvas/qmlprofilercanvas.h"
|
2011-03-11 12:22:57 +01:00
|
|
|
|
|
|
|
#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-10-28 16:32:34 +02:00
|
|
|
#include <projectexplorer/session.h>
|
2011-03-11 12:22:57 +01:00
|
|
|
|
|
|
|
#include <texteditor/itexteditor.h>
|
2011-04-04 15:03:31 +02:00
|
|
|
#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-07-27 11:49:39 +02:00
|
|
|
#include <coreplugin/messagemanager.h>
|
2011-09-14 13:26:19 +02:00
|
|
|
#include <coreplugin/helpmanager.h>
|
2011-03-11 12:22:57 +01:00
|
|
|
|
2011-06-10 17:09:45 +02:00
|
|
|
#include <qt4projectmanager/qt4buildconfiguration.h>
|
2011-06-09 14:34:26 +02:00
|
|
|
#include <qt4projectmanager/qt-s60/s60deployconfiguration.h>
|
|
|
|
|
2011-03-11 12:22:57 +01:00
|
|
|
#include <QtCore/QFile>
|
|
|
|
|
2011-06-10 17:09:45 +02:00
|
|
|
#include <QtGui/QApplication>
|
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-06-10 17:09:45 +02:00
|
|
|
#include <QtGui/QMessageBox>
|
2011-07-13 09:27:25 +02:00
|
|
|
#include <QtGui/QDockWidget>
|
2011-07-26 13:56:14 +02:00
|
|
|
#include <QtGui/QFileDialog>
|
|
|
|
#include <QtGui/QMenu>
|
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-06-28 15:51:20 +02:00
|
|
|
using namespace QmlJsDebugClient;
|
2011-09-14 13:12:25 +02:00
|
|
|
using namespace ProjectExplorer;
|
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-11-04 17:33:09 +01:00
|
|
|
QmlProfilerEventsWidget *m_eventsView;
|
|
|
|
QmlProfilerEventsWidget *m_v8profilerView;
|
2011-04-01 13:48:10 +02:00
|
|
|
Utils::FileInProjectFinder m_projectFinder;
|
2011-09-14 13:12:25 +02:00
|
|
|
RunConfiguration *m_runConfiguration;
|
2011-04-04 15:03:31 +02:00
|
|
|
bool m_isAttached;
|
2011-04-06 12:26:19 +02:00
|
|
|
QToolButton *m_recordButton;
|
2011-06-24 18:19:08 +02:00
|
|
|
QToolButton *m_clearButton;
|
2011-04-14 15:23:17 +02:00
|
|
|
bool m_recordingEnabled;
|
2011-08-25 16:30:36 +02:00
|
|
|
bool m_appIsRunning;
|
2011-06-09 14:34:26 +02:00
|
|
|
|
|
|
|
enum ConnectMode {
|
|
|
|
TcpConnection, OstConnection
|
|
|
|
};
|
|
|
|
|
|
|
|
ConnectMode m_connectMode;
|
|
|
|
QString m_tcpHost;
|
|
|
|
quint64 m_tcpPort;
|
|
|
|
QString m_ostDevice;
|
2011-10-15 11:32:55 +02:00
|
|
|
QString m_sysroot;
|
2011-03-11 12:22:57 +01:00
|
|
|
};
|
|
|
|
|
2011-06-30 18:55:48 +02:00
|
|
|
QmlProfilerTool::QmlProfilerTool(QObject *parent)
|
2011-03-11 12:22:57 +01:00
|
|
|
: IAnalyzerTool(parent), d(new QmlProfilerToolPrivate(this))
|
|
|
|
{
|
2011-07-01 14:19:12 +02:00
|
|
|
setObjectName("QmlProfilerTool");
|
2011-05-20 13:36:16 +02:00
|
|
|
d->m_client = 0;
|
|
|
|
d->m_connectionAttempts = 0;
|
|
|
|
d->m_traceWindow = 0;
|
|
|
|
d->m_runConfiguration = 0;
|
|
|
|
d->m_isAttached = false;
|
|
|
|
d->m_recordingEnabled = true;
|
2011-08-25 16:30:36 +02:00
|
|
|
d->m_appIsRunning = false;
|
2011-05-20 13:36:16 +02:00
|
|
|
|
|
|
|
d->m_connectionTimer.setInterval(200);
|
|
|
|
connect(&d->m_connectionTimer, SIGNAL(timeout()), SLOT(tryToConnect()));
|
2011-06-30 13:44:22 +02:00
|
|
|
|
|
|
|
qmlRegisterType<Canvas>("Monitor", 1, 0, "Canvas");
|
2011-10-28 16:22:45 +02:00
|
|
|
qmlRegisterType<QmlProfilerCanvas>("Monitor", 1, 0, "Canvas2D");
|
2011-06-30 13:44:22 +02:00
|
|
|
qmlRegisterType<Context2D>();
|
|
|
|
qmlRegisterType<CanvasImage>();
|
|
|
|
qmlRegisterType<CanvasGradient>();
|
|
|
|
qmlRegisterType<TimelineView>("Monitor", 1, 0,"TimelineView");
|
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;
|
|
|
|
}
|
|
|
|
|
2011-06-30 13:44:22 +02:00
|
|
|
QByteArray QmlProfilerTool::id() const
|
2011-03-11 12:22:57 +01:00
|
|
|
{
|
2011-06-30 18:55:48 +02:00
|
|
|
return "QmlProfiler";
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QString QmlProfilerTool::displayName() const
|
|
|
|
{
|
2011-06-30 18:55:48 +02:00
|
|
|
return tr("QML Profiler");
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
2011-06-28 19:14:08 +02:00
|
|
|
QString QmlProfilerTool::description() const
|
|
|
|
{
|
|
|
|
return tr("The QML Profiler can be used to find performance bottlenecks in "
|
|
|
|
"applications using QML.");
|
|
|
|
}
|
|
|
|
|
2011-07-01 14:19:12 +02:00
|
|
|
IAnalyzerTool::ToolMode QmlProfilerTool::toolMode() const
|
2011-03-11 12:22:57 +01:00
|
|
|
{
|
2011-05-03 16:44:41 +02:00
|
|
|
return AnyMode;
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
2011-07-26 13:56:14 +02:00
|
|
|
void QmlProfilerTool::showContextMenu(const QPoint &position)
|
|
|
|
{
|
2011-11-04 17:33:09 +01:00
|
|
|
QmlProfilerEventsWidget *eventView = qobject_cast<QmlProfilerEventsWidget *>(sender());
|
2011-10-20 17:38:24 +02:00
|
|
|
TraceWindow *traceView = qobject_cast<TraceWindow *>(sender());
|
2011-08-24 11:18:48 +02:00
|
|
|
|
2011-07-26 13:56:14 +02:00
|
|
|
QMenu menu;
|
|
|
|
QAction *loadAction = menu.addAction(tr("Load QML Trace"));
|
|
|
|
QAction *saveAction = menu.addAction(tr("Save QML Trace"));
|
2011-10-17 15:57:15 +02:00
|
|
|
QAction *copyRowAction = 0;
|
|
|
|
QAction *copyTableAction = 0;
|
2011-10-20 17:38:24 +02:00
|
|
|
QAction *viewAllAction = 0;
|
2011-11-04 17:33:09 +01:00
|
|
|
if (eventView && eventView->mouseOnTable(position)) {
|
|
|
|
if (eventView->selectedItem().isValid())
|
2011-08-24 11:18:48 +02:00
|
|
|
copyRowAction = menu.addAction(tr("Copy Row"));
|
|
|
|
copyTableAction = menu.addAction(tr("Copy Table"));
|
|
|
|
}
|
2011-11-04 17:33:09 +01:00
|
|
|
|
2011-10-20 17:38:24 +02:00
|
|
|
if (traceView) {
|
|
|
|
if (traceView->getEventList()->count() > 0) {
|
|
|
|
menu.addSeparator();
|
|
|
|
viewAllAction = menu.addAction(tr("Reset Zoom"));
|
|
|
|
}
|
|
|
|
}
|
2011-07-26 13:56:14 +02:00
|
|
|
|
|
|
|
QAction *selectedAction = menu.exec(position);
|
2011-10-20 17:38:24 +02:00
|
|
|
|
2011-11-01 16:08:21 +01:00
|
|
|
if (selectedAction) {
|
|
|
|
if (selectedAction == loadAction)
|
|
|
|
showLoadDialog();
|
|
|
|
if (selectedAction == saveAction)
|
|
|
|
showSaveDialog();
|
|
|
|
if (selectedAction == copyRowAction)
|
2011-11-04 17:33:09 +01:00
|
|
|
eventView->copyRowToClipboard();
|
2011-11-01 16:08:21 +01:00
|
|
|
if (selectedAction == copyTableAction)
|
2011-11-04 17:33:09 +01:00
|
|
|
eventView->copyTableToClipboard();
|
2011-10-20 17:38:24 +02:00
|
|
|
if (selectedAction == viewAllAction)
|
|
|
|
traceView->viewAll();
|
2011-11-01 16:08:21 +01:00
|
|
|
}
|
2011-07-26 13:56:14 +02:00
|
|
|
}
|
|
|
|
|
2011-04-04 14:39:28 +02:00
|
|
|
IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp,
|
2011-09-14 13:12:25 +02:00
|
|
|
RunConfiguration *runConfiguration)
|
2011-03-11 12:22:57 +01:00
|
|
|
{
|
2011-09-14 13:12:25 +02:00
|
|
|
QmlProfilerEngine *engine = new QmlProfilerEngine(this, sp, runConfiguration);
|
2011-06-10 17:09:45 +02:00
|
|
|
|
2011-06-09 14:34:26 +02:00
|
|
|
d->m_connectMode = QmlProfilerToolPrivate::TcpConnection;
|
|
|
|
|
2011-09-14 13:12:25 +02:00
|
|
|
if (runConfiguration) {
|
|
|
|
// Check minimum Qt Version. We cannot really be sure what the Qt version
|
|
|
|
// at runtime is, but guess that the active build configuraiton has been used.
|
|
|
|
QtSupport::QtVersionNumber minimumVersion(4, 7, 4);
|
|
|
|
if (Qt4ProjectManager::Qt4BuildConfiguration *qt4Config
|
|
|
|
= qobject_cast<Qt4ProjectManager::Qt4BuildConfiguration*>(
|
|
|
|
runConfiguration->target()->activeBuildConfiguration())) {
|
|
|
|
if (qt4Config->qtVersion()->isValid() && qt4Config->qtVersion()->qtVersion() < minimumVersion) {
|
|
|
|
int result = QMessageBox::warning(QApplication::activeWindow(), tr("QML Profiler"),
|
|
|
|
tr("The QML profiler requires Qt 4.7.4 or newer.\n"
|
|
|
|
"The Qt version configured in your active build configuration is too old.\n"
|
|
|
|
"Do you want to continue?"), QMessageBox::Yes, QMessageBox::No);
|
|
|
|
if (result == QMessageBox::No)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether we should use OST instead of TCP
|
|
|
|
if (Qt4ProjectManager::S60DeployConfiguration *deployConfig
|
|
|
|
= qobject_cast<Qt4ProjectManager::S60DeployConfiguration*>(
|
|
|
|
runConfiguration->target()->activeDeployConfiguration())) {
|
|
|
|
if (deployConfig->communicationChannel()
|
|
|
|
== Qt4ProjectManager::S60DeployConfiguration::CommunicationCodaSerialConnection) {
|
|
|
|
d->m_connectMode = QmlProfilerToolPrivate::OstConnection;
|
|
|
|
d->m_ostDevice = deployConfig->serialPortName();
|
|
|
|
}
|
2011-06-09 14:34:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-05 12:14:41 +02:00
|
|
|
// FIXME: Check that there's something sensible in sp.connParams
|
2011-06-09 14:34:26 +02:00
|
|
|
if (d->m_connectMode == QmlProfilerToolPrivate::TcpConnection) {
|
|
|
|
d->m_tcpHost = sp.connParams.host;
|
|
|
|
d->m_tcpPort = sp.connParams.port;
|
|
|
|
}
|
2011-04-14 15:44:43 +02:00
|
|
|
|
2011-04-04 15:03:31 +02:00
|
|
|
d->m_runConfiguration = runConfiguration;
|
2011-09-14 13:12:25 +02:00
|
|
|
|
2011-10-28 16:32:34 +02:00
|
|
|
//
|
|
|
|
// Initialize m_projectFinder
|
|
|
|
//
|
|
|
|
|
|
|
|
QString projectDirectory;
|
|
|
|
if (d->m_runConfiguration) {
|
|
|
|
Project *project = d->m_runConfiguration->target()->project();
|
|
|
|
projectDirectory = project->projectDirectory();
|
|
|
|
}
|
2011-09-14 13:12:25 +02:00
|
|
|
|
2011-10-28 16:32:34 +02:00
|
|
|
// get files from all the projects in the session
|
|
|
|
QStringList sourceFiles;
|
|
|
|
SessionManager *sessionManager = ProjectExplorerPlugin::instance()->session();
|
|
|
|
QList<Project *> projects = sessionManager->projects();
|
|
|
|
if (Project *startupProject = ProjectExplorerPlugin::instance()->startupProject()) {
|
|
|
|
// startup project first
|
|
|
|
projects.removeOne(ProjectExplorerPlugin::instance()->startupProject());
|
|
|
|
projects.insert(0, startupProject);
|
2011-04-01 13:48:10 +02:00
|
|
|
}
|
2011-10-28 16:32:34 +02:00
|
|
|
foreach (Project *project, projects)
|
|
|
|
sourceFiles << project->files(Project::ExcludeGeneratedFiles);
|
2011-04-01 13:48:10 +02:00
|
|
|
|
2011-10-28 16:32:34 +02:00
|
|
|
d->m_projectFinder.setProjectDirectory(projectDirectory);
|
|
|
|
d->m_projectFinder.setProjectFiles(sourceFiles);
|
2011-10-15 11:32:55 +02:00
|
|
|
d->m_projectFinder.setSysroot(sp.sysroot);
|
|
|
|
|
2011-06-27 17:18:55 +02:00
|
|
|
connect(engine, SIGNAL(processRunning(int)), this, SLOT(connectClient(int)));
|
2011-04-06 12:26:19 +02:00
|
|
|
connect(engine, SIGNAL(finished()), this, SLOT(disconnectClient()));
|
2011-07-13 14:47:34 +02:00
|
|
|
connect(engine, SIGNAL(finished()), this, SLOT(correctTimer()));
|
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)));
|
2011-08-25 16:30:36 +02:00
|
|
|
connect(engine, SIGNAL(starting(const Analyzer::IAnalyzerEngine*)), this, SLOT(setAppIsRunning()));
|
|
|
|
connect(engine, SIGNAL(finished()), this, SLOT(setAppIsStopped()));
|
|
|
|
connect(this, SIGNAL(cancelRun()), engine, SLOT(finishProcess()));
|
2011-04-06 12:26:19 +02:00
|
|
|
emit fetchingData(d->m_recordButton->isChecked());
|
2011-03-11 12:22:57 +01:00
|
|
|
|
|
|
|
return engine;
|
|
|
|
}
|
|
|
|
|
2011-07-06 16:52:14 +02:00
|
|
|
QWidget *QmlProfilerTool::createWidgets()
|
|
|
|
{
|
|
|
|
QTC_ASSERT(!d->m_traceWindow, return 0);
|
|
|
|
|
|
|
|
//
|
|
|
|
// DockWidgets
|
|
|
|
//
|
2011-07-06 14:13:04 +02:00
|
|
|
|
2011-06-30 13:44:22 +02:00
|
|
|
Utils::FancyMainWindow *mw = AnalyzerManager::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-07-26 13:56:14 +02:00
|
|
|
connect(d->m_traceWindow, SIGNAL(contextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
|
2011-08-18 16:10:33 +02:00
|
|
|
connect(d->m_traceWindow->getEventList(), SIGNAL(error(QString)), this, SLOT(showErrorDialog(QString)));
|
2011-04-04 15:03:31 +02:00
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
d->m_eventsView = new QmlProfilerEventsWidget(d->m_traceWindow->getEventList(), mw);
|
|
|
|
connect(d->m_eventsView, SIGNAL(gotoSourceLocation(QString,int)), this, SLOT(gotoSourceLocation(QString,int)));
|
2011-07-26 13:56:14 +02:00
|
|
|
connect(d->m_eventsView, SIGNAL(contextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
|
2011-04-08 13:05:39 +02:00
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
d->m_v8profilerView = new QmlProfilerEventsWidget(d->m_traceWindow->getEventList(), mw);
|
|
|
|
d->m_v8profilerView->switchToV8View();
|
2011-09-27 14:38:22 +02:00
|
|
|
connect(d->m_v8profilerView, SIGNAL(gotoSourceLocation(QString,int)), this, SLOT(gotoSourceLocation(QString,int)));
|
|
|
|
connect(d->m_v8profilerView, SIGNAL(contextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
|
|
|
|
|
2011-06-29 15:05:45 +02:00
|
|
|
QDockWidget *eventsDock = AnalyzerManager::createDockWidget
|
|
|
|
(this, tr("Events"), d->m_eventsView, Qt::BottomDockWidgetArea);
|
2011-06-30 13:44:22 +02:00
|
|
|
QDockWidget *timelineDock = AnalyzerManager::createDockWidget
|
2011-06-29 15:05:45 +02:00
|
|
|
(this, tr("Timeline"), d->m_traceWindow, Qt::BottomDockWidgetArea);
|
2011-09-27 14:38:22 +02:00
|
|
|
QDockWidget *v8profilerDock = AnalyzerManager::createDockWidget
|
|
|
|
(this, tr("JavaScript"), d->m_v8profilerView, Qt::BottomDockWidgetArea);
|
2011-06-22 15:02:33 +02:00
|
|
|
|
2011-07-13 09:27:25 +02:00
|
|
|
eventsDock->show();
|
|
|
|
timelineDock->show();
|
2011-09-27 14:38:22 +02:00
|
|
|
v8profilerDock->show();
|
2011-07-13 09:27:25 +02:00
|
|
|
|
2011-06-29 15:05:45 +02:00
|
|
|
mw->splitDockWidget(mw->toolBarDockWidget(), eventsDock, Qt::Vertical);
|
|
|
|
mw->tabifyDockWidget(eventsDock, timelineDock);
|
2011-11-04 17:33:09 +01:00
|
|
|
mw->tabifyDockWidget(timelineDock, v8profilerDock);
|
2011-07-06 14:13:04 +02:00
|
|
|
|
2011-07-06 16:52:14 +02:00
|
|
|
//
|
|
|
|
// Toolbar
|
|
|
|
//
|
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);
|
2011-07-05 17:49:03 +02:00
|
|
|
// icon and tooltip set in setRecording(), called later
|
2011-04-06 12:26:19 +02:00
|
|
|
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-06-24 18:19:08 +02:00
|
|
|
d->m_clearButton = new QToolButton(toolbarWidget);
|
|
|
|
d->m_clearButton->setIcon(QIcon(QLatin1String(":/qmlprofiler/clean_pane_small.png")));
|
2011-07-05 16:40:26 +02:00
|
|
|
d->m_clearButton->setToolTip(tr("Discard data"));
|
2011-06-24 18:19:08 +02:00
|
|
|
connect(d->m_clearButton,SIGNAL(clicked()), this, SLOT(clearDisplay()));
|
|
|
|
layout->addWidget(d->m_clearButton);
|
|
|
|
|
2011-05-23 15:00:59 +02:00
|
|
|
QLabel *timeLabel = new QLabel(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-23 15:00:59 +02:00
|
|
|
timeLabel->setIndent(10);
|
2011-07-13 14:47:34 +02:00
|
|
|
connect(d->m_traceWindow, SIGNAL(viewUpdated()), this, SLOT(correctTimer()));
|
2011-05-20 13:36:16 +02:00
|
|
|
connect(this, SIGNAL(setTimeLabel(QString)), timeLabel, SLOT(setText(QString)));
|
2011-07-13 14:47:34 +02:00
|
|
|
correctTimer();
|
2011-03-24 12:42:15 +01:00
|
|
|
layout->addWidget(timeLabel);
|
2011-06-24 18:19:08 +02:00
|
|
|
|
2011-03-24 12:42:15 +01:00
|
|
|
toolbarWidget->setLayout(layout);
|
|
|
|
|
|
|
|
return toolbarWidget;
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
2011-06-27 17:18:55 +02:00
|
|
|
void QmlProfilerTool::connectClient(int port)
|
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();
|
2011-06-27 17:18:55 +02:00
|
|
|
d->m_tcpPort = port;
|
2011-04-12 17:24:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2011-03-11 12:22:57 +01:00
|
|
|
|
2011-06-09 14:34:26 +02:00
|
|
|
if (d->m_connectMode == QmlProfilerToolPrivate::TcpConnection) {
|
2011-07-27 11:49:39 +02:00
|
|
|
logStatus(QString("QML Profiler: Connecting to %1:%2 ...").arg(d->m_tcpHost, QString::number(d->m_tcpPort)));
|
2011-06-09 14:34:26 +02:00
|
|
|
d->m_client->connectToHost(d->m_tcpHost, d->m_tcpPort);
|
|
|
|
} else {
|
2011-07-27 11:49:39 +02:00
|
|
|
logStatus(QString("QML Profiler: Connecting to %1 ...").arg(d->m_tcpHost));
|
2011-06-09 14:34:26 +02:00
|
|
|
d->m_client->connectToOst(d->m_ostDevice);
|
|
|
|
}
|
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);
|
2011-08-25 16:30:36 +02:00
|
|
|
|
|
|
|
// manage early stop
|
|
|
|
if (d->m_client && !d->m_client->isConnected() && d->m_appIsRunning)
|
|
|
|
emit cancelRun();
|
2011-04-06 12:26:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void QmlProfilerTool::setRecording(bool recording)
|
|
|
|
{
|
2011-04-14 15:23:17 +02:00
|
|
|
d->m_recordingEnabled = recording;
|
2011-07-05 17:49:03 +02:00
|
|
|
|
|
|
|
// update record button
|
2011-07-05 16:40:26 +02:00
|
|
|
d->m_recordButton->setToolTip( d->m_recordingEnabled ? tr("Disable profiling") : tr("Enable profiling"));
|
2011-07-05 17:49:03 +02:00
|
|
|
d->m_recordButton->setIcon(QIcon(d->m_recordingEnabled ? QLatin1String(":/qmlprofiler/recordOn.png") :
|
|
|
|
QLatin1String(":/qmlprofiler/recordOff.png")));
|
|
|
|
|
2011-04-06 12:26:19 +02:00
|
|
|
if (recording)
|
|
|
|
startRecording();
|
|
|
|
else
|
|
|
|
stopRecording();
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
2011-08-25 16:30:36 +02:00
|
|
|
void QmlProfilerTool::setAppIsRunning()
|
|
|
|
{
|
|
|
|
d->m_appIsRunning = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QmlProfilerTool::setAppIsStopped()
|
|
|
|
{
|
|
|
|
d->m_appIsRunning = false;
|
|
|
|
}
|
|
|
|
|
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-07-19 17:48:57 +02:00
|
|
|
const QString projectFileName = d->m_projectFinder.findFile(fileUrl);
|
2011-03-11 12:22:57 +01:00
|
|
|
|
2011-11-09 11:01:03 +01:00
|
|
|
QFileInfo fileInfo(projectFileName);
|
|
|
|
if (!fileInfo.exists() || !fileInfo.isReadable())
|
|
|
|
return;
|
|
|
|
|
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
|
|
|
|
2011-07-13 14:47:34 +02:00
|
|
|
void QmlProfilerTool::correctTimer() {
|
2011-07-26 13:56:14 +02:00
|
|
|
if (d->m_traceWindow->getEventList()->count() == 0)
|
2011-07-13 14:47:34 +02:00
|
|
|
updateTimer(0);
|
|
|
|
}
|
|
|
|
|
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;
|
2011-05-23 15:00:59 +02:00
|
|
|
emit setTimeLabel(tr("Elapsed: %1 s").arg(timeString));
|
2011-03-24 12:42:15 +01:00
|
|
|
}
|
2011-04-01 13:48:10 +02:00
|
|
|
|
2011-04-06 16:04:18 +02:00
|
|
|
void QmlProfilerTool::clearDisplay()
|
|
|
|
{
|
|
|
|
d->m_traceWindow->clearDisplay();
|
2011-06-29 15:05:45 +02:00
|
|
|
d->m_eventsView->clear();
|
2011-09-27 14:38:22 +02:00
|
|
|
d->m_v8profilerView->clear();
|
2011-04-06 16:04:18 +02:00
|
|
|
}
|
|
|
|
|
2011-09-14 13:12:25 +02:00
|
|
|
static void startRemoteTool(IAnalyzerTool *tool, StartMode mode)
|
2011-04-04 15:03:31 +02:00
|
|
|
{
|
2011-09-14 13:12:25 +02:00
|
|
|
Q_UNUSED(tool);
|
2011-10-15 11:52:03 +02:00
|
|
|
|
|
|
|
QString host;
|
|
|
|
quint16 port;
|
2011-10-17 16:44:41 +02:00
|
|
|
QString sysroot;
|
2011-10-15 11:52:03 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
QSettings *settings = Core::ICore::instance()->settings();
|
|
|
|
|
|
|
|
host = settings->value(QLatin1String("AnalyzerQmlAttachDialog/host"), QLatin1String("localhost")).toString();
|
|
|
|
port = settings->value(QLatin1String("AnalyzerQmlAttachDialog/port"), 3768).toInt();
|
2011-10-17 17:18:34 +02:00
|
|
|
sysroot = settings->value(QLatin1String("AnalyzerQmlAttachDialog/sysroot")).toString();
|
2011-10-15 11:52:03 +02:00
|
|
|
|
|
|
|
QmlProfilerAttachDialog dialog;
|
|
|
|
|
|
|
|
dialog.setAddress(host);
|
|
|
|
dialog.setPort(port);
|
2011-10-17 17:18:34 +02:00
|
|
|
dialog.setSysroot(sysroot);
|
2011-10-15 11:52:03 +02:00
|
|
|
|
|
|
|
if (dialog.exec() != QDialog::Accepted)
|
|
|
|
return;
|
|
|
|
|
|
|
|
host = dialog.address();
|
|
|
|
port = dialog.port();
|
2011-10-17 16:44:41 +02:00
|
|
|
sysroot = dialog.sysroot();
|
2011-10-15 11:52:03 +02:00
|
|
|
|
|
|
|
settings->setValue(QLatin1String("AnalyzerQmlAttachDialog/host"), host);
|
|
|
|
settings->setValue(QLatin1String("AnalyzerQmlAttachDialog/port"), port);
|
2011-10-17 17:18:34 +02:00
|
|
|
settings->setValue(QLatin1String("AnalyzerQmlAttachDialog/sysroot"), sysroot);
|
2011-10-15 11:52:03 +02:00
|
|
|
}
|
2011-04-04 15:03:31 +02:00
|
|
|
|
2011-09-14 13:12:25 +02:00
|
|
|
AnalyzerStartParameters sp;
|
|
|
|
sp.toolId = tool->id();
|
|
|
|
sp.startMode = mode;
|
2011-10-15 11:52:03 +02:00
|
|
|
sp.connParams.host = host;
|
|
|
|
sp.connParams.port = port;
|
2011-10-17 16:44:41 +02:00
|
|
|
sp.sysroot = sysroot;
|
2011-04-04 15:03:31 +02:00
|
|
|
|
2011-09-14 13:12:25 +02:00
|
|
|
AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, 0);
|
|
|
|
QObject::connect(AnalyzerManager::stopAction(), SIGNAL(triggered()), rc, SLOT(stopIt()));
|
2011-04-04 15:03:31 +02:00
|
|
|
|
2011-09-14 13:12:25 +02:00
|
|
|
ProjectExplorerPlugin::instance()->startRunControl(rc, tool->id());
|
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-07-27 11:49:39 +02:00
|
|
|
|
2011-09-14 13:26:19 +02:00
|
|
|
Core::ICore * const core = Core::ICore::instance();
|
|
|
|
QMessageBox *infoBox = new QMessageBox(core->mainWindow());
|
|
|
|
infoBox->setIcon(QMessageBox::Critical);
|
|
|
|
infoBox->setWindowTitle(tr("Qt Creator"));
|
|
|
|
infoBox->setText(tr("Could not connect to the in-process QML profiler.\n"
|
|
|
|
"Do you want to retry?"));
|
|
|
|
infoBox->setStandardButtons(QMessageBox::Retry | QMessageBox::Cancel | QMessageBox::Help);
|
|
|
|
infoBox->setDefaultButton(QMessageBox::Retry);
|
|
|
|
infoBox->setModal(true);
|
|
|
|
|
|
|
|
connect(infoBox, SIGNAL(finished(int)),
|
|
|
|
this, SLOT(retryMessageBoxFinished(int)));
|
|
|
|
|
|
|
|
infoBox->show();
|
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)
|
2011-06-20 10:20:08 +02:00
|
|
|
qWarning("QML Profiler: disconnected");
|
2011-04-14 17:19:28 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case QAbstractSocket::HostLookupState:
|
|
|
|
break;
|
|
|
|
case QAbstractSocket::ConnectingState: {
|
|
|
|
if (QmlProfilerPlugin::debugOutput)
|
2011-06-20 10:20:08 +02:00
|
|
|
qWarning("QML Profiler: Connecting to debug server ...");
|
2011-04-14 17:19:28 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case QAbstractSocket::ConnectedState:
|
|
|
|
{
|
|
|
|
if (QmlProfilerPlugin::debugOutput)
|
2011-06-20 10:20:08 +02:00
|
|
|
qWarning("QML Profiler: 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)
|
2011-06-20 10:20:08 +02:00
|
|
|
qWarning("QML Profiler: closing ...");
|
2011-04-14 17:19:28 +02:00
|
|
|
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();
|
|
|
|
}
|
2011-07-04 18:33:47 +02:00
|
|
|
|
|
|
|
void QmlProfilerTool::startTool(StartMode mode)
|
|
|
|
{
|
2011-07-04 19:11:08 +02:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
|
|
// Make sure mode is shown.
|
|
|
|
AnalyzerManager::showMode();
|
|
|
|
|
2011-09-14 13:12:25 +02:00
|
|
|
if (mode == StartLocal) {
|
|
|
|
ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
|
|
|
|
// ### not sure if we're supposed to check if the RunConFiguration isEnabled
|
|
|
|
Project *pro = pe->startupProject();
|
|
|
|
pe->runProject(pro, id());
|
|
|
|
} else if (mode == StartRemote) {
|
|
|
|
startRemoteTool(this, mode);
|
|
|
|
}
|
2011-07-04 18:33:47 +02:00
|
|
|
}
|
2011-07-27 11:49:39 +02:00
|
|
|
|
|
|
|
void QmlProfilerTool::logStatus(const QString &msg)
|
|
|
|
{
|
|
|
|
Core::MessageManager *messageManager = Core::MessageManager::instance();
|
|
|
|
messageManager->printToOutputPane(msg, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QmlProfilerTool::logError(const QString &msg)
|
|
|
|
{
|
|
|
|
// TODO: Rather show errors in the application ouput
|
|
|
|
Core::MessageManager *messageManager = Core::MessageManager::instance();
|
|
|
|
messageManager->printToOutputPane(msg, true);
|
|
|
|
}
|
2011-07-26 13:56:14 +02:00
|
|
|
|
|
|
|
void QmlProfilerTool::showSaveDialog()
|
|
|
|
{
|
|
|
|
Core::ICore *core = Core::ICore::instance();
|
2011-10-04 17:04:33 +02:00
|
|
|
QString filename = QFileDialog::getSaveFileName(core->mainWindow(), tr("Save QML Trace"), QString(), tr("QML traces (*%1)").arg(TraceFileExtension));
|
2011-07-26 13:56:14 +02:00
|
|
|
if (!filename.isEmpty()) {
|
2011-08-22 16:01:50 +02:00
|
|
|
if (!filename.endsWith(QLatin1String(TraceFileExtension)))
|
|
|
|
filename += QLatin1String(TraceFileExtension);
|
2011-07-26 13:56:14 +02:00
|
|
|
d->m_traceWindow->getEventList()->save(filename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void QmlProfilerTool::showLoadDialog()
|
|
|
|
{
|
|
|
|
Core::ICore *core = Core::ICore::instance();
|
2011-10-04 17:04:33 +02:00
|
|
|
QString filename = QFileDialog::getOpenFileName(core->mainWindow(), tr("Load QML Trace"), QString(), tr("QML traces (*%1)").arg(TraceFileExtension));
|
2011-07-26 13:56:14 +02:00
|
|
|
|
|
|
|
if (!filename.isEmpty()) {
|
|
|
|
// delayed load (prevent graphical artifacts due to long load time)
|
|
|
|
d->m_traceWindow->getEventList()->setFilename(filename);
|
|
|
|
QTimer::singleShot(100, d->m_traceWindow->getEventList(), SLOT(load()));
|
|
|
|
}
|
|
|
|
}
|
2011-08-18 16:10:33 +02:00
|
|
|
|
|
|
|
void QmlProfilerTool::showErrorDialog(const QString &error)
|
|
|
|
{
|
|
|
|
Core::ICore *core = Core::ICore::instance();
|
|
|
|
QMessageBox *errorDialog = new QMessageBox(core->mainWindow());
|
|
|
|
errorDialog->setIcon(QMessageBox::Warning);
|
|
|
|
errorDialog->setWindowTitle(tr("QML Profiler"));
|
|
|
|
errorDialog->setText(error);
|
|
|
|
errorDialog->setStandardButtons(QMessageBox::Ok);
|
|
|
|
errorDialog->setDefaultButton(QMessageBox::Ok);
|
|
|
|
errorDialog->setModal(false);
|
|
|
|
errorDialog->show();
|
|
|
|
}
|
2011-09-14 13:26:19 +02:00
|
|
|
|
|
|
|
void QmlProfilerTool::retryMessageBoxFinished(int result)
|
|
|
|
{
|
|
|
|
switch (result) {
|
|
|
|
case QMessageBox::Retry: {
|
|
|
|
d->m_connectionAttempts = 0;
|
|
|
|
d->m_connectionTimer.start();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case QMessageBox::Help: {
|
|
|
|
Core::HelpManager *helpManager = Core::HelpManager::instance();
|
|
|
|
helpManager->handleHelpRequest("qthelp://com.nokia.qtcreator/doc/creator-debugging-qml.html");
|
|
|
|
// fall through
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
if (d->m_client) {
|
|
|
|
logStatus("QML Profiler: Failed to connect! " + d->m_client->errorString());
|
|
|
|
} else {
|
|
|
|
logStatus("QML Profiler: Failed to connect!");
|
|
|
|
}
|
|
|
|
|
|
|
|
emit connectionFailed();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|