diff options
author | Dominik Holland <dominik.holland@qt.io> | 2021-06-14 10:31:03 +0200 |
---|---|---|
committer | Dominik Holland <dominik.holland@qt.io> | 2021-06-16 09:40:47 +0000 |
commit | f9016ae603cbfbfd7165626ff7eabbeeacb6f1f3 (patch) | |
tree | 80a86a01f67bfa5bbb2a79cacdb2e8209b4721df /examples/ifmedia/tuner | |
parent | 59c60668ada002c3c4d77e30520be840bed758f6 (diff) |
Rename all files to match the new module name
This is a follow-up of the previous commit.
Task-number: AUTOSUITE-1633
Change-Id: I6feb63a346a4c94c434df83cd1255904fe8acc68
Reviewed-by: Robert Griebl <robert.griebl@qt.io>
Diffstat (limited to 'examples/ifmedia/tuner')
-rw-r--r-- | examples/ifmedia/tuner/CMakeLists.txt | 56 | ||||
-rw-r--r-- | examples/ifmedia/tuner/main.cpp | 64 | ||||
-rw-r--r-- | examples/ifmedia/tuner/main.qml | 313 | ||||
-rw-r--r-- | examples/ifmedia/tuner/qml.qrc | 5 | ||||
-rw-r--r-- | examples/ifmedia/tuner/tuner.pro | 16 |
5 files changed, 454 insertions, 0 deletions
diff --git a/examples/ifmedia/tuner/CMakeLists.txt b/examples/ifmedia/tuner/CMakeLists.txt new file mode 100644 index 00000000..4d534b0c --- /dev/null +++ b/examples/ifmedia/tuner/CMakeLists.txt @@ -0,0 +1,56 @@ +# Generated from tuner.pro. + +cmake_minimum_required(VERSION 3.14) +project(tuner LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +if(NOT DEFINED INSTALL_EXAMPLESDIR) + set(INSTALL_EXAMPLESDIR "examples") +endif() + +set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/ifmedia/tuner") + +find_package(Qt6 COMPONENTS Core) +find_package(Qt6 COMPONENTS Gui) +find_package(Qt6 COMPONENTS Qml) +find_package(Qt6 COMPONENTS Quick) +find_package(Qt6 COMPONENTS InterfaceFramework) + +qt_add_executable(tuner + main.cpp +) +set_target_properties(tuner PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE +) +target_link_libraries(tuner PUBLIC + Qt::Core + Qt::Gui + Qt::InterfaceFramework + Qt::Qml + Qt::Quick +) + + +# Resources: +set(qml_resource_files + "main.qml" +) + +qt6_add_resources(tuner "qml" + PREFIX + "/" + FILES + ${qml_resource_files} +) + +install(TARGETS tuner + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/ifmedia/tuner/main.cpp b/examples/ifmedia/tuner/main.cpp new file mode 100644 index 00000000..0022cd0e --- /dev/null +++ b/examples/ifmedia/tuner/main.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtInterfaceFramework module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + + return app.exec(); +} diff --git a/examples/ifmedia/tuner/main.qml b/examples/ifmedia/tuner/main.qml new file mode 100644 index 00000000..23591547 --- /dev/null +++ b/examples/ifmedia/tuner/main.qml @@ -0,0 +1,313 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtInterfaceFramework module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Controls 2.15 +import QtQuick.Layouts 1.1 +import QtInterfaceFramework 1.0 +import QtInterfaceFramework.Media 1.0 + +ApplicationWindow { + visible: true + width: 1000 + height: 500 + title: qsTr("Tuner") + + //![1] + AmFmTuner { + id: tuner + + band: bandGroup.checkedButton.text === "AM" ? AmFmTuner.AMBand : AmFmTuner.FMBand + + onScanStarted: { + console.log("A Station SCAN has been started") + } + + onScanStopped: { + console.log("A Station SCAN has been stopped") + } + } + //![1] + + SplitView { + id: splitView1 + anchors.fill: parent + + //![2] + ColumnLayout { + + RowLayout { + Label { text: "Station:" } + Label { text: tuner.station.stationName } + } + + RowLayout { + Label { text: "Frequency:" } + Label { text: tuner.frequency } + } + + RowLayout { + Label { text: "Band:" } + RadioButton { text: "AM"; ButtonGroup.group: bandGroup; checked: tuner.band === AmFmTuner.AMBand } + RadioButton { text: "FM"; ButtonGroup.group: bandGroup; checked: tuner.band === AmFmTuner.FMBand } + } + + GroupBox { + title: "Band settings" + ColumnLayout { + RowLayout { + Label { text: "Step Size:" } + Label { text: tuner.stepSize } + } + + RowLayout { + Label { text: "Minimum Frequency:" } + Label { text: tuner.minimumFrequency } + } + + RowLayout { + Label { text: "Maximum Frequency::" } + Label { text: tuner.maximumFrequency } + } + } + } + + ButtonGroup { + id: bandGroup + } + + RowLayout { + Button { + text: "<-" + onClicked: tuner.seekDown() + } + + Button { + text: "<" + onClicked: tuner.stepDown() + } + + Button { + text: "Scan" + checkable: true + onClicked: { + if (checked) + tuner.startScan(); + else + tuner.stopScan(); + } + } + + Button { + text: ">" + onClicked: tuner.stepUp() + } + + Button { + text: "->" + onClicked: tuner.seekUp() + } + } + + Item { + Layout.fillHeight: true + } + + } + //![2] + + //![3] + ListView { + spacing: 8 + clip: true + + width: 300 + Layout.fillHeight: true + + //![4] + model: FilterAndBrowseModel { + serviceObject: tuner.serviceObject + contentType: "station" + } + //![4] + + delegate: Rectangle { + width: ListView.view.width + height: column.height + color: "#efefef" + + //![5] + MouseArea { + anchors.fill: parent + onClicked: { + tuner.tune(model.item) + } + } + //![5] + + Row { + anchors.fill: parent + Column { + id: column + width: parent.width * 9 / 10 + + Text { text: "Name: " + model.item.stationName } + Text { text: "Type: " + model.item.frequency } + } + + //![6] + Button { + id: addButton + text: "+" + width: parent.width / 10 + height: parent.height + + onClicked: { + presetsModel.insert(0, model.item) + } + + function checkExists() { + presetsModel.indexOf(model.item).then(function (index) { + addButton.enabled = (index === -1) + }) + } + + Component.onCompleted: { + checkExists() + } + + Connections { + target: presetsModel + function onCountChanged() { + addButton.checkExists() + } + } + } + //![6] + } + } + } + //![3] + + //![7] + ListView { + spacing: 8 + clip: true + Layout.fillWidth: true + + model: FilterAndBrowseModel { + id: presetsModel + serviceObject: tuner.serviceObject + contentType: "presets" + } + + delegate: Rectangle { + width: ListView.view.width + height: column.height + color: "#efefef" + + MouseArea { + anchors.fill: parent + onClicked: { + tuner.tune(model.item) + } + } + + Row { + anchors.fill: parent + Column { + id: column + width: parent.width * 7 / 10 + + Text { text: "Name: " + model.item.stationName } + Text { text: "Type: " + model.item.frequency } + } + + Button { + text: "\u2227" + width: parent.width / 10 + height: parent.height + + enabled: index > 0 + + onClicked: { + presetsModel.move(index, index - 1) + } + } + + Button { + text: "\u2228" + width: parent.width / 10 + height: parent.height + + enabled: index < presetsModel.count -1 + + onClicked: { + presetsModel.move(index, index + 1) + } + } + + Button { + text: "X" + width: parent.width / 10 + height: parent.height + + onClicked: { + presetsModel.remove(index) + } + } + } + } + } + //![7] + } +} diff --git a/examples/ifmedia/tuner/qml.qrc b/examples/ifmedia/tuner/qml.qrc new file mode 100644 index 00000000..5f6483ac --- /dev/null +++ b/examples/ifmedia/tuner/qml.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + </qresource> +</RCC> diff --git a/examples/ifmedia/tuner/tuner.pro b/examples/ifmedia/tuner/tuner.pro new file mode 100644 index 00000000..7a21f132 --- /dev/null +++ b/examples/ifmedia/tuner/tuner.pro @@ -0,0 +1,16 @@ +TEMPLATE = app + +QT += qml quick interfaceframework + +CONFIG += c++11 + +SOURCES += main.cpp + +RESOURCES += qml.qrc + +# Additional import path used to resolve QML modules in Qt Creator's code model +QML_IMPORT_PATH = + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/ifmedia/tuner +INSTALLS += target |