diff options
author | Bea Lam <bea.lam@nokia.com> | 2010-03-08 23:39:57 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2010-03-08 23:39:57 (GMT) |
commit | db0c932bf816b76547798ec62336e25b453d29b8 (patch) | |
tree | 5f662f9318fd144e17146e2733ba7857473ec89c | |
parent | d4abbfdd1959a65ecfb997c962aa8ea132c77eaf (diff) | |
parent | 5f0912e71b6f10c2987eccbc62ea36ab5928f9b8 (diff) | |
download | Qt-db0c932bf816b76547798ec62336e25b453d29b8.zip Qt-db0c932bf816b76547798ec62336e25b453d29b8.tar.gz Qt-db0c932bf816b76547798ec62336e25b453d29b8.tar.bz2 |
Merge branch '4.7' of git@scm.dev.nokia.troll.no:qt/qt-qml into 4.7
44 files changed, 341 insertions, 546 deletions
diff --git a/demos/mainwindow/mainwindow.cpp b/demos/mainwindow/mainwindow.cpp index 32066d7..3ddb74b 100644 --- a/demos/mainwindow/mainwindow.cpp +++ b/demos/mainwindow/mainwindow.cpp @@ -329,7 +329,7 @@ void MainWindow::setupDockWidgets(const QMap<QString, QSize> &customSizeHints) BlueTitleBar *titlebar = new BlueTitleBar(swatch); swatch->setTitleBarWidget(titlebar); connect(swatch, SIGNAL(topLevelChanged(bool)), titlebar, SLOT(updateMask())); - connect(swatch, SIGNAL(featuresChanged(QDockWidget::DockWidgetFeatures)), titlebar, SLOT(updateMask())); + connect(swatch, SIGNAL(featuresChanged(QDockWidget::DockWidgetFeatures)), titlebar, SLOT(updateMask()), Qt::QueuedConnection); #ifdef Q_WS_QWS QPalette pal = palette(); diff --git a/examples/declarative/flipable/back.png b/examples/declarative/flipable/back.png Binary files differnew file mode 100644 index 0000000..0b4cafc --- /dev/null +++ b/examples/declarative/flipable/back.png diff --git a/examples/declarative/flipable/flipable.qml b/examples/declarative/flipable/flipable.qml new file mode 100644 index 0000000..c837ebc --- /dev/null +++ b/examples/declarative/flipable/flipable.qml @@ -0,0 +1,37 @@ +//! [0] +import Qt 4.6 + +Flipable { + id: flipable + width: 240 + height: 240 + + property int angle: 0 + property bool flipped: false + + front: Image { source: "front.png" } + back: Image { source: "back.png" } + + transform: Rotation { + origin.x: flipable.width/2; origin.y: flipable.height/2 + axis.x: 0; axis.y: 1; axis.z: 0 // rotate around y-axis + angle: flipable.angle + } + + states: State { + name: "back" + PropertyChanges { target: flipable; angle: 180 } + when: flipable.flipped + } + + transitions: Transition { + NumberAnimation { properties: "angle"; duration: 1000 } + } + + MouseArea { + anchors.fill: parent + onClicked: flipable.flipped = !flipable.flipped + } +} +//! [0] + diff --git a/examples/declarative/flipable/front.png b/examples/declarative/flipable/front.png Binary files differnew file mode 100644 index 0000000..796b605 --- /dev/null +++ b/examples/declarative/flipable/front.png diff --git a/src/declarative/graphicsitems/qdeclarativeflipable.cpp b/src/declarative/graphicsitems/qdeclarativeflipable.cpp index b36127f..1ebbaee 100644 --- a/src/declarative/graphicsitems/qdeclarativeflipable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflipable.cpp @@ -68,56 +68,31 @@ public: \brief The Flipable item provides a surface that can be flipped. \inherits Item - Flipable allows you to specify a front and a back and then flip between those sides. + Flipable is an item that can be visibly "flipped" between its front and + back sides. It is used together with Rotation and State/Transition to + produce a flipping effect. - Here's an example that flips between the front and back sides when clicked: + Here is a Flipable that flips whenever it is clicked: - \qml - - Flipable { - id: flipable - width: 250; height: 250 - property int angle: 0 - - transform: Rotation { - id: rotation - origin.x: flipable.width/2; origin.y: flipable.height/2 - axis.x: 0; axis.y: 1; axis.z: 0 // rotate around y-axis - angle: flipable.angle - } - - front: Image { source: "front.png" } - back: Image { source: "back.png" } - - states: State { - name: "back" - PropertyChanges { target: flipable; angle: 180 } - } - - transitions: Transition { - NumberAnimation { properties: "angle"; duration: 2000 } - } - - MouseArea { - // change between default and 'back' states - onClicked: flipable.state = (flipable.state == 'back' ? '' : 'back') - anchors.fill: parent - } - } - \endqml + \snippet examples/declarative/flipable/flipable.qml 0 \image flipable.gif + + The Rotation element is used to specify the angle and axis of the flip, + and the State defines the changes in angle which produce the flipping + effect. Finally, the Transition creates the animation that changes the + angle over one second. */ /*! \internal \class QDeclarativeFlipable - \brief The QDeclarativeFlipable class provides a flipable surface. + \brief The Flipable item provides a surface that can be flipped. \ingroup group_widgets - QDeclarativeFlipable allows you to specify a front and a back, as well as an - axis for the flip. + Flipable is an item that can be visibly "flipped" between its front and + back sides. */ QDeclarativeFlipable::QDeclarativeFlipable(QDeclarativeItem *parent) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index b0a7570..59dd43d 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -2217,7 +2217,7 @@ void QDeclarativeItem::setKeepMouseGrab(bool keep) \qmlmethod object Item::mapFromItem(Item item, int x, int y) Maps the point (\a x, \a y), which is in \a item's coordinate system, to - this item's coordinate system, and returns an object with \c x and \c y + this item's coordinate system, and returns an object with \c x and \c y properties matching the mapped cooordinate. If \a item is a \c null value, this maps the point from the coordinate @@ -2576,9 +2576,9 @@ bool QDeclarativeItem::sceneEvent(QEvent *event) !(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { keyPressEvent(static_cast<QKeyEvent *>(event)); if (!event->isAccepted()) - QGraphicsItem::sceneEvent(event); + return QGraphicsItem::sceneEvent(event); } else { - QGraphicsItem::sceneEvent(event); + return QGraphicsItem::sceneEvent(event); } } else { bool rv = QGraphicsItem::sceneEvent(event); diff --git a/src/declarative/graphicsitems/qdeclarativeparticles.cpp b/src/declarative/graphicsitems/qdeclarativeparticles.cpp index deabdd6..ec0bf6c 100644 --- a/src/declarative/graphicsitems/qdeclarativeparticles.cpp +++ b/src/declarative/graphicsitems/qdeclarativeparticles.cpp @@ -758,11 +758,13 @@ void QDeclarativeParticles::setSource(const QUrl &name) The particles element emits particles until it has count active particles. When this number is reached, new particles are not emitted until - some of the current particles reach theend of their lifespan. + some of the current particles reach the end of their lifespan. If count is -1 then there is no maximum number of active particles, and particles will be constantly emitted at the rate specified by emissionRate. + The default value for count is 1. + If both count and emissionRate are set to -1, nothing will be emitted. */ @@ -1219,7 +1221,7 @@ void QDeclarativeParticles::burst(int count, int emissionRate) void QDeclarativeParticlesPainter::updateSize() { - if (!isComponentComplete()) + if (!d->_componentComplete) return; const int parentX = parentItem()->x(); @@ -1304,7 +1306,7 @@ void QDeclarativeParticles::componentComplete() { Q_D(QDeclarativeParticles); QDeclarativeItem::componentComplete(); - if (d->count) { + if (d->count && d->emissionRate) { d->paintItem->updateSize(); d->clock.start(); } diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index 55f1c89..6bad4da 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -927,6 +927,8 @@ QDeclarativeVisualDataModel::ReleaseFlags QDeclarativeVisualDataModel::release(Q if (inPackage) { emit destroyingPackage(qobject_cast<QDeclarativePackage*>(obj)); } else { + if (item->hasFocus()) + item->clearFocus(); item->setOpacity(0.0); static_cast<QGraphicsItem*>(item)->setParentItem(0); } diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index 3c6c949..ef1032b 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -2204,6 +2204,8 @@ bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeParser::Object *obj) if (propNames.contains(prop.name)) COMPILE_EXCEPTION(&prop, QCoreApplication::translate("QDeclarativeCompiler","Duplicate property name")); + if (QString::fromUtf8(prop.name).at(0).isUpper()) + COMPILE_EXCEPTION(&prop, QCoreApplication::translate("QDeclarativeCompiler","Property names cannot begin with an upper case letter")); propNames.insert(prop.name); } @@ -2211,12 +2213,16 @@ bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeParser::Object *obj) QByteArray name = obj->dynamicSignals.at(ii).name; if (methodNames.contains(name)) COMPILE_EXCEPTION(obj, QCoreApplication::translate("QDeclarativeCompiler","Duplicate signal name")); + if (QString::fromUtf8(name).at(0).isUpper()) + COMPILE_EXCEPTION(obj, QCoreApplication::translate("QDeclarativeCompiler","Signal names cannot begin with an upper case letter")); methodNames.insert(name); } for (int ii = 0; ii < obj->dynamicSlots.count(); ++ii) { QByteArray name = obj->dynamicSlots.at(ii).name; if (methodNames.contains(name)) COMPILE_EXCEPTION(obj, QCoreApplication::translate("QDeclarativeCompiler","Duplicate method name")); + if (QString::fromUtf8(name).at(0).isUpper()) + COMPILE_EXCEPTION(obj, QCoreApplication::translate("QDeclarativeCompiler","Method names cannot begin with an upper case letter")); methodNames.insert(name); } diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 1e60df4..41d55d7 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -1234,17 +1234,13 @@ QScriptValue QDeclarativeEnginePrivate::tint(QScriptContext *ctxt, QScriptEngine else if (a == 0x00) finalColor = color; else { - uint src = tintColor.rgba(); - uint dest = color.rgba(); + qreal a = tintColor.alphaF(); + qreal inv_a = 1.0 - a; - uint res = (((a * (src & 0xFF00FF)) + - ((0xFF - a) * (dest & 0xFF00FF))) >> 8) & 0xFF00FF; - res |= (((a * ((src >> 8) & 0xFF00FF)) + - ((0xFF - a) * ((dest >> 8) & 0xFF00FF)))) & 0xFF00FF00; - if ((src & 0xFF000000) == 0xFF000000) - res |= 0xFF000000; - - finalColor = QColor::fromRgba(res); + finalColor.setRgbF(tintColor.redF() * a + color.redF() * inv_a, + tintColor.greenF() * a + color.greenF() * inv_a, + tintColor.blueF() * a + color.blueF() * inv_a, + a + inv_a * color.alphaF()); } return qScriptValueFromValue(engine, qVariantFromValue(finalColor)); diff --git a/src/declarative/util/qdeclarativebehavior.cpp b/src/declarative/util/qdeclarativebehavior.cpp index dea2c02..d90ca33 100644 --- a/src/declarative/util/qdeclarativebehavior.cpp +++ b/src/declarative/util/qdeclarativebehavior.cpp @@ -157,6 +157,7 @@ void QDeclarativeBehavior::setEnabled(bool enabled) void QDeclarativeBehavior::write(const QVariant &value) { Q_D(QDeclarativeBehavior); + qmlExecuteDeferred(this); if (!d->animation || !d->enabled) { QDeclarativePropertyPrivate::write(d->property, value, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); return; diff --git a/src/declarative/util/qdeclarativebehavior_p.h b/src/declarative/util/qdeclarativebehavior_p.h index a633b55..ff58210 100644 --- a/src/declarative/util/qdeclarativebehavior_p.h +++ b/src/declarative/util/qdeclarativebehavior_p.h @@ -65,6 +65,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeBehavior : public QObject, public QDeclar Q_CLASSINFO("DefaultProperty", "animation") Q_PROPERTY(QDeclarativeAbstractAnimation *animation READ animation WRITE setAnimation) Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) + Q_CLASSINFO("DeferredPropertyNames", "animation") public: QDeclarativeBehavior(QObject *parent=0); diff --git a/src/gui/egl/qegl_x11.cpp b/src/gui/egl/qegl_x11.cpp index 8608523..53c4711 100644 --- a/src/gui/egl/qegl_x11.cpp +++ b/src/gui/egl/qegl_x11.cpp @@ -41,18 +41,19 @@ #include <QtCore/qdebug.h> -#include <private/qt_x11_p.h> +#include <QtGui/private/qt_x11_p.h> #include <QtGui/qx11info_x11.h> -#include <private/qpixmapdata_p.h> -#include <private/qpixmap_x11_p.h> +#include <QtGui/private/qpixmapdata_p.h> +#include <QtGui/private/qpixmap_x11_p.h> +#include <QtGui/private/qimagepixmapcleanuphooks_p.h> #include <QtGui/qpaintdevice.h> #include <QtGui/qpixmap.h> #include <QtGui/qwidget.h> #include <QtGui/qcolormap.h> -#include "qegl_p.h" -#include "qeglcontext_p.h" +#include "QtGui/private/qegl_p.h" +#include "QtGui/private/qeglcontext_p.h" QT_BEGIN_NAMESPACE @@ -408,6 +409,7 @@ EGLSurface QEgl::createSurface(QPaintDevice *device, EGLConfig config, const QEg (EGLNativePixmapType) x11PixmapData->handle(), surfaceAttribs.properties()); x11PixmapData->gl_surface = (Qt::HANDLE)surf; + QImagePixmapCleanupHooks::enableCleanupHooks(x11PixmapData); return surf; } diff --git a/src/gui/kernel/qmime_win.cpp b/src/gui/kernel/qmime_win.cpp index 39633bf..2840843 100644 --- a/src/gui/kernel/qmime_win.cpp +++ b/src/gui/kernel/qmime_win.cpp @@ -952,6 +952,8 @@ bool QWindowsMimeImage::convertFromMime(const FORMATETC &formatetc, const QMimeD QDataStream s(&ba, QIODevice::WriteOnly); s.setByteOrder(QDataStream::LittleEndian);// Intel byte order #### if (cf == CF_DIB) { + if (img.format() > QImage::Format_ARGB32) + img = img.convertToFormat(QImage::Format_RGB32); if (qt_write_dib(s, img)) return setData(ba, pmedium); } else { diff --git a/src/imports/multimedia/multimedia.pro b/src/imports/multimedia/multimedia.pro index 117aa9b..f7a1d1b 100644 --- a/src/imports/multimedia/multimedia.pro +++ b/src/imports/multimedia/multimedia.pro @@ -1,5 +1,5 @@ TARGET = multimedia -TARGETPATH = $$[QT_INSTALL_IMPORTS]/Qt/multimedia +TARGETPATH = Qt/multimedia include(../qimportbase.pri) QT += multimedia declarative @@ -21,6 +21,6 @@ QTDIR_build:DESTDIR = $$QT_BUILD_TREE/imports/Qt/multimedia target.path = $$TARGETPATH qmldir.files += $$QT_BUILD_TREE/imports/Qt/multimedia/qmldir -qmldir.path += $$TARGETPATH +qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH INSTALLS += target qmldir diff --git a/src/imports/qimportbase.pri b/src/imports/qimportbase.pri index 363dd88..5433059 100644 --- a/src/imports/qimportbase.pri +++ b/src/imports/qimportbase.pri @@ -12,7 +12,7 @@ isEmpty(TARGET) { QMLDIRFILE = $${_PRO_FILE_PWD_}/qmldir copy2build.input = QMLDIRFILE -copy2build.output = $$TARGETPATH/qmldir +copy2build.output = $$QT_BUILD_TREE/imports/$$TARGETPATH/qmldir isEmpty(vcproj):copy2build.variable_out = PRE_TARGETDEPS copy2build.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} copy2build.name = COPY ${QMAKE_FILE_IN} diff --git a/src/imports/webkit/webkit.pro b/src/imports/webkit/webkit.pro index 76b46f1..fdc12cc 100644 --- a/src/imports/webkit/webkit.pro +++ b/src/imports/webkit/webkit.pro @@ -1,5 +1,5 @@ TARGET = webkitqmlplugin -TARGETPATH = $$[QT_INSTALL_IMPORTS]/org/webkit +TARGETPATH = org/webkit include(../qimportbase.pri) QT += webkit declarative @@ -14,6 +14,6 @@ QTDIR_build:DESTDIR = $$TARGETPATH target.path = $$TARGETPATH qmldir.files += $$QT_BUILD_TREE/imports/org/webkit/qmldir -qmldir.path += $$TARGETPATH +qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH INSTALLS += target qmldir diff --git a/src/imports/widgets/widgets.pro b/src/imports/widgets/widgets.pro index b98be59..02223d7 100644 --- a/src/imports/widgets/widgets.pro +++ b/src/imports/widgets/widgets.pro @@ -1,5 +1,5 @@ TARGET = widgets -TARGETPATH = $$[QT_INSTALL_IMPORTS]/Qt/widgets +TARGETPATH = Qt/widgets include(../qimportbase.pri) QT += declarative @@ -17,6 +17,6 @@ target.path = $$TARGETPATH # install qmldir file qmldir.files += qmldir -qmldir.path = $$TARGETPATH +qmldir.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH INSTALLS += target qmldir diff --git a/src/multimedia/effects/effects.pri b/src/multimedia/effects/effects.pri index ff762e8..be2b696 100644 --- a/src/multimedia/effects/effects.pri +++ b/src/multimedia/effects/effects.pri @@ -1,7 +1,7 @@ -unix { - unix:contains(QT_CONFIG, pulseaudio) { +unix:!mac { + contains(QT_CONFIG, pulseaudio) { DEFINES += QT_MULTIMEDIA_PULSEAUDIO HEADERS += $$PWD/qsoundeffect_pulse_p.h SOURCES += $$PWD/qsoundeffect_pulse_p.cpp diff --git a/src/multimedia/effects/qsoundeffect.cpp b/src/multimedia/effects/qsoundeffect.cpp index 2694023..f64d9ee 100644 --- a/src/multimedia/effects/qsoundeffect.cpp +++ b/src/multimedia/effects/qsoundeffect.cpp @@ -39,9 +39,6 @@ ** ****************************************************************************/ -#include "qmediacontent.h" -#include "qmediaplayer.h" - #include "qsoundeffect_p.h" #if defined(QT_MULTIMEDIA_PULSEAUDIO) @@ -103,12 +100,6 @@ QT_BEGIN_NAMESPACE */ /*! - \qmlproperty int SoundEffect::duration - - This property holds the duration in milliseconds of the current source audio. -*/ - -/*! \qmlsignal SoundEffect::sourceChanged() This handler is called when the source has changed. @@ -132,24 +123,13 @@ QT_BEGIN_NAMESPACE This handler is called when the mute state has changed. */ -/*! - \qmlsignal SoundEffect::durationChanged() - - This handler is called when the duration has changed. -*/ QSoundEffect::QSoundEffect(QObject *parent) : - QObject(parent), - m_loopCount(1), - m_vol(100), - m_muted(false), - m_runningCount(0) + QObject(parent) { d = new QSoundEffectPrivate(this); - connect(d, SIGNAL(volumeChanged(int)), SIGNAL(volumeChanged())); - connect(d, SIGNAL(mutedChanged(bool)), SIGNAL(mutedChanged())); - connect(d, SIGNAL(durationChanged(qint64)), SIGNAL(durationChanged())); - connect(d, SIGNAL(stateChanged(QMediaPlayer::State)), SLOT(repeat())); + connect(d, SIGNAL(volumeChanged()), SIGNAL(volumeChanged())); + connect(d, SIGNAL(mutedChanged()), SIGNAL(mutedChanged())); } QSoundEffect::~QSoundEffect() @@ -159,97 +139,64 @@ QSoundEffect::~QSoundEffect() QUrl QSoundEffect::source() const { - return d != 0 ? d->media().canonicalUrl() : QUrl(); + return d->source(); } void QSoundEffect::setSource(const QUrl &url) { - if (d != 0 && d->media().canonicalUrl() == url) + if (d->source() == url) return; - d->setVolume(m_vol); - d->setMuted(m_muted); - d->setMedia(url); - - if (url.isEmpty()) - return; + d->setSource(url); emit sourceChanged(); } int QSoundEffect::loopCount() const { - return m_loopCount; + return d->loopCount(); } void QSoundEffect::setLoopCount(int loopCount) { - if (m_loopCount == loopCount) + if (d->loopCount() == loopCount) return; - m_loopCount = loopCount; + d->setLoopCount(loopCount); emit loopCountChanged(); } int QSoundEffect::volume() const { - return d != 0 ? d->volume() : m_vol; + return d->volume(); } void QSoundEffect::setVolume(int volume) { - if (m_vol == volume) + if (d->volume() == volume) return; - m_vol = volume; - if (d != 0) - d->setVolume(volume); - else - emit volumeChanged(); + d->setVolume(volume); + emit volumeChanged(); } bool QSoundEffect::isMuted() const { - return d != 0 ? d->isMuted() : m_muted; + return d->isMuted(); } void QSoundEffect::setMuted(bool muted) { - if (m_muted == muted) + if (d->isMuted() == muted) return; - m_muted = muted; - if (d != 0) - d->setMuted(muted); - else - emit mutedChanged(); -} - -int QSoundEffect::duration() const -{ - return d != 0 ? d->duration() : 0; + d->setMuted(muted); + emit mutedChanged(); } void QSoundEffect::play() { - m_runningCount = 0; - - if (d != 0) - d->play(); -} - -void QSoundEffect::stop() -{ - if (d != 0) - d->stop(); -} - -void QSoundEffect::repeat() -{ - if (d->state() == QMediaPlayer::StoppedState) { - if (++m_runningCount < m_loopCount) - d->play(); - } + d->play(); } QT_END_NAMESPACE diff --git a/src/multimedia/effects/qsoundeffect_p.h b/src/multimedia/effects/qsoundeffect_p.h index c5554bf..ec6a2f7 100644 --- a/src/multimedia/effects/qsoundeffect_p.h +++ b/src/multimedia/effects/qsoundeffect_p.h @@ -70,7 +70,6 @@ class Q_MULTIMEDIA_EXPORT QSoundEffect : public QObject Q_PROPERTY(int loopCount READ loopCount WRITE setLoopCount NOTIFY loopCountChanged) Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY volumeChanged) Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged) - Q_PROPERTY(int duration READ duration NOTIFY durationChanged) public: explicit QSoundEffect(QObject *parent = 0); @@ -88,30 +87,17 @@ public: bool isMuted() const; void setMuted(bool muted); - int duration() const; - -signals: +Q_SIGNALS: void sourceChanged(); void loopCountChanged(); void volumeChanged(); void mutedChanged(); - void durationChanged(); -public slots: +public Q_SLOTS: void play(); - void stop(); - -private slots: - void repeat(); private: Q_DISABLE_COPY(QSoundEffect) - - int m_loopCount; - int m_vol; - bool m_muted; - int m_runningCount; - QSoundEffectPrivate* d; }; diff --git a/src/multimedia/effects/qsoundeffect_pulse_p.cpp b/src/multimedia/effects/qsoundeffect_pulse_p.cpp index d99bf4b..c322722 100644 --- a/src/multimedia/effects/qsoundeffect_pulse_p.cpp +++ b/src/multimedia/effects/qsoundeffect_pulse_p.cpp @@ -55,10 +55,6 @@ #include <QtNetwork> #include <QTime> -#include "qmediacontent.h" -#include "qmediaplayer.h" -#include "qsoundeffect_p.h" - #include "wavedecoder_p.h" #include "qsoundeffect_pulse_p.h" @@ -240,11 +236,12 @@ QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent): QObject(parent), m_muted(false), m_playQueued(false), - m_vol(100), + m_sampleLoaded(false), + m_volume(100), m_duration(0), m_dataUploaded(0), - m_state(QMediaPlayer::StoppedState), - m_status(QMediaPlayer::NoMedia), + m_loopCount(1), + m_runningCount(0), m_reply(0), m_stream(0), m_networkAccessManager(0) @@ -257,76 +254,53 @@ QSoundEffectPrivate::~QSoundEffectPrivate() unloadSample(); } -qint64 QSoundEffectPrivate::duration() const +QUrl QSoundEffectPrivate::source() const { - return m_duration; + return m_source; } -int QSoundEffectPrivate::volume() const +void QSoundEffectPrivate::setSource(const QUrl &url) { - return m_vol; -} + if (url.isEmpty()) { + m_source = QUrl(); + unloadSample(); + return; + } -bool QSoundEffectPrivate::isMuted() const -{ - return m_muted; -} + m_source = url; -QMediaContent QSoundEffectPrivate::media() const -{ - return m_media; + if (m_networkAccessManager == 0) + m_networkAccessManager = new QNetworkAccessManager(this); + + m_stream = m_networkAccessManager->get(QNetworkRequest(m_source)); + + unloadSample(); + loadSample(); } -QMediaPlayer::State QSoundEffectPrivate::state() const +int QSoundEffectPrivate::loopCount() const { - return m_state; + return m_loopCount; } -QMediaPlayer::MediaStatus QSoundEffectPrivate::mediaStatus() const +void QSoundEffectPrivate::setLoopCount(int loopCount) { - return m_status; + m_loopCount = loopCount; } -void QSoundEffectPrivate::play() +int QSoundEffectPrivate::volume() const { - if (m_status == QMediaPlayer::LoadingMedia) { - m_playQueued = true; - return; - } - - if (m_status != QMediaPlayer::BufferedMedia || - m_state == QMediaPlayer::PlayingState) - return; - - pa_volume_t m_vol = PA_VOLUME_NORM; - - daemon()->lock(); -#if defined(Q_WS_MAEMO_5) - m_vol = PA_VOLUME_NORM/100*((daemon()->volume()+m_vol)/2); -#endif - pa_operation_unref( - pa_context_play_sample(daemon()->context(), - m_name.constData(), - 0, - m_vol, - play_callback, - this) - ); - daemon()->unlock(); - - m_playbackTime.start(); - - emit stateChanged(m_state = QMediaPlayer::PlayingState); + return m_volume; } -void QSoundEffectPrivate::stop() +void QSoundEffectPrivate::setVolume(int volume) { - emit stateChanged(m_state = QMediaPlayer::StoppedState); + m_volume = volume; } -void QSoundEffectPrivate::setVolume(int volume) +bool QSoundEffectPrivate::isMuted() const { - m_vol = volume; + return m_muted; } void QSoundEffectPrivate::setMuted(bool muted) @@ -334,34 +308,23 @@ void QSoundEffectPrivate::setMuted(bool muted) m_muted = muted; } -void QSoundEffectPrivate::setMedia(const QMediaContent &media) +void QSoundEffectPrivate::play() { - if (media.isNull()) { - m_media = QMediaContent(); - unloadSample(); + if (!m_sampleLoaded) { + m_playQueued = true; return; } - if (m_media == media) - return; - m_media = media; - - if (m_networkAccessManager == 0) - m_networkAccessManager = new QNetworkAccessManager(this); - m_stream = m_networkAccessManager->get(QNetworkRequest(m_media.canonicalUrl())); + m_runningCount += m_loopCount; - unloadSample(); - loadSample(); - - emit mediaChanged(m_media); + playSample(); } void QSoundEffectPrivate::decoderReady() { if (m_waveDecoder->size() >= PA_SCACHE_ENTRY_SIZE_MAX) { - m_status = QMediaPlayer::InvalidMedia; - emit mediaStatusChanged(m_status); - qWarning("QtPulseAudio: attempting to load to large a sample"); + m_waveDecoder->deleteLater(); + qWarning("QSoundEffect(pulseaudio): Attempting to load to large a sample"); return; } @@ -380,52 +343,65 @@ void QSoundEffectPrivate::decoderReady() void QSoundEffectPrivate::decoderError() { - emit mediaStatusChanged(m_status = QMediaPlayer::InvalidMedia); + qWarning("QSoundEffect(pulseaudio): Error decoding source"); } void QSoundEffectPrivate::checkPlayTime() { int elapsed = m_playbackTime.elapsed(); - if (elapsed >= m_duration) { - m_state = QMediaPlayer::StoppedState; - emit stateChanged(m_state); - } - else + if (elapsed < m_duration) startTimer(m_duration - elapsed); } void QSoundEffectPrivate::loadSample() { + m_sampleLoaded = false; + m_dataUploaded = 0; m_waveDecoder = new WaveDecoder(m_stream); connect(m_waveDecoder, SIGNAL(formatKnown()), SLOT(decoderReady())); connect(m_waveDecoder, SIGNAL(invalidFormat()), SLOT(decoderError())); - - m_status = QMediaPlayer::LoadingMedia; - emit mediaStatusChanged(m_status); } void QSoundEffectPrivate::unloadSample() { - if (m_status != QMediaPlayer::BufferedMedia) + if (!m_sampleLoaded) return; - m_status = QMediaPlayer::NoMedia; - daemon()->lock(); pa_context_remove_sample(daemon()->context(), m_name.constData(), NULL, NULL); daemon()->unlock(); m_duration = 0; m_dataUploaded = 0; + m_sampleLoaded = false; +} + +void QSoundEffectPrivate::playSample() +{ + pa_volume_t volume = PA_VOLUME_NORM; + + daemon()->lock(); +#ifdef Q_WS_MAEMO_5 + volume = PA_VOLUME_NORM / 100 * ((daemon()->volume() + m_volume) / 2); +#endif + pa_operation_unref( + pa_context_play_sample(daemon()->context(), + m_name.constData(), + 0, + volume, + play_callback, + this) + ); + daemon()->unlock(); + + m_playbackTime.start(); } void QSoundEffectPrivate::timerEvent(QTimerEvent *event) { - if (m_state == QMediaPlayer::PlayingState) { - m_state = QMediaPlayer::StoppedState; - emit stateChanged(m_state); - } + if (m_runningCount > 0) + playSample(); killTimer(event->timerId()); } @@ -456,15 +432,11 @@ void QSoundEffectPrivate::stream_write_callback(pa_stream *s, size_t length, voi pa_stream_finish_upload(s); self->m_duration = self->m_waveDecoder->duration(); - emit self->durationChanged(self->m_duration); - - self->m_status = QMediaPlayer::BufferedMedia; - emit self->mediaStatusChanged(self->m_status); self->m_waveDecoder->deleteLater(); - if (!self->m_media.isNull()) - self->m_stream->deleteLater(); + self->m_stream->deleteLater(); + self->m_sampleLoaded = true; if (self->m_playQueued) { self->m_playQueued = false; QMetaObject::invokeMethod(self, "play"); @@ -474,8 +446,6 @@ void QSoundEffectPrivate::stream_write_callback(pa_stream *s, size_t length, voi void QSoundEffectPrivate::stream_state_callback(pa_stream *s, void *userdata) { - QSoundEffectPrivate *self = reinterpret_cast<QSoundEffectPrivate*>(userdata); - switch (pa_stream_get_state(s)) { case PA_STREAM_CREATING: case PA_STREAM_READY: @@ -484,8 +454,7 @@ void QSoundEffectPrivate::stream_state_callback(pa_stream *s, void *userdata) case PA_STREAM_FAILED: default: - self->m_status = QMediaPlayer::InvalidMedia; - emit self->mediaStatusChanged(self->m_status); + qWarning("QSoundEffect(pulseaudio): Error in pulse audio stream"); break; } } @@ -496,14 +465,10 @@ void QSoundEffectPrivate::play_callback(pa_context *c, int success, void *userda QSoundEffectPrivate *self = reinterpret_cast<QSoundEffectPrivate*>(userdata); - if (success == 1) + if (success == 1) { + self->m_runningCount--; QMetaObject::invokeMethod(self, "checkPlayTime", Qt::QueuedConnection); - else { - self->m_state = QMediaPlayer::StoppedState; - emit self->stateChanged(self->m_state); } } QT_END_NAMESPACE - - diff --git a/src/multimedia/effects/qsoundeffect_pulse_p.h b/src/multimedia/effects/qsoundeffect_pulse_p.h index 247f8a3..3aed018 100644 --- a/src/multimedia/effects/qsoundeffect_pulse_p.h +++ b/src/multimedia/effects/qsoundeffect_pulse_p.h @@ -77,30 +77,23 @@ public: explicit QSoundEffectPrivate(QObject* parent); ~QSoundEffectPrivate(); - qint64 duration() const; + QUrl source() const; + void setSource(const QUrl &url); + int loopCount() const; + void setLoopCount(int loopCount); int volume() const; + void setVolume(int volume); bool isMuted() const; - QMediaContent media() const; - QMediaPlayer::State state() const; - QMediaPlayer::MediaStatus mediaStatus() const; + void setMuted(bool muted); public Q_SLOTS: void play(); - void stop(); - void setVolume(int volume); - void setMuted(bool muted); - void setMedia(const QMediaContent &media); Q_SIGNALS: - void mediaChanged(const QMediaContent &media); - void mediaStatusChanged(QMediaPlayer::MediaStatus status); - void stateChanged(QMediaPlayer::State newState); - void durationChanged(qint64 duration); - void volumeChanged(int volume); - void mutedChanged(bool muted); - void error(QMediaPlayer::Error error); - -private slots: + void volumeChanged(); + void mutedChanged(); + +private Q_SLOTS: void decoderReady(); void decoderError(); void checkPlayTime(); @@ -108,6 +101,7 @@ private slots: private: void loadSample(); void unloadSample(); + void playSample(); void timerEvent(QTimerEvent *event); @@ -117,14 +111,15 @@ private: bool m_muted; bool m_playQueued; - int m_vol; + bool m_sampleLoaded; + int m_volume; int m_duration; int m_dataUploaded; + int m_loopCount; + int m_runningCount; + QUrl m_source; QTime m_playbackTime; - QMediaPlayer::State m_state; - QMediaPlayer::MediaStatus m_status; QByteArray m_name; - QMediaContent m_media; QNetworkReply *m_reply; WaveDecoder *m_waveDecoder; QIODevice *m_stream; diff --git a/src/multimedia/effects/qsoundeffect_qmedia_p.cpp b/src/multimedia/effects/qsoundeffect_qmedia_p.cpp index 48fb257..43ba22f 100644 --- a/src/multimedia/effects/qsoundeffect_qmedia_p.cpp +++ b/src/multimedia/effects/qsoundeffect_qmedia_p.cpp @@ -50,117 +50,84 @@ // We mean it. // -#include <QtCore/qcoreapplication.h> +#include "qsoundeffect_qmedia_p.h" -#include "qmediacontent.h" -#include "qmediaplayer.h" +#include <QtCore/qcoreapplication.h> -#include "qsoundeffect_p.h" -#include "qsoundeffect_qmedia_p.h" +#include <QtMultimedia/qmediacontent.h> +#include <QtMultimedia/qmediaplayer.h> QT_BEGIN_NAMESPACE QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent): QObject(parent), - m_muted(false), - m_vol(100), + m_loopCount(1), + m_runningCount(0), m_player(0) { + m_player = new QMediaPlayer(this, QMediaPlayer::LowLatency); + connect(m_player, SIGNAL(volumeChanged(int)), SIGNAL(volumeChanged())); + connect(m_player, SIGNAL(mutedChanged(bool)), SIGNAL(mutedChanged())); + connect(m_player, SIGNAL(stateChanged(QMediaPlayer::State)), SLOT(stateChanged(QMediaPlayer::State))); } QSoundEffectPrivate::~QSoundEffectPrivate() { - if (m_player) delete m_player; } -qint64 QSoundEffectPrivate::duration() const +QUrl QSoundEffectPrivate::source() const { - if (m_player) return m_player->duration(); - - return 0; + return m_player->media().canonicalUrl(); } -int QSoundEffectPrivate::volume() const +void QSoundEffectPrivate::setSource(const QUrl &url) { - if (m_player) return m_player->volume(); - - return m_vol; + m_player->setMedia(url); } -bool QSoundEffectPrivate::isMuted() const -{ - if (m_player) return m_player->isMuted(); - - return m_muted; -} - -QMediaContent QSoundEffectPrivate::media() const +int QSoundEffectPrivate::loopCount() const { - if (m_player) return m_player->media(); - - return QMediaContent(); + return m_loopCount; } -QMediaPlayer::State QSoundEffectPrivate::state() const +void QSoundEffectPrivate::setLoopCount(int loopCount) { - if (m_player) return m_player->state(); - - return QMediaPlayer::StoppedState; + m_loopCount = loopCount; } -QMediaPlayer::MediaStatus QSoundEffectPrivate::mediaStatus() const +int QSoundEffectPrivate::volume() const { - if (m_player) return m_player->mediaStatus(); - - return QMediaPlayer::UnknownMediaStatus; + return m_player->volume(); } -void QSoundEffectPrivate::play() +void QSoundEffectPrivate::setVolume(int volume) { - if (m_player && !m_player->isMuted()) - m_player->play(); + m_player->setVolume(volume); } -void QSoundEffectPrivate::stop() +bool QSoundEffectPrivate::isMuted() const { - if (m_player) - m_player->stop(); + return m_player->isMuted(); } -void QSoundEffectPrivate::setVolume(int volume) +void QSoundEffectPrivate::setMuted(bool muted) { - m_vol = volume; - - if (m_player) - m_player->setVolume(volume); + m_player->setMuted(muted); } -void QSoundEffectPrivate::setMuted(bool muted) +void QSoundEffectPrivate::play() { - m_muted = muted; - - if (m_player) - m_player->setMuted(muted); + m_runningCount += m_loopCount; + m_player->play(); } -void QSoundEffectPrivate::setMedia(const QMediaContent &media) +void QSoundEffectPrivate::stateChanged(QMediaPlayer::State state) { - if (media.isNull()) - return; - - if (m_player == 0) { - m_player = new QMediaPlayer(this, QMediaPlayer::LowLatency); - m_player->setVolume(m_vol); - m_player->setMuted(m_muted); - - connect(m_player, SIGNAL(volumeChanged(int)), SIGNAL(volumeChanged(int))); - connect(m_player, SIGNAL(mutedChanged(bool)), SIGNAL(mutedChanged(bool))); - connect(m_player, SIGNAL(durationChanged(qint64)), SIGNAL(durationChanged(qint64))); - connect(m_player, SIGNAL(stateChanged(QMediaPlayer::State)), SIGNAL(stateChanged(QMediaPlayer::State))); + if (state == QMediaPlayer::StoppedState) { + if (--m_runningCount > 0) + m_player->play(); } - - m_player->setMedia(media.canonicalUrl()); } QT_END_NAMESPACE diff --git a/src/multimedia/effects/qsoundeffect_qmedia_p.h b/src/multimedia/effects/qsoundeffect_qmedia_p.h index 8267f79..6ad9d79 100644 --- a/src/multimedia/effects/qsoundeffect_qmedia_p.h +++ b/src/multimedia/effects/qsoundeffect_qmedia_p.h @@ -57,14 +57,12 @@ #include <QtCore/qobject.h> #include <QtCore/qurl.h> #include <QtMultimedia/qmediaplayer.h> -#include "qsoundeffect_p.h" QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -class WaveDecoder; class QSoundEffectPrivate : public QObject { @@ -73,32 +71,28 @@ public: explicit QSoundEffectPrivate(QObject* parent); ~QSoundEffectPrivate(); - qint64 duration() const; + QUrl source() const; + void setSource(const QUrl &url); + int loopCount() const; + void setLoopCount(int loopCount); int volume() const; + void setVolume(int volume); bool isMuted() const; - QMediaContent media() const; - QMediaPlayer::State state() const; - QMediaPlayer::MediaStatus mediaStatus() const; + void setMuted(bool muted); public Q_SLOTS: void play(); - void stop(); - void setVolume(int volume); - void setMuted(bool muted); - void setMedia(const QMediaContent &media); Q_SIGNALS: - void mediaChanged(const QMediaContent &media); - void mediaStatusChanged(QMediaPlayer::MediaStatus status); - void stateChanged(QMediaPlayer::State newState); - void durationChanged(qint64 duration); - void volumeChanged(int volume); - void mutedChanged(bool muted); - void error(QMediaPlayer::Error error); + void volumeChanged(); + void mutedChanged(); + +private Q_SLOTS: + void stateChanged(QMediaPlayer::State); private: - bool m_muted; - int m_vol; + int m_loopCount; + int m_runningCount; QMediaPlayer *m_player; }; diff --git a/src/multimedia/effects/qsoundeffect_qsound_p.cpp b/src/multimedia/effects/qsoundeffect_qsound_p.cpp index df160a9..ff30f67 100644 --- a/src/multimedia/effects/qsoundeffect_qsound_p.cpp +++ b/src/multimedia/effects/qsoundeffect_qsound_p.cpp @@ -50,102 +50,72 @@ // We mean it. // +#include "qsoundeffect_qsound_p.h" + #include <QtCore/qcoreapplication.h> -#include <QtCore/qtimer.h> -#include <QtCore/qfile.h> #include <QtGui/qsound.h> -#include <QtMultimedia/qaudioformat.h> -#include <QDebug> -#include "qmediacontent.h" -#include "qmediaplayer.h" -#include "qsoundeffect_p.h" - -#include "wavedecoder_p.h" - -#include "qsoundeffect_qsound_p.h" QT_BEGIN_NAMESPACE QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent): QObject(parent), - m_queued(false), m_muted(false), - m_state(QMediaPlayer::StoppedState), - m_status(QMediaPlayer::NoMedia), - m_file(0), + m_loopCount(1), + m_volume(100), m_sound(0) { - m_timer = new QTimer(this); - connect(m_timer,SIGNAL(timeout()),SLOT(checkPlayTime())); - m_media = QMediaContent(); } QSoundEffectPrivate::~QSoundEffectPrivate() { - if (m_sound) delete m_sound; - if (m_waveDecoder) delete m_waveDecoder; - m_file->close(); } -qint64 QSoundEffectPrivate::duration() const +QUrl QSoundEffectPrivate::source() const { - if (m_waveDecoder) - return m_waveDecoder->size(); - - return 0; + return m_source; } -int QSoundEffectPrivate::volume() const +void QSoundEffectPrivate::setSource(const QUrl &url) { - return 100; -} + if (url.isEmpty() || url.scheme() != QLatin1String("file")) { + m_source = QUrl(); + return; + } -bool QSoundEffectPrivate::isMuted() const -{ - return m_muted; -} + if (m_sound != 0) + delete m_sound; -QMediaContent QSoundEffectPrivate::media() const -{ - return m_media; + m_source = url; + m_sound = new QSound(m_source.toLocalFile(), this); + m_sound->setLoops(m_loopCount); } -QMediaPlayer::State QSoundEffectPrivate::state() const +int QSoundEffectPrivate::loopCount() const { - return m_state; + return m_loopCount; } -QMediaPlayer::MediaStatus QSoundEffectPrivate::mediaStatus() const +void QSoundEffectPrivate::setLoopCount(int lc) { - return m_status; + m_loopCount = lc; + if (m_sound) + m_sound->setLoops(lc); } -void QSoundEffectPrivate::play() +int QSoundEffectPrivate::volume() const { - if (m_sound && !m_muted) { - m_queued = false; - m_timer->start(20); - m_playbackTime.start(); - m_sound->play(); - emit stateChanged(m_state = QMediaPlayer::PlayingState); - } else if (m_status == QMediaPlayer::LoadingMedia) - m_queued = true; + return m_volume; } -void QSoundEffectPrivate::stop() +void QSoundEffectPrivate::setVolume(int v) { - m_timer->stop(); - - if (m_sound) { - m_sound->stop(); - emit stateChanged(m_state = QMediaPlayer::StoppedState); - } + m_volume = v; } -void QSoundEffectPrivate::setVolume(int volume) +bool QSoundEffectPrivate::isMuted() const { - Q_UNUSED(volume) + return m_muted; } void QSoundEffectPrivate::setMuted(bool muted) @@ -153,73 +123,9 @@ void QSoundEffectPrivate::setMuted(bool muted) m_muted = muted; } -void QSoundEffectPrivate::setMedia(const QMediaContent &media) -{ - m_queued = false; - - if (media.isNull() || media.canonicalUrl().scheme() != QLatin1String("file")) { - m_media = QMediaContent(); - return; - } - if (m_media == media) - return; - - m_media = media; - m_file = new QFile(m_media.canonicalUrl().toLocalFile()); - m_file->open(QIODevice::ReadOnly|QIODevice::Unbuffered); - - unloadSample(); - loadSample(); - - emit mediaChanged(m_media); -} - -void QSoundEffectPrivate::decoderReady() -{ - m_file->close(); - m_sound = new QSound(m_media.canonicalUrl().toLocalFile()); - emit mediaStatusChanged(m_status = QMediaPlayer::LoadedMedia); - - if (m_queued) - play(); -} - -void QSoundEffectPrivate::decoderError() -{ - m_file->close(); - emit mediaStatusChanged(m_status = QMediaPlayer::InvalidMedia); -} - -void QSoundEffectPrivate::checkPlayTime() -{ - if (m_sound->isFinished()) { - m_timer->stop(); - m_state = QMediaPlayer::StoppedState; - emit stateChanged(m_state); - } -} - -void QSoundEffectPrivate::loadSample() -{ - m_waveDecoder = new WaveDecoder(m_file); - connect(m_waveDecoder, SIGNAL(formatKnown()), SLOT(decoderReady())); - connect(m_waveDecoder, SIGNAL(invalidFormat()), SLOT(decoderError())); - - m_status = QMediaPlayer::LoadingMedia; - emit mediaStatusChanged(m_status); -} - -void QSoundEffectPrivate::unloadSample() +void QSoundEffectPrivate::play() { - if (m_sound == 0) - return; - - m_status = QMediaPlayer::NoMedia; - - if (m_sound) - delete m_sound; - - m_sound = 0; + m_sound->play(); } QT_END_NAMESPACE diff --git a/src/multimedia/effects/qsoundeffect_qsound_p.h b/src/multimedia/effects/qsoundeffect_qsound_p.h index 45c0888..6fb3cfa 100644 --- a/src/multimedia/effects/qsoundeffect_qsound_p.h +++ b/src/multimedia/effects/qsoundeffect_qsound_p.h @@ -55,20 +55,14 @@ #include <QtCore/qobject.h> -#include <QtCore/qdatetime.h> -#include <QtMultimedia/qmediaplayer.h> - -#include "qsoundeffect_p.h" +#include <QtCore/qurl.h> QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -class QTimer; class QSound; -class QFile; -class WaveDecoder; class QSoundEffectPrivate : public QObject { @@ -77,49 +71,28 @@ public: explicit QSoundEffectPrivate(QObject* parent); ~QSoundEffectPrivate(); - qint64 duration() const; + QUrl source() const; + void setSource(const QUrl &url); + int loopCount() const; + void setLoopCount(int loopCount); int volume() const; + void setVolume(int volume); bool isMuted() const; - QMediaContent media() const; - QMediaPlayer::State state() const; - QMediaPlayer::MediaStatus mediaStatus() const; + void setMuted(bool muted); public Q_SLOTS: void play(); - void stop(); - void setVolume(int volume); - void setMuted(bool muted); - void setMedia(const QMediaContent &media); Q_SIGNALS: - void mediaChanged(const QMediaContent &media); - void mediaStatusChanged(QMediaPlayer::MediaStatus status); - void stateChanged(QMediaPlayer::State newState); - void durationChanged(qint64 duration); - void volumeChanged(int volume); - void mutedChanged(bool muted); - void error(QMediaPlayer::Error error); - -private slots: - void decoderReady(); - void decoderError(); - void checkPlayTime(); + void volumeChanged(); + void mutedChanged(); private: - void loadSample(); - void unloadSample(); - - bool m_queued; - bool m_muted; - QTime m_playbackTime; - QMediaPlayer::State m_state; - QMediaPlayer::MediaStatus m_status; - QFile *m_file; - QByteArray m_name; - QMediaContent m_media; - WaveDecoder *m_waveDecoder; + bool m_muted; + int m_loopCount; + int m_volume; QSound *m_sound; - QTimer *m_timer; + QUrl m_source; }; QT_END_NAMESPACE diff --git a/src/multimedia/effects/wavedecoder_p.h b/src/multimedia/effects/wavedecoder_p.h index fa1f77e..c1892bb 100644 --- a/src/multimedia/effects/wavedecoder_p.h +++ b/src/multimedia/effects/wavedecoder_p.h @@ -77,11 +77,11 @@ public: bool isSequential() const; qint64 bytesAvailable() const; -signals: +Q_SIGNALS: void formatKnown(); void invalidFormat(); -private slots: +private Q_SLOTS: void handleData(); private: diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index 5ffecc5..fdcc412 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -42,7 +42,6 @@ #include "qgl.h" #include <private/qt_x11_p.h> #include <private/qpixmap_x11_p.h> -#include <private/qimagepixmapcleanuphooks_p.h> #include <private/qgl_p.h> #include <private/qpaintengine_opengl_p.h> #include "qgl_egl_p.h" diff --git a/src/src.pro b/src/src.pro index 8c21ef7..403ffe1 100644 --- a/src/src.pro +++ b/src/src.pro @@ -112,7 +112,7 @@ src_declarative.target = sub-declarative contains(QT_CONFIG, phonon):src_webkit.depends += src_phonon contains(QT_CONFIG, xmlpatterns): src_webkit.depends += src_xmlpatterns contains(QT_CONFIG, declarative):src_declarative.depends += src_webkit - src_imports.depends += webkit + src_imports.depends += src_webkit #exists($$QT_SOURCE_TREE/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro): src_webkit.depends += src_javascriptcore } contains(QT_CONFIG, qt3support): src_plugins.depends += src_qt3support diff --git a/tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml b/tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml index 3f00e68..408ad87 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml @@ -10,7 +10,7 @@ Rectangle { width: 100; height: 100 color: Qt.rgba(1,0,0) Behavior on x { - NumberAnimation { objectName: "MyAnim"; target: redRect; property: "y"; to: 300; repeat: true} + NumberAnimation { id: myAnim; objectName: "MyAnim"; target: redRect; property: "y"; to: 300; repeat: true} } } diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp index 7ade309..aeefea1 100644 --- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp +++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp @@ -659,9 +659,14 @@ void tst_QDeclarativeGridView::currentIndex() QCOMPARE(gridview->contentY(), 0.0); // Test keys - qApp->setActiveWindow(canvas); canvas->show(); - canvas->setFocus(); + qApp->setActiveWindow(canvas); +#ifdef Q_WS_X11 + // to be safe and avoid failing setFocus with window managers + qt_x11_wait_for_window_manager(canvas); +#endif + QVERIFY(canvas->hasFocus()); + QVERIFY(canvas->scene()->hasFocus()); qApp->processEvents(); QTest::keyClick(canvas, Qt::Key_Down); @@ -672,7 +677,6 @@ void tst_QDeclarativeGridView::currentIndex() gridview->setFlow(QDeclarativeGridView::TopToBottom); - QEXPECT_FAIL("", "QTBUG-8475", Abort); QTest::keyClick(canvas, Qt::Key_Right); QCOMPARE(gridview->currentIndex(), 5); diff --git a/tests/auto/declarative/qdeclarativelanguage/data/method.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/method.1.errors.txt new file mode 100644 index 0000000..b10984f --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/method.1.errors.txt @@ -0,0 +1 @@ +3:1:Method names cannot begin with an upper case letter diff --git a/tests/auto/declarative/qdeclarativelanguage/data/method.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/method.1.qml new file mode 100644 index 0000000..d9794b4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/method.1.qml @@ -0,0 +1,5 @@ +import Qt 4.6 + +QtObject { + function MyMethod() {} +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.6.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/property.6.errors.txt new file mode 100644 index 0000000..9e8d454 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/property.6.errors.txt @@ -0,0 +1 @@ +4:5:Property names cannot begin with an upper case letter diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.6.qml b/tests/auto/declarative/qdeclarativelanguage/data/property.6.qml new file mode 100644 index 0000000..f39bed3 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/property.6.qml @@ -0,0 +1,6 @@ +import Qt 4.6 + +QtObject { + property int Hello +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.7.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/property.7.errors.txt new file mode 100644 index 0000000..9e8d454 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/property.7.errors.txt @@ -0,0 +1 @@ +4:5:Property names cannot begin with an upper case letter diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.7.qml b/tests/auto/declarative/qdeclarativelanguage/data/property.7.qml new file mode 100644 index 0000000..502eb22 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/property.7.qml @@ -0,0 +1,5 @@ +import Qt 4.6 + +QtObject { + property int Hello: 10 +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.4.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/signal.4.errors.txt new file mode 100644 index 0000000..d96f9e3 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/signal.4.errors.txt @@ -0,0 +1 @@ +3:1:Signal names cannot begin with an upper case letter diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/signal.4.qml new file mode 100644 index 0000000..7279a46 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/signal.4.qml @@ -0,0 +1,6 @@ +import Qt 4.6 + +QtObject { + signal MySignal +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index da0bf1a..083c551 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -269,12 +269,17 @@ void tst_qdeclarativelanguage::errors_data() QTest::newRow("signal.1") << "signal.1.qml" << "signal.1.errors.txt" << false; QTest::newRow("signal.2") << "signal.2.qml" << "signal.2.errors.txt" << false; QTest::newRow("signal.3") << "signal.3.qml" << "signal.3.errors.txt" << false; + QTest::newRow("signal.4") << "signal.4.qml" << "signal.4.errors.txt" << false; + + QTest::newRow("method.1") << "method.1.qml" << "method.1.errors.txt" << false; QTest::newRow("property.1") << "property.1.qml" << "property.1.errors.txt" << false; QTest::newRow("property.2") << "property.2.qml" << "property.2.errors.txt" << false; QTest::newRow("property.3") << "property.3.qml" << "property.3.errors.txt" << false; QTest::newRow("property.4") << "property.4.qml" << "property.4.errors.txt" << false; QTest::newRow("property.5") << "property.5.qml" << "property.5.errors.txt" << false; + QTest::newRow("property.6") << "property.6.qml" << "property.6.errors.txt" << false; + QTest::newRow("property.7") << "property.7.qml" << "property.7.errors.txt" << false; QTest::newRow("Script.1") << "script.1.qml" << "script.1.errors.txt" << false; QTest::newRow("Script.2") << "script.2.qml" << "script.2.errors.txt" << false; diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index 1df4448..75fbbf8 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -1028,13 +1028,17 @@ void tst_QDeclarativeListView::currentIndex() QCOMPARE(listview->contentY(), 0.0); // Test keys - qApp->setActiveWindow(canvas); canvas->show(); - canvas->setFocus(); + qApp->setActiveWindow(canvas); +#ifdef Q_WS_X11 + // to be safe and avoid failing setFocus with window managers + qt_x11_wait_for_window_manager(canvas); +#endif + QVERIFY(canvas->hasFocus()); + QVERIFY(canvas->scene()->hasFocus()); qApp->processEvents(); QTest::keyClick(canvas, Qt::Key_Down); - QEXPECT_FAIL("", "QTBUG-8475", Abort); QCOMPARE(listview->currentIndex(), 1); QTest::keyClick(canvas, Qt::Key_Up); diff --git a/tests/auto/declarative/qdeclarativeqt/data/tint.qml b/tests/auto/declarative/qdeclarativeqt/data/tint.qml index da8afe2..478245f 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/tint.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/tint.qml @@ -3,7 +3,7 @@ import Qt 4.6 QtObject { property color test1: Qt.tint("red", "blue"); property color test2: Qt.tint(Qt.rgba(1, 0, 0), Qt.rgba(0, 0, 0, 0)); - property color test3: Qt.tint("red", Qt.rgba(0, 0, 1, 0.5)); // XXX - what should this be? + property color test3: Qt.tint("red", Qt.rgba(0, 0, 1, 0.5)); property color test4: Qt.tint("red", Qt.rgba(0, 0, 1, 0.5), 10); property color test5: Qt.tint("red") } diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp index 90afd4e..b70011b 100644 --- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp +++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp @@ -254,8 +254,8 @@ void tst_qdeclarativeqt::tint() QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(0, 0, 1)); QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromRgbF(1, 0, 0)); - QEXPECT_FAIL("", "QT-2424",Continue); - QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor::fromRgbF(1, 0, 0)); + QColor test3 = qvariant_cast<QColor>(object->property("test3")); + QCOMPARE(test3.rgba(), 0xFF7F0080); QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor()); QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor()); |