diff options
Diffstat (limited to 'demos')
22 files changed, 121 insertions, 114 deletions
diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml index 54af7ad..66705e2 100644 --- a/demos/declarative/calculator/calculator.qml +++ b/demos/declarative/calculator/calculator.qml @@ -118,7 +118,7 @@ Rectangle { } transitions: Transition { - NumberAnimation { properties: "x,y,width"; easing: "easeOutBounce"; duration: 500 } - NumberAnimation { properties: "opacity"; easing: "easeInOutQuad"; duration: 500 } + NumberAnimation { properties: "x,y,width"; easing.type: "OutBounce"; duration: 500 } + NumberAnimation { properties: "opacity"; easing.type: "InOutQuad"; duration: 500 } } } diff --git a/demos/declarative/flickr/common/ImageDetails.qml b/demos/declarative/flickr/common/ImageDetails.qml index 19cad06..f91b365 100644 --- a/demos/declarative/flickr/common/ImageDetails.qml +++ b/demos/declarative/flickr/common/ImageDetails.qml @@ -50,7 +50,7 @@ Flipable { LikeOMeter { x: 40; y: 250; rating: container.rating } Flickable { id: flickable; x: 220; width: 480; height: 210; y: 130; clip: true - viewportWidth: 480; viewportHeight: descriptionText.height + contentWidth: 480; contentHeight: descriptionText.height WebView { id: descriptionText; width: parent.width html: "<style TYPE=\"text/css\">body {color: white;} a:link {color: cyan; text-decoration: underline; }</style>" + container.photoDescription } @@ -84,7 +84,7 @@ Flipable { Flickable { id: flick; width: container.width - 10; height: container.height - 10 x: 5; y: 5; clip: true; - viewportWidth: imageContainer.width; viewportHeight: imageContainer.height + contentWidth: imageContainer.width; contentHeight: imageContainer.height Item { id: imageContainer @@ -122,12 +122,12 @@ Flipable { id: slider; x: 25; y: 374; visible: { bigImage.status == 1 && maximum > minimum } onValueChanged: { if (bigImage.width * value > flick.width) { - var xoff = (flick.width/2 + flick.viewportX) * value / prevScale; - flick.viewportX = xoff - flick.width/2; + var xoff = (flick.width/2 + flick.contentX) * value / prevScale; + flick.contentX = xoff - flick.width/2; } if (bigImage.height * value > flick.height) { - var yoff = (flick.height/2 + flick.viewportY) * value / prevScale; - flick.viewportY = yoff - flick.height/2; + var yoff = (flick.height/2 + flick.contentY) * value / prevScale; + flick.contentY = yoff - flick.height/2; } prevScale = value; } @@ -149,7 +149,7 @@ Flipable { property: "smooth" value: false } - NumberAnimation { easing: "easeInOutQuad"; properties: "angle"; duration: 500 } + NumberAnimation { easing.type: "InOutQuad"; properties: "angle"; duration: 500 } PropertyAction { target: bigImage property: "smooth" diff --git a/demos/declarative/flickr/common/MediaLineEdit.qml b/demos/declarative/flickr/common/MediaLineEdit.qml index 3dfd1f3..9559f6a 100644 --- a/demos/declarative/flickr/common/MediaLineEdit.qml +++ b/demos/declarative/flickr/common/MediaLineEdit.qml @@ -42,7 +42,7 @@ Item { ] transitions: [ Transition { - NumberAnimation { properties: "x,width"; duration: 500; easing: "easeInOutQuad" } + NumberAnimation { properties: "x,width"; duration: 500; easing.type: "InOutQuad" } } ] diff --git a/demos/declarative/flickr/common/Star.qml b/demos/declarative/flickr/common/Star.qml index 8cd47b4..748a5ec 100644 --- a/demos/declarative/flickr/common/Star.qml +++ b/demos/declarative/flickr/common/Star.qml @@ -38,7 +38,7 @@ Item { Transition { NumberAnimation { properties: "opacity,scale,x,y" - easing: "easeOutBounce" + easing.type: "OutBounce" } } ] diff --git a/demos/declarative/flickr/flickr-desktop.qml b/demos/declarative/flickr/flickr-desktop.qml index 1ca3cdc..99216cb 100644 --- a/demos/declarative/flickr/flickr-desktop.qml +++ b/demos/declarative/flickr/flickr-desktop.qml @@ -21,9 +21,9 @@ Item { angle: wrapper.PathView.angle ? wrapper.PathView.angle : 0 } - Connection { - sender: imageDetails; signal: "closed()" - script: { + Connections { + target: imageDetails + onClosed: { if (wrapper.state == 'Details') { wrapper.state = ''; imageDetails.photoUrl = ""; @@ -86,14 +86,14 @@ Item { from: "*"; to: "Details" SequentialAnimation { ParentAction { } - NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" } + NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing.type: "InOutQuad" } } }, Transition { from: "Details"; to: "*" SequentialAnimation { ParentAction { } - NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" } + NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing.type: "InOutQuad" } PropertyAction { targets: wrapper; properties: "z" } } } @@ -180,7 +180,7 @@ Item { transitions: [ Transition { from: "*"; to: "*" - NumberAnimation { properties: "y"; duration: 1000; easing: "easeOutBounce(amplitude:0.5)" } + NumberAnimation { properties: "y"; duration: 1000; easing.type: "OutBounce"; easing.amplitude: 0.5 } } ] } diff --git a/demos/declarative/flickr/flickr-mobile.qml b/demos/declarative/flickr/flickr-mobile.qml index 0a89c4f..21e4c49 100644 --- a/demos/declarative/flickr/flickr-mobile.qml +++ b/demos/declarative/flickr/flickr-mobile.qml @@ -38,7 +38,7 @@ Item { } transitions: Transition { - NumberAnimation { properties: "x"; duration: 500; easing: "easeInOutQuad" } + NumberAnimation { properties: "x"; duration: 500; easing.type: "InOutQuad" } } } @@ -53,9 +53,9 @@ Item { onButton2Clicked: if (screen.inListView == true) screen.inListView = false; else screen.inListView = true } - Connection { - sender: imageDetails; signal: "closed()" - script: { + Connections { + target: imageDetails + onClosed: { if (background.state == "DetailedView") { background.state = ''; imageDetails.photoUrl = ""; @@ -76,7 +76,7 @@ Item { } transitions: Transition { - NumberAnimation { properties: "x"; duration: 500; easing: "easeInOutQuad" } + NumberAnimation { properties: "x"; duration: 500; easing.type: "InOutQuad" } } } } diff --git a/demos/declarative/flickr/mobile/GridDelegate.qml b/demos/declarative/flickr/mobile/GridDelegate.qml index 0f5b69c..7634573 100644 --- a/demos/declarative/flickr/mobile/GridDelegate.qml +++ b/demos/declarative/flickr/mobile/GridDelegate.qml @@ -23,7 +23,7 @@ Item { anchors.centerIn: parent scale: 0.0 - scale: Behavior { NumberAnimation { easing: "easeInOutQuad"} } + scale: Behavior { NumberAnimation { easing.type: "InOutQuad"} } id: scaleMe Rectangle { height: 79; width: 79; id: blackRect; anchors.centerIn: parent; color: "black"; smooth: true } @@ -33,9 +33,9 @@ Image { source: "images/gloss.png" } } - Connection { - sender: toolBar; signal: "button2Clicked()" - script: if (scaleMe.state == 'Details' ) scaleMe.state = 'Show'; + Connections { + target: toolBar + onButton2Clicked: if (scaleMe.state == 'Details' ) scaleMe.state = 'Show' } states: [ @@ -55,13 +55,13 @@ Transition { from: "Show"; to: "Details" ParentAction { } - NumberAnimation { properties: "x,y"; duration: 500; easing: "easeInOutQuad" } + NumberAnimation { properties: "x,y"; duration: 500; easing.type: "InOutQuad" } }, Transition { from: "Details"; to: "Show" SequentialAnimation { ParentAction { } - NumberAnimation { properties: "x,y"; duration: 500; easing: "easeInOutQuad" } + NumberAnimation { properties: "x,y"; duration: 500; easing.type: "InOutQuad" } PropertyAction { targets: wrapper; properties: "z" } } } diff --git a/demos/declarative/flickr/mobile/ImageDetails.qml b/demos/declarative/flickr/mobile/ImageDetails.qml index 1963bf5..8749b4c 100644 --- a/demos/declarative/flickr/mobile/ImageDetails.qml +++ b/demos/declarative/flickr/mobile/ImageDetails.qml @@ -57,7 +57,7 @@ Flipable { Common.Progress { anchors.centerIn: parent; width: 200; height: 18; progress: bigImage.progress; visible: bigImage.status!=1 } Flickable { id: flickable; anchors.fill: parent; clip: true - viewportWidth: imageContainer.width; viewportHeight: imageContainer.height + contentWidth: imageContainer.width; contentHeight: imageContainer.height Item { id: imageContainer @@ -97,12 +97,12 @@ Flipable { } onValueChanged: { if (bigImage.width * value > flickable.width) { - var xoff = (flickable.width/2 + flickable.viewportX) * value / prevScale; - flickable.viewportX = xoff - flickable.width/2; + var xoff = (flickable.width/2 + flickable.contentX) * value / prevScale; + flickable.contentX = xoff - flickable.width/2; } if (bigImage.height * value > flickable.height) { - var yoff = (flickable.height/2 + flickable.viewportY) * value / prevScale; - flickable.viewportY = yoff - flickable.height/2; + var yoff = (flickable.height/2 + flickable.contentY) * value / prevScale; + flickable.contentY = yoff - flickable.height/2; } prevScale = value; } @@ -117,7 +117,7 @@ Flipable { transitions: Transition { SequentialAnimation { PropertyAction { target: bigImage; property: "smooth"; value: false } - NumberAnimation { easing: "easeInOutQuad"; properties: "angle"; duration: 500 } + NumberAnimation { easing.type: "InOutQuad"; 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 07b9762..0a06771 100644 --- a/demos/declarative/flickr/mobile/TitleBar.qml +++ b/demos/declarative/flickr/mobile/TitleBar.qml @@ -71,6 +71,6 @@ Item { } transitions: Transition { - NumberAnimation { properties: "x"; easing: "easeInOutQuad" } + NumberAnimation { properties: "x"; easing.type: "InOutQuad" } } } diff --git a/demos/declarative/minehunt/main.cpp b/demos/declarative/minehunt/main.cpp index 0b862e3..0e99731 100644 --- a/demos/declarative/minehunt/main.cpp +++ b/demos/declarative/minehunt/main.cpp @@ -38,11 +38,11 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "qmlengine.h" -#include "qmlcontext.h" -#include "qml.h" -#include <qmlgraphicsitem.h> -#include <qmlview.h> +#include "qdeclarativeengine.h" +#include "qdeclarativecontext.h" +#include "qdeclarative.h" +#include <qdeclarativeitem.h> +#include <qdeclarativeview.h> #include <QWidget> #include <QApplication> @@ -92,7 +92,6 @@ private: }; QML_DECLARE_TYPE(Tile); -QML_DEFINE_TYPE(0,0,0,Tile,Tile); class MyWidget : public QWidget { @@ -134,7 +133,7 @@ private: int getHint(int row, int col); void setPlaying(bool b){if(b==playing) return; playing=b; emit isPlayingChanged();} - QmlView *canvas; + QDeclarativeView *canvas; QList<Tile *> _tiles; int numCols; @@ -163,17 +162,15 @@ MyWidget::MyWidget(int width, int height, QWidget *parent, Qt::WindowFlags flags vbox->setMargin(0); setLayout(vbox); - canvas = new QmlView(this); + canvas = new QDeclarativeView(this); canvas->setFixedSize(width, height); vbox->addWidget(canvas); - canvas->setSource(QUrl::fromLocalFile(fileName)); - - QmlContext *ctxt = canvas->rootContext(); + QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->addDefaultObject(this); ctxt->setContextProperty("tiles", QVariant::fromValue<QList<Tile*>*>(&_tiles));//QTBUG-5675 - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(fileName)); } MyWidget::~MyWidget() @@ -323,6 +320,8 @@ int main(int argc, char ** argv) int width = 370; int height = 480; + QML_REGISTER_TYPE(0,0,0,Tile,Tile); + for (int i = 1; i < argc; ++i) { QString arg = argv[i]; if (arg == "-frameless") { diff --git a/demos/declarative/minehunt/minehunt.qml b/demos/declarative/minehunt/minehunt.qml index 92555c2..617a6ed 100644 --- a/demos/declarative/minehunt/minehunt.qml +++ b/demos/declarative/minehunt/minehunt.qml @@ -92,7 +92,7 @@ Item { } } NumberAnimation { - easing: "easeInOutQuad" + easing.type: "InOutQuad" properties: "angle" } ScriptAction{ diff --git a/demos/declarative/snake/snake.qml b/demos/declarative/snake/snake.qml index 3bec747..09b6b7f 100644 --- a/demos/declarative/snake/snake.qml +++ b/demos/declarative/snake/snake.qml @@ -172,14 +172,14 @@ Rectangle { states: [ State { name: "starting" - when: startHeartbeatTimer.running; + when: startHeartbeatTimer.running PropertyChanges {target: progressIndicator; width: 200} PropertyChanges {target: title; opacity: 0} PropertyChanges {target: progressBar; opacity: 1} }, State { name: "running" - when: heartbeat.running + when: (heartbeat.running && !startHeartbeatTimer.running) PropertyChanges {target: progressIndicator; width: 200} PropertyChanges {target: title; opacity: 0} PropertyChanges {target: skull; row: 0; column: 0; } diff --git a/demos/declarative/twitter/content/HomeTitleBar.qml b/demos/declarative/twitter/content/HomeTitleBar.qml index 8054f2e..a206c87 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 { properties: "x,y,width,height"; easing: "easeInOutQuad" } + NumberAnimation { properties: "x,y,width,height"; easing.type: "InOutQuad" } } ] } diff --git a/demos/declarative/twitter/content/MultiTitleBar.qml b/demos/declarative/twitter/content/MultiTitleBar.qml index ef7de65..e0205b8 100644 --- a/demos/declarative/twitter/content/MultiTitleBar.qml +++ b/demos/declarative/twitter/content/MultiTitleBar.qml @@ -18,7 +18,7 @@ Item { } ] transitions: [ - Transition { NumberAnimation { properties: "x,y"; duration: 500; easing: "easeInOutQuad" } } + Transition { NumberAnimation { properties: "x,y"; duration: 500; easing.type: "InOutQuad" } } ] } diff --git a/demos/declarative/twitter/content/TitleBar.qml b/demos/declarative/twitter/content/TitleBar.qml index 42a6115..149aa82 100644 --- a/demos/declarative/twitter/content/TitleBar.qml +++ b/demos/declarative/twitter/content/TitleBar.qml @@ -72,6 +72,6 @@ Item { } transitions: Transition { - NumberAnimation { properties: "x"; easing: "easeInOutQuad" } + NumberAnimation { properties: "x"; easing.type: "InOutQuad" } } } diff --git a/demos/declarative/twitter/twitter.qml b/demos/declarative/twitter/twitter.qml index d2abf28..b091b03 100644 --- a/demos/declarative/twitter/twitter.qml +++ b/demos/declarative/twitter/twitter.qml @@ -89,7 +89,7 @@ Item { } ] transitions: [ - Transition { NumberAnimation { properties: "x,y"; duration: 500; easing: "easeInOutQuad" } } + Transition { NumberAnimation { properties: "x,y"; duration: 500; easing.type: "InOutQuad" } } ] } } diff --git a/demos/declarative/webbrowser/content/FlickableWebView.qml b/demos/declarative/webbrowser/content/FlickableWebView.qml index 7c46d4c..76a5813 100644 --- a/demos/declarative/webbrowser/content/FlickableWebView.qml +++ b/demos/declarative/webbrowser/content/FlickableWebView.qml @@ -2,6 +2,7 @@ import Qt 4.6 Flickable { property alias title: webView.title + property alias icon: webView.icon property alias progress: webView.progress property alias url: webView.url property alias back: webView.back @@ -10,8 +11,8 @@ Flickable { id: flickable width: parent.width - viewportWidth: Math.max(parent.width,webView.width*webView.scale) - viewportHeight: Math.max(parent.height,webView.height*webView.scale) + contentWidth: Math.max(parent.width,webView.width*webView.scale) + contentHeight: Math.max(parent.height,webView.height*webView.scale) anchors.top: headerSpace.bottom anchors.bottom: footer.top anchors.left: parent.left @@ -53,10 +54,10 @@ Flickable { if (centerX) { var sc = zoom/contentsScale; scaleAnim.to = sc; - flickVX.from = flickable.viewportX + flickVX.from = flickable.contentX flickVX.to = Math.max(0,Math.min(centerX-flickable.width/2,webView.width*sc-flickable.width)) finalX.value = flickVX.to - flickVY.from = flickable.viewportY + flickVY.from = flickable.contentY flickVY.to = Math.max(0,Math.min(centerY-flickable.height/2,webView.height*sc-flickable.height)) finalY.value = flickVY.to finalZoom.value = zoom @@ -76,8 +77,8 @@ Flickable { } onUrlChanged: { // got to topleft - flickable.viewportX = 0 - flickable.viewportY = 0 + flickable.contentX = 0 + flickable.contentY = 0 if (url != null) { header.editUrl = url.toString(); } } onDoubleClick: { @@ -104,14 +105,14 @@ Flickable { property: "scale" from: 1 to: 0 // set before calling - easing: "easeLinear" + easing.type: "Linear" duration: 200 } NumberAnimation { id: flickVX target: flickable - property: "viewportX" - easing: "easeLinear" + property: "contentX" + easing.type: "Linear" duration: 200 from: 0 // set before calling to: 0 // set before calling @@ -119,8 +120,8 @@ Flickable { NumberAnimation { id: flickVY target: flickable - property: "viewportY" - easing: "easeLinear" + property: "contentY" + easing.type: "Linear" duration: 200 from: 0 // set before calling to: 0 // set before calling @@ -136,19 +137,19 @@ Flickable { property: "scale" value: 1.0 } - // Have to set the viewportXY, since the above 2 + // Have to set the contentXY, since the above 2 // size changes may have started a correction if // contentsScale < 1.0. PropertyAction { id: finalX target: flickable - property: "viewportX" + property: "contentX" value: 0 // set before calling } PropertyAction { id: finalY target: flickable - property: "viewportY" + property: "contentY" value: 0 // set before calling } PropertyAction { diff --git a/demos/declarative/webbrowser/content/RetractingWebBrowserHeader.qml b/demos/declarative/webbrowser/content/RetractingWebBrowserHeader.qml index e58ab0a..94c94f2 100644 --- a/demos/declarative/webbrowser/content/RetractingWebBrowserHeader.qml +++ b/demos/declarative/webbrowser/content/RetractingWebBrowserHeader.qml @@ -9,35 +9,44 @@ Image { source: "pics/header.png" width: parent.width height: 60 - x: webView.viewportX < 0 ? -webView.viewportX : webView.viewportX > webView.viewportWidth-webView.width - ? -webView.viewportX+webView.viewportWidth-webView.width : 0 - y: webView.viewportY < 0 ? -webView.viewportY : progressOff* - (webView.viewportY>height?-height:-webView.viewportY) - Text { - id: headerText - - text: webView.title!='' || webView.progress == 1.0 ? webView.title : 'Loading...' - elide: Text.ElideRight - - color: "white" - styleColor: "black" - style: Text.Raised - - font.family: "Helvetica" - font.pointSize: 10 - font.bold: true - - anchors.left: header.left - anchors.right: header.right - anchors.leftMargin: 4 - anchors.rightMargin: 4 + x: webView.contentX < 0 ? -webView.contentX : webView.contentX > webView.contentWidth-webView.width + ? -webView.contentX+webView.contentWidth-webView.width : 0 + y: webView.contentY < 0 ? -webView.contentY : progressOff* + (webView.contentY>height?-height:-webView.contentY) + Row { + id: headerTitle + anchors.top: header.top anchors.topMargin: 4 - horizontalAlignment: Text.AlignHCenter + anchors.horizontalCenter: parent.horizontalCenter + spacing: 6 + + Image { + id: headerIcon + pixmap: webView.icon + } + + Text { + id: headerText + + text: webView.title!='' || webView.progress == 1.0 ? webView.title : 'Loading...' + elide: Text.ElideRight + //width: parent.width - headerIcon.width-4 + + color: "white" + styleColor: "black" + style: Text.Raised + + font.family: "Helvetica" + font.pointSize: 10 + font.bold: true + + horizontalAlignment: Text.AlignHCenter + } } Item { width: parent.width - anchors.top: headerText.bottom + anchors.top: headerTitle.bottom anchors.topMargin: 2 anchors.bottom: parent.bottom @@ -98,7 +107,7 @@ Image { NumberAnimation { targets: header properties: "progressOff" - easing: "easeInOutQuad" + easing.type: "InOutQuad" duration: 300 } } diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index 934593c..6a427f4 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -30,10 +30,10 @@ Item { anchors.bottom: footer.top } RectSoftShadow { - x: -webView.viewportX - y: -webView.viewportY - width: webView.viewportWidth - height: webView.viewportHeight+headerSpace.height + x: -webView.contentX + y: -webView.contentY + width: webView.contentWidth + height: webView.contentHeight+headerSpace.height } Item { id: headerSpace @@ -98,7 +98,7 @@ Item { Transition { NumberAnimation { properties: "opacity" - easing: "easeInOutQuad" + easing.type: "InOutQuad" duration: 300 } } @@ -154,7 +154,7 @@ Item { Transition { NumberAnimation { properties: "opacity" - easing: "easeInOutQuad" + easing.type: "InOutQuad" duration: 320 } } diff --git a/demos/embedded/desktopservices/contenttab.cpp b/demos/embedded/desktopservices/contenttab.cpp index 8714b9c..fa9c586 100644 --- a/demos/embedded/desktopservices/contenttab.cpp +++ b/demos/embedded/desktopservices/contenttab.cpp @@ -114,20 +114,6 @@ QUrl ContentTab::itemUrl(QListWidgetItem *item) void ContentTab::keyPressEvent(QKeyEvent *event) { switch (event->key()) { - case Qt::Key_Up: - if (currentRow() == 0) { - setCurrentRow(count() - 1); - } else { - setCurrentRow(currentRow() - 1); - } - break; - case Qt::Key_Down: - if (currentRow() == (count() - 1)) { - setCurrentRow(0); - } else { - setCurrentRow(currentRow() + 1); - } - break; case Qt::Key_Select: openItem(currentItem()); default: diff --git a/demos/multimedia/player/player.cpp b/demos/multimedia/player/player.cpp index 64b1f25..49d18cb 100644 --- a/demos/multimedia/player/player.cpp +++ b/demos/multimedia/player/player.cpp @@ -99,7 +99,7 @@ Player::Player(QWidget *parent) 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(previous()), this, SLOT(previousClicked())); 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))); @@ -200,6 +200,16 @@ void Player::metaDataChanged() } } +void Player::previousClicked() +{ + // Go to previous track if we are within the first 5 seconds of playback + // Otherwise, seek to the beginning. + if(player->position() <= 5000) + playlist->previous(); + else + player->setPosition(0); +} + void Player::jump(const QModelIndex &index) { if (index.isValid()) { diff --git a/demos/multimedia/player/player.h b/demos/multimedia/player/player.h index 0ad609b..1de8b1a 100644 --- a/demos/multimedia/player/player.h +++ b/demos/multimedia/player/player.h @@ -77,6 +77,8 @@ private slots: void positionChanged(qint64 progress); void metaDataChanged(); + void previousClicked(); + void seek(int seconds); void jump(const QModelIndex &index); void playlistPositionChanged(int); |