diff options
Diffstat (limited to 'basicsuite/qt5-everywhere/demos/radio')
-rw-r--r-- | basicsuite/qt5-everywhere/demos/radio/VolumeButton.qml | 185 | ||||
-rw-r--r-- | basicsuite/qt5-everywhere/demos/radio/VolumePoint.qml | 64 | ||||
-rw-r--r-- | basicsuite/qt5-everywhere/demos/radio/channels.xml | 23 | ||||
-rw-r--r-- | basicsuite/qt5-everywhere/demos/radio/images/radio_btn_pause.png | bin | 1573 -> 0 bytes | |||
-rw-r--r-- | basicsuite/qt5-everywhere/demos/radio/images/radio_btn_play.png | bin | 5402 -> 0 bytes | |||
-rw-r--r-- | basicsuite/qt5-everywhere/demos/radio/images/radio_btn_stop.png | bin | 1388 -> 0 bytes | |||
-rw-r--r-- | basicsuite/qt5-everywhere/demos/radio/images/radio_sound_icon.png | bin | 1972 -> 0 bytes | |||
-rw-r--r-- | basicsuite/qt5-everywhere/demos/radio/images/volume.png | bin | 749 -> 0 bytes | |||
-rw-r--r-- | basicsuite/qt5-everywhere/demos/radio/radio.qml | 285 |
9 files changed, 0 insertions, 557 deletions
diff --git a/basicsuite/qt5-everywhere/demos/radio/VolumeButton.qml b/basicsuite/qt5-everywhere/demos/radio/VolumeButton.qml deleted file mode 100644 index 11b687e..0000000 --- a/basicsuite/qt5-everywhere/demos/radio/VolumeButton.qml +++ /dev/null @@ -1,185 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 Digia Plc and its Subsidiary(-ies) 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.0 - -Item { - id: root - width: size - height: size - - property int steps: 10 - property int size: 0 - property real volume: .5 - property bool playing: false - signal clicked(); - - Item { - id: bg - anchors.fill: parent - - Rectangle { - id: bgRect - - gradient: Gradient { - GradientStop {position: .0; color: "lightgray"} - GradientStop {position: 1.0; color: "white"} - } - - border {width:1; color: "#888888"} - radius: root.size/2 - anchors.centerIn: parent - width: parent.width - height: parent.height - } - - Rectangle { - gradient: Gradient { - GradientStop {position: .0; color: playButtonMouseArea.pressed ? "#052e41": "#095477"} - GradientStop {position: 1.0; color: playButtonMouseArea.pressed ? "#095477": "#052e41"} - } - - border {width:1; color: "#888888"} - radius: width/2 - anchors.centerIn: parent - width: parent.width*.6 - height: parent.height*.6 - - Image { - anchors {fill: parent; margins: parent.height*.3} - source: !root.playing ? "images/radio_btn_play.png" : "images/radio_btn_pause.png" - } - - MouseArea { - id: playButtonMouseArea - anchors.fill: parent - anchors.margins: parent.width*.2 - onClicked:{ - root.clicked() - } - } - } - } - - Item { - id: volumeIndicator - anchors.centerIn: root - width: root.size - height: root.size - z:2 - - Rectangle{ - id: volumeCircle - objectName: "volumeCircle" - anchors {horizontalCenter: parent.horizontalCenter; top: parent.top} - - gradient: Gradient { - GradientStop {position: .1; color: "#095477"} - GradientStop {position: 1.0; color: "#0e82b8"} - } - - width: root.size * .2 - height: width - radius: width/2 - border {width:1; color: "#888888"} - - Image { - anchors {fill: parent; margins: parent.height*.2} - source: "images/radio_sound_icon.png" - rotation: -volumeRotation.angle - } - } - - transform: Rotation { - id: volumeRotation - origin.x: volumeIndicator.width/2 - origin.y: volumeIndicator.height/2 - angle: 270.0*root.volume+225 - } - } - - MouseArea { - id: mouseArea - anchors.fill: volumeIndicator - property bool grabbed: false - anchors.margins: -root.size*.2 - z: -1 - - onPressed: { - var object = mapToItem(volumeIndicator, mouse.x, mouse.y) - var item = volumeIndicator.childAt(object.x,object.y) - if (item && item.objectName === 'volumeCircle') { - grabbed = true - return; - } else { - grabbed = false - } - - object = mapToItem(root, mouse.x, mouse.y) - item = root.childAt(object.x,object.y) - if (item && item.objectName === 'volumePoint') { - root.volume = item.level - } - } - - onPositionChanged: { - if (!grabbed) return; - var ang = (225+Math.atan2((mouse.y-mouseArea.height/2.0), (mouse.x-mouseArea.width/2.0))*180.0/Math.PI) - if (ang >360) ang-=360 - if (ang > 270) return; - root.volume = (ang)/270.0 - } - } - - function init(){ - for (var i=0; i<=root.steps; i++){ - var x=Math.cos(((i)*270/root.steps+135)*0.01745)*root.size*.40 - var y=Math.sin(((i)*270/root.steps+135)*0.01745)*root.size*.40 - var component = Qt.createComponent("VolumePoint.qml") - if (component.status === Component.Ready) { - var object = component.createObject(root); - object.size = root.size*.05 - object.x = root.size/2+x-object.size/2 - object.y = root.size/2+y-object.size/2 - object.level = i/root.steps - } - } - } -} diff --git a/basicsuite/qt5-everywhere/demos/radio/VolumePoint.qml b/basicsuite/qt5-everywhere/demos/radio/VolumePoint.qml deleted file mode 100644 index a491860..0000000 --- a/basicsuite/qt5-everywhere/demos/radio/VolumePoint.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 Digia Plc and its Subsidiary(-ies) 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.0 - -Rectangle { - id: root - objectName: "volumePoint" - width: size - height: size - radius: size/2 - color: volume >= level ? "#0e82b8": "#095477" - border {width:1; color: "#888888"} - property int size: 10 - property real level: 0 - property real volume: parent.volume - - Behavior on color{ColorAnimation { duration: 500 }} - - Item { - id: pointClickArea - objectName: "pointClickArea" - property alias value: root.level - anchors.fill: parent - anchors.margins: -root.size*2 - } -} diff --git a/basicsuite/qt5-everywhere/demos/radio/channels.xml b/basicsuite/qt5-everywhere/demos/radio/channels.xml deleted file mode 100644 index 0ba2bb7..0000000 --- a/basicsuite/qt5-everywhere/demos/radio/channels.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - <radio> - <channel> - <title>BBC World Service</title> - <url>http://vpr.streamguys.net/vpr24.mp3</url> - </channel> - <channel> - <title>"JPR Classics"</title> - <url>http://jpr.streamguys.org:80/jpr-classics</url> - </channel> - <channel> - <title>VPR Classical</title> - <url>http://vprclassical.streamguys.net/vprclassical24.mp3</url> - </channel> - <channel> - <title>VPR Jazz24</title> - <url>http://vprjazz.streamguys.net/vprjazz24.mp3</url> - </channel> - <channel> - <title>Radio Paradise</title> - <url>http://stream-tx1.radioparadise.com/mp3-128</url> - </channel> - </radio> diff --git a/basicsuite/qt5-everywhere/demos/radio/images/radio_btn_pause.png b/basicsuite/qt5-everywhere/demos/radio/images/radio_btn_pause.png Binary files differdeleted file mode 100644 index 5204834..0000000 --- a/basicsuite/qt5-everywhere/demos/radio/images/radio_btn_pause.png +++ /dev/null diff --git a/basicsuite/qt5-everywhere/demos/radio/images/radio_btn_play.png b/basicsuite/qt5-everywhere/demos/radio/images/radio_btn_play.png Binary files differdeleted file mode 100644 index 92ee858..0000000 --- a/basicsuite/qt5-everywhere/demos/radio/images/radio_btn_play.png +++ /dev/null diff --git a/basicsuite/qt5-everywhere/demos/radio/images/radio_btn_stop.png b/basicsuite/qt5-everywhere/demos/radio/images/radio_btn_stop.png Binary files differdeleted file mode 100644 index 187158a..0000000 --- a/basicsuite/qt5-everywhere/demos/radio/images/radio_btn_stop.png +++ /dev/null diff --git a/basicsuite/qt5-everywhere/demos/radio/images/radio_sound_icon.png b/basicsuite/qt5-everywhere/demos/radio/images/radio_sound_icon.png Binary files differdeleted file mode 100644 index ac0b61e..0000000 --- a/basicsuite/qt5-everywhere/demos/radio/images/radio_sound_icon.png +++ /dev/null diff --git a/basicsuite/qt5-everywhere/demos/radio/images/volume.png b/basicsuite/qt5-everywhere/demos/radio/images/volume.png Binary files differdeleted file mode 100644 index a098d82..0000000 --- a/basicsuite/qt5-everywhere/demos/radio/images/volume.png +++ /dev/null diff --git a/basicsuite/qt5-everywhere/demos/radio/radio.qml b/basicsuite/qt5-everywhere/demos/radio/radio.qml deleted file mode 100644 index e81c567..0000000 --- a/basicsuite/qt5-everywhere/demos/radio/radio.qml +++ /dev/null @@ -1,285 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 Digia Plc and its Subsidiary(-ies) 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.0 -import QtMultimedia 5.0 -import QtQuick.XmlListModel 2.0 - -FocusScope { - id: scope - x: parent.x; y: parent.y - width: parent.width; height: parent.height - focus: true - property bool active: false - - Rectangle { - id: root - width:parent.width - height: parent.height - anchors.centerIn: parent - focus: true - color: "#262626" - - Audio { - id: playMusic - source: "" - volume: volumeButton.volume - onSourceChanged: { - if (volumeButton.playing) playMusic.play() - } - onAvailabilityChanged: { - if (availability === Audio.Available) { - if (volumeButton.playing) playMusic.play() - } - } - Component.onDestruction: { - volumeButton.playing = false - playMusic.stop() - playMusic.source = "" - } - } - - Rectangle { - id: playerRect - anchors.top: volumeButton.top - anchors.left: volumeButton.left - anchors.bottom: volumeButton.bottom - anchors.right: parent.right - anchors.rightMargin: parent.height*.05 - gradient: Gradient { - GradientStop {position: .1; color: "lightgrey"} - GradientStop {position: 1.0; color: "white"} - } - border {width:1; color: "#888888"} - radius: height/2 - - Rectangle { - id: displayRect - anchors.fill: parent - anchors.margins: parent.height*.1 - gradient: Gradient { - GradientStop {position: .0; color: "#095477"} - GradientStop {position: 1.0; color: "#052e41"} - } - border {width:1; color: "#888888"} - radius: height/2 - - - Item { - id: networkErrorBox - opacity: 0 - anchors.fill: parent - - Text { - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - anchors.rightMargin: parent.width * 0.1 - text: qsTr("Sorry! No network connection") - font.pixelSize: stationList.height*.1; - color: "white" - smooth: true - } - } - - PathView { - enabled: root.activeFocus - id: stationList - anchors.fill:parent - anchors.leftMargin: parent.height*.9 - model: stationModel - pathItemCount: 6 - clip: true - property int openedIndex: -1 - - onMovementStarted: { - idleTimer.stop() - openedIndex = -1 - pathItemCount = 5 - } - onMovementEnded: idleTimer.restart() - - onOpenedIndexChanged: { - if (openedIndex === -1) return - idleTimer.lastIndex=openedIndex - positionViewAtIndex(openedIndex, PathView.Center) - } - - Timer { - id: idleTimer - interval: 5000 - property int lastIndex: -1 - onTriggered: { - stationList.openedIndex = idleTimer.lastIndex - } - } - - Timer { - id: browseTimer - interval: 500 - property string source:"" - onTriggered: playMusic.source = source - } - - path: Path { - startX: stationList.x; startY: 0 - PathArc { - id: pathArc - x: stationList.x; relativeY: stationList.height*1.1 - radiusX: volumeButton.height/2 - radiusY: volumeButton.height/2 - useLargeArc: false - } - } - - delegate: Item { - id: stationDelegate - property bool opened: stationList.openedIndex === index - width: stationList.width*.7 - height: opened? stationList.height*.4: stationList.height*.2 - - Behavior on height {NumberAnimation{duration:200}} - - Text { - id: delegateText - anchors.left: parent.left - anchors.top: parent.top - text: (index+1) +". " +title - font.pixelSize: stationDelegate.opened? stationList.height*.15 : stationList.height*.1 - font.weight: stationDelegate.opened? Font.Bold: Font.Normal - color: stationList.openedIndex ===-1 || opened? "white": "#0e82b8" - Behavior on font.pixelSize {NumberAnimation{duration:200}} - } - - Text { - id: statustextText - anchors.left: parent.left - anchors.top: delegateText.bottom - - text: playMusic.playbackState=== Audio.PlayingState ? "Playing...": - playMusic.status=== Audio.Buffering ? "Buffering...": - playMusic.status=== Audio.Loading ? "Loading...": - playMusic.playbackState=== Audio.StoppedState ? "Stopped":"Error" - - font.pixelSize: stationList.height*.1 - color: delegateText.color - opacity: opened? 1.0: .0 - Behavior on opacity {NumberAnimation{duration:200}} - } - - - MouseArea { - anchors.fill: parent - visible: root.activeFocus - - onClicked: { - if (opened){ - idleTimer.lastIndex=-1 - stationList.openedIndex=-1 - }else { - stationList.openedIndex= index - browseTimer.source = url - browseTimer.restart() - } - } - } - } - } - } - } - - XmlListModel { - id: stationModel - source: "http://qt-project.org/uploads/videos/qt5_radio_channels.xml" - query: "/radio/channel" - XmlRole {name: "title"; query: "title/string()"} - XmlRole {name: "url"; query: "url/string()"} - - onStatusChanged: { - if (status == XmlListModel.Ready) { - networkErrorBox.opacity = 0; - } else if (status == XmlListModel.Error) { - networkErrorBox.opacity = 1; - } - } - } - - VolumeButton { - id: volumeButton - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: size*.1 - size:parent.height*.5 - playing: playMusic.playbackState === Audio.PlayingState - onClicked: { - if (!playMusic.source) return; - if (!playing) { - playMusic.play() - }else { - playMusic.stop() - } - } - } - - Component.onCompleted: { - volumeButton.init() - scope.focus = true - } - - Keys.onPressed: { - if (event.key === Qt.Key_Down || event.key === Qt.Key_VolumeDown) { - event.accepted = true - if (volumeButton.volume > .1){ - volumeButton.volume-=.1 - }else{ - volumeButton.volume = 0.0 - } - } - - if (event.key === Qt.Key_Up || event.key === Qt.Key_VolumeUp) { - event.accepted = true - if (volumeButton.volume < .9){ - volumeButton.volume+=.1 - }else{ - volumeButton.volume = 1.0 - } - } - } - } -} |