diff options
author | Ulf Hermann <ulf.hermann@digia.com> | 2013-11-20 15:57:07 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@digia.com> | 2013-12-02 12:12:29 +0100 |
commit | 2f8f51912c68123b6bf526f84a8a7d2f2c0ecead (patch) | |
tree | f8695d1ed67b1fdea3306f8c688073af75e252bd | |
parent | 0489adf0cb9f101b0d7b28fc28c477f115482a4e (diff) | |
download | qt-creator-2f8f51912c68123b6bf526f84a8a7d2f2c0ecead.tar.gz |
QmlProfiler: improve selection behavior in timeline
When selecting ranges in the timeline the selector would sometimes hang
or behave weirdly when moving back. This was due to incorrect logic in
the selection bounds calculation and because the vertical flicking would
steal mouse events.
Change-Id: I14074463422d1d9a0aa8ecd1f88847e7330c9b6b
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Reviewed-by: Ulf Hermann <ulf.hermann@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
-rw-r--r-- | src/plugins/qmlprofiler/qml/MainView.qml | 10 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qml/SelectionRange.qml | 21 |
2 files changed, 22 insertions, 9 deletions
diff --git a/src/plugins/qmlprofiler/qml/MainView.qml b/src/plugins/qmlprofiler/qml/MainView.qml index e8bce8ea0d..8d8fe25d69 100644 --- a/src/plugins/qmlprofiler/qml/MainView.qml +++ b/src/plugins/qmlprofiler/qml/MainView.qml @@ -309,8 +309,11 @@ Rectangle { boundsBehavior: Flickable.StopAtBounds // ScrollView will try to deinteractivate it. We don't want that - // as the horizontal flickable is interactive, too. - onInteractiveChanged: interactive = true + // as the horizontal flickable is interactive, too. We do occasionally + // switch to non-interactive ourselves, though. + property bool stayInteractive: true + onInteractiveChanged: interactive = stayInteractive + onStayInteractiveChanged: interactive = stayInteractive // ***** child items TimeMarks { @@ -429,6 +432,9 @@ Rectangle { onPressed: { selectionRange.pressedOnCreation(); } + onCanceled: { + selectionRange.releasedOnCreation(); + } onPositionChanged: { selectionRange.movedOnCreation(); } diff --git a/src/plugins/qmlprofiler/qml/SelectionRange.qml b/src/plugins/qmlprofiler/qml/SelectionRange.qml index 78e09cfb40..381aa27c74 100644 --- a/src/plugins/qmlprofiler/qml/SelectionRange.qml +++ b/src/plugins/qmlprofiler/qml/SelectionRange.qml @@ -42,6 +42,7 @@ RangeMover { property real duration: Math.max(getWidth() * viewTimePerPixel, 500) property real viewTimePerPixel: 1 property int creationState : 0 + property int creationReference : 0 Connections { target: zoomControl @@ -65,6 +66,7 @@ RangeMover { function reset(setVisible) { setRight(getLeft() + 1); creationState = 0; + creationReference = 0; visible = setVisible; } @@ -75,18 +77,21 @@ RangeMover { pos = width; switch (creationState) { - case 1: { + case 1: + creationReference = pos; setLeft(pos); setRight(pos + 1); break; - } - case 2: { - setLeft(Math.min(getLeft(), pos)); - setRight(Math.max(getRight(), pos)); + case 2: + if (pos > creationReference) { + setLeft(creationReference); + setRight(pos); + } else if (pos < creationReference) { + setLeft(pos); + setRight(creationReference); + } break; } - default: return; - } } @@ -104,6 +109,7 @@ RangeMover { function releasedOnCreation() { if (selectionRange.creationState === 2) { flick.interactive = true; + vertflick.stayInteractive = true; selectionRange.creationState = 3; selectionRangeControl.enabled = false; } @@ -112,6 +118,7 @@ RangeMover { function pressedOnCreation() { if (selectionRange.creationState === 1) { flick.interactive = false; + vertflick.stayInteractive = false; selectionRange.setPos(selectionRangeControl.mouseX + flick.contentX); selectionRange.creationState = 2; } |