diff options
Diffstat (limited to 'examples/multimedia/video/qmlvideo/frequencymonitor')
3 files changed, 100 insertions, 0 deletions
diff --git a/examples/multimedia/video/qmlvideo/frequencymonitor/CMakeLists.txt b/examples/multimedia/video/qmlvideo/frequencymonitor/CMakeLists.txt new file mode 100644 index 000000000..4a205fa28 --- /dev/null +++ b/examples/multimedia/video/qmlvideo/frequencymonitor/CMakeLists.txt @@ -0,0 +1,30 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + message(FATAL_ERROR "This module is part of the 'qmlvideo' example, and should not be built independently.") +endif() + +set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/video/qmlvideo/frequencymonitor") + +qt_add_qml_module(frequencymonitor + URI frequencymonitor + QML_FILES + "FrequencyItem.qml" +) + +target_link_libraries(frequencymonitor PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Quick +) + +install(TARGETS frequencymonitor + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) + +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qmldir + DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/multimedia/video/qmlvideo/frequencymonitor/FrequencyItem.qml b/examples/multimedia/video/qmlvideo/frequencymonitor/FrequencyItem.qml new file mode 100644 index 000000000..49a7eea9b --- /dev/null +++ b/examples/multimedia/video/qmlvideo/frequencymonitor/FrequencyItem.qml @@ -0,0 +1,67 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +import QtQuick +import FrequencyMonitor 1.0 + +Rectangle { + id: root + property bool logging: true + property bool displayed: true + property bool enabled: logging || displayed + property alias active: monitor.active + property int samplingInterval: 500 + property color textColor: "yellow" + property int textSize: 20 + property alias label: monitor.label + + border.width: 1 + border.color: "yellow" + width: 5.5 * root.textSize + height: 3.0 * root.textSize + color: "black" + opacity: 0.5 + radius: 10 + visible: displayed && active + + // This should ensure that the monitor is on top of all other content + z: 999 + + function notify() { + monitor.notify() + } + + FrequencyMonitor { + id: monitor + samplingInterval: root.enabled ? root.samplingInterval : 0 + onAverageFrequencyChanged: { + if (root.logging) trace() + averageFrequencyText.text = monitor.averageFrequency.toFixed(2) + } + } + + Text { + id: labelText + anchors { + left: parent.left + top: parent.top + margins: 10 + } + color: root.textColor + font.pixelSize: 0.6 * root.textSize + text: root.label + width: root.width - 2*anchors.margins + elide: Text.ElideRight + } + + Text { + id: averageFrequencyText + anchors { + right: parent.right + bottom: parent.bottom + margins: 10 + } + color: root.textColor + font.pixelSize: root.textSize + } +} diff --git a/examples/multimedia/video/qmlvideo/frequencymonitor/qmldir b/examples/multimedia/video/qmlvideo/frequencymonitor/qmldir new file mode 100644 index 000000000..a935d2c53 --- /dev/null +++ b/examples/multimedia/video/qmlvideo/frequencymonitor/qmldir @@ -0,0 +1,3 @@ +module frequencymonitor + +FrequencyItem 1.0 FrequencyItem.qml |