2011-03-11 12:22:57 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-03-25 09:25:17 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2011-03-11 12:22:57 +01:00
|
|
|
**
|
2011-05-06 15:05:37 +02:00
|
|
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
2011-03-11 12:22:57 +01:00
|
|
|
**
|
2011-03-25 09:25:17 +01:00
|
|
|
** No Commercial Usage
|
2011-03-11 12:22:57 +01:00
|
|
|
**
|
2011-03-25 09:25:17 +01:00
|
|
|
** 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.
|
2011-03-11 12:22:57 +01:00
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
2011-03-25 09:25:17 +01:00
|
|
|
** 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-11 12:22:57 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
2011-03-25 09:25:17 +01:00
|
|
|
|
2011-03-11 12:22:57 +01:00
|
|
|
#include "tracewindow.h"
|
|
|
|
|
|
2011-05-20 13:36:16 +02:00
|
|
|
#include "qmlprofilerplugin.h"
|
2011-06-28 15:51:20 +02:00
|
|
|
#include "qmlprofilertraceclient.h"
|
2011-03-11 12:22:57 +01:00
|
|
|
|
2011-06-28 15:51:20 +02:00
|
|
|
#include <qmljsdebugclient/qdeclarativedebugclient_p.h>
|
|
|
|
|
#include <utils/styledbar.h>
|
2011-03-11 12:22:57 +01:00
|
|
|
|
2011-06-28 15:51:20 +02:00
|
|
|
#include <QtDeclarative/QDeclarativeView>
|
|
|
|
|
#include <QtDeclarative/QDeclarativeContext>
|
|
|
|
|
#include <QtGui/QVBoxLayout>
|
|
|
|
|
#include <QtGui/QToolButton>
|
|
|
|
|
#include <QtGui/QGraphicsObject>
|
2011-04-14 15:49:12 +02:00
|
|
|
|
2011-03-25 09:21:00 +01:00
|
|
|
namespace QmlProfiler {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2011-03-11 12:22:57 +01:00
|
|
|
TraceWindow::TraceWindow(QWidget *parent)
|
2011-05-20 13:36:16 +02:00
|
|
|
: QWidget(parent)
|
2011-03-11 12:22:57 +01:00
|
|
|
{
|
2011-06-28 15:51:20 +02:00
|
|
|
setObjectName("QML Profiler");
|
2011-03-11 12:22:57 +01:00
|
|
|
|
|
|
|
|
QVBoxLayout *groupLayout = new QVBoxLayout;
|
|
|
|
|
groupLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
groupLayout->setSpacing(0);
|
|
|
|
|
|
|
|
|
|
m_view = new QDeclarativeView(this);
|
|
|
|
|
|
2011-03-25 09:21:00 +01:00
|
|
|
if (QmlProfilerPlugin::debugOutput) {
|
2011-03-11 12:22:57 +01:00
|
|
|
//new QmlJSDebugger::JSDebuggerAgent(m_view->engine());
|
|
|
|
|
//new QmlJSDebugger::QDeclarativeViewObserver(m_view, m_view);
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-24 18:19:08 +02:00
|
|
|
Utils::StyledBar *bar = new Utils::StyledBar(this);
|
|
|
|
|
bar->setSingleRow(true);
|
|
|
|
|
bar->setMinimumWidth(150);
|
|
|
|
|
QHBoxLayout *toolBarLayout = new QHBoxLayout(bar);
|
|
|
|
|
toolBarLayout->setMargin(0);
|
|
|
|
|
toolBarLayout->setSpacing(0);
|
|
|
|
|
QToolButton *buttonPrev= new QToolButton;
|
|
|
|
|
buttonPrev->setIcon(QIcon(":/qmlprofiler/prev.png"));
|
|
|
|
|
connect(buttonPrev, SIGNAL(clicked()), this, SIGNAL(jumpToPrev()));
|
2011-07-05 15:50:32 +02:00
|
|
|
connect(this, SIGNAL(enableToolbar(bool)), buttonPrev, SLOT(setEnabled(bool)));
|
2011-06-24 18:19:08 +02:00
|
|
|
QToolButton *buttonNext= new QToolButton;
|
|
|
|
|
buttonNext->setIcon(QIcon(":/qmlprofiler/next.png"));
|
|
|
|
|
connect(buttonNext, SIGNAL(clicked()), this, SIGNAL(jumpToNext()));
|
2011-07-05 15:50:32 +02:00
|
|
|
connect(this, SIGNAL(enableToolbar(bool)), buttonNext, SLOT(setEnabled(bool)));
|
2011-06-27 18:25:50 +02:00
|
|
|
QToolButton *buttonZoomIn = new QToolButton;
|
|
|
|
|
buttonZoomIn->setIcon(QIcon(":/qmlprofiler/magnifier-plus.png"));
|
|
|
|
|
connect(buttonZoomIn, SIGNAL(clicked()), this, SIGNAL(zoomIn()));
|
2011-07-05 15:50:32 +02:00
|
|
|
connect(this, SIGNAL(enableToolbar(bool)), buttonZoomIn, SLOT(setEnabled(bool)));
|
2011-06-27 18:25:50 +02:00
|
|
|
QToolButton *buttonZoomOut = new QToolButton;
|
|
|
|
|
buttonZoomOut->setIcon(QIcon(":/qmlprofiler/magnifier-minus.png"));
|
|
|
|
|
connect(buttonZoomOut, SIGNAL(clicked()), this, SIGNAL(zoomOut()));
|
2011-07-05 15:50:32 +02:00
|
|
|
connect(this, SIGNAL(enableToolbar(bool)), buttonZoomOut, SLOT(setEnabled(bool)));
|
|
|
|
|
|
2011-06-24 18:19:08 +02:00
|
|
|
toolBarLayout->addWidget(buttonPrev);
|
|
|
|
|
toolBarLayout->addWidget(buttonNext);
|
2011-06-27 18:25:50 +02:00
|
|
|
toolBarLayout->addWidget(buttonZoomIn);
|
|
|
|
|
toolBarLayout->addWidget(buttonZoomOut);
|
2011-06-24 18:19:08 +02:00
|
|
|
|
2011-07-05 15:50:32 +02:00
|
|
|
|
|
|
|
|
|
2011-03-11 12:22:57 +01:00
|
|
|
m_view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
|
|
|
|
|
m_view->setFocus();
|
|
|
|
|
groupLayout->addWidget(m_view);
|
|
|
|
|
|
|
|
|
|
setLayout(groupLayout);
|
|
|
|
|
|
2011-06-09 14:54:56 +02:00
|
|
|
// Minimum height: 5 rows of 20 pixels + scrollbar of 50 pixels + 20 pixels margin
|
|
|
|
|
setMinimumHeight(170);
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TraceWindow::~TraceWindow()
|
|
|
|
|
{
|
2011-04-14 17:18:32 +02:00
|
|
|
delete m_plugin.data();
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
|
2011-06-28 15:51:20 +02:00
|
|
|
void TraceWindow::reset(QmlJsDebugClient::QDeclarativeDebugConnection *conn)
|
2011-03-11 12:22:57 +01:00
|
|
|
{
|
|
|
|
|
if (m_plugin)
|
2011-04-14 17:18:32 +02:00
|
|
|
disconnect(m_plugin.data(), SIGNAL(complete()), this, SIGNAL(viewUpdated()));
|
|
|
|
|
delete m_plugin.data();
|
2011-06-28 15:51:20 +02:00
|
|
|
m_plugin = new QmlProfilerTraceClient(conn);
|
2011-04-14 17:18:32 +02:00
|
|
|
connect(m_plugin.data(), SIGNAL(complete()), this, SIGNAL(viewUpdated()));
|
2011-06-22 15:02:33 +02:00
|
|
|
connect(m_plugin.data(), SIGNAL(range(int,int,int,qint64,qint64,QStringList,QString,int)),
|
|
|
|
|
this, SIGNAL(range(int,int,int,qint64,qint64,QStringList,QString,int)));
|
2011-03-11 12:22:57 +01:00
|
|
|
|
2011-04-14 17:18:32 +02:00
|
|
|
m_view->rootContext()->setContextProperty("connection", m_plugin.data());
|
2011-04-04 10:52:04 +02:00
|
|
|
m_view->setSource(QUrl("qrc:/qmlprofiler/MainView.qml"));
|
2011-03-11 12:22:57 +01:00
|
|
|
|
2011-07-05 15:50:32 +02:00
|
|
|
updateToolbar();
|
|
|
|
|
|
2011-03-11 12:22:57 +01:00
|
|
|
connect(m_view->rootObject(), SIGNAL(updateCursorPosition()), this, SLOT(updateCursorPosition()));
|
2011-03-24 12:42:15 +01:00
|
|
|
connect(m_view->rootObject(), SIGNAL(updateTimer()), this, SLOT(updateTimer()));
|
2011-07-05 15:50:32 +02:00
|
|
|
connect(m_view->rootObject(), SIGNAL(dataAvailableChanged()), this, SLOT(updateToolbar()));
|
2011-06-24 18:19:08 +02:00
|
|
|
connect(this, SIGNAL(jumpToPrev()), m_view->rootObject(), SLOT(prevEvent()));
|
|
|
|
|
connect(this, SIGNAL(jumpToNext()), m_view->rootObject(), SLOT(nextEvent()));
|
2011-06-27 18:25:50 +02:00
|
|
|
connect(this, SIGNAL(zoomIn()), m_view->rootObject(), SLOT(zoomIn()));
|
|
|
|
|
connect(this, SIGNAL(zoomOut()), m_view->rootObject(), SLOT(zoomOut()));
|
2011-06-24 18:19:08 +02:00
|
|
|
|
|
|
|
|
connect(this, SIGNAL(internalClearDisplay()), m_view->rootObject(), SLOT(clearAll()));
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TraceWindow::updateCursorPosition()
|
|
|
|
|
{
|
|
|
|
|
emit gotoSourceLocation(m_view->rootObject()->property("fileName").toString(),
|
|
|
|
|
m_view->rootObject()->property("lineNumber").toInt());
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-24 12:42:15 +01:00
|
|
|
void TraceWindow::updateTimer()
|
|
|
|
|
{
|
|
|
|
|
emit timeChanged(m_view->rootObject()->property("elapsedTime").toDouble());
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-06 16:04:18 +02:00
|
|
|
void TraceWindow::clearDisplay()
|
|
|
|
|
{
|
|
|
|
|
if (m_plugin)
|
2011-04-14 17:18:32 +02:00
|
|
|
m_plugin.data()->clearView();
|
2011-06-24 18:19:08 +02:00
|
|
|
else
|
|
|
|
|
emit internalClearDisplay();
|
2011-04-06 16:04:18 +02:00
|
|
|
}
|
|
|
|
|
|
2011-07-05 15:50:32 +02:00
|
|
|
void TraceWindow::updateToolbar()
|
|
|
|
|
{
|
|
|
|
|
bool dataAvailable = m_view->rootObject()->property("dataAvailable").toBool();
|
|
|
|
|
emit enableToolbar(dataAvailable);
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-11 12:22:57 +01:00
|
|
|
void TraceWindow::setRecording(bool recording)
|
|
|
|
|
{
|
2011-04-15 14:51:49 +02:00
|
|
|
if (m_plugin)
|
|
|
|
|
m_plugin.data()->setRecording(recording);
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-06 12:26:19 +02:00
|
|
|
bool TraceWindow::isRecording() const
|
|
|
|
|
{
|
2011-05-20 13:36:16 +02:00
|
|
|
return m_plugin.data()->isRecording();
|
2011-04-06 12:26:19 +02:00
|
|
|
}
|
|
|
|
|
|
2011-05-20 13:36:16 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QmlProfiler
|