forked from qt-creator/qt-creator
QmlProfiler: Reimplement zoom slider in QML
This restores the functionality of the old zoom slider. It probably looks a bit different, but it does the same thing. Task-number: QTCREATORBUG-10635 Change-Id: Idcb19187df066e4b1336df73b122aa567a732dee Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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<QObject*>(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<QObject*>(QLatin1String("zoomSliderToolBar")), "setZoomLevel", Q_ARG(QVariant, newLevel));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -137,6 +137,7 @@ signals:
|
||||
void lockModeChanged(bool);
|
||||
void enableToolbar(bool);
|
||||
void zoomLevelChanged(int);
|
||||
void showZoomSlider(bool);
|
||||
|
||||
void resized();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user