diff options
author | Lasse Räihä <lasse.raiha@digia.com> | 2013-05-29 08:21:35 +0300 |
---|---|---|
committer | Kimmo Ollila <kimmo.ollila@digia.com> | 2013-05-29 08:45:42 +0300 |
commit | 9d616bf5be63cc4d12154cbac5ea5f8c4938832d (patch) | |
tree | 28f1b922d88b388efc602bf3fd0a96a29ee8b871 | |
parent | c2c352b9bc93178d0c74bc7cb75c8e30e5a05f52 (diff) |
Xml-file support to video-demo. Refactoring.
Change-Id: I8f3913366fe612c01d9574e82bf60c9d33483b71
Reviewed-by: Kimmo Ollila <kimmo.ollila@digia.com>
-rw-r--r-- | QtDemo/qml/QtDemo/Slide.qml | 65 | ||||
-rw-r--r-- | QtDemo/qml/QtDemo/demos/description/Content.qml | 8 | ||||
-rw-r--r-- | QtDemo/qml/QtDemo/demos/description/ControlBar.qml | 245 | ||||
-rw-r--r-- | QtDemo/qml/QtDemo/demos/description/ImageButton.qml | 4 | ||||
-rw-r--r-- | QtDemo/qml/QtDemo/demos/description/PlaybackControl.qml | 33 | ||||
-rw-r--r-- | QtDemo/qml/QtDemo/demos/description/VideoDelegate.qml | 11 | ||||
-rw-r--r-- | QtDemo/qml/QtDemo/demos/description/VideoSelector.qml | 15 | ||||
-rw-r--r-- | QtDemo/qml/QtDemo/demos/description/VolumeControl.qml | 2 | ||||
-rw-r--r-- | QtDemo/qml/QtDemo/demos/description/images/CloseButton.png | bin | 0 -> 534 bytes | |||
-rw-r--r-- | QtDemo/qml/QtDemo/demos/description/images/PauseButton.png | bin | 686 -> 681 bytes | |||
-rw-r--r-- | QtDemo/qml/QtDemo/demos/description/images/VolumeDown.png | bin | 2938 -> 814 bytes | |||
-rw-r--r-- | QtDemo/qml/QtDemo/demos/description/images/VolumeUp.png | bin | 3060 -> 1972 bytes | |||
-rw-r--r-- | QtDemo/qml/QtDemo/demos/description/main.qml | 2 | ||||
-rw-r--r-- | QtDemo/qml/QtDemo/demos/description/videos.xml | 18 | ||||
-rw-r--r-- | QtDemo/qml/QtDemo/engine.js | 5 |
15 files changed, 169 insertions, 239 deletions
diff --git a/QtDemo/qml/QtDemo/Slide.qml b/QtDemo/qml/QtDemo/Slide.qml index 76492c2..f534cfd 100644 --- a/QtDemo/qml/QtDemo/Slide.qml +++ b/QtDemo/qml/QtDemo/Slide.qml @@ -3,12 +3,7 @@ import QtQuick 2.0 Item { id: slide objectName: "slide" - x: startX - y: startY + deltaY - rotation: deltaRot - property bool rotAnimationEnabled: false - property bool yAnimationEnabled: false property int uid: 0 property string url: "" property int device: 0 @@ -16,8 +11,6 @@ Item { property bool loaded: false property bool loading: false property real targetScale: 1 - property int startX: 0 - property int startY: 0 property bool animationRunning: navigationAnimation.running || zoomAnimation.running property int demoWidth: 603 property int demoHeight: 378 @@ -25,9 +18,6 @@ Item { property int maskHorizontalOffset: 1 property string demoColor: "#883322" property string name: "" - property real deltaRot: 0 - property int deltaY: 0 - property int swing: 5 property bool dirty: parent.angle !== 0 || rotation !==0 function targetWidth() @@ -99,8 +89,8 @@ Item { height: slide.height z: 2 - //IslandElementContainer { id: leftElementcontainer; place: 0; islandHeight: islandImage.height; islandWidth: islandImage.width } - //IslandElementContainer { id: rightElementcontainer;place: 1; islandHeight: islandImage.height; islandWidth: islandImage.width } + IslandElementContainer { id: leftElementcontainer; place: 0; islandHeight: islandImage.height; islandWidth: islandImage.width } + IslandElementContainer { id: rightElementcontainer;place: 1; islandHeight: islandImage.height; islandWidth: islandImage.width } IslandElementContainer { id: bottomElementcontainer;place: 2; islandHeight: islandImage.height; islandWidth: islandImage.width } } @@ -117,20 +107,6 @@ Item { z: -3 } - SequentialAnimation{ - id: rotationAnimation - NumberAnimation { target: slide; property: "deltaRot"; duration: 3000; to:swing; easing.type: Easing.InOutQuad } - NumberAnimation { target: slide; property: "deltaRot"; duration: 3000; to:-swing; easing.type: Easing.InOutQuad } - loops: Animation.Infinite - } - - SequentialAnimation{ - id: yAnimation - NumberAnimation { target: slide; property: "deltaY"; duration: 4000; to:10*swing; easing.type: Easing.InOutQuad } - NumberAnimation { target: slide; property: "deltaY"; duration: 4000; to:-10*swing; easing.type: Easing.InOutQuad } - loops: Animation.Infinite - } - // Load timer Timer { id: loadTimer @@ -143,26 +119,7 @@ Item { } } - // Starter timer - Timer { - id: yStarter - interval: Math.random()*5000 - onTriggered: yAnimation.start() - } - // Starter timer - Timer { - id: rotStarter - interval: Math.random()*2000 - onTriggered: rotationAnimation.start() - } - function loadDemo(){ - yAnimation.stop() - rotationAnimation.stop() - deltaY = 0 - deltaRot = 0 - - if (!slide.loaded) { splashScreenText.visible = true @@ -225,11 +182,8 @@ Item { return; } - if (yAnimationEnabled) - yAnimation.restart() - if (rotAnimationEnabled) - rotationAnimation.restart() - if (slide.name === "Internet Radio") return; //Always alive + if (slide.name === "Internet Radio") + return; //Always alive app.forceActiveFocus(); @@ -247,15 +201,8 @@ Item { function createElements() { - //leftElementcontainer.createElements() - //rightElementcontainer.createElements() + leftElementcontainer.createElements() + rightElementcontainer.createElements() bottomElementcontainer.createElements() } - - Component.onCompleted: { - if (yAnimationEnabled) - yStarter.start() - if (rotAnimationEnabled) - rotStarter.start() - } } diff --git a/QtDemo/qml/QtDemo/demos/description/Content.qml b/QtDemo/qml/QtDemo/demos/description/Content.qml index 15ec1e1..de25f13 100644 --- a/QtDemo/qml/QtDemo/demos/description/Content.qml +++ b/QtDemo/qml/QtDemo/demos/description/Content.qml @@ -48,14 +48,6 @@ Rectangle { color: "black" - /*Rectangle { - id: videoContent - anchors.fill: root - color: "#262626" - function play() { print("fake play") } - function stop() { print("fake stop") } - }*/ - ContentVideo { id: videoContent anchors.fill: root diff --git a/QtDemo/qml/QtDemo/demos/description/ControlBar.qml b/QtDemo/qml/QtDemo/demos/description/ControlBar.qml index 6adce50..02aeaf8 100644 --- a/QtDemo/qml/QtDemo/demos/description/ControlBar.qml +++ b/QtDemo/qml/QtDemo/demos/description/ControlBar.qml @@ -1,16 +1,13 @@ import QtQuick 2.0 import QtMultimedia 5.0 -Rectangle { +Item { id: controlBar - height: parent.height * 0.2 - color: "#88333333" + anchors.fill: parent property MediaPlayer mediaPlayer: null property bool isMouseAbove: false - property int margin: parent.width * 0.01 - property double playBackHeight: height*0.48 - property double seekHeight: height*0.48 + property int margin: applicationWindow.width * 0.01 signal openURL() @@ -39,136 +36,150 @@ Rectangle { statusText.text = strText; } - VolumeControl { - id: volumeControl - anchors.verticalCenter: playbackControl.verticalCenter - anchors.left: controlBar.left - anchors.leftMargin: controlBar.margin - height: controlBar.playBackHeight - width: parent.width * 0.3 - onVolumeChanged: { - if (mediaPlayer !== null) - mediaPlayer.volume = volume - } - - Connections { - target: mediaPlayer - onVolumeChanged: volumeControl.volume = mediaPlayer.volume - } - } - - //Playback Controls - PlaybackControl { - id: playbackControl - anchors.horizontalCenter: controlBar.horizontalCenter - anchors.top: controlBar.top - anchors.topMargin: controlBar.margin - height: controlBar.playBackHeight - - onPlayButtonPressed: { - if (mediaPlayer === null) - return; - - if (isPlaying) { - mediaPlayer.pause(); - } else { - mediaPlayer.play(); + Rectangle { + anchors.right: parent.right + anchors.top: parent.top + width: applicationWindow.height * 0.12 + height: width + color: "#88333333" + + Image { + id: closeImage + source: "images/CloseButton.png" + anchors.centerIn: parent + width: 0.5*parent.height + height: width + opacity: closeMouseArea.pressed ? 0.6 : 1 + smooth: true + } + + MouseArea { + id: closeMouseArea + anchors.fill: parent + onClicked: { + if (mediaPlayer !== null) + mediaPlayer.stop(); + + videoSelector.show(); } } + } - onReverseButtonPressed: { - if (mediaPlayer === null) - return; + Rectangle { + id: bottomBar + height: parent.height * 0.2 + color: "#88333333" + anchors.left: parent.left + anchors.bottom: parent.bottom + anchors.right: parent.right - if (mediaPlayer.seekable) { - //Subtract 10 % - mediaPlayer.seek(normalizeSeek(Math.round(-mediaPlayer.duration * 0.1))); + property double playBackHeight: height*0.48 + property double seekHeight: height*0.48 + + VolumeControl { + id: volumeControl + anchors.verticalCenter: playbackControl.verticalCenter + anchors.left: bottomBar.left + anchors.leftMargin: bottomBar.margin + height: bottomBar.playBackHeight + width: parent.width * 0.3 + onVolumeChanged: { + if (mediaPlayer !== null) + mediaPlayer.volume = volume } - } - - onForwardButtonPressed: { - if (mediaPlayer === null) - return; - if (mediaPlayer.seekable) { - //Add 10 % - mediaPlayer.seek(normalizeSeek(Math.round(mediaPlayer.duration * 0.1))); + Connections { + target: mediaPlayer + onVolumeChanged: volumeControl.volume = mediaPlayer.volume } } - onStopButtonPressed: { - if (mediaPlayer !== null) - mediaPlayer.stop(); + //Playback Controls + PlaybackControl { + id: playbackControl + anchors.horizontalCenter: bottomBar.horizontalCenter + anchors.top: bottomBar.top + anchors.topMargin: bottomBar.margin + height: bottomBar.playBackHeight - videoSelector.show(); - } - } + onPlayButtonPressed: { + if (mediaPlayer === null) + return; - Text { - id: statusText - anchors.right: parent.right - anchors.verticalCenter: playbackControl.verticalCenter - anchors.rightMargin: controlBar.margin - verticalAlignment: Text.AlignVCenter - height: controlBar.playBackHeight - font.pixelSize: playbackControl.height * 0.5 - color: "white" - } - - //Seek controls - SeekControl { - id: seekControl - anchors.bottom: controlBar.bottom - anchors.right: controlBar.right - anchors.left: controlBar.left - height: controlBar.seekHeight - anchors.leftMargin: controlBar.margin - anchors.rightMargin: controlBar.margin - - enabled: playbackControl.isPlaybackEnabled - duration: mediaPlayer !== null ? mediaPlayer.duration : 0 - - onSeekValueChanged: { - if (mediaPlayer !== null) { - mediaPlayer.seek(newPosition); - position = mediaPlayer.position; + if (isPlaying) { + mediaPlayer.pause(); + } else { + mediaPlayer.play(); + } } } - Component.onCompleted: { - if (mediaPlayer !== null) - seekable = mediaPlayer.seekable; - } - } + Text { + id: statusText + anchors.right: parent.right + anchors.verticalCenter: playbackControl.verticalCenter + anchors.rightMargin: bottomBar.margin + verticalAlignment: Text.AlignVCenter + height: bottomBar.playBackHeight + font.pixelSize: playbackControl.height * 0.5 + color: "white" + } + + //Seek controls + SeekControl { + id: seekControl + anchors.bottom: bottomBar.bottom + anchors.right: bottomBar.right + anchors.left: bottomBar.left + height: bottomBar.seekHeight + anchors.leftMargin: bottomBar.margin + anchors.rightMargin: bottomBar.margin + + enabled: playbackControl.isPlaybackEnabled + duration: mediaPlayer !== null ? mediaPlayer.duration : 0 + + onSeekValueChanged: { + if (mediaPlayer !== null) { + mediaPlayer.seek(newPosition); + position = mediaPlayer.position; + } + } - Connections { - target: mediaPlayer - onPositionChanged: { - if (!seekControl.pressed) seekControl.position = mediaPlayer.position; - } - onStatusChanged: { - if ((mediaPlayer.status == MediaPlayer.Loaded) || (mediaPlayer.status == MediaPlayer.Buffered) || mediaPlayer.status === MediaPlayer.Buffering || mediaPlayer.status === MediaPlayer.EndOfMedia) - playbackControl.isPlaybackEnabled = true; - else - playbackControl.isPlaybackEnabled = false; - updateStatusText(); - } - onErrorChanged: { - updateStatusText(); + Component.onCompleted: { + if (mediaPlayer !== null) + seekable = mediaPlayer.seekable; + } } - onPlaybackStateChanged: { - if (mediaPlayer.playbackState === MediaPlayer.PlayingState) { - playbackControl.isPlaying = true; - applicationWindow.resetTimer(); - } else { - show(); - playbackControl.isPlaying = false; + Connections { + target: mediaPlayer + onPositionChanged: { + if (!seekControl.pressed) seekControl.position = mediaPlayer.position; + } + onStatusChanged: { + if ((mediaPlayer.status == MediaPlayer.Loaded) || (mediaPlayer.status == MediaPlayer.Buffered) || mediaPlayer.status === MediaPlayer.Buffering || mediaPlayer.status === MediaPlayer.EndOfMedia) + playbackControl.isPlaybackEnabled = true; + else + playbackControl.isPlaybackEnabled = false; + updateStatusText(); + } + onErrorChanged: { + updateStatusText(); } - } - onSeekableChanged: { - seekControl.seekable = mediaPlayer.seekable; + onPlaybackStateChanged: { + if (mediaPlayer.playbackState === MediaPlayer.PlayingState) { + playbackControl.isPlaying = true; + applicationWindow.resetTimer(); + } else { + show(); + playbackControl.isPlaying = false; + } + } + + onSeekableChanged: { + seekControl.seekable = mediaPlayer.seekable; + } } } diff --git a/QtDemo/qml/QtDemo/demos/description/ImageButton.qml b/QtDemo/qml/QtDemo/demos/description/ImageButton.qml index 19d9836..50dd3fa 100644 --- a/QtDemo/qml/QtDemo/demos/description/ImageButton.qml +++ b/QtDemo/qml/QtDemo/demos/description/ImageButton.qml @@ -4,7 +4,7 @@ import QtQuick 2.0 Item { id: root - height: parent.height + height: parent.height * 0.8 width: image.width * image.scale property alias enabled: mouseArea.enabled @@ -22,7 +22,7 @@ Item { Image { id: image anchors.centerIn: parent - scale: root.height / height * 0.9 + scale: root.height / height visible: true opacity: pressed ? 0.6 : 1 smooth: true diff --git a/QtDemo/qml/QtDemo/demos/description/PlaybackControl.qml b/QtDemo/qml/QtDemo/demos/description/PlaybackControl.qml index f0485fc..3a4153f 100644 --- a/QtDemo/qml/QtDemo/demos/description/PlaybackControl.qml +++ b/QtDemo/qml/QtDemo/demos/description/PlaybackControl.qml @@ -8,31 +8,8 @@ Row { property bool isPlaybackEnabled: false property bool isPlaying: false - signal forwardButtonPressed() - signal reverseButtonPressed() signal playButtonPressed() - signal stopButtonPressed() - //Playback Controls - ImageButton { - id: rateReverseButton - enabled: isPlaybackEnabled - imageSource: "images/RateButtonReverse.png" - anchors.verticalCenter: root.verticalCenter - - onClicked: { - reverseButtonPressed(); - } - } - ImageButton { - id: stopButton - enabled: isPlaybackEnabled - imageSource: "images/StopButton.png" - anchors.verticalCenter: root.verticalCenter - onClicked: { - stopButtonPressed(); - } - } ImageButton { id: playButton enabled: isPlaybackEnabled @@ -42,14 +19,4 @@ Row { playButtonPressed(); } } - - ImageButton { - id: rateForwardButton - enabled: isPlaybackEnabled - imageSource: "images/RateButtonForward.png" - anchors.verticalCenter: root.verticalCenter - onClicked: { - forwardButtonPressed(); - } - } } diff --git a/QtDemo/qml/QtDemo/demos/description/VideoDelegate.qml b/QtDemo/qml/QtDemo/demos/description/VideoDelegate.qml index f9cefc3..0c0e22d 100644 --- a/QtDemo/qml/QtDemo/demos/description/VideoDelegate.qml +++ b/QtDemo/qml/QtDemo/demos/description/VideoDelegate.qml @@ -7,7 +7,7 @@ Rectangle { color: "transparent" property int tileMargin: videoSelector.tileMargin - signal videoSelected(string url) + signal videoSelected(string link) Rectangle { anchors.left: parent.left @@ -21,7 +21,6 @@ Rectangle { anchors.fill: parent onClicked: { grid.currentIndex = index - console.log(link) delegate.videoSelected(link) } } @@ -36,15 +35,15 @@ Rectangle { Image { id: iconImage - source: url + source: thumbnail width: parent.width height: parent.height } Rectangle{ width: parent.width - height: dateText.height + tileMargin - anchors.top: dateText.top + height: titleText.height + tileMargin + anchors.top: titleText.top anchors.bottom: parent.bottom color: "Black" opacity: 0.5 @@ -53,7 +52,7 @@ Rectangle { } Text { - id: dateText + id: titleText anchors.left: parent.left anchors.leftMargin: tileMargin anchors.bottom: parent.bottom diff --git a/QtDemo/qml/QtDemo/demos/description/VideoSelector.qml b/QtDemo/qml/QtDemo/demos/description/VideoSelector.qml index 933e160..2c9a661 100644 --- a/QtDemo/qml/QtDemo/demos/description/VideoSelector.qml +++ b/QtDemo/qml/QtDemo/demos/description/VideoSelector.qml @@ -11,7 +11,7 @@ Rectangle { property string textColor: "white" property string uiFont: "Segoe UI" - signal selectVideo(string url) + signal selectVideo(string link) state: "VISIBLE" @@ -22,15 +22,10 @@ Rectangle { XmlListModel { id: videoModel - //source: "http://blog.qt.digia.com/feed/" - source: "http://news.yahoo.com/rss/tech" - //query: "/rss/channel/item" - // Filter out items that don't have images - query: "/rss/channel/item[exists(child::media:content)]" - namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";" - XmlRole { name: "url"; query: "media:content/@url/string()" } + source: "videos.xml" + query: "/videolist/item" + XmlRole { name: "thumbnail"; query: "thumbnail/string()" } XmlRole { name: "title"; query: "title/string()" } - XmlRole { name: "pubDate"; query: "pubDate/string()" } XmlRole { name: "link"; query: "link/string()" } } @@ -45,7 +40,7 @@ Rectangle { clip: false focus: true model: videoModel - delegate: VideoDelegate { onVideoSelected: videoSelector.selectVideo("http://download.qt-project.org/learning/videos/Qt5-Jens-Bache-Wiig-Qt-Quick.mp4"); } + delegate: VideoDelegate { onVideoSelected: videoSelector.selectVideo(link); } // Only show the scrollbars when the view is moving. states: State { diff --git a/QtDemo/qml/QtDemo/demos/description/VolumeControl.qml b/QtDemo/qml/QtDemo/demos/description/VolumeControl.qml index 52b6242..a71d66e 100644 --- a/QtDemo/qml/QtDemo/demos/description/VolumeControl.qml +++ b/QtDemo/qml/QtDemo/demos/description/VolumeControl.qml @@ -8,6 +8,7 @@ Item { //Volume Controls ImageButton { id: volumeDown + height: parent.height * 0.5 imageSource: "images/VolumeDown.png" anchors.verticalCenter: root.verticalCenter anchors.left: root.left @@ -28,6 +29,7 @@ Item { ImageButton { id: volumeUp + height: parent.height * 0.5 imageSource: "images/VolumeUp.png" anchors.verticalCenter: root.verticalCenter anchors.verticalCenterOffset: 1 diff --git a/QtDemo/qml/QtDemo/demos/description/images/CloseButton.png b/QtDemo/qml/QtDemo/demos/description/images/CloseButton.png Binary files differnew file mode 100644 index 0000000..24407fe --- /dev/null +++ b/QtDemo/qml/QtDemo/demos/description/images/CloseButton.png diff --git a/QtDemo/qml/QtDemo/demos/description/images/PauseButton.png b/QtDemo/qml/QtDemo/demos/description/images/PauseButton.png Binary files differindex 880d23a..b58ceb4 100644 --- a/QtDemo/qml/QtDemo/demos/description/images/PauseButton.png +++ b/QtDemo/qml/QtDemo/demos/description/images/PauseButton.png diff --git a/QtDemo/qml/QtDemo/demos/description/images/VolumeDown.png b/QtDemo/qml/QtDemo/demos/description/images/VolumeDown.png Binary files differindex 255ce2c..38b1013 100644 --- a/QtDemo/qml/QtDemo/demos/description/images/VolumeDown.png +++ b/QtDemo/qml/QtDemo/demos/description/images/VolumeDown.png diff --git a/QtDemo/qml/QtDemo/demos/description/images/VolumeUp.png b/QtDemo/qml/QtDemo/demos/description/images/VolumeUp.png Binary files differindex 7cc153a..cffe961 100644 --- a/QtDemo/qml/QtDemo/demos/description/images/VolumeUp.png +++ b/QtDemo/qml/QtDemo/demos/description/images/VolumeUp.png diff --git a/QtDemo/qml/QtDemo/demos/description/main.qml b/QtDemo/qml/QtDemo/demos/description/main.qml index 6463409..5987843 100644 --- a/QtDemo/qml/QtDemo/demos/description/main.qml +++ b/QtDemo/qml/QtDemo/demos/description/main.qml @@ -81,7 +81,7 @@ Rectangle { visible: true onSelectVideo: { videoSelector.hide() - content.openVideo(url) + content.openVideo(link) content.videoPlayer.play() } onVisibleChanged: { diff --git a/QtDemo/qml/QtDemo/demos/description/videos.xml b/QtDemo/qml/QtDemo/demos/description/videos.xml new file mode 100644 index 0000000..4aca775 --- /dev/null +++ b/QtDemo/qml/QtDemo/demos/description/videos.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<videolist> + <item> + <title>Video1</title> + <thumbnail>http://findicons.com/files/icons/719/crystal_clear_actions/64/agt_action_fail.png</thumbnail> + <link>http://download.qt-project.org/learning/videos/Qt5-Jens-Bache-Wiig-Qt-Quick.mp4</link> + </item> + <item> + <title>Video2</title> + <thumbnail>http://findicons.com/files/icons/72/harmonia_pastelis/128/hp_fav_star.png</thumbnail> + <link>http://download.qt-project.org/learning/videos/Qt5-Jens-Bache-Wiig-Qt-Quick.mp4</link> + </item> + <item> + <title>Video3</title> + <thumbnail>http://findicons.com/files/icons/1786/oxygen_refit/128/face_gearhead_female_smile.png</thumbnail> + <link>http://download.qt-project.org/learning/videos/Qt5-Jens-Bache-Wiig-Qt-Quick.mp4</link> + </item> +</videolist> diff --git a/QtDemo/qml/QtDemo/engine.js b/QtDemo/qml/QtDemo/engine.js index bc98acd..a1ef916 100644 --- a/QtDemo/qml/QtDemo/engine.js +++ b/QtDemo/qml/QtDemo/engine.js @@ -55,9 +55,8 @@ function createNew(x,y,url,device,name){ object.maskHorizontalOffset = maskHorizontalOffsets[device] object.uid = objects.length object.name = name - object.startX = x-object.width/2 - object.startY = y-object.height/2 - object.swing = Math.random()*(objects.length/2)+1 + object.x = x-object.width/2 + object.y = y-object.height/2 object.createElements(); if (url){ |