summaryrefslogtreecommitdiffstats
path: root/examples/video/snippets/performancemonitor/qml/performancemonitor/PerformanceItem.qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/video/snippets/performancemonitor/qml/performancemonitor/PerformanceItem.qml')
-rw-r--r--examples/video/snippets/performancemonitor/qml/performancemonitor/PerformanceItem.qml103
1 files changed, 67 insertions, 36 deletions
diff --git a/examples/video/snippets/performancemonitor/qml/performancemonitor/PerformanceItem.qml b/examples/video/snippets/performancemonitor/qml/performancemonitor/PerformanceItem.qml
index dd38aaeca..5bdfa3e8b 100644
--- a/examples/video/snippets/performancemonitor/qml/performancemonitor/PerformanceItem.qml
+++ b/examples/video/snippets/performancemonitor/qml/performancemonitor/PerformanceItem.qml
@@ -46,65 +46,96 @@ Rectangle {
property bool logging: true
property bool displayed: true
property bool videoActive
- property int samplingInterval: 500
- property color textColor: "yellow"
- property int textSize: 28
property int margins: 5
+ property bool enabled: true
color: "transparent"
// This should ensure that the monitor is on top of all other content
z: 999
- Loader {
- id: videoFrameRateItemLoader
- function init() {
- source = "../frequencymonitor/FrequencyItem.qml"
- item.label = "videoFrameRate"
- item.parent = root
- item.anchors.left = root.left
- item.anchors.top = root.top
- item.anchors.margins = root.margins
- item.logging = root.logging
- item.displayed = root.displayed
- videoFrameRateActiveConnections.target = item
+ Column {
+ id: column
+ anchors {
+ fill: root
+ margins: 10
}
+ spacing: 10
+ }
- Connections {
- id: videoFrameRateActiveConnections
- ignoreUnknownSignals: true
- onActiveChanged: root.videoActive = videoFrameRateActiveConnections.target.active
- }
+ QtObject {
+ id: d
+ property Item qmlFrameRateItem: null
+ property Item videoFrameRateItem: null
+ }
+
+ Connections {
+ id: videoFrameRateActiveConnections
+ ignoreUnknownSignals: true
+ onActiveChanged: root.videoActive = videoFrameRateActiveConnections.target.active
}
- Loader {
- id: qmlFrameRateItemLoader
- function init() {
- source = "../frequencymonitor/FrequencyItem.qml"
- item.label = "qmlFrameRate"
- item.parent = root
- item.anchors.left = root.left
- item.anchors.bottom = root.bottom
- item.anchors.margins = root.margins
- item.logging = root.logging
- item.displayed = root.displayed
+ states: [
+ State {
+ name: "hidden"
+ PropertyChanges {
+ target: root
+ opacity: 0
+ }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ from: "*"
+ to: "*"
+ NumberAnimation {
+ properties: "opacity"
+ easing.type: Easing.OutQuart
+ duration: 500
+ }
}
+ ]
+
+ state: enabled ? "baseState" : "hidden"
+
+ function createQmlFrameRateItem() {
+ var component = Qt.createComponent("../frequencymonitor/FrequencyItem.qml")
+ if (component.status == Component.Ready)
+ d.qmlFrameRateItem = component.createObject(column, { label: "QML frame rate",
+ displayed: root.displayed,
+ logging: root.logging
+ })
}
+ function createVideoFrameRateItem() {
+ var component = Qt.createComponent("../frequencymonitor/FrequencyItem.qml")
+ if (component.status == Component.Ready)
+ d.videoFrameRateItem = component.createObject(column, { label: "Video frame rate",
+ displayed: root.displayed,
+ logging: root.logging
+ })
+ videoFrameRateActiveConnections.target = d.videoFrameRateItem
+ }
+
+
function init() {
- videoFrameRateItemLoader.init()
- qmlFrameRateItemLoader.init()
+ createQmlFrameRateItem()
+ createVideoFrameRateItem()
}
function videoFramePainted() {
- videoFrameRateItemLoader.item.notify()
+ if (d.videoFrameRateItem)
+ d.videoFrameRateItem.notify()
}
function qmlFramePainted() {
- qmlFrameRateItemLoader.item.notify()
+ if (d.qmlFrameRateItem)
+ d.qmlFrameRateItem.notify()
}
onVideoActiveChanged: {
- videoFrameRateItemLoader.item.active = root.videoActive
+ if (d.videoFrameRateItem)
+ d.videoFrameRateItem.active = root.videoActive
}
}