summaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authoraxis <qt-info@nokia.com>2010-02-23 15:23:05 (GMT)
committeraxis <qt-info@nokia.com>2010-02-23 15:23:05 (GMT)
commitf67062af3a076468442c29127cb48bb13937ce0e (patch)
treea12cd4c644fb528dd5f95cb58559732a0b8b6311 /demos
parenta670009fd378d48ff891602ec31204614e8a476f (diff)
parentc15307e9e916aa613096275919ca91deba64454f (diff)
downloadQt-f67062af3a076468442c29127cb48bb13937ce0e.zip
Qt-f67062af3a076468442c29127cb48bb13937ce0e.tar.gz
Qt-f67062af3a076468442c29127cb48bb13937ce0e.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-s60-public
Conflicts: mkspecs/features/symbian/qt.prf qmake/Makefile.unix qmake/Makefile.win32 qmake/Makefile.win32-g++ qmake/Makefile.win32-g++-sh qmake/generators/symbian/initprojectdeploy_symbian.cpp src/src.pro
Diffstat (limited to 'demos')
-rw-r--r--demos/composition/composition.cpp35
-rw-r--r--demos/composition/composition.h13
-rw-r--r--demos/declarative/calculator/CalcButton.qml2
-rw-r--r--demos/declarative/calculator/calculator.qml4
-rw-r--r--demos/declarative/flickr/common/ImageDetails.qml2
-rw-r--r--demos/declarative/flickr/common/Loading.qml2
-rw-r--r--demos/declarative/flickr/common/MediaButton.qml2
-rw-r--r--demos/declarative/flickr/common/MediaLineEdit.qml4
-rw-r--r--demos/declarative/flickr/common/ScrollBar.qml2
-rw-r--r--demos/declarative/flickr/common/Slider.qml2
-rw-r--r--demos/declarative/flickr/common/Star.qml4
-rw-r--r--demos/declarative/flickr/flickr-desktop.qml10
-rw-r--r--demos/declarative/flickr/flickr-mobile.qml4
-rw-r--r--demos/declarative/flickr/mobile/Button.qml2
-rw-r--r--demos/declarative/flickr/mobile/GridDelegate.qml8
-rw-r--r--demos/declarative/flickr/mobile/ImageDetails.qml2
-rw-r--r--demos/declarative/flickr/mobile/TitleBar.qml2
-rw-r--r--demos/declarative/minehunt/Description.qml2
-rw-r--r--demos/declarative/minehunt/main.cpp5
-rw-r--r--demos/declarative/minehunt/minehunt.qml20
-rw-r--r--demos/declarative/samegame/content/Button.qml2
-rw-r--r--demos/declarative/samegame/content/Dialog.qml3
-rwxr-xr-xdemos/declarative/samegame/content/samegame.js9
-rw-r--r--demos/declarative/samegame/samegame.qml20
-rw-r--r--demos/declarative/snake/content/Button.qml2
-rw-r--r--demos/declarative/snake/snake.qml2
-rw-r--r--demos/declarative/twitter/content/Button.qml2
-rw-r--r--demos/declarative/twitter/content/HomeTitleBar.qml2
-rw-r--r--demos/declarative/twitter/content/Loading.qml2
-rw-r--r--demos/declarative/twitter/content/MultiTitleBar.qml2
-rw-r--r--demos/declarative/twitter/content/TitleBar.qml2
-rw-r--r--demos/declarative/twitter/twitter.qml2
-rw-r--r--demos/declarative/webbrowser/content/RetractingWebBrowserHeader.qml4
-rw-r--r--demos/declarative/webbrowser/content/fieldtext/FieldText.qml8
-rw-r--r--demos/declarative/webbrowser/webbrowser.qml10
-rw-r--r--demos/demos.pro2
-rw-r--r--demos/multimedia/multimedia.pro4
-rw-r--r--demos/multimedia/player/main.cpp54
-rw-r--r--demos/multimedia/player/player.cpp325
-rw-r--r--demos/multimedia/player/player.h109
-rw-r--r--demos/multimedia/player/player.pro22
-rw-r--r--demos/multimedia/player/playercontrols.cpp205
-rw-r--r--demos/multimedia/player/playercontrols.h107
-rw-r--r--demos/multimedia/player/playlistmodel.cpp160
-rw-r--r--demos/multimedia/player/playlistmodel.h95
-rw-r--r--demos/multimedia/player/videowidget.cpp72
-rw-r--r--demos/multimedia/player/videowidget.h66
47 files changed, 1341 insertions, 79 deletions
diff --git a/demos/composition/composition.cpp b/demos/composition/composition.cpp
index e03f3e6..deca5dc 100644
--- a/demos/composition/composition.cpp
+++ b/demos/composition/composition.cpp
@@ -48,6 +48,8 @@
#include <QMouseEvent>
#include <qmath.h>
+const int animationInterval = 15; // update every 16 ms = ~60FPS
+
CompositionWidget::CompositionWidget(QWidget *parent)
: QWidget(parent)
{
@@ -236,6 +238,7 @@ CompositionRenderer::CompositionRenderer(QWidget *parent)
: ArthurFrame(parent)
{
m_animation_enabled = true;
+ m_animationTimer = startTimer(animationInterval);
#ifdef Q_WS_QWS
m_image = QPixmap(":res/composition/flower.jpg");
m_image.setAlphaChannel(QPixmap(":res/composition/flower_alpha.jpg"));
@@ -264,6 +267,20 @@ QRectF rectangle_around(const QPointF &p, const QSizeF &size = QSize(250, 200))
return rect;
}
+void CompositionRenderer::setAnimationEnabled(bool enabled)
+{
+ if (m_animation_enabled == enabled)
+ return;
+ m_animation_enabled = enabled;
+ if (enabled) {
+ Q_ASSERT(!m_animationTimer);
+ m_animationTimer = startTimer(animationInterval);
+ } else {
+ killTimer(m_animationTimer);
+ m_animationTimer = 0;
+ }
+}
+
void CompositionRenderer::updateCirclePos()
{
if (m_current_object != NoObject)
@@ -471,10 +488,6 @@ void CompositionRenderer::paint(QPainter *painter)
painter->drawImage(0, 0, m_buffer);
#endif
}
-
- if (m_animation_enabled && m_current_object == NoObject) {
- updateCirclePos();
- }
}
void CompositionRenderer::mousePressEvent(QMouseEvent *e)
@@ -489,6 +502,10 @@ void CompositionRenderer::mousePressEvent(QMouseEvent *e)
} else {
m_current_object = NoObject;
}
+ if (m_animation_enabled) {
+ killTimer(m_animationTimer);
+ m_animationTimer = 0;
+ }
}
void CompositionRenderer::mouseMoveEvent(QMouseEvent *e)
@@ -500,7 +517,15 @@ void CompositionRenderer::mouseReleaseEvent(QMouseEvent *)
{
m_current_object = NoObject;
- if (m_animation_enabled)
+ if (m_animation_enabled) {
+ Q_ASSERT(!m_animationTimer);
+ m_animationTimer = startTimer(animationInterval);
+ }
+}
+
+void CompositionRenderer::timerEvent(QTimerEvent *event)
+{
+ if (event->timerId() == m_animationTimer)
updateCirclePos();
}
diff --git a/demos/composition/composition.h b/demos/composition/composition.h
index 1123531..f5a9fc3 100644
--- a/demos/composition/composition.h
+++ b/demos/composition/composition.h
@@ -109,10 +109,6 @@ public:
void paint(QPainter *);
- void mousePressEvent(QMouseEvent *);
- void mouseMoveEvent(QMouseEvent *);
- void mouseReleaseEvent(QMouseEvent *);
-
void setCirclePos(const QPointF &pos);
QSize sizeHint() const { return QSize(500, 400); }
@@ -121,6 +117,12 @@ public:
int circleColor() const { return m_circle_hue; }
int circleAlpha() const { return m_circle_alpha; }
+protected:
+ void mousePressEvent(QMouseEvent *);
+ void mouseMoveEvent(QMouseEvent *);
+ void mouseReleaseEvent(QMouseEvent *);
+ void timerEvent(QTimerEvent *);
+
public slots:
void setClearMode() { m_composition_mode = QPainter::CompositionMode_Clear; update(); }
void setSourceMode() { m_composition_mode = QPainter::CompositionMode_Source; update(); }
@@ -150,7 +152,7 @@ public slots:
void setCircleAlpha(int alpha) { m_circle_alpha = alpha; update(); }
void setCircleColor(int hue) { m_circle_hue = hue; update(); }
- void setAnimationEnabled(bool enabled) { m_animation_enabled = enabled; update(); }
+ void setAnimationEnabled(bool enabled);
private:
void updateCirclePos();
@@ -177,6 +179,7 @@ private:
ObjectType m_current_object;
bool m_animation_enabled;
+ int m_animationTimer;
#ifdef QT_OPENGL_SUPPORT
QGLPixelBuffer *m_pbuffer;
diff --git a/demos/declarative/calculator/CalcButton.qml b/demos/declarative/calculator/CalcButton.qml
index 08851d0..6210e46 100644
--- a/demos/declarative/calculator/CalcButton.qml
+++ b/demos/declarative/calculator/CalcButton.qml
@@ -15,7 +15,7 @@ Rectangle {
Text { id: label; anchors.centerIn: parent; color: palette.buttonText }
- MouseRegion {
+ MouseArea {
id: clickRegion
anchors.fill: parent
onClicked: {
diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml
index d9b73ed..54af7ad 100644
--- a/demos/declarative/calculator/calculator.qml
+++ b/demos/declarative/calculator/calculator.qml
@@ -118,7 +118,7 @@ Rectangle {
}
transitions: Transition {
- NumberAnimation { matchProperties: "x,y,width"; easing: "easeOutBounce"; duration: 500 }
- NumberAnimation { matchProperties: "opacity"; easing: "easeInOutQuad"; duration: 500 }
+ NumberAnimation { properties: "x,y,width"; easing: "easeOutBounce"; duration: 500 }
+ NumberAnimation { properties: "opacity"; easing: "easeInOutQuad"; duration: 500 }
}
}
diff --git a/demos/declarative/flickr/common/ImageDetails.qml b/demos/declarative/flickr/common/ImageDetails.qml
index 95c32e8..19cad06 100644
--- a/demos/declarative/flickr/common/ImageDetails.qml
+++ b/demos/declarative/flickr/common/ImageDetails.qml
@@ -149,7 +149,7 @@ Flipable {
property: "smooth"
value: false
}
- NumberAnimation { easing: "easeInOutQuad"; matchProperties: "angle"; duration: 500 }
+ NumberAnimation { easing: "easeInOutQuad"; properties: "angle"; duration: 500 }
PropertyAction {
target: bigImage
property: "smooth"
diff --git a/demos/declarative/flickr/common/Loading.qml b/demos/declarative/flickr/common/Loading.qml
index 64a04c4..174cd21 100644
--- a/demos/declarative/flickr/common/Loading.qml
+++ b/demos/declarative/flickr/common/Loading.qml
@@ -3,6 +3,6 @@ import Qt 4.6
Image {
id: loading; source: "pics/loading.png"; transformOrigin: "Center"
rotation: NumberAnimation {
- id: "RotationAnimation"; from: 0; to: 360; running: loading.visible == true; repeat: true; duration: 900
+ from: 0; to: 360; running: loading.visible == true; repeat: true; duration: 900
}
}
diff --git a/demos/declarative/flickr/common/MediaButton.qml b/demos/declarative/flickr/common/MediaButton.qml
index c12b642..86ac948 100644
--- a/demos/declarative/flickr/common/MediaButton.qml
+++ b/demos/declarative/flickr/common/MediaButton.qml
@@ -16,7 +16,7 @@ Item {
source: "pics/button-pressed.png"
opacity: 0
}
- MouseRegion {
+ MouseArea {
id: mouseRegion
anchors.fill: buttonImage
onClicked: { container.clicked(); }
diff --git a/demos/declarative/flickr/common/MediaLineEdit.qml b/demos/declarative/flickr/common/MediaLineEdit.qml
index abc8034..3dfd1f3 100644
--- a/demos/declarative/flickr/common/MediaLineEdit.qml
+++ b/demos/declarative/flickr/common/MediaLineEdit.qml
@@ -42,7 +42,7 @@ Item {
]
transitions: [
Transition {
- NumberAnimation { matchProperties: "x,width"; duration: 500; easing: "easeInOutQuad" }
+ NumberAnimation { properties: "x,width"; duration: 500; easing: "easeInOutQuad" }
}
]
@@ -62,7 +62,7 @@ Item {
anchors.right: container.right
}
- MouseRegion {
+ MouseArea {
id: mouseRegion
anchors.fill: buttonImage
onClicked: { container.state = container.state=="Edit" ? "" : "Edit" }
diff --git a/demos/declarative/flickr/common/ScrollBar.qml b/demos/declarative/flickr/common/ScrollBar.qml
index 2c1ec8a..feebcb0 100644
--- a/demos/declarative/flickr/common/ScrollBar.qml
+++ b/demos/declarative/flickr/common/ScrollBar.qml
@@ -32,7 +32,7 @@ Item {
to: "*"
NumberAnimation {
target: container
- matchProperties: "opacity"
+ properties: "opacity"
duration: 400
}
}
diff --git a/demos/declarative/flickr/common/Slider.qml b/demos/declarative/flickr/common/Slider.qml
index fa1645c..05a87e7 100644
--- a/demos/declarative/flickr/common/Slider.qml
+++ b/demos/declarative/flickr/common/Slider.qml
@@ -27,7 +27,7 @@ Item {
GradientStop { position: 1.0; color: "gray" }
}
- MouseRegion {
+ MouseArea {
anchors.fill: parent; drag.target: parent
drag.axis: "XAxis"; drag.minimumX: 2; drag.maximumX: slider.xMax+2
onPositionChanged: { value = (maximum - minimum) * (handle.x-2) / slider.xMax + minimum; }
diff --git a/demos/declarative/flickr/common/Star.qml b/demos/declarative/flickr/common/Star.qml
index c5abcca..8cd47b4 100644
--- a/demos/declarative/flickr/common/Star.qml
+++ b/demos/declarative/flickr/common/Star.qml
@@ -17,7 +17,7 @@ Item {
opacity: 0.4
scale: 0.5
}
- MouseRegion {
+ MouseArea {
anchors.fill: container
onClicked: { container.clicked() }
}
@@ -37,7 +37,7 @@ Item {
transitions: [
Transition {
NumberAnimation {
- matchProperties: "opacity,scale,x,y"
+ properties: "opacity,scale,x,y"
easing: "easeOutBounce"
}
}
diff --git a/demos/declarative/flickr/flickr-desktop.qml b/demos/declarative/flickr/flickr-desktop.qml
index 4e3b6cb..1ca3cdc 100644
--- a/demos/declarative/flickr/flickr-desktop.qml
+++ b/demos/declarative/flickr/flickr-desktop.qml
@@ -61,7 +61,7 @@ Item {
}
}
- MouseRegion { anchors.fill: wrapper; onClicked: { photoClicked() } }
+ MouseArea { anchors.fill: wrapper; onClicked: { photoClicked() } }
states: [
State {
@@ -86,15 +86,15 @@ Item {
from: "*"; to: "Details"
SequentialAnimation {
ParentAction { }
- NumberAnimation { matchProperties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" }
+ NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" }
}
},
Transition {
from: "Details"; to: "*"
SequentialAnimation {
ParentAction { }
- NumberAnimation { matchProperties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" }
- PropertyAction { matchTargets: wrapper; matchProperties: "z" }
+ NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" }
+ PropertyAction { targets: wrapper; properties: "z" }
}
}
]
@@ -180,7 +180,7 @@ Item {
transitions: [
Transition {
from: "*"; to: "*"
- NumberAnimation { matchProperties: "y"; duration: 1000; easing: "easeOutBounce(amplitude:0.5)" }
+ NumberAnimation { properties: "y"; duration: 1000; easing: "easeOutBounce(amplitude:0.5)" }
}
]
}
diff --git a/demos/declarative/flickr/flickr-mobile.qml b/demos/declarative/flickr/flickr-mobile.qml
index 583f992..0a89c4f 100644
--- a/demos/declarative/flickr/flickr-mobile.qml
+++ b/demos/declarative/flickr/flickr-mobile.qml
@@ -38,7 +38,7 @@ Item {
}
transitions: Transition {
- NumberAnimation { matchProperties: "x"; duration: 500; easing: "easeInOutQuad" }
+ NumberAnimation { properties: "x"; duration: 500; easing: "easeInOutQuad" }
}
}
@@ -76,7 +76,7 @@ Item {
}
transitions: Transition {
- NumberAnimation { matchProperties: "x"; duration: 500; easing: "easeInOutQuad" }
+ NumberAnimation { properties: "x"; duration: 500; easing: "easeInOutQuad" }
}
}
}
diff --git a/demos/declarative/flickr/mobile/Button.qml b/demos/declarative/flickr/mobile/Button.qml
index 770330c..4ba6b19 100644
--- a/demos/declarative/flickr/mobile/Button.qml
+++ b/demos/declarative/flickr/mobile/Button.qml
@@ -18,7 +18,7 @@ Item {
source: "images/toolbutton.sci"
width: container.width; height: container.height
}
- MouseRegion {
+ MouseArea {
id: mouseRegion
anchors.fill: buttonImage
onClicked: { container.clicked(); }
diff --git a/demos/declarative/flickr/mobile/GridDelegate.qml b/demos/declarative/flickr/mobile/GridDelegate.qml
index 3a42507..0f5b69c 100644
--- a/demos/declarative/flickr/mobile/GridDelegate.qml
+++ b/demos/declarative/flickr/mobile/GridDelegate.qml
@@ -55,18 +55,18 @@
Transition {
from: "Show"; to: "Details"
ParentAction { }
- NumberAnimation { matchProperties: "x,y"; duration: 500; easing: "easeInOutQuad" }
+ NumberAnimation { properties: "x,y"; duration: 500; easing: "easeInOutQuad" }
},
Transition {
from: "Details"; to: "Show"
SequentialAnimation {
ParentAction { }
- NumberAnimation { matchProperties: "x,y"; duration: 500; easing: "easeInOutQuad" }
- PropertyAction { matchTargets: wrapper; matchProperties: "z" }
+ NumberAnimation { properties: "x,y"; duration: 500; easing: "easeInOutQuad" }
+ PropertyAction { targets: wrapper; properties: "z" }
}
}
]
}
- MouseRegion { anchors.fill: wrapper; onClicked: { photoClicked() } }
+ MouseArea { anchors.fill: wrapper; onClicked: { photoClicked() } }
}
}
diff --git a/demos/declarative/flickr/mobile/ImageDetails.qml b/demos/declarative/flickr/mobile/ImageDetails.qml
index 9116428..1963bf5 100644
--- a/demos/declarative/flickr/mobile/ImageDetails.qml
+++ b/demos/declarative/flickr/mobile/ImageDetails.qml
@@ -117,7 +117,7 @@ Flipable {
transitions: Transition {
SequentialAnimation {
PropertyAction { target: bigImage; property: "smooth"; value: false }
- NumberAnimation { easing: "easeInOutQuad"; matchProperties: "angle"; duration: 500 }
+ NumberAnimation { easing: "easeInOutQuad"; properties: "angle"; duration: 500 }
PropertyAction { target: bigImage; property: "smooth"; value: !flickable.moving }
}
}
diff --git a/demos/declarative/flickr/mobile/TitleBar.qml b/demos/declarative/flickr/mobile/TitleBar.qml
index 0341585..07b9762 100644
--- a/demos/declarative/flickr/mobile/TitleBar.qml
+++ b/demos/declarative/flickr/mobile/TitleBar.qml
@@ -71,6 +71,6 @@ Item {
}
transitions: Transition {
- NumberAnimation { matchProperties: "x"; easing: "easeInOutQuad" }
+ NumberAnimation { properties: "x"; easing: "easeInOutQuad" }
}
}
diff --git a/demos/declarative/minehunt/Description.qml b/demos/declarative/minehunt/Description.qml
index 440dd2e..cc4d3b2 100644
--- a/demos/declarative/minehunt/Description.qml
+++ b/demos/declarative/minehunt/Description.qml
@@ -4,7 +4,7 @@ Item {
id: page
height: myText.height + 20
property var text
- MouseRegion {
+ MouseArea {
anchors.fill: parent
drag.target: page
drag.axis: "XandYAxis"
diff --git a/demos/declarative/minehunt/main.cpp b/demos/declarative/minehunt/main.cpp
index 8ca37ff..0b862e3 100644
--- a/demos/declarative/minehunt/main.cpp
+++ b/demos/declarative/minehunt/main.cpp
@@ -167,10 +167,7 @@ MyWidget::MyWidget(int width, int height, QWidget *parent, Qt::WindowFlags flags
canvas->setFixedSize(width, height);
vbox->addWidget(canvas);
- QFile file(fileName);
- file.open(QFile::ReadOnly);
- QString qml = file.readAll();
- canvas->setQml(qml, fileName);
+ canvas->setSource(QUrl::fromLocalFile(fileName));
QmlContext *ctxt = canvas->rootContext();
ctxt->addDefaultObject(this);
diff --git a/demos/declarative/minehunt/minehunt.qml b/demos/declarative/minehunt/minehunt.qml
index ff00d83..92555c2 100644
--- a/demos/declarative/minehunt/minehunt.qml
+++ b/demos/declarative/minehunt/minehunt.qml
@@ -31,7 +31,7 @@ Item {
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
source: "pics/flag.png"
- opacity: modelData.hasFlag
+ opacity: model.hasFlag
opacity: Behavior {
NumberAnimation {
property: "opacity"
@@ -47,16 +47,16 @@ Item {
Text {
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
- text: modelData.hint
+ text: model.hint
color: "white"
font.bold: true
- opacity: !modelData.hasMine && modelData.hint > 0
+ opacity: !model.hasMine && model.hint > 0
}
Image {
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
source: "pics/bomb.png"
- opacity: modelData.hasMine
+ opacity: model.hasMine
}
Explosion {
id: expl
@@ -65,7 +65,7 @@ Item {
states: [
State {
name: "back"
- when: modelData.flipped
+ when: model.flipped
PropertyChanges { target: flipable; angle: 180 }
}
]
@@ -81,7 +81,7 @@ Item {
else
ret = 0;
if (ret > 0) {
- if (modelData.hasMine && modelData.flipped) {
+ if (model.hasMine && model.flipped) {
ret*3;
} else {
ret;
@@ -93,15 +93,15 @@ Item {
}
NumberAnimation {
easing: "easeInOutQuad"
- matchProperties: "angle"
+ properties: "angle"
}
ScriptAction{
- script: if(modelData.hasMine && modelData.flipped){expl.explode = true;}
+ script: if(model.hasMine && model.flipped){expl.explode = true;}
}
}
}
]
- MouseRegion {
+ MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onPressed: {
@@ -188,7 +188,7 @@ Item {
anchors.right: field.right
anchors.rightMargin: 20
source: isPlaying ? 'pics/face-smile.png' : hasWon ? 'pics/face-smile-big.png': 'pics/face-sad.png'
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onPressed: { reset() }
}
diff --git a/demos/declarative/samegame/content/Button.qml b/demos/declarative/samegame/content/Button.qml
index 63cd555..6629302 100644
--- a/demos/declarative/samegame/content/Button.qml
+++ b/demos/declarative/samegame/content/Button.qml
@@ -17,7 +17,7 @@ Rectangle {
GradientStop { position: 1.0; color: activePalette.button }
}
- MouseRegion { id: mr; anchors.fill: parent; onClicked: container.clicked() }
+ MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() }
Text {
id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
diff --git a/demos/declarative/samegame/content/Dialog.qml b/demos/declarative/samegame/content/Dialog.qml
index f9a281a..7769328 100644
--- a/demos/declarative/samegame/content/Dialog.qml
+++ b/demos/declarative/samegame/content/Dialog.qml
@@ -11,11 +11,12 @@ Rectangle {
page.opacity = 1;
}
signal closed();
+ property Item text: myText
color: "white"; border.width: 1; width: myText.width + 20; height: myText.height + 40;
opacity: 0
opacity: Behavior {
NumberAnimation { duration: 1000 }
}
Text { id: myText; anchors.centerIn: parent; text: "Hello World!" }
- MouseRegion { id: mr; anchors.fill: parent; onClicked: forceClose(); }
+ MouseArea { id: mr; anchors.fill: parent; onClicked: forceClose(); }
}
diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js
index 0a42e88..c0f10bd 100755
--- a/demos/declarative/samegame/content/samegame.js
+++ b/demos/declarative/samegame/content/samegame.js
@@ -158,7 +158,11 @@ function victoryCheck()
//Checks for game over
if(deservesBonus || !(floodMoveCheck(0,maxY-1, -1))){
timer = new Date() - timer;
+ //scoreName.show("You won! Please enter your name: ");
scoreName.show("You won! Please enter your name: ");
+ scoreName.initialWidth = scoreName.text.width + 20;
+ scoreName.width = scoreName.initialWidth;
+ scoreName.text.opacity = 0;//Just a spacer
//dialog.show("Game Over. Your score is " + gameCanvas.score);
}
}
@@ -218,8 +222,9 @@ function saveHighScore(name) {
tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)');
tx.executeSql(dataStr, data);
- var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "12x17" ORDER BY score desc LIMIT 10');
- var r = "\nHIGH SCORES for a standard sized grid\n\n"
+ //Only show results for the current grid size
+ var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "'+maxX+"x"+maxY+'" ORDER BY score desc LIMIT 10');
+ var r = "\nHIGH SCORES for this grid size\n\n"
for(var i = 0; i < rs.rows.length; i++){
r += (i+1)+". " + rs.rows.item(i).name +' got '
+ rs.rows.item(i).score + ' points in '
diff --git a/demos/declarative/samegame/samegame.qml b/demos/declarative/samegame/samegame.qml
index 626c76b..50f6293 100644
--- a/demos/declarative/samegame/samegame.qml
+++ b/demos/declarative/samegame/samegame.qml
@@ -28,7 +28,7 @@ Rectangle {
width: parent.width - (parent.width % getTileSize());
height: parent.height - (parent.height % getTileSize());
- MouseRegion {
+ MouseArea {
id: gameMR
anchors.fill: parent; onClicked: handleClick(mouse.x,mouse.y);
}
@@ -38,20 +38,30 @@ Rectangle {
Dialog { id: dialog; anchors.centerIn: parent; z: 21 }
Dialog {
id: scoreName; anchors.centerIn: parent; z: 22;
+ property int initialWidth: 0
+ width: Behavior{NumberAnimation{} enabled: initialWidth!=0}
Text {
id: spacer
- opacity: 0
- text: " You won! Please enter your name:"
+ anchors.left: scoreName.left
+ anchors.leftMargin: 20
+ anchors.verticalCenter: parent.verticalCenter
+ text: "You won! Please enter your name: "
}
TextInput {
id: editor
+ onTextChanged: {
+ var newWidth = editor.width + spacer.width + 40;
+ if((newWidth > scoreName.width && newWidth < screen.width)
+ || (scoreName.width > scoreName.initialWidth))
+ scoreName.width = newWidth;
+ }
onAccepted: {
if(scoreName.opacity==1&&editor.text!="")
saveHighScore(editor.text);
scoreName.forceClose();
}
anchors.verticalCenter: parent.verticalCenter
- width: 72; focus: true
+ focus: true
anchors.left: spacer.right
}
}
@@ -79,7 +89,7 @@ Rectangle {
text: "Score: " + gameCanvas.score; font.bold: true
anchors.right: parent.right; anchors.rightMargin: 3
anchors.verticalCenter: parent.verticalCenter
- color: activePalette.text
+ color: activePalette.windowText
}
}
}
diff --git a/demos/declarative/snake/content/Button.qml b/demos/declarative/snake/content/Button.qml
index 63cd555..6629302 100644
--- a/demos/declarative/snake/content/Button.qml
+++ b/demos/declarative/snake/content/Button.qml
@@ -17,7 +17,7 @@ Rectangle {
GradientStop { position: 1.0; color: activePalette.button }
}
- MouseRegion { id: mr; anchors.fill: parent; onClicked: container.clicked() }
+ MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() }
Text {
id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
diff --git a/demos/declarative/snake/snake.qml b/demos/declarative/snake/snake.qml
index 58827a7..3bec747 100644
--- a/demos/declarative/snake/snake.qml
+++ b/demos/declarative/snake/snake.qml
@@ -101,7 +101,7 @@ Rectangle {
id: skull
}
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onPressed: {
if (!head || !heartbeat.running) {
diff --git a/demos/declarative/twitter/content/Button.qml b/demos/declarative/twitter/content/Button.qml
index 09d471c..4cba8c3 100644
--- a/demos/declarative/twitter/content/Button.qml
+++ b/demos/declarative/twitter/content/Button.qml
@@ -19,7 +19,7 @@ Item {
source: "images/toolbutton.sci"
width: container.width; height: container.height
}
- MouseRegion {
+ MouseArea {
id: mouseRegion
anchors.fill: buttonImage
onClicked: { container.clicked(); }
diff --git a/demos/declarative/twitter/content/HomeTitleBar.qml b/demos/declarative/twitter/content/HomeTitleBar.qml
index c48befd..8054f2e 100644
--- a/demos/declarative/twitter/content/HomeTitleBar.qml
+++ b/demos/declarative/twitter/content/HomeTitleBar.qml
@@ -115,7 +115,7 @@ Item {
transitions: [
Transition {
from: "*"; to: "*"
- NumberAnimation { matchProperties: "x,y,width,height"; easing: "easeInOutQuad" }
+ NumberAnimation { properties: "x,y,width,height"; easing: "easeInOutQuad" }
}
]
}
diff --git a/demos/declarative/twitter/content/Loading.qml b/demos/declarative/twitter/content/Loading.qml
index 8b22e70..3151415 100644
--- a/demos/declarative/twitter/content/Loading.qml
+++ b/demos/declarative/twitter/content/Loading.qml
@@ -3,6 +3,6 @@ import Qt 4.6
Image {
id: loading; source: "images/loading.png"; transformOrigin: "Center"
rotation: NumberAnimation {
- id: "RotationAnimation"; from: 0; to: 360; running: loading.visible == true; repeat: true; duration: 900
+ from: 0; to: 360; running: loading.visible == true; repeat: true; duration: 900
}
}
diff --git a/demos/declarative/twitter/content/MultiTitleBar.qml b/demos/declarative/twitter/content/MultiTitleBar.qml
index ef8a450..ef7de65 100644
--- a/demos/declarative/twitter/content/MultiTitleBar.qml
+++ b/demos/declarative/twitter/content/MultiTitleBar.qml
@@ -18,7 +18,7 @@ Item {
}
]
transitions: [
- Transition { NumberAnimation { matchProperties: "x,y"; duration: 500; easing: "easeInOutQuad" } }
+ Transition { NumberAnimation { properties: "x,y"; duration: 500; easing: "easeInOutQuad" } }
]
}
diff --git a/demos/declarative/twitter/content/TitleBar.qml b/demos/declarative/twitter/content/TitleBar.qml
index 28e7389..42a6115 100644
--- a/demos/declarative/twitter/content/TitleBar.qml
+++ b/demos/declarative/twitter/content/TitleBar.qml
@@ -72,6 +72,6 @@ Item {
}
transitions: Transition {
- NumberAnimation { matchProperties: "x"; easing: "easeInOutQuad" }
+ NumberAnimation { properties: "x"; easing: "easeInOutQuad" }
}
}
diff --git a/demos/declarative/twitter/twitter.qml b/demos/declarative/twitter/twitter.qml
index bb7da9c..d2abf28 100644
--- a/demos/declarative/twitter/twitter.qml
+++ b/demos/declarative/twitter/twitter.qml
@@ -89,7 +89,7 @@ Item {
}
]
transitions: [
- Transition { NumberAnimation { matchProperties: "x,y"; duration: 500; easing: "easeInOutQuad" } }
+ Transition { NumberAnimation { properties: "x,y"; duration: 500; easing: "easeInOutQuad" } }
]
}
}
diff --git a/demos/declarative/webbrowser/content/RetractingWebBrowserHeader.qml b/demos/declarative/webbrowser/content/RetractingWebBrowserHeader.qml
index a7e6a97..e58ab0a 100644
--- a/demos/declarative/webbrowser/content/RetractingWebBrowserHeader.qml
+++ b/demos/declarative/webbrowser/content/RetractingWebBrowserHeader.qml
@@ -96,8 +96,8 @@ Image {
transitions: [
Transition {
NumberAnimation {
- matchTargets: header
- matchProperties: "progressOff"
+ targets: header
+ properties: "progressOff"
easing: "easeInOutQuad"
duration: 300
}
diff --git a/demos/declarative/webbrowser/content/fieldtext/FieldText.qml b/demos/declarative/webbrowser/content/fieldtext/FieldText.qml
index 6b1d271..19b6acc 100644
--- a/demos/declarative/webbrowser/content/fieldtext/FieldText.qml
+++ b/demos/declarative/webbrowser/content/fieldtext/FieldText.qml
@@ -93,17 +93,17 @@ Item {
}
}
- MouseRegion {
+ MouseArea {
anchors.fill: cancelIcon
onClicked: { reset() }
}
- MouseRegion {
+ MouseArea {
anchors.fill: confirmIcon
onClicked: { confirm() }
}
- MouseRegion {
+ MouseArea {
id: editRegion
anchors.fill: textEdit
onClicked: { edit() }
@@ -149,7 +149,7 @@ Item {
to: "*"
reversible: true
NumberAnimation {
- matchProperties: "opacity,leftMargin,rightMargin"
+ properties: "opacity,leftMargin,rightMargin"
duration: 200
}
ColorAnimation {
diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml
index 3b3790c..934593c 100644
--- a/demos/declarative/webbrowser/webbrowser.qml
+++ b/demos/declarative/webbrowser/webbrowser.qml
@@ -97,13 +97,13 @@ Item {
transitions: [
Transition {
NumberAnimation {
- matchProperties: "opacity"
+ properties: "opacity"
easing: "easeInOutQuad"
duration: 300
}
}
]
- MouseRegion {
+ MouseArea {
anchors.fill: back_e
onClicked: { if (webView.back.enabled) webView.back.trigger() }
}
@@ -114,7 +114,7 @@ Item {
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
}
- MouseRegion {
+ MouseArea {
anchors.fill: reload
onClicked: { webView.reload.trigger() }
}
@@ -153,13 +153,13 @@ Item {
transitions: [
Transition {
NumberAnimation {
- matchProperties: "opacity"
+ properties: "opacity"
easing: "easeInOutQuad"
duration: 320
}
}
]
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: { if (webView.forward.enabled) webView.forward.trigger() }
}
diff --git a/demos/demos.pro b/demos/demos.pro
index 6340175..91b4ed1 100644
--- a/demos/demos.pro
+++ b/demos/demos.pro
@@ -55,6 +55,7 @@ wince*:SUBDIRS += demos_sqlbrowser
}
contains(QT_CONFIG, phonon):!static:SUBDIRS += demos_mediaplayer
contains(QT_CONFIG, webkit):contains(QT_CONFIG, svg):!symbian:SUBDIRS += demos_browser
+contains(QT_CONFIG, multimedia):SUBDIRS += demos_multimedia
# install
sources.files = README *.pro
@@ -85,6 +86,7 @@ demos_sqlbrowser.subdir = sqlbrowser
demos_undo.subdir = undo
demos_qtdemo.subdir = qtdemo
demos_mediaplayer.subdir = qmediaplayer
+demos_multimedia.subdir = multimedia
demos_browser.subdir = browser
diff --git a/demos/multimedia/multimedia.pro b/demos/multimedia/multimedia.pro
new file mode 100644
index 0000000..042650f
--- /dev/null
+++ b/demos/multimedia/multimedia.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+SUBDIRS = player
+
+
diff --git a/demos/multimedia/player/main.cpp b/demos/multimedia/player/main.cpp
new file mode 100644
index 0000000..87c5b87
--- /dev/null
+++ b/demos/multimedia/player/main.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "player.h"
+
+#include <QtGui>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ Player player;
+ player.show();
+
+ return app.exec();
+};
diff --git a/demos/multimedia/player/player.cpp b/demos/multimedia/player/player.cpp
new file mode 100644
index 0000000..64b1f25
--- /dev/null
+++ b/demos/multimedia/player/player.cpp
@@ -0,0 +1,325 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "player.h"
+
+#include "playercontrols.h"
+#include "playlistmodel.h"
+#include "videowidget.h"
+
+#include <QtMultimedia/qmediaservice.h>
+#include <QtMultimedia/qmediaplaylist.h>
+
+#include <QtGui>
+
+Player::Player(QWidget *parent)
+ : QWidget(parent)
+ , videoWidget(0)
+ , coverLabel(0)
+ , slider(0)
+ , colorDialog(0)
+{
+ player = new QMediaPlayer(this);
+ playlist = new QMediaPlaylist(this);
+ playlist->setMediaObject(player);
+
+ connect(player, SIGNAL(durationChanged(qint64)), SLOT(durationChanged(qint64)));
+ connect(player, SIGNAL(positionChanged(qint64)), SLOT(positionChanged(qint64)));
+ connect(player, SIGNAL(metaDataChanged()), SLOT(metaDataChanged()));
+ connect(playlist, SIGNAL(currentIndexChanged(int)), SLOT(playlistPositionChanged(int)));
+ connect(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
+ this, SLOT(statusChanged(QMediaPlayer::MediaStatus)));
+ connect(player, SIGNAL(bufferStatusChanged(int)), this, SLOT(bufferingProgress(int)));
+
+ videoWidget = new VideoWidget;
+ videoWidget->setMediaObject(player);
+
+ playlistModel = new PlaylistModel(this);
+ playlistModel->setPlaylist(playlist);
+
+ playlistView = new QListView;
+ playlistView->setModel(playlistModel);
+ playlistView->setCurrentIndex(playlistModel->index(playlist->currentIndex(), 0));
+
+ connect(playlistView, SIGNAL(activated(QModelIndex)), this, SLOT(jump(QModelIndex)));
+
+ slider = new QSlider(Qt::Horizontal);
+ slider->setRange(0, player->duration() / 1000);
+
+ connect(slider, SIGNAL(sliderMoved(int)), this, SLOT(seek(int)));
+
+ QPushButton *openButton = new QPushButton(tr("Open"));
+
+ connect(openButton, SIGNAL(clicked()), this, SLOT(open()));
+
+ PlayerControls *controls = new PlayerControls;
+ controls->setState(player->state());
+ controls->setVolume(player->volume());
+ controls->setMuted(controls->isMuted());
+
+ connect(controls, SIGNAL(play()), player, SLOT(play()));
+ connect(controls, SIGNAL(pause()), player, SLOT(pause()));
+ connect(controls, SIGNAL(stop()), player, SLOT(stop()));
+ connect(controls, SIGNAL(next()), playlist, SLOT(next()));
+ connect(controls, SIGNAL(previous()), playlist, SLOT(previous()));
+ connect(controls, SIGNAL(changeVolume(int)), player, SLOT(setVolume(int)));
+ connect(controls, SIGNAL(changeMuting(bool)), player, SLOT(setMuted(bool)));
+ connect(controls, SIGNAL(changeRate(qreal)), player, SLOT(setPlaybackRate(qreal)));
+
+ connect(player, SIGNAL(stateChanged(QMediaPlayer::State)),
+ controls, SLOT(setState(QMediaPlayer::State)));
+ connect(player, SIGNAL(volumeChanged(int)), controls, SLOT(setVolume(int)));
+ connect(player, SIGNAL(mutedChanged(bool)), controls, SLOT(setMuted(bool)));
+
+ QPushButton *fullScreenButton = new QPushButton(tr("FullScreen"));
+ fullScreenButton->setCheckable(true);
+
+ if (videoWidget != 0) {
+ connect(fullScreenButton, SIGNAL(clicked(bool)), videoWidget, SLOT(setFullScreen(bool)));
+ connect(videoWidget, SIGNAL(fullScreenChanged(bool)),
+ fullScreenButton, SLOT(setChecked(bool)));
+ } else {
+ fullScreenButton->setEnabled(false);
+ }
+
+ QPushButton *colorButton = new QPushButton(tr("Color Options..."));
+ if (videoWidget)
+ connect(colorButton, SIGNAL(clicked()), this, SLOT(showColorDialog()));
+ else
+ colorButton->setEnabled(false);
+
+ QBoxLayout *displayLayout = new QHBoxLayout;
+ if (videoWidget)
+ displayLayout->addWidget(videoWidget, 2);
+ else
+ displayLayout->addWidget(coverLabel, 2);
+ displayLayout->addWidget(playlistView);
+
+ QBoxLayout *controlLayout = new QHBoxLayout;
+ controlLayout->setMargin(0);
+ controlLayout->addWidget(openButton);
+ controlLayout->addStretch(1);
+ controlLayout->addWidget(controls);
+ controlLayout->addStretch(1);
+ controlLayout->addWidget(fullScreenButton);
+ controlLayout->addWidget(colorButton);
+
+ QBoxLayout *layout = new QVBoxLayout;
+ layout->addLayout(displayLayout);
+ layout->addWidget(slider);
+ layout->addLayout(controlLayout);
+
+ setLayout(layout);
+
+ metaDataChanged();
+
+ QStringList fileNames = qApp->arguments();
+ fileNames.removeAt(0);
+ foreach (QString const &fileName, fileNames) {
+ if (QFileInfo(fileName).exists())
+ playlist->addMedia(QUrl::fromLocalFile(fileName));
+ }
+}
+
+Player::~Player()
+{
+ delete playlist;
+ delete player;
+}
+
+void Player::open()
+{
+ QStringList fileNames = QFileDialog::getOpenFileNames();
+ foreach (QString const &fileName, fileNames)
+ playlist->addMedia(QUrl::fromLocalFile(fileName));
+}
+
+void Player::durationChanged(qint64 duration)
+{
+ slider->setMaximum(duration / 1000);
+}
+
+void Player::positionChanged(qint64 progress)
+{
+ slider->setValue(progress / 1000);
+}
+
+void Player::metaDataChanged()
+{
+ //qDebug() << "update metadata" << player->metaData(QtMultimedia::Title).toString();
+ if (player->isMetaDataAvailable()) {
+ setTrackInfo(QString("%1 - %2")
+ .arg(player->metaData(QtMultimedia::AlbumArtist).toString())
+ .arg(player->metaData(QtMultimedia::Title).toString()));
+
+ if (coverLabel) {
+ QUrl url = player->metaData(QtMultimedia::CoverArtUrlLarge).value<QUrl>();
+
+ coverLabel->setPixmap(!url.isEmpty()
+ ? QPixmap(url.toString())
+ : QPixmap());
+ }
+ }
+}
+
+void Player::jump(const QModelIndex &index)
+{
+ if (index.isValid()) {
+ playlist->setCurrentIndex(index.row());
+ player->play();
+ }
+}
+
+void Player::playlistPositionChanged(int currentItem)
+{
+ playlistView->setCurrentIndex(playlistModel->index(currentItem, 0));
+}
+
+void Player::seek(int seconds)
+{
+ player->setPosition(seconds * 1000);
+}
+
+void Player::statusChanged(QMediaPlayer::MediaStatus status)
+{
+ switch (status) {
+ case QMediaPlayer::UnknownMediaStatus:
+ case QMediaPlayer::NoMedia:
+ case QMediaPlayer::LoadedMedia:
+ case QMediaPlayer::BufferingMedia:
+ case QMediaPlayer::BufferedMedia:
+#ifndef QT_NO_CURSOR
+ unsetCursor();
+#endif
+ setStatusInfo(QString());
+ break;
+ case QMediaPlayer::LoadingMedia:
+#ifndef QT_NO_CURSOR
+ setCursor(QCursor(Qt::BusyCursor));
+#endif
+ setStatusInfo(tr("Loading..."));
+ break;
+ case QMediaPlayer::StalledMedia:
+#ifndef QT_NO_CURSOR
+ setCursor(QCursor(Qt::BusyCursor));
+#endif
+ break;
+ case QMediaPlayer::EndOfMedia:
+#ifndef QT_NO_CURSOR
+ unsetCursor();
+#endif
+ setStatusInfo(QString());
+ QApplication::alert(this);
+ break;
+ case QMediaPlayer::InvalidMedia:
+#ifndef QT_NO_CURSOR
+ unsetCursor();
+#endif
+ setStatusInfo(player->errorString());
+ break;
+ }
+}
+
+void Player::bufferingProgress(int progress)
+{
+ setStatusInfo(tr("Buffering %4%%").arg(progress));
+}
+
+void Player::setTrackInfo(const QString &info)
+{
+ trackInfo = info;
+
+ if (!statusInfo.isEmpty())
+ setWindowTitle(QString("%1 | %2").arg(trackInfo).arg(statusInfo));
+ else
+ setWindowTitle(trackInfo);
+
+}
+
+void Player::setStatusInfo(const QString &info)
+{
+ statusInfo = info;
+
+ if (!statusInfo.isEmpty())
+ setWindowTitle(QString("%1 | %2").arg(trackInfo).arg(statusInfo));
+ else
+ setWindowTitle(trackInfo);
+}
+
+void Player::showColorDialog()
+{
+ if (!colorDialog) {
+ QSlider *brightnessSlider = new QSlider(Qt::Horizontal);
+ brightnessSlider->setRange(-100, 100);
+ brightnessSlider->setValue(videoWidget->brightness());
+ connect(brightnessSlider, SIGNAL(sliderMoved(int)), videoWidget, SLOT(setBrightness(int)));
+ connect(videoWidget, SIGNAL(brightnessChanged(int)), brightnessSlider, SLOT(setValue(int)));
+
+ QSlider *contrastSlider = new QSlider(Qt::Horizontal);
+ contrastSlider->setRange(-100, 100);
+ contrastSlider->setValue(videoWidget->contrast());
+ connect(contrastSlider, SIGNAL(sliderMoved(int)), videoWidget, SLOT(setContrast(int)));
+ connect(videoWidget, SIGNAL(contrastChanged(int)), contrastSlider, SLOT(setValue(int)));
+
+ QSlider *hueSlider = new QSlider(Qt::Horizontal);
+ hueSlider->setRange(-100, 100);
+ hueSlider->setValue(videoWidget->hue());
+ connect(hueSlider, SIGNAL(sliderMoved(int)), videoWidget, SLOT(setHue(int)));
+ connect(videoWidget, SIGNAL(hueChanged(int)), hueSlider, SLOT(setValue(int)));
+
+ QSlider *saturationSlider = new QSlider(Qt::Horizontal);
+ saturationSlider->setRange(-100, 100);
+ saturationSlider->setValue(videoWidget->saturation());
+ connect(saturationSlider, SIGNAL(sliderMoved(int)), videoWidget, SLOT(setSaturation(int)));
+ connect(videoWidget, SIGNAL(saturationChanged(int)), saturationSlider, SLOT(setValue(int)));
+
+ QFormLayout *layout = new QFormLayout;
+ layout->addRow(tr("Brightness"), brightnessSlider);
+ layout->addRow(tr("Contrast"), contrastSlider);
+ layout->addRow(tr("Hue"), hueSlider);
+ layout->addRow(tr("Saturation"), saturationSlider);
+
+ colorDialog = new QDialog(this);
+ colorDialog->setWindowTitle(tr("Color Options"));
+ colorDialog->setLayout(layout);
+ }
+ colorDialog->show();
+}
diff --git a/demos/multimedia/player/player.h b/demos/multimedia/player/player.h
new file mode 100644
index 0000000..0ad609b
--- /dev/null
+++ b/demos/multimedia/player/player.h
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PLAYER_H
+#define PLAYER_H
+
+#include <QtGui/QWidget>
+
+#include <qmediaplayer.h>
+#include <qmediaplaylist.h>
+#include <qvideowidget.h>
+
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QAbstractItemView;
+class QLabel;
+class QModelIndex;
+class QSlider;
+class QMediaPlayer;
+class QVideoWidget;
+class PlaylistModel;
+
+class Player : public QWidget
+{
+ Q_OBJECT
+public:
+ Player(QWidget *parent = 0);
+ ~Player();
+
+Q_SIGNALS:
+ void fullScreenChanged(bool fullScreen);
+
+private slots:
+ void open();
+ void durationChanged(qint64 duration);
+ void positionChanged(qint64 progress);
+ void metaDataChanged();
+
+ void seek(int seconds);
+ void jump(const QModelIndex &index);
+ void playlistPositionChanged(int);
+
+ void statusChanged(QMediaPlayer::MediaStatus status);
+ void bufferingProgress(int progress);
+
+ void showColorDialog();
+
+private:
+ void setTrackInfo(const QString &info);
+ void setStatusInfo(const QString &info);
+
+ QMediaPlayer *player;
+ QMediaPlaylist *playlist;
+ QVideoWidget *videoWidget;
+ QLabel *coverLabel;
+ QSlider *slider;
+ PlaylistModel *playlistModel;
+ QAbstractItemView *playlistView;
+ QDialog *colorDialog;
+ QString trackInfo;
+ QString statusInfo;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/demos/multimedia/player/player.pro b/demos/multimedia/player/player.pro
new file mode 100644
index 0000000..dc731e4
--- /dev/null
+++ b/demos/multimedia/player/player.pro
@@ -0,0 +1,22 @@
+TEMPLATE = app
+TARGET = player
+
+QT += gui multimedia
+
+
+HEADERS = \
+ player.h \
+ playercontrols.h \
+ playlistmodel.h \
+ videowidget.h
+
+SOURCES = \
+ main.cpp \
+ player.cpp \
+ playercontrols.cpp \
+ playlistmodel.cpp \
+ videowidget.cpp
+
+target.path = $$[QT_INSTALL_DEMOS]/multimedia/player
+INSTALLS += target
+
diff --git a/demos/multimedia/player/playercontrols.cpp b/demos/multimedia/player/playercontrols.cpp
new file mode 100644
index 0000000..3798a71
--- /dev/null
+++ b/demos/multimedia/player/playercontrols.cpp
@@ -0,0 +1,205 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "playercontrols.h"
+
+#include <QtGui/qboxlayout.h>
+#include <QtGui/qslider.h>
+#include <QtGui/qstyle.h>
+#include <QtGui/qtoolbutton.h>
+#include <QtGui/qcombobox.h>
+
+PlayerControls::PlayerControls(QWidget *parent)
+ : QWidget(parent)
+ , playerState(QMediaPlayer::StoppedState)
+ , playerMuted(false)
+ , playButton(0)
+ , stopButton(0)
+ , nextButton(0)
+ , previousButton(0)
+ , muteButton(0)
+ , volumeSlider(0)
+ , rateBox(0)
+{
+ playButton = new QToolButton;
+ playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
+
+ connect(playButton, SIGNAL(clicked()), this, SLOT(playClicked()));
+
+ stopButton = new QToolButton;
+ stopButton->setIcon(style()->standardIcon(QStyle::SP_MediaStop));
+ stopButton->setEnabled(false);
+
+ connect(stopButton, SIGNAL(clicked()), this, SIGNAL(stop()));
+
+ nextButton = new QToolButton;
+ nextButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipForward));
+
+ connect(nextButton, SIGNAL(clicked()), this, SIGNAL(next()));
+
+ previousButton = new QToolButton;
+ previousButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipBackward));
+
+ connect(previousButton, SIGNAL(clicked()), this, SIGNAL(previous()));
+
+ muteButton = new QToolButton;
+ muteButton->setIcon(style()->standardIcon(QStyle::SP_MediaVolume));
+
+ connect(muteButton, SIGNAL(clicked()), this, SLOT(muteClicked()));
+
+ volumeSlider = new QSlider(Qt::Horizontal);
+ volumeSlider->setRange(0, 100);
+
+ connect(volumeSlider, SIGNAL(sliderMoved(int)), this, SIGNAL(changeVolume(int)));
+
+ rateBox = new QComboBox;
+ rateBox->addItem("0.5x", QVariant(0.5));
+ rateBox->addItem("1.0x", QVariant(1.0));
+ rateBox->addItem("2.0x", QVariant(2.0));
+ rateBox->setCurrentIndex(1);
+
+ connect(rateBox, SIGNAL(activated(int)), SLOT(updateRate()));
+
+ QBoxLayout *layout = new QHBoxLayout;
+ layout->setMargin(0);
+ layout->addWidget(stopButton);
+ layout->addWidget(previousButton);
+ layout->addWidget(playButton);
+ layout->addWidget(nextButton);
+ layout->addWidget(muteButton);
+ layout->addWidget(volumeSlider);
+ layout->addWidget(rateBox);
+ setLayout(layout);
+}
+
+QMediaPlayer::State PlayerControls::state() const
+{
+ return playerState;
+}
+
+void PlayerControls::setState(QMediaPlayer::State state)
+{
+ if (state != playerState) {
+ playerState = state;
+
+ switch (state) {
+ case QMediaPlayer::StoppedState:
+ stopButton->setEnabled(false);
+ playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
+ break;
+ case QMediaPlayer::PlayingState:
+ stopButton->setEnabled(true);
+ playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
+ break;
+ case QMediaPlayer::PausedState:
+ stopButton->setEnabled(true);
+ playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
+ break;
+ }
+ }
+}
+
+int PlayerControls::volume() const
+{
+ return volumeSlider->value();
+}
+
+void PlayerControls::setVolume(int volume)
+{
+ volumeSlider->setValue(volume);
+}
+
+bool PlayerControls::isMuted() const
+{
+ return playerMuted;
+}
+
+void PlayerControls::setMuted(bool muted)
+{
+ if (muted != playerMuted) {
+ playerMuted = muted;
+
+ muteButton->setIcon(style()->standardIcon(muted
+ ? QStyle::SP_MediaVolumeMuted
+ : QStyle::SP_MediaVolume));
+ }
+}
+
+void PlayerControls::playClicked()
+{
+ switch (playerState) {
+ case QMediaPlayer::StoppedState:
+ case QMediaPlayer::PausedState:
+ emit play();
+ break;
+ case QMediaPlayer::PlayingState:
+ emit pause();
+ break;
+ }
+}
+
+void PlayerControls::muteClicked()
+{
+ emit changeMuting(!playerMuted);
+}
+
+qreal PlayerControls::playbackRate() const
+{
+ return rateBox->itemData(rateBox->currentIndex()).toDouble();
+}
+
+void PlayerControls::setPlaybackRate(float rate)
+{
+ for (int i=0; i<rateBox->count(); i++) {
+ if (qFuzzyCompare(rate, float(rateBox->itemData(i).toDouble()))) {
+ rateBox->setCurrentIndex(i);
+ return;
+ }
+ }
+
+ rateBox->addItem( QString("%1x").arg(rate), QVariant(rate));
+ rateBox->setCurrentIndex(rateBox->count()-1);
+}
+
+void PlayerControls::updateRate()
+{
+ emit changeRate(playbackRate());
+}
diff --git a/demos/multimedia/player/playercontrols.h b/demos/multimedia/player/playercontrols.h
new file mode 100644
index 0000000..99894ff
--- /dev/null
+++ b/demos/multimedia/player/playercontrols.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PLAYERCONTROLS_H
+#define PLAYERCONTROLS_H
+
+#include <QtMultimedia/qmediaplayer.h>
+
+#include <QtGui/qwidget.h>
+
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QAbstractButton;
+class QAbstractSlider;
+class QComboBox;
+
+class PlayerControls : public QWidget
+{
+ Q_OBJECT
+public:
+ PlayerControls(QWidget *parent = 0);
+
+ QMediaPlayer::State state() const;
+
+ int volume() const;
+ bool isMuted() const;
+ qreal playbackRate() const;
+
+public slots:
+ void setState(QMediaPlayer::State state);
+ void setVolume(int volume);
+ void setMuted(bool muted);
+ void setPlaybackRate(float rate);
+
+signals:
+ void play();
+ void pause();
+ void stop();
+ void next();
+ void previous();
+ void changeVolume(int volume);
+ void changeMuting(bool muting);
+ void changeRate(qreal rate);
+
+private slots:
+ void playClicked();
+ void muteClicked();
+ void updateRate();
+
+private:
+ QMediaPlayer::State playerState;
+ bool playerMuted;
+ QAbstractButton *playButton;
+ QAbstractButton *stopButton;
+ QAbstractButton *nextButton;
+ QAbstractButton *previousButton;
+ QAbstractButton *muteButton;
+ QAbstractSlider *volumeSlider;
+ QComboBox *rateBox;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/demos/multimedia/player/playlistmodel.cpp b/demos/multimedia/player/playlistmodel.cpp
new file mode 100644
index 0000000..b60f914
--- /dev/null
+++ b/demos/multimedia/player/playlistmodel.cpp
@@ -0,0 +1,160 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "playlistmodel.h"
+
+#include <QtCore/qfileinfo.h>
+#include <QtCore/qurl.h>
+
+#include <qmediaplaylist.h>
+
+PlaylistModel::PlaylistModel(QObject *parent)
+ : QAbstractItemModel(parent)
+ , m_playlist(0)
+{
+}
+
+int PlaylistModel::rowCount(const QModelIndex &parent) const
+{
+ return m_playlist && !parent.isValid() ? m_playlist->mediaCount() : 0;
+}
+
+int PlaylistModel::columnCount(const QModelIndex &parent) const
+{
+ return !parent.isValid() ? ColumnCount : 0;
+}
+
+QModelIndex PlaylistModel::index(int row, int column, const QModelIndex &parent) const
+{
+ return m_playlist && !parent.isValid()
+ && row >= 0 && row < m_playlist->mediaCount()
+ && column >= 0 && column < ColumnCount
+ ? createIndex(row, column)
+ : QModelIndex();
+}
+
+QModelIndex PlaylistModel::parent(const QModelIndex &child) const
+{
+ Q_UNUSED(child);
+
+ return QModelIndex();
+}
+
+QVariant PlaylistModel::data(const QModelIndex &index, int role) const
+{
+ if (index.isValid() && role == Qt::DisplayRole) {
+ QVariant value = m_data[index];
+ if (!value.isValid() && index.column() == Title) {
+ QUrl location = m_playlist->media(index.row()).canonicalUrl();
+ return QFileInfo(location.path()).fileName();
+ }
+
+ return value;
+ }
+ return QVariant();
+}
+
+QMediaPlaylist *PlaylistModel::playlist() const
+{
+ return m_playlist;
+}
+
+void PlaylistModel::setPlaylist(QMediaPlaylist *playlist)
+{
+ if (m_playlist) {
+ disconnect(m_playlist, SIGNAL(mediaAboutToBeInserted(int,int)), this, SLOT(beginInsertItems(int,int)));
+ disconnect(m_playlist, SIGNAL(mediaInserted(int,int)), this, SLOT(endInsertItems()));
+ disconnect(m_playlist, SIGNAL(mediaAboutToBeRemoved(int,int)), this, SLOT(beginRemoveItems(int,int)));
+ disconnect(m_playlist, SIGNAL(mediaRemoved(int,int)), this, SLOT(endRemoveItems()));
+ disconnect(m_playlist, SIGNAL(mediaChanged(int,int)), this, SLOT(changeItems(int,int)));
+ }
+
+ m_playlist = playlist;
+
+ if (m_playlist) {
+ connect(m_playlist, SIGNAL(mediaAboutToBeInserted(int,int)), this, SLOT(beginInsertItems(int,int)));
+ connect(m_playlist, SIGNAL(mediaInserted(int,int)), this, SLOT(endInsertItems()));
+ connect(m_playlist, SIGNAL(mediaAboutToBeRemoved(int,int)), this, SLOT(beginRemoveItems(int,int)));
+ connect(m_playlist, SIGNAL(mediaRemoved(int,int)), this, SLOT(endRemoveItems()));
+ connect(m_playlist, SIGNAL(mediaChanged(int,int)), this, SLOT(changeItems(int,int)));
+ }
+
+
+ reset();
+}
+
+bool PlaylistModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ Q_UNUSED(role);
+ m_data[index] = value;
+ emit dataChanged(index, index);
+ return true;
+}
+
+void PlaylistModel::beginInsertItems(int start, int end)
+{
+ m_data.clear();
+ beginInsertRows(QModelIndex(), start, end);
+}
+
+void PlaylistModel::endInsertItems()
+{
+ endInsertRows();
+}
+
+void PlaylistModel::beginRemoveItems(int start, int end)
+{
+ m_data.clear();
+ beginRemoveRows(QModelIndex(), start, end);
+}
+
+void PlaylistModel::endRemoveItems()
+{
+ endInsertRows();
+}
+
+void PlaylistModel::changeItems(int start, int end)
+{
+ m_data.clear();
+ emit dataChanged(index(start,0), index(end,ColumnCount));
+}
+
+
diff --git a/demos/multimedia/player/playlistmodel.h b/demos/multimedia/player/playlistmodel.h
new file mode 100644
index 0000000..0180282
--- /dev/null
+++ b/demos/multimedia/player/playlistmodel.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PLAYLISTMODEL_H
+#define PLAYLISTMODEL_H
+
+#include <QtCore/qabstractitemmodel.h>
+
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QMediaPlaylist;
+
+class PlaylistModel : public QAbstractItemModel
+{
+ Q_OBJECT
+public:
+ enum Column
+ {
+ Title = 0,
+ ColumnCount
+ };
+
+ PlaylistModel(QObject *parent = 0);
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
+ QModelIndex parent(const QModelIndex &child) const;
+
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+
+ QMediaPlaylist *playlist() const;
+ void setPlaylist(QMediaPlaylist *playlist);
+
+ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::DisplayRole);
+
+private slots:
+ void beginInsertItems(int start, int end);
+ void endInsertItems();
+ void beginRemoveItems(int start, int end);
+ void endRemoveItems();
+ void changeItems(int start, int end);
+
+private:
+ QMediaPlaylist *m_playlist;
+ QMap<QModelIndex, QVariant> m_data;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/demos/multimedia/player/videowidget.cpp b/demos/multimedia/player/videowidget.cpp
new file mode 100644
index 0000000..3bf36c3
--- /dev/null
+++ b/demos/multimedia/player/videowidget.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "videowidget.h"
+
+#include <QtGui>
+
+VideoWidget::VideoWidget(QWidget *parent)
+ : QVideoWidget(parent)
+{
+ setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
+}
+
+void VideoWidget::keyPressEvent(QKeyEvent *event)
+{
+ if (event->key() == Qt::Key_Escape && isFullScreen()) {
+ showNormal();
+
+ event->accept();
+ } else if (event->key() == Qt::Key_Enter && event->modifiers() & Qt::Key_Alt) {
+ setFullScreen(!isFullScreen());
+
+ event->accept();
+ } else {
+ QVideoWidget::keyPressEvent(event);
+ }
+}
+
+void VideoWidget::mouseDoubleClickEvent(QMouseEvent *event)
+{
+ setFullScreen(!isFullScreen());
+
+ event->accept();
+}
diff --git a/demos/multimedia/player/videowidget.h b/demos/multimedia/player/videowidget.h
new file mode 100644
index 0000000..543e1e0
--- /dev/null
+++ b/demos/multimedia/player/videowidget.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef VIDEOWIDGET_H
+#define VIDEOWIDGET_H
+
+#include <QtMultimedia/qvideowidget.h>
+
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class VideoWidget : public QVideoWidget
+{
+ Q_OBJECT
+public:
+ VideoWidget(QWidget *parent = 0);
+
+protected:
+ void keyPressEvent(QKeyEvent *event);
+ void mouseDoubleClickEvent(QMouseEvent *event);
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif