forked from qt-creator/qt-creator
QmlProfiler: Centralize redrawing of custom canvas
Don't handle redraw events in QML anymore and instead trigger a redraw on geometryChange as well as componentComplete from C++. This reduces redundant code and glitches from forgotten QML event handlers. Change-Id: I0eadfb54cf8e392152c4d91b83c874b37b1aca96 Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
@@ -92,6 +92,13 @@ void QmlProfilerCanvas::componentComplete()
|
||||
QMetaObject::connect(this, p.notifySignalIndex(), this, requestPaintMethod, 0, 0);
|
||||
}
|
||||
QQuickItem::componentComplete();
|
||||
requestRedraw();
|
||||
}
|
||||
|
||||
void QmlProfilerCanvas::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
|
||||
{
|
||||
QQuickItem::geometryChanged(newGeometry, oldGeometry);
|
||||
requestRedraw();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ private slots:
|
||||
protected:
|
||||
virtual void paint(QPainter *);
|
||||
virtual void componentComplete();
|
||||
virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
|
||||
|
||||
private:
|
||||
Context2D *m_context2d;
|
||||
|
||||
@@ -38,17 +38,6 @@ Canvas2D {
|
||||
property real endTime : 0
|
||||
property real timePerPixel: 0
|
||||
|
||||
|
||||
Component.onCompleted: {
|
||||
requestRedraw();
|
||||
}
|
||||
onWidthChanged: {
|
||||
requestRedraw();
|
||||
}
|
||||
onHeightChanged: {
|
||||
requestRedraw();
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: zoomControl
|
||||
onRangeChanged: {
|
||||
|
||||
@@ -38,21 +38,6 @@ Canvas2D {
|
||||
property real endTime
|
||||
property real timePerPixel
|
||||
|
||||
Component.onCompleted: {
|
||||
requestRedraw();
|
||||
}
|
||||
|
||||
onWidthChanged: {
|
||||
requestRedraw();
|
||||
}
|
||||
onHeightChanged: {
|
||||
requestRedraw();
|
||||
}
|
||||
|
||||
onYChanged: {
|
||||
requestRedraw();
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: labels
|
||||
onHeightChanged: { requestRedraw(); }
|
||||
|
||||
Reference in New Issue
Block a user