diff options
author | Dominik Holland <dominik.holland@pelagicore.com> | 2016-06-22 16:46:40 +0200 |
---|---|---|
committer | Johan Thelin <johan.thelin@pelagicore.com> | 2016-07-04 06:10:11 +0000 |
commit | 0b023831782fbecc819987dbddf5937a5c32c47c (patch) | |
tree | f099d9953631557f9c8855b6572c2ac2cd0ac62a /examples | |
parent | 11c43c160ce9681acbe300f1e75fecf4ffe52bda (diff) | |
download | qtivi-0b023831782fbecc819987dbddf5937a5c32c47c.tar.gz |
Added a basic AmFmTuner
Including a basic tuner QML example and a simulation backend
Change-Id: I46985d26a5eaa6ab84f19384ef8f08d6206570aa
Task-number: QTAUTO-60
Reviewed-by: Johan Thelin <johan.thelin@pelagicore.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/media/media.pro | 3 | ||||
-rw-r--r-- | examples/media/tuner/main.cpp | 64 | ||||
-rw-r--r-- | examples/media/tuner/main.qml | 153 | ||||
-rw-r--r-- | examples/media/tuner/qml.qrc | 5 | ||||
-rw-r--r-- | examples/media/tuner/tuner.pro | 16 |
5 files changed, 240 insertions, 1 deletions
diff --git a/examples/media/media.pro b/examples/media/media.pro index bf30a2c..ab7c158 100644 --- a/examples/media/media.pro +++ b/examples/media/media.pro @@ -1,2 +1,3 @@ TEMPLATE = subdirs -SUBDIRS = mediaplayer +SUBDIRS = mediaplayer \ + tuner diff --git a/examples/media/tuner/main.cpp b/examples/media/tuner/main.cpp new file mode 100644 index 0000000..1b4c909 --- /dev/null +++ b/examples/media/tuner/main.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite 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$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +#include <QApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + + return app.exec(); +} diff --git a/examples/media/tuner/main.qml b/examples/media/tuner/main.qml new file mode 100644 index 0000000..662173e --- /dev/null +++ b/examples/media/tuner/main.qml @@ -0,0 +1,153 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite 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$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Controls 1.5 +import QtQuick.Layouts 1.1 +import QtIvi 1.0 +import QtIvi.Media 1.0 + +ApplicationWindow { + visible: true + width: 500 + height: 250 + title: qsTr("Tuner") + + AmFmTuner { + id: tuner + + band: bandGroup.current.text === "AM" ? AmFmTuner.AMBand : AmFmTuner.FMBand + } + + SplitView { + id: splitView1 + anchors.fill: parent + + 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"; exclusiveGroup: bandGroup; checked: tuner.band === AmFmTuner.AMBand } + RadioButton { text: "FM"; exclusiveGroup: bandGroup; checked: tuner.band === AmFmTuner.FMBand } + } + + ExclusiveGroup { + id: bandGroup + } + + RowLayout { + Button { + text: "<-" + onClicked: tuner.seekDown() + } + + Button { + text: "<" + onClicked: tuner.stepDown() + } + + Button { + text: ">" + onClicked: tuner.stepUp() + } + + Button { + text: "->" + onClicked: tuner.seekUp() + } + } + } + + ListView { + spacing: 8 + clip: true + Layout.fillHeight: true + Layout.fillWidth: true + + model: SearchAndBrowseModel { + serviceObject: tuner.serviceObject + contentType: "station" + } + + delegate: Rectangle { + width: ListView.view.width + height: column.height + color: "#efefef" + + Column { + id: column + width: parent.width + + Text { text: "Name: " + model.item.stationName } + Text { text: "Type: " + model.item.frequency } + } + + MouseArea { + anchors.fill: parent + onClicked: { + tuner.tune(model.item) + } + } + } + } + } +} diff --git a/examples/media/tuner/qml.qrc b/examples/media/tuner/qml.qrc new file mode 100644 index 0000000..5f6483a --- /dev/null +++ b/examples/media/tuner/qml.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + </qresource> +</RCC> diff --git a/examples/media/tuner/tuner.pro b/examples/media/tuner/tuner.pro new file mode 100644 index 0000000..f8ac5ed --- /dev/null +++ b/examples/media/tuner/tuner.pro @@ -0,0 +1,16 @@ +TEMPLATE = app + +QT += qml quick widgets ivicore + +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]/media/tuner +INSTALLS += target |