chore(Tracer): Simplify by using Timer instead of Animation

This commit is contained in:
Michał Cieślak 2023-09-22 17:09:36 +02:00 committed by Michał
parent fe0b0ee795
commit c61fd6057b
1 changed files with 18 additions and 20 deletions

View File

@ -1,6 +1,6 @@
import QtQuick 2.14 import QtQuick 2.15
import QtQuick.Controls 2.14 import QtQuick.Controls 2.15
import QtQuick.Layouts 1.14 import QtQuick.Layouts 1.15
Rectangle { Rectangle {
id: root id: root
@ -10,31 +10,29 @@ Rectangle {
color: 'transparent' color: 'transparent'
QtObject { QtObject {
id: internal id: d
property Item originalParent property Item originalParent
property int counter: 0
PropertyAnimation on counter {
id: positionUpdater
running: false
from: 0
to: 1000
duration: 1000
loops: Animation.Infinite
} }
onCounterChanged: { Timer {
const overlay = originalParent.Overlay.overlay id: positionUpdateTimer
interval: 500
repeat: true
triggeredOnStart: true
onTriggered: {
const overlay = d.originalParent.Overlay.overlay
if (!overlay) if (!overlay)
return return
root.parent = overlay root.parent = overlay
root.visible = originalParent.visible root.visible = d.originalParent.visible
const rect = originalParent.mapToItem( const rect = d.originalParent.mapToItem(overlay, 0, 0,
overlay, 0, 0, originalParent.width, originalParent.height) d.originalParent.width,
d.originalParent.height)
root.x = rect.x root.x = rect.x
root.y = rect.y root.y = rect.y
root.width = rect.width root.width = rect.width
@ -51,8 +49,8 @@ Rectangle {
|| parent instanceof Row || parent instanceof Row
|| parent instanceof Grid || parent instanceof Grid
|| parent instanceof Flow) { || parent instanceof Flow) {
internal.originalParent = parent d.originalParent = parent
positionUpdater.running = true positionUpdateTimer.running = true
} else { } else {
if (!anchors.fill) if (!anchors.fill)
anchors.fill = parent anchors.fill = parent