forked from qt-creator/qt-creator
QmlProfiler: updated zoom controls
Change-Id: I3e09e0879a44f1dbf03f3989267aaf79c959526f Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
@@ -154,28 +154,28 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function zoomIn() {
|
function updateWindowLength(absoluteFactor) {
|
||||||
updateZoom( 1/1.1 );
|
var windowLength = view.endTime - view.startTime;
|
||||||
|
if (qmlEventList.traceEndTime() <= 0 || windowLength <= 0)
|
||||||
|
return;
|
||||||
|
var currentFactor = windowLength / qmlEventList.traceEndTime();
|
||||||
|
updateZoom(absoluteFactor / currentFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
function zoomOut() {
|
function updateZoom(relativeFactor) {
|
||||||
updateZoom( 1.1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateZoom(factor) {
|
|
||||||
var min_length = 1e5; // 0.1 ms
|
var min_length = 1e5; // 0.1 ms
|
||||||
var windowLength = view.endTime - view.startTime;
|
var windowLength = view.endTime - view.startTime;
|
||||||
if (windowLength < min_length)
|
if (windowLength < min_length)
|
||||||
windowLength = min_length;
|
windowLength = min_length;
|
||||||
var newWindowLength = windowLength * factor;
|
var newWindowLength = windowLength * relativeFactor;
|
||||||
|
|
||||||
if (newWindowLength > qmlEventList.traceEndTime()) {
|
if (newWindowLength > qmlEventList.traceEndTime()) {
|
||||||
newWindowLength = qmlEventList.traceEndTime();
|
newWindowLength = qmlEventList.traceEndTime();
|
||||||
factor = newWindowLength / windowLength;
|
relativeFactor = newWindowLength / windowLength;
|
||||||
}
|
}
|
||||||
if (newWindowLength < min_length) {
|
if (newWindowLength < min_length) {
|
||||||
newWindowLength = min_length;
|
newWindowLength = min_length;
|
||||||
factor = newWindowLength / windowLength;
|
relativeFactor = newWindowLength / windowLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
var fixedPoint = (view.startTime + view.endTime) / 2;
|
var fixedPoint = (view.startTime + view.endTime) / 2;
|
||||||
@@ -186,7 +186,29 @@ Rectangle {
|
|||||||
fixedPoint = newFixedPoint;
|
fixedPoint = newFixedPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
var startTime = fixedPoint - factor*(fixedPoint - view.startTime);
|
var startTime = fixedPoint - relativeFactor*(fixedPoint - view.startTime);
|
||||||
|
zoomControl.setRange(startTime, startTime + newWindowLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateZoomCentered(centerX, relativeFactor)
|
||||||
|
{
|
||||||
|
var min_length = 1e5; // 0.1 ms
|
||||||
|
var windowLength = view.endTime - view.startTime;
|
||||||
|
if (windowLength < min_length)
|
||||||
|
windowLength = min_length;
|
||||||
|
var newWindowLength = windowLength * relativeFactor;
|
||||||
|
|
||||||
|
if (newWindowLength > qmlEventList.traceEndTime()) {
|
||||||
|
newWindowLength = qmlEventList.traceEndTime();
|
||||||
|
relativeFactor = newWindowLength / windowLength;
|
||||||
|
}
|
||||||
|
if (newWindowLength < min_length) {
|
||||||
|
newWindowLength = min_length;
|
||||||
|
relativeFactor = newWindowLength / windowLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
var fixedPoint = (centerX - flick.x) * windowLength / flick.width + view.startTime;
|
||||||
|
var startTime = fixedPoint - relativeFactor*(fixedPoint - view.startTime);
|
||||||
zoomControl.setRange(startTime, startTime + newWindowLength);
|
zoomControl.setRange(startTime, startTime + newWindowLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,6 +222,19 @@ Rectangle {
|
|||||||
zoomControl.setRange(newStart, newStart + windowLength);
|
zoomControl.setRange(newStart, newStart + windowLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function globalZoom() {
|
||||||
|
zoomControl.setRange(qmlEventList.traceStartTime(), qmlEventList.traceEndTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
function wheelZoom(wheelCenter, wheelDelta) {
|
||||||
|
if (qmlEventList.traceEndTime()>0 && wheelDelta!=0) {
|
||||||
|
if (wheelDelta>0)
|
||||||
|
updateZoomCentered(wheelCenter, 1/1.2);
|
||||||
|
else
|
||||||
|
updateZoomCentered(wheelCenter, 1.2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function hideRangeDetails() {
|
function hideRangeDetails() {
|
||||||
rangeDetails.visible = false;
|
rangeDetails.visible = false;
|
||||||
rangeDetails.duration = "";
|
rangeDetails.duration = "";
|
||||||
@@ -482,7 +517,7 @@ Rectangle {
|
|||||||
selectionRange.isDragging = false;
|
selectionRange.isDragging = false;
|
||||||
}
|
}
|
||||||
onDoubleClicked: {
|
onDoubleClicked: {
|
||||||
zoomControl.setRange(selectionRange.startTime, selectionRange.startTime+selectionRange.duration);
|
zoomControl.setRange(selectionRange.startTime, selectionRange.startTime + selectionRange.duration);
|
||||||
root.selectionRangeMode = false;
|
root.selectionRangeMode = false;
|
||||||
root.updateRangeButton();
|
root.updateRangeButton();
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 423 B |
Binary file not shown.
Before Width: | Height: | Size: 412 B |
BIN
src/plugins/qmlprofiler/qml/magnifier.png
Normal file
BIN
src/plugins/qmlprofiler/qml/magnifier.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 281 B |
@@ -11,8 +11,6 @@
|
|||||||
<file>clean_pane_small.png</file>
|
<file>clean_pane_small.png</file>
|
||||||
<file>prev.png</file>
|
<file>prev.png</file>
|
||||||
<file>next.png</file>
|
<file>next.png</file>
|
||||||
<file>magnifier-minus.png</file>
|
|
||||||
<file>magnifier-plus.png</file>
|
|
||||||
<file>recordOff.png</file>
|
<file>recordOff.png</file>
|
||||||
<file>recordOn.png</file>
|
<file>recordOn.png</file>
|
||||||
<file>StatusDisplay.qml</file>
|
<file>StatusDisplay.qml</file>
|
||||||
@@ -25,5 +23,6 @@
|
|||||||
<file>range_pressed.png</file>
|
<file>range_pressed.png</file>
|
||||||
<file>SelectionRange.qml</file>
|
<file>SelectionRange.qml</file>
|
||||||
<file>SelectionRangeDetails.qml</file>
|
<file>SelectionRangeDetails.qml</file>
|
||||||
|
<file>magnifier.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@@ -176,19 +176,28 @@ IAnalyzerTool::ToolMode QmlProfilerTool::toolMode() const
|
|||||||
void QmlProfilerTool::showContextMenu(const QPoint &position)
|
void QmlProfilerTool::showContextMenu(const QPoint &position)
|
||||||
{
|
{
|
||||||
QmlProfilerEventsView *senderView = qobject_cast<QmlProfilerEventsView *>(sender());
|
QmlProfilerEventsView *senderView = qobject_cast<QmlProfilerEventsView *>(sender());
|
||||||
|
TraceWindow *traceView = qobject_cast<TraceWindow *>(sender());
|
||||||
|
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
QAction *loadAction = menu.addAction(tr("Load QML Trace"));
|
QAction *loadAction = menu.addAction(tr("Load QML Trace"));
|
||||||
QAction *saveAction = menu.addAction(tr("Save QML Trace"));
|
QAction *saveAction = menu.addAction(tr("Save QML Trace"));
|
||||||
QAction *copyRowAction = 0;
|
QAction *copyRowAction = 0;
|
||||||
QAction *copyTableAction = 0;
|
QAction *copyTableAction = 0;
|
||||||
|
QAction *viewAllAction = 0;
|
||||||
if (senderView) {
|
if (senderView) {
|
||||||
if (senderView->selectedItem().isValid())
|
if (senderView->selectedItem().isValid())
|
||||||
copyRowAction = menu.addAction(tr("Copy Row"));
|
copyRowAction = menu.addAction(tr("Copy Row"));
|
||||||
copyTableAction = menu.addAction(tr("Copy Table"));
|
copyTableAction = menu.addAction(tr("Copy Table"));
|
||||||
}
|
}
|
||||||
|
if (traceView) {
|
||||||
|
if (traceView->getEventList()->count() > 0) {
|
||||||
|
menu.addSeparator();
|
||||||
|
viewAllAction = menu.addAction(tr("Reset Zoom"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QAction *selectedAction = menu.exec(position);
|
QAction *selectedAction = menu.exec(position);
|
||||||
|
|
||||||
if (selectedAction) {
|
if (selectedAction) {
|
||||||
if (selectedAction == loadAction)
|
if (selectedAction == loadAction)
|
||||||
showLoadDialog();
|
showLoadDialog();
|
||||||
@@ -198,6 +207,8 @@ void QmlProfilerTool::showContextMenu(const QPoint &position)
|
|||||||
senderView->copyRowToClipboard();
|
senderView->copyRowToClipboard();
|
||||||
if (selectedAction == copyTableAction)
|
if (selectedAction == copyTableAction)
|
||||||
senderView->copyTableToClipboard();
|
senderView->copyTableToClipboard();
|
||||||
|
if (selectedAction == viewAllAction)
|
||||||
|
traceView->viewAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -44,18 +44,36 @@
|
|||||||
#include <QtGui/QGraphicsObject>
|
#include <QtGui/QGraphicsObject>
|
||||||
#include <QtGui/QContextMenuEvent>
|
#include <QtGui/QContextMenuEvent>
|
||||||
#include <QtGui/QScrollBar>
|
#include <QtGui/QScrollBar>
|
||||||
|
#include <QtGui/QSlider>
|
||||||
#include <QtGui/QWidget>
|
#include <QtGui/QWidget>
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
using namespace QmlJsDebugClient;
|
using namespace QmlJsDebugClient;
|
||||||
|
|
||||||
namespace QmlProfiler {
|
namespace QmlProfiler {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
const int sliderTicks = 10000;
|
||||||
|
const qreal sliderExp = 3;
|
||||||
|
|
||||||
|
void ZoomControl::setRange(qint64 startTime, qint64 endTime)
|
||||||
|
{
|
||||||
|
if (m_startTime != startTime || m_endTime != endTime) {
|
||||||
|
m_startTime = startTime;
|
||||||
|
m_endTime = endTime;
|
||||||
|
emit rangeChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TraceWindow::TraceWindow(QWidget *parent)
|
TraceWindow::TraceWindow(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
setObjectName("QML Profiler");
|
setObjectName("QML Profiler");
|
||||||
|
|
||||||
|
m_zoomControl = new ZoomControl(this);
|
||||||
|
connect(m_zoomControl.data(), SIGNAL(rangeChanged()), this, SLOT(updateRange()));
|
||||||
|
|
||||||
QVBoxLayout *groupLayout = new QVBoxLayout;
|
QVBoxLayout *groupLayout = new QVBoxLayout;
|
||||||
groupLayout->setContentsMargins(0, 0, 0, 0);
|
groupLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
groupLayout->setSpacing(0);
|
groupLayout->setSpacing(0);
|
||||||
@@ -67,6 +85,10 @@ TraceWindow::TraceWindow(QWidget *parent)
|
|||||||
m_mainView->setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
m_mainView->setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
||||||
m_mainView->setFocus();
|
m_mainView->setFocus();
|
||||||
|
|
||||||
|
MouseWheelResizer *resizer = new MouseWheelResizer(this);
|
||||||
|
connect(resizer,SIGNAL(mouseWheelMoved(int,int,int)), this, SLOT(mouseWheelMoved(int,int,int)));
|
||||||
|
m_mainView->viewport()->installEventFilter(resizer);
|
||||||
|
|
||||||
QHBoxLayout *toolsLayout = new QHBoxLayout;
|
QHBoxLayout *toolsLayout = new QHBoxLayout;
|
||||||
|
|
||||||
m_timebar = new QDeclarativeView(this);
|
m_timebar = new QDeclarativeView(this);
|
||||||
@@ -79,6 +101,10 @@ TraceWindow::TraceWindow(QWidget *parent)
|
|||||||
m_overview->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
m_overview->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||||
m_overview->setMaximumHeight(50);
|
m_overview->setMaximumHeight(50);
|
||||||
|
|
||||||
|
m_zoomToolbar = createZoomToolbar();
|
||||||
|
m_zoomToolbar->move(0, m_timebar->height());
|
||||||
|
m_zoomToolbar->setVisible(false);
|
||||||
|
|
||||||
toolsLayout->addWidget(createToolbar());
|
toolsLayout->addWidget(createToolbar());
|
||||||
toolsLayout->addWidget(m_timebar);
|
toolsLayout->addWidget(m_timebar);
|
||||||
|
|
||||||
@@ -99,15 +125,13 @@ TraceWindow::TraceWindow(QWidget *parent)
|
|||||||
|
|
||||||
// Minimum height: 5 rows of 20 pixels + scrollbar of 50 pixels + 20 pixels margin
|
// Minimum height: 5 rows of 20 pixels + scrollbar of 50 pixels + 20 pixels margin
|
||||||
setMinimumHeight(170);
|
setMinimumHeight(170);
|
||||||
|
m_currentZoomLevel = 0;
|
||||||
m_zoomControl = new ZoomControl();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TraceWindow::~TraceWindow()
|
TraceWindow::~TraceWindow()
|
||||||
{
|
{
|
||||||
delete m_plugin.data();
|
delete m_plugin.data();
|
||||||
delete m_v8plugin.data();
|
delete m_v8plugin.data();
|
||||||
delete m_zoomControl.data();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *TraceWindow::createToolbar()
|
QWidget *TraceWindow::createToolbar()
|
||||||
@@ -120,26 +144,27 @@ QWidget *TraceWindow::createToolbar()
|
|||||||
QHBoxLayout *toolBarLayout = new QHBoxLayout(bar);
|
QHBoxLayout *toolBarLayout = new QHBoxLayout(bar);
|
||||||
toolBarLayout->setMargin(0);
|
toolBarLayout->setMargin(0);
|
||||||
toolBarLayout->setSpacing(0);
|
toolBarLayout->setSpacing(0);
|
||||||
|
|
||||||
QToolButton *buttonPrev= new QToolButton;
|
QToolButton *buttonPrev= new QToolButton;
|
||||||
buttonPrev->setIcon(QIcon(":/qmlprofiler/prev.png"));
|
buttonPrev->setIcon(QIcon(":/qmlprofiler/prev.png"));
|
||||||
buttonPrev->setToolTip(tr("Jump to previous event"));
|
buttonPrev->setToolTip(tr("Jump to previous event"));
|
||||||
connect(buttonPrev, SIGNAL(clicked()), this, SIGNAL(jumpToPrev()));
|
connect(buttonPrev, SIGNAL(clicked()), this, SIGNAL(jumpToPrev()));
|
||||||
connect(this, SIGNAL(enableToolbar(bool)), buttonPrev, SLOT(setEnabled(bool)));
|
connect(this, SIGNAL(enableToolbar(bool)), buttonPrev, SLOT(setEnabled(bool)));
|
||||||
|
|
||||||
QToolButton *buttonNext= new QToolButton;
|
QToolButton *buttonNext= new QToolButton;
|
||||||
buttonNext->setIcon(QIcon(":/qmlprofiler/next.png"));
|
buttonNext->setIcon(QIcon(":/qmlprofiler/next.png"));
|
||||||
buttonNext->setToolTip(tr("Jump to next event"));
|
buttonNext->setToolTip(tr("Jump to next event"));
|
||||||
connect(buttonNext, SIGNAL(clicked()), this, SIGNAL(jumpToNext()));
|
connect(buttonNext, SIGNAL(clicked()), this, SIGNAL(jumpToNext()));
|
||||||
connect(this, SIGNAL(enableToolbar(bool)), buttonNext, SLOT(setEnabled(bool)));
|
connect(this, SIGNAL(enableToolbar(bool)), buttonNext, SLOT(setEnabled(bool)));
|
||||||
QToolButton *buttonZoomIn = new QToolButton;
|
|
||||||
buttonZoomIn->setIcon(QIcon(":/qmlprofiler/magnifier-plus.png"));
|
QToolButton *buttonZoomControls = new QToolButton;
|
||||||
buttonZoomIn->setToolTip(tr("Zoom in 10%"));
|
buttonZoomControls->setIcon(QIcon(":/qmlprofiler/magnifier.png"));
|
||||||
connect(buttonZoomIn, SIGNAL(clicked()), this, SIGNAL(zoomIn()));
|
buttonZoomControls->setToolTip(tr("Show zoom slider"));
|
||||||
connect(this, SIGNAL(enableToolbar(bool)), buttonZoomIn, SLOT(setEnabled(bool)));
|
buttonZoomControls->setCheckable(true);
|
||||||
QToolButton *buttonZoomOut = new QToolButton;
|
buttonZoomControls->setChecked(false);
|
||||||
buttonZoomOut->setIcon(QIcon(":/qmlprofiler/magnifier-minus.png"));
|
connect(buttonZoomControls, SIGNAL(toggled(bool)), m_zoomToolbar, SLOT(setVisible(bool)));
|
||||||
buttonZoomOut->setToolTip(tr("Zoom out 10%"));
|
connect(this, SIGNAL(enableToolbar(bool)), buttonZoomControls, SLOT(setEnabled(bool)));
|
||||||
connect(buttonZoomOut, SIGNAL(clicked()), this, SIGNAL(zoomOut()));
|
|
||||||
connect(this, SIGNAL(enableToolbar(bool)), buttonZoomOut, SLOT(setEnabled(bool)));
|
|
||||||
m_buttonRange = new QToolButton;
|
m_buttonRange = new QToolButton;
|
||||||
m_buttonRange->setIcon(QIcon(":/qmlprofiler/range.png"));
|
m_buttonRange->setIcon(QIcon(":/qmlprofiler/range.png"));
|
||||||
m_buttonRange->setToolTip(tr("Select range"));
|
m_buttonRange->setToolTip(tr("Select range"));
|
||||||
@@ -151,13 +176,57 @@ QWidget *TraceWindow::createToolbar()
|
|||||||
|
|
||||||
toolBarLayout->addWidget(buttonPrev);
|
toolBarLayout->addWidget(buttonPrev);
|
||||||
toolBarLayout->addWidget(buttonNext);
|
toolBarLayout->addWidget(buttonNext);
|
||||||
toolBarLayout->addWidget(buttonZoomIn);
|
toolBarLayout->addWidget(buttonZoomControls);
|
||||||
toolBarLayout->addWidget(buttonZoomOut);
|
|
||||||
toolBarLayout->addWidget(m_buttonRange);
|
toolBarLayout->addWidget(m_buttonRange);
|
||||||
|
|
||||||
return bar;
|
return bar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QWidget *TraceWindow::createZoomToolbar()
|
||||||
|
{
|
||||||
|
Utils::StyledBar *bar = new Utils::StyledBar(this);
|
||||||
|
bar->setSingleRow(true);
|
||||||
|
bar->setFixedWidth(150);
|
||||||
|
bar->setFixedHeight(24);
|
||||||
|
|
||||||
|
QHBoxLayout *toolBarLayout = new QHBoxLayout(bar);
|
||||||
|
toolBarLayout->setMargin(0);
|
||||||
|
toolBarLayout->setSpacing(0);
|
||||||
|
|
||||||
|
QSlider *zoomSlider = new QSlider(Qt::Horizontal);
|
||||||
|
zoomSlider->setFocusPolicy(Qt::NoFocus);
|
||||||
|
zoomSlider->setRange(1, sliderTicks);
|
||||||
|
zoomSlider->setInvertedAppearance(true);
|
||||||
|
zoomSlider->setPageStep(sliderTicks/100);
|
||||||
|
connect(this, SIGNAL(enableToolbar(bool)), zoomSlider, SLOT(setEnabled(bool)));
|
||||||
|
connect(zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(setZoomLevel(int)));
|
||||||
|
connect(this, SIGNAL(zoomLevelChanged(int)), zoomSlider, SLOT(setValue(int)));
|
||||||
|
zoomSlider->setStyleSheet("\
|
||||||
|
QSlider:horizontal {\
|
||||||
|
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #444444, stop: 1 #5a5a5a);\
|
||||||
|
border: 1px #313131;\
|
||||||
|
height: 20px;\
|
||||||
|
margin: 0px 0px 0px 0px;\
|
||||||
|
}\
|
||||||
|
QSlider::groove:horizontal {\
|
||||||
|
position: absolute;\
|
||||||
|
}\
|
||||||
|
QSlider::add-page:horizontal {\
|
||||||
|
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #5a5a5a, stop: 1 #444444);\
|
||||||
|
border: 1px #313131;\
|
||||||
|
}\
|
||||||
|
QSlider::sub-page:horizontal {\
|
||||||
|
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #5a5a5a, stop: 1 #444444);\
|
||||||
|
border: 1px #313131;\
|
||||||
|
}\
|
||||||
|
");
|
||||||
|
|
||||||
|
toolBarLayout->addWidget(zoomSlider);
|
||||||
|
|
||||||
|
return bar;
|
||||||
|
}
|
||||||
|
|
||||||
void TraceWindow::reset(QDeclarativeDebugConnection *conn)
|
void TraceWindow::reset(QDeclarativeDebugConnection *conn)
|
||||||
{
|
{
|
||||||
if (m_plugin)
|
if (m_plugin)
|
||||||
@@ -198,8 +267,9 @@ void TraceWindow::reset(QDeclarativeDebugConnection *conn)
|
|||||||
connect(m_eventList, SIGNAL(countChanged()), this, SLOT(updateToolbar()));
|
connect(m_eventList, SIGNAL(countChanged()), this, SLOT(updateToolbar()));
|
||||||
connect(this, SIGNAL(jumpToPrev()), m_mainView->rootObject(), SLOT(prevEvent()));
|
connect(this, SIGNAL(jumpToPrev()), m_mainView->rootObject(), SLOT(prevEvent()));
|
||||||
connect(this, SIGNAL(jumpToNext()), m_mainView->rootObject(), SLOT(nextEvent()));
|
connect(this, SIGNAL(jumpToNext()), m_mainView->rootObject(), SLOT(nextEvent()));
|
||||||
connect(this, SIGNAL(zoomIn()), m_mainView->rootObject(), SLOT(zoomIn()));
|
connect(this, SIGNAL(updateViewZoom(QVariant)), m_mainView->rootObject(), SLOT(updateWindowLength(QVariant)));
|
||||||
connect(this, SIGNAL(zoomOut()), m_mainView->rootObject(), SLOT(zoomOut()));
|
connect(this, SIGNAL(wheelZoom(QVariant,QVariant)), m_mainView->rootObject(), SLOT(wheelZoom(QVariant,QVariant)));
|
||||||
|
connect(this, SIGNAL(globalZoom()), m_mainView->rootObject(), SLOT(globalZoom()));
|
||||||
|
|
||||||
connect(this, SIGNAL(internalClearDisplay()), m_mainView->rootObject(), SLOT(clearAll()));
|
connect(this, SIGNAL(internalClearDisplay()), m_mainView->rootObject(), SLOT(clearAll()));
|
||||||
connect(this,SIGNAL(internalClearDisplay()), m_overview->rootObject(), SLOT(clearDisplay()));
|
connect(this,SIGNAL(internalClearDisplay()), m_overview->rootObject(), SLOT(clearDisplay()));
|
||||||
@@ -311,5 +381,56 @@ void TraceWindow::resizeEvent(QResizeEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MouseWheelResizer::eventFilter(QObject *obj, QEvent *event)
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::Wheel) {
|
||||||
|
QWheelEvent *ev = static_cast<QWheelEvent *>(event);
|
||||||
|
if (ev->modifiers() & Qt::ControlModifier) {
|
||||||
|
emit mouseWheelMoved(ev->pos().x(), ev->pos().y(), ev->delta());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QObject::eventFilter(obj, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TraceWindow::mouseWheelMoved(int x, int y, int delta)
|
||||||
|
{
|
||||||
|
Q_UNUSED(y);
|
||||||
|
if (m_mainView->rootObject()) {
|
||||||
|
emit wheelZoom(QVariant(x), QVariant(delta));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TraceWindow::viewAll()
|
||||||
|
{
|
||||||
|
emit globalZoom();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TraceWindow::setZoomLevel(int zoomLevel)
|
||||||
|
{
|
||||||
|
if (m_currentZoomLevel != zoomLevel && m_mainView->rootObject()) {
|
||||||
|
qreal newFactor = pow(qreal(zoomLevel) / qreal(sliderTicks), sliderExp);
|
||||||
|
m_currentZoomLevel = zoomLevel;
|
||||||
|
emit updateViewZoom(QVariant(newFactor));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TraceWindow::updateRange()
|
||||||
|
{
|
||||||
|
if (!m_eventList)
|
||||||
|
return;
|
||||||
|
qreal duration = m_zoomControl.data()->endTime() - m_zoomControl.data()->startTime();
|
||||||
|
if (duration <= 0)
|
||||||
|
return;
|
||||||
|
qreal totalTime = m_eventList->traceEndTime() - m_eventList->traceStartTime();
|
||||||
|
if (totalTime <= 0)
|
||||||
|
return;
|
||||||
|
int newLevel = pow(duration / totalTime, 1/sliderExp) * sliderTicks;
|
||||||
|
if (m_currentZoomLevel != newLevel) {
|
||||||
|
m_currentZoomLevel = newLevel;
|
||||||
|
emit zoomLevelChanged(newLevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace QmlProfiler
|
} // namespace QmlProfiler
|
||||||
|
@@ -42,6 +42,8 @@
|
|||||||
#include <QtGui/QWidget>
|
#include <QtGui/QWidget>
|
||||||
#include <QtGui/QToolButton>
|
#include <QtGui/QToolButton>
|
||||||
|
|
||||||
|
#include <QtCore/QEvent>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QDeclarativeView;
|
class QDeclarativeView;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
@@ -49,6 +51,16 @@ QT_END_NAMESPACE
|
|||||||
namespace QmlProfiler {
|
namespace QmlProfiler {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
class MouseWheelResizer : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
MouseWheelResizer(QObject *parent=0):QObject(parent){}
|
||||||
|
protected:
|
||||||
|
bool eventFilter(QObject *obj, QEvent *event);
|
||||||
|
signals:
|
||||||
|
void mouseWheelMoved(int x, int y, int delta);
|
||||||
|
};
|
||||||
|
|
||||||
// centralized zoom control
|
// centralized zoom control
|
||||||
class ZoomControl : public QObject {
|
class ZoomControl : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -56,13 +68,7 @@ public:
|
|||||||
ZoomControl(QObject *parent=0):QObject(parent),m_startTime(0),m_endTime(0) {}
|
ZoomControl(QObject *parent=0):QObject(parent),m_startTime(0),m_endTime(0) {}
|
||||||
~ZoomControl(){}
|
~ZoomControl(){}
|
||||||
|
|
||||||
Q_INVOKABLE void setRange(qint64 startTime, qint64 endTime) {
|
Q_INVOKABLE void setRange(qint64 startTime, qint64 endTime);
|
||||||
if (m_startTime != startTime || m_endTime != endTime) {
|
|
||||||
m_startTime = startTime;
|
|
||||||
m_endTime = endTime;
|
|
||||||
emit rangeChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Q_INVOKABLE qint64 startTime() { return m_startTime; }
|
Q_INVOKABLE qint64 startTime() { return m_startTime; }
|
||||||
Q_INVOKABLE qint64 endTime() { return m_endTime; }
|
Q_INVOKABLE qint64 endTime() { return m_endTime; }
|
||||||
|
|
||||||
@@ -88,6 +94,7 @@ public:
|
|||||||
|
|
||||||
void setRecording(bool recording);
|
void setRecording(bool recording);
|
||||||
bool isRecording() const;
|
bool isRecording() const;
|
||||||
|
void viewAll();
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@@ -97,7 +104,9 @@ public slots:
|
|||||||
void updateToolbar();
|
void updateToolbar();
|
||||||
void toggleRangeMode(bool);
|
void toggleRangeMode(bool);
|
||||||
void updateRangeButton();
|
void updateRangeButton();
|
||||||
|
void setZoomLevel(int zoomLevel);
|
||||||
|
void updateRange();
|
||||||
|
void mouseWheelMoved(int x, int y, int delta);
|
||||||
|
|
||||||
void qmlComplete();
|
void qmlComplete();
|
||||||
void v8Complete();
|
void v8Complete();
|
||||||
@@ -114,16 +123,19 @@ signals:
|
|||||||
void internalClearDisplay();
|
void internalClearDisplay();
|
||||||
void jumpToPrev();
|
void jumpToPrev();
|
||||||
void jumpToNext();
|
void jumpToNext();
|
||||||
void zoomIn();
|
|
||||||
void zoomOut();
|
|
||||||
void rangeModeChanged(bool);
|
void rangeModeChanged(bool);
|
||||||
void enableToolbar(bool);
|
void enableToolbar(bool);
|
||||||
|
void zoomLevelChanged(int);
|
||||||
|
void updateViewZoom(QVariant zoomLevel);
|
||||||
|
void wheelZoom(QVariant wheelCenter, QVariant wheelDelta);
|
||||||
|
void globalZoom();
|
||||||
|
|
||||||
void contextMenuRequested(const QPoint& position);
|
void contextMenuRequested(const QPoint& position);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void contextMenuEvent(QContextMenuEvent *);
|
void contextMenuEvent(QContextMenuEvent *);
|
||||||
QWidget *createToolbar();
|
QWidget *createToolbar();
|
||||||
|
QWidget *createZoomToolbar();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void resizeEvent(QResizeEvent *event);
|
virtual void resizeEvent(QResizeEvent *event);
|
||||||
@@ -143,6 +155,8 @@ private:
|
|||||||
QWeakPointer<ZoomControl> m_zoomControl;
|
QWeakPointer<ZoomControl> m_zoomControl;
|
||||||
|
|
||||||
QToolButton *m_buttonRange;
|
QToolButton *m_buttonRange;
|
||||||
|
QWidget *m_zoomToolbar;
|
||||||
|
int m_currentZoomLevel;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
Reference in New Issue
Block a user