diff --git a/src/plugins/qmlprofiler/qml/MainView.qml b/src/plugins/qmlprofiler/qml/MainView.qml index c80a56f5c5f..72a32737356 100644 --- a/src/plugins/qmlprofiler/qml/MainView.qml +++ b/src/plugins/qmlprofiler/qml/MainView.qml @@ -29,6 +29,7 @@ import QtQuick 2.1 import Monitor 1.0 +import QtQuick.Controls 1.0 Rectangle { id: root @@ -561,6 +562,34 @@ Rectangle { id: rangeDetails } + Rectangle { + objectName: "zoomSliderToolBar" + color: "#9b9b9b" + enabled: false + visible: false + width: labels.width + height: 24 + x: 0 + y: 0 + + signal zoomLevelChanged(int value) + function toggleEnabled() {enabled = !enabled} + function toggleVisible() {visible = !visible} + function setZoomLevel(level) {zoomSlider.value = level} + + Slider { + id: zoomSlider + anchors.fill: parent + minimumValue: 1 + maximumValue: 10000 + stepSize: 100 + + // For some reason the child may generate a meaningless value + // change event before the parent is initialized. + onValueChanged: if (parent) parent.zoomLevelChanged(value) + } + } + Item { anchors.right: root.right width: 6 diff --git a/src/plugins/qmlprofiler/qmlprofilertraceview.cpp b/src/plugins/qmlprofiler/qmlprofilertraceview.cpp index b82448a0ded..004c47cd62c 100644 --- a/src/plugins/qmlprofiler/qmlprofilertraceview.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertraceview.cpp @@ -233,6 +233,11 @@ void QmlProfilerTraceView::reset() connect(this, SIGNAL(jumpToNext()), rootObject, SLOT(nextEvent())); connect(rootObject, SIGNAL(selectedEventChanged(int)), this, SIGNAL(selectedEventChanged(int))); connect(rootObject, SIGNAL(changeToolTip(QString)), this, SLOT(updateToolTip(QString))); + + QObject *zoomSlider = rootObject->findChild(QLatin1String("zoomSliderToolBar")); + connect(this, SIGNAL(enableToolbar(bool)), zoomSlider, SLOT(toggleEnabled())); + connect(zoomSlider, SIGNAL(zoomLevelChanged(int)), this, SLOT(setZoomLevel(int))); + connect(this, SIGNAL(showZoomSlider(bool)), zoomSlider, SLOT(toggleVisible())); } QWidget *QmlProfilerTraceView::createToolbar() @@ -264,6 +269,7 @@ QWidget *QmlProfilerTraceView::createToolbar() buttonZoomControls->setToolTip(tr("Show zoom slider")); buttonZoomControls->setCheckable(true); buttonZoomControls->setChecked(false); + connect(buttonZoomControls, SIGNAL(toggled(bool)), this, SIGNAL(showZoomSlider(bool))); connect(this, SIGNAL(enableToolbar(bool)), buttonZoomControls, SLOT(setEnabled(bool))); d->m_buttonRange = new QToolButton; @@ -425,6 +431,7 @@ void QmlProfilerTraceView::updateRange() if (d->m_currentZoomLevel != newLevel) { d->m_currentZoomLevel = newLevel; emit zoomLevelChanged(newLevel); + QMetaObject::invokeMethod(d->m_mainView->rootObject()->findChild(QLatin1String("zoomSliderToolBar")), "setZoomLevel", Q_ARG(QVariant, newLevel)); } } diff --git a/src/plugins/qmlprofiler/qmlprofilertraceview.h b/src/plugins/qmlprofiler/qmlprofilertraceview.h index 5ac42601fae..1dc517529fa 100644 --- a/src/plugins/qmlprofiler/qmlprofilertraceview.h +++ b/src/plugins/qmlprofiler/qmlprofilertraceview.h @@ -137,6 +137,7 @@ signals: void lockModeChanged(bool); void enableToolbar(bool); void zoomLevelChanged(int); + void showZoomSlider(bool); void resized();