diff options
125 files changed, 3741 insertions, 1823 deletions
diff --git a/demos/embedded/fluidlauncher/fluidlauncher.pro b/demos/embedded/fluidlauncher/fluidlauncher.pro index b2916d7..13274c3 100644 --- a/demos/embedded/fluidlauncher/fluidlauncher.pro +++ b/demos/embedded/fluidlauncher/fluidlauncher.pro @@ -180,10 +180,12 @@ symbian { mifs.sources += \ $$appResourceDir(demos/embedded/anomaly/anomaly.mif) - # Since Fluidlauncher itself doesn't link webkit, we won't get dependency automatically - executables.pkg_prerules += \ - "; Dependency to Qt Webkit" \ - "(0x200267C2), $${QT_MAJOR_VERSION}, $${QT_MINOR_VERSION}, $${QT_PATCH_VERSION}, {\"QtWebKit\"}" + isEmpty(QT_LIBINFIX) { + # Since Fluidlauncher itself doesn't link webkit, we won't get dependency automatically + executables.pkg_prerules += \ + "; Dependency to Qt Webkit" \ + "(0x200267C2), $${QT_MAJOR_VERSION}, $${QT_MINOR_VERSION}, $${QT_PATCH_VERSION}, {\"QtWebKit\"}" + } } contains(QT_CONFIG, phonon) { diff --git a/mkspecs/common/symbian/symbian-mmp.conf b/mkspecs/common/symbian/symbian-mmp.conf index e54e878..507b60c 100644 --- a/mkspecs/common/symbian/symbian-mmp.conf +++ b/mkspecs/common/symbian/symbian-mmp.conf @@ -2,17 +2,18 @@ # qmake configuration for symbian-* # +include(symbian.conf) + contains(QMAKE_HOST.os, "Windows") { - QMAKE_MOC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc.exe - QMAKE_UIC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic.exe - QMAKE_IDC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc.exe + QMAKE_MOC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc.exe + QMAKE_UIC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic.exe + QMAKE_IDC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc.exe } else { - QMAKE_MOC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc - QMAKE_UIC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic - QMAKE_IDC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc + QMAKE_MOC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc + QMAKE_UIC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic + QMAKE_IDC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc } -include(symbian.conf) load(symbian/add_mmp_rules) symbian-abld { diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf index 4dd81b0..090f3b6 100644 --- a/mkspecs/common/symbian/symbian.conf +++ b/mkspecs/common/symbian/symbian.conf @@ -71,12 +71,16 @@ QMAKE_LIBS_GUI = $$QMAKE_LIBS_CORE -lfbscli -lbitgdi -lhal -lgdi -lws32 QMAKE_LIBS_NETWORK = QMAKE_LIBS_EGL = -llibEGL QMAKE_LIBS_OPENGL = -QMAKE_LIBS_OPENVG = -llibOpenVG -lgraphicsresource -lfbscli -lbitgdi -lgdi +QMAKE_LIBS_OPENVG = -llibOpenVG -lfbscli -lbitgdi -lgdi QMAKE_LIBS_THREAD = -llibpthread QMAKE_LIBS_COMPAT = QMAKE_LIBS_QT_ENTRY = -llibcrt0.lib QMAKE_LIBS_S60 = -lavkon +exists($${EPOCROOT}epoc32/include/platform/sgresource/sgimage.h) { + QMAKE_LIBS_OPENVG += -lsgresource +} + contains(QMAKE_HOST.os,Windows) { QMAKE_COPY = copy /y QMAKE_COPY_DIR = xcopy /s /q /y /i diff --git a/mkspecs/features/symbian/data_caging_paths.prf b/mkspecs/features/symbian/data_caging_paths.prf index 3ed5661..6f40bb5 100644 --- a/mkspecs/features/symbian/data_caging_paths.prf +++ b/mkspecs/features/symbian/data_caging_paths.prf @@ -74,7 +74,7 @@ exists($${EPOCROOT}epoc32/include/data_caging_paths.prf) { BOOTDATA_DIR = /resource/bootdata } -isEmpty(QT_PLUGINS_BASE_DIR): QT_PLUGINS_BASE_DIR = /$$RESOURCE_FILES_DIR/qt/plugins +isEmpty(QT_PLUGINS_BASE_DIR): QT_PLUGINS_BASE_DIR = /$$RESOURCE_FILES_DIR/qt$${QT_LIBINFIX}/plugins isEmpty(HW_ZDIR): HW_ZDIR = epoc32/data/z isEmpty(REG_RESOURCE_DIR): REG_RESOURCE_DIR = /private/10003a3f/apps isEmpty(REG_RESOURCE_IMPORT_DIR): REG_RESOURCE_IMPORT_DIR = /private/10003a3f/import/apps
\ No newline at end of file diff --git a/mkspecs/features/symbian/default_post.prf b/mkspecs/features/symbian/default_post.prf index d29e460..0564e9b 100644 --- a/mkspecs/features/symbian/default_post.prf +++ b/mkspecs/features/symbian/default_post.prf @@ -5,7 +5,7 @@ contains(TEMPLATE, ".*app") { QMAKE_LIBS += } else:contains(QT, gui):contains(CONFIG,qt) { S60MAIN_LIBS = -leuser - QMAKE_LIBS += -lqtmain.lib $$S60MAIN_LIBS + QMAKE_LIBS += -lqtmain$${QT_LIBINFIX}.lib $$S60MAIN_LIBS } else { QMAKE_LIBS += $$QMAKE_LIBS_QT_ENTRY } diff --git a/mkspecs/features/symbian/qt.prf b/mkspecs/features/symbian/qt.prf index 294a68c..2dc614f 100644 --- a/mkspecs/features/symbian/qt.prf +++ b/mkspecs/features/symbian/qt.prf @@ -24,7 +24,7 @@ INCLUDEPATH = $$PREPEND_INCLUDEPATH $$INCLUDEPATH # Add dependency to Qt package to all other projects besides Qt libs. # Note: Qt libs with full capabilities has UID3 of 0x2001E61C, # while self-signed version typically has temporary UID3 of 0xE001E61C. -contains(CONFIG, qt):!contains(TARGET.UID3, 0x2001E61C):!contains(TARGET.UID3, 0xE001E61C) { +contains(CONFIG, qt):!contains(TARGET.UID3, 0x2001E61C):!contains(TARGET.UID3, 0xE001E61C):isEmpty(QT_LIBINFIX) { default_deployment.pkg_prerules += \ "; Default dependency to Qt libraries" \ "(0x2001E61C), $${QT_MAJOR_VERSION}, $${QT_MINOR_VERSION}, $${QT_PATCH_VERSION}, {\"Qt\"}" @@ -43,5 +43,5 @@ isEmpty(TARGET.EPOCHEAPSIZE):TARGET.EPOCHEAPSIZE = 0x020000 0x800000 # Workaround for the fact that Gnupoc and Symbian chose different approaches to # the letter casing of headers. contains(CONFIG, is_using_gnupoc) { - INCLUDEPATH += $$QT_SOURCE_TREE/mkspecs/common/symbian/header-wrappers + INCLUDEPATH += $$[QT_INSTALL_PREFIX]/mkspecs/common/symbian/header-wrappers } diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h index 1599562..5fb7fe3 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h +++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h @@ -75,7 +75,7 @@ #include <libkern/OSAtomic.h> #elif OS(ANDROID) #include <cutils/atomic.h> -#elif COMPILER(GCC) +#elif COMPILER(GCC) && !PLATFORM(SYMBIAN) #if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) #include <ext/atomicity.h> #else @@ -239,7 +239,7 @@ inline int atomicDecrement(int volatile* addend) { return OSAtomicDecrement32Bar inline int atomicIncrement(int volatile* addend) { return android_atomic_inc(addend); } inline int atomicDecrement(int volatile* addend) { return android_atomic_dec(addend); } -#elif COMPILER(GCC) && !CPU(SPARC64) // sizeof(_Atomic_word) != sizeof(int) on sparc64 gcc +#elif COMPILER(GCC) && !PLATFORM(SPARC64) && !PLATFORM(SYMBIAN) // sizeof(_Atomic_word) != sizeof(int) on sparc64 gcc #define WTF_USE_LOCKFREE_THREADSAFESHARED 1 inline int atomicIncrement(int volatile* addend) { return __gnu_cxx::__exchange_and_add(addend, 1) + 1; } diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp index 132eb79..6cfeb76 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp @@ -20,7 +20,6 @@ along with this library. If not, see <http://www.gnu.org/licenses/>. #include "abstractaudioeffect.h" #include "audioplayer.h" -#include "mmf_videoplayer.h" QT_BEGIN_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.h b/src/3rdparty/phonon/mmf/abstractaudioeffect.h index 436e8e4..d71993b 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.h +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.h @@ -28,7 +28,6 @@ along with this library. If not, see <http://www.gnu.org/licenses/>. #include "audioplayer.h" #include "effectparameter.h" #include "mmf_medianode.h" -#include "mmf_videoplayer.h" class CMdaAudioOutputStream; diff --git a/src/3rdparty/phonon/mmf/abstractplayer.cpp b/src/3rdparty/phonon/mmf/abstractplayer.cpp index 53973eb..421155b 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractplayer.cpp @@ -96,7 +96,7 @@ void MMF::AbstractPlayer::volumeChanged(qreal volume) // Video output //----------------------------------------------------------------------------- -void MMF::AbstractPlayer::setVideoOutput(VideoOutput* videoOutput) +void MMF::AbstractPlayer::setVideoOutput(AbstractVideoOutput* videoOutput) { m_videoOutput = videoOutput; videoOutputChanged(); diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index cec5568..92bd87e 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -24,7 +24,7 @@ along with this library. If not, see <http://www.gnu.org/licenses/>. #include <QObject> -#include "videooutput.h" +#include "abstractvideooutput.h" class RFile; @@ -34,7 +34,6 @@ namespace Phonon { namespace MMF { -class VideoOutput; /** * @short Interface which abstracts from MediaObject the current @@ -79,7 +78,7 @@ public: virtual void volumeChanged(qreal volume); - void setVideoOutput(VideoOutput* videoOutput); + void setVideoOutput(AbstractVideoOutput *videoOutput); /** * Records error message and changes state to ErrorState @@ -156,7 +155,7 @@ private: protected: // Not owned - VideoOutput* m_videoOutput; + AbstractVideoOutput* m_videoOutput; qreal m_volume; diff --git a/src/3rdparty/phonon/mmf/abstractvideooutput.cpp b/src/3rdparty/phonon/mmf/abstractvideooutput.cpp new file mode 100644 index 0000000..3fe66fc --- /dev/null +++ b/src/3rdparty/phonon/mmf/abstractvideooutput.cpp @@ -0,0 +1,177 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#include "abstractvideooutput.h" +#include "utils.h" + +#ifndef QT_NO_DEBUG +#include "objectdump.h" +#endif + +#include <QtCore/private/qcore_symbian_p.h> // for qt_TSize2QSize + +#include <QMoveEvent> +#include <QResizeEvent> + +#include <coecntrl.h> + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +/*! \class MMF::AbstractVideoOutput + \internal +*/ + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + +static const Phonon::VideoWidget::AspectRatio DefaultAspectRatio = + Phonon::VideoWidget::AspectRatioAuto; +static const Phonon::VideoWidget::ScaleMode DefaultScaleMode = + Phonon::VideoWidget::FitInView; + + +//----------------------------------------------------------------------------- +// Constructor / destructor +//----------------------------------------------------------------------------- + +MMF::AbstractVideoOutput::AbstractVideoOutput(QWidget *parent) + : QWidget(parent) + , m_aspectRatio(DefaultAspectRatio) + , m_scaleMode(DefaultScaleMode) +{ + +} + +MMF::AbstractVideoOutput::~AbstractVideoOutput() +{ + +} + +void MMF::AbstractVideoOutput::setVideoSize(const QSize &frameSize) +{ + TRACE_CONTEXT(AbstractVideoOutput::setVideoSize, EVideoInternal); + TRACE("oldSize %d %d newSize %d %d", + m_videoFrameSize.width(), m_videoFrameSize.height(), + frameSize.width(), frameSize.height()); + + if (frameSize != m_videoFrameSize) { + m_videoFrameSize = frameSize; + updateGeometry(); + } +} + + +//----------------------------------------------------------------------------- +// QWidget +//----------------------------------------------------------------------------- + +QSize MMF::AbstractVideoOutput::sizeHint() const +{ + // TODO: replace this with a more sensible default + QSize result(320, 240); + + if (!m_videoFrameSize.isNull()) + result = m_videoFrameSize; + + return result; +} + + +//----------------------------------------------------------------------------- +// Public functions +//----------------------------------------------------------------------------- + +RWindowBase* MMF::AbstractVideoOutput::videoWindow() const +{ + CCoeControl *control = internalWinId(); + if (!control) + control = effectiveWinId(); + + RWindowBase *window = 0; + if (control) + window = control->DrawableWindow(); + + return window; +} + +QSize MMF::AbstractVideoOutput::videoWindowSize() const +{ + QSize result; + if (RWindowBase *const window = videoWindow()) + result = qt_TSize2QSize(window->Size()); + return result; +} + +Phonon::VideoWidget::AspectRatio MMF::AbstractVideoOutput::aspectRatio() const +{ + return m_aspectRatio; +} + +void MMF::AbstractVideoOutput::setAspectRatio + (Phonon::VideoWidget::AspectRatio aspectRatio) +{ + if (m_aspectRatio != aspectRatio) { + m_aspectRatio = aspectRatio; + emit aspectRatioChanged(); + } +} + +Phonon::VideoWidget::ScaleMode MMF::AbstractVideoOutput::scaleMode() const +{ + return m_scaleMode; +} + +void MMF::AbstractVideoOutput::setScaleMode + (Phonon::VideoWidget::ScaleMode scaleMode) +{ + if (m_scaleMode != scaleMode) { + m_scaleMode = scaleMode; + emit scaleModeChanged(); + } +} + + +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- + +void MMF::AbstractVideoOutput::dump() const +{ +#ifndef QT_NO_DEBUG + TRACE_CONTEXT(AbstractVideoOutput::dump, EVideoInternal); + + QScopedPointer<ObjectDump::QVisitor> visitor(new ObjectDump::QVisitor); + visitor->setPrefix("Phonon::MMF"); // to aid searchability of logs + ObjectDump::addDefaultAnnotators(*visitor); + TRACE("Dumping tree from leaf 0x%08x:", this); + ObjectDump::dumpTreeFromLeaf(*this, *visitor); + + QScopedPointer<ObjectDump::QDumper> dumper(new ObjectDump::QDumper); + dumper->setPrefix("Phonon::MMF"); // to aid searchability of logs + ObjectDump::addDefaultAnnotators(*dumper); + TRACE_0("Dumping AbstractVideoOutput:"); + dumper->dumpObject(*this); +#endif +} + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/videooutput.h b/src/3rdparty/phonon/mmf/abstractvideooutput.h index 3e9c036..61bcd0f 100644 --- a/src/3rdparty/phonon/mmf/videooutput.h +++ b/src/3rdparty/phonon/mmf/abstractvideooutput.h @@ -16,14 +16,15 @@ along with this library. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef PHONON_MMF_VIDEOOUTPUT_H -#define PHONON_MMF_VIDEOOUTPUT_H +#ifndef PHONON_MMF_ABSTRACTVIDEOOUTPUT_H +#define PHONON_MMF_ABSTRACTVIDEOOUTPUT_H #include <QtGui/QWidget> #include <QVector> #include <QRect> #include "defs.h" +#include <phonon/abstractvideooutput.h> #include <phonon/videowidget.h> #include <e32std.h> @@ -35,21 +36,25 @@ namespace Phonon { namespace MMF { -class AncestorMoveMonitor; -class VideoOutput : public QWidget +/** + * @short ABC for widget on which video is displayed + * + * @see DsaVideoOutput, SurfaceVideoOutput + */ +class AbstractVideoOutput + : public QWidget { Q_OBJECT public: - VideoOutput(AncestorMoveMonitor* ancestorMoveMonitor, QWidget* parent); - ~VideoOutput(); + ~AbstractVideoOutput(); // Set size of video frame. Called by VideoPlayer. - void setVideoSize(const QSize& size); + void setVideoSize(const QSize &size); - RWindowBase* videoWindow(); - const QRect& videoWindowRect() const; + RWindowBase* videoWindow() const; + QSize videoWindowSize() const; Phonon::VideoWidget::AspectRatio aspectRatio() const; void setAspectRatio(Phonon::VideoWidget::AspectRatio aspectRatio); @@ -57,41 +62,24 @@ public: Phonon::VideoWidget::ScaleMode scaleMode() const; void setScaleMode(Phonon::VideoWidget::ScaleMode scaleMode); - // Called by AncestorMoveMonitor - void ancestorMoved(); - // Debugging output void dump() const; -public Q_SLOTS: - void beginNativePaintEvent(const QRect& /*controlRect*/); - void endNativePaintEvent(const QRect& /*controlRect*/); - Q_SIGNALS: void videoWindowChanged(); void aspectRatioChanged(); void scaleModeChanged(); - void beginVideoWindowNativePaint(); - void endVideoWindowNativePaint(); protected: - // Override QWidget functions - QSize sizeHint() const; - void paintEvent(QPaintEvent* event); - void resizeEvent(QResizeEvent* event); - void moveEvent(QMoveEvent* event); - bool event(QEvent* event); + AbstractVideoOutput(QWidget *parent); private: - void getVideoWindowRect(); - void registerForAncestorMoved(); + // QWidget + QSize sizeHint() const; private: - // Not owned - AncestorMoveMonitor* m_ancestorMoveMonitor; - + // Dimensions of the video clip QSize m_videoFrameSize; - QRect m_videoWindowRect; Phonon::VideoWidget::AspectRatio m_aspectRatio; Phonon::VideoWidget::ScaleMode m_scaleMode; diff --git a/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp b/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp new file mode 100644 index 0000000..8cb9db5 --- /dev/null +++ b/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp @@ -0,0 +1,490 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#include <QUrl> +#include <QTimer> +#include <QWidget> + +#include <coemain.h> // for CCoeEnv + +#include "abstractvideoplayer.h" +#include "utils.h" + +#ifndef QT_NO_DEBUG +#include "objectdump.h" +#endif + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +/*! \class MMF::AbstractVideoPlayer + \internal +*/ + +//----------------------------------------------------------------------------- +// Constructor / destructor +//----------------------------------------------------------------------------- + +MMF::AbstractVideoPlayer::AbstractVideoPlayer(MediaObject *parent, const AbstractPlayer *player) + : AbstractMediaPlayer(parent, player) + , m_wsSession(CCoeEnv::Static()->WsSession()) + , m_screenDevice(*CCoeEnv::Static()->ScreenDevice()) + , m_window(0) + , m_scaleWidth(1.0) + , m_scaleHeight(1.0) + , m_totalTime(0) +{ + +} + +void MMF::AbstractVideoPlayer::construct() +{ + TRACE_CONTEXT(AbstractVideoPlayer::AbstractVideoPlayer, EVideoApi); + TRACE_ENTRY_0(); + + if (m_videoOutput) { + initVideoOutput(); + m_window = m_videoOutput->videoWindow(); + } + + createPlayer(); + + TRACE_EXIT_0(); +} + +MMF::AbstractVideoPlayer::~AbstractVideoPlayer() +{ + TRACE_CONTEXT(AbstractVideoPlayer::~AbstractVideoPlayer, EVideoApi); + TRACE_ENTRY_0(); + + // QObject destructor removes all signal-slot connections involving this + // object, so we do not need to disconnect from m_videoOutput here. + + TRACE_EXIT_0(); +} + +CVideoPlayerUtility* MMF::AbstractVideoPlayer::nativePlayer() const +{ + return m_player.data(); +} + +//----------------------------------------------------------------------------- +// Public API +//----------------------------------------------------------------------------- + +void MMF::AbstractVideoPlayer::doPlay() +{ + TRACE_CONTEXT(AbstractVideoPlayer::doPlay, EVideoApi); + + handlePendingParametersChanged(); + + m_player->Play(); +} + +void MMF::AbstractVideoPlayer::doPause() +{ + TRACE_CONTEXT(AbstractVideoPlayer::doPause, EVideoApi); + + TRAPD(err, m_player->PauseL()); + if (KErrNone != err && state() != ErrorState) { + TRACE("PauseL error %d", err); + setError(tr("Pause failed"), err); + } +} + +void MMF::AbstractVideoPlayer::doStop() +{ + m_player->Stop(); +} + +void MMF::AbstractVideoPlayer::doSeek(qint64 ms) +{ + TRACE_CONTEXT(AbstractVideoPlayer::doSeek, EVideoApi); + + TRAPD(err, m_player->SetPositionL(TTimeIntervalMicroSeconds(ms * 1000))); + + if (KErrNone != err) + setError(tr("Seek failed"), err); +} + +int MMF::AbstractVideoPlayer::setDeviceVolume(int mmfVolume) +{ + TRAPD(err, m_player->SetVolumeL(mmfVolume)); + return err; +} + +int MMF::AbstractVideoPlayer::openFile(RFile &file) +{ + TRAPD(err, m_player->OpenFileL(file)); + return err; +} + +int MMF::AbstractVideoPlayer::openUrl(const QString &url) +{ + TRAPD(err, m_player->OpenUrlL(qt_QString2TPtrC(url))); + return err; +} + +int MMF::AbstractVideoPlayer::bufferStatus() const +{ + int result = 0; + TRAP_IGNORE(m_player->GetVideoLoadingProgressL(result)); + return result; +} + +void MMF::AbstractVideoPlayer::close() +{ + m_player->Close(); +} + +bool MMF::AbstractVideoPlayer::hasVideo() const +{ + return true; +} + +qint64 MMF::AbstractVideoPlayer::currentTime() const +{ + TRACE_CONTEXT(AbstractVideoPlayer::currentTime, EVideoApi); + + TTimeIntervalMicroSeconds us; + TRAPD(err, us = m_player->PositionL()) + + qint64 result = 0; + + if (KErrNone == err) { + result = toMilliSeconds(us); + } else { + TRACE("PositionL error %d", err); + + // If we don't cast away constness here, we simply have to ignore + // the error. + const_cast<AbstractVideoPlayer*>(this)->setError(tr("Getting position failed"), err); + } + + return result; +} + +qint64 MMF::AbstractVideoPlayer::totalTime() const +{ + return m_totalTime; +} + + +//----------------------------------------------------------------------------- +// Public slots +//----------------------------------------------------------------------------- + +void MMF::AbstractVideoPlayer::videoWindowChanged() +{ + TRACE_CONTEXT(AbstractVideoPlayer::videoOutputRegionChanged, EVideoInternal); + TRACE_ENTRY("state %d", state()); + + m_window = m_videoOutput ? m_videoOutput->videoWindow() : 0; + + handleVideoWindowChanged(); + + TRACE_EXIT_0(); +} + +void MMF::AbstractVideoPlayer::aspectRatioChanged() +{ + TRACE_CONTEXT(AbstractVideoPlayer::aspectRatioChanged, EVideoInternal); + TRACE_ENTRY("state %d aspectRatio %d", state()); + + updateScaleFactors(m_videoOutput->videoWindowSize()); + + TRACE_EXIT_0(); +} + +void MMF::AbstractVideoPlayer::scaleModeChanged() +{ + TRACE_CONTEXT(AbstractVideoPlayer::scaleModeChanged, EVideoInternal); + TRACE_ENTRY("state %d", state()); + + updateScaleFactors(m_videoOutput->videoWindowSize()); + + TRACE_EXIT_0(); +} + + +//----------------------------------------------------------------------------- +// MVideoPlayerUtilityObserver callbacks +//----------------------------------------------------------------------------- + +void MMF::AbstractVideoPlayer::MvpuoOpenComplete(TInt aError) +{ + TRACE_CONTEXT(AbstractVideoPlayer::MvpuoOpenComplete, EVideoApi); + TRACE_ENTRY("state %d error %d", state(), aError); + + __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); + + if (KErrNone == aError) + m_player->Prepare(); + else + setError(tr("Opening clip failed"), aError); + + TRACE_EXIT_0(); +} + +void MMF::AbstractVideoPlayer::MvpuoPrepareComplete(TInt aError) +{ + TRACE_CONTEXT(AbstractVideoPlayer::MvpuoPrepareComplete, EVideoApi); + TRACE_ENTRY("state %d error %d", state(), aError); + + __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); + + TRAPD(err, getVideoClipParametersL(aError)); + + if (KErrNone == err) { + maxVolumeChanged(m_player->MaxVolume()); + + if (m_videoOutput) + m_videoOutput->setVideoSize(m_videoFrameSize); + + prepareCompleted(); + handlePendingParametersChanged(); + + emit totalTimeChanged(totalTime()); + changeState(StoppedState); + } else { + setError(tr("Buffering clip failed"), err); + } + + TRACE_EXIT_0(); +} + +void MMF::AbstractVideoPlayer::getVideoClipParametersL(TInt aError) +{ + User::LeaveIfError(aError); + + // Get frame size + TSize size; + m_player->VideoFrameSizeL(size); + m_videoFrameSize = QSize(size.iWidth, size.iHeight); + + // Get duration + m_totalTime = toMilliSeconds(m_player->DurationL()); +} + + +void MMF::AbstractVideoPlayer::MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError) +{ + TRACE_CONTEXT(AbstractVideoPlayer::MvpuoFrameReady, EVideoApi); + TRACE_ENTRY("state %d error %d", state(), aError); + + Q_UNUSED(aFrame); + Q_UNUSED(aError); // suppress warnings in release builds + + TRACE_EXIT_0(); +} + +void MMF::AbstractVideoPlayer::MvpuoPlayComplete(TInt aError) +{ + TRACE_CONTEXT(AbstractVideoPlayer::MvpuoPlayComplete, EVideoApi) + TRACE_ENTRY("state %d error %d", state(), aError); + + // Call base class function which handles end of playback for both + // audio and video clips. + playbackComplete(aError); + + TRACE_EXIT_0(); +} + +void MMF::AbstractVideoPlayer::MvpuoEvent(const TMMFEvent &aEvent) +{ + TRACE_CONTEXT(AbstractVideoPlayer::MvpuoEvent, EVideoApi); + TRACE_ENTRY("state %d", state()); + + Q_UNUSED(aEvent); + + TRACE_EXIT_0(); +} + + +//----------------------------------------------------------------------------- +// MVideoLoadingObserver callbacks +//----------------------------------------------------------------------------- + +void MMF::AbstractVideoPlayer::MvloLoadingStarted() +{ + bufferingStarted(); +} + +void MMF::AbstractVideoPlayer::MvloLoadingComplete() +{ + bufferingComplete(); +} + + +//----------------------------------------------------------------------------- +// Video window updates +//----------------------------------------------------------------------------- + +void MMF::AbstractVideoPlayer::videoOutputChanged() +{ + TRACE_CONTEXT(AbstractVideoPlayer::videoOutputChanged, EVideoInternal); + TRACE_ENTRY_0(); + + if (m_videoOutput) + initVideoOutput(); + + videoWindowChanged(); + + TRACE_EXIT_0(); +} + +void MMF::AbstractVideoPlayer::initVideoOutput() +{ + bool connected = connect( + m_videoOutput, SIGNAL(videoWindowChanged()), + this, SLOT(videoWindowChanged()) + ); + Q_ASSERT(connected); + + connected = connect( + m_videoOutput, SIGNAL(aspectRatioChanged()), + this, SLOT(aspectRatioChanged()) + ); + Q_ASSERT(connected); + + connected = connect( + m_videoOutput, SIGNAL(scaleModeChanged()), + this, SLOT(scaleModeChanged()) + ); + Q_ASSERT(connected); + + // Suppress warnings in release builds + Q_UNUSED(connected); + + // Do these after all connections are complete, to ensure + // that any signals generated get to their destinations. + m_videoOutput->winId(); + m_videoOutput->setVideoSize(m_videoFrameSize); +} + +// Helper function for aspect ratio / scale mode handling +QSize scaleToAspect(const QSize &srcRect, int aspectWidth, int aspectHeight) +{ + const qreal aspectRatio = qreal(aspectWidth) / aspectHeight; + + int width = srcRect.width(); + int height = srcRect.width() / aspectRatio; + if (height > srcRect.height()){ + height = srcRect.height(); + width = srcRect.height() * aspectRatio; + } + return QSize(width, height); +} + +void MMF::AbstractVideoPlayer::updateScaleFactors(const QSize &windowSize, bool apply) +{ + if (m_videoFrameSize.isValid()) { + QRect videoRect; + + // Calculate size of smallest rect which contains video frame size + // and conforms to aspect ratio + switch (m_videoOutput->aspectRatio()) { + case Phonon::VideoWidget::AspectRatioAuto: + videoRect.setSize(m_videoFrameSize); + break; + + case Phonon::VideoWidget::AspectRatioWidget: + videoRect.setSize(windowSize); + break; + + case Phonon::VideoWidget::AspectRatio4_3: + videoRect.setSize(scaleToAspect(m_videoFrameSize, 4, 3)); + break; + + case Phonon::VideoWidget::AspectRatio16_9: + videoRect.setSize(scaleToAspect(m_videoFrameSize, 16, 9)); + break; + } + + // Scale to fill the window width + const int windowWidth = windowSize.width(); + const int windowHeight = windowSize.height(); + const qreal windowScaleFactor = qreal(windowWidth) / videoRect.width(); + int videoWidth = windowWidth; + int videoHeight = videoRect.height() * windowScaleFactor; + + const qreal windowToVideoHeightRatio = qreal(windowHeight) / videoHeight; + + switch (m_videoOutput->scaleMode()) { + case Phonon::VideoWidget::ScaleAndCrop: + if (videoHeight < windowHeight) { + videoWidth *= windowToVideoHeightRatio; + videoHeight = windowHeight; + } + break; + case Phonon::VideoWidget::FitInView: + default: + if (videoHeight > windowHeight) { + videoWidth *= windowToVideoHeightRatio; + videoHeight = windowHeight; + } + break; + } + + // Calculate scale factors + m_scaleWidth = 100.0f * videoWidth / m_videoFrameSize.width(); + m_scaleHeight = 100.0f * videoHeight / m_videoFrameSize.height(); + + if (apply) + parametersChanged(ScaleFactors); + } +} + +void MMF::AbstractVideoPlayer::parametersChanged(VideoParameters parameters) +{ + if (state() == LoadingState) + m_pendingChanges |= parameters; + else + handleParametersChanged(parameters); +} + +void MMF::AbstractVideoPlayer::handlePendingParametersChanged() +{ + if (m_pendingChanges) + handleParametersChanged(m_pendingChanges); + m_pendingChanges = 0; +} + + +//----------------------------------------------------------------------------- +// Metadata +//----------------------------------------------------------------------------- + +int MMF::AbstractVideoPlayer::numberOfMetaDataEntries() const +{ + int numberOfEntries = 0; + TRAP_IGNORE(numberOfEntries = m_player->NumberOfMetaDataEntriesL()); + return numberOfEntries; +} + +QPair<QString, QString> MMF::AbstractVideoPlayer::metaDataEntry(int index) const +{ + CMMFMetaDataEntry *entry = 0; + QT_TRAP_THROWING(entry = m_player->MetaDataEntryL(index)); + return QPair<QString, QString>(qt_TDesC2QString(entry->Name()), qt_TDesC2QString(entry->Value())); +} + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/abstractvideoplayer.h b/src/3rdparty/phonon/mmf/abstractvideoplayer.h new file mode 100644 index 0000000..d854793 --- /dev/null +++ b/src/3rdparty/phonon/mmf/abstractvideoplayer.h @@ -0,0 +1,171 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_ABSTRACTVIDEOPLAYER_H +#define PHONON_MMF_ABSTRACTVIDEOPLAYER_H + +#include <videoplayer.h> // from epoc32/include + +#include <QSize> + +#include "abstractmediaplayer.h" +#include "abstractvideooutput.h" +#include "defs.h" + +QT_BEGIN_NAMESPACE + +namespace Phonon +{ +namespace MMF +{ +/** + * @short ABC for classes which wrap the MMF video player utility + * + * On devices which use the legacy graphics subsystem which does not + * support surfaces, video rendering is done via Direct Screen Access using + * the CVideoPlayerUtility API. On devices with a graphics subsystem which + * does support surfaces, video rendering is done using the + * CVideoPlayerUtility2 API. Because CVideoPlayerUtility2 inherits from + * CVideoPlayerUtility, AbstractVideoPlayer holds a pointer to the latter. + * + * @see DsaVideoPlayer, SurfaceVideoPlayer + */ +class AbstractVideoPlayer + : public AbstractMediaPlayer + , public MVideoPlayerUtilityObserver + , public MVideoLoadingObserver +{ + Q_OBJECT + +public: + ~AbstractVideoPlayer(); + + typedef CVideoPlayerUtility NativePlayer; + NativePlayer *nativePlayer() const; + + // AbstractPlayer + virtual void doPlay(); + virtual void doPause(); + virtual void doStop(); + virtual void doSeek(qint64 milliseconds); + virtual int setDeviceVolume(int mmfVolume); + virtual int openFile(RFile &file); + virtual int openUrl(const QString &url); + virtual int bufferStatus() const; + virtual void close(); + + // MediaObjectInterface + virtual bool hasVideo() const; + virtual qint64 currentTime() const; + virtual qint64 totalTime() const; + + // AbstractPlayer + virtual void videoOutputChanged(); + + // AbstractMediaPlayer + virtual int numberOfMetaDataEntries() const; + virtual QPair<QString, QString> metaDataEntry(int index) const; + +public Q_SLOTS: + void videoWindowChanged(); + void aspectRatioChanged(); + void scaleModeChanged(); + +protected: + AbstractVideoPlayer(MediaObject *parent, const AbstractPlayer *player); + void construct(); + virtual void initVideoOutput(); + void updateScaleFactors(const QSize &windowSize, bool apply = true); + + // Called when a video parameter changes. If the underlying native API is + // ready to handle the change, it is propagated immediately, otherwise the + // change is recorded in m_pendingChanged and handled later by + // handlePendingParametersChanged(). + void parametersChanged(VideoParameters parameter); + + // Implementation must initialize the m_player pointer. + virtual void createPlayer() = 0; + + // Called from the MvpuoPrepareComplete callback. Allows derived class to + // calculate clipping rectangles and scale factors prior to starting + // playback. + virtual void prepareCompleted() = 0; + + // Called when native video window handle changes. Derived class may defer + // propagation of this change to the MMF video player utility by calling + // parametersChanged(). + virtual void handleVideoWindowChanged() = 0; + + // Called when the derived class must handle changes which have been made + // to video parameters such as window handle, screen rectangle and scale + // factors. Guaranteed to be called only when the underlying MMF video + // player object is ready to handle changes to these parameters. + virtual void handleParametersChanged(VideoParameters parameters) = 0; + +private: + void getVideoClipParametersL(TInt aError); + + // Called when native player API enters a state in which it is able to + // handle pending changes such as new video window handle, updated scale + // factors etc. + void handlePendingParametersChanged(); + +private: + // MVideoPlayerUtilityObserver + virtual void MvpuoOpenComplete(TInt aError); + virtual void MvpuoPrepareComplete(TInt aError); + virtual void MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError); + virtual void MvpuoPlayComplete(TInt aError); + virtual void MvpuoEvent(const TMMFEvent &aEvent); + + // MVideoLoadingObserver + virtual void MvloLoadingStarted(); + virtual void MvloLoadingComplete(); + +protected: + QScopedPointer<NativePlayer> m_player; + + // Not owned + RWsSession& m_wsSession; + CWsScreenDevice& m_screenDevice; + RWindowBase* m_window; + + // Scaling factors for video display, expressed as percentages + TReal32 m_scaleWidth; + TReal32 m_scaleHeight; + + // Dimensions of the video clip + QSize m_videoFrameSize; + +private: + // Bitmask of parameters which have changed while the MMF video player + // object is not yet ready to receive these changes. + // See handlePendingParametersChanged(). + VideoParameters m_pendingChanges; + + // Duration of the video clip + qint64 m_totalTime; + +}; + +} +} + +QT_END_NAMESPACE + +#endif diff --git a/src/3rdparty/phonon/mmf/ancestormovemonitor.cpp b/src/3rdparty/phonon/mmf/ancestormovemonitor.cpp index 18ced94..f0d1be2 100644 --- a/src/3rdparty/phonon/mmf/ancestormovemonitor.cpp +++ b/src/3rdparty/phonon/mmf/ancestormovemonitor.cpp @@ -18,7 +18,8 @@ along with this library. If not, see <http://www.gnu.org/licenses/>. #include "ancestormovemonitor.h" #include "utils.h" -#include "videooutput.h" + +#include "videooutput_dsa.h" #include <QCoreApplication> @@ -59,7 +60,7 @@ AncestorMoveMonitor::~AncestorMoveMonitor() // Public functions //----------------------------------------------------------------------------- -void AncestorMoveMonitor::registerTarget(VideoOutput *target) +void AncestorMoveMonitor::registerTarget(DsaVideoOutput *target) { TRACE_CONTEXT(AncestorMoveMonitor::registerTarget, EVideoInternal); TRACE_ENTRY("target 0x%08x", target); @@ -93,7 +94,7 @@ void AncestorMoveMonitor::registerTarget(VideoOutput *target) TRACE_EXIT_0(); } -void AncestorMoveMonitor::unRegisterTarget(VideoOutput *target) +void AncestorMoveMonitor::unRegisterTarget(DsaVideoOutput *target) { TRACE_CONTEXT(AncestorMoveMonitor::unRegisterTarget, EVideoInternal); TRACE_ENTRY("target 0x%08x", target); @@ -126,7 +127,7 @@ bool AncestorMoveMonitor::eventFilter(QObject *watched, QEvent *event) const Hash::const_iterator it = m_hash.find(watched); if(it != m_hash.end()) { const TargetList& targetList = it.value(); - VideoOutput* target = 0; + DsaVideoOutput* target = 0; foreach(target, targetList) { switch (event->type()) { @@ -166,7 +167,7 @@ void AncestorMoveMonitor::dump() const QObject *ancestor = it.key(); TRACE("ancestor 0x%08x", ancestor); const TargetList& targetList = it.value(); - VideoOutput* target = 0; + DsaVideoOutput* target = 0; foreach(target, targetList) { TRACE(" target 0x%08x", target); } @@ -174,7 +175,5 @@ void AncestorMoveMonitor::dump() #endif } - - QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/ancestormovemonitor.h b/src/3rdparty/phonon/mmf/ancestormovemonitor.h index 0e681aa..f3a022d 100644 --- a/src/3rdparty/phonon/mmf/ancestormovemonitor.h +++ b/src/3rdparty/phonon/mmf/ancestormovemonitor.h @@ -29,7 +29,7 @@ namespace Phonon { namespace MMF { -class VideoOutput; +class DsaVideoOutput; class AncestorMoveMonitor : public QObject { @@ -49,7 +49,7 @@ public: * ancestor list to be updated - therefore it should be called when * the target receives a ParentChange event. */ - void registerTarget(VideoOutput *target); + void registerTarget(DsaVideoOutput *target); /** * Remove target from the monitor. @@ -57,7 +57,7 @@ public: * The target will no longer receive notification when move events are * delivered to its ancestors. */ - void unRegisterTarget(VideoOutput *target); + void unRegisterTarget(DsaVideoOutput *target); protected: /** @@ -77,7 +77,7 @@ private: * therefore a set, however we use QList rather than QSet for * efficiency of iteration. */ - typedef QList<VideoOutput *> TargetList; + typedef QList<DsaVideoOutput *> TargetList; /** * Map from widget on which the move event occurs, to widgets which @@ -92,4 +92,4 @@ private: QT_END_NAMESPACE -#endif +#endif // !PHONON_MMF_ANCESTORMOVEMONITOR_H diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index 3568a49..2cec43b 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -24,7 +24,6 @@ along with this library. If not, see <http://www.gnu.org/licenses/>. #include <apmstd.h> // for TDataType #include "abstractaudioeffect.h" -#include "ancestormovemonitor.h" #include "audiooutput.h" #include "audioplayer.h" #include "backend.h" @@ -44,7 +43,9 @@ using namespace Phonon::MMF; Backend::Backend(QObject *parent) : QObject(parent) +#ifndef PHONON_MMF_VIDEO_SURFACES , m_ancestorMoveMonitor(new AncestorMoveMonitor(this)) +#endif , m_effectFactory(new EffectFactory(this)) { TRACE_CONTEXT(Backend::Backend, EBackend); @@ -86,8 +87,15 @@ QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const static_cast<EffectFactory::Type>(args.first().toInt()); return m_effectFactory->createAudioEffect(type, parent); } + case VideoWidgetClass: - result = new VideoWidget(m_ancestorMoveMonitor.data(), qobject_cast<QWidget *>(parent)); + { + VideoWidget *widget = new VideoWidget(qobject_cast<QWidget *>(parent)); +#ifndef PHONON_MMF_VIDEO_SURFACES + widget->setAncestorMoveMonitor(m_ancestorMoveMonitor.data()); +#endif + result = widget; + } break; default: diff --git a/src/3rdparty/phonon/mmf/backend.h b/src/3rdparty/phonon/mmf/backend.h index 9361544..a45c92a 100644 --- a/src/3rdparty/phonon/mmf/backend.h +++ b/src/3rdparty/phonon/mmf/backend.h @@ -19,7 +19,10 @@ along with this library. If not, see <http://www.gnu.org/licenses/>. #ifndef PHONON_MMF_BACKEND_H #define PHONON_MMF_BACKEND_H +#ifndef PHONON_MMF_VIDEO_SURFACES #include "ancestormovemonitor.h" +#endif + #include "effectfactory.h" #include <phonon/mediasource.h> @@ -53,7 +56,9 @@ Q_SIGNALS: void objectDescriptionChanged(ObjectDescriptionType); private: +#ifndef PHONON_MMF_VIDEO_SURFACES QScopedPointer<AncestorMoveMonitor> m_ancestorMoveMonitor; +#endif QScopedPointer<EffectFactory> m_effectFactory; }; diff --git a/src/3rdparty/phonon/mmf/defs.h b/src/3rdparty/phonon/mmf/defs.h index 1a93aa9..1ed8250 100644 --- a/src/3rdparty/phonon/mmf/defs.h +++ b/src/3rdparty/phonon/mmf/defs.h @@ -35,6 +35,15 @@ enum MediaType { MediaTypeAudio, MediaTypeVideo }; + +enum VideoParameter { + WindowHandle = 0x1, + WindowScreenRect = 0x2, + ScaleFactors = 0x4 +}; +Q_DECLARE_FLAGS(VideoParameters, VideoParameter) +Q_DECLARE_OPERATORS_FOR_FLAGS(VideoParameters) + } } diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 9744774..ee459e6 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -22,7 +22,13 @@ along with this library. If not, see <http://www.gnu.org/licenses/>. #include "dummyplayer.h" #include "utils.h" #include "utils.h" -#include "mmf_videoplayer.h" + +#ifdef PHONON_MMF_VIDEO_SURFACES +#include "videoplayer_surface.h" +#else +#include "videoplayer_dsa.h" +#endif + #include "videowidget.h" #include "mediaobject.h" @@ -293,7 +299,11 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) break; case MediaTypeVideo: - newPlayer = new VideoPlayer(this, oldPlayer); +#ifdef PHONON_MMF_VIDEO_SURFACES + newPlayer = SurfaceVideoPlayer::create(this, oldPlayer); +#else + newPlayer = DsaVideoPlayer::create(this, oldPlayer); +#endif break; } @@ -383,7 +393,7 @@ void MMF::MediaObject::disconnectMediaObject(MediaObject * /*mediaObject*/) // Video output //----------------------------------------------------------------------------- -void MMF::MediaObject::setVideoOutput(VideoOutput* videoOutput) +void MMF::MediaObject::setVideoOutput(AbstractVideoOutput* videoOutput) { m_player->setVideoOutput(videoOutput); } diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index d6248e2..62e0a0e 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -38,7 +38,7 @@ namespace Phonon namespace MMF { class AbstractPlayer; -class VideoOutput; +class AbstractVideoOutput; /** * @short Facade class which wraps MMF client utility instance @@ -85,7 +85,7 @@ public: */ AbstractPlayer *abstractPlayer() const; - void setVideoOutput(VideoOutput* videoOutput); + void setVideoOutput(AbstractVideoOutput* videoOutput); public Q_SLOTS: void volumeChanged(qreal volume); diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp deleted file mode 100644 index 127edb4..0000000 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp +++ /dev/null @@ -1,658 +0,0 @@ -/* This file is part of the KDE project. - -Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 2.1 or 3 of the License. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this library. If not, see <http://www.gnu.org/licenses/>. - -*/ - -#include <QApplication> // for QApplication::activeWindow -#include <QUrl> -#include <QTimer> -#include <QWidget> - -#include <coemain.h> // for CCoeEnv -#include <coecntrl.h> - -#include "mmf_videoplayer.h" -#include "utils.h" - -#ifndef QT_NO_DEBUG -#include "objectdump.h" -#endif - -QT_BEGIN_NAMESPACE - -using namespace Phonon; -using namespace Phonon::MMF; - -/*! \class MMF::VideoPlayer - \internal -*/ - -//----------------------------------------------------------------------------- -// Constructor / destructor -//----------------------------------------------------------------------------- - -MMF::VideoPlayer::VideoPlayer(MediaObject *parent, const AbstractPlayer *player) - : AbstractMediaPlayer(parent, player) - , m_wsSession(CCoeEnv::Static()->WsSession()) - , m_screenDevice(*CCoeEnv::Static()->ScreenDevice()) - , m_window(0) - , m_totalTime(0) - , m_pendingChanges(false) - , m_dsaActive(false) -{ - construct(); -} - -void MMF::VideoPlayer::construct() -{ - TRACE_CONTEXT(VideoPlayer::VideoPlayer, EVideoApi); - TRACE_ENTRY_0(); - - getVideoWindow(); - - const TInt priority = 0; - const TMdaPriorityPreference preference = EMdaPriorityPreferenceNone; - - CVideoPlayerUtility *player = 0; - QT_TRAP_THROWING(player = CVideoPlayerUtility::NewL - ( - *this, - priority, preference, - m_wsSession, m_screenDevice, - *m_window, - m_videoRect, m_videoRect - ) - ); - m_player.reset(player); - - // CVideoPlayerUtility::NewL starts DSA - m_dsaActive = true; - - m_player->RegisterForVideoLoadingNotification(*this); - - TRACE_EXIT_0(); -} - -MMF::VideoPlayer::~VideoPlayer() -{ - TRACE_CONTEXT(VideoPlayer::~VideoPlayer, EVideoApi); - TRACE_ENTRY_0(); - - // QObject destructor removes all signal-slot connections involving this - // object, so we do not need to disconnect from m_videoOutput here. - - TRACE_EXIT_0(); -} - -CVideoPlayerUtility* MMF::VideoPlayer::nativePlayer() const -{ - return m_player.data(); -} - -//----------------------------------------------------------------------------- -// Public API -//----------------------------------------------------------------------------- - -void MMF::VideoPlayer::doPlay() -{ - TRACE_CONTEXT(VideoPlayer::doPlay, EVideoApi); - - applyPendingChanges(); - - m_player->Play(); -} - -void MMF::VideoPlayer::doPause() -{ - TRACE_CONTEXT(VideoPlayer::doPause, EVideoApi); - - TRAPD(err, m_player->PauseL()); - if (KErrNone != err && state() != ErrorState) { - TRACE("PauseL error %d", err); - setError(tr("Pause failed"), err); - } -} - -void MMF::VideoPlayer::doStop() -{ - m_player->Stop(); -} - -void MMF::VideoPlayer::doSeek(qint64 ms) -{ - TRACE_CONTEXT(VideoPlayer::doSeek, EVideoApi); - - TRAPD(err, m_player->SetPositionL(TTimeIntervalMicroSeconds(ms * 1000))); - - if(KErrNone != err) - setError(tr("Seek failed"), err); -} - -int MMF::VideoPlayer::setDeviceVolume(int mmfVolume) -{ - TRAPD(err, m_player->SetVolumeL(mmfVolume)); - return err; -} - -int MMF::VideoPlayer::openFile(RFile& file) -{ - TRAPD(err, m_player->OpenFileL(file)); - return err; -} - -int MMF::VideoPlayer::openUrl(const QString& url) -{ - TRAPD(err, m_player->OpenUrlL(qt_QString2TPtrC(url))); - return err; -} - -int MMF::VideoPlayer::bufferStatus() const -{ - int result = 0; - TRAP_IGNORE(m_player->GetVideoLoadingProgressL(result)); - return result; -} - -void MMF::VideoPlayer::close() -{ - m_player->Close(); -} - -bool MMF::VideoPlayer::hasVideo() const -{ - return true; -} - -qint64 MMF::VideoPlayer::currentTime() const -{ - TRACE_CONTEXT(VideoPlayer::currentTime, EVideoApi); - - TTimeIntervalMicroSeconds us; - TRAPD(err, us = m_player->PositionL()) - - qint64 result = 0; - - if (KErrNone == err) { - result = toMilliSeconds(us); - } else { - TRACE("PositionL error %d", err); - - // If we don't cast away constness here, we simply have to ignore - // the error. - const_cast<VideoPlayer*>(this)->setError(tr("Getting position failed"), err); - } - - return result; -} - -qint64 MMF::VideoPlayer::totalTime() const -{ - return m_totalTime; -} - - -//----------------------------------------------------------------------------- -// MVideoPlayerUtilityObserver callbacks -//----------------------------------------------------------------------------- - -void MMF::VideoPlayer::MvpuoOpenComplete(TInt aError) -{ - TRACE_CONTEXT(VideoPlayer::MvpuoOpenComplete, EVideoApi); - TRACE_ENTRY("state %d error %d", state(), aError); - - __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); - - if (KErrNone == aError) - m_player->Prepare(); - else - setError(tr("Opening clip failed"), aError); - - TRACE_EXIT_0(); -} - -void MMF::VideoPlayer::MvpuoPrepareComplete(TInt aError) -{ - TRACE_CONTEXT(VideoPlayer::MvpuoPrepareComplete, EVideoApi); - TRACE_ENTRY("state %d error %d", state(), aError); - - __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); - - TRAPD(err, doPrepareCompleteL(aError)); - - if (KErrNone == err) { - maxVolumeChanged(m_player->MaxVolume()); - - if (m_videoOutput) - m_videoOutput->setVideoSize(m_videoFrameSize); - - updateVideoRect(); - applyPendingChanges(); - - emit totalTimeChanged(totalTime()); - changeState(StoppedState); - } else { - setError(tr("Buffering clip failed"), err); - } - - TRACE_EXIT_0(); -} - -void MMF::VideoPlayer::doPrepareCompleteL(TInt aError) -{ - User::LeaveIfError(aError); - - // Get frame size - TSize size; - m_player->VideoFrameSizeL(size); - m_videoFrameSize = QSize(size.iWidth, size.iHeight); - - // Get duration - m_totalTime = toMilliSeconds(m_player->DurationL()); -} - - -void MMF::VideoPlayer::MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError) -{ - TRACE_CONTEXT(VideoPlayer::MvpuoFrameReady, EVideoApi); - TRACE_ENTRY("state %d error %d", state(), aError); - - Q_UNUSED(aFrame); - Q_UNUSED(aError); // suppress warnings in release builds - - TRACE_EXIT_0(); -} - -void MMF::VideoPlayer::MvpuoPlayComplete(TInt aError) -{ - TRACE_CONTEXT(VideoPlayer::MvpuoPlayComplete, EVideoApi) - TRACE_ENTRY("state %d error %d", state(), aError); - - // Call base class function which handles end of playback for both - // audio and video clips. - playbackComplete(aError); - - TRACE_EXIT_0(); -} - -void MMF::VideoPlayer::MvpuoEvent(const TMMFEvent &aEvent) -{ - TRACE_CONTEXT(VideoPlayer::MvpuoEvent, EVideoApi); - TRACE_ENTRY("state %d", state()); - - Q_UNUSED(aEvent); - - TRACE_EXIT_0(); -} - - -//----------------------------------------------------------------------------- -// MVideoLoadingObserver callbacks -//----------------------------------------------------------------------------- - -void MMF::VideoPlayer::MvloLoadingStarted() -{ - bufferingStarted(); -} - -void MMF::VideoPlayer::MvloLoadingComplete() -{ - bufferingComplete(); -} - - -//----------------------------------------------------------------------------- -// Video window updates -//----------------------------------------------------------------------------- - -void MMF::VideoPlayer::getVideoWindow() -{ - TRACE_CONTEXT(VideoPlayer::getVideoWindow, EVideoInternal); - TRACE_ENTRY_0(); - - if(m_videoOutput) { - // Dump information to log, only in debug builds - m_videoOutput->dump(); - - initVideoOutput(); - videoWindowChanged(); - } else - // Top-level window - m_window = QApplication::activeWindow()->effectiveWinId()->DrawableWindow(); - - TRACE_EXIT_0(); -} - -void MMF::VideoPlayer::videoOutputChanged() -{ - TRACE_CONTEXT(VideoPlayer::videoOutputChanged, EVideoInternal); - TRACE_ENTRY_0(); - - if (m_videoOutput) { - initVideoOutput(); - videoWindowChanged(); - } - - TRACE_EXIT_0(); -} - -void MMF::VideoPlayer::initVideoOutput() -{ - m_videoOutput->winId(); - m_videoOutput->setVideoSize(m_videoFrameSize); - - bool connected = connect( - m_videoOutput, SIGNAL(videoWindowChanged()), - this, SLOT(videoWindowChanged()) - ); - Q_ASSERT(connected); - - connected = connect( - m_videoOutput, SIGNAL(beginVideoWindowNativePaint()), - this, SLOT(suspendDirectScreenAccess()) - ); - Q_ASSERT(connected); - - connected = connect( - m_videoOutput, SIGNAL(endVideoWindowNativePaint()), - this, SLOT(resumeDirectScreenAccess()) - ); - Q_ASSERT(connected); - - connected = connect( - m_videoOutput, SIGNAL(aspectRatioChanged()), - this, SLOT(aspectRatioChanged()) - ); - Q_ASSERT(connected); - - connected = connect( - m_videoOutput, SIGNAL(scaleModeChanged()), - this, SLOT(scaleModeChanged()) - ); - Q_ASSERT(connected); - - // Suppress warnings in release builds - Q_UNUSED(connected); -} - -void MMF::VideoPlayer::videoWindowChanged() -{ - TRACE_CONTEXT(VideoPlayer::videoOutputRegionChanged, EVideoInternal); - TRACE_ENTRY("state %d", state()); - - m_window = m_videoOutput->videoWindow(); - updateVideoRect(); - - TRACE_EXIT_0(); -} - -void MMF::VideoPlayer::suspendDirectScreenAccess() -{ - m_dsaWasActive = stopDirectScreenAccess(); -} - -void MMF::VideoPlayer::resumeDirectScreenAccess() -{ - if(m_dsaWasActive) { - startDirectScreenAccess(); - m_dsaWasActive = false; - } -} - -void MMF::VideoPlayer::startDirectScreenAccess() -{ - if(!m_dsaActive) { - TRAPD(err, m_player->StartDirectScreenAccessL()); - if(KErrNone == err) - m_dsaActive = true; - else - setError(tr("Video display error"), err); - } -} - -bool MMF::VideoPlayer::stopDirectScreenAccess() -{ - const bool dsaWasActive = m_dsaActive; - if(m_dsaActive) { - TRAPD(err, m_player->StopDirectScreenAccessL()); - if(KErrNone == err) - m_dsaActive = false; - else - setError(tr("Video display error"), err); - } - return dsaWasActive; -} - -// Helper function for aspect ratio / scale mode handling -QSize scaleToAspect(const QSize& srcRect, int aspectWidth, int aspectHeight) -{ - const qreal aspectRatio = qreal(aspectWidth) / aspectHeight; - - int width = srcRect.width(); - int height = srcRect.width() / aspectRatio; - if (height > srcRect.height()){ - height = srcRect.height(); - width = srcRect.height() * aspectRatio; - } - return QSize(width, height); -} - -void MMF::VideoPlayer::updateVideoRect() -{ - QRect videoRect; - QRect windowRect = m_videoOutput->videoWindowRect(); - - // Clip to physical window size - // This is due to a defect in the layout when running on S60 3.2, which - // results in the rectangle of the video widget extending outside the - // screen in certain circumstances. These include the initial startup - // of the mediaplayer demo in portrait mode. When this rectangle is - // passed to the CVideoPlayerUtility, no video is rendered. - const TSize screenSize = m_screenDevice.SizeInPixels(); - const QRect screenRect(0, 0, screenSize.iWidth, screenSize.iHeight); - windowRect = windowRect.intersected(screenRect); - - const QSize windowSize = windowRect.size(); - - // Calculate size of smallest rect which contains video frame size - // and conforms to aspect ratio - switch (m_videoOutput->aspectRatio()) { - case Phonon::VideoWidget::AspectRatioAuto: - videoRect.setSize(m_videoFrameSize); - break; - - case Phonon::VideoWidget::AspectRatioWidget: - videoRect.setSize(windowSize); - break; - - case Phonon::VideoWidget::AspectRatio4_3: - videoRect.setSize(scaleToAspect(m_videoFrameSize, 4, 3)); - break; - - case Phonon::VideoWidget::AspectRatio16_9: - videoRect.setSize(scaleToAspect(m_videoFrameSize, 16, 9)); - break; - } - - // Scale to fill the window width - const int windowWidth = windowSize.width(); - const int windowHeight = windowSize.height(); - const qreal windowScaleFactor = qreal(windowWidth) / videoRect.width(); - int videoWidth = windowWidth; - int videoHeight = videoRect.height() * windowScaleFactor; - - const qreal windowToVideoHeightRatio = qreal(windowHeight) / videoHeight; - - switch(m_videoOutput->scaleMode()) { - case Phonon::VideoWidget::ScaleAndCrop: - if(videoHeight < windowHeight) { - videoWidth *= windowToVideoHeightRatio; - videoHeight = windowHeight; - } - break; - case Phonon::VideoWidget::FitInView: - default: - if(videoHeight > windowHeight) { - videoWidth *= windowToVideoHeightRatio; - videoHeight = windowHeight; - } - break; - } - - // Calculate scale factors - m_scaleWidth = 100.0f * videoWidth / m_videoFrameSize.width(); - m_scaleHeight = 100.0f * videoHeight / m_videoFrameSize.height(); - - m_videoRect = qt_QRect2TRect(windowRect); - - if (state() == LoadingState) - m_pendingChanges = true; - else { - applyVideoWindowChange(); - m_pendingChanges = false; - } -} - -void MMF::VideoPlayer::aspectRatioChanged() -{ - TRACE_CONTEXT(VideoPlayer::aspectRatioChanged, EVideoInternal); - TRACE_ENTRY("state %d aspectRatio %d", state()); - - updateVideoRect(); - - TRACE_EXIT_0(); -} - -void MMF::VideoPlayer::scaleModeChanged() -{ - TRACE_CONTEXT(VideoPlayer::scaleModeChanged, EVideoInternal); - TRACE_ENTRY("state %d", state()); - - updateVideoRect(); - - TRACE_EXIT_0(); -} - -#ifndef QT_NO_DEBUG - -// The following code is for debugging problems related to video visibility. It allows -// the VideoPlayer instance to query the window server in order to determine the -// DSA drawing region for the video window. - -class CDummyAO : public CActive -{ -public: - CDummyAO() : CActive(CActive::EPriorityStandard) { CActiveScheduler::Add(this); } - void RunL() { } - void DoCancel() { } - TRequestStatus& Status() { return iStatus; } - void SetActive() { CActive::SetActive(); } -}; - -void getDsaRegion(RWsSession &session, const RWindowBase &window) -{ - RDirectScreenAccess dsa(session); - TInt err = dsa.Construct(); - CDummyAO ao; - RRegion* region; - err = dsa.Request(region, ao.Status(), window); - ao.SetActive(); - dsa.Close(); - ao.Cancel(); - if (region) { - qDebug() << "Phonon::MMF::getDsaRegion count" << region->Count(); - for (int i=0; i<region->Count(); ++i) { - const TRect& rect = region->RectangleList()[i]; - qDebug() << "Phonon::MMF::getDsaRegion rect" - << rect.iTl.iX << rect.iTl.iY << rect.iBr.iX << rect.iBr.iY; - } - region->Close(); - } -} - -#endif // _DEBUG - -void MMF::VideoPlayer::applyPendingChanges() -{ - if(m_pendingChanges) - applyVideoWindowChange(); - - m_pendingChanges = false; -} - -void MMF::VideoPlayer::applyVideoWindowChange() -{ - TRACE_CONTEXT(VideoPlayer::applyVideoWindowChange, EVideoInternal); - TRACE_ENTRY_0(); - -#ifndef QT_NO_DEBUG - getDsaRegion(m_wsSession, *m_window); -#endif - - static const TBool antialias = ETrue; - - TRAPD(err, m_player->SetScaleFactorL(m_scaleWidth, m_scaleHeight, antialias)); - if(KErrNone != err) { - TRACE("SetScaleFactorL (1) err %d", err); - setError(tr("Video display error"), err); - } - - if(KErrNone == err) { - TRAP(err, - m_player->SetDisplayWindowL - ( - m_wsSession, m_screenDevice, - *m_window, - m_videoRect, m_videoRect - ) - ); - - if (KErrNone != err) { - TRACE("SetDisplayWindowL err %d", err); - setError(tr("Video display error"), err); - } else { - m_dsaActive = true; - TRAP(err, m_player->SetScaleFactorL(m_scaleWidth, m_scaleHeight, antialias)); - if(KErrNone != err) { - TRACE("SetScaleFactorL (2) err %d", err); - setError(tr("Video display error"), err); - } - } - } - - TRACE_EXIT_0(); -} - - -//----------------------------------------------------------------------------- -// Metadata -//----------------------------------------------------------------------------- - -int MMF::VideoPlayer::numberOfMetaDataEntries() const -{ - int numberOfEntries = 0; - TRAP_IGNORE(numberOfEntries = m_player->NumberOfMetaDataEntriesL()); - return numberOfEntries; -} - -QPair<QString, QString> MMF::VideoPlayer::metaDataEntry(int index) const -{ - CMMFMetaDataEntry *entry = 0; - QT_TRAP_THROWING(entry = m_player->MetaDataEntryL(index)); - return QPair<QString, QString>(qt_TDesC2QString(entry->Name()), qt_TDesC2QString(entry->Value())); -} - -QT_END_NAMESPACE - diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.h b/src/3rdparty/phonon/mmf/mmf_videoplayer.h deleted file mode 100644 index 0253ab9..0000000 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.h +++ /dev/null @@ -1,138 +0,0 @@ -/* This file is part of the KDE project. - -Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 2.1 or 3 of the License. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this library. If not, see <http://www.gnu.org/licenses/>. - -*/ - -#ifndef PHONON_MMF_VIDEOPLAYER_H -#define PHONON_MMF_VIDEOPLAYER_H - -#include <videoplayer.h> // from epoc32/include - -#include "abstractmediaplayer.h" -#include "videooutput.h" - -QT_BEGIN_NAMESPACE - -namespace Phonon -{ -namespace MMF -{ -/** - * @short Wrapper over MMF video client utility - * - * See - * <a href="http://wiki.forum.nokia.com/index.php/How_to_play_a_video_file_using_CVideoPlayerUtility">How to - * play a video file using CVideoPlayerUtility</a> - */ -class VideoPlayer : public AbstractMediaPlayer - , public MVideoPlayerUtilityObserver - , public MVideoLoadingObserver -{ - Q_OBJECT - -public: - VideoPlayer(MediaObject *parent = 0, const AbstractPlayer *player = 0); - virtual ~VideoPlayer(); - - typedef CVideoPlayerUtility NativePlayer; - NativePlayer *nativePlayer() const; - - // AbstractPlayer - virtual void doPlay(); - virtual void doPause(); - virtual void doStop(); - virtual void doSeek(qint64 milliseconds); - virtual int setDeviceVolume(int mmfVolume); - virtual int openFile(RFile& file); - virtual int openUrl(const QString& url); - virtual int bufferStatus() const; - virtual void close(); - - // MediaObjectInterface - virtual bool hasVideo() const; - virtual qint64 currentTime() const; - virtual qint64 totalTime() const; - - // AbstractPlayer - virtual void videoOutputChanged(); - - // AbstractMediaPlayer - virtual int numberOfMetaDataEntries() const; - virtual QPair<QString, QString> metaDataEntry(int index) const; - -public Q_SLOTS: - void videoWindowChanged(); - void aspectRatioChanged(); - void scaleModeChanged(); - void suspendDirectScreenAccess(); - void resumeDirectScreenAccess(); - -private: - void construct(); - - void doPrepareCompleteL(TInt aError); - - void getVideoWindow(); - void initVideoOutput(); - void updateVideoRect(); - - void applyPendingChanges(); - void applyVideoWindowChange(); - - void startDirectScreenAccess(); - bool stopDirectScreenAccess(); - -private: - // MVideoPlayerUtilityObserver - virtual void MvpuoOpenComplete(TInt aError); - virtual void MvpuoPrepareComplete(TInt aError); - virtual void MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError); - virtual void MvpuoPlayComplete(TInt aError); - virtual void MvpuoEvent(const TMMFEvent &aEvent); - - // MVideoLoadingObserver - virtual void MvloLoadingStarted(); - virtual void MvloLoadingComplete(); - -private: - QScopedPointer<NativePlayer> m_player; - - // Not owned - RWsSession& m_wsSession; - CWsScreenDevice& m_screenDevice; - RWindowBase* m_window; - - /* Extent of the video display - will be clipped to m_windowRect */ - TRect m_videoRect; - - TReal32 m_scaleWidth; - TReal32 m_scaleHeight; - - QSize m_videoFrameSize; - qint64 m_totalTime; - - bool m_pendingChanges; - bool m_dsaActive; - bool m_dsaWasActive; - -}; - -} -} - -QT_END_NAMESPACE - -#endif diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp deleted file mode 100644 index 119dcb1..0000000 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ /dev/null @@ -1,303 +0,0 @@ -/* This file is part of the KDE project. - -Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 2.1 or 3 of the License. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this library. If not, see <http://www.gnu.org/licenses/>. - -*/ - -#include "ancestormovemonitor.h" -#include "utils.h" -#include "videooutput.h" - -#ifndef QT_NO_DEBUG -#include "objectdump.h" -#endif - -#include <QPaintEvent> -#include <QPainter> -#include <QMoveEvent> -#include <QResizeEvent> - -#include <QtCore/private/qcore_symbian_p.h> // for qt_TRect2QRect -#include <QtGui/private/qwidget_p.h> // to access QWExtra - -#include <coecntrl.h> - -#include <coemain.h> // for CCoeEnv - -QT_BEGIN_NAMESPACE - -using namespace Phonon; -using namespace Phonon::MMF; - -/*! \class MMF::VideoOutput - \internal -*/ - -//----------------------------------------------------------------------------- -// Constants -//----------------------------------------------------------------------------- - -static const Phonon::VideoWidget::AspectRatio DefaultAspectRatio = - Phonon::VideoWidget::AspectRatioAuto; -static const Phonon::VideoWidget::ScaleMode DefaultScaleMode = - Phonon::VideoWidget::FitInView; - - -//----------------------------------------------------------------------------- -// Constructor / destructor -//----------------------------------------------------------------------------- - -MMF::VideoOutput::VideoOutput - (AncestorMoveMonitor* ancestorMoveMonitor, QWidget* parent) - : QWidget(parent) - , m_ancestorMoveMonitor(ancestorMoveMonitor) - , m_aspectRatio(DefaultAspectRatio) - , m_scaleMode(DefaultScaleMode) -{ - TRACE_CONTEXT(VideoOutput::VideoOutput, EVideoInternal); - TRACE_ENTRY("parent 0x%08x", parent); - - setPalette(QPalette(Qt::black)); - setAttribute(Qt::WA_OpaquePaintEvent, true); - setAttribute(Qt::WA_NoSystemBackground, true); - setAutoFillBackground(false); - - qt_widget_private(this)->extraData()->nativePaintMode = QWExtra::ZeroFill; - qt_widget_private(this)->extraData()->receiveNativePaintEvents = true; - - getVideoWindowRect(); - registerForAncestorMoved(); - - dump(); - - TRACE_EXIT_0(); -} - -MMF::VideoOutput::~VideoOutput() -{ - TRACE_CONTEXT(VideoOutput::~VideoOutput, EVideoInternal); - TRACE_ENTRY_0(); - - m_ancestorMoveMonitor->unRegisterTarget(this); - - TRACE_EXIT_0(); -} - -void MMF::VideoOutput::setVideoSize(const QSize& frameSize) -{ - TRACE_CONTEXT(VideoOutput::setVideoSize, EVideoInternal); - TRACE("oldSize %d %d newSize %d %d", - m_videoFrameSize.width(), m_videoFrameSize.height(), - frameSize.width(), frameSize.height()); - - if (frameSize != m_videoFrameSize) { - m_videoFrameSize = frameSize; - updateGeometry(); - } -} - -void MMF::VideoOutput::ancestorMoved() -{ - TRACE_CONTEXT(VideoOutput::ancestorMoved, EVideoInternal); - TRACE_ENTRY_0(); - - RWindowBase *const window = videoWindow(); - - if(window) { - const TPoint newWindowPosSymbian = window->AbsPosition(); - const QPoint newWindowPos(newWindowPosSymbian.iX, newWindowPosSymbian.iY); - - if(newWindowPos != m_videoWindowRect.topLeft()) { - m_videoWindowRect.moveTo(newWindowPos); - emit videoWindowChanged(); - } - } - - TRACE_EXIT_0(); -} - -//----------------------------------------------------------------------------- -// QWidget -//----------------------------------------------------------------------------- - -QSize MMF::VideoOutput::sizeHint() const -{ - // TODO: replace this with a more sensible default - QSize result(320, 240); - - if (!m_videoFrameSize.isNull()) - result = m_videoFrameSize; - - return result; -} - -void MMF::VideoOutput::paintEvent(QPaintEvent* event) -{ - TRACE_CONTEXT(VideoOutput::paintEvent, EVideoInternal); - TRACE("rect %d %d - %d %d", - event->rect().left(), event->rect().top(), - event->rect().right(), event->rect().bottom()); - TRACE("regions %d", event->region().rectCount()); - TRACE("type %d", event->type()); - - // Do nothing -} - -void MMF::VideoOutput::resizeEvent(QResizeEvent* event) -{ - TRACE_CONTEXT(VideoOutput::resizeEvent, EVideoInternal); - TRACE("%d %d -> %d %d", - event->oldSize().width(), event->oldSize().height(), - event->size().width(), event->size().height()); - - if(event->size() != event->oldSize()) { - m_videoWindowRect.setSize(event->size()); - emit videoWindowChanged(); - } -} - -void MMF::VideoOutput::moveEvent(QMoveEvent* event) -{ - TRACE_CONTEXT(VideoOutput::moveEvent, EVideoInternal); - TRACE("%d %d -> %d %d", - event->oldPos().x(), event->oldPos().y(), - event->pos().x(), event->pos().y()); - - if(event->pos() != event->oldPos()) { - m_videoWindowRect.moveTo(event->pos()); - emit videoWindowChanged(); - } -} - -bool MMF::VideoOutput::event(QEvent* event) -{ - TRACE_CONTEXT(VideoOutput::event, EVideoInternal); - - if (event->type() == QEvent::WinIdChange) { - TRACE_0("WinIdChange"); - getVideoWindowRect(); - emit videoWindowChanged(); - return true; - } else if (event->type() == QEvent::ParentChange) { - // Tell ancestor move monitor to update ancestor list for this widget - registerForAncestorMoved(); - return true; - } else - return QWidget::event(event); -} - - -//----------------------------------------------------------------------------- -// Public functions -//----------------------------------------------------------------------------- - -RWindowBase* MMF::VideoOutput::videoWindow() -{ - CCoeControl *control = internalWinId(); - if(!control) - control = effectiveWinId(); - - RWindowBase *window = 0; - if(control) - window = control->DrawableWindow(); - - return window; -} - -const QRect& MMF::VideoOutput::videoWindowRect() const -{ - return m_videoWindowRect; -} - -Phonon::VideoWidget::AspectRatio MMF::VideoOutput::aspectRatio() const -{ - return m_aspectRatio; -} - -void MMF::VideoOutput::setAspectRatio - (Phonon::VideoWidget::AspectRatio aspectRatio) -{ - if(m_aspectRatio != aspectRatio) { - m_aspectRatio = aspectRatio; - emit aspectRatioChanged(); - } -} - -Phonon::VideoWidget::ScaleMode MMF::VideoOutput::scaleMode() const -{ - return m_scaleMode; -} - -void MMF::VideoOutput::setScaleMode - (Phonon::VideoWidget::ScaleMode scaleMode) -{ - if(m_scaleMode != scaleMode) { - m_scaleMode = scaleMode; - emit scaleModeChanged(); - } -} - - -//----------------------------------------------------------------------------- -// Private functions -//----------------------------------------------------------------------------- - -void MMF::VideoOutput::getVideoWindowRect() -{ - RWindowBase *const window = videoWindow(); - if(window) - m_videoWindowRect = - qt_TRect2QRect(TRect(window->AbsPosition(), window->Size())); -} - -void MMF::VideoOutput::registerForAncestorMoved() -{ - m_ancestorMoveMonitor->registerTarget(this); -} - -void MMF::VideoOutput::dump() const -{ -#ifndef QT_NO_DEBUG - TRACE_CONTEXT(VideoOutput::dump, EVideoInternal); - - QScopedPointer<ObjectDump::QVisitor> visitor(new ObjectDump::QVisitor); - visitor->setPrefix("Phonon::MMF"); // to aid searchability of logs - ObjectDump::addDefaultAnnotators(*visitor); - TRACE("Dumping tree from leaf 0x%08x:", this); - ObjectDump::dumpTreeFromLeaf(*this, *visitor); - - QScopedPointer<ObjectDump::QDumper> dumper(new ObjectDump::QDumper); - dumper->setPrefix("Phonon::MMF"); // to aid searchability of logs - ObjectDump::addDefaultAnnotators(*dumper); - TRACE_0("Dumping VideoOutput:"); - dumper->dumpObject(*this); -#endif -} - -void MMF::VideoOutput::beginNativePaintEvent(const QRect& /*controlRect*/) -{ - emit beginVideoWindowNativePaint(); -} - -void MMF::VideoOutput::endNativePaintEvent(const QRect& /*controlRect*/) -{ - // Ensure that draw ops are executed into the WSERV output framebuffer - CCoeEnv::Static()->WsSession().Flush(); - - emit endVideoWindowNativePaint(); -} - -QT_END_NAMESPACE - diff --git a/src/3rdparty/phonon/mmf/videooutput_dsa.cpp b/src/3rdparty/phonon/mmf/videooutput_dsa.cpp new file mode 100644 index 0000000..a5e2ac8 --- /dev/null +++ b/src/3rdparty/phonon/mmf/videooutput_dsa.cpp @@ -0,0 +1,177 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#include <QtCore/private/qcore_symbian_p.h> // for qt_TRect2QRect +#include <QtGui/private/qwidget_p.h> // to access QWExtra +#include <QResizeEvent> +#include <QMoveEvent> + +#include <coemain.h> // for CCoeEnv + +#include "ancestormovemonitor.h" +#include "utils.h" +#include "videooutput_dsa.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +DsaVideoOutput::DsaVideoOutput(QWidget *parent) + : AbstractVideoOutput(parent) + , m_ancestorMoveMonitor(0) +{ + TRACE_CONTEXT(DsaVideoOutput::DsaVideoOutput, EVideoInternal); + TRACE_ENTRY("parent 0x%08x", parent); + + setPalette(QPalette(Qt::black)); + setAttribute(Qt::WA_OpaquePaintEvent, true); + setAttribute(Qt::WA_NoSystemBackground, true); + setAutoFillBackground(false); + + qt_widget_private(this)->extraData()->nativePaintMode = QWExtra::ZeroFill; + qt_widget_private(this)->extraData()->receiveNativePaintEvents = true; + + getVideoWindowScreenRect(); + + dump(); + + TRACE_EXIT_0(); +} + +DsaVideoOutput::~DsaVideoOutput() +{ + TRACE_CONTEXT(DsaVideoOutput::~DsaVideoOutput, EVideoInternal); + TRACE_ENTRY_0(); + + m_ancestorMoveMonitor->unRegisterTarget(this); + + TRACE_EXIT_0(); +} + +//----------------------------------------------------------------------------- +// Public functions +//----------------------------------------------------------------------------- + +void MMF::DsaVideoOutput::setAncestorMoveMonitor(AncestorMoveMonitor *monitor) +{ + m_ancestorMoveMonitor = monitor; + registerForAncestorMoved(); +} + +const QRect& MMF::DsaVideoOutput::videoWindowScreenRect() const +{ + return m_videoWindowScreenRect; +} + +void MMF::DsaVideoOutput::ancestorMoved() +{ + TRACE_CONTEXT(DsaVideoOutput::ancestorMoved, EVideoInternal); + TRACE_ENTRY_0(); + + RWindowBase *const window = videoWindow(); + + if (window) { + const TPoint newWindowPosSymbian = window->AbsPosition(); + const QPoint newWindowPos(newWindowPosSymbian.iX, newWindowPosSymbian.iY); + + if (newWindowPos != m_videoWindowScreenRect.topLeft()) { + m_videoWindowScreenRect.moveTo(newWindowPos); + emit videoWindowScreenRectChanged(); + } + } + + TRACE_EXIT_0(); +} + +void MMF::DsaVideoOutput::beginNativePaintEvent(const QRect & /*controlRect*/) +{ + emit beginVideoWindowNativePaint(); +} + +void MMF::DsaVideoOutput::endNativePaintEvent(const QRect & /*controlRect*/) +{ + // Ensure that draw ops are executed into the WSERV output framebuffer + CCoeEnv::Static()->WsSession().Flush(); + + emit endVideoWindowNativePaint(); +} + +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- + +void MMF::DsaVideoOutput::getVideoWindowScreenRect() +{ + RWindowBase *const window = videoWindow(); + if (window) + m_videoWindowScreenRect = + qt_TRect2QRect(TRect(window->AbsPosition(), window->Size())); +} + +void MMF::DsaVideoOutput::registerForAncestorMoved() +{ + m_ancestorMoveMonitor->registerTarget(this); +} + +void MMF::DsaVideoOutput::resizeEvent(QResizeEvent *event) +{ + TRACE_CONTEXT(DsaVideoOutput::resizeEvent, EVideoInternal); + TRACE("%d %d -> %d %d", + event->oldSize().width(), event->oldSize().height(), + event->size().width(), event->size().height()); + + if (event->size() != event->oldSize()) { + m_videoWindowScreenRect.setSize(event->size()); + emit videoWindowScreenRectChanged(); + } +} + +void MMF::DsaVideoOutput::moveEvent(QMoveEvent *event) +{ + TRACE_CONTEXT(DsaVideoOutput::moveEvent, EVideoInternal); + TRACE("%d %d -> %d %d", + event->oldPos().x(), event->oldPos().y(), + event->pos().x(), event->pos().y()); + + if (event->pos() != event->oldPos()) { + m_videoWindowScreenRect.moveTo(event->pos()); + emit videoWindowScreenRectChanged(); + } +} + +bool MMF::DsaVideoOutput::event(QEvent *event) +{ + TRACE_CONTEXT(DsaVideoOutput::event, EVideoInternal); + + if (event->type() == QEvent::WinIdChange) { + TRACE_0("WinIdChange"); + getVideoWindowScreenRect(); + emit videoWindowChanged(); + return true; + } else if (event->type() == QEvent::ParentChange) { + // Tell ancestor move monitor to update ancestor list for this widget + registerForAncestorMoved(); + return true; + } else { + return QWidget::event(event); + } +} + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/videooutput_dsa.h b/src/3rdparty/phonon/mmf/videooutput_dsa.h new file mode 100644 index 0000000..c37dad8 --- /dev/null +++ b/src/3rdparty/phonon/mmf/videooutput_dsa.h @@ -0,0 +1,109 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_VIDEOOUTPUT_DSA_H +#define PHONON_MMF_VIDEOOUTPUT_DSA_H + +#include <QRect> + +#include "phonon/mmf/abstractvideooutput.h" + +QT_BEGIN_NAMESPACE + +class QResizeEvent; +class QMoveEvent; + +namespace Phonon +{ +namespace MMF +{ +class AncestorMoveMonitor; + +/** + * @short Widget on which video is displayed by DSA rendering + * + * This implementation is used on devices with the legacy graphics + * subsystem, which does not support surfaces. On such devices, + * video rendering is done via Direct Screen Access (DSA), whereby + * the video decoder writes directly to the framebuffer. To ensure + * that the window server and video decoder do not try to draw to + * the same screen region at the same time, the video subsystem + * first requests permission to perform DSA. If the window server + * needs to draw to this screen region (for example to display a + * message dialog), it first notifies the video subsystem that it + * must stop rendering to this region. + * + * @see SurfaceVideoOutput + */ +class DsaVideoOutput + : public AbstractVideoOutput +{ + Q_OBJECT + +public: + DsaVideoOutput(QWidget *parent); + ~DsaVideoOutput(); + + void setAncestorMoveMonitor(AncestorMoveMonitor *monitor); + + // Get absolute screen rectangle for video window + const QRect& videoWindowScreenRect() const; + + // Called by AncestorMoveMonitor + void ancestorMoved(); + +public Q_SLOTS: + // Callbacks received from Symbian QtGui implementation, when it + // begins / ends blitting the video widget's backing store to the + // window server. + void beginNativePaintEvent(const QRect & /*controlRect*/); + void endNativePaintEvent(const QRect & /*controlRect*/); + +Q_SIGNALS: + void videoWindowScreenRectChanged(); + + // Emitted when the Symbian QtGui implementation begins / ends + // blitting the video widget's backing store to the window server. + void beginVideoWindowNativePaint(); + void endVideoWindowNativePaint(); + +private: + void getVideoWindowScreenRect(); + void registerForAncestorMoved(); + + // QWidget + void resizeEvent(QResizeEvent *event); + void moveEvent(QMoveEvent *event); + bool event(QEvent *event); + +private: + // Not owned + AncestorMoveMonitor* m_ancestorMoveMonitor; + + // Absolute screen rectangle on which video is displayed + QRect m_videoWindowScreenRect; + +}; + +} +} + +QT_END_NAMESPACE + +#endif // !PHONON_MMF_VIDEOOUTPUT_DSA_H + diff --git a/src/3rdparty/phonon/mmf/videooutput_surface.cpp b/src/3rdparty/phonon/mmf/videooutput_surface.cpp new file mode 100644 index 0000000..e9b2d3f --- /dev/null +++ b/src/3rdparty/phonon/mmf/videooutput_surface.cpp @@ -0,0 +1,87 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#include <QResizeEvent> + +#include <QtCore/private/qcore_symbian_p.h> // for qt_TRect2QRect +#include <QtGui/private/qwidget_p.h> // to access QWExtra + +#include "utils.h" +#include "videooutput_surface.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +SurfaceVideoOutput::SurfaceVideoOutput(QWidget *parent) + : AbstractVideoOutput(parent) +{ + TRACE_CONTEXT(SurfaceVideoOutput::SurfaceVideoOutput, EVideoInternal); + TRACE_ENTRY("parent 0x%08x", parent); + + qt_widget_private(this)->createExtra(); + qt_widget_private(this)->extraData()->nativePaintMode = QWExtra::Disable; + + TRACE_EXIT_0(); +} + +SurfaceVideoOutput::~SurfaceVideoOutput() +{ + TRACE_CONTEXT(SurfaceVideoOutput::~SurfaceVideoOutput, EVideoInternal); + TRACE_ENTRY_0(); + + TRACE_EXIT_0(); +} + +//----------------------------------------------------------------------------- +// Public functions +//----------------------------------------------------------------------------- + + +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- + +void MMF::SurfaceVideoOutput::resizeEvent(QResizeEvent *event) +{ + TRACE_CONTEXT(SurfaceVideoOutput::resizeEvent, EVideoInternal); + TRACE("%d %d -> %d %d", + event->oldSize().width(), event->oldSize().height(), + event->size().width(), event->size().height()); + + if (event->size() != event->oldSize()) + emit videoWindowSizeChanged(); +} + +bool MMF::SurfaceVideoOutput::event(QEvent *event) +{ + TRACE_CONTEXT(SurfaceVideoOutput::event, EVideoInternal); + + if (event->type() == QEvent::WinIdChange) { + TRACE_0("WinIdChange"); + emit videoWindowChanged(); + return true; + } else { + return QWidget::event(event); + } +} + + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/videooutput_surface.h b/src/3rdparty/phonon/mmf/videooutput_surface.h new file mode 100644 index 0000000..0b22a710 --- /dev/null +++ b/src/3rdparty/phonon/mmf/videooutput_surface.h @@ -0,0 +1,66 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_VIDEOOUTPUT_SURFACE_H +#define PHONON_MMF_VIDEOOUTPUT_SURFACE_H + +#include "phonon/mmf/abstractvideooutput.h" + +QT_BEGIN_NAMESPACE + +class QResizeEvent; + +namespace Phonon +{ +namespace MMF +{ + +/** + * @short Widget on which video is displayed by rendering to a surface + * + * This implementation is used on devices with a graphics subsystem which + * supports surfaces. + * + * @see DsaVideoOutput + */ +class SurfaceVideoOutput + : public AbstractVideoOutput +{ + Q_OBJECT + +public: + SurfaceVideoOutput(QWidget *parent); + ~SurfaceVideoOutput(); + +Q_SIGNALS: + void videoWindowSizeChanged(); + +private: + // QWidget + void resizeEvent(QResizeEvent *event); + bool event(QEvent *event); + +}; + +} +} + +QT_END_NAMESPACE + +#endif // !PHONON_MMF_VIDEOOUTPUT_SURFACE_H + diff --git a/src/3rdparty/phonon/mmf/videoplayer_dsa.cpp b/src/3rdparty/phonon/mmf/videoplayer_dsa.cpp new file mode 100644 index 0000000..21cdb16 --- /dev/null +++ b/src/3rdparty/phonon/mmf/videoplayer_dsa.cpp @@ -0,0 +1,285 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#include <coecntrl.h> // for CCoeControl + +#include <QApplication> // for QApplication::activeWindow +#include <QtCore/private/qcore_symbian_p.h> // for qt_TRect2QRect + +#include "utils.h" +#include "videooutput_dsa.h" +#include "videoplayer_dsa.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +// Two-phase constructor idiom is used because construct() calls virtual +// functions and therefore cannot be called from the AbstractVideoPlayer +// C++ constructor. +DsaVideoPlayer* DsaVideoPlayer::create(MediaObject *parent, + const AbstractPlayer *player) +{ + QScopedPointer<DsaVideoPlayer> self(new DsaVideoPlayer(parent, player)); + self->construct(); + return self.take(); +} + +DsaVideoPlayer::DsaVideoPlayer(MediaObject *parent, const AbstractPlayer *player) + : AbstractVideoPlayer(parent, player) + , m_dsaActive(false) + , m_dsaWasActive(false) +{ + +} + +DsaVideoPlayer::~DsaVideoPlayer() +{ + +} + + +//----------------------------------------------------------------------------- +// Public functions +//----------------------------------------------------------------------------- + +void MMF::DsaVideoPlayer::videoWindowScreenRectChanged() +{ + QRect windowRect = static_cast<DsaVideoOutput *>(m_videoOutput)->videoWindowScreenRect(); + + // Clip to physical window size + // This is due to a defect in the layout when running on S60 3.2, which + // results in the rectangle of the video widget extending outside the + // screen in certain circumstances. These include the initial startup + // of the mediaplayer demo in portrait mode. When this rectangle is + // passed to the CVideoPlayerUtility, no video is rendered. + const TSize screenSize = m_screenDevice.SizeInPixels(); + const QRect screenRect(0, 0, screenSize.iWidth, screenSize.iHeight); + windowRect = windowRect.intersected(screenRect); + + // Recalculate scale factors. Pass 'false' as second parameter in order to + // suppress application of the change to the player - this is done at the end + // of the function. + updateScaleFactors(windowRect.size(), false); + + m_videoScreenRect = qt_QRect2TRect(windowRect); + + parametersChanged(WindowScreenRect | ScaleFactors); +} + +void MMF::DsaVideoPlayer::suspendDirectScreenAccess() +{ + m_dsaWasActive = stopDirectScreenAccess(); +} + +void MMF::DsaVideoPlayer::resumeDirectScreenAccess() +{ + if (m_dsaWasActive) { + startDirectScreenAccess(); + m_dsaWasActive = false; + } +} + + +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- + +void MMF::DsaVideoPlayer::createPlayer() +{ + // A window handle must be provided in order to construct + // CVideoPlayerUtility. If no VideoOutput has yet been connected to this + // player, we temporarily use the top-level application window handle. + // No video ever gets rendered into this window; SetDisplayWindowL is + // always called before rendering actually begins. + if (!m_window) + m_window = QApplication::activeWindow()->effectiveWinId()->DrawableWindow(); + + const TInt priority = 0; + const TMdaPriorityPreference preference = EMdaPriorityPreferenceNone; + + CVideoPlayerUtility *player = 0; + QT_TRAP_THROWING(player = CVideoPlayerUtility::NewL(*this, + priority, preference, + m_wsSession, m_screenDevice, + *m_window, + m_videoScreenRect, m_videoScreenRect)); + m_player.reset(player); + + // CVideoPlayerUtility::NewL starts DSA + m_dsaActive = true; + + m_player->RegisterForVideoLoadingNotification(*this); +} + +void MMF::DsaVideoPlayer::initVideoOutput() +{ + bool connected = connect( + m_videoOutput, SIGNAL(videoWindowScreenRectChanged()), + this, SLOT(videoWindowScreenRectChanged()) + ); + Q_ASSERT(connected); + + connected = connect( + m_videoOutput, SIGNAL(beginVideoWindowNativePaint()), + this, SLOT(suspendDirectScreenAccess()) + ); + Q_ASSERT(connected); + + connected = connect( + m_videoOutput, SIGNAL(endVideoWindowNativePaint()), + this, SLOT(resumeDirectScreenAccess()) + ); + Q_ASSERT(connected); + + // Suppress warnings in release builds + Q_UNUSED(connected); + + AbstractVideoPlayer::initVideoOutput(); +} + +void MMF::DsaVideoPlayer::prepareCompleted() +{ + videoWindowScreenRectChanged(); +} + +void MMF::DsaVideoPlayer::handleVideoWindowChanged() +{ + if (!m_window) { + m_window = QApplication::activeWindow()->effectiveWinId()->DrawableWindow(); + m_videoScreenRect = TRect(); + } + + parametersChanged(WindowHandle | WindowScreenRect); +} + +#ifndef QT_NO_DEBUG + +// The following code is for debugging problems related to video visibility. It allows +// the VideoPlayer instance to query the window server in order to determine the +// DSA drawing region for the video window. + +class CDummyAO : public CActive +{ +public: + CDummyAO() : CActive(CActive::EPriorityStandard) { CActiveScheduler::Add(this); } + void RunL() { } + void DoCancel() { } + TRequestStatus& Status() { return iStatus; } + void SetActive() { CActive::SetActive(); } +}; + +void getDsaRegion(RWsSession &session, const RWindowBase &window) +{ + RDirectScreenAccess dsa(session); + TInt err = dsa.Construct(); + CDummyAO ao; + RRegion* region; + err = dsa.Request(region, ao.Status(), window); + ao.SetActive(); + dsa.Close(); + ao.Cancel(); + if (region) { + qDebug() << "Phonon::MMF::getDsaRegion count" << region->Count(); + for (int i=0; i<region->Count(); ++i) { + const TRect& rect = region->RectangleList()[i]; + qDebug() << "Phonon::MMF::getDsaRegion rect" + << rect.iTl.iX << rect.iTl.iY << rect.iBr.iX << rect.iBr.iY; + } + region->Close(); + } +} + +#endif // QT_NO_DEBUG + +void MMF::DsaVideoPlayer::handleParametersChanged(VideoParameters parameters) +{ + TRACE_CONTEXT(DsaVideoPlayer::handleParametersChanged, EVideoInternal); + TRACE_ENTRY_0(); + +#ifndef QT_NO_DEBUG + getDsaRegion(m_wsSession, *m_window); +#endif + + static const TBool antialias = ETrue; + int err = KErrNone; + + if (parameters & ScaleFactors) { + TRAP(err, m_player->SetScaleFactorL(m_scaleWidth, m_scaleHeight, + antialias)); + if(KErrNone != err) { + TRACE("SetScaleFactorL (1) err %d", err); + setError(tr("Video display error"), err); + } + } + + if (KErrNone == err) { + if (parameters & WindowHandle || parameters & WindowScreenRect) { + TRAP(err, + m_player->SetDisplayWindowL(m_wsSession, m_screenDevice, + *m_window, + m_videoScreenRect, + m_videoScreenRect)); + } + + if (KErrNone != err) { + TRACE("SetDisplayWindowL err %d", err); + setError(tr("Video display error"), err); + } else { + m_dsaActive = true; + if (parameters & ScaleFactors) { + TRAP(err, m_player->SetScaleFactorL(m_scaleWidth, m_scaleHeight, + antialias)); + if (KErrNone != err) { + TRACE("SetScaleFactorL (2) err %d", err); + setError(tr("Video display error"), err); + } + } + } + } + + TRACE_EXIT_0(); +} + +void MMF::DsaVideoPlayer::startDirectScreenAccess() +{ + if (!m_dsaActive) { + TRAPD(err, m_player->StartDirectScreenAccessL()); + if (KErrNone == err) + m_dsaActive = true; + else + setError(tr("Video display error"), err); + } +} + +bool MMF::DsaVideoPlayer::stopDirectScreenAccess() +{ + const bool dsaWasActive = m_dsaActive; + if (m_dsaActive) { + TRAPD(err, m_player->StopDirectScreenAccessL()); + if (KErrNone == err) + m_dsaActive = false; + else + setError(tr("Video display error"), err); + } + return dsaWasActive; +} + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/videoplayer_dsa.h b/src/3rdparty/phonon/mmf/videoplayer_dsa.h new file mode 100644 index 0000000..45cc47d --- /dev/null +++ b/src/3rdparty/phonon/mmf/videoplayer_dsa.h @@ -0,0 +1,92 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_VIDEOPLAYER_DSA_H +#define PHONON_MMF_VIDEOPLAYER_DSA_H + +#include "abstractvideoplayer.h" + +QT_BEGIN_NAMESPACE + +namespace Phonon +{ +namespace MMF +{ + +/** + * @short Wrapper over the MMF video player utility (DSA version) + * + * This implementation is used on devices with the legacy graphics + * subsystem, which does not support surfaces. On such devices, + * video rendering is done via Direct Screen Access (DSA), whereby + * the video decoder writes directly to the framebuffer. To ensure + * that the window server and video decoder do not try to draw to + * the same screen region at the same time, the video subsystem + * first requests permission to perform DSA. If the window server + * needs to draw to this screen region (for example to display a + * message dialog), it first notifies the video subsystem that it + * must stop rendering to this region. + * + * @see SurfaceVideoPlayer + */ +class DsaVideoPlayer + : public AbstractVideoPlayer +{ + Q_OBJECT + +public: + // Factory function + static DsaVideoPlayer* create(MediaObject *parent = 0, + const AbstractPlayer *player = 0); + ~DsaVideoPlayer(); + +public Q_SLOTS: + void videoWindowScreenRectChanged(); + void suspendDirectScreenAccess(); + void resumeDirectScreenAccess(); + +private: + DsaVideoPlayer(MediaObject *parent, const AbstractPlayer *player); + + // AbstractVideoPlayer + void createPlayer(); + void initVideoOutput(); + void prepareCompleted(); + void handleVideoWindowChanged(); + void handleParametersChanged(VideoParameters parameters); + + void startDirectScreenAccess(); + bool stopDirectScreenAccess(); + +private: + bool m_dsaActive; + bool m_dsaWasActive; + + // Absolute screen rectangle on which video is displayed + TRect m_videoScreenRect; + +}; + +} +} + +QT_END_NAMESPACE + +#endif // !PHONON_MMF_VIDEOPLAYER_DSA_H + + diff --git a/src/3rdparty/phonon/mmf/videoplayer_surface.cpp b/src/3rdparty/phonon/mmf/videoplayer_surface.cpp new file mode 100644 index 0000000..5f234e5 --- /dev/null +++ b/src/3rdparty/phonon/mmf/videoplayer_surface.cpp @@ -0,0 +1,150 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#include <videoplayer2.h> + +#include <QtCore/private/qcore_symbian_p.h> // for qt_QRect2TRect + +#include "utils.h" +#include "videooutput_surface.h" +#include "videoplayer_surface.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +// Two-phase constructor idiom is used because construct() calls virtual +// functions and therefore cannot be called from the AbstractVideoPlayer +// C++ constructor. +SurfaceVideoPlayer* SurfaceVideoPlayer::create(MediaObject *parent, + const AbstractPlayer *player) +{ + QScopedPointer<SurfaceVideoPlayer> self(new SurfaceVideoPlayer(parent, player)); + self->construct(); + return self.take(); +} + +SurfaceVideoPlayer::SurfaceVideoPlayer(MediaObject *parent, const AbstractPlayer *player) + : AbstractVideoPlayer(parent, player) + , m_displayWindow(0) +{ + +} + +SurfaceVideoPlayer::~SurfaceVideoPlayer() +{ + +} + + +//----------------------------------------------------------------------------- +// Public functions +//----------------------------------------------------------------------------- + +void MMF::SurfaceVideoPlayer::videoWindowSizeChanged() +{ + updateScaleFactors(m_videoOutput->videoWindowSize()); +} + + +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- + +void MMF::SurfaceVideoPlayer::createPlayer() +{ + const TInt priority = 0; + const TMdaPriorityPreference preference = EMdaPriorityPreferenceNone; + + CVideoPlayerUtility2 *player = 0; + QT_TRAP_THROWING(player = CVideoPlayerUtility2::NewL(*this, + priority, preference)); + m_player.reset(player); +} + +void MMF::SurfaceVideoPlayer::initVideoOutput() +{ + bool connected = connect( + m_videoOutput, SIGNAL(videoWindowSizeChanged()), + this, SLOT(videoWindowSizeChanged()) + ); + Q_ASSERT(connected); + + // Suppress warnings in release builds + Q_UNUSED(connected); + + AbstractVideoPlayer::initVideoOutput(); +} + +void MMF::SurfaceVideoPlayer::prepareCompleted() +{ + videoWindowSizeChanged(); +} + +void MMF::SurfaceVideoPlayer::handleVideoWindowChanged() +{ + parametersChanged(WindowHandle); +} + +void MMF::SurfaceVideoPlayer::handleParametersChanged(VideoParameters parameters) +{ + CVideoPlayerUtility2 *player = static_cast<CVideoPlayerUtility2 *>(m_player.data()); + + int err = KErrNone; + + TRect rect; + + if (m_videoOutput) { + m_videoOutput->dump(); + const QSize size = m_videoOutput->videoWindowSize(); + rect.SetSize(TSize(size.width(), size.height())); + } + + if (parameters & WindowHandle) { + if (m_displayWindow) + player->RemoveDisplayWindow(*m_displayWindow); + + RWindow *window = static_cast<RWindow *>(m_window); + if (window) { + window->SetBackgroundColor(TRgb(0, 0, 0, 255)); + TRAP(err, player->AddDisplayWindowL(m_wsSession, m_screenDevice, *window, rect, rect)); + if (KErrNone != err) { + setError(tr("Video display error"), err); + window = 0; + } + } + m_displayWindow = window; + } + + if (KErrNone == err) { + if (parameters & ScaleFactors) { + Q_ASSERT(m_displayWindow); + TRAP(err, player->SetVideoExtentL(*m_displayWindow, rect)); + if (KErrNone == err) + TRAP(err, player->SetWindowClipRectL(*m_displayWindow, rect)); + if (KErrNone == err) + TRAP(err, player->SetScaleFactorL(*m_displayWindow, m_scaleWidth, m_scaleHeight)); + if (KErrNone != err) + setError(tr("Video display error"), err); + } + } +} + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/videoplayer_surface.h b/src/3rdparty/phonon/mmf/videoplayer_surface.h new file mode 100644 index 0000000..c05da9c --- /dev/null +++ b/src/3rdparty/phonon/mmf/videoplayer_surface.h @@ -0,0 +1,78 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_VIDEOPLAYER_SURFACE_H +#define PHONON_MMF_VIDEOPLAYER_SURFACE_H + +#include "abstractvideoplayer.h" + +class RWindow; + +QT_BEGIN_NAMESPACE + +namespace Phonon +{ +namespace MMF +{ + +/** + * @short Wrapper over the MMF video player utility (surface version) + * + * This implementation is used on devices with a graphics subsystem which + * supports surfaces. + * + * @see DsaVideoPlayer + */ +class SurfaceVideoPlayer + : public AbstractVideoPlayer +{ + Q_OBJECT + +public: + // Factory function + static SurfaceVideoPlayer* create(MediaObject *parent = 0, + const AbstractPlayer *player = 0); + ~SurfaceVideoPlayer(); + +public Q_SLOTS: + void videoWindowSizeChanged(); + +private: + SurfaceVideoPlayer(MediaObject *parent, const AbstractPlayer *player); + + // AbstractVideoPlayer + void createPlayer(); + void initVideoOutput(); + void prepareCompleted(); + void handleVideoWindowChanged(); + void handleParametersChanged(VideoParameters parameters); + +private: + // Window handle which has been passed to the MMF via + // CVideoPlayerUtility2::SetDisplayWindowL + RWindow* m_displayWindow; + +}; + +} +} + +QT_END_NAMESPACE + +#endif // !PHONON_MMF_VIDEOPLAYER_SURFACE_H + diff --git a/src/3rdparty/phonon/mmf/videowidget.cpp b/src/3rdparty/phonon/mmf/videowidget.cpp index bc9acfd..4ed9979 100644 --- a/src/3rdparty/phonon/mmf/videowidget.cpp +++ b/src/3rdparty/phonon/mmf/videowidget.cpp @@ -18,10 +18,15 @@ along with this library. If not, see <http://www.gnu.org/licenses/>. #include "mediaobject.h" #include "utils.h" -#include "videooutput.h" #include "videowidget.h" +#ifdef PHONON_MMF_VIDEO_SURFACES +#include "videooutput_surface.h" +#else +#include "videooutput_dsa.h" +#endif + QT_BEGIN_NAMESPACE using namespace Phonon; @@ -45,10 +50,13 @@ static const qreal DefaultSaturation = 1.0; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::VideoWidget::VideoWidget - (AncestorMoveMonitor* ancestorMoveMonitor, QWidget* parent) +MMF::VideoWidget::VideoWidget(QWidget *parent) : MediaNode(parent) - , m_videoOutput(new VideoOutput(ancestorMoveMonitor, parent)) +#ifdef PHONON_MMF_VIDEO_SURFACES + , m_videoOutput(new SurfaceVideoOutput(parent)) +#else + , m_videoOutput(new DsaVideoOutput(parent)) +#endif , m_brightness(DefaultBrightness) , m_contrast(DefaultContrast) , m_hue(DefaultHue) @@ -68,6 +76,13 @@ MMF::VideoWidget::~VideoWidget() TRACE_EXIT_0(); } +#ifndef PHONON_MMF_VIDEO_SURFACES +void MMF::VideoWidget::setAncestorMoveMonitor(AncestorMoveMonitor *monitor) +{ + static_cast<DsaVideoOutput *>(m_videoOutput.data())->setAncestorMoveMonitor(monitor); +} +#endif + //----------------------------------------------------------------------------- // VideoWidgetInterface diff --git a/src/3rdparty/phonon/mmf/videowidget.h b/src/3rdparty/phonon/mmf/videowidget.h index 899dca6..3b6283e 100644 --- a/src/3rdparty/phonon/mmf/videowidget.h +++ b/src/3rdparty/phonon/mmf/videowidget.h @@ -19,8 +19,8 @@ along with this library. If not, see <http://www.gnu.org/licenses/>. #ifndef PHONON_MMF_VIDEOWIDGET_H #define PHONON_MMF_VIDEOWIDGET_H +#include "abstractvideooutput.h" #include "mmf_medianode.h" -#include "videooutput.h" #include <QtGui/QWidget> #include <phonon/videowidget.h> @@ -32,8 +32,9 @@ namespace Phonon { namespace MMF { +#ifndef PHONON_MMF_VIDEO_SURFACES class AncestorMoveMonitor; -class VideoOutput; +#endif class VideoWidget : public MediaNode , public Phonon::VideoWidgetInterface @@ -42,9 +43,13 @@ class VideoWidget : public MediaNode Q_INTERFACES(Phonon::VideoWidgetInterface) public: - VideoWidget(AncestorMoveMonitor* ancestorMoveMonitor, QWidget* parent); + VideoWidget(QWidget* parent); ~VideoWidget(); +#ifndef PHONON_MMF_VIDEO_SURFACES + void setAncestorMoveMonitor(AncestorMoveMonitor *ancestorMoveMonitor); +#endif + // VideoWidgetInterface virtual Phonon::VideoWidget::AspectRatio aspectRatio() const; virtual void setAspectRatio(Phonon::VideoWidget::AspectRatio aspectRatio); @@ -66,7 +71,7 @@ protected: void disconnectMediaObject(MediaObject *mediaObject); private: - QScopedPointer<VideoOutput> m_videoOutput; + QScopedPointer<AbstractVideoOutput> m_videoOutput; qreal m_brightness; qreal m_contrast; diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.h b/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.h index 71c9402..52a24f6 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.h +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.h @@ -73,7 +73,7 @@ #include <windows.h> #elif PLATFORM(DARWIN) #include <libkern/OSAtomic.h> -#elif COMPILER(GCC) +#elif COMPILER(GCC) && !PLATFORM(SYMBIAN) #if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) #include <ext/atomicity.h> #else @@ -232,7 +232,7 @@ inline int atomicDecrement(int volatile* addend) { return InterlockedDecrement(r inline int atomicIncrement(int volatile* addend) { return OSAtomicIncrement32Barrier(const_cast<int*>(addend)); } inline int atomicDecrement(int volatile* addend) { return OSAtomicDecrement32Barrier(const_cast<int*>(addend)); } -#elif COMPILER(GCC) && !PLATFORM(SPARC64) // sizeof(_Atomic_word) != sizeof(int) on sparc64 gcc +#elif COMPILER(GCC) && !PLATFORM(SPARC64) && !PLATFORM(SYMBIAN) // sizeof(_Atomic_word) != sizeof(int) on sparc64 gcc #define WTF_USE_LOCKFREE_THREADSAFESHARED 1 inline int atomicIncrement(int volatile* addend) { return __gnu_cxx::__exchange_and_add(addend, 1) + 1; } diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp index ceb5ee1..a80c5d3 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp @@ -30,6 +30,7 @@ #include <QtGui/qapplication.h> #include <QtGui/qgraphicssceneevent.h> #include <QtGui/qstyleoption.h> +#include <QtGui/qinputcontext.h> #if defined(Q_WS_X11) #include <QX11Info> #endif @@ -63,6 +64,8 @@ public: void _q_doLoadFinished(bool success); + void _q_updateMicroFocus(); + QGraphicsWebView* q; QWebPage* page; }; @@ -80,6 +83,20 @@ void QGraphicsWebViewPrivate::_q_doLoadFinished(bool success) emit q->loadFinished(success); } +void QGraphicsWebViewPrivate::_q_updateMicroFocus() +{ +#if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)) + // Ideally, this should be handled by a common call to an updateMicroFocus function + // in QGraphicsItem. See http://bugreports.qt.nokia.com/browse/QTBUG-7578. + QList<QGraphicsView*> views = q->scene()->views(); + for (int c = 0; c < views.size(); ++c) { + QInputContext* ic = views.at(c)->inputContext(); + if (ic) + ic->update(); + } +#endif +} + void QGraphicsWebViewPrivate::scroll(int dx, int dy, const QRect& rectToScroll) { q->scroll(qreal(dx), qreal(dy), QRectF(rectToScroll)); @@ -435,6 +452,8 @@ void QGraphicsWebView::setPage(QWebPage* page) this, SIGNAL(statusBarMessage(QString))); connect(d->page, SIGNAL(linkClicked(QUrl)), this, SIGNAL(linkClicked(QUrl))); + connect(d->page, SIGNAL(microFocusChanged()), + this, SLOT(_q_updateMicroFocus())); } /*! diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h index f3afb4c..68379a2 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h +++ b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h @@ -140,3 +140,4 @@ private: }; #endif // QGraphicsWebView_h + Q_PRIVATE_SLOT(d, void _q_updateMicroFocus()) diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index e54c176..a5441cd 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,15 @@ +2010-03-21 Kristian Amlie <kristian.amlie@nokia.com> + + Reviewed by Simon Hausmann. + + Fixed updating the VKB display when inputting into QGraphicsWebView. + https://bugs.webkit.org/show_bug.cgi?id=36292 + + * Api/qgraphicswebview.cpp: + (QGraphicsWebViewPrivate::_q_updateMicroFocus): + (QGraphicsWebView::setPage): + * Api/qgraphicswebview.h: + 2010-03-04 Simon Hausmann <simon.hausmann@nokia.com> Reviewed by Kenneth Rohde Christiansen. diff --git a/src/corelib/animation/qanimationgroup.cpp b/src/corelib/animation/qanimationgroup.cpp index a89f949..2decda3 100644 --- a/src/corelib/animation/qanimationgroup.cpp +++ b/src/corelib/animation/qanimationgroup.cpp @@ -244,7 +244,7 @@ QAbstractAnimation *QAnimationGroup::takeAnimation(int index) // in ChildRemoved event d->animations.removeAt(index); animation->setParent(0); - d->animationRemovedAt(index); + d->animationRemoved(index, animation); return animation; } @@ -285,7 +285,7 @@ bool QAnimationGroup::event(QEvent *event) } -void QAnimationGroupPrivate::animationRemovedAt(int index) +void QAnimationGroupPrivate::animationRemoved(int index, QAbstractAnimation *) { Q_Q(QAnimationGroup); Q_UNUSED(index); diff --git a/src/corelib/animation/qanimationgroup_p.h b/src/corelib/animation/qanimationgroup_p.h index 394773b..45603b3 100644 --- a/src/corelib/animation/qanimationgroup_p.h +++ b/src/corelib/animation/qanimationgroup_p.h @@ -72,8 +72,19 @@ public: isGroup = true; } - virtual void animationInsertedAt(int index) { Q_UNUSED(index) }; - virtual void animationRemovedAt(int index); + virtual void animationInsertedAt(int) { } + virtual void animationRemoved(int, QAbstractAnimation *); + + void disconnectUncontrolledAnimation(QAbstractAnimation *anim) + { + //0 for the signal here because we might be called from the animation destructor + QObject::disconnect(anim, 0, q_func(), SLOT(_q_uncontrolledAnimationFinished())); + } + + void connectUncontrolledAnimation(QAbstractAnimation *anim) + { + QObject::connect(anim, SIGNAL(finished()), q_func(), SLOT(_q_uncontrolledAnimationFinished())); + } QList<QAbstractAnimation *> animations; }; diff --git a/src/corelib/animation/qparallelanimationgroup.cpp b/src/corelib/animation/qparallelanimationgroup.cpp index eaa0364..280afed 100644 --- a/src/corelib/animation/qparallelanimationgroup.cpp +++ b/src/corelib/animation/qparallelanimationgroup.cpp @@ -246,11 +246,9 @@ void QParallelAnimationGroupPrivate::_q_uncontrolledAnimationFinished() void QParallelAnimationGroupPrivate::disconnectUncontrolledAnimations() { - Q_Q(QParallelAnimationGroup); - QHash<QAbstractAnimation *, int>::iterator it = uncontrolledFinishTime.begin(); while (it != uncontrolledFinishTime.end()) { - QObject::disconnect(it.key(), SIGNAL(finished()), q, SLOT(_q_uncontrolledAnimationFinished())); + disconnectUncontrolledAnimation(it.key()); ++it; } @@ -259,13 +257,11 @@ void QParallelAnimationGroupPrivate::disconnectUncontrolledAnimations() void QParallelAnimationGroupPrivate::connectUncontrolledAnimations() { - Q_Q(QParallelAnimationGroup); - for (int i = 0; i < animations.size(); ++i) { QAbstractAnimation *animation = animations.at(i); if (animation->duration() == -1 || animation->loopCount() < 0) { uncontrolledFinishTime[animation] = -1; - QObject::connect(animation, SIGNAL(finished()), q, SLOT(_q_uncontrolledAnimationFinished())); + connectUncontrolledAnimation(animation); } } } @@ -305,6 +301,13 @@ bool QParallelAnimationGroupPrivate::isUncontrolledAnimationFinished(QAbstractAn return uncontrolledFinishTime.value(anim, -1) >= 0; } +void QParallelAnimationGroupPrivate::animationRemoved(int index, QAbstractAnimation *anim) +{ + QAnimationGroupPrivate::animationRemoved(index, anim); + disconnectUncontrolledAnimation(anim); + uncontrolledFinishTime.remove(anim); +} + /*! \reimp */ diff --git a/src/corelib/animation/qparallelanimationgroup_p.h b/src/corelib/animation/qparallelanimationgroup_p.h index a74d496..cab4fa9 100644 --- a/src/corelib/animation/qparallelanimationgroup_p.h +++ b/src/corelib/animation/qparallelanimationgroup_p.h @@ -80,6 +80,8 @@ public: void connectUncontrolledAnimations(); void disconnectUncontrolledAnimations(); + void animationRemoved(int index, QAbstractAnimation *); + // private slot void _q_uncontrolledAnimationFinished(); }; diff --git a/src/corelib/animation/qsequentialanimationgroup.cpp b/src/corelib/animation/qsequentialanimationgroup.cpp index 8ab084a..7617c1f 100644 --- a/src/corelib/animation/qsequentialanimationgroup.cpp +++ b/src/corelib/animation/qsequentialanimationgroup.cpp @@ -479,7 +479,7 @@ void QSequentialAnimationGroupPrivate::activateCurrentAnimation(bool intermediat // connects to the finish signal of uncontrolled animations if (currentAnimation->totalDuration() == -1) - QObject::connect(currentAnimation, SIGNAL(finished()), q, SLOT(_q_uncontrolledAnimationFinished())); + connectUncontrolledAnimation(currentAnimation); currentAnimation->start(); if (!intermediate && state == QSequentialAnimationGroup::Paused) @@ -496,7 +496,7 @@ void QSequentialAnimationGroupPrivate::_q_uncontrolledAnimationFinished() actualDuration.append(-1); actualDuration[currentAnimationIndex] = currentAnimation->currentTime(); - QObject::disconnect(currentAnimation, SIGNAL(finished()), q, SLOT(_q_uncontrolledAnimationFinished())); + disconnectUncontrolledAnimation(currentAnimation); if ((direction == QAbstractAnimation::Forward && currentAnimation == animations.last()) || (direction == QAbstractAnimation::Backward && currentAnimationIndex == 0)) { @@ -543,10 +543,10 @@ void QSequentialAnimationGroupPrivate::animationInsertedAt(int index) the group at index \a index. The animation is no more listed when this method is called. */ -void QSequentialAnimationGroupPrivate::animationRemovedAt(int index) +void QSequentialAnimationGroupPrivate::animationRemoved(int index, QAbstractAnimation *anim) { Q_Q(QSequentialAnimationGroup); - QAnimationGroupPrivate::animationRemovedAt(index); + QAnimationGroupPrivate::animationRemoved(index, anim); Q_ASSERT(currentAnimation); // currentAnimation should always be set @@ -555,7 +555,10 @@ void QSequentialAnimationGroupPrivate::animationRemovedAt(int index) const int currentIndex = animations.indexOf(currentAnimation); if (currentIndex == -1) { - //we're removing the current animation, let's update it to another one + //we're removing the current animation + + disconnectUncontrolledAnimation(currentAnimation); + if (index < animations.count()) setCurrentAnimation(index); //let's try to take the next one else if (index > 0) diff --git a/src/corelib/animation/qsequentialanimationgroup_p.h b/src/corelib/animation/qsequentialanimationgroup_p.h index a55e136..de69916 100644 --- a/src/corelib/animation/qsequentialanimationgroup_p.h +++ b/src/corelib/animation/qsequentialanimationgroup_p.h @@ -85,7 +85,7 @@ public: void activateCurrentAnimation(bool intermediate = false); void animationInsertedAt(int index); - void animationRemovedAt(int index); + void animationRemoved(int index, QAbstractAnimation *anim); bool atEnd() const; diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 6437fb7..3118f8f 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -2429,12 +2429,15 @@ QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathSysconf(); #define Q_SYMBIAN_FIXED_POINTER_CURSORS #define Q_SYMBIAN_HAS_EXTENDED_BITMAP_TYPE #define Q_SYMBIAN_WINDOW_SIZE_CACHE -//enabling new graphics resources -#define QT_SYMBIAN_SUPPORTS_SGIMAGE #define QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER +//enabling new graphics resources +#ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE +# define QT_SYMBIAN_SUPPORTS_SGIMAGE +#endif + #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS -#define Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE +# define Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE #endif #endif diff --git a/src/corelib/io/qprocess_symbian.cpp b/src/corelib/io/qprocess_symbian.cpp index 8902f7d..92212fe 100644 --- a/src/corelib/io/qprocess_symbian.cpp +++ b/src/corelib/io/qprocess_symbian.cpp @@ -237,11 +237,15 @@ static void qt_create_symbian_commandline(const QStringList &arguments, QString --i; endQuote += QLatin1String("\\"); } - commandLine += QLatin1String(" \"") + tmp.left(i) + endQuote; + commandLine += QLatin1String("\"") + tmp.left(i) + endQuote + QLatin1Char(' '); } else { - commandLine += QLatin1Char(' ') + tmp; + commandLine += tmp + QLatin1Char(' '); } } + + // Chop the extra trailing space if any arguments were appended + if (arguments.size()) + commandLine.chop(1); } static TInt qt_create_symbian_process(RProcess **proc, const QString &programName, const QStringList &arguments) diff --git a/src/corelib/kernel/qcore_symbian_p.cpp b/src/corelib/kernel/qcore_symbian_p.cpp index 0257ac4..402eccf 100644 --- a/src/corelib/kernel/qcore_symbian_p.cpp +++ b/src/corelib/kernel/qcore_symbian_p.cpp @@ -132,9 +132,10 @@ private: void init() { #ifdef Q_WS_S60 - _LIT(KLibName_3_1, "qts60plugin_3_1.dll"); - _LIT(KLibName_3_2, "qts60plugin_3_2.dll"); - _LIT(KLibName_5_0, "qts60plugin_5_0.dll"); + _LIT(KLibName_3_1, "qts60plugin_3_1" QT_LIBINFIX_UNICODE L".dll"); + _LIT(KLibName_3_2, "qts60plugin_3_2" QT_LIBINFIX_UNICODE L".dll"); + _LIT(KLibName_5_0, "qts60plugin_5_0" QT_LIBINFIX_UNICODE L".dll"); + TPtrC libName; TInt uidValue; switch (QSysInfo::s60Version()) { diff --git a/src/corelib/kernel/qcore_symbian_p.h b/src/corelib/kernel/qcore_symbian_p.h index 9f282d5..4a515ce 100644 --- a/src/corelib/kernel/qcore_symbian_p.h +++ b/src/corelib/kernel/qcore_symbian_p.h @@ -60,6 +60,15 @@ #include <qhash.h> #include <f32file.h> +#define QT_LSTRING2(x) L##x +#define QT_LSTRING(x) QT_LSTRING2(x) + +#if defined(QT_LIBINFIX) +# define QT_LIBINFIX_UNICODE QT_LSTRING(QT_LIBINFIX) +#else +# define QT_LIBINFIX_UNICODE L"" +#endif + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index b045c42..555a1f5 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -78,6 +78,7 @@ class QString; #define Q_CLASSINFO(name, value) #define Q_INTERFACES(x) #define Q_PROPERTY(text) +#define Q_PRIVATE_PROPERTY(d, text) #define Q_OVERRIDE(text) #define Q_ENUMS(x) #define Q_FLAGS(x) @@ -178,6 +179,7 @@ private: #define Q_CLASSINFO(name, value) Q_CLASSINFO(name, value) #define Q_INTERFACES(x) Q_INTERFACES(x) #define Q_PROPERTY(text) Q_PROPERTY(text) +#define Q_PRIVATE_PROPERTY(d, text) Q_PRIVATE_PROPERTY(d, text) #define Q_OVERRIDE(text) Q_OVERRIDE(text) #define Q_ENUMS(x) Q_ENUMS(x) #define Q_FLAGS(x) Q_FLAGS(x) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 159c997..bcdc7d3 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -4301,6 +4301,12 @@ static void _q_paintIntoCache(QPixmap *pix, QGraphicsItem *item, const QRegion & if (!subPix.isNull()) { // Blit the subpixmap into the main pixmap. pixmapPainter.begin(pix); + if (item->cacheMode() == QGraphicsItem::DeviceCoordinateCache + && itemToPixmap.type() > QTransform::TxTranslate) { + pixmapPainter.setCompositionMode(QPainter::CompositionMode_SourceAtop); + } else { + pixmapPainter.setCompositionMode(QPainter::CompositionMode_Source); + } pixmapPainter.setClipRegion(pixmapExposed); pixmapPainter.drawPixmap(br.topLeft(), subPix); pixmapPainter.end(); diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp index 87416b4..669dd61 100644 --- a/src/gui/graphicsview/qgraphicswidget.cpp +++ b/src/gui/graphicsview/qgraphicswidget.cpp @@ -384,7 +384,7 @@ void QGraphicsWidget::setGeometry(const QRectF &rect) } QSizeF oldSize = size(); QGraphicsLayoutItem::setGeometry(newGeom); - + emit geometryChanged(); // Send resize event bool resized = newGeom.size() != oldSize; if (resized) { diff --git a/src/gui/graphicsview/qgraphicswidget.h b/src/gui/graphicsview/qgraphicswidget.h index 4bea5be..87c669b 100644 --- a/src/gui/graphicsview/qgraphicswidget.h +++ b/src/gui/graphicsview/qgraphicswidget.h @@ -73,7 +73,7 @@ class Q_GUI_EXPORT QGraphicsWidget : public QGraphicsObject, public QGraphicsLay Q_PROPERTY(QPalette palette READ palette WRITE setPalette) Q_PROPERTY(QFont font READ font WRITE setFont) Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection RESET unsetLayoutDirection) - Q_PROPERTY(QSizeF size READ size WRITE resize) + Q_PROPERTY(QSizeF size READ size WRITE resize NOTIFY geometryChanged) Q_PROPERTY(QSizeF minimumSize READ minimumSize WRITE setMinimumSize) Q_PROPERTY(QSizeF preferredSize READ preferredSize WRITE setPreferredSize) Q_PROPERTY(QSizeF maximumSize READ maximumSize WRITE setMaximumSize) @@ -81,12 +81,11 @@ class Q_GUI_EXPORT QGraphicsWidget : public QGraphicsObject, public QGraphicsLay Q_PROPERTY(Qt::FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy) Q_PROPERTY(Qt::WindowFlags windowFlags READ windowFlags WRITE setWindowFlags) Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle) - Q_PROPERTY(QRectF geometry READ geometry WRITE setGeometry) + Q_PROPERTY(QRectF geometry READ geometry WRITE setGeometry NOTIFY geometryChanged) Q_PROPERTY(bool autoFillBackground READ autoFillBackground WRITE setAutoFillBackground) public: QGraphicsWidget(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); ~QGraphicsWidget(); - QGraphicsLayout *layout() const; void setLayout(QGraphicsLayout *layout); void adjustSize(); @@ -179,6 +178,9 @@ public: using QObject::children; #endif +Q_SIGNALS: + void geometryChanged(); + public Q_SLOTS: bool close(); diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index fea8c37..9fe6c87 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -903,6 +903,14 @@ void QApplicationPrivate::initialize() { QWidgetPrivate::mapper = new QWidgetMapper; QWidgetPrivate::allWidgets = new QWidgetSet; + +#if !defined(Q_WS_X11) && !defined(Q_WS_QWS) + // initialize the graphics system - on X11 this is initialized inside + // qt_init() in qapplication_x11.cpp because of several reasons. + // On QWS, the graphics system is set by the QScreen plugin. + graphics_system = QGraphicsSystemFactory::create(graphics_system_name); +#endif + if (qt_appType != QApplication::Tty) (void) QApplication::style(); // trigger creation of application style // trigger registering of QVariant's GUI types @@ -936,13 +944,7 @@ void QApplicationPrivate::initialize() // Set up which span functions should be used in raster engine... qInitDrawhelperAsm(); - -#if !defined(Q_WS_X11) && !defined(Q_WS_QWS) - // initialize the graphics system - on X11 this is initialized inside - // qt_init() in qapplication_x11.cpp because of several reasons. - // On QWS, the graphics system is set by the QScreen plugin. - graphics_system = QGraphicsSystemFactory::create(graphics_system_name); -#endif + #ifndef QT_NO_WHEELEVENT QApplicationPrivate::wheel_scroll_lines = 3; #endif diff --git a/src/gui/kernel/qtooltip.cpp b/src/gui/kernel/qtooltip.cpp index c912129..1343959 100644 --- a/src/gui/kernel/qtooltip.cpp +++ b/src/gui/kernel/qtooltip.cpp @@ -368,7 +368,16 @@ void QTipLabel::placeTip(const QPoint &pos, QWidget *w) #ifdef Q_WS_MAC - QRect screen = QApplication::desktop()->availableGeometry(getTipScreen(pos, w)); + // When in full screen mode, there is no Dock nor Menu so we can use + // the whole screen for displaying the tooltip. However when not in + // full screen mode we need to save space for the dock, so we use + // availableGeometry instead. + extern bool qt_mac_app_fullscreen; //qapplication_mac.mm + QRect screen; + if(qt_mac_app_fullscreen) + screen = QApplication::desktop()->screenGeometry(getTipScreen(pos, w)); + else + screen = QApplication::desktop()->availableGeometry(getTipScreen(pos, w)); #else QRect screen = QApplication::desktop()->screenGeometry(getTipScreen(pos, w)); #endif diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp index 10fb009..9660de5 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -369,7 +369,7 @@ Q_GUI_EXPORT void qt_x11_wait_for_window_manager(QWidget* w) // ConfigureNotify ... MapNotify ... Expose enum State { - Initial, Reparented, Mapped + Initial, Mapped } state = Initial; do { @@ -377,33 +377,15 @@ Q_GUI_EXPORT void qt_x11_wait_for_window_manager(QWidget* w) XNextEvent(X11->display, &ev); qApp->x11ProcessEvent(&ev); - if (w->windowFlags() & Qt::X11BypassWindowManagerHint) { - switch (state) { - case Initial: - case Reparented: - if (ev.type == MapNotify && ev.xany.window == winid) - state = Mapped; - break; - case Mapped: - if (ev.type == Expose && ev.xany.window == winid) - return; - break; - } - } else { - switch (state) { - case Initial: - if (ev.type == ReparentNotify && ev.xany.window == winid) - state = Reparented; - break; - case Reparented: - if (ev.type == MapNotify && ev.xany.window == winid) - state = Mapped; - break; - case Mapped: - if (ev.type == Expose && ev.xany.window == winid) - return; - break; - } + switch (state) { + case Initial: + if (ev.type == MapNotify && ev.xany.window == winid) + state = Mapped; + break; + case Mapped: + if (ev.type == Expose && ev.xany.window == winid) + return; + break; } } else { if (!XEventsQueued(X11->display, QueuedAfterFlush)) diff --git a/src/gui/s60framework/qs60mainapplication.cpp b/src/gui/s60framework/qs60mainapplication.cpp index 2a7c4aa..41ac1a8 100644 --- a/src/gui/s60framework/qs60mainapplication.cpp +++ b/src/gui/s60framework/qs60mainapplication.cpp @@ -41,6 +41,7 @@ // INCLUDE FILES #include <exception> +#include <private/qcore_symbian_p.h> #include "qs60maindocument.h" #include "qs60mainapplication_p.h" #include "qs60mainapplication.h" @@ -57,17 +58,17 @@ CApaApplication *newS60Application() return new QS60MainApplication; } -_LIT(KQtWrapperResourceFile, "\\resource\\apps\\s60main.rsc"); +_LIT(KQtWrapperResourceFile, "\\resource\\apps\\s60main" QT_LIBINFIX_UNICODE L".rsc"); /*! \class QS60MainApplication \since 4.6 \brief The QS60MainApplication class provides support for migration from S60. - + \warning This class is provided only to get access to S60 specific functionality in the application framework classes. It is not portable. We strongly recommend against using it in new applications. - + The QS60MainApplication provides a helper class for use in migrating from existing S60 based applications to Qt based applications. It is used in the exact same way as the \c CAknApplication class from diff --git a/src/gui/s60framework/qs60mainappui.cpp b/src/gui/s60framework/qs60mainappui.cpp index 012985b..3b5b9d3 100644 --- a/src/gui/s60framework/qs60mainappui.cpp +++ b/src/gui/s60framework/qs60mainappui.cpp @@ -45,7 +45,15 @@ #include <eikmenub.h> #include <eikmenup.h> #include <barsread.h> -#include <s60main.rsg> +#include <qconfig.h> +#if defined(QT_LIBINFIX_UNQUOTED) +// Two level macro needed for proper expansion of libinfix +# define QT_S60MAIN_RSG_2(x) <s60main##x##.rsg> +# define QT_S60MAIN_RSG(x) QT_S60MAIN_RSG_2(x) +# include QT_S60MAIN_RSG(QT_LIBINFIX_UNQUOTED) +#else +# include <s60main.rsg> +#endif #include <avkon.rsg> #include "qs60mainappui.h" diff --git a/src/gui/s60framework/s60framework.pri b/src/gui/s60framework/s60framework.pri index e177a33..f9d89dc 100644 --- a/src/gui/s60framework/s60framework.pri +++ b/src/gui/s60framework/s60framework.pri @@ -4,6 +4,7 @@ minimalAppResource31 = \ "SOURCEPATH s60framework" \ "START RESOURCE s60main.rss" \ + "TARGET s60main$${QT_LIBINFIX}" \ "HEADER" \ "TARGETPATH /resource/apps" \ "END" @@ -19,3 +20,5 @@ HEADERS += s60framework/qs60mainapplication_p.h \ s60framework/qs60mainapplication.h \ s60framework/qs60mainappui.h \ s60framework/qs60maindocument.h + +!isEmpty(QT_LIBINFIX): DEFINES += QT_LIBINFIX_UNQUOTED=$$QT_LIBINFIX
\ No newline at end of file diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index a2ebebb..750e19f 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -2069,11 +2069,11 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti break; case PE_IndicatorViewItemCheck: #ifndef QT_NO_ITEMVIEWS - if (const QListView *listItem = (qobject_cast<const QListView *>(widget))) { + if (const QAbstractItemView *itemView = (qobject_cast<const QAbstractItemView *>(widget))) { if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { const bool checkBoxVisible = vopt->features & QStyleOptionViewItemV2::HasCheckIndicator; - const bool singleSelection = listItem->selectionMode() == - QAbstractItemView::SingleSelection || listItem->selectionMode() == QAbstractItemView::NoSelection; + const bool singleSelection = itemView->selectionMode() == + QAbstractItemView::SingleSelection || itemView->selectionMode() == QAbstractItemView::NoSelection; // draw either checkbox at the beginning if (checkBoxVisible && singleSelection) { drawPrimitive(PE_IndicatorCheckBox, option, painter, widget); @@ -2475,6 +2475,12 @@ int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w { int retValue = -1; switch (sh) { + case SH_RequestSoftwareInputPanel: + if (QS60StylePrivate::isSingleClickUi()) + retValue = RSIP_OnMouseClick; + else + retValue = RSIP_OnMouseClickAndAlreadyFocused; + break; case SH_ComboBox_Popup: retValue = true; break; @@ -2531,9 +2537,6 @@ int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w case SH_UnderlineShortcut: retValue = 0; break; - case SH_RequestSoftwareInputPanel: - retValue = RSIP_OnMouseClickAndAlreadyFocused; - break; case SH_FormLayoutWrapPolicy: retValue = QFormLayout::WrapLongRows; break; diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index ecac3d6..6138e85 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -1121,7 +1121,7 @@ QColor QS60StylePrivate::s60Color(QS60StyleEnums::ColorLists list, &KAknsIIDQsnParentColors, &KAknsIIDQsnTextColors }; - Q_ASSERT((int)list <= (int)sizeof(idMap)/sizeof(idMap[0])); + Q_ASSERT((int)list < (int)sizeof(idMap)/sizeof(idMap[0])); const QColor color = QS60StyleModeSpecifics::colorValue(*idMap[(int) list], index - 1); return option ? QS60StylePrivate::stateColor(color, option) : color; } diff --git a/src/gui/styles/qwindowsmobilestyle.cpp b/src/gui/styles/qwindowsmobilestyle.cpp index 6e77409..5f939d0 100644 --- a/src/gui/styles/qwindowsmobilestyle.cpp +++ b/src/gui/styles/qwindowsmobilestyle.cpp @@ -5076,6 +5076,10 @@ void QWindowsMobileStyle::drawPrimitive(PrimitiveElement element, const QStyleOp color = option->palette.buttonText().color(); QImage image; int xoffset, yoffset; + bool isTabBarArrow = widget && widget->parent() + && widget->inherits("QToolButton") + && widget->parent()->inherits("QTabBar"); + switch (element) { case PE_IndicatorArrowUp: image = d->imageArrowUp; @@ -5090,12 +5094,12 @@ void QWindowsMobileStyle::drawPrimitive(PrimitiveElement element, const QStyleOp case PE_IndicatorArrowLeft: image = d->imageArrowLeft; xoffset = 8; - yoffset = 2; + yoffset = isTabBarArrow ? 12 : 2; break; case PE_IndicatorArrowRight: image = d->imageArrowRight; xoffset = 8; - yoffset = 2; + yoffset = isTabBarArrow ? 12 : 2; break; case PE_IndicatorArrowUpBig: image = d->imageArrowUpBig; @@ -6949,10 +6953,11 @@ int QWindowsMobileStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, co case PM_SliderThickness: ret = d->doubleControls ? windowsMobileSliderThickness * 2: windowsMobileSliderThickness; break; - case PM_TabBarScrollButtonWidth: - ret = d->doubleControls ? 14 * 2 : 18; - case PM_CheckBoxLabelSpacing: - case PM_RadioButtonLabelSpacing: + case PM_TabBarScrollButtonWidth: + ret = d->doubleControls ? 14 * 2 : 18; + break; + case PM_CheckBoxLabelSpacing: + case PM_RadioButtonLabelSpacing: ret = d->doubleControls ? 6 * 2 : 6; break; // Returns the number of pixels to use for the business part of the diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index cc6793d..766053c 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1644,28 +1644,67 @@ namespace { struct LineBreakHelper { - LineBreakHelper() : glyphCount(0), maxGlyphs(0), manualWrap(false) {} + LineBreakHelper() + : glyphCount(0), maxGlyphs(0), currentPosition(0), fontEngine(0), logClusters(0), + manualWrap(false) + { + } + QScriptLine tmpData; QScriptLine spaceData; + QGlyphLayout glyphs; + int glyphCount; int maxGlyphs; + int currentPosition; QFixed minw; QFixed softHyphenWidth; QFixed rightBearing; + QFixed minimumRightBearing; + + QFontEngine *fontEngine; + const unsigned short *logClusters; bool manualWrap; bool checkFullOtherwiseExtend(QScriptLine &line); + + QFixed calculateNewWidth(const QScriptLine &line) const { + return line.textWidth + tmpData.textWidth + spaceData.textWidth + softHyphenWidth + - qMin(rightBearing, QFixed()); + } + + inline glyph_t currentGlyph() const + { + Q_ASSERT(currentPosition > 0); + return glyphs.glyphs[logClusters[currentPosition - 1]]; + } + + inline void adjustRightBearing() + { + if (currentPosition <= 0) + return; + + glyph_metrics_t gi = fontEngine->boundingBox(currentGlyph()); + if (gi.isValid()) + rightBearing = qMin(QFixed(), gi.xoff - gi.x - gi.width); + } + + inline void resetRightBearing() + { + rightBearing = QFixed(1); // Any positive number is defined as invalid since only + // negative right bearings are interesting to us. + } }; inline bool LineBreakHelper::checkFullOtherwiseExtend(QScriptLine &line) { LB_DEBUG("possible break width %f, spacew=%f", tmpData.textWidth.toReal(), spaceData.textWidth.toReal()); - QFixed newWidth = line.textWidth + tmpData.textWidth + spaceData.textWidth + softHyphenWidth + rightBearing; + QFixed newWidth = calculateNewWidth(line); if (line.length && !manualWrap && (newWidth > line.width || glyphCount > maxGlyphs)) return true; @@ -1741,13 +1780,12 @@ void QTextLine::layout_helper(int maxGlyphs) Qt::Alignment alignment = eng->option.alignment(); const HB_CharAttributes *attributes = eng->attributes(); - int pos = line.from; + lbh.currentPosition = line.from; int end = 0; - QGlyphLayout glyphs; - const unsigned short *logClusters = eng->layoutData->logClustersPtr; + lbh.logClusters = eng->layoutData->logClustersPtr; while (newItem < eng->layoutData->items.size()) { - lbh.rightBearing = 0; + lbh.resetRightBearing(); lbh.softHyphenWidth = 0; if (newItem != item) { item = newItem; @@ -1755,13 +1793,19 @@ void QTextLine::layout_helper(int maxGlyphs) if (!current.num_glyphs) { eng->shape(item); attributes = eng->attributes(); - logClusters = eng->layoutData->logClustersPtr; + lbh.logClusters = eng->layoutData->logClustersPtr; } - pos = qMax(line.from, current.position); + lbh.currentPosition = qMax(line.from, current.position); end = current.position + eng->length(item); - glyphs = eng->shapedGlyphs(¤t); + lbh.glyphs = eng->shapedGlyphs(¤t); } const QScriptItem ¤t = eng->layoutData->items[item]; + QFontEngine *fontEngine = eng->fontEngine(current); + if (lbh.fontEngine != fontEngine) { + lbh.fontEngine = fontEngine; + lbh.minimumRightBearing = qMin(QFixed(), + QFixed::fromReal(fontEngine->minRightBearing())); + } lbh.tmpData.leading = qMax(lbh.tmpData.leading + lbh.tmpData.ascent, current.leading + current.ascent) - qMax(lbh.tmpData.ascent, @@ -1791,8 +1835,8 @@ void QTextLine::layout_helper(int maxGlyphs) if (!line.length && !lbh.tmpData.length) line.setDefaultHeight(eng); if (eng->option.flags() & QTextOption::ShowLineAndParagraphSeparators) { - addNextCluster(pos, end, lbh.tmpData, lbh.glyphCount, - current, logClusters, glyphs); + addNextCluster(lbh.currentPosition, end, lbh.tmpData, lbh.glyphCount, + current, lbh.logClusters, lbh.glyphs); } else { lbh.tmpData.length++; } @@ -1811,10 +1855,10 @@ void QTextLine::layout_helper(int maxGlyphs) ++lbh.glyphCount; if (lbh.checkFullOtherwiseExtend(line)) goto found; - } else if (attributes[pos].whiteSpace) { - while (pos < end && attributes[pos].whiteSpace) - addNextCluster(pos, end, lbh.spaceData, lbh.glyphCount, - current, logClusters, glyphs); + } else if (attributes[lbh.currentPosition].whiteSpace) { + while (lbh.currentPosition < end && attributes[lbh.currentPosition].whiteSpace) + addNextCluster(lbh.currentPosition, end, lbh.spaceData, lbh.glyphCount, + current, lbh.logClusters, lbh.glyphs); if (!lbh.manualWrap && lbh.spaceData.textWidth > line.width) { lbh.spaceData.textWidth = line.width; // ignore spaces that fall out of the line. @@ -1823,19 +1867,19 @@ void QTextLine::layout_helper(int maxGlyphs) } else { bool sb_or_ws = false; do { - addNextCluster(pos, end, lbh.tmpData, lbh.glyphCount, - current, logClusters, glyphs); + addNextCluster(lbh.currentPosition, end, lbh.tmpData, lbh.glyphCount, + current, lbh.logClusters, lbh.glyphs); - if (attributes[pos].whiteSpace || attributes[pos-1].lineBreakType != HB_NoBreak) { + if (attributes[lbh.currentPosition].whiteSpace || attributes[lbh.currentPosition-1].lineBreakType != HB_NoBreak) { sb_or_ws = true; break; - } else if (breakany && attributes[pos].charStop) { + } else if (breakany && attributes[lbh.currentPosition].charStop) { break; } - } while (pos < end); + } while (lbh.currentPosition < end); lbh.minw = qMax(lbh.tmpData.textWidth, lbh.minw); - if (pos && attributes[pos - 1].lineBreakType == HB_SoftHyphen) { + if (lbh.currentPosition && attributes[lbh.currentPosition - 1].lineBreakType == HB_SoftHyphen) { // if we are splitting up a word because of // a soft hyphen then we ... // @@ -1853,43 +1897,40 @@ void QTextLine::layout_helper(int maxGlyphs) // and thus become invisible again. // if (line.length) - lbh.softHyphenWidth = glyphs.advances_x[logClusters[pos - 1]]; + lbh.softHyphenWidth = lbh.glyphs.advances_x[lbh.logClusters[lbh.currentPosition - 1]]; else if (breakany) - lbh.tmpData.textWidth += glyphs.advances_x[logClusters[pos - 1]]; + lbh.tmpData.textWidth += lbh.glyphs.advances_x[lbh.logClusters[lbh.currentPosition - 1]]; } // The actual width of the text needs to take the right bearing into account. The // right bearing is left-ward, which means that if the rightmost pixel is to the right // of the advance of the glyph, the bearing will be negative. We flip the sign // for the code to be more readable. Logic borrowed from qfontmetrics.cpp. - if (pos) { - QFontEngine *fontEngine = eng->fontEngine(current); - glyph_t glyph = glyphs.glyphs[logClusters[pos - 1]]; - glyph_metrics_t gi = fontEngine->boundingBox(glyph); - if (gi.isValid()) - lbh.rightBearing = qMax(QFixed(), -(gi.xoff - gi.x - gi.width)); - } + // We ignore the right bearing if the minimum negative bearing is too little to + // expand the text beyond the edge. + if (sb_or_ws|breakany) { + if (lbh.calculateNewWidth(line) + lbh.minimumRightBearing > line.width) + lbh.adjustRightBearing(); + if (lbh.checkFullOtherwiseExtend(line)) { + if (!breakany) { + line.textWidth += lbh.softHyphenWidth; + } - if ((sb_or_ws|breakany) && lbh.checkFullOtherwiseExtend(line)) { - if (!breakany) { - line.textWidth += lbh.softHyphenWidth; + goto found; } - - line.textAdvance = line.textWidth; - line.textWidth += lbh.rightBearing; - - goto found; } } - if (pos == end) + if (lbh.currentPosition == end) newItem = item + 1; } LB_DEBUG("reached end of line"); lbh.checkFullOtherwiseExtend(line); +found: + if (lbh.rightBearing > 0) // If right bearing has not yet been adjusted + lbh.adjustRightBearing(); line.textAdvance = line.textWidth; - line.textWidth += lbh.rightBearing; + line.textWidth -= qMin(QFixed(), lbh.rightBearing); -found: if (line.length == 0) { LB_DEBUG("no break available in line, adding temp: length %d, width %f, space: length %d, width %f", lbh.tmpData.length, lbh.tmpData.textWidth.toReal(), diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 806452c..1d8224c 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -353,6 +353,7 @@ void QHttpNetworkConnectionChannel::_q_receiveReply() replyPrivate->autoDecompress = false; } if (replyPrivate->statusCode == 100) { + replyPrivate->clearHttpLayerInformation(); replyPrivate->state = QHttpNetworkReplyPrivate::ReadingStatusState; break; // ignore } diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp index 984f557..338236e 100644 --- a/src/network/access/qhttpnetworkreply.cpp +++ b/src/network/access/qhttpnetworkreply.cpp @@ -219,7 +219,7 @@ QHttpNetworkReplyPrivate::~QHttpNetworkReplyPrivate() { } -void QHttpNetworkReplyPrivate::clear() +void QHttpNetworkReplyPrivate::clearHttpLayerInformation() { state = NothingDoneState; statusCode = 100; @@ -229,18 +229,24 @@ void QHttpNetworkReplyPrivate::clear() currentChunkSize = 0; currentChunkRead = 0; connectionCloseEnabled = true; - connection = 0; - connectionChannel = 0; #ifndef QT_NO_COMPRESS if (initInflate) inflateEnd(&inflateStrm); #endif initInflate = false; streamEnd = false; - autoDecompress = false; fields.clear(); } +// TODO: Isn't everything HTTP layer related? We don't need to set connection and connectionChannel to 0 at all +void QHttpNetworkReplyPrivate::clear() +{ + connection = 0; + connectionChannel = 0; + autoDecompress = false; + clearHttpLayerInformation(); +} + // QHttpNetworkReplyPrivate qint64 QHttpNetworkReplyPrivate::bytesAvailable() const { @@ -539,6 +545,11 @@ qint64 QHttpNetworkReplyPrivate::readHeader(QAbstractSocket *socket) || fragment.endsWith("\r\n\n") || fragment.endsWith("\n\n")) allHeaders = true; + + // there is another case: We have no headers. Then the fragment equals just the line ending + if ((fragment.length() == 2 && fragment.endsWith("\r\n")) + || (fragment.length() == 1 && fragment.endsWith("\n"))) + allHeaders = true; } } } while (!allHeaders && haveRead > 0); diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h index fa240ec..4011c78 100644 --- a/src/network/access/qhttpnetworkreply_p.h +++ b/src/network/access/qhttpnetworkreply_p.h @@ -172,6 +172,7 @@ public: bool findChallenge(bool forProxy, QByteArray &challenge) const; QAuthenticatorPrivate::Method authenticationMethod(bool isProxy) const; void clear(); + void clearHttpLayerInformation(); qint64 readReplyBodyRaw(QIODevice *in, QByteDataBuffer *out, qint64 size); qint64 readReplyBodyChunked(QIODevice *in, QByteDataBuffer *out); diff --git a/src/openvg/openvg.pro b/src/openvg/openvg.pro index c8c9917..3790492 100644 --- a/src/openvg/openvg.pro +++ b/src/openvg/openvg.pro @@ -33,6 +33,8 @@ contains(QT_CONFIG, egl) { qwindowsurface_vgegl.cpp } +symbian: DEFINES += QVG_RECREATE_ON_SIZE_CHANGE + include(../qbase.pri) unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp index 53f6b4c..e66d80b 100644 --- a/src/openvg/qpixmapdata_vg.cpp +++ b/src/openvg/qpixmapdata_vg.cpp @@ -45,10 +45,10 @@ #include "qvg_p.h" #include "qvgimagepool_p.h" -#ifdef QT_SYMBIAN_SUPPORTS_SGIMAGE #include <private/qt_s60_p.h> #include <fbs.h> -#include <graphics/sgimage.h> +#ifdef QT_SYMBIAN_SUPPORTS_SGIMAGE +#include <sgresource/sgimage.h> typedef EGLImageKHR (*pfnEglCreateImageKHR)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, EGLint*); typedef EGLBoolean (*pfnEglDestroyImageKHR)(EGLDisplay, EGLImageKHR); typedef VGImage (*pfnVgCreateEGLImageTargetKHR)(VGeglImageKHR); @@ -465,23 +465,24 @@ void QVGPixmapData::fromNativeType(void* pixmap, NativeType type) TInt err = 0; - err = SgDriver::Open(); - if(err != KErrNone) { + RSgDriver driver; + err = driver.Open(); + if (err != KErrNone) { cleanup(); return; } - if(sgImage->IsNull()) { + if (sgImage->IsNull()) { cleanup(); - SgDriver::Close(); + driver.Close(); return; } TSgImageInfo sgImageInfo; err = sgImage->GetInfo(sgImageInfo); - if(err != KErrNone) { + if (err != KErrNone) { cleanup(); - SgDriver::Close(); + driver.Close(); return; } @@ -489,9 +490,9 @@ void QVGPixmapData::fromNativeType(void* pixmap, NativeType type) pfnEglDestroyImageKHR eglDestroyImageKHR = (pfnEglDestroyImageKHR) eglGetProcAddress("eglDestroyImageKHR"); pfnVgCreateEGLImageTargetKHR vgCreateEGLImageTargetKHR = (pfnVgCreateEGLImageTargetKHR) eglGetProcAddress("vgCreateEGLImageTargetKHR"); - if(eglGetError() != EGL_SUCCESS || !eglCreateImageKHR || !eglDestroyImageKHR || !vgCreateEGLImageTargetKHR) { + if (eglGetError() != EGL_SUCCESS || !eglCreateImageKHR || !eglDestroyImageKHR || !vgCreateEGLImageTargetKHR) { cleanup(); - SgDriver::Close(); + driver.Close(); return; } @@ -502,17 +503,17 @@ void QVGPixmapData::fromNativeType(void* pixmap, NativeType type) (EGLClientBuffer)sgImage, (EGLint*)KEglImageAttribs); - if(eglGetError() != EGL_SUCCESS) { + if (eglGetError() != EGL_SUCCESS) { cleanup(); - SgDriver::Close(); + driver.Close(); return; } vgImage = vgCreateEGLImageTargetKHR(eglImage); - if(vgGetError() != VG_NO_ERROR) { + if (vgGetError() != VG_NO_ERROR) { cleanup(); eglDestroyImageKHR(QEgl::display(), eglImage); - SgDriver::Close(); + driver.Close(); return; } @@ -526,7 +527,7 @@ void QVGPixmapData::fromNativeType(void* pixmap, NativeType type) setSerialNumber(++qt_vg_pixmap_serial); // release stuff eglDestroyImageKHR(QEgl::display(), eglImage); - SgDriver::Close(); + driver.Close(); } else if (type == QPixmapData::FbsBitmap) { CFbsBitmap *bitmap = reinterpret_cast<CFbsBitmap*>(pixmap); @@ -584,29 +585,25 @@ void* QVGPixmapData::toNativeType(NativeType type) if (type == QPixmapData::SgImage) { toVGImage(); - if(!isValid() || vgImage == VG_INVALID_HANDLE) + if (!isValid() || vgImage == VG_INVALID_HANDLE) return 0; TInt err = 0; - err = SgDriver::Open(); - if(err != KErrNone) + RSgDriver driver; + err = driver.Open(); + if (err != KErrNone) return 0; TSgImageInfo sgInfo; sgInfo.iPixelFormat = EUidPixelFormatARGB_8888_PRE; sgInfo.iSizeInPixels.SetSize(w, h); - sgInfo.iUsage = ESgUsageOpenVgImage | ESgUsageOpenVgTarget; - sgInfo.iShareable = ETrue; - sgInfo.iCpuAccess = ESgCpuAccessNone; - sgInfo.iScreenId = KSgScreenIdMain; //KSgScreenIdAny; - sgInfo.iUserAttributes = NULL; - sgInfo.iUserAttributeCount = 0; + sgInfo.iUsage = ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface; RSgImage *sgImage = q_check_ptr(new RSgImage()); err = sgImage->Create(sgInfo, NULL, NULL); - if(err != KErrNone) { - SgDriver::Close(); + if (err != KErrNone) { + driver.Close(); return 0; } @@ -614,8 +611,8 @@ void* QVGPixmapData::toNativeType(NativeType type) pfnEglDestroyImageKHR eglDestroyImageKHR = (pfnEglDestroyImageKHR) eglGetProcAddress("eglDestroyImageKHR"); pfnVgCreateEGLImageTargetKHR vgCreateEGLImageTargetKHR = (pfnVgCreateEGLImageTargetKHR) eglGetProcAddress("vgCreateEGLImageTargetKHR"); - if(eglGetError() != EGL_SUCCESS || !eglCreateImageKHR || !eglDestroyImageKHR || !vgCreateEGLImageTargetKHR) { - SgDriver::Close(); + if (eglGetError() != EGL_SUCCESS || !eglCreateImageKHR || !eglDestroyImageKHR || !vgCreateEGLImageTargetKHR) { + driver.Close(); return 0; } @@ -625,17 +622,17 @@ void* QVGPixmapData::toNativeType(NativeType type) EGL_NATIVE_PIXMAP_KHR, (EGLClientBuffer)sgImage, (EGLint*)KEglImageAttribs); - if(eglGetError() != EGL_SUCCESS) { + if (eglGetError() != EGL_SUCCESS) { sgImage->Close(); - SgDriver::Close(); + driver.Close(); return 0; } VGImage dstVgImage = vgCreateEGLImageTargetKHR(eglImage); - if(vgGetError() != VG_NO_ERROR) { + if (vgGetError() != VG_NO_ERROR) { eglDestroyImageKHR(QEgl::display(), eglImage); sgImage->Close(); - SgDriver::Close(); + driver.Close(); return 0; } @@ -643,14 +640,14 @@ void* QVGPixmapData::toNativeType(NativeType type) vgImage, 0, 0, w, h, VG_FALSE); - if(vgGetError() != VG_NO_ERROR) { + if (vgGetError() != VG_NO_ERROR) { sgImage->Close(); sgImage = 0; } // release stuff vgDestroyImage(dstVgImage); eglDestroyImageKHR(QEgl::display(), eglImage); - SgDriver::Close(); + driver.Close(); return reinterpret_cast<void*>(sgImage); } else if (type == QPixmapData::FbsBitmap) { CFbsBitmap *bitmap = q_check_ptr(new CFbsBitmap); diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index cfaca9d..da41f18 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -20,13 +20,16 @@ phonon_mmf_audio_drm { # '#include <videoplayer.h>' picks up the Symbian header, as intended. PREPEND_INCLUDEPATH = /epoc32/include +PREPEND_INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty + INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE HEADERS += \ $$PHONON_MMF_DIR/abstractaudioeffect.h \ $$PHONON_MMF_DIR/abstractmediaplayer.h \ $$PHONON_MMF_DIR/abstractplayer.h \ - $$PHONON_MMF_DIR/ancestormovemonitor.h \ + $$PHONON_MMF_DIR/abstractvideooutput.h \ + $$PHONON_MMF_DIR/abstractvideoplayer.h \ $$PHONON_MMF_DIR/audioequalizer.h \ $$PHONON_MMF_DIR/audiooutput.h \ $$PHONON_MMF_DIR/audioplayer.h \ @@ -40,23 +43,22 @@ HEADERS += \ $$PHONON_MMF_DIR/loudness.h \ $$PHONON_MMF_DIR/mediaobject.h \ $$PHONON_MMF_DIR/mmf_medianode.h \ - $$PHONON_MMF_DIR/mmf_videoplayer.h \ $$PHONON_MMF_DIR/stereowidening.h \ $$PHONON_MMF_DIR/objectdump.h \ $$PHONON_MMF_DIR/objectdump_symbian.h \ $$PHONON_MMF_DIR/objecttree.h \ $$PHONON_MMF_DIR/utils.h \ - $$PHONON_MMF_DIR/videooutput.h \ $$PHONON_MMF_DIR/videowidget.h SOURCES += \ $$PHONON_MMF_DIR/abstractaudioeffect.cpp \ $$PHONON_MMF_DIR/abstractmediaplayer.cpp \ $$PHONON_MMF_DIR/abstractplayer.cpp \ - $$PHONON_MMF_DIR/ancestormovemonitor.cpp \ $$PHONON_MMF_DIR/audioequalizer.cpp \ $$PHONON_MMF_DIR/audiooutput.cpp \ $$PHONON_MMF_DIR/audioplayer.cpp \ + $$PHONON_MMF_DIR/abstractvideooutput.cpp \ + $$PHONON_MMF_DIR/abstractvideoplayer.cpp \ $$PHONON_MMF_DIR/backend.cpp \ $$PHONON_MMF_DIR/bassboost.cpp \ $$PHONON_MMF_DIR/dummyplayer.cpp \ @@ -66,15 +68,34 @@ SOURCES += \ $$PHONON_MMF_DIR/loudness.cpp \ $$PHONON_MMF_DIR/mediaobject.cpp \ $$PHONON_MMF_DIR/mmf_medianode.cpp \ - $$PHONON_MMF_DIR/mmf_videoplayer.cpp \ $$PHONON_MMF_DIR/stereowidening.cpp \ $$PHONON_MMF_DIR/objectdump.cpp \ $$PHONON_MMF_DIR/objectdump_symbian.cpp \ $$PHONON_MMF_DIR/objecttree.cpp \ $$PHONON_MMF_DIR/utils.cpp \ - $$PHONON_MMF_DIR/videooutput.cpp \ $$PHONON_MMF_DIR/videowidget.cpp +# Test for whether the build environment supports video rendering to graphics +# surfaces. +exists($${EPOCROOT}epoc32/include/platform/videoplayer2.h) { + HEADERS += \ + $$PHONON_MMF_DIR/videooutput_surface.h \ + $$PHONON_MMF_DIR/videoplayer_surface.h + SOURCES += \ + $$PHONON_MMF_DIR/videooutput_surface.cpp \ + $$PHONON_MMF_DIR/videoplayer_surface.cpp + DEFINES += PHONON_MMF_VIDEO_SURFACES +} else { + HEADERS += \ + $$PHONON_MMF_DIR/ancestormovemonitor.h \ + $$PHONON_MMF_DIR/videooutput_dsa.h \ + $$PHONON_MMF_DIR/videoplayer_dsa.h + SOURCES += \ + $$PHONON_MMF_DIR/ancestormovemonitor.cpp \ + $$PHONON_MMF_DIR/videooutput_dsa.cpp \ + $$PHONON_MMF_DIR/videoplayer_dsa.cpp \ +} + LIBS += -lcone LIBS += -lws32 diff --git a/src/plugins/qpluginbase.pri b/src/plugins/qpluginbase.pri index 3dd3d2e..8b119b5 100644 --- a/src/plugins/qpluginbase.pri +++ b/src/plugins/qpluginbase.pri @@ -17,5 +17,6 @@ wince*:LIBS += $$QMAKE_LIBS_GUI symbian: { TARGET.EPOCALLOWDLLDATA=1 TARGET.CAPABILITY = All -Tcb + TARGET = $${TARGET}$${QT_LIBINFIX} load(armcc_warnings) } diff --git a/src/plugins/s60/3_1/3_1.pro b/src/plugins/s60/3_1/3_1.pro index 58ff5ce..9437f3d 100644 --- a/src/plugins/s60/3_1/3_1.pro +++ b/src/plugins/s60/3_1/3_1.pro @@ -1,6 +1,6 @@ include(../s60pluginbase.pri) -TARGET = qts60plugin_3_1 +TARGET = qts60plugin_3_1$${QT_LIBINFIX} SOURCES += ../src/qlocale_3_1.cpp \ ../src/qdesktopservices_3_1.cpp \ diff --git a/src/plugins/s60/3_2/3_2.pro b/src/plugins/s60/3_2/3_2.pro index 7700677..0524866 100644 --- a/src/plugins/s60/3_2/3_2.pro +++ b/src/plugins/s60/3_2/3_2.pro @@ -1,6 +1,6 @@ include(../s60pluginbase.pri) -TARGET = qts60plugin_3_2 +TARGET = qts60plugin_3_2$${QT_LIBINFIX} contains(S60_VERSION, 3.1) { SOURCES += ../src/qlocale_3_1.cpp \ diff --git a/src/plugins/s60/5_0/5_0.pro b/src/plugins/s60/5_0/5_0.pro index 164dfaa..00aea1b 100644 --- a/src/plugins/s60/5_0/5_0.pro +++ b/src/plugins/s60/5_0/5_0.pro @@ -1,6 +1,6 @@ include(../s60pluginbase.pri) -TARGET = qts60plugin_5_0 +TARGET = qts60plugin_5_0$${QT_LIBINFIX} contains(S60_VERSION, 3.1) { SOURCES += ../src/qlocale_3_1.cpp \ diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index b2e873f..db1ee4d 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -7,25 +7,38 @@ symbian: { SUBDIRS= # WARNING: Changing TARGET name will break Symbian SISX upgrade functionality # DO NOT TOUCH TARGET VARIABLE IF YOU ARE NOT SURE WHAT YOU ARE DOING - TARGET = "Qt" - TARGET.UID3 = 0x2001E61C + TARGET = "Qt$${QT_LIBINFIX}" + + isEmpty(QT_LIBINFIX) { + TARGET.UID3 = 0x2001E61C + + # sqlite3 is expected to be already found on phone if infixed configuration is built. + sqlitedeployment = \ + "; Deploy sqlite onto phone that does not have it already" \ + "@\"$$PWD/sqlite3.sis\", (0x2002af5f)" + qtlibraries.pkg_postrules += sqlitedeployment + } else { + # Always use experimental UID for infixed configuration to avoid UID clash + TARGET.UID3 = 0xE001E61C + } VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION} symbian-abld|symbian-sbsv2 { - qtresources.sources = $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/s60main.rsc + qtresources.sources = $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/s60main$${QT_LIBINFIX}.rsc } else { - qtresources.sources = $$QMAKE_LIBDIR_QT/s60main.rsc + qtresources.sources = $$QMAKE_LIBDIR_QT/s60main$${QT_LIBINFIX}.rsc DESTDIR = $$QMAKE_LIBDIR_QT } qtresources.path = c:$$APP_RESOURCE_DIR + DEPLOYMENT += qtresources qtlibraries.sources = \ - $$QMAKE_LIBDIR_QT/QtCore.dll \ - $$QMAKE_LIBDIR_QT/QtXml.dll \ - $$QMAKE_LIBDIR_QT/QtGui.dll \ - $$QMAKE_LIBDIR_QT/QtNetwork.dll \ - $$QMAKE_LIBDIR_QT/QtTest.dll \ - $$QMAKE_LIBDIR_QT/QtSql.dll + $$QMAKE_LIBDIR_QT/QtCore$${QT_LIBINFIX}.dll \ + $$QMAKE_LIBDIR_QT/QtXml$${QT_LIBINFIX}.dll \ + $$QMAKE_LIBDIR_QT/QtGui$${QT_LIBINFIX}.dll \ + $$QMAKE_LIBDIR_QT/QtNetwork$${QT_LIBINFIX}.dll \ + $$QMAKE_LIBDIR_QT/QtTest$${QT_LIBINFIX}.dll \ + $$QMAKE_LIBDIR_QT/QtSql$${QT_LIBINFIX}.dll symbian-abld|symbian-sbsv2 { pluginLocations = $${EPOCROOT}epoc32/release/$(PLATFORM)/$(TARGET) @@ -35,20 +48,16 @@ symbian: { qts60plugindeployment = \ "IF package(0x1028315F)" \ - " \"$$pluginLocations/qts60plugin_5_0.dll\" - \"c:\\sys\\bin\\qts60plugin_5_0.dll\"" \ + " \"$$pluginLocations/qts60plugin_5_0$${QT_LIBINFIX}.dll\" - \"c:\\sys\\bin\\qts60plugin_5_0$${QT_LIBINFIX}.dll\"" \ "ELSEIF package(0x102752AE)" \ - " \"$$pluginLocations/qts60plugin_3_2.dll\" - \"c:\\sys\\bin\\qts60plugin_3_2.dll\"" \ + " \"$$pluginLocations/qts60plugin_3_2$${QT_LIBINFIX}.dll\" - \"c:\\sys\\bin\\qts60plugin_3_2$${QT_LIBINFIX}.dll\"" \ "ELSEIF package(0x102032BE)" \ - " \"$$pluginLocations/qts60plugin_3_1.dll\" - \"c:\\sys\\bin\\qts60plugin_3_1.dll\"" \ + " \"$$pluginLocations/qts60plugin_3_1$${QT_LIBINFIX}.dll\" - \"c:\\sys\\bin\\qts60plugin_3_1$${QT_LIBINFIX}.dll\"" \ "ELSE" \ - " \"$$pluginLocations/qts60plugin_5_0.dll\" - \"c:\\sys\\bin\\qts60plugin_5_0.dll\"" \ + " \"$$pluginLocations/qts60plugin_5_0$${QT_LIBINFIX}.dll\" - \"c:\\sys\\bin\\qts60plugin_5_0$${QT_LIBINFIX}.dll\"" \ "ENDIF" qtlibraries.pkg_postrules += qts60plugindeployment - sqlitedeployment = \ - "; Deploy sqlite onto phone that does not have it already" \ - "@\"$$PWD/sqlite3.sis\", (0x2002af5f)" - qtlibraries.pkg_postrules += sqlitedeployment qtlibraries.path = c:/sys/bin @@ -72,18 +81,18 @@ symbian: { } qtlibraries.pkg_prerules += "(0x2002af5f), 0, 5, 0, {\"sqlite3\"}" - !contains(QT_CONFIG, no-jpeg): imageformats_plugins.sources += $$QT_BUILD_TREE/plugins/imageformats/qjpeg.dll - !contains(QT_CONFIG, no-gif): imageformats_plugins.sources += $$QT_BUILD_TREE/plugins/imageformats/qgif.dll - !contains(QT_CONFIG, no-mng): imageformats_plugins.sources += $$QT_BUILD_TREE/plugins/imageformats/qmng.dll - !contains(QT_CONFIG, no-tiff): imageformats_plugins.sources += $$QT_BUILD_TREE/plugins/imageformats/qtiff.dll - !contains(QT_CONFIG, no-ico): imageformats_plugins.sources += $$QT_BUILD_TREE/plugins/imageformats/qico.dll + !contains(QT_CONFIG, no-jpeg): imageformats_plugins.sources += $$QT_BUILD_TREE/plugins/imageformats/qjpeg$${QT_LIBINFIX}.dll + !contains(QT_CONFIG, no-gif): imageformats_plugins.sources += $$QT_BUILD_TREE/plugins/imageformats/qgif$${QT_LIBINFIX}.dll + !contains(QT_CONFIG, no-mng): imageformats_plugins.sources += $$QT_BUILD_TREE/plugins/imageformats/qmng$${QT_LIBINFIX}.dll + !contains(QT_CONFIG, no-tiff): imageformats_plugins.sources += $$QT_BUILD_TREE/plugins/imageformats/qtiff$${QT_LIBINFIX}.dll + !contains(QT_CONFIG, no-ico): imageformats_plugins.sources += $$QT_BUILD_TREE/plugins/imageformats/qico$${QT_LIBINFIX}.dll imageformats_plugins.path = c:$$QT_PLUGINS_BASE_DIR/imageformats - codecs_plugins.sources = $$QT_BUILD_TREE/plugins/codecs/qcncodecs.dll $$QT_BUILD_TREE/plugins/codecs/qjpcodecs.dll $$QT_BUILD_TREE/plugins/codecs/qtwcodecs.dll $$QT_BUILD_TREE/plugins/codecs/qkrcodecs.dll + codecs_plugins.sources = $$QT_BUILD_TREE/plugins/codecs/qcncodecs$${QT_LIBINFIX}.dll $$QT_BUILD_TREE/plugins/codecs/qjpcodecs$${QT_LIBINFIX}.dll $$QT_BUILD_TREE/plugins/codecs/qtwcodecs$${QT_LIBINFIX}.dll $$QT_BUILD_TREE/plugins/codecs/qkrcodecs$${QT_LIBINFIX}.dll codecs_plugins.path = c:$$QT_PLUGINS_BASE_DIR/codecs contains(QT_CONFIG, phonon-backend) { - phonon_backend_plugins.sources += $$QMAKE_LIBDIR_QT/phonon_mmf.dll + phonon_backend_plugins.sources += $$QMAKE_LIBDIR_QT/phonon_mmf$${QT_LIBINFIX}.dll phonon_backend_plugins.path = c:$$QT_PLUGINS_BASE_DIR/phonon_backend DEPLOYMENT += phonon_backend_plugins @@ -94,10 +103,9 @@ symbian: { qtbackup.path = c:/private/10202D56/import/packages/$$replace(TARGET.UID3, 0x,) bearer_plugins.path = c:$$QT_PLUGINS_BASE_DIR/bearer - bearer_plugins.sources += $$QT_BUILD_TREE/plugins/bearer/qsymbianbearer.dll + bearer_plugins.sources += $$QT_BUILD_TREE/plugins/bearer/qsymbianbearer$${QT_LIBINFIX}.dll - DEPLOYMENT += qtresources \ - qtlibraries \ + DEPLOYMENT += qtlibraries \ qtbackup \ imageformats_plugins \ codecs_plugins \ @@ -105,37 +113,37 @@ symbian: { bearer_plugins contains(QT_CONFIG, svg): { - qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtSvg.dll - imageformats_plugins.sources += $$QT_BUILD_TREE/plugins/imageformats/qsvg.dll - iconengines_plugins.sources = $$QT_BUILD_TREE/plugins/iconengines/qsvgicon.dll + qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtSvg$${QT_LIBINFIX}.dll + imageformats_plugins.sources += $$QT_BUILD_TREE/plugins/imageformats/qsvg$${QT_LIBINFIX}.dll + iconengines_plugins.sources = $$QT_BUILD_TREE/plugins/iconengines/qsvgicon$${QT_LIBINFIX}.dll iconengines_plugins.path = c:$$QT_PLUGINS_BASE_DIR/iconengines DEPLOYMENT += iconengines_plugins } contains(QT_CONFIG, phonon): { - qtlibraries.sources += $$QMAKE_LIBDIR_QT/phonon.dll + qtlibraries.sources += $$QMAKE_LIBDIR_QT/phonon$${QT_LIBINFIX}.dll } contains(QT_CONFIG, script): { - qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtScript.dll + qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtScript$${QT_LIBINFIX}.dll } contains(QT_CONFIG, xmlpatterns): { - qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtXmlPatterns.dll + qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtXmlPatterns$${QT_LIBINFIX}.dll } contains(QT_CONFIG, declarative): { - qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtDeclarative.dll + qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtDeclarative$${QT_LIBINFIX}.dll } graphicssystems_plugins.path = c:$$QT_PLUGINS_BASE_DIR/graphicssystems contains(QT_CONFIG, openvg) { - qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtOpenVG.dll - graphicssystems_plugins.sources += $$QT_BUILD_TREE/plugins/graphicssystems/qvggraphicssystem.dll + qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtOpenVG$${QT_LIBINFIX}.dll + graphicssystems_plugins.sources += $$QT_BUILD_TREE/plugins/graphicssystems/qvggraphicssystem$${QT_LIBINFIX}.dll } contains(QT_CONFIG, multimedia) { - qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtMultimedia.dll + qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtMultimedia$${QT_LIBINFIX}.dll } BLD_INF_RULES.prj_exports += "qt.iby $$CORE_MW_LAYER_IBY_EXPORT_PATH(qt.iby)" diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 294c3a0..356b4d0 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -3318,7 +3318,7 @@ void QScriptEngine::installTranslatorFunctions(const QScriptValue &object) JSC::JSValue jscObject = d->scriptValueToJSCValue(object); JSC::JSGlobalObject *glob = d->originalGlobalObject(); if (!jscObject || !jscObject.isObject()) - jscObject = glob; + jscObject = d->globalObject(); // unsigned attribs = JSC::DontEnum; JSC::asObject(jscObject)->putDirectFunction(exec, new (exec)JSC::NativeFunctionWrapper(exec, glob->prototypeFunctionStructure(), 5, JSC::Identifier(exec, "qsTranslate"), QScript::functionQsTranslate)); JSC::asObject(jscObject)->putDirectFunction(exec, new (exec)JSC::NativeFunctionWrapper(exec, glob->prototypeFunctionStructure(), 2, JSC::Identifier(exec, "QT_TRANSLATE_NOOP"), QScript::functionQsTranslateNoOp)); diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index a3af2d4..5db1165 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -1609,7 +1609,7 @@ QScriptValue QScriptValue::call(const QScriptValue &thisObject, JSC::MarkedArgumentBuffer applyArgs; if (!array.isUndefinedOrNull()) { if (!array.isObject()) { - return d->engine->scriptValueFromJSCValue(JSC::throwError(exec, JSC::TypeError)); + return d->engine->scriptValueFromJSCValue(JSC::throwError(exec, JSC::TypeError, "Arguments must be an array")); } if (JSC::asObject(array)->classInfo() == &JSC::Arguments::info) JSC::asArguments(array)->fillArgList(exec, applyArgs); @@ -1620,8 +1620,7 @@ QScriptValue QScriptValue::call(const QScriptValue &thisObject, for (unsigned i = 0; i < length; ++i) applyArgs.append(JSC::asArray(array)->get(exec, i)); } else { - Q_ASSERT_X(false, Q_FUNC_INFO, "implement me"); -// return JSC::throwError(exec, JSC::TypeError); + return d->engine->scriptValueFromJSCValue(JSC::throwError(exec, JSC::TypeError, "Arguments must be an array")); } } diff --git a/src/script/bridge/qscriptclassobject.cpp b/src/script/bridge/qscriptclassobject.cpp index a7b5f48..dd229f1 100644 --- a/src/script/bridge/qscriptclassobject.cpp +++ b/src/script/bridge/qscriptclassobject.cpp @@ -234,7 +234,7 @@ JSC::JSObject* ClassObjectDelegate::construct(JSC::ExecState *exec, JSC::JSObjec QScriptClass *scriptClass = static_cast<ClassObjectDelegate*>(delegate)->scriptClass(); QScriptEnginePrivate *eng_p = scriptEngineFromExec(exec); - //JSC::ExecState *oldFrame = eng_p->currentFrame; + JSC::ExecState *oldFrame = eng_p->currentFrame; eng_p->pushContext(exec, JSC::JSValue(), args, callee, true); QScriptContext *ctx = eng_p->contextForFrame(eng_p->currentFrame); @@ -242,6 +242,8 @@ JSC::JSObject* ClassObjectDelegate::construct(JSC::ExecState *exec, JSC::JSObjec QScriptValue result = qvariant_cast<QScriptValue>(scriptClass->extension(QScriptClass::Callable, qVariantFromValue(ctx))); if (!result.isObject()) result = defaultObject; + eng_p->popContext(); + eng_p->currentFrame = oldFrame; return JSC::asObject(eng_p->scriptValueToJSCValue(result)); } diff --git a/src/src.pro b/src/src.pro index 0033942..c2ed59d 100644 --- a/src/src.pro +++ b/src/src.pro @@ -109,7 +109,8 @@ src_declarative.target = sub-declarative src_tools_idc.depends = src_corelib # target defined in tools.pro src_tools_uic3.depends = src_qt3support src_xml # target defined in tools.pro src_phonon.depends = src_gui - src_multimedia.depends = src_gui src_opengl + src_multimedia.depends = src_gui + contains(QT_CONFIG, opengl):src_multimedia.depends += src_opengl src_tools_activeqt.depends = src_tools_idc src_gui src_declarative.depends = src_xml src_gui src_script src_network src_svg src_plugins.depends = src_gui src_sql src_svg src_multimedia diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 6729c62..9a982d0 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -738,18 +738,23 @@ void Generator::generateMetacall() const PropertyDef &p = cdef->propertyList.at(propindex); if (p.read.isEmpty()) continue; + QByteArray prefix; + if (p.inPrivateClass.size()) { + prefix = p.inPrivateClass; + prefix.append("->"); + } if (p.gspec == PropertyDef::PointerSpec) - fprintf(out, " case %d: _a[0] = const_cast<void*>(reinterpret_cast<const void*>(%s())); break;\n", - propindex, p.read.constData()); + fprintf(out, " case %d: _a[0] = const_cast<void*>(reinterpret_cast<const void*>(%s%s())); break;\n", + propindex, prefix.constData(), p.read.constData()); else if (p.gspec == PropertyDef::ReferenceSpec) - fprintf(out, " case %d: _a[0] = const_cast<void*>(reinterpret_cast<const void*>(&%s())); break;\n", - propindex, p.read.constData()); + fprintf(out, " case %d: _a[0] = const_cast<void*>(reinterpret_cast<const void*>(&%s%s())); break;\n", + propindex, prefix.constData(), p.read.constData()); else if (cdef->enumDeclarations.value(p.type, false)) - fprintf(out, " case %d: *reinterpret_cast<int*>(_v) = QFlag(%s()); break;\n", - propindex, p.read.constData()); + fprintf(out, " case %d: *reinterpret_cast<int*>(_v) = QFlag(%s%s()); break;\n", + propindex, prefix.constData(), p.read.constData()); else - fprintf(out, " case %d: *reinterpret_cast< %s*>(_v) = %s(); break;\n", - propindex, p.type.constData(), p.read.constData()); + fprintf(out, " case %d: *reinterpret_cast< %s*>(_v) = %s%s(); break;\n", + propindex, p.type.constData(), prefix.constData(), p.read.constData()); } fprintf(out, " }\n"); } @@ -768,12 +773,17 @@ void Generator::generateMetacall() const PropertyDef &p = cdef->propertyList.at(propindex); if (p.write.isEmpty()) continue; + QByteArray prefix; + if (p.inPrivateClass.size()) { + prefix = p.inPrivateClass; + prefix.append("->"); + } if (cdef->enumDeclarations.value(p.type, false)) { - fprintf(out, " case %d: %s(QFlag(*reinterpret_cast<int*>(_v))); break;\n", - propindex, p.write.constData()); + fprintf(out, " case %d: %s%s(QFlag(*reinterpret_cast<int*>(_v))); break;\n", + propindex, prefix.constData(), p.write.constData()); } else { - fprintf(out, " case %d: %s(*reinterpret_cast< %s*>(_v)); break;\n", - propindex, p.write.constData(), p.type.constData()); + fprintf(out, " case %d: %s%s(*reinterpret_cast< %s*>(_v)); break;\n", + propindex, prefix.constData(), p.write.constData(), p.type.constData()); } } fprintf(out, " }\n"); @@ -791,8 +801,13 @@ void Generator::generateMetacall() const PropertyDef &p = cdef->propertyList.at(propindex); if (!p.reset.endsWith(')')) continue; - fprintf(out, " case %d: %s; break;\n", - propindex, p.reset.constData()); + QByteArray prefix; + if (p.inPrivateClass.size()) { + prefix = p.inPrivateClass; + prefix.append("->"); + } + fprintf(out, " case %d: %s%s; break;\n", + propindex, prefix.constData(), p.reset.constData()); } fprintf(out, " }\n"); } diff --git a/src/tools/moc/keywords.cpp b/src/tools/moc/keywords.cpp index abc6be0..df1ba0d 100644 --- a/src/tools/moc/keywords.cpp +++ b/src/tools/moc/keywords.cpp @@ -43,12 +43,12 @@ // DO NOT EDIT. static const short keyword_trans[][128] = { - {0,0,0,0,0,0,0,0,0,525,522,0,0,0,0,0, + {0,0,0,0,0,0,0,0,0,533,530,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 525,252,523,526,0,38,239,524,25,26,236,234,30,235,27,237, + 533,252,531,534,0,38,239,532,25,26,236,234,30,235,27,237, 22,22,22,22,22,22,22,22,22,22,34,41,23,39,24,43, 0,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,21,8,8,8,8,8,8,8,8,8,31,527,32,238,8, + 8,21,8,8,8,8,8,8,8,8,8,31,535,32,238,8, 0,1,2,3,4,5,6,7,8,9,8,8,10,11,12,13, 14,8,15,16,17,18,19,20,8,8,8,36,245,37,248,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -190,7 +190,7 @@ static const short keyword_trans[][128] = { {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,42,0,0,0,28,0, - 530,530,530,530,530,530,530,530,530,530,0,0,0,0,0,0, + 538,538,538,538,538,538,538,538,538,538,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -349,7 +349,7 @@ static const short keyword_trans[][128] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,529,0,0,0,0,528, + 0,0,0,0,0,0,0,0,0,0,537,0,0,0,0,536, 0,0,0,0,0,0,0,0,0,0,0,0,0,258,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -430,6 +430,14 @@ static const short keyword_trans[][128] = { {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 522,0,0,481,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,497,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,486, @@ -925,12 +933,12 @@ static const struct {CHARACTER, 0, 84, 478, CHARACTER}, {CHARACTER, 0, 69, 479, CHARACTER}, {CHARACTER, 0, 95, 480, CHARACTER}, - {CHARACTER, 0, 83, 481, CHARACTER}, + {CHARACTER, 48, 0, 0, CHARACTER}, {CHARACTER, 0, 76, 482, CHARACTER}, {CHARACTER, 0, 79, 483, CHARACTER}, {CHARACTER, 0, 84, 484, CHARACTER}, {Q_PRIVATE_SLOT_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 48, 0, 0, CHARACTER}, + {CHARACTER, 49, 0, 0, CHARACTER}, {CHARACTER, 0, 77, 487, CHARACTER}, {CHARACTER, 0, 79, 488, CHARACTER}, {CHARACTER, 0, 67, 489, CHARACTER}, @@ -967,6 +975,14 @@ static const struct {CHARACTER, 0, 76, 520, CHARACTER}, {CHARACTER, 0, 69, 521, CHARACTER}, {Q_SCRIPTABLE_TOKEN, 0, 0, 0, CHARACTER}, + {CHARACTER, 0, 82, 523, CHARACTER}, + {CHARACTER, 0, 79, 524, CHARACTER}, + {CHARACTER, 0, 80, 525, CHARACTER}, + {CHARACTER, 0, 69, 526, CHARACTER}, + {CHARACTER, 0, 82, 527, CHARACTER}, + {CHARACTER, 0, 84, 528, CHARACTER}, + {CHARACTER, 0, 89, 529, CHARACTER}, + {Q_PRIVATE_PROPERTY_TOKEN, 0, 0, 0, CHARACTER}, {NEWLINE, 0, 0, 0, NOTOKEN}, {QUOTE, 0, 0, 0, NOTOKEN}, {SINGLEQUOTE, 0, 0, 0, NOTOKEN}, diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 94ad56f..680b8a5 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -658,6 +658,9 @@ void Moc::parse() case Q_PRIVATE_SLOT_TOKEN: parseSlotInPrivate(&def, access); break; + case Q_PRIVATE_PROPERTY_TOKEN: + parsePrivateProperty(&def); + break; case ENUM: { EnumDef enumDef; if (parseEnum(&enumDef)) @@ -872,11 +875,8 @@ void Moc::parseSignals(ClassDef *def) } } - -void Moc::parseProperty(ClassDef *def) +void Moc::createPropertyDef(PropertyDef &propDef) { - next(LPAREN); - PropertyDef propDef; QByteArray type = parseType().name; if (type.isEmpty()) error(); @@ -964,7 +964,6 @@ void Moc::parseProperty(ClassDef *def) error(2); } } - next(RPAREN); if (propDef.read.isNull()) { QByteArray msg; msg += "Property declaration "; @@ -988,6 +987,41 @@ void Moc::parseProperty(ClassDef *def) propDef.constant = false; warning(msg.constData()); } +} + +void Moc::parseProperty(ClassDef *def) +{ + next(LPAREN); + PropertyDef propDef; + createPropertyDef(propDef); + next(RPAREN); + + + if(!propDef.notify.isEmpty()) + def->notifyableProperties++; + def->propertyList += propDef; +} + +void Moc::parsePrivateProperty(ClassDef *def) +{ + next(LPAREN); + PropertyDef propDef; + next(IDENTIFIER); + propDef.inPrivateClass = lexem(); + while (test(SCOPE)) { + propDef.inPrivateClass += lexem(); + next(IDENTIFIER); + propDef.inPrivateClass += lexem(); + } + // also allow void functions + if (test(LPAREN)) { + next(RPAREN); + propDef.inPrivateClass += "()"; + } + + next(COMMA); + + createPropertyDef(propDef); if(!propDef.notify.isEmpty()) def->notifyableProperties++; diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h index 10abfc6..d365ed5 100644 --- a/src/tools/moc/moc.h +++ b/src/tools/moc/moc.h @@ -116,7 +116,7 @@ struct FunctionDef struct PropertyDef { PropertyDef():notifyId(-1), constant(false), final(false), gspec(ValueSpec){} - QByteArray name, type, read, write, reset, designable, scriptable, editable, stored, user, notify; + QByteArray name, type, read, write, reset, designable, scriptable, editable, stored, user, notify, inPrivateClass; int notifyId; bool constant; bool final; @@ -217,6 +217,7 @@ public: void parseSlots(ClassDef *def, FunctionDef::Access access); void parseSignals(ClassDef *def); void parseProperty(ClassDef *def); + void createPropertyDef(PropertyDef &def); void parseEnumOrFlag(ClassDef *def, bool isFlag); void parseFlag(ClassDef *def); void parseClassInfo(ClassDef *def); @@ -224,6 +225,7 @@ public: void parseDeclareInterface(); void parseDeclareMetatype(); void parseSlotInPrivate(ClassDef *def, FunctionDef::Access access); + void parsePrivateProperty(ClassDef *def); void parseFunctionArguments(FunctionDef *def); diff --git a/src/tools/moc/token.cpp b/src/tools/moc/token.cpp index 98307a1..3da9446 100644 --- a/src/tools/moc/token.cpp +++ b/src/tools/moc/token.cpp @@ -179,6 +179,7 @@ const char *tokenTypeName(Token t) case Q_SIGNAL_TOKEN: return "Q_SIGNAL_TOKEN"; case Q_SLOT_TOKEN: return "Q_SLOT_TOKEN"; case Q_PRIVATE_SLOT_TOKEN: return "Q_PRIVATE_SLOT_TOKEN"; + case Q_PRIVATE_PROPERTY_TOKEN: return "Q_PRIVATE_PROPERTY_TOKEN"; case SPECIAL_TREATMENT_MARK: return "SPECIAL_TREATMENT_MARK"; case MOC_INCLUDE_BEGIN: return "MOC_INCLUDE_BEGIN"; case MOC_INCLUDE_END: return "MOC_INCLUDE_END"; diff --git a/src/tools/moc/token.h b/src/tools/moc/token.h index 6b1ad7d..6ca3d84 100644 --- a/src/tools/moc/token.h +++ b/src/tools/moc/token.h @@ -185,6 +185,7 @@ enum Token { Q_QT3_SUPPORT_TOKEN, Q_INVOKABLE_TOKEN, Q_SCRIPTABLE_TOKEN, + Q_PRIVATE_PROPERTY_TOKEN, Q_META_TOKEN_END, SPECIAL_TREATMENT_MARK = Q_META_TOKEN_END, MOC_INCLUDE_BEGIN, diff --git a/src/tools/moc/util/generate_keywords.cpp b/src/tools/moc/util/generate_keywords.cpp index 0641b40..88f187d 100644 --- a/src/tools/moc/util/generate_keywords.cpp +++ b/src/tools/moc/util/generate_keywords.cpp @@ -248,7 +248,7 @@ static const Keyword keywords[] = { { "Q_SIGNAL", "Q_SIGNAL_TOKEN" }, { "Q_SLOT", "Q_SLOT_TOKEN" }, { "Q_SCRIPTABLE", "Q_SCRIPTABLE_TOKEN" }, - + { "Q_PRIVATE_PROPERTY", "Q_PRIVATE_PROPERTY_TOKEN" }, { "\n", "NEWLINE" }, { "\"", "QUOTE" }, { "\'", "SINGLEQUOTE" }, diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 497e720..c0004f7 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -18,6 +18,5 @@ contains(QT_CONFIG, webkit): SUBDIRS += webkit.pro contains(QT_CONFIG, multimedia): SUBDIRS += multimedia.pro contains(QT_CONFIG, phonon): SUBDIRS += phonon.pro contains(QT_CONFIG, svg): SUBDIRS += svg.pro -contains(QT_CONFIG, declarative): SUBDIRS += declarative - +contains(QT_CONFIG, declarative): SUBDIRS += declarative.pro diff --git a/tests/auto/declarative.pro b/tests/auto/declarative.pro new file mode 100644 index 0000000..f2173f0 --- /dev/null +++ b/tests/auto/declarative.pro @@ -0,0 +1,4 @@ +TEMPLATE=subdirs +SUBDIRS=\ + declarative \ + diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index 36eade8..eb74244 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -1,7 +1,6 @@ TEMPLATE = subdirs SUBDIRS += \ graphicswidgets \ # Cover - layouts \ # Cover parserstress \ # Cover qmetaobjectbuilder \ # Cover qdeclarativeanimations \ # Cover @@ -29,6 +28,7 @@ SUBDIRS += \ qdeclarativeitem \ # Cover qdeclarativelistview \ # Cover qdeclarativeloader \ # Cover + qdeclarativelayouts \ # Cover qdeclarativemousearea \ # Cover qdeclarativeparticles \ # Cover qdeclarativepathview \ # Cover diff --git a/tests/auto/declarative/layouts/data/layouts.qml b/tests/auto/declarative/qdeclarativelayouts/data/layouts.qml index 1792500..1792500 100644 --- a/tests/auto/declarative/layouts/data/layouts.qml +++ b/tests/auto/declarative/qdeclarativelayouts/data/layouts.qml diff --git a/tests/auto/declarative/layouts/layouts.pro b/tests/auto/declarative/qdeclarativelayouts/qdeclarativelayouts.pro index f38e155..7276162 100644 --- a/tests/auto/declarative/layouts/layouts.pro +++ b/tests/auto/declarative/qdeclarativelayouts/qdeclarativelayouts.pro @@ -1,6 +1,6 @@ load(qttest_p4) contains(QT_CONFIG,declarative): QT += declarative -SOURCES += tst_layouts.cpp +SOURCES += tst_qdeclarativelayouts.cpp macx:CONFIG -= app_bundle # Define SRCDIR equal to test's source directory diff --git a/tests/auto/declarative/layouts/tst_layouts.cpp b/tests/auto/declarative/qdeclarativelayouts/tst_qdeclarativelayouts.cpp index 942125f..879047e 100644 --- a/tests/auto/declarative/layouts/tst_layouts.cpp +++ b/tests/auto/declarative/qdeclarativelayouts/tst_qdeclarativelayouts.cpp @@ -144,4 +144,4 @@ QDeclarativeView *tst_QDeclarativeLayouts::createView(const QString &filename) QTEST_MAIN(tst_QDeclarativeLayouts) -#include "tst_layouts.moc" +#include "tst_qdeclarativelayouts.moc" diff --git a/tests/auto/maketestselftest/features/dump_subdirs.prf b/tests/auto/maketestselftest/features/dump_subdirs.prf new file mode 100644 index 0000000..2547f58 --- /dev/null +++ b/tests/auto/maketestselftest/features/dump_subdirs.prf @@ -0,0 +1,4 @@ +for(dir, SUBDIRS) { + message(subdir: $$dir) +} + diff --git a/tests/auto/maketestselftest/tst_maketestselftest.cpp b/tests/auto/maketestselftest/tst_maketestselftest.cpp index 8264e27..437e143 100644 --- a/tests/auto/maketestselftest/tst_maketestselftest.cpp +++ b/tests/auto/maketestselftest/tst_maketestselftest.cpp @@ -44,16 +44,62 @@ #include <QRegExp> #include <QStringList> #include <QTest> +#include <QSet> +#include <QProcess> +#include <QDebug> + +enum FindSubdirsMode { + Flat = 0, + Recursive +}; class tst_MakeTestSelfTest: public QObject { Q_OBJECT private slots: + void tests_auto_pro(); + void tests_pro_files(); void tests_pro_files_data(); + + void naming_convention(); + void naming_convention_data(); + +private: + QStringList find_subdirs(QString const&, FindSubdirsMode, QString const& = QString()); + + QSet<QString> all_test_classes; }; +bool looks_like_testcase(QString const&,QString*); +bool looks_like_subdirs(QString const&); +QStringList find_test_class(QString const&); + +/* + Verify that auto.pro only contains other .pro files (and not directories). + We enforce this so that we can process every .pro file other than auto.pro + independently and get all the tests. + If tests were allowed to appear directly in auto.pro, we'd have the problem + that we need to somehow run these tests from auto.pro while preventing + recursion into the other .pro files. +*/ +void tst_MakeTestSelfTest::tests_auto_pro() +{ + QStringList subdirsList = find_subdirs(SRCDIR "/../auto.pro", Flat); + if (QTest::currentTestFailed()) { + return; + } + + foreach (QString const& subdir, subdirsList) { + QVERIFY2(subdir.endsWith(".pro"), qPrintable(QString( + "auto.pro contains a subdir `%1'.\n" + "auto.pro must _only_ contain other .pro files, not actual subdirs.\n" + "Please move `%1' into some other .pro file referenced by auto.pro." + ).arg(subdir))); + } +} + /* Verify that all tests are listed somewhere in one of the autotest .pro files */ void tst_MakeTestSelfTest::tests_pro_files() { @@ -82,6 +128,8 @@ void tst_MakeTestSelfTest::tests_pro_files() } } + + QFAIL(qPrintable(QString( "Subdir `%1' is missing from tests/auto/*.pro\n" "This means the test won't be compiled or run on any platform.\n" @@ -106,5 +154,355 @@ void tst_MakeTestSelfTest::tests_pro_files_data() } } +QString format_list(QStringList const& list) +{ + if (list.count() == 1) { + return list.at(0); + } + return QString("one of (%1)").arg(list.join(", ")); +} + +void tst_MakeTestSelfTest::naming_convention() +{ + QFETCH(QString, subdir); + QFETCH(QString, target); + + QDir dir(SRCDIR "/../" + subdir); + + QStringList cppfiles = dir.entryList(QStringList() << "*.h" << "*.cpp"); + if (cppfiles.isEmpty()) { + // Common convention is to have test/test.pro and source files in parent dir + if (dir.dirName() == "test") { + dir.cdUp(); + cppfiles = dir.entryList(QStringList() << "*.h" << "*.cpp"); + } + + if (cppfiles.isEmpty()) { + QSKIP("Couldn't locate source files for test", SkipSingle); + } + } + + QStringList possible_test_classes; + foreach (QString const& file, cppfiles) { + possible_test_classes << find_test_class(dir.path() + "/" + file); + } + + if (possible_test_classes.isEmpty()) { + QSKIP(qPrintable(QString("Couldn't locate test class in %1").arg(format_list(cppfiles))), SkipSingle); + } + + QVERIFY2(possible_test_classes.contains(target), qPrintable(QString( + "TARGET is %1, while test class appears to be %2.\n" + "TARGET and test class _must_ match so that all testcase names can be accurately " + "determined even if a test fails to compile or run.") + .arg(target) + .arg(format_list(possible_test_classes)) + )); + + QVERIFY2(!all_test_classes.contains(target), qPrintable(QString( + "It looks like there are multiple tests named %1.\n" + "This makes it impossible to separate results for these tests.\n" + "Please ensure all tests are uniquely named.") + .arg(target) + )); + + all_test_classes << target; +} + +void tst_MakeTestSelfTest::naming_convention_data() +{ + QTest::addColumn<QString>("subdir"); + QTest::addColumn<QString>("target"); + + foreach (const QString& subdir, find_subdirs(SRCDIR "/../auto.pro", Recursive)) { + if (QFileInfo(SRCDIR "/../" + subdir).isDir()) { + QString target; + if (looks_like_testcase(SRCDIR "/../" + subdir + "/" + QFileInfo(subdir).baseName() + ".pro", &target)) { + QTest::newRow(qPrintable(subdir)) << subdir << target.toLower(); + } + } + } +} + +/* + Returns true if a .pro file seems to be for an autotest. + Running qmake to figure this out takes too long. +*/ +bool looks_like_testcase(QString const& pro_file, QString* target) +{ + QFile file(pro_file); + if (!file.open(QIODevice::ReadOnly)) { + return false; + } + + *target = QString(); + + bool loaded_qttest = false; + + do { + QByteArray line = file.readLine(); + if (line.isEmpty()) { + break; + } + + line = line.trimmed(); + line.replace(' ', ""); + + if (line == "load(qttest_p4)") { + loaded_qttest = true; + } + + if (line.startsWith("TARGET=")) { + *target = QString::fromLatin1(line.mid(sizeof("TARGET=")-1)); + if (target->contains('/')) { + *target = target->right(target->lastIndexOf('/')+1); + } + } + + if (loaded_qttest && !target->isEmpty()) { + break; + } + } while(1); + + if (!loaded_qttest) { + return false; + } + + if (!target->isEmpty() && !target->startsWith("tst_")) { + return false; + } + + // If no target was set, default to tst_<dirname> + if (target->isEmpty()) { + *target = "tst_" + QFileInfo(pro_file).baseName(); + } + + return true; +} + +/* + Returns true if a .pro file seems to be a subdirs project. + Running qmake to figure this out takes too long. +*/ +bool looks_like_subdirs(QString const& pro_file) +{ + QFile file(pro_file); + if (!file.open(QIODevice::ReadOnly)) { + return false; + } + + do { + QByteArray line = file.readLine(); + if (line.isEmpty()) { + break; + } + + line = line.trimmed(); + line.replace(' ', ""); + + if (line == "TEMPLATE=subdirs") { + return true; + } + } while(1); + + return false; +} + +/* + Returns a list of all subdirs in a given .pro file +*/ +QStringList tst_MakeTestSelfTest::find_subdirs(QString const& pro_file, FindSubdirsMode mode, QString const& prefix) +{ + QStringList out; + + QByteArray features = qgetenv("QMAKEFEATURES"); + + if (features.isEmpty()) { + features = SRCDIR "/features"; + } + else { + features.prepend(SRCDIR "/features" +#ifdef Q_OS_WIN32 + ";" +#else + ":" +#endif + ); + } + + QStringList args; + args << pro_file << "-o" << SRCDIR "/dummy_output" << "CONFIG+=dump_subdirs"; + + /* Turn on every option there is, to ensure we process every single directory */ + args + << "QT_CONFIG+=dbus" + << "QT_CONFIG+=declarative" + << "QT_CONFIG+=egl" + << "QT_CONFIG+=multimedia" + << "QT_CONFIG+=OdfWriter" + << "QT_CONFIG+=opengl" + << "QT_CONFIG+=openvg" + << "QT_CONFIG+=phonon" + << "QT_CONFIG+=private_tests" + << "QT_CONFIG+=pulseaudio" + << "QT_CONFIG+=qt3support" + << "QT_CONFIG+=script" + << "QT_CONFIG+=svg" + << "QT_CONFIG+=webkit" + << "QT_CONFIG+=xmlpatterns" + << "CONFIG+=mac" + << "CONFIG+=embedded" + << "CONFIG+=symbian" + ; + + + + QString cmd_with_args = QString("qmake %1").arg(args.join(" ")); + + QProcess proc; + + proc.setProcessChannelMode(QProcess::MergedChannels); + + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + env.insert("QMAKEFEATURES", features); + proc.setProcessEnvironment(env); + + proc.start("qmake", args); + if (!proc.waitForStarted(10000)) { + QTest::qFail(qPrintable(QString("Failed to run qmake: %1\nCommand: %2") + .arg(proc.errorString()) + .arg(cmd_with_args)), + __FILE__, __LINE__ + ); + return out; + } + if (!proc.waitForFinished(30000)) { + QTest::qFail(qPrintable(QString("qmake did not finish within 30 seconds\nCommand: %1\nOutput: %2") + .arg(proc.errorString()) + .arg(cmd_with_args) + .arg(QString::fromLocal8Bit(proc.readAll()))), + __FILE__, __LINE__ + ); + return out; + } + + if (proc.exitStatus() != QProcess::NormalExit) { + QTest::qFail(qPrintable(QString("qmake crashed\nCommand: %1\nOutput: %2") + .arg(cmd_with_args) + .arg(QString::fromLocal8Bit(proc.readAll()))), + __FILE__, __LINE__ + ); + return out; + } + + if (proc.exitCode() != 0) { + QTest::qFail(qPrintable(QString("qmake exited with code %1\nCommand: %2\nOutput: %3") + .arg(proc.exitCode()) + .arg(cmd_with_args) + .arg(QString::fromLocal8Bit(proc.readAll()))), + __FILE__, __LINE__ + ); + return out; + } + + QList<QByteArray> lines = proc.readAll().split('\n'); + if (!lines.count()) { + QTest::qFail(qPrintable(QString("qmake seems to have not output anything\nCommand: %1\n") + .arg(cmd_with_args)), + __FILE__, __LINE__ + ); + return out; + } + + foreach (QByteArray const& line, lines) { + static const QByteArray marker = "Project MESSAGE: subdir: "; + if (line.startsWith(marker)) { + QString subdir = QString::fromLocal8Bit(line.mid(marker.size()).trimmed()); + out << prefix + subdir; + + if (mode == Flat) { + continue; + } + + // Need full path to subdir + QString subdir_filepath = subdir; + subdir_filepath.prepend(QFileInfo(pro_file).path() + "/"); + + // Add subdirs recursively + if (subdir.endsWith(".pro") && looks_like_subdirs(subdir_filepath)) { + // Need full path to .pro file + out << find_subdirs(subdir_filepath, mode, prefix); + } + + if (QFileInfo(subdir_filepath).isDir()) { + subdir_filepath += "/" + subdir + ".pro"; + if (looks_like_subdirs(subdir_filepath)) { + out << find_subdirs(subdir_filepath, mode, prefix + subdir + "/"); + } + } + } + } + + return out; +} + +QStringList find_test_class(QString const& filename) +{ + QStringList out; + + QFile file(filename); + if (!file.open(QIODevice::ReadOnly)) { + return out; + } + + static char const* klass_indicators[] = { + "QTEST_MAIN(", + "QTEST_APPLESS_MAIN(", + "class", + "staticconstcharklass[]=\"", /* hax0r tests which define their own metaobject */ + 0 + }; + + do { + QByteArray line = file.readLine(); + if (line.isEmpty()) { + break; + } + + line = line.trimmed(); + line.replace(' ', ""); + + for (int i = 0; klass_indicators[i]; ++i) { + char const* prefix = klass_indicators[i]; + if (!line.startsWith(prefix)) { + continue; + } + QByteArray klass = line.mid(strlen(prefix)); + if (!klass.startsWith("tst_")) { + continue; + } + for (int j = 0; j < klass.size(); ++j) { + char c = klass[j]; + if (c == '_' + || (c >= '0' && c <= '9') + || (c >= 'A' && c <= 'Z') + || (c >= 'a' && c <= 'z')) { + continue; + } + else { + klass.truncate(j); + break; + } + } + QString klass_str = QString::fromLocal8Bit(klass).toLower(); + if (!out.contains(klass_str)) + out << klass_str; + break; + } + } while(1); + + return out; +} + QTEST_MAIN(tst_MakeTestSelfTest) #include "tst_maketestselftest.moc" diff --git a/tests/auto/moc/tst_moc.cpp b/tests/auto/moc/tst_moc.cpp index fad4845..30c2721 100644 --- a/tests/auto/moc/tst_moc.cpp +++ b/tests/auto/moc/tst_moc.cpp @@ -484,6 +484,7 @@ private slots: void singleFunctionKeywordSignalAndSlot(); void templateGtGt(); void qprivateslots(); + void qprivateproperties(); void inlineSlotsWithThrowDeclaration(); void warnOnPropertyWithoutREAD(); void constructors(); @@ -1071,6 +1072,56 @@ void tst_Moc::qprivateslots() QVERIFY(mobj->indexOfMethod("method1()") != -1); //tast204730 } +class PrivatePropertyTest : public QObject +{ + Q_OBJECT + Q_PROPERTY(int foo READ foo WRITE setFoo); + Q_PRIVATE_PROPERTY(d, int bar READ bar WRITE setBar); + Q_PRIVATE_PROPERTY(PrivatePropertyTest::d, int plop READ plop WRITE setPlop); + Q_PRIVATE_PROPERTY(PrivatePropertyTest::d_func(), int baz READ baz WRITE setBaz); + class MyDPointer { + public: + MyDPointer() : mBar(0), mPlop(0) {} + int bar() { return mBar ; } + void setBar(int value) { mBar = value; } + int plop() { return mPlop ; } + void setPlop(int value) { mPlop = value; } + int baz() { return mBaz ; } + void setBaz(int value) { mBaz = value; } + private: + int mBar; + int mPlop; + int mBaz; + }; +public: + PrivatePropertyTest() : mFoo(0), d (new MyDPointer) {} + int foo() { return mFoo ; } + void setFoo(int value) { mFoo = value; } + MyDPointer *d_func() {return d;} +private: + int mFoo; + MyDPointer *d; +}; + + +void tst_Moc::qprivateproperties() +{ + PrivatePropertyTest test; + + test.setProperty("foo", 1); + QCOMPARE(test.property("foo"), qVariantFromValue(1)); + + test.setProperty("bar", 2); + QCOMPARE(test.property("bar"), qVariantFromValue(2)); + + test.setProperty("plop", 3); + QCOMPARE(test.property("plop"), qVariantFromValue(3)); + + test.setProperty("baz", 4); + QCOMPARE(test.property("baz"), qVariantFromValue(4)); + +} + #include "task189996.h" void InlineSlotsWithThrowDeclaration::c() throw() {} diff --git a/tests/auto/network.pro b/tests/auto/network.pro index 6b24850..dbefa91 100644 --- a/tests/auto/network.pro +++ b/tests/auto/network.pro @@ -17,8 +17,8 @@ SUBDIRS=\ qhttpsocketengine \ qnativesocketengine \ qnetworkaddressentry \ - qnetworkconfigmanager \ qnetworkconfiguration \ + qnetworkconfigurationmanager \ qnetworkcookie \ qnetworkcookiejar \ qnetworkinterface \ diff --git a/tests/auto/opengl.pro b/tests/auto/opengl.pro index 7220c45..9b59cd1 100644 --- a/tests/auto/opengl.pro +++ b/tests/auto/opengl.pro @@ -1,6 +1,6 @@ TEMPLATE=subdirs SUBDIRS=\ qgl \ - qgl_threads \ + qglthreads \ qglbuffer \ diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp index 133cb33..e5a332a 100644 --- a/tests/auto/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp @@ -3923,9 +3923,8 @@ void tst_QAccessibility::comboBoxTest() acc = QAccessible::queryAccessibleInterface(cb); - QRect accRect = acc->rect(0); for (int i = 1; i < acc->childCount(); ++i) { - QVERIFY(accRect.contains(acc->rect(i))); + QTRY_VERIFY(acc->rect(0).contains(acc->rect(i))); } QCOMPARE(acc->doAction(QAccessible::Press, 2), true); QTest::qWait(400); diff --git a/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp b/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp index a215bd5..af0ed76 100644 --- a/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp +++ b/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp @@ -49,7 +49,7 @@ #include <QtMultimedia/qmetadatacontrol.h> -class tst_QmlAudio : public QObject +class tst_QDeclarativeAudio : public QObject { Q_OBJECT public slots: @@ -285,12 +285,12 @@ public: }; -void tst_QmlAudio::initTestCase() +void tst_QDeclarativeAudio::initTestCase() { qRegisterMetaType<QDeclarativeAudio::Error>(); } -void tst_QmlAudio::nullPlayerControl() +void tst_QDeclarativeAudio::nullPlayerControl() { QtTestMetaDataControl metaDataControl; QtTestMediaServiceProvider provider(0, &metaDataControl); @@ -339,7 +339,7 @@ void tst_QmlAudio::nullPlayerControl() QCOMPARE(audio.error(), QDeclarativeAudio::ServiceMissing); } -void tst_QmlAudio::nullMetaDataControl() +void tst_QDeclarativeAudio::nullMetaDataControl() { QtTestMediaPlayerControl playerControl; QtTestMediaServiceProvider provider(&playerControl, 0); @@ -351,7 +351,7 @@ void tst_QmlAudio::nullMetaDataControl() QCOMPARE(audio.metaObject()->indexOfProperty("description"), -1); } -void tst_QmlAudio::nullService() +void tst_QDeclarativeAudio::nullService() { QtTestMediaServiceProvider provider(0); @@ -403,7 +403,7 @@ void tst_QmlAudio::nullService() QCOMPARE(audio.metaObject()->indexOfProperty("description"), -1); } -void tst_QmlAudio::source() +void tst_QDeclarativeAudio::source() { const QUrl url1("http://example.com"); const QUrl url2("file:///local/path"); @@ -431,7 +431,7 @@ void tst_QmlAudio::source() QCOMPARE(spy.count(), 3); } -void tst_QmlAudio::autoLoad() +void tst_QDeclarativeAudio::autoLoad() { QtTestMediaServiceProvider provider; QDeclarativeAudio audio; @@ -458,7 +458,7 @@ void tst_QmlAudio::autoLoad() QCOMPARE(audio.isPaused(), true); } -void tst_QmlAudio::playing() +void tst_QDeclarativeAudio::playing() { QtTestMediaServiceProvider provider; QDeclarativeAudio audio; @@ -547,7 +547,7 @@ void tst_QmlAudio::playing() QCOMPARE(stoppedSpy.count(), stopped); } -void tst_QmlAudio::paused() +void tst_QDeclarativeAudio::paused() { QtTestMediaServiceProvider provider; QDeclarativeAudio audio; @@ -836,7 +836,7 @@ void tst_QmlAudio::paused() QCOMPARE(stoppedSpy.count(), stopped); } -void tst_QmlAudio::duration() +void tst_QDeclarativeAudio::duration() { QtTestMediaServiceProvider provider; QDeclarativeAudio audio; @@ -865,7 +865,7 @@ void tst_QmlAudio::duration() QCOMPARE(spy.count(), 4); } -void tst_QmlAudio::position() +void tst_QDeclarativeAudio::position() { QtTestMediaServiceProvider provider; QDeclarativeAudio audio; @@ -909,7 +909,7 @@ void tst_QmlAudio::position() QVERIFY(spy.count() < 6); } -void tst_QmlAudio::volume() +void tst_QDeclarativeAudio::volume() { QtTestMediaServiceProvider provider; QDeclarativeAudio audio; @@ -934,7 +934,7 @@ void tst_QmlAudio::volume() QCOMPARE(spy.count(), 2); } -void tst_QmlAudio::muted() +void tst_QDeclarativeAudio::muted() { QtTestMediaServiceProvider provider; QDeclarativeAudio audio; @@ -959,7 +959,7 @@ void tst_QmlAudio::muted() QCOMPARE(spy.count(), 3); } -void tst_QmlAudio::bufferProgress() +void tst_QDeclarativeAudio::bufferProgress() { QtTestMediaServiceProvider provider; QDeclarativeAudio audio; @@ -994,7 +994,7 @@ void tst_QmlAudio::bufferProgress() QVERIFY(spy.count() < 6); } -void tst_QmlAudio::seekable() +void tst_QDeclarativeAudio::seekable() { QtTestMediaServiceProvider provider; QDeclarativeAudio audio; @@ -1018,7 +1018,7 @@ void tst_QmlAudio::seekable() QCOMPARE(spy.count(), 3); } -void tst_QmlAudio::playbackRate() +void tst_QDeclarativeAudio::playbackRate() { QtTestMediaServiceProvider provider; QDeclarativeAudio audio; @@ -1044,7 +1044,7 @@ void tst_QmlAudio::playbackRate() QCOMPARE(spy.count(), 3); } -void tst_QmlAudio::status() +void tst_QDeclarativeAudio::status() { QtTestMediaServiceProvider provider; QDeclarativeAudio audio; @@ -1153,7 +1153,7 @@ void tst_QmlAudio::status() QCOMPARE(endOfMediaSpy.count(), 1); } -void tst_QmlAudio::metaData_data() +void tst_QDeclarativeAudio::metaData_data() { QTest::addColumn<QByteArray>("propertyName"); QTest::addColumn<QtMultimedia::MetaData>("propertyKey"); @@ -1179,7 +1179,7 @@ void tst_QmlAudio::metaData_data() << QVariant(12); } -void tst_QmlAudio::metaData() +void tst_QDeclarativeAudio::metaData() { QFETCH(QByteArray, propertyName); QFETCH(QtMultimedia::MetaData, propertyKey); @@ -1209,7 +1209,7 @@ void tst_QmlAudio::metaData() QCOMPARE(spy.count(), 2); } -void tst_QmlAudio::error() +void tst_QDeclarativeAudio::error() { const QString errorString = QLatin1String("Failed to open device."); @@ -1247,6 +1247,6 @@ void tst_QmlAudio::error() } -QTEST_MAIN(tst_QmlAudio) +QTEST_MAIN(tst_QDeclarativeAudio) #include "tst_qdeclarativeaudio.moc" diff --git a/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp b/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp index 56dce28..0fbd78c 100644 --- a/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp +++ b/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp @@ -53,7 +53,7 @@ #include <QtMultimedia/qvideosurfaceformat.h> -class tst_QmlGraphicsVideo : public QObject +class tst_QDeclarativeVideo : public QObject { Q_OBJECT public slots: @@ -291,12 +291,12 @@ public: }; -void tst_QmlGraphicsVideo::initTestCase() +void tst_QDeclarativeVideo::initTestCase() { qRegisterMetaType<QDeclarativeVideo::Error>(); } -void tst_QmlGraphicsVideo::nullPlayerControl() +void tst_QDeclarativeVideo::nullPlayerControl() { QtTestMediaServiceProvider provider(0, 0, 0); @@ -347,7 +347,7 @@ void tst_QmlGraphicsVideo::nullPlayerControl() QCOMPARE(video.error(), QDeclarativeVideo::ServiceMissing); } -void tst_QmlGraphicsVideo::nullService() +void tst_QDeclarativeVideo::nullService() { QtTestMediaServiceProvider provider(0); @@ -402,7 +402,7 @@ void tst_QmlGraphicsVideo::nullService() QCOMPARE(video.metaObject()->indexOfProperty("description"), -1); } -void tst_QmlGraphicsVideo::playing() +void tst_QDeclarativeVideo::playing() { QtTestMediaServiceProvider provider; QDeclarativeVideo video; @@ -490,7 +490,7 @@ void tst_QmlGraphicsVideo::playing() QCOMPARE(stoppedSpy.count(), stopped); } -void tst_QmlGraphicsVideo::paused() +void tst_QDeclarativeVideo::paused() { QtTestMediaServiceProvider provider; QDeclarativeVideo video; @@ -778,7 +778,7 @@ void tst_QmlGraphicsVideo::paused() QCOMPARE(stoppedSpy.count(), stopped); } -void tst_QmlGraphicsVideo::error() +void tst_QDeclarativeVideo::error() { const QString errorString = QLatin1String("Failed to open device."); @@ -815,7 +815,7 @@ void tst_QmlGraphicsVideo::error() } -void tst_QmlGraphicsVideo::hasAudio() +void tst_QDeclarativeVideo::hasAudio() { QtTestMediaServiceProvider provider; QDeclarativeVideo video; @@ -838,7 +838,7 @@ void tst_QmlGraphicsVideo::hasAudio() QCOMPARE(spy.count(), 3); } -void tst_QmlGraphicsVideo::hasVideo() +void tst_QDeclarativeVideo::hasVideo() { QtTestMediaServiceProvider provider; QDeclarativeVideo video; @@ -862,7 +862,7 @@ void tst_QmlGraphicsVideo::hasVideo() QCOMPARE(spy.count(), 3); } -void tst_QmlGraphicsVideo::fillMode() +void tst_QDeclarativeVideo::fillMode() { QtTestMediaServiceProvider provider; QDeclarativeVideo video; @@ -888,7 +888,7 @@ void tst_QmlGraphicsVideo::fillMode() QCOMPARE(videoItem->aspectRatioMode(), Qt::KeepAspectRatio); } -void tst_QmlGraphicsVideo::geometry() +void tst_QDeclarativeVideo::geometry() { QtTestMediaServiceProvider provider; QDeclarativeVideo video; @@ -916,6 +916,6 @@ void tst_QmlGraphicsVideo::geometry() QCOMPARE(videoItem->size().height(), qreal(328)); } -QTEST_MAIN(tst_QmlGraphicsVideo) +QTEST_MAIN(tst_QDeclarativeVideo) #include "tst_qdeclarativevideo.moc" diff --git a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp index f2e1dbd..6bfa8be 100644 --- a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp @@ -87,13 +87,13 @@ public: } }; -class tst_QFiledialog : public QObject +class tst_QFileDialog2 : public QObject { Q_OBJECT public: - tst_QFiledialog(); - virtual ~tst_QFiledialog(); + tst_QFileDialog2(); + virtual ~tst_QFileDialog2(); public slots: void init(); @@ -138,18 +138,18 @@ private: QByteArray userSettings; }; -tst_QFiledialog::tst_QFiledialog() +tst_QFileDialog2::tst_QFileDialog2() { #if defined(Q_OS_WINCE) qApp->setAutoMaximizeThreshold(-1); #endif } -tst_QFiledialog::~tst_QFiledialog() +tst_QFileDialog2::~tst_QFileDialog2() { } -void tst_QFiledialog::init() +void tst_QFileDialog2::init() { // Save the developers settings so they don't get mad when their sidebar folders are gone. QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); @@ -164,14 +164,14 @@ void tst_QFiledialog::init() #endif } -void tst_QFiledialog::cleanup() +void tst_QFileDialog2::cleanup() { QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); settings.beginGroup(QLatin1String("Qt")); settings.setValue(QLatin1String("filedialog"), userSettings); } -void tst_QFiledialog::listRoot() +void tst_QFileDialog2::listRoot() { #if defined QT_BUILD_INTERNAL QFileInfoGatherer fileInfoGatherer; @@ -193,7 +193,7 @@ void tst_QFiledialog::listRoot() #endif } -void tst_QFiledialog::heapCorruption() +void tst_QFileDialog2::heapCorruption() { QVector<QNonNativeFileDialog*> dialogs; for (int i=0; i < 10; i++) { @@ -205,12 +205,12 @@ void tst_QFiledialog::heapCorruption() struct FriendlyQFileDialog : public QNonNativeFileDialog { - friend class tst_QFileDialog; + friend class tst_QFileDialog2; Q_DECLARE_PRIVATE(QFileDialog) }; -void tst_QFiledialog::deleteDirAndFiles() +void tst_QFileDialog2::deleteDirAndFiles() { #if defined QT_BUILD_INTERNAL QString tempPath = QDir::tempPath() + '/' + "QFileDialogTestDir4FullDelete"; @@ -242,7 +242,7 @@ void tst_QFiledialog::deleteDirAndFiles() #endif } -void tst_QFiledialog::filter() +void tst_QFileDialog2::filter() { QNonNativeFileDialog fd; QAction *hiddenAction = qFindChild<QAction*>(&fd, "qt_show_hidden_action"); @@ -255,7 +255,7 @@ void tst_QFiledialog::filter() QVERIFY(hiddenAction->isChecked()); } -void tst_QFiledialog::showNameFilterDetails() +void tst_QFileDialog2::showNameFilterDetails() { QNonNativeFileDialog fd; QComboBox *filters = qFindChild<QComboBox*>(&fd, "fileTypeCombo"); @@ -280,7 +280,7 @@ void tst_QFiledialog::showNameFilterDetails() QCOMPARE(filters->itemText(2), filterChoices.at(2)); } -void tst_QFiledialog::unc() +void tst_QFileDialog2::unc() { #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) // Only test UNC on Windows./ @@ -295,7 +295,7 @@ void tst_QFiledialog::unc() QCOMPARE(model->index(fd.directory().absolutePath()), model->index(dir)); } -void tst_QFiledialog::emptyUncPath() +void tst_QFileDialog2::emptyUncPath() { QNonNativeFileDialog fd; fd.show(); @@ -308,7 +308,7 @@ void tst_QFiledialog::emptyUncPath() QVERIFY(model); } -void tst_QFiledialog::task178897_minimumSize() +void tst_QFileDialog2::task178897_minimumSize() { QNonNativeFileDialog fd; QSize oldMs = fd.layout()->minimumSize(); @@ -322,7 +322,7 @@ void tst_QFiledialog::task178897_minimumSize() QVERIFY(ms.width() <= oldMs.width()); } -void tst_QFiledialog::task180459_lastDirectory_data() +void tst_QFileDialog2::task180459_lastDirectory_data() { QTest::addColumn<QString>("path"); QTest::addColumn<QString>("directory"); @@ -345,7 +345,7 @@ void tst_QFiledialog::task180459_lastDirectory_data() } -void tst_QFiledialog::task180459_lastDirectory() +void tst_QFileDialog2::task180459_lastDirectory() { //first visit the temp directory and close the dialog QNonNativeFileDialog *dlg = new QNonNativeFileDialog(0, "", QDir::tempPath()); @@ -449,7 +449,7 @@ QString &dir, const QString &filter) } }; -void tst_QFiledialog::task227304_proxyOnFileDialog() +void tst_QFileDialog2::task227304_proxyOnFileDialog() { #if defined QT_BUILD_INTERNAL QNonNativeFileDialog fd(0, "", QDir::currentPath(), 0); @@ -488,7 +488,7 @@ void tst_QFiledialog::task227304_proxyOnFileDialog() #endif } -void tst_QFiledialog::task227930_correctNavigationKeyboardBehavior() +void tst_QFileDialog2::task227930_correctNavigationKeyboardBehavior() { QDir current = QDir::currentPath(); current.mkdir("test"); @@ -527,7 +527,7 @@ void tst_QFiledialog::task227930_correctNavigationKeyboardBehavior() } #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) -void tst_QFiledialog::task226366_lowerCaseHardDriveWindows() +void tst_QFileDialog2::task226366_lowerCaseHardDriveWindows() { QNonNativeFileDialog fd; fd.setDirectory(QDir::root().path()); @@ -553,7 +553,7 @@ void tst_QFiledialog::task226366_lowerCaseHardDriveWindows() } #endif -void tst_QFiledialog::completionOnLevelAfterRoot() +void tst_QFileDialog2::completionOnLevelAfterRoot() { QNonNativeFileDialog fd; #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) @@ -592,7 +592,7 @@ void tst_QFiledialog::completionOnLevelAfterRoot() #endif } -void tst_QFiledialog::task233037_selectingDirectory() +void tst_QFileDialog2::task233037_selectingDirectory() { QDir current = QDir::currentPath(); current.mkdir("test"); @@ -615,7 +615,7 @@ void tst_QFiledialog::task233037_selectingDirectory() current.rmdir("test"); } -void tst_QFiledialog::task235069_hideOnEscape() +void tst_QFileDialog2::task235069_hideOnEscape() { QDir current = QDir::currentPath(); QNonNativeFileDialog fd; @@ -637,7 +637,7 @@ void tst_QFiledialog::task235069_hideOnEscape() QCOMPARE(fd2.isVisible(), false); } -void tst_QFiledialog::task236402_dontWatchDeletedDir() +void tst_QFileDialog2::task236402_dontWatchDeletedDir() { #if defined QT_BUILD_INTERNAL //THIS TEST SHOULD NOT DISPLAY WARNINGS @@ -662,7 +662,7 @@ void tst_QFiledialog::task236402_dontWatchDeletedDir() #endif } -void tst_QFiledialog::task203703_returnProperSeparator() +void tst_QFileDialog2::task203703_returnProperSeparator() { QDir current = QDir::currentPath(); current.mkdir("aaaaaaaaaaaaaaaaaa"); @@ -687,7 +687,7 @@ void tst_QFiledialog::task203703_returnProperSeparator() current.rmdir("aaaaaaaaaaaaaaaaaa"); } -void tst_QFiledialog::task228844_ensurePreviousSorting() +void tst_QFileDialog2::task228844_ensurePreviousSorting() { QDir current = QDir::currentPath(); current.mkdir("aaaaaaaaaaaaaaaaaa"); @@ -789,7 +789,7 @@ void tst_QFiledialog::task228844_ensurePreviousSorting() } -void tst_QFiledialog::task239706_editableFilterCombo() +void tst_QFileDialog2::task239706_editableFilterCombo() { QNonNativeFileDialog d; d.setNameFilter("*.cpp *.h"); @@ -812,7 +812,7 @@ void tst_QFiledialog::task239706_editableFilterCombo() QTest::keyPress(filterCombo, Qt::Key_Enter); // should not trigger assertion failure } -void tst_QFiledialog::task218353_relativePaths() +void tst_QFileDialog2::task218353_relativePaths() { QDir appDir = QDir::current(); QVERIFY(appDir.cdUp() != false); @@ -829,7 +829,7 @@ void tst_QFiledialog::task218353_relativePaths() appDir.rmdir("test"); } -void tst_QFiledialog::task251321_sideBarHiddenEntries() +void tst_QFileDialog2::task251321_sideBarHiddenEntries() { #if defined QT_BUILD_INTERNAL QNonNativeFileDialog fd; @@ -889,7 +889,7 @@ public : }; #endif -void tst_QFiledialog::task251341_sideBarRemoveEntries() +void tst_QFileDialog2::task251341_sideBarRemoveEntries() { #if defined QT_BUILD_INTERNAL QNonNativeFileDialog fd; @@ -954,7 +954,7 @@ void tst_QFiledialog::task251341_sideBarRemoveEntries() #endif } -void tst_QFiledialog::task254490_selectFileMultipleTimes() +void tst_QFileDialog2::task254490_selectFileMultipleTimes() { QString tempPath = QDir::tempPath(); QTemporaryFile *t; @@ -986,7 +986,7 @@ void tst_QFiledialog::task254490_selectFileMultipleTimes() t->deleteLater(); } -void tst_QFiledialog::task257579_sideBarWithNonCleanUrls() +void tst_QFileDialog2::task257579_sideBarWithNonCleanUrls() { #if defined QT_BUILD_INTERNAL QDir tempDir = QDir::temp(); @@ -1012,7 +1012,7 @@ void tst_QFiledialog::task257579_sideBarWithNonCleanUrls() #endif } -void tst_QFiledialog::task259105_filtersCornerCases() +void tst_QFileDialog2::task259105_filtersCornerCases() { QNonNativeFileDialog fd(0, "TestFileDialog"); fd.setNameFilter(QLatin1String("All Files! (*);;Text Files (*.txt)")); @@ -1056,7 +1056,7 @@ void tst_QFiledialog::task259105_filtersCornerCases() QCOMPARE(filters->currentText(), QLatin1String("Text Files")); } -void tst_QFiledialog::QTBUG4419_lineEditSelectAll() +void tst_QFileDialog2::QTBUG4419_lineEditSelectAll() { QString tempPath = QDir::tempPath(); QTemporaryFile *t; @@ -1082,7 +1082,7 @@ void tst_QFiledialog::QTBUG4419_lineEditSelectAll() QCOMPARE(tempPath + QChar('/') + lineEdit->selectedText(), t->fileName()); } -void tst_QFiledialog::QTBUG6558_showDirsOnly() +void tst_QFileDialog2::QTBUG6558_showDirsOnly() { const QString tempPath = QDir::tempPath(); QDir dirTemp(tempPath); @@ -1148,7 +1148,7 @@ void tst_QFiledialog::QTBUG6558_showDirsOnly() dirTemp.rmdir(tempName); } -void tst_QFiledialog::QTBUG4842_selectFilterWithHideNameFilterDetails() +void tst_QFileDialog2::QTBUG4842_selectFilterWithHideNameFilterDetails() { QStringList filtersStr; filtersStr << "Images (*.png *.xpm *.jpg)" << "Text files (*.txt)" << "XML files (*.xml)"; @@ -1188,5 +1188,5 @@ void tst_QFiledialog::QTBUG4842_selectFilterWithHideNameFilterDetails() } -QTEST_MAIN(tst_QFiledialog) +QTEST_MAIN(tst_QFileDialog2) #include "tst_qfiledialog2.moc" diff --git a/tests/auto/qgl_threads/qgl_threads.pro b/tests/auto/qgl_threads/qgl_threads.pro deleted file mode 100644 index 9312c05..0000000 --- a/tests/auto/qgl_threads/qgl_threads.pro +++ /dev/null @@ -1,11 +0,0 @@ -############################################################ -# Project file for autotest for file qgl.h -############################################################ - -load(qttest_p4) -requires(contains(QT_CONFIG,opengl)) -QT += opengl - -HEADERS += tst_openglthreading.h -SOURCES += tst_openglthreading.cpp - diff --git a/tests/auto/qglthreads/qglthreads.pro b/tests/auto/qglthreads/qglthreads.pro new file mode 100644 index 0000000..4d20a19 --- /dev/null +++ b/tests/auto/qglthreads/qglthreads.pro @@ -0,0 +1,7 @@ +load(qttest_p4) +requires(contains(QT_CONFIG,opengl)) +QT += opengl + +HEADERS += tst_qglthreads.h +SOURCES += tst_qglthreads.cpp + diff --git a/tests/auto/qgl_threads/tst_openglthreading.cpp b/tests/auto/qglthreads/tst_qglthreads.cpp index cf100cb..cce3161 100644 --- a/tests/auto/qgl_threads/tst_openglthreading.cpp +++ b/tests/auto/qglthreads/tst_qglthreads.cpp @@ -43,7 +43,7 @@ #include <QtCore/QtCore> #include <QtGui/QtGui> #include <QtOpenGL/QtOpenGL> -#include "tst_openglthreading.h" +#include "tst_qglthreads.h" #ifdef Q_WS_X11 #include <private/qt_x11_p.h> @@ -51,7 +51,7 @@ #define RUNNING_TIME 5000 -tst_OpenGLThreading::tst_OpenGLThreading(QObject *parent) +tst_QGLThreads::tst_QGLThreads(QObject *parent) : QObject(parent) { } @@ -143,7 +143,7 @@ public: SwapThread *m_thread; }; -void tst_OpenGLThreading::swapInThread() +void tst_QGLThreads::swapInThread() { #ifdef Q_OS_MAC QSKIP("OpenGL threading tests are currently disabled on mac as they were causing reboots", SkipAll); @@ -249,7 +249,7 @@ private: QList <QPoint> m_positions; }; -void tst_OpenGLThreading::textureUploadInThread() +void tst_QGLThreads::textureUploadInThread() { #ifdef Q_OS_MAC QSKIP("OpenGL threading tests are currently disabled on mac as they were causing reboots", SkipAll); @@ -412,7 +412,7 @@ private: QSize m_size; }; -void tst_OpenGLThreading::renderInThread_data() +void tst_QGLThreads::renderInThread_data() { QTest::addColumn<bool>("resize"); QTest::addColumn<bool>("update"); @@ -423,7 +423,7 @@ void tst_OpenGLThreading::renderInThread_data() QTest::newRow("with-resize-and-update") << true << true; } -void tst_OpenGLThreading::renderInThread() +void tst_QGLThreads::renderInThread() { #ifdef Q_OS_MAC QSKIP("OpenGL threading tests are currently disabled on mac as they were causing reboots", SkipAll); @@ -473,8 +473,8 @@ int main(int argc, char **argv) QApplication app(argc, argv); QTEST_DISABLE_KEYPAD_NAVIGATION \ - tst_OpenGLThreading tc; + tst_QGLThreads tc; return QTest::qExec(&tc, argc, argv); } -#include "tst_openglthreading.moc" +#include "tst_qglthreads.moc" diff --git a/tests/auto/qgl_threads/tst_openglthreading.h b/tests/auto/qglthreads/tst_qglthreads.h index c4b55cd..9e97909 100644 --- a/tests/auto/qgl_threads/tst_openglthreading.h +++ b/tests/auto/qglthreads/tst_qglthreads.h @@ -39,16 +39,16 @@ ** ****************************************************************************/ -#ifndef TST_OPENGLTHREADING_H -#define TST_OPENGLTHREADING_H +#ifndef TST_QGLTHREADS_H +#define TST_QGLTHREADS_H #include <QObject> -class tst_OpenGLThreading : public QObject +class tst_QGLThreads : public QObject { Q_OBJECT public: - explicit tst_OpenGLThreading(QObject *parent = 0); + explicit tst_QGLThreads(QObject *parent = 0); private slots: void swapInThread(); @@ -58,4 +58,4 @@ private slots: void renderInThread(); }; -#endif // TST_OPENGLTHREADING_H +#endif // TST_QGLTHREADS_H diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index d37ff76..a155222 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -284,6 +284,7 @@ private slots: void task250680_childClip(); void taskQTBUG_5904_crashWithDeviceCoordinateCache(); void taskQT657_paintIntoCacheWithTransparentParts(); + void taskQTBUG_7863_paintIntoCacheWithTransparentParts(); }; void tst_QGraphicsScene::initTestCase() @@ -4349,12 +4350,14 @@ void tst_QGraphicsScene::taskQTBUG_5904_crashWithDeviceCoordinateCache() void tst_QGraphicsScene::taskQT657_paintIntoCacheWithTransparentParts() { + // Test using DeviceCoordinateCache and opaque item QWidget *w = new QWidget(); - w->setPalette(Qt::blue); + w->setPalette(QColor(0, 0, 255)); w->setGeometry(0, 0, 50, 50); QGraphicsScene *scene = new QGraphicsScene(); - QGraphicsView *view = new QGraphicsView(scene); + CustomView *view = new CustomView; + view->setScene(scene); QGraphicsProxyWidget *proxy = scene->addWidget(w); proxy->setCacheMode(QGraphicsItem::DeviceCoordinateCache); @@ -4362,13 +4365,14 @@ void tst_QGraphicsScene::taskQT657_paintIntoCacheWithTransparentParts() view->show(); QTest::qWaitForWindowShown(view); - w->update(10,10,10,10); + view->repaints = 0; + proxy->update(10, 10, 10, 10); QTest::qWait(50); + QTRY_VERIFY(view->repaints > 0); QPixmap pix; QGraphicsItemPrivate* itemp = QGraphicsItemPrivate::get(proxy); - QPixmapCache::Key key = itemp->extraItemCache()->deviceData.value(view->viewport()).key; - QVERIFY(QPixmapCache::find(key, &pix)); + QTRY_VERIFY(QPixmapCache::find(itemp->extraItemCache()->deviceData.value(view->viewport()).key, &pix)); QTransform t = proxy->sceneTransform(); // Map from scene coordinates to pixmap coordinates. @@ -4383,6 +4387,138 @@ void tst_QGraphicsScene::taskQT657_paintIntoCacheWithTransparentParts() for(int j = 0; j < im.height(); j++) QCOMPARE(qAlpha(im.pixel(i, j)), 255); } + + delete w; +} + +void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts() +{ + // Test using DeviceCoordinateCache and semi-transparent item + { + QGraphicsRectItem *backItem = new QGraphicsRectItem(0, 0, 100, 100); + backItem->setBrush(QColor(255, 255, 0)); + QGraphicsRectItem *rectItem = new QGraphicsRectItem(0, 0, 50, 50); + rectItem->setBrush(QColor(0, 0, 255, 125)); + rectItem->setParentItem(backItem); + + QGraphicsScene *scene = new QGraphicsScene(); + CustomView *view = new CustomView; + view->setScene(scene); + + scene->addItem(backItem); + rectItem->setCacheMode(QGraphicsItem::DeviceCoordinateCache); + backItem->rotate(15); + + view->show(); + QTest::qWaitForWindowShown(view); + view->repaints = 0; + rectItem->update(10, 10, 10, 10); + QTest::qWait(50); + QTRY_VERIFY(view->repaints > 0); + + QPixmap pix; + QGraphicsItemPrivate* itemp = QGraphicsItemPrivate::get(rectItem); + QTRY_VERIFY(QPixmapCache::find(itemp->extraItemCache()->deviceData.value(view->viewport()).key, &pix)); + + QTransform t = rectItem->sceneTransform(); + // Map from scene coordinates to pixmap coordinates. + // X origin in the pixmap is the most-left point + // of the item's boundingRect in the scene. + qreal adjust = t.mapRect(rectItem->boundingRect().toRect()).left(); + QRect rect = t.mapRect(QRect(10, 10, 10, 10)).adjusted(-adjust, 0, -adjust + 1, 1); + QPixmap subpix = pix.copy(rect); + + QImage im = subpix.toImage(); + for(int i = 0; i < im.width(); i++) { + for(int j = 0; j < im.height(); j++) { + QCOMPARE(qAlpha(im.pixel(i, j)), 125); + } + } + + delete view; + } + + // Test using ItemCoordinateCache and opaque item + { + QGraphicsRectItem *rectItem = new QGraphicsRectItem(0, 0, 50, 50); + rectItem->setBrush(QColor(0, 0, 255)); + + QGraphicsScene *scene = new QGraphicsScene(); + CustomView *view = new CustomView; + view->setScene(scene); + + scene->addItem(rectItem); + rectItem->setCacheMode(QGraphicsItem::ItemCoordinateCache); + rectItem->rotate(15); + + view->show(); + QTest::qWaitForWindowShown(view); + view->repaints = 0; + rectItem->update(10, 10, 10, 10); + QTest::qWait(50); + QTRY_VERIFY(view->repaints > 0); + + QPixmap pix; + QGraphicsItemPrivate* itemp = QGraphicsItemPrivate::get(rectItem); + QTRY_VERIFY(QPixmapCache::find(itemp->extraItemCache()->key, &pix)); + + QTransform t = rectItem->sceneTransform(); + // Map from scene coordinates to pixmap coordinates. + // X origin in the pixmap is the most-left point + // of the item's boundingRect in the scene. + qreal adjust = t.mapRect(rectItem->boundingRect().toRect()).left(); + QRect rect = t.mapRect(QRect(10, 10, 10, 10)).adjusted(-adjust, 0, -adjust + 1, 1); + QPixmap subpix = pix.copy(rect); + + QImage im = subpix.toImage(); + for(int i = 0; i < im.width(); i++) { + for(int j = 0; j < im.height(); j++) + QCOMPARE(qAlpha(im.pixel(i, j)), 255); + } + + delete view; + } + + // Test using ItemCoordinateCache and semi-transparent item + { + QGraphicsRectItem *rectItem = new QGraphicsRectItem(0, 0, 50, 50); + rectItem->setBrush(QColor(0, 0, 255, 125)); + + QGraphicsScene *scene = new QGraphicsScene(); + CustomView *view = new CustomView; + view->setScene(scene); + + scene->addItem(rectItem); + rectItem->setCacheMode(QGraphicsItem::ItemCoordinateCache); + rectItem->rotate(15); + + view->show(); + QTest::qWaitForWindowShown(view); + view->repaints = 0; + rectItem->update(10, 10, 10, 10); + QTest::qWait(50); + QTRY_VERIFY(view->repaints > 0); + + QPixmap pix; + QGraphicsItemPrivate* itemp = QGraphicsItemPrivate::get(rectItem); + QTRY_VERIFY(QPixmapCache::find(itemp->extraItemCache()->key, &pix)); + + QTransform t = rectItem->sceneTransform(); + // Map from scene coordinates to pixmap coordinates. + // X origin in the pixmap is the most-left point + // of the item's boundingRect in the scene. + qreal adjust = t.mapRect(rectItem->boundingRect().toRect()).left(); + QRect rect = t.mapRect(QRect(10, 10, 10, 10)).adjusted(-adjust, 0, -adjust + 1, 1); + QPixmap subpix = pix.copy(rect); + + QImage im = subpix.toImage(); + for(int i = 0; i < im.width(); i++) { + for(int j = 0; j < im.height(); j++) + QCOMPARE(qAlpha(im.pixel(i, j)), 125); + } + + delete view; + } } QTEST_MAIN(tst_QGraphicsScene) diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 6941d23..587b7d5 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -462,7 +462,7 @@ void tst_QGraphicsWidget::focusWidget() QFETCH(int, childWithFocus); SubQGraphicsWidget *widget = children[childWithFocus]; widget->setFocus(); - QVERIFY(widget->hasFocus()); + QTRY_VERIFY(widget->hasFocus()); QCOMPARE(parent->focusWidget(), static_cast<QGraphicsWidget*>(widget)); } } @@ -479,23 +479,23 @@ void tst_QGraphicsWidget::focusWidget2() scene.addItem(widget); - QVERIFY(!widget->hasFocus()); + QTRY_VERIFY(!widget->hasFocus()); widget->setFocusPolicy(Qt::StrongFocus); - QVERIFY(!widget->hasFocus()); + QTRY_VERIFY(!widget->hasFocus()); QGraphicsWidget *subWidget = new QGraphicsWidget(widget); - QVERIFY(!subWidget->hasFocus()); + QTRY_VERIFY(!subWidget->hasFocus()); scene.setFocus(); - QVERIFY(!widget->hasFocus()); - QVERIFY(!subWidget->hasFocus()); + QTRY_VERIFY(!widget->hasFocus()); + QTRY_VERIFY(!subWidget->hasFocus()); widget->setFocus(); - QVERIFY(widget->hasFocus()); - QCOMPARE(focusInSpy.count(), 1); - QVERIFY(!subWidget->hasFocus()); + QTRY_VERIFY(widget->hasFocus()); + QTRY_COMPARE(focusInSpy.count(), 1); + QTRY_VERIFY(!subWidget->hasFocus()); QGraphicsWidget *otherSubWidget = new QGraphicsWidget; EventSpy otherFocusInSpy(otherSubWidget, QEvent::FocusIn); @@ -504,18 +504,18 @@ void tst_QGraphicsWidget::focusWidget2() otherSubWidget->setFocusPolicy(Qt::StrongFocus); otherSubWidget->setParentItem(widget); - QVERIFY(widget->hasFocus()); + QTRY_VERIFY(widget->hasFocus()); QCOMPARE(scene.focusItem(), (QGraphicsItem *)widget); - QVERIFY(!subWidget->hasFocus()); - QVERIFY(!otherSubWidget->hasFocus()); + QTRY_VERIFY(!subWidget->hasFocus()); + QTRY_VERIFY(!otherSubWidget->hasFocus()); widget->hide(); - QVERIFY(!widget->hasFocus()); // lose but still has subfocus + QTRY_VERIFY(!widget->hasFocus()); // lose but still has subfocus QCOMPARE(focusInSpy.count(), 1); QCOMPARE(focusOutSpy.count(), 1); widget->show(); - QVERIFY(!widget->hasFocus()); // no regain + QTRY_VERIFY(!widget->hasFocus()); // no regain QCOMPARE(focusInSpy.count(), 1); QCOMPARE(focusOutSpy.count(), 1); @@ -523,24 +523,24 @@ void tst_QGraphicsWidget::focusWidget2() // try to setup subFocus on item that can't take focus subWidget->setFocus(); - QVERIFY(!subWidget->hasFocus()); + QTRY_VERIFY(!subWidget->hasFocus()); QVERIFY(!scene.focusItem()); // but isn't the scene's focus item // try to setup subFocus on item that can take focus otherSubWidget->setFocus(); - QVERIFY(!otherSubWidget->hasFocus()); + QTRY_VERIFY(!otherSubWidget->hasFocus()); QCOMPARE(widget->focusWidget(), otherSubWidget); QVERIFY(!scene.focusItem()); // but isn't the scene's focus item widget->show(); - QCOMPARE(scene.focusItem(), (QGraphicsItem *)otherSubWidget); // but isn't the scene's focus item + QTRY_COMPARE(scene.focusItem(), (QGraphicsItem *)otherSubWidget); // but isn't the scene's focus item QCOMPARE(otherFocusInSpy.count(), 1); QCOMPARE(otherFocusOutSpy.count(), 0); delete otherSubWidget; - QCOMPARE(otherFocusOutSpy.count(), 1); + QTRY_COMPARE(otherFocusOutSpy.count(), 1); QVERIFY(!scene.focusItem()); QVERIFY(!widget->focusWidget()); } @@ -579,16 +579,16 @@ void tst_QGraphicsWidget::focusPolicy() SubQGraphicsWidget *widget = new SubQGraphicsWidget; scene.addItem(widget); - QCOMPARE(Qt::NoFocus, widget->focusPolicy()); + QTRY_COMPARE(Qt::NoFocus, widget->focusPolicy()); QFETCH(Qt::FocusPolicy, focusPolicy1); widget->setFocusPolicy(focusPolicy1); - QCOMPARE(widget->focusPolicy(), focusPolicy1); + QTRY_COMPARE(widget->focusPolicy(), focusPolicy1); bool isFocusable = widget->flags() & QGraphicsItem::ItemIsFocusable; bool wasFocusable = isFocusable; - QVERIFY(isFocusable == (focusPolicy1 != Qt::NoFocus)); + QTRY_VERIFY(isFocusable == (focusPolicy1 != Qt::NoFocus)); widget->setFocus(); - QCOMPARE(widget->hasFocus(), isFocusable); + QTRY_COMPARE(widget->hasFocus(), isFocusable); QFETCH(Qt::FocusPolicy, focusPolicy2); widget->setFocusPolicy(focusPolicy2); @@ -691,25 +691,21 @@ void tst_QGraphicsWidget::fontChangedEvent() EventSpy rootSpyFont(root, QEvent::FontChange); EventSpy rootSpyPolish(root, QEvent::Polish); - QCOMPARE(rootSpyFont.count(), 0); - QApplication::processEvents(); //The polish event is sent - QCOMPARE(rootSpyPolish.count(), 1); - QApplication::processEvents(); //Process events to see if we get the font change event + QTRY_COMPARE(rootSpyFont.count(), 0); + QTRY_COMPARE(rootSpyPolish.count(), 1); //The font is still the same so no fontChangeEvent - QCOMPARE(rootSpyFont.count(), 0); + QTRY_COMPARE(rootSpyFont.count(), 0); QFont font; font.setPointSize(43); root->setFont(font); - QApplication::processEvents(); //Process events to get the font change event //The font changed - QCOMPARE(rootSpyFont.count(), 1); + QTRY_COMPARE(rootSpyFont.count(), 1); //then roll back to the default one. root->setFont(appFont); - QApplication::processEvents(); //Process events to get the font change event //The font changed - QCOMPARE(rootSpyFont.count(), 2); + QTRY_COMPARE(rootSpyFont.count(), 2); } void tst_QGraphicsWidget::fontPropagationWidgetItemWidget() @@ -770,11 +766,13 @@ void tst_QGraphicsWidget::geometry() { SubQGraphicsWidget widget; QCOMPARE(widget.geometry(), QRectF(widget.pos(), widget.size())); - + QSignalSpy spy(&widget, SIGNAL(geometryChanged())); QFETCH(QPointF, pos); QFETCH(QSizeF, size); widget.setPos(pos); widget.resize(size); + if (!size.isNull()) + QCOMPARE(spy.count(), 1); QCOMPARE(widget.geometry(), QRectF(pos, size)); } @@ -843,7 +841,6 @@ void tst_QGraphicsWidget::initStyleOption() qt_x11_wait_for_window_manager(&view); #endif QApplication::setActiveWindow(&view); - QTest::qWait(25); QTRY_COMPARE(QApplication::activeWindow(), &view); view.setAlignment(Qt::AlignTop | Qt::AlignLeft); @@ -868,7 +865,6 @@ void tst_QGraphicsWidget::initStyleOption() view.resize(300, 300); view.show(); QTest::qWaitForWindowShown(&view); - QTest::qWait(20); sendMouseMove(view.viewport(), view.mapFromScene(widget->mapToScene(widget->boundingRect().center()))); } @@ -921,9 +917,7 @@ void tst_QGraphicsWidget::layout() } widget.setLayout(layout); - QTest::qWait(25); - - QCOMPARE(widget.layout(), static_cast<QGraphicsLayout*>(layout)); + QTRY_COMPARE(widget.layout(), static_cast<QGraphicsLayout*>(layout)); for (int i = 0; i < children.count(); ++i) { SubQGraphicsWidget *item = children[i]; QCOMPARE(item->parentWidget(), (QGraphicsWidget *)&widget); @@ -963,10 +957,9 @@ void tst_QGraphicsWidget::layoutDirection() view->show(); QTest::qWaitForWindowShown(view); for (int i = 0; i < children.count(); ++i) { - QCOMPARE(children[i]->layoutDirection(), layoutDirection); - QCOMPARE(children[i]->testAttribute(Qt::WA_SetLayoutDirection), false); + QTRY_COMPARE(children[i]->layoutDirection(), layoutDirection); + QTRY_COMPARE(children[i]->testAttribute(Qt::WA_SetLayoutDirection), false); view->repaint(); - QApplication::processEvents(); QTRY_COMPARE(children[i]->m_painterLayoutDirection, layoutDirection); } delete view; @@ -1179,7 +1172,6 @@ void tst_QGraphicsWidget::setTabOrder() qt_x11_wait_for_window_manager(&view); #endif QApplication::setActiveWindow(&view); - QTest::qWait(25); QTRY_COMPARE(QApplication::activeWindow(), &view); QGraphicsWidget *lastItem = 0; @@ -1200,7 +1192,6 @@ void tst_QGraphicsWidget::setTabOrder() if (!children.isEmpty()) { QGraphicsWidget *first = children.first(); view.viewport()->setFocus(); - QApplication::processEvents(); QTRY_VERIFY(view.viewport()->hasFocus()); first->setFocus(); QVERIFY(first->hasFocus()); @@ -1461,18 +1452,14 @@ void tst_QGraphicsWidget::verifyFocusChain() QTest::qWaitForWindowShown(window); lineEdit->setFocus(); - QTest::qWait(25); QTRY_VERIFY(lineEdit->hasFocus()); QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(25); QTRY_VERIFY(w1_1->hasFocus()); QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(25); QTRY_VERIFY(w1_2->hasFocus()); // remove the tabFocusFirst and insert new item delete w1_1; // calls _q_removeItemLater - QTest::qWait(25); SubQGraphicsWidget *w1_3 = new SubQGraphicsWidget; w1_3->setFocusPolicy(Qt::StrongFocus); w1_3->setData(0, "w1_3"); @@ -1480,14 +1467,11 @@ void tst_QGraphicsWidget::verifyFocusChain() scene.addItem(w1_3); QTRY_VERIFY(w1_2->hasFocus()); QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); - QTest::qWait(25); QTRY_VERIFY(lineEdit->hasFocus()); // tabFocusFirst should now point to w1_2 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(25); QTRY_VERIFY(w1_2->hasFocus()); QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(25); QTRY_VERIFY(w1_3->hasFocus()); scene.removeItem(w1_2); // does not call _q_removeItemLater delete w1_2; // calls _q_removeItemLater @@ -1498,16 +1482,12 @@ void tst_QGraphicsWidget::verifyFocusChain() w1_4->setGeometry(75,0,25, 25); scene.addItem(w1_4); QTRY_VERIFY(w1_3->hasFocus()); - QTest::qWait(25); QTRY_VERIFY(compareFocusChain(view, QList<QGraphicsItem*>() << w1_3 << w1_4)); QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); - QTest::qWait(25); QTRY_VERIFY(lineEdit->hasFocus()); // tabFocusFirst should now point to w1_3 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(25); QTRY_VERIFY(w1_3->hasFocus()); - QTest::qWait(25); QTRY_VERIFY(compareFocusChain(view, QList<QGraphicsItem*>() << w1_3 << w1_4)); delete window; } @@ -1522,7 +1502,6 @@ void tst_QGraphicsWidget::updateFocusChainWhenChildDie() qt_x11_wait_for_window_manager(&view); #endif QApplication::setActiveWindow(&view); - QTest::qWait(25); QTRY_COMPARE(QApplication::activeWindow(), &view); // delete item in focus chain with no focus and verify chain @@ -1756,31 +1735,29 @@ void tst_QGraphicsWidget::setSizes() widget->setPreferredSize(pref); widget->setMaximumSize(max); - QApplication::processEvents(); - for (i = 0; i < compareInstructions.count(); ++i) { Inst input = compareInstructions.at(i); switch (input.first) { case MinimumSize: - QCOMPARE(widget->minimumSize(), input.second.toSizeF()); + QTRY_COMPARE(widget->minimumSize(), input.second.toSizeF()); break; case PreferredSize: - QCOMPARE(widget->preferredSize(), input.second.toSizeF()); + QTRY_COMPARE(widget->preferredSize(), input.second.toSizeF()); break; case MaximumSize: - QCOMPARE(widget->maximumSize(), input.second.toSizeF()); + QTRY_COMPARE(widget->maximumSize(), input.second.toSizeF()); break; case Size: - QCOMPARE(widget->size(), input.second.toSizeF()); + QTRY_COMPARE(widget->size(), input.second.toSizeF()); break; case MinimumWidth: - QCOMPARE(widget->minimumWidth(), qreal(input.second.toDouble())); + QTRY_COMPARE(widget->minimumWidth(), qreal(input.second.toDouble())); break; case PreferredWidth: - QCOMPARE(widget->preferredWidth(), qreal(input.second.toDouble())); + QTRY_COMPARE(widget->preferredWidth(), qreal(input.second.toDouble())); break; case MaximumWidth: - QCOMPARE(widget->maximumWidth(), qreal(input.second.toDouble())); + QTRY_COMPARE(widget->maximumWidth(), qreal(input.second.toDouble())); break; default: qWarning("instruction not implemented"); @@ -1835,14 +1812,13 @@ void tst_QGraphicsWidget::task236127_bspTreeIndexFails() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif - QTest::qWait(100); - QVERIFY(!scene.itemAt(25, 25)); + QTRY_VERIFY(!scene.itemAt(25, 25)); widget->setGeometry(0, 112, 360, 528); - QCOMPARE(scene.itemAt(15, 120), (QGraphicsItem *)widget); + QTRY_COMPARE(scene.itemAt(15, 120), (QGraphicsItem *)widget); widget2->setGeometry(0, 573, 360, 67); - QCOMPARE(scene.itemAt(15, 120), (QGraphicsItem *)widget); - QCOMPARE(scene.itemAt(50, 585), (QGraphicsItem *)widget2); + QTRY_COMPARE(scene.itemAt(15, 120), (QGraphicsItem *)widget); + QTRY_COMPARE(scene.itemAt(50, 585), (QGraphicsItem *)widget2); } void tst_QGraphicsWidget::defaultSize() @@ -1857,7 +1833,6 @@ void tst_QGraphicsWidget::defaultSize() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif - QTest::qWait(50); QSizeF initialSize = widget->size(); widget->resize(initialSize); @@ -1867,9 +1842,8 @@ void tst_QGraphicsWidget::defaultSize() widget->setPreferredSize(60, 60); widget->setMaximumSize(110, 110); widget->setVisible(true); - QTest::qWait(50); // should still have its size set to initialsize - QCOMPARE(widget->geometry().size(), initialSize); + QTRY_COMPARE(widget->geometry().size(), initialSize); } @@ -2391,7 +2365,6 @@ void tst_QGraphicsWidget::painterStateProtectionOnWindowFrame() scene.addItem(widget); view.show(); QTest::qWaitForWindowShown(&view); - QTest::qWait(500); } class ProxyStyle : public QCommonStyle @@ -2480,7 +2453,6 @@ void tst_QGraphicsWidget::task250119_shortcutContext() view.setScene(&scene); view.show(); QApplication::setActiveWindow(&view); - QTest::qWait(25); QTRY_COMPARE(QApplication::activeWindow(), &view); @@ -2735,9 +2707,7 @@ void tst_QGraphicsWidget::respectHFW() QTest::qWaitForWindowShown(view); { // here we go - simulate a interactive resize of the window - QTest::qWait(100); QTest::mouseMove(view, view->mapFromScene(71, 71)); // bottom right corner - QTest::qWait(100); QTest::mousePress(view->viewport(), Qt::LeftButton, 0, view->mapFromScene(71, 71), 200); view->grabMouse(); @@ -2751,10 +2721,9 @@ void tst_QGraphicsWidget::respectHFW() QApplication::sendEvent(view->viewport(), &e); view->releaseMouse(); } - QTest::qWait(100); const QSizeF winSize = window->size(); qreal minHFW = window->effectiveSizeHint(Qt::MinimumSize, QSizeF(winSize.width(), -1)).height(); - QVERIFY(qAbs(minHFW - winSize.height()) < 1); + QTRY_VERIFY(qAbs(minHFW - winSize.height()) < 1); #endif } @@ -2806,7 +2775,7 @@ void tst_QGraphicsWidget::addChildInpolishEvent() view.resize(200, 200); view.show(); QTest::qWaitForWindowShown(&view); - QCOMPARE(PolishWidget::numberOfPolish, 2); + QTRY_COMPARE(PolishWidget::numberOfPolish, 2); } void tst_QGraphicsWidget::polishEvent() @@ -2853,10 +2822,8 @@ void tst_QGraphicsWidget::polishEvent2() widget->events.clear(); - QApplication::processEvents(); - // Make sure the item got polish event. - QVERIFY(widget->events.contains(QEvent::Polish)); + QTRY_VERIFY(widget->events.contains(QEvent::Polish)); } void tst_QGraphicsWidget::autoFillBackground() @@ -2902,11 +2869,9 @@ void tst_QGraphicsWidget::initialShow() view.show(); QTest::qWaitForWindowShown(&view); - QTest::qWait(100); scene.addItem(widget); - QTest::qWait(100); - QCOMPARE(widget->repaints, 1); + QTRY_COMPARE(widget->repaints, 1); } void tst_QGraphicsWidget::initialShow2() @@ -2935,7 +2900,6 @@ void tst_QGraphicsWidget::initialShow2() const int expectedRepaintCount = paintSpy.count(); delete dummyView; dummyView = 0; - QTest::qWait(200); MyGraphicsWidget *widget = new MyGraphicsWidget; widget->resize(100, 100); @@ -2948,7 +2912,7 @@ void tst_QGraphicsWidget::initialShow2() view.show(); QTest::qWaitForWindowShown(&view); - QCOMPARE(widget->repaints, expectedRepaintCount); + QTRY_COMPARE(widget->repaints, expectedRepaintCount); } void tst_QGraphicsWidget::QT_BUG_6544_tabFocusFirstUnsetWhenRemovingItems() diff --git a/tests/auto/qnetworkconfigmanager/qnetworkconfigmanager.pro b/tests/auto/qnetworkconfigurationmanager/qnetworkconfigurationmanager.pro index 30eb5f0..e0028e5 100644 --- a/tests/auto/qnetworkconfigmanager/qnetworkconfigmanager.pro +++ b/tests/auto/qnetworkconfigurationmanager/qnetworkconfigurationmanager.pro @@ -1,5 +1,5 @@ load(qttest_p4) -SOURCES += tst_qnetworkconfigmanager.cpp +SOURCES += tst_qnetworkconfigurationmanager.cpp HEADERS += ../qbearertestcommon.h QT = core network diff --git a/tests/auto/qnetworkconfigmanager/tst_qnetworkconfigmanager.cpp b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp index 3052330..8b68006 100644 --- a/tests/auto/qnetworkconfigmanager/tst_qnetworkconfigmanager.cpp +++ b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp @@ -332,4 +332,4 @@ void tst_QNetworkConfigurationManager::configurationFromIdentifier() QTEST_MAIN(tst_QNetworkConfigurationManager) -#include "tst_qnetworkconfigmanager.moc" +#include "tst_qnetworkconfigurationmanager.moc" diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index e11900e..4922a89 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -205,6 +205,10 @@ private Q_SLOTS: #endif void ioGetFromHttpBrokenServer_data(); void ioGetFromHttpBrokenServer(); + void ioGetFromHttpStatus100_data(); + void ioGetFromHttpStatus100(); + void ioGetFromHttpNoHeaders_data(); + void ioGetFromHttpNoHeaders(); void ioGetFromHttpWithCache_data(); void ioGetFromHttpWithCache(); @@ -2159,6 +2163,60 @@ void tst_QNetworkReply::ioGetFromHttpBrokenServer() QVERIFY(reply->error() != QNetworkReply::NoError); } +void tst_QNetworkReply::ioGetFromHttpStatus100_data() +{ + QTest::addColumn<QByteArray>("dataToSend"); + QTest::newRow("normal") << QByteArray("HTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"); + QTest::newRow("minimal") << QByteArray("HTTP/1.1 100 Continue\n\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"); + QTest::newRow("minimal2") << QByteArray("HTTP/1.1 100 Continue\n\nHTTP/1.0 200 OK\r\n\r\n"); + QTest::newRow("minimal3") << QByteArray("HTTP/1.1 100 Continue\n\nHTTP/1.0 200 OK\n\n"); + QTest::newRow("with_headers") << QByteArray("HTTP/1.1 100 Continue\r\nBla: x\r\n\r\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"); + QTest::newRow("with_headers2") << QByteArray("HTTP/1.1 100 Continue\nBla: x\n\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"); +} + +void tst_QNetworkReply::ioGetFromHttpStatus100() +{ + QFETCH(QByteArray, dataToSend); + MiniHttpServer server(dataToSend); + server.doClose = true; + + QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort()))); + QNetworkReplyPtr reply = manager.get(request); + + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(10); + QVERIFY(!QTestEventLoop::instance().timeout()); + + QCOMPARE(reply->url(), request.url()); + QCOMPARE(reply->error(), QNetworkReply::NoError); + QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); + QVERIFY(reply->rawHeader("bla").isNull()); +} + +void tst_QNetworkReply::ioGetFromHttpNoHeaders_data() +{ + QTest::addColumn<QByteArray>("dataToSend"); + QTest::newRow("justStatus+noheaders+disconnect") << QByteArray("HTTP/1.0 200 OK\r\n\r\n"); +} + +void tst_QNetworkReply::ioGetFromHttpNoHeaders() +{ + QFETCH(QByteArray, dataToSend); + MiniHttpServer server(dataToSend); + server.doClose = true; + + QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort()))); + QNetworkReplyPtr reply = manager.get(request); + + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(10); + QVERIFY(!QTestEventLoop::instance().timeout()); + + QCOMPARE(reply->url(), request.url()); + QCOMPARE(reply->error(), QNetworkReply::NoError); + QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); +} + void tst_QNetworkReply::ioGetFromHttpWithCache_data() { qRegisterMetaType<MyMemoryCache::CachedContent>(); diff --git a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp index fb0f3e0..d2d86fb 100644 --- a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp +++ b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp @@ -75,6 +75,8 @@ private slots: void loopCount(); void autoAdd(); void pauseResume(); + + void QTBUG8910_crashWhenRemovingUncontrolledAnimation(); }; tst_QParallelAnimationGroup::tst_QParallelAnimationGroup() @@ -999,9 +1001,22 @@ void tst_QParallelAnimationGroup::pauseResume() QCOMPARE(spy.count(), 2); //this shouldn't have changed group.resume(); QCOMPARE(spy.count(), 2); //this shouldn't have changed +} - +void tst_QParallelAnimationGroup::QTBUG8910_crashWhenRemovingUncontrolledAnimation() +{ + QParallelAnimationGroup group; + TestAnimation *anim = new TestAnimation; + anim->setLoopCount(-1); + TestAnimation *anim2 = new TestAnimation; + anim2->setLoopCount(-1); + group.addAnimation(anim); + group.addAnimation(anim2); + group.start(); + delete anim; + // it would crash here because the internals of the group would still have a reference to anim + delete anim2; } diff --git a/tests/auto/qscriptclass/tst_qscriptclass.cpp b/tests/auto/qscriptclass/tst_qscriptclass.cpp index aca33ce..b4dbe73 100644 --- a/tests/auto/qscriptclass/tst_qscriptclass.cpp +++ b/tests/auto/qscriptclass/tst_qscriptclass.cpp @@ -98,7 +98,12 @@ public: NotCallable, CallableReturnsSum, CallableReturnsArgument, - CallableReturnsInvalidVariant + CallableReturnsInvalidVariant, + CallableReturnsGlobalObject, + CallableReturnsThisObject, + CallableReturnsCallee, + CallableReturnsArgumentsObject, + CallableInitializesThisObject }; TestClass(QScriptEngine *engine); @@ -348,7 +353,7 @@ QVariant TestClass::extension(Extension extension, qsreal sum = 0; for (int i = 0; i < ctx->argumentCount(); ++i) sum += ctx->argument(i).toNumber(); - QScriptValueIterator it(ctx->thisObject()); + QScriptValueIterator it(ctx->callee()); while (it.hasNext()) { it.next(); sum += it.value().toNumber(); @@ -358,6 +363,17 @@ QVariant TestClass::extension(Extension extension, return qVariantFromValue(ctx->argument(0)); } else if (m_callableMode == CallableReturnsInvalidVariant) { return QVariant(); + } else if (m_callableMode == CallableReturnsGlobalObject) { + return qVariantFromValue(engine()->globalObject()); + } else if (m_callableMode == CallableReturnsThisObject) { + return qVariantFromValue(ctx->thisObject()); + } else if (m_callableMode == CallableReturnsCallee) { + return qVariantFromValue(ctx->callee()); + } else if (m_callableMode == CallableReturnsArgumentsObject) { + return qVariantFromValue(ctx->argumentsObject()); + } else if (m_callableMode == CallableInitializesThisObject) { + engine()->newQObject(ctx->thisObject(), engine()); + return QVariant(); } } else if (extension == HasInstance) { Q_ASSERT(m_hasInstance); @@ -797,9 +813,11 @@ void tst_QScriptClass::extension() QVERIFY(cls.supportsExtension(QScriptClass::Callable)); QScriptValue obj = eng.newObject(&cls); + eng.globalObject().setProperty("obj", obj); obj.setProperty("one", QScriptValue(&eng, 1)); obj.setProperty("two", QScriptValue(&eng, 2)); obj.setProperty("three", QScriptValue(&eng, 3)); + // From C++ cls.clearReceivedArgs(); { QScriptValueList args; @@ -810,8 +828,18 @@ void tst_QScriptClass::extension() QVERIFY(ret.isNumber()); QCOMPARE(ret.toNumber(), qsreal(15)); } + // From JS + cls.clearReceivedArgs(); + { + QScriptValue ret = eng.evaluate("obj(4, 5)"); + QCOMPARE(cls.lastExtensionType(), QScriptClass::Callable); + QCOMPARE(cls.lastExtensionArgument().userType(), qMetaTypeId<QScriptContext*>()); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toNumber(), qsreal(15)); + } cls.setCallableMode(TestClass::CallableReturnsArgument); + // From C++ cls.clearReceivedArgs(); { QScriptValue ret = obj.call(obj, QScriptValueList() << 123); @@ -843,6 +871,13 @@ void tst_QScriptClass::extension() QScriptValue ret = obj.call(obj, QScriptValueList() << QScriptValue()); QVERIFY(ret.isUndefined()); } + // From JS + cls.clearReceivedArgs(); + { + QScriptValue ret = eng.evaluate("obj(123)"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt32(), 123); + } cls.setCallableMode(TestClass::CallableReturnsInvalidVariant); { @@ -850,13 +885,92 @@ void tst_QScriptClass::extension() QVERIFY(ret.isUndefined()); } + cls.setCallableMode(TestClass::CallableReturnsThisObject); + // From C++ + { + QScriptValue ret = obj.call(obj); + QVERIFY(ret.isObject()); + QVERIFY(ret.strictlyEquals(obj)); + } + // From JS + { + QScriptValue ret = eng.evaluate("obj()"); + QVERIFY(ret.isObject()); + QVERIFY(ret.strictlyEquals(eng.globalObject())); + } + + cls.setCallableMode(TestClass::CallableReturnsCallee); + // From C++ + { + QScriptValue ret = obj.call(); + QVERIFY(ret.isObject()); + QVERIFY(ret.strictlyEquals(obj)); + } + // From JS + { + QScriptValue ret = eng.evaluate("obj()"); + QVERIFY(ret.isObject()); + QVERIFY(ret.strictlyEquals(obj)); + } + + cls.setCallableMode(TestClass::CallableReturnsArgumentsObject); + // From C++ + { + QScriptValue ret = obj.call(obj, QScriptValueList() << 123); + QVERIFY(ret.isObject()); + QVERIFY(ret.property("length").isNumber()); + QCOMPARE(ret.property("length").toInt32(), 1); + QVERIFY(ret.property(0).isNumber()); + QCOMPARE(ret.property(0).toInt32(), 123); + } + // From JS + { + QScriptValue ret = eng.evaluate("obj(123)"); + QVERIFY(ret.isObject()); + QVERIFY(ret.property("length").isNumber()); + QCOMPARE(ret.property("length").toInt32(), 1); + QVERIFY(ret.property(0).isNumber()); + QCOMPARE(ret.property(0).toInt32(), 123); + } + // construct() + // From C++ cls.clearReceivedArgs(); + cls.setCallableMode(TestClass::CallableReturnsGlobalObject); { QScriptValue ret = obj.construct(); QCOMPARE(cls.lastExtensionType(), QScriptClass::Callable); QCOMPARE(cls.lastExtensionArgument().userType(), qMetaTypeId<QScriptContext*>()); QVERIFY(ret.isObject()); + QVERIFY(ret.strictlyEquals(eng.globalObject())); + } + // From JS + cls.clearReceivedArgs(); + { + QScriptValue ret = eng.evaluate("new obj()"); + QCOMPARE(cls.lastExtensionType(), QScriptClass::Callable); + QCOMPARE(cls.lastExtensionArgument().userType(), qMetaTypeId<QScriptContext*>()); + QVERIFY(ret.isObject()); + QVERIFY(ret.strictlyEquals(eng.globalObject())); + } + // From C++ + cls.clearReceivedArgs(); + cls.setCallableMode(TestClass::CallableInitializesThisObject); + { + QScriptValue ret = obj.construct(); + QCOMPARE(cls.lastExtensionType(), QScriptClass::Callable); + QCOMPARE(cls.lastExtensionArgument().userType(), qMetaTypeId<QScriptContext*>()); + QVERIFY(ret.isQObject()); + QCOMPARE(ret.toQObject(), (QObject*)&eng); + } + // From JS + cls.clearReceivedArgs(); + { + QScriptValue ret = eng.evaluate("new obj()"); + QCOMPARE(cls.lastExtensionType(), QScriptClass::Callable); + QCOMPARE(cls.lastExtensionArgument().userType(), qMetaTypeId<QScriptContext*>()); + QVERIFY(ret.isQObject()); + QCOMPARE(ret.toQObject(), (QObject*)&eng); } } // HasInstance diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index d9beb45..e71d7c3 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -150,6 +150,7 @@ private slots: void getSetAgent(); void reentrancy(); void incDecNonObjectProperty(); + void installTranslatorFunctions_data(); void installTranslatorFunctions(); void functionScopes(); void nativeFunctionScopes(); @@ -4119,22 +4120,46 @@ void tst_QScriptEngine:: incDecNonObjectProperty() } } +void tst_QScriptEngine::installTranslatorFunctions_data() +{ + QTest::addColumn<bool>("useCustomGlobalObject"); + + QTest::newRow("Default global object") << false; + QTest::newRow("Custom global object") << true; +} + void tst_QScriptEngine::installTranslatorFunctions() { + QFETCH(bool, useCustomGlobalObject); + QScriptEngine eng; - QScriptValue global = eng.globalObject(); + QScriptValue globalOrig = eng.globalObject(); + QScriptValue global; + if (useCustomGlobalObject) { + global = eng.newObject(); + eng.setGlobalObject(global); + } else { + global = globalOrig; + } QVERIFY(!global.property("qsTranslate").isValid()); QVERIFY(!global.property("QT_TRANSLATE_NOOP").isValid()); QVERIFY(!global.property("qsTr").isValid()); QVERIFY(!global.property("QT_TR_NOOP").isValid()); - QVERIFY(!global.property("String").property("prototype").property("arg").isValid()); + QVERIFY(!globalOrig.property("String").property("prototype").property("arg").isValid()); eng.installTranslatorFunctions(); QVERIFY(global.property("qsTranslate").isFunction()); QVERIFY(global.property("QT_TRANSLATE_NOOP").isFunction()); QVERIFY(global.property("qsTr").isFunction()); QVERIFY(global.property("QT_TR_NOOP").isFunction()); - QVERIFY(global.property("String").property("prototype").property("arg").isFunction()); + QVERIFY(globalOrig.property("String").property("prototype").property("arg").isFunction()); + + if (useCustomGlobalObject) { + QVERIFY(!globalOrig.property("qsTranslate").isValid()); + QVERIFY(!globalOrig.property("QT_TRANSLATE_NOOP").isValid()); + QVERIFY(!globalOrig.property("qsTr").isValid()); + QVERIFY(!globalOrig.property("QT_TR_NOOP").isValid()); + } { QScriptValue ret = eng.evaluate("qsTr('foo')"); diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp index 5b79340..dc369aa 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp @@ -2573,6 +2573,10 @@ void tst_QScriptValue::call() // call with something else as arguments QScriptValue ret5 = fun.call(QScriptValue(), QScriptValue(&eng, 123.0)); QCOMPARE(ret5.isError(), true); + // call with a non-array object as arguments + QScriptValue ret6 = fun.call(QScriptValue(), eng.globalObject()); + QVERIFY(ret6.isError()); + QCOMPARE(ret6.toString(), QString::fromLatin1("TypeError: Arguments must be an array")); } // calling things that are not functions @@ -2705,6 +2709,10 @@ void tst_QScriptValue::construct() // construct with something else as arguments QScriptValue ret5 = fun.construct(QScriptValue(&eng, 123.0)); QCOMPARE(ret5.isError(), true); + // construct with a non-array object as arguments + QScriptValue ret6 = fun.construct(eng.globalObject()); + QVERIFY(ret6.isError()); + QCOMPARE(ret6.toString(), QString::fromLatin1("TypeError: Arguments must be an array")); } // construct on things that are not functions diff --git a/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp index 29cb341..4f7822d 100644 --- a/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp +++ b/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp @@ -90,7 +90,7 @@ int distance(TestIterator &a, TestIterator &b) using namespace QtConcurrent; -class tst_iteratekernel: public QObject +class tst_QtConcurrentIterateKernel: public QObject { Q_OBJECT private slots: @@ -149,13 +149,13 @@ public: }; -void tst_iteratekernel::instantiate() +void tst_QtConcurrentIterateKernel::instantiate() { startThreadEngine(new PrintFor(0, 40)).startBlocking(); QCOMPARE((int)iterations, 40); } -void tst_iteratekernel::cancel() +void tst_QtConcurrentIterateKernel::cancel() { { QFuture<void> f = startThreadEngine(new SleepPrintFor(0, 40)).startAsynchronously(); @@ -182,7 +182,7 @@ public: } }; -void tst_iteratekernel::stresstest() +void tst_QtConcurrentIterateKernel::stresstest() { const int iterations = 1000; const int times = 50; @@ -194,7 +194,7 @@ void tst_iteratekernel::stresstest() } } -void tst_iteratekernel::noIterations() +void tst_QtConcurrentIterateKernel::noIterations() { const int times = 20000; for (int i = 0; i < times; ++i) @@ -242,7 +242,7 @@ public: bool throttling; }; -void tst_iteratekernel::throttling() +void tst_QtConcurrentIterateKernel::throttling() { const int totalIterations = 400; iterations = 0; @@ -271,7 +271,7 @@ public: } }; -void tst_iteratekernel::blockSize() +void tst_QtConcurrentIterateKernel::blockSize() { #ifdef QT_NO_STL QSKIP("Missing stl iterators prevent correct block size calculation", SkipAll); @@ -296,7 +296,7 @@ public: }; -void tst_iteratekernel::multipleResults() +void tst_QtConcurrentIterateKernel::multipleResults() { #ifdef QT_NO_STL QSKIP("Missing stl iterators prevent correct summation", SkipAll); @@ -320,7 +320,7 @@ public: } }; -void tst_iteratekernel::instantiateWhile() +void tst_QtConcurrentIterateKernel::instantiateWhile() { PrintWhile w; w.startBlocking(); @@ -339,7 +339,7 @@ public: } }; -void tst_iteratekernel::stresstestWhile() +void tst_QtConcurrentIterateKernel::stresstestWhile() { int iterations = 100000; StressWhile w(iterations); @@ -348,7 +348,7 @@ void tst_iteratekernel::stresstestWhile() } #endif -QTEST_MAIN(tst_iteratekernel) +QTEST_MAIN(tst_QtConcurrentIterateKernel) #include "tst_qtconcurrentiteratekernel.moc" diff --git a/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp b/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp index d3417b1..894bac4 100644 --- a/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp +++ b/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp @@ -56,7 +56,7 @@ Q_DECLARE_METATYPE(QList<int>); Q_DECLARE_METATYPE(QList<double>); Q_DECLARE_METATYPE(QList<QString>); -class tst_map: public QObject +class tst_QtConcurrentMap: public QObject { Q_OBJECT private slots: @@ -114,7 +114,7 @@ public: Q_DECLARE_METATYPE(QList<Number>); -void tst_map::map() +void tst_QtConcurrentMap::map() { // functors take arguments by reference, modifying the sequence in place { @@ -246,7 +246,7 @@ void tst_map::map() #endif } -void tst_map::blocking_map() +void tst_QtConcurrentMap::blocking_map() { // functors take arguments by reference, modifying the sequence in place { @@ -428,7 +428,7 @@ public: } }; -void tst_map::mapped() +void tst_QtConcurrentMap::mapped() { QList<int> list; list << 1 << 2 << 3; @@ -790,7 +790,7 @@ void tst_map::mapped() } } -void tst_map::blocking_mapped() +void tst_QtConcurrentMap::blocking_mapped() { QList<int> list; list << 1 << 2 << 3; @@ -1244,7 +1244,7 @@ public: } }; -void tst_map::mappedReduced() +void tst_QtConcurrentMap::mappedReduced() { QList<int> list; list << 1 << 2 << 3; @@ -1625,7 +1625,7 @@ void tst_map::mappedReduced() // ### the same as above, with an initial result value } -void tst_map::blocking_mappedReduced() +void tst_QtConcurrentMap::blocking_mappedReduced() { QList<int> list; list << 1 << 2 << 3; @@ -2010,7 +2010,7 @@ int sleeper(int val) return val; } -void tst_map::assignResult() +void tst_QtConcurrentMap::assignResult() { const QList<int> startList = QList<int>() << 0 << 1 << 2; QList<int> list = QtConcurrent::blockingMapped(startList, sleeper); @@ -2077,7 +2077,7 @@ public: Q_DECLARE_METATYPE(QVector<MemFnTester>); Q_DECLARE_METATYPE(QList<MemFnTester>); -void tst_map::functionOverloads() +void tst_QtConcurrentMap::functionOverloads() { QList<int> intList; const QList<int> constIntList; @@ -2159,7 +2159,7 @@ void fastReduce(int &result, const InstanceCounter&) ++result; } -void tst_map::throttling() +void tst_QtConcurrentMap::throttling() { const int itemcount = 100; const int allowedTemporaries = QThread::idealThreadCount() * 40; @@ -2208,7 +2208,7 @@ void throwMapper(int &e) throw QtConcurrent::Exception(); } -void tst_map::exceptions() +void tst_QtConcurrentMap::exceptions() { bool caught = false; try { @@ -2228,7 +2228,7 @@ int mapper(const int &i) return i; } -void tst_map::incrementalResults() +void tst_QtConcurrentMap::incrementalResults() { const int count = 200; QList<int> ints; @@ -2256,7 +2256,7 @@ void tst_map::incrementalResults() Test that mapped does not cause deep copies when holding references to Qt containers. */ -void tst_map::noDetatch() +void tst_QtConcurrentMap::noDetatch() { { QList<int> l = QList<int>() << 1; @@ -2299,7 +2299,7 @@ void tst_map::noDetatch() } -void tst_map::stlContainers() +void tst_QtConcurrentMap::stlContainers() { #ifdef QT_NO_STL QSKIP("Qt compiled without STL support", SkipAll); @@ -2331,7 +2331,7 @@ InstanceCounter ic_fn(const InstanceCounter & ic) // Verify that held results are deleted when a future is // assigned over with operator == -void tst_map::qFutureAssignmentLeak() +void tst_QtConcurrentMap::qFutureAssignmentLeak() { currentInstanceCount = 0; peakInstanceCount = 0; @@ -2370,7 +2370,7 @@ void add(int &result, const int &sum) result += sum; } -void tst_map::stressTest() +void tst_QtConcurrentMap::stressTest() { const int listSize = 1000; const int sum = (listSize - 1) * (listSize / 2); @@ -2399,26 +2399,26 @@ void tst_map::stressTest() } } -QTEST_MAIN(tst_map) +QTEST_MAIN(tst_QtConcurrentMap) #else -void tst_map::map() {} -void tst_map::blocking_map() {} -void tst_map::mapped() {} -void tst_map::blocking_mapped() {} -void tst_map::mappedReduced() {} -void tst_map::blocking_mappedReduced() {} -void tst_map::assignResult() {} -void tst_map::functionOverloads() {} +void tst_QtConcurrentMap::map() {} +void tst_QtConcurrentMap::blocking_map() {} +void tst_QtConcurrentMap::mapped() {} +void tst_QtConcurrentMap::blocking_mapped() {} +void tst_QtConcurrentMap::mappedReduced() {} +void tst_QtConcurrentMap::blocking_mappedReduced() {} +void tst_QtConcurrentMap::assignResult() {} +void tst_QtConcurrentMap::functionOverloads() {} #ifndef QT_NO_EXCEPTIONS -void tst_map::exceptions() {} +void tst_QtConcurrentMap::exceptions() {} #endif -void tst_map::incrementalResults() {} -void tst_map::stressTest() {} -void tst_map::throttling() {} -void tst_map::stlContainers() {} -void tst_map::noDetatch() {} +void tst_QtConcurrentMap::incrementalResults() {} +void tst_QtConcurrentMap::stressTest() {} +void tst_QtConcurrentMap::throttling() {} +void tst_QtConcurrentMap::stlContainers() {} +void tst_QtConcurrentMap::noDetatch() {} QTEST_NOOP_MAIN diff --git a/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp index b9ab6d3..8fdc50c 100644 --- a/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp +++ b/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp @@ -49,7 +49,7 @@ using namespace QtConcurrent; -class TestRunFunction: public QObject +class tst_QtConcurrentRun: public QObject { Q_OBJECT private slots: @@ -73,7 +73,7 @@ private slots: #endif -QTEST_MAIN(TestRunFunction) +QTEST_MAIN(tst_QtConcurrentRun) void light() { @@ -91,7 +91,7 @@ void heavy() } -void TestRunFunction::runLightFunction() +void tst_QtConcurrentRun::runLightFunction() { qDebug("starting function"); QFuture<void> future = run(F(light)); @@ -100,7 +100,7 @@ void TestRunFunction::runLightFunction() qDebug("done"); } -void TestRunFunction::runHeavyFunction() +void tst_QtConcurrentRun::runHeavyFunction() { qDebug("starting function"); QFuture<void> future = run(F(heavy)); @@ -141,7 +141,7 @@ public: int operator()(int in) const { return in; } }; -void TestRunFunction::returnValue() +void tst_QtConcurrentRun::returnValue() { QFuture<int> f; @@ -217,7 +217,7 @@ struct TestConstClass void fooInt(int) const { }; }; -void TestRunFunction::functionObject() +void tst_QtConcurrentRun::functionObject() { QFuture<void> f; TestClass c; @@ -235,7 +235,7 @@ void TestRunFunction::functionObject() } -void TestRunFunction::memberFunctions() +void tst_QtConcurrentRun::memberFunctions() { TestClass c; @@ -278,7 +278,7 @@ void stringIntFunction(QString) } -void TestRunFunction::implicitConvertibleTypes() +void tst_QtConcurrentRun::implicitConvertibleTypes() { double d; run(F(doubleFunction), d).waitForFinished(); @@ -294,7 +294,7 @@ void TestRunFunction::implicitConvertibleTypes() void fn() { } -void TestRunFunction::runWaitLoop() +void tst_QtConcurrentRun::runWaitLoop() { for (int i = 0; i < 1000; ++i) run(fn).waitForFinished(); @@ -324,7 +324,7 @@ int recursiveResult(int level) return 1; } -void TestRunFunction::recursive() +void tst_QtConcurrentRun::recursive() { int levels = 15; @@ -375,7 +375,7 @@ int fn2(double, int *) } #if 0 -void TestRunFunction::createFunctor() +void tst_QtConcurrentRun::createFunctor() { e = 0; ::QtConcurrent::createFunctor(vfn0)(); diff --git a/tests/auto/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/tests/auto/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp index 6f586d7..23fd19b 100644 --- a/tests/auto/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp +++ b/tests/auto/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp @@ -48,7 +48,7 @@ using namespace QtConcurrent; -class tst_threadengine: public QObject +class tst_QtConcurrentThreadEngine: public QObject { Q_OBJECT public: @@ -79,7 +79,7 @@ public: } }; -void tst_threadengine::runDirectly() +void tst_QtConcurrentThreadEngine::runDirectly() { { PrintUser engine; @@ -120,7 +120,7 @@ public: bool done; }; -void tst_threadengine::result() +void tst_QtConcurrentThreadEngine::result() { StringResultUser engine; QCOMPARE(*engine.startBlocking(), QString("Foo")); @@ -147,7 +147,7 @@ public: bool done; }; -void tst_threadengine::runThroughStarter() +void tst_QtConcurrentThreadEngine::runThroughStarter() { { ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser()); @@ -180,7 +180,7 @@ public: } }; -void tst_threadengine::cancel() +void tst_QtConcurrentThreadEngine::cancel() { { CancelUser *engine = new CancelUser(); @@ -234,7 +234,7 @@ public: // Test that a user task with a thread function that always // want to be throttled still completes. The thread engine // should make keep one thread running at all times. -void tst_threadengine::throttle() +void tst_QtConcurrentThreadEngine::throttle() { const int repeats = 10; for (int i = 0; i < repeats; ++i) { @@ -280,7 +280,7 @@ public: bool finishing; }; -void tst_threadengine::threadCount() +void tst_QtConcurrentThreadEngine::threadCount() { const int repeats = 10; for (int i = 0; i < repeats; ++i) { @@ -320,7 +320,7 @@ public: }; -void tst_threadengine::multipleResults() +void tst_QtConcurrentThreadEngine::multipleResults() { MultipleResultsUser *engine = new MultipleResultsUser(); QFuture<int> f = engine->startAsynchronously(); @@ -351,7 +351,7 @@ public: } }; -void tst_threadengine::stresstest() +void tst_QtConcurrentThreadEngine::stresstest() { const int times = 20000; @@ -379,7 +379,7 @@ public: ThreadFunctionResult threadFunction() { QTest::qSleep(sleepTime); return ThreadFinished; } }; -void tst_threadengine::cancelQueuedSlowUser() +void tst_QtConcurrentThreadEngine::cancelQueuedSlowUser() { const int times = 100; @@ -436,7 +436,7 @@ public: QThread *blockThread; }; -void tst_threadengine::exceptions() +void tst_QtConcurrentThreadEngine::exceptions() { // Asynchronous mode: { @@ -527,7 +527,7 @@ void tst_threadengine::exceptions() #endif -QTEST_MAIN(tst_threadengine) +QTEST_MAIN(tst_QtConcurrentThreadEngine) #include "tst_qtconcurrentthreadengine.moc" diff --git a/tests/auto/qvectornd/tst_qvectornd.cpp b/tests/auto/qvectornd/tst_qvectornd.cpp index 2be7264..2850f32 100644 --- a/tests/auto/qvectornd/tst_qvectornd.cpp +++ b/tests/auto/qvectornd/tst_qvectornd.cpp @@ -45,12 +45,12 @@ #include <QtGui/qvector3d.h> #include <QtGui/qvector4d.h> -class tst_QVector : public QObject +class tst_QVectorND : public QObject { Q_OBJECT public: - tst_QVector() {} - ~tst_QVector() {} + tst_QVectorND() {} + ~tst_QVectorND() {} private slots: void create2(); @@ -155,7 +155,7 @@ static bool fuzzyCompare(qreal x, qreal y) // Test the creation of QVector2D objects in various ways: // construct, copy, and modify. -void tst_QVector::create2() +void tst_QVectorND::create2() { QVector2D null; QCOMPARE(null.x(), (qreal)0.0f); @@ -244,7 +244,7 @@ void tst_QVector::create2() // Test the creation of QVector3D objects in various ways: // construct, copy, and modify. -void tst_QVector::create3() +void tst_QVectorND::create3() { QVector3D null; QCOMPARE(null.x(), (qreal)0.0f); @@ -370,7 +370,7 @@ void tst_QVector::create3() // Test the creation of QVector4D objects in various ways: // construct, copy, and modify. -void tst_QVector::create4() +void tst_QVectorND::create4() { QVector4D null; QCOMPARE(null.x(), (qreal)0.0f); @@ -556,7 +556,7 @@ void tst_QVector::create4() } // Test vector length computation for 2D vectors. -void tst_QVector::length2_data() +void tst_QVectorND::length2_data() { QTest::addColumn<qreal>("x"); QTest::addColumn<qreal>("y"); @@ -569,7 +569,7 @@ void tst_QVector::length2_data() QTest::newRow("-1y") << (qreal)0.0f << (qreal)-1.0f << (qreal)1.0f; QTest::newRow("two") << (qreal)2.0f << (qreal)-2.0f << (qreal)qSqrt(8.0f); } -void tst_QVector::length2() +void tst_QVectorND::length2() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -581,7 +581,7 @@ void tst_QVector::length2() } // Test vector length computation for 3D vectors. -void tst_QVector::length3_data() +void tst_QVectorND::length3_data() { QTest::addColumn<qreal>("x"); QTest::addColumn<qreal>("y"); @@ -597,7 +597,7 @@ void tst_QVector::length3_data() QTest::newRow("-1z") << (qreal)0.0f << (qreal)0.0f << (qreal)-1.0f << (qreal)1.0f; QTest::newRow("two") << (qreal)2.0f << (qreal)-2.0f << (qreal)2.0f << (qreal)qSqrt(12.0f); } -void tst_QVector::length3() +void tst_QVectorND::length3() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -610,7 +610,7 @@ void tst_QVector::length3() } // Test vector length computation for 4D vectors. -void tst_QVector::length4_data() +void tst_QVectorND::length4_data() { QTest::addColumn<qreal>("x"); QTest::addColumn<qreal>("y"); @@ -629,7 +629,7 @@ void tst_QVector::length4_data() QTest::newRow("-1w") << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)-1.0f << (qreal)1.0f; QTest::newRow("two") << (qreal)2.0f << (qreal)-2.0f << (qreal)2.0f << (qreal)2.0f << (qreal)qSqrt(16.0f); } -void tst_QVector::length4() +void tst_QVectorND::length4() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -643,12 +643,12 @@ void tst_QVector::length4() } // Test the unit vector conversion for 2D vectors. -void tst_QVector::normalized2_data() +void tst_QVectorND::normalized2_data() { // Use the same test data as the length test. length2_data(); } -void tst_QVector::normalized2() +void tst_QVectorND::normalized2() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -665,12 +665,12 @@ void tst_QVector::normalized2() } // Test the unit vector conversion for 3D vectors. -void tst_QVector::normalized3_data() +void tst_QVectorND::normalized3_data() { // Use the same test data as the length test. length3_data(); } -void tst_QVector::normalized3() +void tst_QVectorND::normalized3() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -689,12 +689,12 @@ void tst_QVector::normalized3() } // Test the unit vector conversion for 4D vectors. -void tst_QVector::normalized4_data() +void tst_QVectorND::normalized4_data() { // Use the same test data as the length test. length4_data(); } -void tst_QVector::normalized4() +void tst_QVectorND::normalized4() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -715,12 +715,12 @@ void tst_QVector::normalized4() } // Test the unit vector conversion for 2D vectors. -void tst_QVector::normalize2_data() +void tst_QVectorND::normalize2_data() { // Use the same test data as the length test. length2_data(); } -void tst_QVector::normalize2() +void tst_QVectorND::normalize2() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -735,12 +735,12 @@ void tst_QVector::normalize2() } // Test the unit vector conversion for 3D vectors. -void tst_QVector::normalize3_data() +void tst_QVectorND::normalize3_data() { // Use the same test data as the length test. length3_data(); } -void tst_QVector::normalize3() +void tst_QVectorND::normalize3() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -756,12 +756,12 @@ void tst_QVector::normalize3() } // Test the unit vector conversion for 4D vectors. -void tst_QVector::normalize4_data() +void tst_QVectorND::normalize4_data() { // Use the same test data as the length test. length4_data(); } -void tst_QVector::normalize4() +void tst_QVectorND::normalize4() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -778,7 +778,7 @@ void tst_QVector::normalize4() } // Test the comparison operators for 2D vectors. -void tst_QVector::compare2() +void tst_QVectorND::compare2() { QVector2D v1(1, 2); QVector2D v2(1, 2); @@ -791,7 +791,7 @@ void tst_QVector::compare2() } // Test the comparison operators for 3D vectors. -void tst_QVector::compare3() +void tst_QVectorND::compare3() { QVector3D v1(1, 2, 4); QVector3D v2(1, 2, 4); @@ -806,7 +806,7 @@ void tst_QVector::compare3() } // Test the comparison operators for 4D vectors. -void tst_QVector::compare4() +void tst_QVectorND::compare4() { QVector4D v1(1, 2, 4, 8); QVector4D v2(1, 2, 4, 8); @@ -823,7 +823,7 @@ void tst_QVector::compare4() } // Test vector addition for 2D vectors. -void tst_QVector::add2_data() +void tst_QVectorND::add2_data() { QTest::addColumn<qreal>("x1"); QTest::addColumn<qreal>("y1"); @@ -852,7 +852,7 @@ void tst_QVector::add2_data() << (qreal)4.0f << (qreal)5.0f << (qreal)5.0f << (qreal)7.0f; } -void tst_QVector::add2() +void tst_QVectorND::add2() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -876,7 +876,7 @@ void tst_QVector::add2() } // Test vector addition for 3D vectors. -void tst_QVector::add3_data() +void tst_QVectorND::add3_data() { QTest::addColumn<qreal>("x1"); QTest::addColumn<qreal>("y1"); @@ -913,7 +913,7 @@ void tst_QVector::add3_data() << (qreal)4.0f << (qreal)5.0f << (qreal)-6.0f << (qreal)5.0f << (qreal)7.0f << (qreal)-3.0f; } -void tst_QVector::add3() +void tst_QVectorND::add3() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -941,7 +941,7 @@ void tst_QVector::add3() } // Test vector addition for 4D vectors. -void tst_QVector::add4_data() +void tst_QVectorND::add4_data() { QTest::addColumn<qreal>("x1"); QTest::addColumn<qreal>("y1"); @@ -986,7 +986,7 @@ void tst_QVector::add4_data() << (qreal)4.0f << (qreal)5.0f << (qreal)-6.0f << (qreal)9.0f << (qreal)5.0f << (qreal)7.0f << (qreal)-3.0f << (qreal)17.0f; } -void tst_QVector::add4() +void tst_QVectorND::add4() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1018,12 +1018,12 @@ void tst_QVector::add4() } // Test vector subtraction for 2D vectors. -void tst_QVector::subtract2_data() +void tst_QVectorND::subtract2_data() { // Use the same test data as the add test. add2_data(); } -void tst_QVector::subtract2() +void tst_QVectorND::subtract2() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1055,12 +1055,12 @@ void tst_QVector::subtract2() } // Test vector subtraction for 3D vectors. -void tst_QVector::subtract3_data() +void tst_QVectorND::subtract3_data() { // Use the same test data as the add test. add3_data(); } -void tst_QVector::subtract3() +void tst_QVectorND::subtract3() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1097,12 +1097,12 @@ void tst_QVector::subtract3() } // Test vector subtraction for 4D vectors. -void tst_QVector::subtract4_data() +void tst_QVectorND::subtract4_data() { // Use the same test data as the add test. add4_data(); } -void tst_QVector::subtract4() +void tst_QVectorND::subtract4() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1144,7 +1144,7 @@ void tst_QVector::subtract4() } // Test component-wise vector multiplication for 2D vectors. -void tst_QVector::multiply2_data() +void tst_QVectorND::multiply2_data() { QTest::addColumn<qreal>("x1"); QTest::addColumn<qreal>("y1"); @@ -1173,7 +1173,7 @@ void tst_QVector::multiply2_data() << (qreal)4.0f << (qreal)5.0f << (qreal)4.0f << (qreal)10.0f; } -void tst_QVector::multiply2() +void tst_QVectorND::multiply2() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1197,7 +1197,7 @@ void tst_QVector::multiply2() } // Test component-wise vector multiplication for 3D vectors. -void tst_QVector::multiply3_data() +void tst_QVectorND::multiply3_data() { QTest::addColumn<qreal>("x1"); QTest::addColumn<qreal>("y1"); @@ -1234,7 +1234,7 @@ void tst_QVector::multiply3_data() << (qreal)4.0f << (qreal)5.0f << (qreal)-6.0f << (qreal)4.0f << (qreal)10.0f << (qreal)-18.0f; } -void tst_QVector::multiply3() +void tst_QVectorND::multiply3() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1262,7 +1262,7 @@ void tst_QVector::multiply3() } // Test component-wise vector multiplication for 4D vectors. -void tst_QVector::multiply4_data() +void tst_QVectorND::multiply4_data() { QTest::addColumn<qreal>("x1"); QTest::addColumn<qreal>("y1"); @@ -1307,7 +1307,7 @@ void tst_QVector::multiply4_data() << (qreal)4.0f << (qreal)5.0f << (qreal)-6.0f << (qreal)9.0f << (qreal)4.0f << (qreal)10.0f << (qreal)-18.0f << (qreal)72.0f; } -void tst_QVector::multiply4() +void tst_QVectorND::multiply4() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1339,7 +1339,7 @@ void tst_QVector::multiply4() } // Test vector multiplication by a factor for 2D vectors. -void tst_QVector::multiplyFactor2_data() +void tst_QVectorND::multiplyFactor2_data() { QTest::addColumn<qreal>("x1"); QTest::addColumn<qreal>("y1"); @@ -1372,7 +1372,7 @@ void tst_QVector::multiplyFactor2_data() << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; } -void tst_QVector::multiplyFactor2() +void tst_QVectorND::multiplyFactor2() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1395,7 +1395,7 @@ void tst_QVector::multiplyFactor2() } // Test vector multiplication by a factor for 3D vectors. -void tst_QVector::multiplyFactor3_data() +void tst_QVectorND::multiplyFactor3_data() { QTest::addColumn<qreal>("x1"); QTest::addColumn<qreal>("y1"); @@ -1435,7 +1435,7 @@ void tst_QVector::multiplyFactor3_data() << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; } -void tst_QVector::multiplyFactor3() +void tst_QVectorND::multiplyFactor3() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1461,7 +1461,7 @@ void tst_QVector::multiplyFactor3() } // Test vector multiplication by a factor for 4D vectors. -void tst_QVector::multiplyFactor4_data() +void tst_QVectorND::multiplyFactor4_data() { QTest::addColumn<qreal>("x1"); QTest::addColumn<qreal>("y1"); @@ -1508,7 +1508,7 @@ void tst_QVector::multiplyFactor4_data() << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; } -void tst_QVector::multiplyFactor4() +void tst_QVectorND::multiplyFactor4() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1537,12 +1537,12 @@ void tst_QVector::multiplyFactor4() } // Test vector division by a factor for 2D vectors. -void tst_QVector::divide2_data() +void tst_QVectorND::divide2_data() { // Use the same test data as the multiply test. multiplyFactor2_data(); } -void tst_QVector::divide2() +void tst_QVectorND::divide2() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1567,12 +1567,12 @@ void tst_QVector::divide2() } // Test vector division by a factor for 3D vectors. -void tst_QVector::divide3_data() +void tst_QVectorND::divide3_data() { // Use the same test data as the multiply test. multiplyFactor3_data(); } -void tst_QVector::divide3() +void tst_QVectorND::divide3() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1600,12 +1600,12 @@ void tst_QVector::divide3() } // Test vector division by a factor for 4D vectors. -void tst_QVector::divide4_data() +void tst_QVectorND::divide4_data() { // Use the same test data as the multiply test. multiplyFactor4_data(); } -void tst_QVector::divide4() +void tst_QVectorND::divide4() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1636,12 +1636,12 @@ void tst_QVector::divide4() } // Test vector negation for 2D vectors. -void tst_QVector::negate2_data() +void tst_QVectorND::negate2_data() { // Use the same test data as the add test. add2_data(); } -void tst_QVector::negate2() +void tst_QVectorND::negate2() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1653,12 +1653,12 @@ void tst_QVector::negate2() } // Test vector negation for 3D vectors. -void tst_QVector::negate3_data() +void tst_QVectorND::negate3_data() { // Use the same test data as the add test. add3_data(); } -void tst_QVector::negate3() +void tst_QVectorND::negate3() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1671,12 +1671,12 @@ void tst_QVector::negate3() } // Test vector negation for 4D vectors. -void tst_QVector::negate4_data() +void tst_QVectorND::negate4_data() { // Use the same test data as the add test. add4_data(); } -void tst_QVector::negate4() +void tst_QVectorND::negate4() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1690,7 +1690,7 @@ void tst_QVector::negate4() } // Test the computation of vector cross-products. -void tst_QVector::crossProduct_data() +void tst_QVectorND::crossProduct_data() { QTest::addColumn<qreal>("x1"); QTest::addColumn<qreal>("y1"); @@ -1721,7 +1721,7 @@ void tst_QVector::crossProduct_data() << (qreal)-3.0f << (qreal)6.0f << (qreal)-3.0f << (qreal)32.0f; } -void tst_QVector::crossProduct() +void tst_QVectorND::crossProduct() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1751,12 +1751,12 @@ void tst_QVector::crossProduct() } // Test the computation of normals. -void tst_QVector::normal_data() +void tst_QVectorND::normal_data() { // Use the same test data as the crossProduct test. crossProduct_data(); } -void tst_QVector::normal() +void tst_QVectorND::normal() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1780,7 +1780,7 @@ void tst_QVector::normal() } // Test distance to plane calculations. -void tst_QVector::distanceToPlane_data() +void tst_QVectorND::distanceToPlane_data() { QTest::addColumn<qreal>("x1"); // Point on plane QTest::addColumn<qreal>("y1"); @@ -1823,7 +1823,7 @@ void tst_QVector::distanceToPlane_data() << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f << (qreal)-2.0f; } -void tst_QVector::distanceToPlane() +void tst_QVectorND::distanceToPlane() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1853,7 +1853,7 @@ void tst_QVector::distanceToPlane() } // Test distance to line calculations. -void tst_QVector::distanceToLine_data() +void tst_QVectorND::distanceToLine_data() { QTest::addColumn<qreal>("x1"); // Point on line QTest::addColumn<qreal>("y1"); @@ -1896,7 +1896,7 @@ void tst_QVector::distanceToLine_data() << (qreal)0.0f << (qreal)5.0f << (qreal)0.0f << (qreal)5.0f; } -void tst_QVector::distanceToLine() +void tst_QVectorND::distanceToLine() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1917,7 +1917,7 @@ void tst_QVector::distanceToLine() } // Test the computation of dot products for 2D vectors. -void tst_QVector::dotProduct2_data() +void tst_QVectorND::dotProduct2_data() { QTest::addColumn<qreal>("x1"); QTest::addColumn<qreal>("y1"); @@ -1940,7 +1940,7 @@ void tst_QVector::dotProduct2_data() << (qreal)4.0f << (qreal)5.0f << (qreal)14.0f; } -void tst_QVector::dotProduct2() +void tst_QVectorND::dotProduct2() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1960,12 +1960,12 @@ void tst_QVector::dotProduct2() } // Test the computation of dot products for 3D vectors. -void tst_QVector::dotProduct3_data() +void tst_QVectorND::dotProduct3_data() { // Use the same test data as the crossProduct test. crossProduct_data(); } -void tst_QVector::dotProduct3() +void tst_QVectorND::dotProduct3() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1994,7 +1994,7 @@ void tst_QVector::dotProduct3() } // Test the computation of dot products for 4D vectors. -void tst_QVector::dotProduct4_data() +void tst_QVectorND::dotProduct4_data() { QTest::addColumn<qreal>("x1"); QTest::addColumn<qreal>("y1"); @@ -2021,7 +2021,7 @@ void tst_QVector::dotProduct4_data() << (qreal)4.0f << (qreal)5.0f << (qreal)6.0f << (qreal)7.0f << (qreal)60.0f; } -void tst_QVector::dotProduct4() +void tst_QVectorND::dotProduct4() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -2044,14 +2044,14 @@ void tst_QVector::dotProduct4() QCOMPARE(QVector4D::dotProduct(v1, v2), d); } -class tst_QVectorProperties : public QObject +class tst_QVectorNDProperties : public QObject { Q_OBJECT Q_PROPERTY(QVector2D vector2D READ vector2D WRITE setVector2D) Q_PROPERTY(QVector3D vector3D READ vector3D WRITE setVector3D) Q_PROPERTY(QVector4D vector4D READ vector4D WRITE setVector4D) public: - tst_QVectorProperties(QObject *parent = 0) : QObject(parent) {} + tst_QVectorNDProperties(QObject *parent = 0) : QObject(parent) {} QVector2D vector2D() const { return v2; } void setVector2D(const QVector2D& value) { v2 = value; } @@ -2069,9 +2069,9 @@ private: }; // Test getting and setting vector properties via the metaobject system. -void tst_QVector::properties() +void tst_QVectorND::properties() { - tst_QVectorProperties obj; + tst_QVectorNDProperties obj; obj.setVector2D(QVector2D(1.0f, 2.0f)); obj.setVector3D(QVector3D(3.0f, 4.0f, 5.0f)); @@ -2115,7 +2115,7 @@ void tst_QVector::properties() QCOMPARE(v4.w(), (qreal)-9.0f); } -void tst_QVector::metaTypes() +void tst_QVectorND::metaTypes() { QVERIFY(QMetaType::type("QVector2D") == QMetaType::QVector2D); QVERIFY(QMetaType::type("QVector3D") == QMetaType::QVector3D); @@ -2137,6 +2137,6 @@ void tst_QVector::metaTypes() QVERIFY(qMetaTypeId<QVector4D>() == QMetaType::QVector4D); } -QTEST_APPLESS_MAIN(tst_QVector) +QTEST_APPLESS_MAIN(tst_QVectorND) #include "tst_qvectornd.moc" diff --git a/tests/auto/xmlpatternsdiagnosticsts/tst_xmlpatternsdiagnosticsts.cpp b/tests/auto/xmlpatternsdiagnosticsts/tst_xmlpatternsdiagnosticsts.cpp index 4a11404..f4f6181 100644 --- a/tests/auto/xmlpatternsdiagnosticsts/tst_xmlpatternsdiagnosticsts.cpp +++ b/tests/auto/xmlpatternsdiagnosticsts/tst_xmlpatternsdiagnosticsts.cpp @@ -52,25 +52,25 @@ \since 4.5 \brief Test QtXmlPatterns test suite driver in tests/auto/xmlpatternsxqts/lib/. */ -class tst_XmlPatternsXSLTS : public tst_SuiteTest +class tst_XmlPatternsDiagnosticsTS : public tst_SuiteTest { Q_OBJECT public: - tst_XmlPatternsXSLTS(); + tst_XmlPatternsDiagnosticsTS(); protected: virtual void catalogPath(QString &write) const; }; -tst_XmlPatternsXSLTS::tst_XmlPatternsXSLTS() : tst_SuiteTest(tst_SuiteTest::XQuerySuite, true) +tst_XmlPatternsDiagnosticsTS::tst_XmlPatternsDiagnosticsTS() : tst_SuiteTest(tst_SuiteTest::XQuerySuite, true) { } -void tst_XmlPatternsXSLTS::catalogPath(QString &write) const +void tst_XmlPatternsDiagnosticsTS::catalogPath(QString &write) const { write = QLatin1String("TestSuite/DiagnosticsCatalog.xml"); } -QTEST_MAIN(tst_XmlPatternsXSLTS) +QTEST_MAIN(tst_XmlPatternsDiagnosticsTS) #include "tst_xmlpatternsdiagnosticsts.moc" #else diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 8a47991..0aca545 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -973,6 +973,10 @@ void Configure::parseCmdLine() if(i==argCount) break; dictionary[ "QT_LIBINFIX" ] = configCmdLine.at(i); + if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith("symbian")) { + dictionary[ "QT_INSTALL_PLUGINS" ] = + QString("\\resource\\qt%1\\plugins").arg(dictionary[ "QT_LIBINFIX" ]); + } } else if( configCmdLine.at(i) == "-D" ) { ++i; if (i==argCount) @@ -3063,6 +3067,8 @@ void Configure::generateConfigfiles() qconfigList += "QT_NO_CRASHHANDLER"; qconfigList += "QT_NO_PRINTER"; qconfigList += "QT_NO_SYSTEMTRAYICON"; + if (dictionary.contains("QT_LIBINFIX")) + tmpStream << QString("#define QT_LIBINFIX \"%1\"").arg(dictionary["QT_LIBINFIX"]) << endl; } qconfigList.sort(); diff --git a/tools/runonphone/main.cpp b/tools/runonphone/main.cpp index 1a5cdee..af08777 100644 --- a/tools/runonphone/main.cpp +++ b/tools/runonphone/main.cpp @@ -44,9 +44,9 @@ #include <QStringList> #include <QScopedPointer> #include <QTimer> -#include "trkutils.h" -#include "trkdevice.h" -#include "launcher.h" +#include "symbianutils/trkutils.h" +#include "symbianutils/trkdevice.h" +#include "symbianutils/launcher.h" #include "trksignalhandler.h" #include "serenum.h" @@ -133,28 +133,28 @@ int main(int argc, char *argv[]) return 1; } - if(serialPortName.isEmpty()) { - if(loglevel > 0) + if (serialPortName.isEmpty()) { + if (loglevel > 0) outstream << "Detecting serial ports" << endl; - QList <SerialPortId> ports = enumerateSerialPorts(); - foreach(SerialPortId id, ports) { - if(loglevel > 0) + foreach (const SerialPortId &id, enumerateSerialPorts()) { + if (loglevel > 0) outstream << "Port Name: " << id.portName << ", " << "Friendly Name:" << id.friendlyName << endl; - if(serialPortName.isEmpty()) { - if(!id.friendlyName.isEmpty() && - serialPortFriendlyName.isEmpty() && - (id.friendlyName.contains("symbian", Qt::CaseInsensitive) || - id.friendlyName.contains("s60", Qt::CaseInsensitive) || - id.friendlyName.contains("nokia", Qt::CaseInsensitive))) - serialPortName = id.portName; - else if (!id.friendlyName.isEmpty() && - !serialPortFriendlyName.isEmpty() && - id.friendlyName.contains(serialPortFriendlyName)) - serialPortName = id.portName; + if (!id.friendlyName.isEmpty() + && serialPortFriendlyName.isEmpty() + && (id.friendlyName.contains("symbian", Qt::CaseInsensitive) + || id.friendlyName.contains("s60", Qt::CaseInsensitive) + || id.friendlyName.contains("nokia", Qt::CaseInsensitive))) { + serialPortName = id.portName; + break; + } else if (!id.friendlyName.isEmpty() + && !serialPortFriendlyName.isEmpty() + && id.friendlyName.contains(serialPortFriendlyName)) { + serialPortName = id.portName; + break; } } - if(serialPortName.isEmpty()) { + if (serialPortName.isEmpty()) { errstream << "No phone found, ensure USB cable is connected or specify manually with -p" << endl; return 1; } @@ -162,7 +162,7 @@ int main(int argc, char *argv[]) QScopedPointer<trk::Launcher> launcher; - if(sisFile.isEmpty()) { + if (sisFile.isEmpty()) { launcher.reset(new trk::Launcher(trk::Launcher::ActionCopyRun)); launcher->setCopyFileName(exeFile, QString("c:\\sys\\bin\\") + exeFile); errstream << "System TRK required to copy EXE, use --sis if using Application TRK" << endl; @@ -172,14 +172,14 @@ int main(int argc, char *argv[]) launcher->setCopyFileName(sisFile, "c:\\data\\testtemp.sis"); launcher->setInstallFileName("c:\\data\\testtemp.sis"); } - if(loglevel > 0) + if (loglevel > 0) outstream << "Connecting to target via " << serialPortName << endl; launcher->setTrkServerName(serialPortName); launcher->setFileName(QString("c:\\sys\\bin\\") + exeFile); launcher->setCommandLineArgs(cmdLine); - if(loglevel > 1) + if (loglevel > 1) launcher->setVerbose(1); TrkSignalHandler handler; @@ -212,7 +212,7 @@ int main(int argc, char *argv[]) } QString errorMessage; - if(!launcher->startServer(&errorMessage)) { + if (!launcher->startServer(&errorMessage)) { errstream << errorMessage << endl; return 1; } diff --git a/tools/runonphone/runonphone.pro b/tools/runonphone/runonphone.pro index 7bed3e5..0c63723 100644 --- a/tools/runonphone/runonphone.pro +++ b/tools/runonphone/runonphone.pro @@ -22,7 +22,10 @@ windows { } else:unix:!symbian { SOURCES += serenum_unix.cpp + LIBS += -lusb } else { SOURCES += serenum_stub.cpp } + + diff --git a/tools/runonphone/serenum_stub.cpp b/tools/runonphone/serenum_stub.cpp index f39765e..6f0e1ef 100644 --- a/tools/runonphone/serenum_stub.cpp +++ b/tools/runonphone/serenum_stub.cpp @@ -47,7 +47,7 @@ QList<SerialPortId> enumerateSerialPorts() { QList<SerialPortId> list; - qWarning() << "enumerateSerialPorts not implemented" << endl; + qWarning() << "enumerateSerialPorts not implemented"; return list; } diff --git a/tools/runonphone/serenum_unix.cpp b/tools/runonphone/serenum_unix.cpp index ca6c437..b6f0293 100644 --- a/tools/runonphone/serenum_unix.cpp +++ b/tools/runonphone/serenum_unix.cpp @@ -46,13 +46,80 @@ #include <QFileInfo> #include <QDir> +#include <usb.h> + QList<SerialPortId> enumerateSerialPorts() { + QList<QString> eligableInterfaces; QList<SerialPortId> list; + + usb_init(); + usb_find_busses(); + usb_find_devices(); + + for (struct usb_bus *bus = usb_get_busses(); bus; bus = bus->next) { + for (struct usb_device *device = bus->devices; device; device = device->next) { + for (int n = 0; n < device->descriptor.bNumConfigurations; ++n) { + struct usb_config_descriptor &usbConfig =device->config[n]; + QList<int> usableInterfaces; + for (int m = 0; m < usbConfig.bNumInterfaces; ++m) { + for (int o = 0; o < usbConfig.interface[m].num_altsetting; ++o) { + struct usb_interface_descriptor &descriptor = usbConfig.interface[m].altsetting[o]; + if (descriptor.bInterfaceClass != 2 // "Communication" + || descriptor.bInterfaceSubClass != 2 // Abstract (modem) + || descriptor.bInterfaceProtocol != 255) // Vendor Specific + continue; + + unsigned char *buf = descriptor.extra; + unsigned int size = descriptor.extralen; + while (size >= 2 * sizeof(u_int8_t)) { + // for Communication devices there is a slave interface for the actual + // data transmission. + // the extra info stores that as a index for the interface + if (buf[0] >= 5 && buf[1] == 36 && buf[2] == 6) { // CDC Union + for (int i = 4; i < buf[0]; i++) + usableInterfaces.append((int) buf[i]); + } + size -= buf[0]; + buf += buf[0]; + } + } + } + + // second loop to find the actual data interface. + foreach (int i, usableInterfaces) { + for (int m = 0; m < usbConfig.bNumInterfaces; ++m) { + for (int o = 0; o < usbConfig.interface[m].num_altsetting; ++o) { + struct usb_interface_descriptor &descriptor = usbConfig.interface[m].altsetting[o]; + if (descriptor.bInterfaceNumber != i) + continue; + if (descriptor.bInterfaceClass == 10) { // "CDC Data" + // qDebug() << " found the data port" + // << "bus:" << bus->dirname + // << "device" << device->filename + // << "interface" << descriptor.bInterfaceNumber; + eligableInterfaces << QString("if%1").arg(QString::number(i), 2, QChar('0')); // fix! + } + } + } + } + } + } + } + QDir dir("/dev/serial/by-id/"); - QFileInfoList ports(dir.entryInfoList()); - foreach(QFileInfo info, ports) { + foreach (const QFileInfo &info, dir.entryInfoList()) { if (!info.isDir()) { + bool usable = eligableInterfaces.isEmpty(); + foreach (const QString &iface, eligableInterfaces) { + if (info.fileName().contains(iface)) { + usable = true; + break; + } + } + if (!usable) + continue; + SerialPortId id; id.friendlyName = info.fileName(); id.portName = info.canonicalFilePath(); diff --git a/tools/runonphone/trksignalhandler.cpp b/tools/runonphone/trksignalhandler.cpp index 4fa79f1..18a2c0c 100644 --- a/tools/runonphone/trksignalhandler.cpp +++ b/tools/runonphone/trksignalhandler.cpp @@ -58,13 +58,13 @@ private: void TrkSignalHandler::copyingStarted() { - if(d->loglevel > 0) + if (d->loglevel > 0) d->out << "Copying..." << endl; } void TrkSignalHandler::canNotConnect(const QString &errorMessage) { - d->err << "Cannot Connect - " << errorMessage << endl; + d->err << "Cannot connect - " << errorMessage << endl; } void TrkSignalHandler::canNotCreateFile(const QString &filename, const QString &errorMessage) @@ -84,7 +84,7 @@ void TrkSignalHandler::canNotCloseFile(const QString &filename, const QString &e void TrkSignalHandler::installingStarted() { - if(d->loglevel > 0) + if (d->loglevel > 0) d->out << "Installing..." << endl; } @@ -95,19 +95,19 @@ void TrkSignalHandler::canNotInstall(const QString &packageFilename, const QStri void TrkSignalHandler::installingFinished() { - if(d->loglevel > 0) + if (d->loglevel > 0) d->out << "Installing finished" << endl; } void TrkSignalHandler::startingApplication() { - if(d->loglevel > 0) + if (d->loglevel > 0) d->out << "Starting app..." << endl; } void TrkSignalHandler::applicationRunning(uint pid) { - if(d->loglevel > 0) + if (d->loglevel > 0) d->out << "Running..." << endl; } @@ -118,29 +118,29 @@ void TrkSignalHandler::canNotRun(const QString &errorMessage) void TrkSignalHandler::finished() { - if(d->loglevel > 0) + if (d->loglevel > 0) d->out << "Done." << endl; QCoreApplication::quit(); } void TrkSignalHandler::applicationOutputReceived(const QString &output) { - d->out << output; + d->out << output << flush; } void TrkSignalHandler::copyProgress(int percent) { - if(d->loglevel > 0) { + if (d->loglevel > 0) { d->out << percent << "% "; d->out.flush(); - if(percent==100) + if (percent==100) d->out << endl; } } void TrkSignalHandler::stateChanged(int state) { - if(d->loglevel > 1) + if (d->loglevel > 1) d->out << "State" << state << endl; } @@ -164,10 +164,10 @@ void TrkSignalHandler::timeout() emit terminate(); } -TrkSignalHandlerPrivate::TrkSignalHandlerPrivate() : - out(stdout), - err(stderr), - loglevel(0) +TrkSignalHandlerPrivate::TrkSignalHandlerPrivate() + : out(stdout), + err(stderr), + loglevel(0) { } @@ -179,8 +179,8 @@ TrkSignalHandlerPrivate::~TrkSignalHandlerPrivate() } TrkSignalHandler::TrkSignalHandler() + : d(new TrkSignalHandlerPrivate()) { - d = new TrkSignalHandlerPrivate(); } TrkSignalHandler::~TrkSignalHandler() |