summaryrefslogtreecommitdiffstats
path: root/Lib/colorsys.py
Commit message (Expand)AuthorAgeFilesLines
* pep8tify conditionalsBenjamin Peterson2009-01-301-29/+58
* A very minor bug fix: this code looks like it is designed to acceptArmin Rigo2006-10-061-1/+2
* r879@spiff: Fredrik | 2005-11-12 14:38:03 +0100Fredrik Lundh2005-11-121-11/+14
* added __all__ lists to a number of Python modulesSkip Montanaro2001-01-201-0/+2
* Fix the question marks next to the expansions of some of theFred Drake2000-02-141-2/+2
* Oops, one more "x, y, z" to convert...Fred Drake1999-02-251-1/+1
* Adjusted comment at the top to be less confusing, following FredrikFred Drake1999-02-251-14/+16
* New module 'colorsys' implements conversions between different color systems.Guido van Rossum1992-09-071-0/+119
,7 @@ void MMF::AudioPlayer::MapcInitComplete(TInt aError, updateMetaData(); changeState(StoppedState); } else { - // TODO: set different error states according to value of aError? - setError(NormalError); + setError(tr("Opening clip failed"), aError); } TRACE_EXIT_0(); @@ -208,8 +206,7 @@ void MMF::AudioPlayer::MapcPlayComplete(TInt aError) changeState(StoppedState); // TODO: move on to m_nextSource } else { - // TODO: do something with aError? - setError(NormalError); + setError(tr("Playback complete"), aError); } /* diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 21dcfe1..6158ca1 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -238,7 +238,6 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) const bool oldPlayerHasVideo = oldPlayer->hasVideo(); const bool oldPlayerSeekable = oldPlayer->isSeekable(); - Phonon::ErrorType error = NoError; QString errorMessage; // Determine media type @@ -255,7 +254,6 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) } else { errorMessage = QLatin1String("Network streaming not supported yet"); - error = NormalError; } } break; @@ -263,8 +261,7 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) case MediaSource::Invalid: case MediaSource::Disc: case MediaSource::Stream: - TRACE_0("Unsupported media type"); - error = NormalError; + errorMessage = tr("Error opening source: type not supported"); break; case MediaSource::Empty: @@ -287,8 +284,7 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) newPlayer = new DummyPlayer(); } - error = NormalError; - errorMessage = tr("Media type could not be determined"); + errorMessage = tr("Error opening source: media type could not be determined"); break; case MediaTypeAudio: @@ -326,9 +322,9 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) // We need to call setError() after doing the connects, otherwise the // error won't be received. - if (error != NoError) { + if (!errorMessage.isEmpty()) { Q_ASSERT(m_player); - m_player->setError(error, errorMessage); + m_player->setError(errorMessage); } TRACE_EXIT_0(); diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp index b6f53ae..4619f54 100644 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp @@ -93,7 +93,7 @@ void MMF::VideoPlayer::construct() m_dsaActive = true; if (KErrNone != err) - changeState(ErrorState); + setError("Creation of video player failed", err); TRACE_EXIT_0(); } @@ -129,7 +129,7 @@ void MMF::VideoPlayer::doPause() TRAPD(err, m_player->PauseL()); if (KErrNone != err) { TRACE("PauseL error %d", err); - setError(NormalError); + setError(tr("Pause failed"), err); } } @@ -158,7 +158,7 @@ void MMF::VideoPlayer::doSeek(qint64 ms) } else { TRACE("SetPositionL error %d", err); - setError(NormalError); + setError(tr("Seek failed"), err); } } @@ -200,7 +200,7 @@ qint64 MMF::VideoPlayer::currentTime() const // If we don't cast away constness here, we simply have to ignore // the error. - const_cast(this)->setError(NormalError); + const_cast(this)->setError(tr("Getting position failed"), err); } return result; @@ -226,7 +226,7 @@ void MMF::VideoPlayer::MvpuoOpenComplete(TInt aError) if (KErrNone == aError) m_player->Prepare(); else - setError(NormalError); + setError(tr("Opening clip failed"), aError); TRACE_EXIT_0(); } @@ -252,7 +252,7 @@ void MMF::VideoPlayer::MvpuoPrepareComplete(TInt aError) emit totalTimeChanged(totalTime()); changeState(StoppedState); } else { - setError(NormalError); + setError(tr("Buffering clip failed"), err); } TRACE_EXIT_0(); @@ -412,7 +412,7 @@ void MMF::VideoPlayer::startDirectScreenAccess() if(KErrNone == err) m_dsaActive = true; else - setError(NormalError); + setError(tr("Video display error"), err); } } @@ -424,7 +424,7 @@ bool MMF::VideoPlayer::stopDirectScreenAccess() if(KErrNone == err) m_dsaActive = false; else - setError(NormalError); + setError(tr("Video display error"), err); } return dsaWasActive; } @@ -600,7 +600,7 @@ void MMF::VideoPlayer::applyVideoWindowChange() TRAPD(err, m_player->SetScaleFactorL(m_scaleWidth, m_scaleHeight, antialias)); if(KErrNone != err) { TRACE("SetScaleFactorL (1) err %d", err); - setError(NormalError); + setError(tr("Video display error"), err); } if(KErrNone == err) { @@ -615,13 +615,13 @@ void MMF::VideoPlayer::applyVideoWindowChange() if (KErrNone != err) { TRACE("SetDisplayWindowL err %d", err); - setError(NormalError); + 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(NormalError); + setError(tr("Video display error"), err); } } } diff --git a/src/3rdparty/phonon/mmf/utils.cpp b/src/3rdparty/phonon/mmf/utils.cpp index d728fcf..75fec9f 100644 --- a/src/3rdparty/phonon/mmf/utils.cpp +++ b/src/3rdparty/phonon/mmf/utils.cpp @@ -18,6 +18,7 @@ along with this library. If not, see . #include "utils.h" #include +#include QT_BEGIN_NAMESPACE @@ -69,6 +70,103 @@ MMF::MediaType MMF::Utils::mimeTypeToMediaType(const TDesC& mimeType) return result; } +QString MMF::Utils::symbianErrorToString(int errorCode) +{ + /** + * Here we translate only the error codes which are likely to be + * meaningful to the user. For example, when an error occurs + * during opening of a media file, displaying "not found" or + * "permission denied" is informative. On the other hand, + * differentiating between KErrGeneral and KErrArgument at the UI + * level does not make sense. + */ + switch (errorCode) + { + // System-wide errors + case KErrNone: + return tr("no error"); + case KErrNotFound: + return tr("not found"); + case KErrNoMemory: + return tr("out of memory"); + case KErrNotSupported: + return tr("not supported"); + case KErrOverflow: + return tr("overflow"); + case KErrUnderflow: + return tr("underflow"); + case KErrAlreadyExists: + return tr("already exists"); + case KErrPathNotFound: + return tr("path not found"); + case KErrInUse: + return tr("in use"); + case KErrNotReady: + return tr("not ready"); + case KErrAccessDenied: + return tr("access denied"); + case KErrCouldNotConnect: + return tr("could not connect"); + case KErrDisconnected: + return tr("disconnected"); + case KErrPermissionDenied: + return tr("permission denied"); + + // Multimedia framework errors + case KErrMMNotEnoughBandwidth: + return tr("insufficient bandwidth"); + case KErrMMSocketServiceNotFound: + case KErrMMServerSocket: + return tr("network unavailable"); + case KErrMMNetworkRead: + case KErrMMNetworkWrite: + case KErrMMUDPReceive: + return tr("network communication error"); + case KErrMMServerNotSupported: + return tr("streaming not supported"); + case KErrMMServerAlert: + return tr("server alert"); + case KErrMMInvalidProtocol: + return tr("invalid protocol"); + case KErrMMInvalidURL: + return tr("invalid URL"); + case KErrMMMulticast: + return tr("multicast error"); + case KErrMMProxyServer: + case KErrMMProxyServerConnect: + return tr("proxy server error"); + case KErrMMProxyServerNotSupported: + return tr("proxy server not supported"); + case KErrMMAudioDevice: + return tr("audio output error"); + case KErrMMVideoDevice: + return tr("video output error"); + case KErrMMDecoder: + return tr("decoder error"); + case KErrMMPartialPlayback: + return tr("audio or video components could not be played"); + case KErrMMDRMNotAuthorized: + return tr("DRM error"); + + /* + // We don't use QoS settings + case KErrMMQosLowBandwidth: + case KErrMMQosUnsupportedTrafficClass: + case KErrMMQosPoorTrafficClass: + case KErrMMQosUnsupportedParameters: + case KErrMMQosPoorParameters: + case KErrMMQosNotSupported: + */ + + // Catch-all for errors other than those above + default: + { + QString errorString; + errorString.setNum(errorCode); + return tr("unknown error") + " (" + errorString + ")"; + } + } +} #ifndef QT_NO_DEBUG diff --git a/src/3rdparty/phonon/mmf/utils.h b/src/3rdparty/phonon/mmf/utils.h index 7e363e8..60c03a5 100644 --- a/src/3rdparty/phonon/mmf/utils.h +++ b/src/3rdparty/phonon/mmf/utils.h @@ -21,7 +21,7 @@ along with this library. If not, see . #include #include // for RDebug - +#include // for Q_DECLARE_TR_FUNCTIONS #include #include "defs.h" @@ -41,32 +41,40 @@ enum PanicCode { InvalidBackendInterfaceClass = 3 }; -namespace Utils +class Utils { + Q_DECLARE_TR_FUNCTIONS(Utils) + +public: /** * Raise a fatal exception */ -void panic(PanicCode code); +static void panic(PanicCode code); /** * Determines whether the provided MIME type is an audio or video * type. If it is neither, the function returns MediaTypeUnknown. */ -MediaType mimeTypeToMediaType(const TDesC& mimeType); +static MediaType mimeTypeToMediaType(const TDesC& mimeType); + +/** + * Translates a Symbian error code into a user-readable string. + */ +static QString symbianErrorToString(int errorCode); #ifndef QT_NO_DEBUG /** * Retrieve color of specified pixel from the screen. */ -QColor getScreenPixel(const QPoint& pos); +static QColor getScreenPixel(const QPoint& pos); /** * Samples a small number of pixels from the screen, and dumps their * colors to the debug log. */ -void dumpScreenPixelSample(); +static void dumpScreenPixelSample(); #endif -} +}; /** * Available trace categories; -- cgit v0.12 From dfa9343cc1e634eebdb0f3a2cf931ada9829ae6b Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 1 Dec 2009 14:35:43 +0000 Subject: Fixed bug which caused Phonon backend error messages to be suppressed When the mediaplayer receives a state change into the ErrorState, it calls pause() on the media object. Previously, this caused the backend to transition into PausedState. When the mediaplayer subsequently called errorString() to retrieve the error message, an empty string was returned because the backend was no longer in the ErrorState. Task-number: QTBUG-4994 Reviewed-by: trustme --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 11 ++++++----- src/3rdparty/phonon/mmf/mmf_videoplayer.cpp | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index bc38513..adade9c 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -104,21 +104,22 @@ void MMF::AbstractMediaPlayer::pause() TRACE_ENTRY("state %d", privateState()); m_playPending = false; + stopTickTimer(); switch (privateState()) { case GroundState: case LoadingState: case PausedState: + case StoppedState: // Do nothing break; - case StoppedState: case PlayingState: - case ErrorState: case BufferingState: - doPause(); - stopTickTimer(); changeState(PausedState); + // Fall through + case ErrorState: + doPause(); break; // Protection against adding new states and forgetting to update this switch @@ -135,6 +136,7 @@ void MMF::AbstractMediaPlayer::stop() TRACE_ENTRY("state %d", privateState()); m_playPending = false; + stopTickTimer(); switch (privateState()) { case GroundState: @@ -148,7 +150,6 @@ void MMF::AbstractMediaPlayer::stop() case BufferingState: case PausedState: doStop(); - stopTickTimer(); changeState(StoppedState); break; diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp index 4619f54..eb6f690 100644 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp @@ -127,7 +127,7 @@ void MMF::VideoPlayer::doPause() TRACE_CONTEXT(VideoPlayer::doPause, EVideoApi); TRAPD(err, m_player->PauseL()); - if (KErrNone != err) { + if (KErrNone != err && state() != ErrorState) { TRACE("PauseL error %d", err); setError(tr("Pause failed"), err); } -- cgit v0.12 From db782f7ab22241d8161190b95c41af4d56c05b82 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Mon, 7 Dec 2009 15:09:33 +0100 Subject: Symbian: More i18n strings work. * Consistently capitalize error sentences * Simplify & fix code/documentation. Task-number: QTBUG-4994 Reviewed-by: TrustMe --- src/3rdparty/phonon/mmf/abstractplayer.h | 4 +- src/3rdparty/phonon/mmf/utils.cpp | 64 ++++++++++++++++---------------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index 9af1362..cd15baf 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -96,7 +96,9 @@ public: * * Appends a human-readable version of symbianErrorCode to the error message, * e.g. - * setError(NormalError, "Opening file failed", KErrPermissionDenied) + * @code + * setError("Opening file failed", KErrPermissionDenied) + * @endcode * results in the following error message: * "Opening file failed: permission denied" */ diff --git a/src/3rdparty/phonon/mmf/utils.cpp b/src/3rdparty/phonon/mmf/utils.cpp index 75fec9f..2d17bd2 100644 --- a/src/3rdparty/phonon/mmf/utils.cpp +++ b/src/3rdparty/phonon/mmf/utils.cpp @@ -84,67 +84,67 @@ QString MMF::Utils::symbianErrorToString(int errorCode) { // System-wide errors case KErrNone: - return tr("no error"); + return tr("No error"); case KErrNotFound: - return tr("not found"); + return tr("Not found"); case KErrNoMemory: - return tr("out of memory"); + return tr("Out of memory"); case KErrNotSupported: - return tr("not supported"); + return tr("Not supported"); case KErrOverflow: - return tr("overflow"); + return tr("Overflow"); case KErrUnderflow: - return tr("underflow"); + return tr("Underflow"); case KErrAlreadyExists: - return tr("already exists"); + return tr("Already exists"); case KErrPathNotFound: - return tr("path not found"); + return tr("Path not found"); case KErrInUse: - return tr("in use"); + return tr("In use"); case KErrNotReady: - return tr("not ready"); + return tr("Not ready"); case KErrAccessDenied: - return tr("access denied"); + return tr("Access denied"); case KErrCouldNotConnect: - return tr("could not connect"); + return tr("Could not connect"); case KErrDisconnected: - return tr("disconnected"); + return tr("Disconnected"); case KErrPermissionDenied: - return tr("permission denied"); + return tr("Permission denied"); // Multimedia framework errors case KErrMMNotEnoughBandwidth: - return tr("insufficient bandwidth"); + return tr("Insufficient bandwidth"); case KErrMMSocketServiceNotFound: case KErrMMServerSocket: - return tr("network unavailable"); + return tr("Network unavailable"); case KErrMMNetworkRead: case KErrMMNetworkWrite: case KErrMMUDPReceive: - return tr("network communication error"); + return tr("Network communication error"); case KErrMMServerNotSupported: - return tr("streaming not supported"); + return tr("Streaming not supported"); case KErrMMServerAlert: - return tr("server alert"); + return tr("Server alert"); case KErrMMInvalidProtocol: - return tr("invalid protocol"); + return tr("Invalid protocol"); case KErrMMInvalidURL: - return tr("invalid URL"); + return tr("Invalid URL"); case KErrMMMulticast: - return tr("multicast error"); + return tr("Multicast error"); case KErrMMProxyServer: case KErrMMProxyServerConnect: - return tr("proxy server error"); + return tr("Proxy server error"); case KErrMMProxyServerNotSupported: - return tr("proxy server not supported"); + return tr("Proxy server not supported"); case KErrMMAudioDevice: - return tr("audio output error"); + return tr("Audio output error"); case KErrMMVideoDevice: - return tr("video output error"); + return tr("Video output error"); case KErrMMDecoder: - return tr("decoder error"); + return tr("Decoder error"); case KErrMMPartialPlayback: - return tr("audio or video components could not be played"); + return tr("Audio or video components could not be played"); case KErrMMDRMNotAuthorized: return tr("DRM error"); @@ -160,11 +160,9 @@ QString MMF::Utils::symbianErrorToString(int errorCode) // Catch-all for errors other than those above default: - { - QString errorString; - errorString.setNum(errorCode); - return tr("unknown error") + " (" + errorString + ")"; - } + { + return tr("Unknown error (%1)").arg(errorCode); + } } } -- cgit v0.12 From 99b10b64fd5f68c63e0c406558b507e429eea248 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 2 Dec 2009 16:59:46 +0000 Subject: Removed stale TODO comments from Phonon MMF backend Reviewed-by: Frans Englich --- src/3rdparty/phonon/mmf/mediaobject.h | 1 - src/3rdparty/phonon/mmf/mmf_videoplayer.cpp | 2 -- src/3rdparty/phonon/mmf/objectdump.cpp | 2 +- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index ee94ea2..d6f4c7b 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -98,7 +98,6 @@ Q_SIGNALS: void aboutToFinish(); // TODO: emit prefinishMarkReached from MediaObject void prefinishMarkReached(qint32); - // TODO: emit metaDataChanged from MediaObject void metaDataChanged(const QMultiMap& metaData); void currentSourceChanged(const MediaSource& source); void stateChanged(Phonon::State oldState, diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp index eb6f690..66bbe38 100644 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp @@ -277,7 +277,6 @@ void MMF::VideoPlayer::MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError) TRACE_CONTEXT(VideoPlayer::MvpuoFrameReady, EVideoApi); TRACE_ENTRY("state %d error %d", state(), aError); - // TODO Q_UNUSED(aFrame); Q_UNUSED(aError); // suppress warnings in release builds @@ -300,7 +299,6 @@ void MMF::VideoPlayer::MvpuoEvent(const TMMFEvent &aEvent) TRACE_CONTEXT(VideoPlayer::MvpuoEvent, EVideoApi); TRACE_ENTRY("state %d", state()); - // TODO Q_UNUSED(aEvent); TRACE_EXIT_0(); diff --git a/src/3rdparty/phonon/mmf/objectdump.cpp b/src/3rdparty/phonon/mmf/objectdump.cpp index 3d10be4..778cde9 100644 --- a/src/3rdparty/phonon/mmf/objectdump.cpp +++ b/src/3rdparty/phonon/mmf/objectdump.cpp @@ -390,7 +390,7 @@ void QVisitorPrivate::dumpNode // No annotations - just dump the object pointer const bool isNodeLine = true; QByteArray buffer = branchBuffer(branches, isNodeLine, isLastChild); - qDebug() << 0; // TODO + qDebug() << 0; } else { // Dump annotations -- cgit v0.12 From bbab8eabb91b95dcd946c94b5f0ac59413e7a929 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 3 Dec 2009 15:44:55 +0000 Subject: Phonon MMF: leaves during object construction throw exceptions Reviewed-by: Frans Englich --- src/3rdparty/phonon/mmf/audioplayer.cpp | 6 +++--- src/3rdparty/phonon/mmf/mmf_videoplayer.cpp | 10 ++++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index 72d6684..2ce10db 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -50,9 +50,9 @@ void MMF::AudioPlayer::construct() TRACE_CONTEXT(AudioPlayer::AudioPlayer, EAudioApi); TRACE_ENTRY_0(); - TRAPD(err, m_player.reset(CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone))); - if (KErrNone != err) - setError("Creation of audio player failed", err); + CPlayerType *player = 0; + QT_TRAP_THROWING(player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone)); + m_player.reset(player); TRACE_EXIT_0(); } diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp index 66bbe38..0a1c78f 100644 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp @@ -78,23 +78,21 @@ void MMF::VideoPlayer::construct() const TInt priority = 0; const TMdaPriorityPreference preference = EMdaPriorityPreferenceNone; - TRAPD(err, - m_player.reset(CVideoPlayerUtility::NewL + 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; - if (KErrNone != err) - setError("Creation of video player failed", err); - TRACE_EXIT_0(); } -- cgit v0.12 From 3117e3a6a9c1bf95fc30ebee4d8d11b646cb7125 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 5 Nov 2009 18:13:47 +0000 Subject: Added support for streaming playback to Phonon MMF backend Because the MIME type of the stream cannot always be deduced from the URL, we assume that it is a video stream. This is based on the assumption that the video controllers will be capable of parsing the container formats for audio-only, as well as video clips. Note that this assumption may not hold on all devices. Note that most implementations of the MMF client APIs do not support HTTP streaming (a.k.a. progressive download). The backend has therefore only been tested with RTSP streams - see the JIRA entry for further details. Task-number: QTBUG-4660 Reviewed-by: Frans Englich --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 8 ++++---- src/3rdparty/phonon/mmf/abstractmediaplayer.h | 1 + src/3rdparty/phonon/mmf/audioplayer.cpp | 11 +++++++++++ src/3rdparty/phonon/mmf/audioplayer.h | 1 + src/3rdparty/phonon/mmf/mediaobject.cpp | 5 ++++- src/3rdparty/phonon/mmf/mmf_videoplayer.cpp | 6 ++++++ src/3rdparty/phonon/mmf/mmf_videoplayer.h | 1 + src/3rdparty/phonon/mmf/utils.h | 3 ++- 8 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index adade9c..260d8e6 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -243,12 +243,12 @@ void MMF::AbstractMediaPlayer::setFileSource(const MediaSource &source, RFile& f if (url.scheme() == QLatin1String("file")) { symbianErr = openFile(file); if (KErrNone != symbianErr) + errorMessage = tr("Error opening file"); + } else { + symbianErr = openUrl(url.toString()); + if (KErrNone != symbianErr) errorMessage = tr("Error opening URL"); } - else { - TRACE_0("Error opening URL: protocol not supported"); - errorMessage = tr("Error opening URL: protocol not supported"); - } break; } diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h index cb6e437..0432b07 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h @@ -68,6 +68,7 @@ protected: virtual void doSeek(qint64 pos) = 0; virtual int setDeviceVolume(int mmfVolume) = 0; virtual int openFile(RFile& file) = 0; + virtual int openUrl(const QString& url) = 0; virtual void close() = 0; virtual void changeState(PrivateState newState); diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index 2ce10db..2d618b8 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -124,6 +124,17 @@ int MMF::AudioPlayer::openFile(RFile& file) return err; } +int MMF::AudioPlayer::openUrl(const QString& /*url*/) +{ + // Streaming playback is generally not supported by the implementation + // of the audio player API, so we use CVideoPlayerUtility for both + // audio and video streaming. + Utils::panic(AudioUtilityUrlNotSupported); + + // Silence warning + return 0; +} + void MMF::AudioPlayer::close() { m_player->Close(); diff --git a/src/3rdparty/phonon/mmf/audioplayer.h b/src/3rdparty/phonon/mmf/audioplayer.h index bc60076..4674afc 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.h +++ b/src/3rdparty/phonon/mmf/audioplayer.h @@ -63,6 +63,7 @@ public: virtual void doSeek(qint64 milliseconds); virtual int setDeviceVolume(int mmfVolume); virtual int openFile(RFile& file); + virtual int openUrl(const QString& url); virtual void close(); // MediaObjectInterface diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 6158ca1..ca3e837 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -253,7 +253,10 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) mediaType = fileMediaType(url.toLocalFile()); } else { - errorMessage = QLatin1String("Network streaming not supported yet"); + // Streaming playback is generally not supported by the implementation + // of the audio player API, so we use CVideoPlayerUtility for both + // audio and video streaming. + mediaType = MediaTypeVideo; } } break; diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp index 0a1c78f..62bbdef 100644 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp @@ -172,6 +172,12 @@ int MMF::VideoPlayer::openFile(RFile& file) return err; } +int MMF::VideoPlayer::openUrl(const QString& url) +{ + TRAPD(err, m_player->OpenUrlL(qt_QString2TPtrC(url))); + return err; +} + void MMF::VideoPlayer::close() { m_player->Close(); diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.h b/src/3rdparty/phonon/mmf/mmf_videoplayer.h index abb1da8..7c42991 100644 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.h +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.h @@ -54,6 +54,7 @@ public: virtual void doSeek(qint64 milliseconds); virtual int setDeviceVolume(int mmfVolume); virtual int openFile(RFile& file); + virtual int openUrl(const QString& url); virtual void close(); // MediaObjectInterface diff --git a/src/3rdparty/phonon/mmf/utils.h b/src/3rdparty/phonon/mmf/utils.h index 60c03a5..56ccafc 100644 --- a/src/3rdparty/phonon/mmf/utils.h +++ b/src/3rdparty/phonon/mmf/utils.h @@ -38,7 +38,8 @@ namespace MMF enum PanicCode { InvalidStatePanic = 1, InvalidMediaTypePanic = 2, - InvalidBackendInterfaceClass = 3 + InvalidBackendInterfaceClass = 3, + AudioUtilityUrlNotSupported = 4 }; class Utils -- cgit v0.12 From bed33ac62d87073120d56ff75a3d2356c99c64ea Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 1 Dec 2009 17:55:30 +0000 Subject: Implemented buffer status notifications in Phonon MMF backend When clips are buffering (either at the start of playback, or during playback, when buffer levels drop due to e.g. CPU, file system or network load), the backend receives notification from the MMF. While buffering is ongoing, the backend periodically queries the filling status and emits a signal. Task-number: QTBUG-4660 Reviewed-by: Frans Englich --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 80 +++++++++++++++++++------ src/3rdparty/phonon/mmf/abstractmediaplayer.h | 23 ++++--- src/3rdparty/phonon/mmf/abstractplayer.h | 1 + src/3rdparty/phonon/mmf/audioplayer.cpp | 25 +++++++- src/3rdparty/phonon/mmf/audioplayer.h | 34 +++++------ src/3rdparty/phonon/mmf/mediaobject.cpp | 1 + src/3rdparty/phonon/mmf/mediaobject.h | 1 - src/3rdparty/phonon/mmf/mmf_videoplayer.cpp | 27 ++++++++- src/3rdparty/phonon/mmf/mmf_videoplayer.h | 32 ++++++---- 9 files changed, 162 insertions(+), 62 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index 260d8e6..6e7f458 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -36,6 +36,7 @@ using namespace Phonon::MMF; //----------------------------------------------------------------------------- const int NullMaxVolume = -1; +const int BufferStatusTimerInterval = 100; // ms //----------------------------------------------------------------------------- @@ -44,19 +45,23 @@ const int NullMaxVolume = -1; MMF::AbstractMediaPlayer::AbstractMediaPlayer() : m_playPending(false) - , m_tickTimer(new QTimer(this)) + , m_positionTimer(new QTimer(this)) + , m_bufferStatusTimer(new QTimer(this)) , m_mmfMaxVolume(NullMaxVolume) { - connect(m_tickTimer.data(), SIGNAL(timeout()), this, SLOT(tick())); + connect(m_positionTimer.data(), SIGNAL(timeout()), this, SLOT(positionTick())); + connect(m_bufferStatusTimer.data(), SIGNAL(timeout()), this, SLOT(bufferStatusTick())); } MMF::AbstractMediaPlayer::AbstractMediaPlayer(const AbstractPlayer& player) : AbstractPlayer(player) , m_playPending(false) - , m_tickTimer(new QTimer(this)) + , m_positionTimer(new QTimer(this)) + , m_bufferStatusTimer(new QTimer(this)) , m_mmfMaxVolume(NullMaxVolume) { - connect(m_tickTimer.data(), SIGNAL(timeout()), this, SLOT(tick())); + connect(m_positionTimer.data(), SIGNAL(timeout()), this, SLOT(positionTick())); + connect(m_bufferStatusTimer.data(), SIGNAL(timeout()), this, SLOT(bufferStatusTick())); } //----------------------------------------------------------------------------- @@ -80,7 +85,7 @@ void MMF::AbstractMediaPlayer::play() case StoppedState: case PausedState: doPlay(); - startTickTimer(); + startPositionTimer(); changeState(PlayingState); break; @@ -104,7 +109,7 @@ void MMF::AbstractMediaPlayer::pause() TRACE_ENTRY("state %d", privateState()); m_playPending = false; - stopTickTimer(); + stopTimers(); switch (privateState()) { case GroundState: @@ -136,7 +141,7 @@ void MMF::AbstractMediaPlayer::stop() TRACE_ENTRY("state %d", privateState()); m_playPending = false; - stopTickTimer(); + stopTimers(); switch (privateState()) { case GroundState: @@ -174,14 +179,13 @@ void MMF::AbstractMediaPlayer::seek(qint64 ms) case PlayingState: case LoadingState: { - const bool tickTimerWasRunning = m_tickTimer->isActive(); - stopTickTimer(); + const bool positionTimerWasRunning = m_positionTimer->isActive(); + stopPositionTimer(); doSeek(ms); - if (tickTimerWasRunning) { - startTickTimer(); - } + if (positionTimerWasRunning) + startPositionTimer(); break; } case BufferingState: @@ -204,7 +208,7 @@ void MMF::AbstractMediaPlayer::doSetTickInterval(qint32 interval) TRACE_CONTEXT(AbstractMediaPlayer::doSetTickInterval, EAudioApi); TRACE_ENTRY("state %d m_interval %d interval %d", privateState(), tickInterval(), interval); - m_tickTimer->setInterval(interval); + m_positionTimer->setInterval(interval); TRACE_EXIT_0(); } @@ -307,6 +311,35 @@ void MMF::AbstractMediaPlayer::volumeChanged(qreal volume) TRACE_EXIT_0(); } +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- + +void MMF::AbstractMediaPlayer::startPositionTimer() +{ + m_positionTimer->start(tickInterval()); +} + +void MMF::AbstractMediaPlayer::stopPositionTimer() +{ + m_positionTimer->stop(); +} + +void MMF::AbstractMediaPlayer::startBufferStatusTimer() +{ + m_bufferStatusTimer->start(BufferStatusTimerInterval); +} + +void MMF::AbstractMediaPlayer::stopBufferStatusTimer() +{ + m_bufferStatusTimer->stop(); +} + +void MMF::AbstractMediaPlayer::stopTimers() +{ + stopPositionTimer(); + stopBufferStatusTimer(); +} void MMF::AbstractMediaPlayer::doVolumeChanged() { @@ -342,14 +375,19 @@ void MMF::AbstractMediaPlayer::doVolumeChanged() // Protected functions //----------------------------------------------------------------------------- -void MMF::AbstractMediaPlayer::startTickTimer() +void MMF::AbstractMediaPlayer::bufferingStarted() { - m_tickTimer->start(tickInterval()); + m_stateBeforeBuffering = privateState(); + changeState(BufferingState); + bufferStatusTick(); + startBufferStatusTimer(); } -void MMF::AbstractMediaPlayer::stopTickTimer() +void MMF::AbstractMediaPlayer::bufferingComplete() { - m_tickTimer->stop(); + stopBufferStatusTimer(); + emit MMF::AbstractPlayer::bufferStatus(100); + changeState(m_stateBeforeBuffering); } void MMF::AbstractMediaPlayer::maxVolumeChanged(int mmfMaxVolume) @@ -367,12 +405,16 @@ qint64 MMF::AbstractMediaPlayer::toMilliSeconds(const TTimeIntervalMicroSeconds // Slots //----------------------------------------------------------------------------- -void MMF::AbstractMediaPlayer::tick() +void MMF::AbstractMediaPlayer::positionTick() { - // For the MWC compiler, we need to qualify the base class. emit MMF::AbstractPlayer::tick(currentTime()); } +void MMF::AbstractMediaPlayer::bufferStatusTick() +{ + emit MMF::AbstractPlayer::bufferStatus(bufferStatus()); +} + void MMF::AbstractMediaPlayer::changeState(PrivateState newState) { TRACE_CONTEXT(AbstractMediaPlayer::changeState, EAudioInternal); diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h index 0432b07..7c11ec7 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h @@ -69,6 +69,7 @@ protected: virtual int setDeviceVolume(int mmfVolume) = 0; virtual int openFile(RFile& file) = 0; virtual int openUrl(const QString& url) = 0; + virtual int bufferStatus() const = 0; virtual void close() = 0; virtual void changeState(PrivateState newState); @@ -77,21 +78,22 @@ protected: virtual QPair metaDataEntry(int index) const = 0; protected: - bool tickTimerRunning() const; - void startTickTimer(); - void stopTickTimer(); + void bufferingStarted(); + void bufferingComplete(); void maxVolumeChanged(int maxVolume); - static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); private: + void startPositionTimer(); + void stopPositionTimer(); + void startBufferStatusTimer(); + void stopBufferStatusTimer(); + void stopTimers(); void doVolumeChanged(); private Q_SLOTS: - /** - * Receives signal from m_tickTimer - */ - void tick(); + void positionTick(); + void bufferStatusTick(); private: /** @@ -101,7 +103,10 @@ private: */ bool m_playPending; - QScopedPointer m_tickTimer; + QScopedPointer m_positionTimer; + + QScopedPointer m_bufferStatusTimer; + PrivateState m_stateBeforeBuffering; int m_mmfMaxVolume; diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index cd15baf..5aaae3c 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -110,6 +110,7 @@ Q_SIGNALS: void totalTimeChanged(qint64 length); void finished(); void tick(qint64 time); + void bufferStatus(int percentFilled); void stateChanged(Phonon::State oldState, Phonon::State newState); void metaDataChanged(const QMultiMap& metaData); diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index 2d618b8..0967a27 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -53,6 +53,7 @@ void MMF::AudioPlayer::construct() CPlayerType *player = 0; QT_TRAP_THROWING(player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone)); m_player.reset(player); + m_player->RegisterForAudioLoadingNotification(*this); TRACE_EXIT_0(); } @@ -135,6 +136,13 @@ int MMF::AudioPlayer::openUrl(const QString& /*url*/) return 0; } +int MMF::AudioPlayer::bufferStatus() const +{ + int result = 0; + TRAP_IGNORE(m_player->GetAudioLoadingProgressL(result)); + return result; +} + void MMF::AudioPlayer::close() { m_player->Close(); @@ -211,8 +219,6 @@ void MMF::AudioPlayer::MapcPlayComplete(TInt aError) TRACE_CONTEXT(AudioPlayer::MapcPlayComplete, EAudioInternal); TRACE_ENTRY("state %d error %d", state(), aError); - stopTickTimer(); - if (KErrNone == aError) { changeState(StoppedState); // TODO: move on to m_nextSource @@ -260,6 +266,21 @@ void MMF::AudioPlayer::MaloLoadingComplete() //----------------------------------------------------------------------------- +// MAudioLoadingObserver callbacks +//----------------------------------------------------------------------------- + +void MMF::AudioPlayer::MaloLoadingStarted() +{ + bufferingStarted(); +} + +void MMF::AudioPlayer::MaloLoadingComplete() +{ + bufferingComplete(); +} + + +//----------------------------------------------------------------------------- // Private functions //----------------------------------------------------------------------------- diff --git a/src/3rdparty/phonon/mmf/audioplayer.h b/src/3rdparty/phonon/mmf/audioplayer.h index 4674afc..5c7cfc1 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.h +++ b/src/3rdparty/phonon/mmf/audioplayer.h @@ -45,9 +45,7 @@ namespace MMF */ class AudioPlayer : public AbstractMediaPlayer , public MPlayerObserverType // typedef -#ifdef QT_PHONON_MMF_AUDIO_DRM , public MAudioLoadingObserver -#endif { Q_OBJECT @@ -64,6 +62,7 @@ public: virtual int setDeviceVolume(int mmfVolume); virtual int openFile(RFile& file); virtual int openUrl(const QString& url); + virtual int bufferStatus() const; virtual void close(); // MediaObjectInterface @@ -71,15 +70,24 @@ public: virtual qint64 currentTime() const; virtual qint64 totalTime() const; + // AbstractMediaPlayer + virtual int numberOfMetaDataEntries() const; + virtual QPair metaDataEntry(int index) const; + + /** + * This class owns the pointer. + */ + CPlayerType *player() const; + +private: + void construct(); + +private: #ifdef QT_PHONON_MMF_AUDIO_DRM // MDrmAudioPlayerCallback virtual void MdapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds &aDuration); virtual void MdapcPlayComplete(TInt aError); - - // MAudioLoadingObserver - virtual void MaloLoadingStarted(); - virtual void MaloLoadingComplete(); #else // MMdaAudioPlayerCallback virtual void MapcInitComplete(TInt aError, @@ -87,17 +95,9 @@ public: virtual void MapcPlayComplete(TInt aError); #endif - /** - * This class owns the pointer. - */ - CPlayerType *player() const; - -private: - void construct(); - - // AbstractMediaPlayer - virtual int numberOfMetaDataEntries() const; - virtual QPair metaDataEntry(int index) const; + // MAudioLoadingObserver + virtual void MaloLoadingStarted(); + virtual void MaloLoadingComplete(); private: /** diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index ca3e837..bf1f268 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -321,6 +321,7 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) connect(m_player.data(), SIGNAL(stateChanged(Phonon::State,Phonon::State)), SIGNAL(stateChanged(Phonon::State,Phonon::State))); connect(m_player.data(), SIGNAL(finished()), SIGNAL(finished())); connect(m_player.data(), SIGNAL(tick(qint64)), SIGNAL(tick(qint64))); + connect(m_player.data(), SIGNAL(bufferStatus(int)), SIGNAL(bufferStatus(int))); connect(m_player.data(), SIGNAL(metaDataChanged(QMultiMap)), SIGNAL(metaDataChanged(QMultiMap))); // We need to call setError() after doing the connects, otherwise the diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index d6f4c7b..07baad0 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -92,7 +92,6 @@ Q_SIGNALS: void totalTimeChanged(qint64 length); void hasVideoChanged(bool hasVideo); void seekableChanged(bool seekable); - // TODO: emit bufferStatus from MediaObject void bufferStatus(int); // TODO: emit aboutToFinish from MediaObject void aboutToFinish(); diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp index 62bbdef..4a70d58 100644 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp @@ -93,6 +93,8 @@ void MMF::VideoPlayer::construct() // CVideoPlayerUtility::NewL starts DSA m_dsaActive = true; + m_player->RegisterForVideoLoadingNotification(*this); + TRACE_EXIT_0(); } @@ -178,6 +180,13 @@ int MMF::VideoPlayer::openUrl(const QString& 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(); @@ -292,7 +301,8 @@ void MMF::VideoPlayer::MvpuoPlayComplete(TInt aError) TRACE_CONTEXT(VideoPlayer::MvpuoPlayComplete, EVideoApi) TRACE_ENTRY("state %d error %d", state(), aError); - Q_UNUSED(aError); // suppress warnings in release builds + // TODO: handle aError + Q_UNUSED(aError); changeState(StoppedState); TRACE_EXIT_0(); @@ -310,6 +320,21 @@ void MMF::VideoPlayer::MvpuoEvent(const TMMFEvent &aEvent) //----------------------------------------------------------------------------- +// MVideoLoadingObserver callbacks +//----------------------------------------------------------------------------- + +void MMF::VideoPlayer::MvloLoadingStarted() +{ + bufferingStarted(); +} + +void MMF::VideoPlayer::MvloLoadingComplete() +{ + bufferingComplete(); +} + + +//----------------------------------------------------------------------------- // Video window updates //----------------------------------------------------------------------------- diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.h b/src/3rdparty/phonon/mmf/mmf_videoplayer.h index 7c42991..3ece19c 100644 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.h +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.h @@ -39,6 +39,7 @@ namespace MMF */ class VideoPlayer : public AbstractMediaPlayer , public MVideoPlayerUtilityObserver + , public MVideoLoadingObserver { Q_OBJECT @@ -55,6 +56,7 @@ public: virtual int setDeviceVolume(int mmfVolume); virtual int openFile(RFile& file); virtual int openUrl(const QString& url); + virtual int bufferStatus() const; virtual void close(); // MediaObjectInterface @@ -62,12 +64,12 @@ public: virtual qint64 currentTime() const; virtual qint64 totalTime() const; - // 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); + // AbstractPlayer + virtual void videoOutputChanged(); + + // AbstractMediaPlayer + virtual int numberOfMetaDataEntries() const; + virtual QPair metaDataEntry(int index) const; public Q_SLOTS: void videoWindowChanged(); @@ -81,12 +83,8 @@ private: void doPrepareCompleteL(TInt aError); - // AbstractPlayer - virtual void videoOutputChanged(); - void getVideoWindow(); void initVideoOutput(); - void updateVideoRect(); void applyPendingChanges(); @@ -95,9 +93,17 @@ private: void startDirectScreenAccess(); bool stopDirectScreenAccess(); - // AbstractMediaPlayer - virtual int numberOfMetaDataEntries() const; - virtual QPair metaDataEntry(int index) const; +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 m_player; -- cgit v0.12 From 66b765734585971dd9d248059701fdecebbccd78 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 1 Dec 2009 18:51:45 +0000 Subject: Changed call sequence of seeking in Phonon MMF backend, for streaming Modified the sequence of calls made to the MMF APIs when seeking during ongoing playback. This fixes a bug found during early testing of streaming playback, whereby playback would not resume following the seeking operation. This was due to an interaction between the pause / seek / play operations, and the buffering callbacks received from the MMF, which caused the backend to enter an incorrect state. Task-number: QTBUG-4660 Reviewed-by: Frans Englich --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 14 ++++++++++---- src/3rdparty/phonon/mmf/mmf_videoplayer.cpp | 16 +--------------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index 6e7f458..83c534a 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -179,13 +179,20 @@ void MMF::AbstractMediaPlayer::seek(qint64 ms) case PlayingState: case LoadingState: { - const bool positionTimerWasRunning = m_positionTimer->isActive(); - stopPositionTimer(); + bool wasPlaying = false; + if (state() == PlayingState) { + stopPositionTimer(); + doPause(); + wasPlaying = true; + } doSeek(ms); - if (positionTimerWasRunning) + if(wasPlaying && state() != ErrorState) { + doPlay(); startPositionTimer(); + } + break; } case BufferingState: @@ -370,7 +377,6 @@ void MMF::AbstractMediaPlayer::doVolumeChanged() } } - //----------------------------------------------------------------------------- // Protected functions //----------------------------------------------------------------------------- diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp index 4a70d58..dab7505 100644 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp @@ -142,24 +142,10 @@ void MMF::VideoPlayer::doSeek(qint64 ms) { TRACE_CONTEXT(VideoPlayer::doSeek, EVideoApi); - bool wasPlaying = false; - if (state() == PlayingState) { - // The call to SetPositionL does not have any effect if playback is - // ongoing, so we pause before seeking. - doPause(); - wasPlaying = true; - } - TRAPD(err, m_player->SetPositionL(TTimeIntervalMicroSeconds(ms * 1000))); - if (KErrNone == err) { - if (wasPlaying) - doPlay(); - } - else { - TRACE("SetPositionL error %d", err); + if(KErrNone != err) setError(tr("Seek failed"), err); - } } int MMF::VideoPlayer::setDeviceVolume(int mmfVolume) -- cgit v0.12 From 946dede337f0a43ccb394c10aa2045bc9ef59301 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 2 Dec 2009 16:11:29 +0000 Subject: Mediaplayer: enqueue all entries from .ram file before starting playback This ensures that Phonon::MediaObject::setNextSource is called before the first clip finishes playback, and therefore that the next clip is played once the first finishes. Reviewed-by: Frans Englich --- demos/qmediaplayer/mediaplayer.cpp | 16 +++++++++++----- demos/qmediaplayer/mediaplayer.h | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/demos/qmediaplayer/mediaplayer.cpp b/demos/qmediaplayer/mediaplayer.cpp index 8f6848f..8471ebd 100644 --- a/demos/qmediaplayer/mediaplayer.cpp +++ b/demos/qmediaplayer/mediaplayer.cpp @@ -673,6 +673,13 @@ void MediaPlayer::setFile(const QString &fileName) m_MediaObject.play(); } +void MediaPlayer::setLocation(const QString& location) +{ + setWindowTitle(location.right(location.length() - location.lastIndexOf('/') - 1)); + m_MediaObject.setCurrentSource(Phonon::MediaSource(QUrl::fromEncoded(location.toUtf8()))); + m_MediaObject.play(); +} + bool MediaPlayer::playPauseForDialog() { // If we're running on a small screen, we want to pause the video when @@ -850,9 +857,7 @@ void MediaPlayer::openUrl() bool ok = false; sourceURL = QInputDialog::getText(this, tr("Open Location"), tr("Please enter a valid address here:"), QLineEdit::Normal, sourceURL, &ok); if (ok && !sourceURL.isEmpty()) { - setWindowTitle(sourceURL.right(sourceURL.length() - sourceURL.lastIndexOf('/') - 1)); - m_MediaObject.setCurrentSource(Phonon::MediaSource(QUrl::fromEncoded(sourceURL.toUtf8()))); - m_MediaObject.play(); + setLocation(sourceURL); settings.setValue("location", sourceURL); } } @@ -892,10 +897,11 @@ void MediaPlayer::openRamFile() } if (!list.isEmpty()) { - m_MediaObject.setCurrentSource(Phonon::MediaSource(list[0])); - m_MediaObject.play(); + m_MediaObject.clearQueue(); + setLocation(list[0].toString()); for (int i = 1; i < list.count(); i++) m_MediaObject.enqueue(Phonon::MediaSource(list[i])); + m_MediaObject.play(); } forwardButton->setEnabled(!m_MediaObject.queue().isEmpty()); diff --git a/demos/qmediaplayer/mediaplayer.h b/demos/qmediaplayer/mediaplayer.h index 14ed4ac..fc1bd90 100644 --- a/demos/qmediaplayer/mediaplayer.h +++ b/demos/qmediaplayer/mediaplayer.h @@ -112,6 +112,7 @@ public: void dropEvent(QDropEvent *e); void handleDrop(QDropEvent *e); void setFile(const QString &text); + void setLocation(const QString &location); void initVideoWindow(); void initSettingsDialog(); -- cgit v0.12 From 89e1e7fcbcbe93d8096afe0f7c240fe706cc9069 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 2 Dec 2009 16:20:00 +0000 Subject: Implemented support for playlist handling in Phonon MMF backend The main changes are: 1. MediaObject emits prefinishMark at the appropriate instant 2. MediaObject emits aboutToFinish at the appropriate instant 3. MediaObject switches to next source when playback completes Task-number: QTBUG-6214 Reviewed-by: Frans Englich --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 84 ++++++++++++++----------- src/3rdparty/phonon/mmf/abstractmediaplayer.h | 17 ++--- src/3rdparty/phonon/mmf/abstractplayer.cpp | 22 +++---- src/3rdparty/phonon/mmf/abstractplayer.h | 13 ++-- src/3rdparty/phonon/mmf/audioplayer.cpp | 41 +++--------- src/3rdparty/phonon/mmf/audioplayer.h | 5 +- src/3rdparty/phonon/mmf/dummyplayer.cpp | 19 +----- src/3rdparty/phonon/mmf/dummyplayer.h | 8 +-- src/3rdparty/phonon/mmf/mediaobject.cpp | 54 +++++++++------- src/3rdparty/phonon/mmf/mediaobject.h | 11 +++- src/3rdparty/phonon/mmf/mmf_videoplayer.cpp | 22 ++----- src/3rdparty/phonon/mmf/mmf_videoplayer.h | 3 +- 12 files changed, 129 insertions(+), 170 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index 83c534a..18f96cc 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -20,6 +20,7 @@ along with this library. If not, see . #include "abstractmediaplayer.h" #include "defs.h" +#include "mediaobject.h" #include "utils.h" QT_BEGIN_NAMESPACE @@ -43,22 +44,16 @@ const int BufferStatusTimerInterval = 100; // ms // Constructor / destructor //----------------------------------------------------------------------------- -MMF::AbstractMediaPlayer::AbstractMediaPlayer() : - m_playPending(false) - , m_positionTimer(new QTimer(this)) - , m_bufferStatusTimer(new QTimer(this)) - , m_mmfMaxVolume(NullMaxVolume) -{ - connect(m_positionTimer.data(), SIGNAL(timeout()), this, SLOT(positionTick())); - connect(m_bufferStatusTimer.data(), SIGNAL(timeout()), this, SLOT(bufferStatusTick())); -} - -MMF::AbstractMediaPlayer::AbstractMediaPlayer(const AbstractPlayer& player) : - AbstractPlayer(player) +MMF::AbstractMediaPlayer::AbstractMediaPlayer + (MediaObject *parent, const AbstractPlayer *player) + : AbstractPlayer(player) + , m_parent(parent) , m_playPending(false) , m_positionTimer(new QTimer(this)) , m_bufferStatusTimer(new QTimer(this)) , m_mmfMaxVolume(NullMaxVolume) + , m_prefinishMarkSent(false) + , m_aboutToFinishSent(false) { connect(m_positionTimer.data(), SIGNAL(timeout()), this, SLOT(positionTick())); connect(m_bufferStatusTimer.data(), SIGNAL(timeout()), this, SLOT(bufferStatusTick())); @@ -220,12 +215,7 @@ void MMF::AbstractMediaPlayer::doSetTickInterval(qint32 interval) TRACE_EXIT_0(); } -MediaSource MMF::AbstractMediaPlayer::source() const -{ - return m_source; -} - -void MMF::AbstractMediaPlayer::setFileSource(const MediaSource &source, RFile& file) +void MMF::AbstractMediaPlayer::open(const MediaSource &source, RFile& file) { TRACE_CONTEXT(AbstractMediaPlayer::setFileSource, EAudioApi); TRACE_ENTRY("state %d source.type %d", privateState(), source.type()); @@ -233,14 +223,10 @@ void MMF::AbstractMediaPlayer::setFileSource(const MediaSource &source, RFile& f close(); changeState(GroundState); - // TODO: is it correct to assign even if the media type is not supported in - // the switch statement below? - m_source = source; - TInt symbianErr = KErrNone; QString errorMessage; - switch (m_source.type()) { + switch (source.type()) { case MediaSource::LocalFile: { symbianErr = openFile(file); if (KErrNone != symbianErr) @@ -293,20 +279,6 @@ void MMF::AbstractMediaPlayer::setFileSource(const MediaSource &source, RFile& f TRACE_EXIT_0(); } -void MMF::AbstractMediaPlayer::setNextSource(const MediaSource &source) -{ - TRACE_CONTEXT(AbstractMediaPlayer::setNextSource, EAudioApi); - TRACE_ENTRY("state %d", privateState()); - - // TODO: handle 'next source' - - m_nextSource = source; - Q_UNUSED(source); - - TRACE_EXIT_0(); -} - - void MMF::AbstractMediaPlayer::volumeChanged(qreal volume) { TRACE_CONTEXT(AbstractMediaPlayer::volumeChanged, EAudioInternal); @@ -402,6 +374,23 @@ void MMF::AbstractMediaPlayer::maxVolumeChanged(int mmfMaxVolume) doVolumeChanged(); } +void MMF::AbstractMediaPlayer::playbackComplete(int error) +{ + stopTimers(); + + if (KErrNone == error) { + changeState(StoppedState); + + // MediaObject::switchToNextSource deletes the current player, so we + // call it via delayed slot invokation to ensure that this object does + // not get deleted during execution of a member function. + QMetaObject::invokeMethod(m_parent, "switchToNextSource", Qt::QueuedConnection); + } + else { + setError(tr("Playback complete"), error); + } +} + qint64 MMF::AbstractMediaPlayer::toMilliSeconds(const TTimeIntervalMicroSeconds &in) { return in.Int64() / 1000; @@ -413,7 +402,26 @@ qint64 MMF::AbstractMediaPlayer::toMilliSeconds(const TTimeIntervalMicroSeconds void MMF::AbstractMediaPlayer::positionTick() { - emit MMF::AbstractPlayer::tick(currentTime()); + const qint64 current = currentTime(); + const qint64 total = totalTime(); + const qint64 remaining = total - current; + + if (prefinishMark() && !m_prefinishMarkSent) { + if (remaining < (prefinishMark() + tickInterval()/2)) { + m_prefinishMarkSent = true; + emit prefinishMarkReached(remaining); + } + } + + if (!m_aboutToFinishSent) { + if (remaining < tickInterval()) { + m_aboutToFinishSent = true; + emit aboutToFinish(); + } + } + + // For the MWC compiler, we need to qualify the base class. + emit MMF::AbstractPlayer::tick(current); } void MMF::AbstractMediaPlayer::bufferStatusTick() diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h index 7c11ec7..24fa228 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h @@ -33,6 +33,7 @@ namespace Phonon namespace MMF { class AudioOutput; +class MediaObject; /** * Interface via which MMF client APIs for both audio and video can be @@ -43,19 +44,17 @@ class AbstractMediaPlayer : public AbstractPlayer Q_OBJECT protected: - AbstractMediaPlayer(); - explicit AbstractMediaPlayer(const AbstractPlayer& player); + AbstractMediaPlayer(MediaObject *parent, const AbstractPlayer *player); public: + virtual void open(const Phonon::MediaSource&, RFile&); + // MediaObjectInterface virtual void play(); virtual void pause(); virtual void stop(); virtual void seek(qint64 milliseconds); virtual bool isSeekable() const; - virtual MediaSource source() const; - virtual void setFileSource(const Phonon::MediaSource&, RFile&); - virtual void setNextSource(const MediaSource &source); virtual void volumeChanged(qreal volume); protected: @@ -81,6 +80,8 @@ protected: void bufferingStarted(); void bufferingComplete(); void maxVolumeChanged(int maxVolume); + void playbackComplete(int error); + static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); private: @@ -96,6 +97,8 @@ private Q_SLOTS: void bufferStatusTick(); private: + MediaObject *const m_parent; + /** * This flag is set to true if play is called when the object is * in a Loading state. Once loading is complete, playback will @@ -110,8 +113,8 @@ private: int m_mmfMaxVolume; - MediaSource m_source; - MediaSource m_nextSource; + bool m_prefinishMarkSent; + bool m_aboutToFinishSent; QMultiMap m_metaData; diff --git a/src/3rdparty/phonon/mmf/abstractplayer.cpp b/src/3rdparty/phonon/mmf/abstractplayer.cpp index 13ff5fb..53973eb 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractplayer.cpp @@ -33,7 +33,7 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::AbstractPlayer::AbstractPlayer() +MMF::AbstractPlayer::AbstractPlayer(const AbstractPlayer *player) : m_videoOutput(0) , m_volume(InitialVolume) , m_state(GroundState) @@ -42,19 +42,13 @@ MMF::AbstractPlayer::AbstractPlayer() , m_transitionTime(0) , m_prefinishMark(0) { - -} - -MMF::AbstractPlayer::AbstractPlayer(const AbstractPlayer& player) - : m_videoOutput(player.m_videoOutput) - , m_volume(player.m_volume) - , m_state(GroundState) - , m_error(NoError) - , m_tickInterval(player.tickInterval()) - , m_transitionTime(player.transitionTime()) - , m_prefinishMark(player.prefinishMark()) -{ - + if(player) { + m_videoOutput = player->m_videoOutput; + m_volume = player->m_volume; + m_tickInterval = player->m_tickInterval; + m_transitionTime = player->m_transitionTime; + m_prefinishMark = player->m_prefinishMark; + } } //----------------------------------------------------------------------------- diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index 5aaae3c..40ad7f8 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -53,8 +53,9 @@ class AbstractPlayer : public QObject Q_OBJECT public: - AbstractPlayer(); - explicit AbstractPlayer(const AbstractPlayer& player); + AbstractPlayer(const AbstractPlayer *player); + + virtual void open(const Phonon::MediaSource&, RFile&) = 0; // MediaObjectInterface (implemented) qint32 tickInterval() const; @@ -75,12 +76,6 @@ public: virtual Phonon::ErrorType errorType() const; virtual QString errorString() const; virtual qint64 totalTime() const = 0; - virtual Phonon::MediaSource source() const = 0; - // This is a temporary hack to work around KErrInUse from MMF - // client utility OpenFileL calls - //virtual void setSource(const Phonon::MediaSource &) = 0; - virtual void setFileSource(const Phonon::MediaSource&, RFile&) = 0; - virtual void setNextSource(const Phonon::MediaSource &) = 0; virtual void volumeChanged(qreal volume); @@ -114,6 +109,8 @@ Q_SIGNALS: void stateChanged(Phonon::State oldState, Phonon::State newState); void metaDataChanged(const QMultiMap& metaData); + void aboutToFinish(); + void prefinishMarkReached(qint32 remaining); protected: /** diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index 0967a27..77488f4 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -34,13 +34,9 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::AudioPlayer::AudioPlayer() -{ - construct(); -} - -MMF::AudioPlayer::AudioPlayer(const AbstractPlayer& player) - : AbstractMediaPlayer(player) +MMF::AudioPlayer::AudioPlayer(MediaObject *parent, const AbstractPlayer *player) + : AbstractMediaPlayer(parent, player) + , m_totalTime(0) { construct(); } @@ -177,7 +173,7 @@ qint64 MMF::AudioPlayer::currentTime() const qint64 MMF::AudioPlayer::totalTime() const { - return toMilliSeconds(m_player->Duration()); + return m_totalTime; } @@ -200,7 +196,8 @@ void MMF::AudioPlayer::MapcInitComplete(TInt aError, if (KErrNone == aError) { maxVolumeChanged(m_player->MaxVolume()); - emit totalTimeChanged(totalTime()); + m_totalTime = toMilliSeconds(m_player->Duration()); + emit totalTimeChanged(m_totalTime); updateMetaData(); changeState(StoppedState); } else { @@ -219,29 +216,9 @@ void MMF::AudioPlayer::MapcPlayComplete(TInt aError) TRACE_CONTEXT(AudioPlayer::MapcPlayComplete, EAudioInternal); TRACE_ENTRY("state %d error %d", state(), aError); - if (KErrNone == aError) { - changeState(StoppedState); - // TODO: move on to m_nextSource - } else { - setError(tr("Playback complete"), aError); - } - - /* - if (aError == KErrNone) { - if (m_nextSource.type() == MediaSource::Empty) { - emit finished(); - } else { - setSource(m_nextSource); - m_nextSource = MediaSource(); - } - - changeState(StoppedState); - } - else { - m_error = NormalError; - changeState(ErrorState); - } - */ + // Call base class function which handles end of playback for both + // audio and video clips. + playbackComplete(aError); TRACE_EXIT_0(); } diff --git a/src/3rdparty/phonon/mmf/audioplayer.h b/src/3rdparty/phonon/mmf/audioplayer.h index 5c7cfc1..4c4bcd0 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.h +++ b/src/3rdparty/phonon/mmf/audioplayer.h @@ -50,8 +50,7 @@ class AudioPlayer : public AbstractMediaPlayer Q_OBJECT public: - AudioPlayer(); - explicit AudioPlayer(const AbstractPlayer& player); + AudioPlayer(MediaObject *parent = 0, const AbstractPlayer *player = 0); virtual ~AudioPlayer(); // AbstractMediaPlayer @@ -105,6 +104,8 @@ private: * CMdaAudioPlayerUtility and CDrmPlayerUtility */ QScopedPointer m_player; + + qint64 m_totalTime; }; } } diff --git a/src/3rdparty/phonon/mmf/dummyplayer.cpp b/src/3rdparty/phonon/mmf/dummyplayer.cpp index e6f3855..6970088 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.cpp +++ b/src/3rdparty/phonon/mmf/dummyplayer.cpp @@ -31,12 +31,7 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::DummyPlayer::DummyPlayer() -{ - -} - -MMF::DummyPlayer::DummyPlayer(const AbstractPlayer& player) +MMF::DummyPlayer::DummyPlayer(const AbstractPlayer *player) : AbstractPlayer(player) { @@ -97,17 +92,7 @@ qint64 MMF::DummyPlayer::totalTime() const return 0; } -MediaSource MMF::DummyPlayer::source() const -{ - return MediaSource(); -} - -void MMF::DummyPlayer::setFileSource(const Phonon::MediaSource &, RFile &) -{ - -} - -void MMF::DummyPlayer::setNextSource(const MediaSource &) +void MMF::DummyPlayer::open(const Phonon::MediaSource &, RFile &) { } diff --git a/src/3rdparty/phonon/mmf/dummyplayer.h b/src/3rdparty/phonon/mmf/dummyplayer.h index c6270c9..6841b5d 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.h +++ b/src/3rdparty/phonon/mmf/dummyplayer.h @@ -42,8 +42,7 @@ class AudioOutput; class DummyPlayer : public AbstractPlayer { public: - DummyPlayer(); - DummyPlayer(const AbstractPlayer& player); + DummyPlayer(const AbstractPlayer *player = 0); // MediaObjectInterface virtual void play(); @@ -56,12 +55,9 @@ public: virtual Phonon::State state() const; virtual Phonon::ErrorType errorType() const; virtual qint64 totalTime() const; - virtual MediaSource source() const; - // virtual void setSource(const MediaSource &); - virtual void setFileSource(const Phonon::MediaSource&, RFile&); - virtual void setNextSource(const MediaSource &source); // AbstractPlayer + virtual void open(const Phonon::MediaSource&, RFile&); virtual void doSetTickInterval(qint32 interval); }; } diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index bf1f268..a9a012f 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -45,6 +45,7 @@ using namespace Phonon::MMF; MMF::MediaObject::MediaObject(QObject *parent) : MMF::MediaNode::MediaNode(parent) , m_recognizerOpened(false) + , m_nextSourceSet(false) { m_player.reset(new DummyPlayer()); @@ -211,18 +212,20 @@ qint64 MMF::MediaObject::totalTime() const MediaSource MMF::MediaObject::source() const { - return m_player->source(); + return m_source; } void MMF::MediaObject::setSource(const MediaSource &source) { - createPlayer(source); - - // This is a hack to work around KErrInUse from MMF client utility - // OpenFileL calls - m_player->setFileSource(source, m_file); + switchToSource(source); +} - emit currentSourceChanged(source); +void MMF::MediaObject::switchToSource(const MediaSource &source) +{ + createPlayer(source); + m_source = source; + m_player->open(m_source, m_file); + emit currentSourceChanged(m_source); } void MMF::MediaObject::createPlayer(const MediaSource &source) @@ -281,29 +284,16 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) switch (mediaType) { case MediaTypeUnknown: TRACE_0("Media type could not be determined"); - if (oldPlayer) { - newPlayer = new DummyPlayer(*oldPlayer); - } else { - newPlayer = new DummyPlayer(); - } - + newPlayer = new DummyPlayer(oldPlayer); errorMessage = tr("Error opening source: media type could not be determined"); break; case MediaTypeAudio: - if (oldPlayer) { - newPlayer = new AudioPlayer(*oldPlayer); - } else { - newPlayer = new AudioPlayer(); - } + newPlayer = new AudioPlayer(this, oldPlayer); break; case MediaTypeVideo: - if (oldPlayer) { - newPlayer = new VideoPlayer(*oldPlayer); - } else { - newPlayer = new VideoPlayer(); - } + newPlayer = new VideoPlayer(this, oldPlayer); break; } @@ -323,6 +313,8 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) connect(m_player.data(), SIGNAL(tick(qint64)), SIGNAL(tick(qint64))); connect(m_player.data(), SIGNAL(bufferStatus(int)), SIGNAL(bufferStatus(int))); connect(m_player.data(), SIGNAL(metaDataChanged(QMultiMap)), SIGNAL(metaDataChanged(QMultiMap))); + connect(m_player.data(), SIGNAL(aboutToFinish()), SIGNAL(aboutToFinish())); + connect(m_player.data(), SIGNAL(prefinishMarkReached(qint32)), SIGNAL(tick(qint32))); // We need to call setError() after doing the connects, otherwise the // error won't be received. @@ -336,7 +328,8 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) void MMF::MediaObject::setNextSource(const MediaSource &source) { - m_player->setNextSource(source); + m_nextSource = source; + m_nextSourceSet = true; } qint32 MMF::MediaObject::prefinishMark() const @@ -385,5 +378,18 @@ bool MMF::MediaObject::activateOnMediaObject(MediaObject *) return true; } +//----------------------------------------------------------------------------- +// Playlist support +//----------------------------------------------------------------------------- + +void MMF::MediaObject::switchToNextSource() +{ + if (m_nextSourceSet) { + m_nextSourceSet = false; + switchToSource(m_nextSource); + play(); + } +} + QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index 07baad0..7c39598 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -87,16 +87,16 @@ public: public Q_SLOTS: void volumeChanged(qreal volume); + void switchToNextSource(); Q_SIGNALS: void totalTimeChanged(qint64 length); void hasVideoChanged(bool hasVideo); void seekableChanged(bool seekable); void bufferStatus(int); - // TODO: emit aboutToFinish from MediaObject void aboutToFinish(); - // TODO: emit prefinishMarkReached from MediaObject - void prefinishMarkReached(qint32); + void prefinishMarkReached(qint32 remaining); + // TODO: emit metaDataChanged from MediaObject void metaDataChanged(const QMultiMap& metaData); void currentSourceChanged(const MediaSource& source); void stateChanged(Phonon::State oldState, @@ -105,6 +105,7 @@ Q_SIGNALS: void tick(qint64 time); private: + void switchToSource(const MediaSource &source); void createPlayer(const MediaSource &source); bool openRecognizer(); @@ -121,6 +122,10 @@ private: RApaLsSession m_recognizer; RFs m_fileServer; + MediaSource m_source; + MediaSource m_nextSource; + bool m_nextSourceSet; + // Storing the file handle here to work around KErrInUse error // from MMF player utility OpenFileL functions RFile m_file; diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp index dab7505..877dfb3 100644 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp @@ -44,20 +44,8 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::VideoPlayer::VideoPlayer() - : m_wsSession(CCoeEnv::Static()->WsSession()) - , m_screenDevice(*CCoeEnv::Static()->ScreenDevice()) - , m_window(0) - , m_totalTime(0) - , m_pendingChanges(false) - , m_dsaActive(false) - , m_dsaWasActive(false) -{ - construct(); -} - -MMF::VideoPlayer::VideoPlayer(const AbstractPlayer& player) - : AbstractMediaPlayer(player) +MMF::VideoPlayer::VideoPlayer(MediaObject *parent, const AbstractPlayer *player) + : AbstractMediaPlayer(parent, player) , m_wsSession(CCoeEnv::Static()->WsSession()) , m_screenDevice(*CCoeEnv::Static()->ScreenDevice()) , m_window(0) @@ -287,9 +275,9 @@ void MMF::VideoPlayer::MvpuoPlayComplete(TInt aError) TRACE_CONTEXT(VideoPlayer::MvpuoPlayComplete, EVideoApi) TRACE_ENTRY("state %d error %d", state(), aError); - // TODO: handle aError - Q_UNUSED(aError); - changeState(StoppedState); + // Call base class function which handles end of playback for both + // audio and video clips. + playbackComplete(aError); TRACE_EXIT_0(); } diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.h b/src/3rdparty/phonon/mmf/mmf_videoplayer.h index 3ece19c..6200e39 100644 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.h +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.h @@ -44,8 +44,7 @@ class VideoPlayer : public AbstractMediaPlayer Q_OBJECT public: - VideoPlayer(); - explicit VideoPlayer(const AbstractPlayer& player); + VideoPlayer(MediaObject *parent = 0, const AbstractPlayer *player = 0); virtual ~VideoPlayer(); // AbstractPlayer -- cgit v0.12 From fe5b275bfab1605da3ee95b6eb1d976aecb0a8a8 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 8 Dec 2009 10:31:26 +0000 Subject: Re-emit prefinishMarkReached and aboutToFinish if rewound back past mark. Task-number: QTBUG-6214 Reviewed-by: Frans Englich --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 25 +++++++++++++++++++++++-- src/3rdparty/phonon/mmf/abstractmediaplayer.h | 2 ++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index 18f96cc..344413d 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -182,6 +182,7 @@ void MMF::AbstractMediaPlayer::seek(qint64 ms) } doSeek(ms); + resetMarksIfRewound(); if(wasPlaying && state() != ErrorState) { doPlay(); @@ -402,6 +403,14 @@ qint64 MMF::AbstractMediaPlayer::toMilliSeconds(const TTimeIntervalMicroSeconds void MMF::AbstractMediaPlayer::positionTick() { + emitMarksIfReached(); + + const qint64 current = currentTime(); + emit MMF::AbstractPlayer::tick(current); +} + +void MMF::AbstractMediaPlayer::emitMarksIfReached() +{ const qint64 current = currentTime(); const qint64 total = totalTime(); const qint64 remaining = total - current; @@ -419,9 +428,21 @@ void MMF::AbstractMediaPlayer::positionTick() emit aboutToFinish(); } } +} - // For the MWC compiler, we need to qualify the base class. - emit MMF::AbstractPlayer::tick(current); +void MMF::AbstractMediaPlayer::resetMarksIfRewound() +{ + const qint64 current = currentTime(); + const qint64 total = totalTime(); + const qint64 remaining = total - current; + + if (prefinishMark() && m_prefinishMarkSent) + if (remaining >= (prefinishMark() + tickInterval()/2)) + m_prefinishMarkSent = false; + + if (m_aboutToFinishSent) + if (remaining >= tickInterval()) + m_aboutToFinishSent = false; } void MMF::AbstractMediaPlayer::bufferStatusTick() diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h index 24fa228..abd6bff 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h @@ -91,6 +91,8 @@ private: void stopBufferStatusTimer(); void stopTimers(); void doVolumeChanged(); + void emitMarksIfReached(); + void resetMarksIfRewound(); private Q_SLOTS: void positionTick(); -- cgit v0.12 From 8e21fc62fe40c8e393007516958c216ad8dbd629 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 2 Dec 2009 17:03:48 +0000 Subject: Removed dead code from Phonon MMF backend The following source types are handled in MediaObject::createPlayer Invalid, Disc, Stream, Empty The code removed in this patch is therefore never executed. Reviewed-by: Frans Englich --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index 344413d..544762a 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -251,19 +251,9 @@ void MMF::AbstractMediaPlayer::open(const MediaSource &source, RFile& file) break; } - case MediaSource::Invalid: - case MediaSource::Disc: - case MediaSource::Stream: - TRACE_0("Error opening source: type not supported"); - errorMessage = tr("Error opening source: type not supported"); - break; - - case MediaSource::Empty: - TRACE_0("Empty source - doing nothing"); - TRACE_EXIT_0(); - return; + // Other source types are handled in MediaObject::createPlayer - // Protection against adding new media types and forgetting to update this switch + // Protection against adding new media types and forgetting to update this switch default: TRACE_PANIC(InvalidMediaTypePanic); } -- cgit v0.12 From 3f648dc075689e2ffedda2769cc76b4a56fb1073 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Fri, 4 Dec 2009 11:49:12 +0000 Subject: Implemented node disconnection in Phonon MMF backend Task-number: QTBUG-4663 Reviewed-by: Frans Englich --- src/3rdparty/phonon/mmf/abstractaudioeffect.cpp | 58 ++++++--- src/3rdparty/phonon/mmf/abstractaudioeffect.h | 27 +++-- src/3rdparty/phonon/mmf/audioequalizer.cpp | 38 +++++- src/3rdparty/phonon/mmf/audioequalizer.h | 13 +- src/3rdparty/phonon/mmf/audiooutput.cpp | 13 +- src/3rdparty/phonon/mmf/audiooutput.h | 4 +- src/3rdparty/phonon/mmf/audioplayer.cpp | 15 ++- src/3rdparty/phonon/mmf/audioplayer.h | 21 ++-- src/3rdparty/phonon/mmf/backend.cpp | 29 +++-- src/3rdparty/phonon/mmf/bassboost.cpp | 22 +++- src/3rdparty/phonon/mmf/bassboost.h | 12 +- src/3rdparty/phonon/mmf/effectfactory.cpp | 2 +- src/3rdparty/phonon/mmf/mediaobject.cpp | 25 +++- src/3rdparty/phonon/mmf/mediaobject.h | 6 +- src/3rdparty/phonon/mmf/mmf_medianode.cpp | 153 ++++++++++++++---------- src/3rdparty/phonon/mmf/mmf_medianode.h | 76 ++++++------ src/3rdparty/phonon/mmf/mmf_videoplayer.cpp | 5 + src/3rdparty/phonon/mmf/mmf_videoplayer.h | 5 +- src/3rdparty/phonon/mmf/videowidget.cpp | 14 ++- src/3rdparty/phonon/mmf/videowidget.h | 4 +- 20 files changed, 348 insertions(+), 194 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp index a559249..8c73027 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp @@ -19,6 +19,8 @@ along with this library. If not, see . #include "mediaobject.h" #include "abstractaudioeffect.h" +#include "audioplayer.h" +#include "mmf_videoplayer.h" QT_BEGIN_NAMESPACE @@ -34,18 +36,13 @@ using namespace Phonon::MMF; */ AbstractAudioEffect::AbstractAudioEffect(QObject *parent, - const QList ¶ms) : MediaNode::MediaNode(parent) - , m_params(params) + const QList ¶ms) + : MediaNode::MediaNode(parent) + , m_player(0) + , m_params(params) { } -bool AbstractAudioEffect::disconnectMediaNode(MediaNode *target) -{ - MediaNode::disconnectMediaNode(target); - m_effect.reset(); - return true; -} - QList AbstractAudioEffect::parameters() const { return m_params; @@ -61,21 +58,44 @@ QVariant AbstractAudioEffect::parameterValue(const EffectParameter &queriedParam return val; } -bool AbstractAudioEffect::activateOnMediaObject(MediaObject *mo) -{ - AudioPlayer *const ap = qobject_cast(mo->abstractPlayer()); - - if (ap) - return activateOn(ap->player()); - else - return true; -} - void AbstractAudioEffect::setParameterValue(const EffectParameter ¶m, const QVariant &newValue) { m_values.insert(param.id(), newValue); parameterChanged(param.id(), newValue); + // TODO: handle audio effect errors + TRAP_IGNORE(m_effect->ApplyL()); +} + +void AbstractAudioEffect::connectMediaObject(MediaObject *mediaObject) +{ + Q_ASSERT_X(!m_player, Q_FUNC_INFO, "Player already connected"); + Q_ASSERT_X(!m_effect.data(), Q_FUNC_INFO, "Effect already created"); + + AbstractMediaPlayer *const player = + qobject_cast(mediaObject->abstractPlayer()); + + if (player) { + m_player = player; + + if (AudioPlayer *audioPlayer = qobject_cast(player)) { + connectAudioPlayer(audioPlayer->nativePlayer()); + } else { + VideoPlayer *videoPlayer = qobject_cast(player); + Q_ASSERT_X(videoPlayer, Q_FUNC_INFO, "Player type not recognised"); + connectVideoPlayer(videoPlayer->nativePlayer()); + } + + applyParameters(); + // TODO: handle audio effect errors + TRAP_IGNORE(m_effect->EnableL()); + } +} + +void AbstractAudioEffect::disconnectMediaObject(MediaObject * /*mediaObject*/) +{ + m_player = 0; + m_effect.reset(); } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.h b/src/3rdparty/phonon/mmf/abstractaudioeffect.h index 01542c9..10578af 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.h +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.h @@ -19,15 +19,16 @@ along with this library. If not, see . #ifndef PHONON_MMF_ABSTRACTEFFECT_H #define PHONON_MMF_ABSTRACTEFFECT_H -#include "mmf_medianode.h" - #include #include #include #include + #include "audioplayer.h" +#include "mmf_medianode.h" +#include "mmf_videoplayer.h" QT_BEGIN_NAMESPACE @@ -35,6 +36,7 @@ namespace Phonon { namespace MMF { +class AbstractMediaPlayer; /** * @short Base class for all effects for MMF. @@ -66,8 +68,6 @@ public: virtual void setParameterValue(const EffectParameter &, const QVariant &newValue); - virtual bool disconnectMediaNode(MediaNode *target); - enum Type { EffectAudioEqualizer = 1, @@ -81,21 +81,26 @@ public: }; protected: - virtual bool activateOn(CPlayerType *player) = 0; + // MediaNode + void connectMediaObject(MediaObject *mediaObject); + void disconnectMediaObject(MediaObject *mediaObject); + + virtual void connectAudioPlayer(AudioPlayer::NativePlayer *player) = 0; + virtual void connectVideoPlayer(VideoPlayer::NativePlayer *player) = 0; + virtual void applyParameters() = 0; + virtual void parameterChanged(const int id, const QVariant &value) = 0; - /** - * Part of the implementation of AbstractAudioEffect. Forwards the call to - * activateOn(), essentially. - */ - virtual bool activateOnMediaObject(MediaObject *mo); - +protected: QScopedPointer m_effect; + private: + AbstractMediaPlayer * m_player; const QList m_params; QHash m_values; }; + } } diff --git a/src/3rdparty/phonon/mmf/audioequalizer.cpp b/src/3rdparty/phonon/mmf/audioequalizer.cpp index 7cc9bc7..51f1c32 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.cpp +++ b/src/3rdparty/phonon/mmf/audioequalizer.cpp @@ -16,6 +16,7 @@ along with this library. If not, see . */ +#include #include "audioequalizer.h" QT_BEGIN_NAMESPACE @@ -34,18 +35,43 @@ AudioEqualizer::AudioEqualizer(QObject *parent) : AbstractAudioEffect::AbstractA void AudioEqualizer::parameterChanged(const int pid, const QVariant &value) { - // There is no way to return an error from this function, so we just - // have to trap and ignore exceptions. - TRAP_IGNORE(static_cast(m_effect.data())->SetBandLevelL(pid, value.toInt())); + if (m_effect.data()) { + const int band = pid; + const int level = value.toInt(); + setBandLevel(band, level); + } } -bool AudioEqualizer::activateOn(CPlayerType *player) +void AudioEqualizer::connectAudioPlayer(AudioPlayer::NativePlayer *player) { CAudioEqualizer *ptr = 0; QT_TRAP_THROWING(ptr = CAudioEqualizer::NewL(*player)); m_effect.reset(ptr); +} - return true; +void AudioEqualizer::connectVideoPlayer(VideoPlayer::NativePlayer *player) +{ + CAudioEqualizer *ptr = 0; + QT_TRAP_THROWING(ptr = CAudioEqualizer::NewL(*player)); + m_effect.reset(ptr); +} + +void AudioEqualizer::applyParameters() +{ + Q_ASSERT_X(m_effect.data(), Q_FUNC_INFO, "Effect not created"); + EffectParameter param; + foreach (param, parameters()) { + const int band = param.id(); + const int level = parameterValue(param).toInt(); + setBandLevel(band, level); + } +} + +void AudioEqualizer::setBandLevel(int band, int level) +{ + CAudioEqualizer *const effect = static_cast(m_effect.data()); + // TODO: handle audio effect errors + TRAP_IGNORE(effect->SetBandLevelL(band, level)); } QList AudioEqualizer::createParams() @@ -57,7 +83,7 @@ QList AudioEqualizer::createParams() AudioPlayer dummyPlayer; CAudioEqualizer *eqPtr = 0; - QT_TRAP_THROWING(eqPtr = CAudioEqualizer::NewL(*dummyPlayer.player());) + QT_TRAP_THROWING(eqPtr = CAudioEqualizer::NewL(*dummyPlayer.nativePlayer())); QScopedPointer e(eqPtr); TInt32 dbMin; diff --git a/src/3rdparty/phonon/mmf/audioequalizer.h b/src/3rdparty/phonon/mmf/audioequalizer.h index d4c8165..9910ea4 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.h +++ b/src/3rdparty/phonon/mmf/audioequalizer.h @@ -19,7 +19,6 @@ along with this library. If not, see . #ifndef PHONON_MMF_AUDIOEQUALIZER_H #define PHONON_MMF_AUDIOEQUALIZER_H -#include #include "abstractaudioeffect.h" QT_BEGIN_NAMESPACE @@ -43,14 +42,18 @@ public: AudioEqualizer(QObject *parent); protected: - virtual void parameterChanged(const int id, - const QVariant &value); + // AbstractAudioEffect + virtual void connectAudioPlayer(AudioPlayer::NativePlayer *player); + virtual void connectVideoPlayer(VideoPlayer::NativePlayer *player); + virtual void applyParameters(); + virtual void parameterChanged(const int id, const QVariant &value); - virtual bool activateOn(CPlayerType *player); +private: + void setBandLevel(int band, int level); private: static QList createParams(); - QScopedPointer m_bassBoost; + }; } } diff --git a/src/3rdparty/phonon/mmf/audiooutput.cpp b/src/3rdparty/phonon/mmf/audiooutput.cpp index d6e0c13..c6be20b 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.cpp +++ b/src/3rdparty/phonon/mmf/audiooutput.cpp @@ -81,13 +81,18 @@ bool MMF::AudioOutput::setOutputDevice(int index) return true; } -bool MMF::AudioOutput::activateOnMediaObject(MediaObject *mo) +void MMF::AudioOutput::connectMediaObject(MediaObject *mediaObject) { // Ensure that the MediaObject has the correct initial volume - mo->volumeChanged(m_volume); + mediaObject->volumeChanged(m_volume); // Connect MediaObject to receive future volume changes - connect(this, SIGNAL(volumeChanged(qreal)), mo, SLOT(volumeChanged(qreal))); - return true; + connect(this, SIGNAL(volumeChanged(qreal)), mediaObject, SLOT(volumeChanged(qreal))); +} + +void MMF::AudioOutput::disconnectMediaObject(MediaObject *mediaObject) +{ + // Disconnect all signal-slot connections + disconnect(this, 0, mediaObject, 0); } QHash MMF::AudioOutput::audioOutputDescription(int index) diff --git a/src/3rdparty/phonon/mmf/audiooutput.h b/src/3rdparty/phonon/mmf/audiooutput.h index 1e1e134..67aaa38 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.h +++ b/src/3rdparty/phonon/mmf/audiooutput.h @@ -74,7 +74,9 @@ public: }; protected: - virtual bool activateOnMediaObject(MediaObject *mo); + // MediaNode + void connectMediaObject(MediaObject *mediaObject); + void disconnectMediaObject(MediaObject *mediaObject); Q_SIGNALS: void volumeChanged(qreal volume); diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index 77488f4..ee07229 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -46,8 +46,8 @@ void MMF::AudioPlayer::construct() TRACE_CONTEXT(AudioPlayer::AudioPlayer, EAudioApi); TRACE_ENTRY_0(); - CPlayerType *player = 0; - QT_TRAP_THROWING(player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone)); + NativePlayer *player = 0; + QT_TRAP_THROWING(player = NativePlayer::NewL(*this, 0, EMdaPriorityPreferenceNone)); m_player.reset(player); m_player->RegisterForAudioLoadingNotification(*this); @@ -62,6 +62,11 @@ MMF::AudioPlayer::~AudioPlayer() TRACE_EXIT_0(); } +MMF::AudioPlayer::NativePlayer *MMF::AudioPlayer::nativePlayer() const +{ + return m_player.data(); +} + //----------------------------------------------------------------------------- // Public API //----------------------------------------------------------------------------- @@ -223,12 +228,6 @@ void MMF::AudioPlayer::MapcPlayComplete(TInt aError) TRACE_EXIT_0(); } -CPlayerType *MMF::AudioPlayer::player() const -{ - return m_player.data(); -} - - #ifdef QT_PHONON_MMF_AUDIO_DRM void MMF::AudioPlayer::MaloLoadingStarted() { diff --git a/src/3rdparty/phonon/mmf/audioplayer.h b/src/3rdparty/phonon/mmf/audioplayer.h index 4c4bcd0..0eb8bb7 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.h +++ b/src/3rdparty/phonon/mmf/audioplayer.h @@ -26,12 +26,10 @@ class TTimeIntervalMicroSeconds; #ifdef QT_PHONON_MMF_AUDIO_DRM #include -typedef CDrmPlayerUtility CPlayerType; -typedef MDrmAudioPlayerCallback MPlayerObserverType; +typedef MDrmAudioPlayerCallback NativePlayerObserver; #else #include -typedef CMdaAudioPlayerUtility CPlayerType; -typedef MMdaAudioPlayerCallback MPlayerObserverType; +typedef MMdaAudioPlayerCallback NativePlayerObserver; #endif QT_BEGIN_NAMESPACE @@ -44,7 +42,7 @@ namespace MMF * @short Wrapper over MMF audio client utility */ class AudioPlayer : public AbstractMediaPlayer - , public MPlayerObserverType // typedef + , public NativePlayerObserver , public MAudioLoadingObserver { Q_OBJECT @@ -53,6 +51,14 @@ public: AudioPlayer(MediaObject *parent = 0, const AbstractPlayer *player = 0); virtual ~AudioPlayer(); +#ifdef QT_PHONON_MMF_AUDIO_DRM +typedef CDrmPlayerUtility NativePlayer; +#else +typedef CMdaAudioPlayerUtility NativePlayer; +#endif + + NativePlayer *nativePlayer() const; + // AbstractMediaPlayer virtual void doPlay(); virtual void doPause(); @@ -76,7 +82,7 @@ public: /** * This class owns the pointer. */ - CPlayerType *player() const; + NativePlayer *player() const; private: void construct(); @@ -103,9 +109,10 @@ private: * Using CPlayerType typedef in order to be able to easily switch between * CMdaAudioPlayerUtility and CDrmPlayerUtility */ - QScopedPointer m_player; + QScopedPointer m_player; qint64 m_totalTime; + }; } } diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index 7e3a67f..0c07f66 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -139,29 +139,32 @@ bool Backend::startConnectionChange(QSet) return true; } -bool Backend::connectNodes(QObject *source, QObject *target) +bool Backend::connectNodes(QObject *sourceObject, QObject *targetObject) { TRACE_CONTEXT(Backend::connectNodes, EBackend); - TRACE_ENTRY("source 0x%08x target 0x%08x", source, target); - Q_ASSERT(qobject_cast(source)); - Q_ASSERT(qobject_cast(target)); + TRACE_ENTRY("source 0x%08x target 0x%08x", sourceObject, targetObject); - MediaNode *const mediaSource = static_cast(source); - MediaNode *const mediaTarget = static_cast(target); + MediaNode *const source = qobject_cast(sourceObject); + MediaNode *const target = qobject_cast(targetObject); - return mediaSource->connectMediaNode(mediaTarget); + Q_ASSERT_X(source, Q_FUNC_INFO, "source is not a MediaNode"); + Q_ASSERT_X(target, Q_FUNC_INFO, "target is not a MediaNode"); + + return source->connectOutput(target); } -bool Backend::disconnectNodes(QObject *source, QObject *target) +bool Backend::disconnectNodes(QObject *sourceObject, QObject *targetObject) { TRACE_CONTEXT(Backend::disconnectNodes, EBackend); - TRACE_ENTRY("source 0x%08x target 0x%08x", source, target); - Q_ASSERT(qobject_cast(source)); - Q_ASSERT(qobject_cast(target)); + TRACE_ENTRY("source 0x%08x target 0x%08x", sourceObject, targetObject); + + MediaNode *const source = qobject_cast(sourceObject); + MediaNode *const target = qobject_cast(targetObject); - const bool result = static_cast(source)->disconnectMediaNode(static_cast(target)); + Q_ASSERT_X(source, Q_FUNC_INFO, "source is not a MediaNode"); + Q_ASSERT_X(target, Q_FUNC_INFO, "target is not a MediaNode"); - TRACE_RETURN("%d", result); + return source->disconnectOutput(target); } bool Backend::endConnectionChange(QSet) diff --git a/src/3rdparty/phonon/mmf/bassboost.cpp b/src/3rdparty/phonon/mmf/bassboost.cpp index e34f9e7..36069fb 100644 --- a/src/3rdparty/phonon/mmf/bassboost.cpp +++ b/src/3rdparty/phonon/mmf/bassboost.cpp @@ -16,6 +16,7 @@ along with this library. If not, see . */ +#include #include "bassboost.h" QT_BEGIN_NAMESPACE @@ -35,13 +36,26 @@ BassBoost::BassBoost(QObject *parent) : AbstractAudioEffect::AbstractAudioEffect void BassBoost::parameterChanged(const int, const QVariant &) { - // We should never be called, because we have no parameters. + Q_ASSERT_X(false, Q_FUNC_INFO, "BassBoost has not parameters"); } -bool BassBoost::activateOn(CPlayerType *player) +void BassBoost::connectAudioPlayer(AudioPlayer::NativePlayer *player) { - m_effect.reset(CBassBoost::NewL(*player, true)); - return true; + CBassBoost *ptr = 0; + QT_TRAP_THROWING(ptr = CBassBoost::NewL(*player)); + m_effect.reset(ptr); +} + +void BassBoost::connectVideoPlayer(VideoPlayer::NativePlayer *player) +{ + CBassBoost *ptr = 0; + QT_TRAP_THROWING(ptr = CBassBoost::NewL(*player)); + m_effect.reset(ptr); +} + +void BassBoost::applyParameters() +{ + // No parameters to apply } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/bassboost.h b/src/3rdparty/phonon/mmf/bassboost.h index c16393a..1b893db 100644 --- a/src/3rdparty/phonon/mmf/bassboost.h +++ b/src/3rdparty/phonon/mmf/bassboost.h @@ -19,7 +19,6 @@ along with this library. If not, see . #ifndef PHONON_MMF_BASSBOOST_H #define PHONON_MMF_BASSBOOST_H -#include #include "abstractaudioeffect.h" QT_BEGIN_NAMESPACE @@ -41,13 +40,12 @@ public: BassBoost(QObject *parent); protected: - virtual void parameterChanged(const int id, - const QVariant &value); + // AbstractAudioEffect + virtual void connectAudioPlayer(AudioPlayer::NativePlayer *player); + virtual void connectVideoPlayer(VideoPlayer::NativePlayer *player); + virtual void applyParameters(); + virtual void parameterChanged(const int id, const QVariant &value); - virtual bool activateOn(CPlayerType *player); - -private: - QScopedPointer m_bassBoost; }; } } diff --git a/src/3rdparty/phonon/mmf/effectfactory.cpp b/src/3rdparty/phonon/mmf/effectfactory.cpp index e9c5e27..cc94367 100644 --- a/src/3rdparty/phonon/mmf/effectfactory.cpp +++ b/src/3rdparty/phonon/mmf/effectfactory.cpp @@ -113,7 +113,7 @@ bool isEffectSupported() AudioPlayer audioPlayer; QScopedPointer eff; - TRAPD(errorCode, eff.reset(TEffect::NewL(*audioPlayer.player()))); + TRAPD(errorCode, eff.reset(TEffect::NewL(*audioPlayer.nativePlayer()))); return errorCode != KErrNone; } diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index a9a012f..4653fee 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -358,6 +358,25 @@ void MMF::MediaObject::volumeChanged(qreal volume) } //----------------------------------------------------------------------------- +// MediaNode +//----------------------------------------------------------------------------- + +void MMF::MediaObject::connectMediaObject(MediaObject * /*mediaObject*/) +{ + // This function should never be called - see MediaNode::setMediaObject() + Q_ASSERT_X(false, Q_FUNC_INFO, + "Connection of MediaObject to MediaObject"); +} + +void MMF::MediaObject::disconnectMediaObject(MediaObject * /*mediaObject*/) +{ + // This function should never be called - see MediaNode::setMediaObject() + Q_ASSERT_X(false, Q_FUNC_INFO, + "Disconnection of MediaObject from MediaObject"); +} + + +//----------------------------------------------------------------------------- // Video output //----------------------------------------------------------------------------- @@ -372,12 +391,6 @@ AbstractPlayer *MMF::MediaObject::abstractPlayer() const return m_player.data(); } -bool MMF::MediaObject::activateOnMediaObject(MediaObject *) -{ - // Guess what, we do nothing. - return true; -} - //----------------------------------------------------------------------------- // Playlist support //----------------------------------------------------------------------------- diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index 7c39598..668b953 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -75,6 +75,10 @@ public: virtual qint32 transitionTime() const; virtual void setTransitionTime(qint32); + // MediaNode + void connectMediaObject(MediaObject *mediaObject); + void disconnectMediaObject(MediaObject *mediaObject); + /** * This class owns the AbstractPlayer, and will delete it upon * destruction. @@ -83,8 +87,6 @@ public: void setVideoOutput(VideoOutput* videoOutput); - virtual bool activateOnMediaObject(MediaObject *); - public Q_SLOTS: void volumeChanged(qreal volume); void switchToNextSource(); diff --git a/src/3rdparty/phonon/mmf/mmf_medianode.cpp b/src/3rdparty/phonon/mmf/mmf_medianode.cpp index 253c5e7..ca413d9 100644 --- a/src/3rdparty/phonon/mmf/mmf_medianode.cpp +++ b/src/3rdparty/phonon/mmf/mmf_medianode.cpp @@ -29,92 +29,123 @@ using namespace Phonon::MMF; \internal */ -MMF::MediaNode::MediaNode(QObject *parent) : QObject::QObject(parent) - , m_source(0) - , m_target(0) - , m_isApplied(false) +MMF::MediaNode::MediaNode(QObject *parent) + : QObject(parent) + , m_mediaObject(qobject_cast(this)) + , m_input(0) { -} - -bool MMF::MediaNode::connectMediaNode(MediaNode *target) -{ - m_target = target; - m_target->setSource(this); - return applyNodesOnMediaObject(target); } -bool MMF::MediaNode::disconnectMediaNode(MediaNode *target) +MMF::MediaNode::~MediaNode() { - Q_UNUSED(target); - m_target = 0; - m_isApplied = false; - return true; + // Phonon framework ensures nodes are disconnected before being destroyed. + Q_ASSERT_X(!m_mediaObject, Q_FUNC_INFO, + "Media node not disconnected before destruction"); } -void MMF::MediaNode::setSource(MediaNode *source) +bool MMF::MediaNode::connectOutput(MediaNode *output) { - m_source = source; + Q_ASSERT_X(output, Q_FUNC_INFO, "Null output pointer"); + + bool connected = false; + + // Check that this connection will not result in a graph which + // containing more than one MediaObject + const bool mediaObjectMisMatch = + m_mediaObject + && output->m_mediaObject + && m_mediaObject != output->m_mediaObject; + + const bool canConnect = + !output->isMediaObject() + && !output->m_input + && !m_outputs.contains(output); + + if (canConnect && !mediaObjectMisMatch) { + output->m_input = this; + m_outputs += output; + updateMediaObject(); + connected = true; + } + + return connected; } -MMF::MediaNode *MMF::MediaNode::source() const +bool MMF::MediaNode::disconnectOutput(MediaNode *output) { - return m_source; + Q_ASSERT_X(output, Q_FUNC_INFO, "Null output pointer"); + + bool disconnected = false; + + if (m_outputs.contains(output) && this == output->m_input) { + output->m_input = 0; + const bool removed = m_outputs.removeOne(output); + Q_ASSERT_X(removed, Q_FUNC_INFO, "Output removal failed"); + + Q_ASSERT_X(!m_outputs.contains(output), Q_FUNC_INFO, + "Output list contains duplicate entries"); + + // Perform traversal across each of the two graphs separately + updateMediaObject(); + output->updateMediaObject(); + + disconnected = true; + } + + return disconnected; } -MMF::MediaNode *MMF::MediaNode::target() const +bool MMF::MediaNode::isMediaObject() const { - return m_target; + return (qobject_cast(this) != 0); } -bool MMF::MediaNode::applyNodesOnMediaObject(MediaNode *) +void MMF::MediaNode::updateMediaObject() { - // Algorithmically, this can be expressed in a more efficient way by - // exercising available assumptions, but it complicates code for input - // data(length of the graph) which typically is very small. - - // First, we go to the very beginning of the graph. - MMF::MediaNode *current = this; - do { - MediaNode *const candidate = current->source(); - if (candidate) - current = candidate; - else - break; - } - while (current); - - // Now we do two things, while walking to the other end: - // 1. Find the MediaObject, if present - // 2. Collect a list of all unapplied MediaNodes - - QList unapplied; - MMF::MediaObject *mo = 0; + QList nodes; + MediaObject *mediaObject = 0; - do { - if (!current->m_isApplied) - unapplied.append(current); + // Traverse the graph, collecting a list of nodes, and locating + // the MediaObject node, if present + visit(nodes, mediaObject); - if (!mo) - mo = qobject_cast(current); + MediaNode *node = 0; + foreach(node, nodes) + node->setMediaObject(mediaObject); +} - current = current->target(); +void MMF::MediaNode::setMediaObject(MediaObject *mediaObject) +{ + if(!isMediaObject() && m_mediaObject != mediaObject) { + if (!mediaObject) + disconnectMediaObject(m_mediaObject); + else { + Q_ASSERT_X(!m_mediaObject, Q_FUNC_INFO, "MediaObject already set"); + connectMediaObject(mediaObject); + } + m_mediaObject = mediaObject; } - while (current); +} - // Now, lets activate all the objects, if we found the MediaObject. +void MMF::MediaNode::visit(QList& visited, MediaObject*& mediaObject) +{ + if (isMediaObject()) { + // There can never be more than one MediaObject per graph, due to the + // mediaObjectMisMatch test in connectOutput(). + Q_ASSERT_X(!mediaObject, Q_FUNC_INFO, "MediaObject already found"); + mediaObject = static_cast(this); + } - if (mo) { - for (int i = 0; i < unapplied.count(); ++i) { - MediaNode *const at = unapplied.at(i); + visited += this; - // We don't want to apply MediaObject on itself. - if (at != mo) - at->activateOnMediaObject(mo); - } - } + if (m_input && !visited.contains(m_input)) + m_input->visit(visited, mediaObject); - return true; + MediaNode *output = 0; + foreach (output, m_outputs) + if (!visited.contains(output)) + output->visit(visited, mediaObject); } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/mmf_medianode.h b/src/3rdparty/phonon/mmf/mmf_medianode.h index 4616ff1..0ed21c4 100644 --- a/src/3rdparty/phonon/mmf/mmf_medianode.h +++ b/src/3rdparty/phonon/mmf/mmf_medianode.h @@ -43,54 +43,62 @@ class MediaObject; /** * @short Base class for all nodes in the MMF backend. * - * MediaNode is the base class for all nodes in the chain for MMF. Currently - * they are: + * MediaNode is the base class for all nodes created by the MMF + * backend. * - * - MediaObject: a source of media - * - AbstractEffect: supplying audio effects - * - AudioOutput: pretty much a dummy interface, but is also MediaNode in order - * to simplify connection/disconnection. + * These nodes may be one of the following types: * - * MediaNode provides spectatability into the chain, and also allows the - * connection code to be written in a polymorphic manner, instead of putting it - * all in the Backend class. Due to that MMF has no concept of chaining, the - * order of the nodes in the graph has no meaning. + * - MediaObject + * This represents the source of media data. It encapsulates the + * appropriate MMF client API for playing audio or video. + * - AudioOutput + * This represents the audio output device. Since the MMF client API + * does not expose the output device directly, this backend node + * simply forwards volume control commands to the MediaObject. + * - VideoWidget + * A native widget on which video will be rendered. + * - An audio effect, derived form AbstractAudioEffect + * + * Because the MMF API does not support the concept of a media filter graph, + * this class must ensure the following: + * + * - Each media graph contains at most one MediaObject instance. + * - Every non-MediaObject node holds a reference to the MediaObject. This + * allows commands to be sent through the graph to the encapsulated MMF client + * API. */ class MediaNode : public QObject { Q_OBJECT public: MediaNode(QObject *parent); + ~MediaNode(); + + bool connectOutput(MediaNode *output); + bool disconnectOutput(MediaNode *output); + + virtual void connectMediaObject(MediaObject *mediaObject) = 0; + virtual void disconnectMediaObject(MediaObject *mediaObject) = 0; - virtual bool connectMediaNode(MediaNode *target); - virtual bool disconnectMediaNode(MediaNode *target); - void setSource(MediaNode *source); +private: + bool isMediaObject() const; - MediaNode *source() const; - MediaNode *target() const; + void updateMediaObject(); + void setMediaObject(MediaObject *mediaObject); -protected: - /** - * When connectMediaNode() is called and a MediaObject is part of - * the its graph, this function will be called for each MediaNode in the - * graph for which it hasn't been called yet. - * - * The caller guarantees that @p mo is always non-null. - */ - virtual bool activateOnMediaObject(MediaObject *mo) = 0; + typedef QList NodeList; + void visit(QList& visited, MediaObject*& mediaObject); private: - /** - * Finds a MediaObject anywhere in the graph @p target is apart of, and - * calls activateOnMediaObject() for all MediaNodes in the graph for which - * it hasn't been applied to already. - */ - bool applyNodesOnMediaObject(MediaNode *target); - - MediaNode * m_source; - MediaNode * m_target; - bool m_isApplied; + MediaObject * m_mediaObject; + + // All nodes except MediaObject may have an input + MediaNode * m_input; + + // Only MediaObject can have more than one output + QList m_outputs; }; + } } diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp index 877dfb3..127edb4 100644 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp @@ -97,6 +97,11 @@ MMF::VideoPlayer::~VideoPlayer() TRACE_EXIT_0(); } +CVideoPlayerUtility* MMF::VideoPlayer::nativePlayer() const +{ + return m_player.data(); +} + //----------------------------------------------------------------------------- // Public API //----------------------------------------------------------------------------- diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.h b/src/3rdparty/phonon/mmf/mmf_videoplayer.h index 6200e39..0253ab9 100644 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.h +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.h @@ -47,6 +47,9 @@ public: VideoPlayer(MediaObject *parent = 0, const AbstractPlayer *player = 0); virtual ~VideoPlayer(); + typedef CVideoPlayerUtility NativePlayer; + NativePlayer *nativePlayer() const; + // AbstractPlayer virtual void doPlay(); virtual void doPause(); @@ -105,7 +108,7 @@ private: virtual void MvloLoadingComplete(); private: - QScopedPointer m_player; + QScopedPointer m_player; // Not owned RWsSession& m_wsSession; diff --git a/src/3rdparty/phonon/mmf/videowidget.cpp b/src/3rdparty/phonon/mmf/videowidget.cpp index bd22307..bc9acfd 100644 --- a/src/3rdparty/phonon/mmf/videowidget.cpp +++ b/src/3rdparty/phonon/mmf/videowidget.cpp @@ -157,10 +157,18 @@ QWidget* MMF::VideoWidget::widget() return m_videoOutput.data(); } -bool MMF::VideoWidget::activateOnMediaObject(MediaObject *mo) +//----------------------------------------------------------------------------- +// MediaNode +//----------------------------------------------------------------------------- + +void MMF::VideoWidget::connectMediaObject(MediaObject *mediaObject) +{ + mediaObject->setVideoOutput(m_videoOutput.data()); +} + +void MMF::VideoWidget::disconnectMediaObject(MediaObject *mediaObject) { - mo->setVideoOutput(m_videoOutput.data()); - return true; + mediaObject->setVideoOutput(0); } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/videowidget.h b/src/3rdparty/phonon/mmf/videowidget.h index 2f0978b..a876748 100644 --- a/src/3rdparty/phonon/mmf/videowidget.h +++ b/src/3rdparty/phonon/mmf/videowidget.h @@ -61,7 +61,9 @@ public: virtual QWidget *widget(); protected: - virtual bool activateOnMediaObject(MediaObject *mo); + // MediaNode + void connectMediaObject(MediaObject *mediaObject); + void disconnectMediaObject(MediaObject *mediaObject); private: QScopedPointer m_videoOutput; -- cgit v0.12 From 2c4f51cec3aaa219ff0b14afdeafd726cbf8a4db Mon Sep 17 00:00:00 2001 From: David Boddie Date: Fri, 18 Dec 2009 14:41:15 +0100 Subject: Doc: Made corrections to documentation style and clarified some points. Reviewed-by: Trust Me --- src/multimedia/audio/qaudioformat.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/multimedia/audio/qaudioformat.cpp b/src/multimedia/audio/qaudioformat.cpp index b2bbe14..eb5dde3 100644 --- a/src/multimedia/audio/qaudioformat.cpp +++ b/src/multimedia/audio/qaudioformat.cpp @@ -120,7 +120,7 @@ public: \row \o Sample size \o How much data is stored in each sample (typically 8 - or 16) + or 16 bits) \row \o Sample type \o Numerical representation of sample (typically signed integer, @@ -224,7 +224,7 @@ bool QAudioFormat::isValid() const } /*! - Sets the frequency to \a frequency. + Sets the frequency (sample rate) to \a frequency. */ void QAudioFormat::setFrequency(int frequency) @@ -233,7 +233,7 @@ void QAudioFormat::setFrequency(int frequency) } /*! - Returns the current frequency value. + Returns the current frequency (sample rate) value. */ int QAudioFormat::frequency() const @@ -242,7 +242,7 @@ int QAudioFormat::frequency() const } /*! - Sets the channels to \a channels. + Sets the number of channels to the \a channels value specified. */ void QAudioFormat::setChannels(int channels) @@ -251,7 +251,7 @@ void QAudioFormat::setChannels(int channels) } /*! - Returns the current channel value. + Returns the current number of channels. */ int QAudioFormat::channels() const @@ -260,7 +260,7 @@ int QAudioFormat::channels() const } /*! - Sets the sampleSize to \a sampleSize. + Sets the sample size to the \a sampleSize specified. */ void QAudioFormat::setSampleSize(int sampleSize) @@ -269,7 +269,7 @@ void QAudioFormat::setSampleSize(int sampleSize) } /*! - Returns the current sampleSize value. + Returns the current sample size value. */ int QAudioFormat::sampleSize() const -- cgit v0.12 From ba7927c84e0e1ed4df197e60b1c9eeec8ce1475c Mon Sep 17 00:00:00 2001 From: David Boddie Date: Fri, 18 Dec 2009 14:49:48 +0100 Subject: Doc: Fixed comments in a code snippet. Reviewed-by: Trust Me --- doc/src/snippets/audio/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/snippets/audio/main.cpp b/doc/src/snippets/audio/main.cpp index 0910865..396872f 100644 --- a/doc/src/snippets/audio/main.cpp +++ b/doc/src/snippets/audio/main.cpp @@ -112,7 +112,7 @@ public slots: switch (newState) { case QAudio::StopState: if (output->error() != QAudio::NoError) { - // Do your error handlin + // Perform error handling } else { // Normal stop } -- cgit v0.12 From 65a0c8cc6d2c13cfb2cef22e8a23f4e3050fde25 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 18 Dec 2009 15:13:49 +0100 Subject: doc: Added an explanatory \note about the table being sorted. Task-number: QTBUG-5046 --- src/gui/itemviews/qtableview.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp index d27e693..26f5a20 100644 --- a/src/gui/itemviews/qtableview.cpp +++ b/src/gui/itemviews/qtableview.cpp @@ -2359,12 +2359,22 @@ void QTableView::setColumnHidden(int column, bool hide) \property QTableView::sortingEnabled \brief whether sorting is enabled - If this property is true, sorting is enabled for the table; if the - property is false, sorting is not enabled. The default value is false. + If this property is true, sorting is enabled for the table. If + this property is false, sorting is not enabled. The default value + is false. + + \note. Setting the property to true with setSortingEnabled() + immediately triggers a call to sortByColumn() with the current + sort section and order. \sa sortByColumn() */ +/*! + If \a enabled true enables sorting for the table and immediately + trigger a call to sortByColumn() with the current sort section and + order + */ void QTableView::setSortingEnabled(bool enable) { Q_D(QTableView); -- cgit v0.12 From 1f1b37e613a930cc1ab871f5d11bf9742920c7f9 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 30 Dec 2009 09:21:34 +0100 Subject: Track which vertex attrib arrays are enabled in QGLContextPrivate The GL2 engine (and probably Qt/3D) needs to track which vertex attribute arrays are currently enabled and which are disabled. As this is per-context state, the logical place to track this is in the context and not in the paint engine. This patch also makes the GL2 engine's shader manager enable/disable the appropriate attribute arrays for a given shader program when it is used. Reviewed-By: Kim --- .../gl2paintengineex/qglengineshadermanager.cpp | 29 +++++++++++++++++++- .../gl2paintengineex/qglengineshadermanager_p.h | 3 +++ .../gl2paintengineex/qpaintengineex_opengl2.cpp | 11 +++++--- src/opengl/qgl.cpp | 31 ++++++++++++++++++++++ src/opengl/qgl.h | 1 + src/opengl/qgl_p.h | 9 +++++++ 6 files changed, 79 insertions(+), 5 deletions(-) diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index d28d5f3..da33eb3 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -505,7 +505,27 @@ QGLShaderProgram* QGLEngineShaderManager::currentProgram() if (currentShaderProg) return currentShaderProg->program; else - return simpleProgram(); + return sharedShaders->simpleProgram(); +} + +void QGLEngineShaderManager::useSimpleProgram() +{ + sharedShaders->simpleProgram()->bind(); + QGLContextPrivate* ctx_d = ctx->d_func(); + ctx_d->setVertexAttribArrayEnabled(QT_VERTEX_COORDS_ATTR, true); + ctx_d->setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, false); + ctx_d->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, false); + shaderProgNeedsChanging = true; +} + +void QGLEngineShaderManager::useBlitProgram() +{ + sharedShaders->blitProgram()->bind(); + QGLContextPrivate* ctx_d = ctx->d_func(); + ctx_d->setVertexAttribArrayEnabled(QT_VERTEX_COORDS_ATTR, true); + ctx_d->setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, true); + ctx_d->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, false); + shaderProgNeedsChanging = true; } QGLShaderProgram* QGLEngineShaderManager::simpleProgram() @@ -716,6 +736,13 @@ bool QGLEngineShaderManager::useCorrectShaderProg() customSrcStage->setUniforms(currentShaderProg->program); } + // Make sure all the vertex attribute arrays the program uses are enabled (and the ones it + // doesn't use are disabled) + QGLContextPrivate* ctx_d = ctx->d_func(); + ctx_d->setVertexAttribArrayEnabled(QT_VERTEX_COORDS_ATTR, true); + ctx_d->setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, currentShaderProg->useTextureCoords); + ctx_d->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, currentShaderProg->useOpacityAttribute); + shaderProgNeedsChanging = false; return true; } diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h index 1ec4cdc..a132e1b 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h @@ -468,6 +468,9 @@ public: void setDirty(); // someone has manually changed the current shader program bool useCorrectShaderProg(); // returns true if the shader program needed to be changed + void useSimpleProgram(); + void useBlitProgram(); + QGLShaderProgram* currentProgram(); // Returns pointer to the shader the manager has chosen QGLShaderProgram* simpleProgram(); // Used to draw into e.g. stencil buffers QGLShaderProgram* blitProgram(); // Used to blit a texture into the framebuffer diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index d3a9547..0574c52 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -248,9 +248,8 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, vertexCoordinateArray); glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray); - pex->shaderManager->blitProgram()->bind(); + pex->shaderManager->useBlitProgram(); pex->shaderManager->blitProgram()->setUniformValue("imageTexture", QT_IMAGE_TEXTURE_UNIT); - pex->shaderManager->setDirty(); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); @@ -413,8 +412,7 @@ void QGL2PaintEngineExPrivate::setBrush(const QBrush& brush) void QGL2PaintEngineExPrivate::useSimpleShader() { - shaderManager->simpleProgram()->bind(); - shaderManager->setDirty(); + shaderManager->useSimpleProgram(); if (matrixDirty) updateMatrix(); @@ -745,6 +743,10 @@ void QGL2PaintEngineEx::beginNativePainting() QGLContext *ctx = d->ctx; glUseProgram(0); + // Disable all the vertex attribute arrays: + for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i) + glDisableVertexAttribArray(i); + #ifndef QT_OPENGL_ES_2 // be nice to people who mix OpenGL 1.x code with QPainter commands // by setting modelview and projection matrices to mirror the GL 1 @@ -1935,6 +1937,7 @@ void QGL2PaintEngineEx::ensureActive() glViewport(0, 0, d->width, d->height); d->needsSync = false; d->shaderManager->setDirty(); + d->ctx->d_func()->syncGlState(); setState(state()); } } diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 466e851..5bb62f7 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1484,6 +1484,8 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) current_fbo = 0; default_fbo = 0; active_engine = 0; + for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i) + vertexAttributeArraysEnabledState[i] = false; } QGLContext* QGLContext::currentCtx = 0; @@ -1874,6 +1876,35 @@ void QGLContextPrivate::cleanup() { } +#define ctx q_ptr +void QGLContextPrivate::setVertexAttribArrayEnabled(int arrayIndex, bool enabled) +{ + Q_ASSERT(arrayIndex < QT_GL_VERTEX_ARRAY_TRACKED_COUNT); + Q_ASSERT(glEnableVertexAttribArray); + + if (vertexAttributeArraysEnabledState[arrayIndex] && !enabled) + glDisableVertexAttribArray(arrayIndex); + + if (!vertexAttributeArraysEnabledState[arrayIndex] && enabled) + glEnableVertexAttribArray(arrayIndex); + + vertexAttributeArraysEnabledState[arrayIndex] = enabled; +} + +void QGLContextPrivate::syncGlState() +{ + Q_ASSERT(glEnableVertexAttribArray); + for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i) { + if (vertexAttributeArraysEnabledState[i]) + glEnableVertexAttribArray(i); + else + glDisableVertexAttribArray(i); + } + +} +#undef ctx + + /*! \overload diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index 2076c46..b6cd128 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -393,6 +393,7 @@ private: friend class QOpenGLPaintEnginePrivate; friend class QGL2PaintEngineEx; friend class QGL2PaintEngineExPrivate; + friend class QGLEngineShaderManager; friend class QGLWindowSurface; friend class QGLPixmapData; friend class QGLPixmapFilterBase; diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 99c0f33..834ff96 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -257,6 +257,10 @@ private: class QGLTexture; +// This probably needs to grow to GL_MAX_VERTEX_ATTRIBS, but 3 is ok for now as that's +// all the GL2 engine uses: +#define QT_GL_VERTEX_ARRAY_TRACKED_COUNT 3 + class QGLContextPrivate { Q_DECLARE_PUBLIC(QGLContext) @@ -276,6 +280,9 @@ public: void cleanup(); + void setVertexAttribArrayEnabled(int arrayIndex, bool enabled = true); + void syncGlState(); // Makes sure the GL context's state is what we think it is + #if defined(Q_WS_WIN) HGLRC rc; HDC dc; @@ -332,6 +339,8 @@ public: GLuint default_fbo; QPaintEngine *active_engine; + bool vertexAttributeArraysEnabledState[QT_GL_VERTEX_ARRAY_TRACKED_COUNT]; + static inline QGLContextGroup *contextGroup(const QGLContext *ctx) { return ctx->d_ptr->group; } #ifdef Q_WS_WIN -- cgit v0.12 From 16b41824dceb1cecfe54089d88af787af134af8a Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 30 Dec 2009 09:48:35 +0100 Subject: Remove superfluous enable/disable vertex arrtib arrays Now that the shader manager takes care of enabling/disabling the vertex attribute arrays for us, the GL2 paint engine doesn't have to do it. This reduces GL state changes within the paint engine and provides significant performance improvements. For a given test case (25,000 3x3px solid rects), the improvement is 67% on desktop (nVidia) and 9% on embedded (SGX). Reviewed-By: Kim --- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 34 ---------------------- 1 file changed, 34 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 0574c52..90b7214 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -242,9 +242,6 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) float vertexCoordinateArray[] = { -1, -1, 1, -1, 1, 1, -1, 1 }; float textureCoordinateArray[] = { 0, 0, 1, 0, 1, 1, 0, 1 }; - glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); - glEnableVertexAttribArray(QT_TEXTURE_COORDS_ATTR); - glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, vertexCoordinateArray); glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray); @@ -253,9 +250,6 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR); - glDisableVertexAttribArray(QT_TEXTURE_COORDS_ATTR); - glBindTexture(GL_TEXTURE_2D, m_texture); #ifdef QT_OPENGL_ES_2 @@ -806,34 +800,20 @@ void QGL2PaintEngineExPrivate::transferMode(EngineMode newMode) return; if (mode == TextDrawingMode || mode == ImageDrawingMode || mode == ImageArrayDrawingMode) { - glDisableVertexAttribArray(QT_TEXTURE_COORDS_ATTR); - glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR); - glDisableVertexAttribArray(QT_OPACITY_ATTR); - lastTextureUsed = GLuint(-1); } if (newMode == TextDrawingMode) { - glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); - glEnableVertexAttribArray(QT_TEXTURE_COORDS_ATTR); - glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, vertexCoordinateArray.data()); glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray.data()); } if (newMode == ImageDrawingMode) { - glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); - glEnableVertexAttribArray(QT_TEXTURE_COORDS_ATTR); - glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, staticVertexCoordinateArray); glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, staticTextureCoordinateArray); } if (newMode == ImageArrayDrawingMode) { - glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); - glEnableVertexAttribArray(QT_TEXTURE_COORDS_ATTR); - glEnableVertexAttribArray(QT_OPACITY_ATTR); - glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, vertexCoordinateArray.data()); glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray.data()); glVertexAttribPointer(QT_OPACITY_ATTR, 1, GL_FLOAT, GL_FALSE, 0, opacityArray.data()); @@ -944,7 +924,6 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) } prepareForDraw(currentBrush.isOpaque()); - glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); #ifdef QT_OPENGL_CACHE_AS_VBOS glBindBuffer(GL_ARRAY_BUFFER, cache->vbo); glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, false, 0, 0); @@ -1085,10 +1064,8 @@ void QGL2PaintEngineExPrivate::fillStencilWithVertexArray(const float *data, glStencilMask(GL_STENCIL_HIGH_BIT); #if 0 glStencilOp(GL_KEEP, GL_KEEP, GL_INVERT); // Simply invert the stencil bit - glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, data); glDrawArrays(GL_TRIANGLE_STRIP, 0, count); - glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR); #else glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); @@ -1098,10 +1075,8 @@ void QGL2PaintEngineExPrivate::fillStencilWithVertexArray(const float *data, } else { glStencilFunc(GL_ALWAYS, GL_STENCIL_HIGH_BIT, 0xff); } - glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, data); glDrawArrays(GL_TRIANGLE_STRIP, 0, count); - glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR); #endif } @@ -1228,12 +1203,8 @@ void QGL2PaintEngineExPrivate::composite(const QGLRect& boundingRect) boundingRect.right, boundingRect.top }; - glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, rectVerts); - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - - glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR); } // Draws the vertex array as a set of triangle fans. @@ -1241,7 +1212,6 @@ void QGL2PaintEngineExPrivate::drawVertexArrays(const float *data, int *stops, i GLenum primitive) { // Now setup the pointer to the vertex array: - glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, data); int previousStop = 0; @@ -1255,7 +1225,6 @@ void QGL2PaintEngineExPrivate::drawVertexArrays(const float *data, int *stops, i glDrawArrays(primitive, previousStop, stop - previousStop); previousStop = stop; } - glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR); } void QGL2PaintEngineExPrivate::prepareDepthRangeForRenderText() @@ -1364,7 +1333,6 @@ void QGL2PaintEngineExPrivate::stroke(const QVectorPath &path, const QPen &pen) if (opaque) { prepareForDraw(opaque); - glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, false, 0, stroker.vertices()); glDrawArrays(GL_TRIANGLE_STRIP, 0, stroker.vertexCount() / 2); @@ -1373,8 +1341,6 @@ void QGL2PaintEngineExPrivate::stroke(const QVectorPath &path, const QPen &pen) // d->prepareForDraw(true); // glDrawArrays(GL_LINE_STRIP, 0, d->stroker.vertexCount() / 2); - glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR); - } else { qreal width = qpen_widthf(pen) / 2; if (width == 0) -- cgit v0.12 From 2600fd42117913b427d07e510724b0ea5e355205 Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Wed, 30 Dec 2009 13:44:58 +0100 Subject: Fixes painting artifacts when using CacheBackground in a QGraphicsView. The problem was that when the background cache was invalidated, it was entirely recreated but only the exposed area of the view was repainted in it, causing the cache to be partly empty in some cases. Now the background cache is always fully repainted when it is invalidated. Task-number: QTBUG-6935 Reviewed-by: ogoffart --- src/gui/graphicsview/qgraphicsview.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index 3bb40fb..1569078 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -3365,7 +3365,8 @@ void QGraphicsView::paintEvent(QPaintEvent *event) #define X11 qt_x11Data #endif backgroundPainter.setCompositionMode(QPainter::CompositionMode_Source); - drawBackground(&backgroundPainter, exposedSceneRect); + QRectF backgroundExposedSceneRect = mapToScene(d->backgroundPixmapExposed.boundingRect()).boundingRect(); + drawBackground(&backgroundPainter, backgroundExposedSceneRect); d->backgroundPixmapExposed = QRegion(); } -- cgit v0.12 From 5394052c422f7087263ad6dc6d6a4448b4c4afba Mon Sep 17 00:00:00 2001 From: Trond Kjernaasen Date: Wed, 30 Dec 2009 14:11:22 +0100 Subject: Fixed QGLWidget::renderText(). Fall back and use the GL 1 engine for the renderText() functions. Getting it to work with the GL 2 engine is a futile effort. Making it work with renderPixmap() in the GL 2 engine is not possible at all, since software contexts in general do not support shader programs. Task-number: QTBUG-5002, QTBUG-6931 Reviewed-by: Kim --- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 88 ++-------------------- .../gl2paintengineex/qpaintengineex_opengl2_p.h | 9 +-- src/opengl/qgl.cpp | 25 ++---- 3 files changed, 13 insertions(+), 109 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 90b7214..0f8e945 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -227,11 +227,6 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) pex->transferMode(BrushDrawingMode); -#ifndef QT_OPENGL_ES_2 - if (pex->inRenderText) - glPushAttrib(GL_ENABLE_BIT | GL_VIEWPORT_BIT | GL_SCISSOR_BIT); -#endif - glDisable(GL_STENCIL_TEST); glDisable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); @@ -276,11 +271,6 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) glViewport(0, 0, pex->width, pex->height); pex->updateClipScissorTest(); - -#ifndef QT_OPENGL_ES_2 - if (pex->inRenderText) - glPopAttrib(); -#endif } void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph) @@ -965,20 +955,11 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) // Pass when high bit is set, replace stencil value with 0 glStencilFunc(GL_NOTEQUAL, 0, GL_STENCIL_HIGH_BIT); } - prepareForDraw(currentBrush.isOpaque()); - if (inRenderText) - prepareDepthRangeForRenderText(); - // Stencil the brush onto the dest buffer composite(vertexCoordinateArray.boundingRect()); - - if (inRenderText) - restoreDepthRangeForRenderText(); - glStencilMask(0); - updateClipScissorTest(); } } @@ -1017,13 +998,6 @@ void QGL2PaintEngineExPrivate::fillStencilWithVertexArray(const float *data, useSimpleShader(); glEnable(GL_STENCIL_TEST); // For some reason, this has to happen _after_ the simple shader is use()'d -#ifndef QT_OPENGL_ES_2 - if (inRenderText) { - glPushAttrib(GL_ENABLE_BIT); - glDisable(GL_DEPTH_TEST); - } -#endif - if (mode == WindingFillMode) { Q_ASSERT(stops && !count); if (q->state()->clipTestEnabled) { @@ -1082,12 +1056,6 @@ void QGL2PaintEngineExPrivate::fillStencilWithVertexArray(const float *data, // Enable color writes & disable stencil writes glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - -#ifndef QT_OPENGL_ES_2 - if (inRenderText) - glPopAttrib(); -#endif - } /* @@ -1227,30 +1195,6 @@ void QGL2PaintEngineExPrivate::drawVertexArrays(const float *data, int *stops, i } } -void QGL2PaintEngineExPrivate::prepareDepthRangeForRenderText() -{ -#ifndef QT_OPENGL_ES_2 - // Get the z translation value from the model view matrix and - // transform it using the ortogonal projection with z-near = 0, - // and z-far = 1, which is used in QGLWidget::renderText() - GLdouble model[4][4]; - glGetDoublev(GL_MODELVIEW_MATRIX, &model[0][0]); - float deviceZ = -2 * model[3][2] - 1; - - glGetFloatv(GL_DEPTH_RANGE, depthRange); - float windowZ = depthRange[0] + (deviceZ + 1) * 0.5 * (depthRange[1] - depthRange[0]); - - glDepthRange(windowZ, windowZ); -#endif -} - -void QGL2PaintEngineExPrivate::restoreDepthRangeForRenderText() -{ -#ifndef QT_OPENGL_ES_2 - glDepthRange(depthRange[0], depthRange[1]); -#endif -} - /////////////////////////////////// Public Methods ////////////////////////////////////////// QGL2PaintEngineEx::QGL2PaintEngineEx() @@ -1268,10 +1212,7 @@ void QGL2PaintEngineEx::fill(const QVectorPath &path, const QBrush &brush) if (qbrush_style(brush) == Qt::NoBrush) return; - - if (!d->inRenderText) - ensureActive(); - + ensureActive(); d->setBrush(brush); d->fill(path); } @@ -1486,8 +1427,7 @@ void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem { Q_D(QGL2PaintEngineEx); - if (!d->inRenderText) - ensureActive(); + ensureActive(); QOpenGL2PaintEngineState *s = state(); const QTextItemInt &ti = static_cast(textItem); @@ -1506,7 +1446,7 @@ void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem ? QFontEngineGlyphCache::Type(ti.fontEngine->glyphFormat) : d->glyphCacheType; - if (d->inRenderText || txtype > QTransform::TxTranslate) + if (txtype > QTransform::TxTranslate) glyphType = QFontEngineGlyphCache::Raster_A8; if (glyphType == QFontEngineGlyphCache::Raster_RGBMask @@ -1548,8 +1488,6 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, QFontEngineGly if (cache->width() == 0 || cache->height() == 0) return; - if (inRenderText) - transferMode(BrushDrawingMode); transferMode(TextDrawingMode); int margin = cache->glyphMargin(); @@ -1585,9 +1523,6 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, QFontEngineGly QBrush pensBrush = q->state()->pen.brush(); setBrush(pensBrush); - if (inRenderText) - prepareDepthRangeForRenderText(); - if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) { // Subpixel antialiasing without gamma correction @@ -1672,9 +1607,6 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, QFontEngineGly shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::MaskTexture), QT_MASK_TEXTURE_UNIT); glDrawArrays(GL_TRIANGLES, 0, 6 * glyphs.size()); - - if (inRenderText) - restoreDepthRangeForRenderText(); } void QGL2PaintEngineEx::drawPixmaps(const QDrawPixmaps::Data *drawingData, int dataCount, const QPixmap &pixmap, QDrawPixmaps::DrawingHints hints) @@ -1822,11 +1754,9 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) d->shaderManager = new QGLEngineShaderManager(d->ctx); - if (!d->inRenderText) { - glDisable(GL_STENCIL_TEST); - glDisable(GL_DEPTH_TEST); - glDisable(GL_SCISSOR_TEST); - } + glDisable(GL_STENCIL_TEST); + glDisable(GL_DEPTH_TEST); + glDisable(GL_SCISSOR_TEST); #if !defined(QT_OPENGL_ES_2) glDisable(GL_MULTISAMPLE); @@ -2267,12 +2197,6 @@ QPainterState *QGL2PaintEngineEx::createState(QPainterState *orig) const return s; } -void QGL2PaintEngineEx::setRenderTextActive(bool active) -{ - Q_D(QGL2PaintEngineEx); - d->inRenderText = active; -} - QOpenGL2PaintEngineState::QOpenGL2PaintEngineState(QOpenGL2PaintEngineState &other) : QPainterState(other) { diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index c94c4f4..9a5c447 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -168,8 +168,7 @@ public: ctx(0), useSystemClip(true), addOffset(false), - inverseScale(1), - inRenderText(false) + inverseScale(1) { } ~QGL2PaintEngineExPrivate(); @@ -215,10 +214,6 @@ public: return shaderManager->getUniformLocation(uniform); } - - void prepareDepthRangeForRenderText(); - void restoreDepthRangeForRenderText(); - void clearClip(uint value); void writeClip(const QVectorPath &path, uint value); void resetClipIfNeeded(); @@ -228,7 +223,6 @@ public: void regenerateClip(); void systemStateChanged(); - static QGLEngineShaderManager* shaderManagerForEngine(QGL2PaintEngineEx *engine) { return engine->d_func()->shaderManager; } static QGL2PaintEngineExPrivate *getData(QGL2PaintEngineEx *engine) { return engine->d_func(); } static void cleanupVectorPath(QPaintEngineEx *engine, void *data); @@ -273,7 +267,6 @@ public: GLuint lastTextureUsed; bool needsSync; - bool inRenderText; bool multisamplingAlwaysEnabled; GLfloat depthRange[2]; diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 5bb62f7..f5e46de 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -4409,9 +4409,9 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, int height = d->glcx->device()->height(); bool auto_swap = autoBufferSwap(); + QPaintEngine::Type oldEngineType = qgl_engine_selector()->preferredPaintEngine(); + qgl_engine_selector()->setPreferredPaintEngine(QPaintEngine::OpenGL); QPaintEngine *engine = paintEngine(); - if (engine->type() == QPaintEngine::OpenGL2) - static_cast(engine)->setRenderTextActive(true); QPainter *p; bool reuse_painter = false; if (engine->isActive()) { @@ -4431,11 +4431,6 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, setAutoBufferSwap(false); // disable glClear() as a result of QPainter::begin() d->disable_clear_on_painter_begin = true; - if (engine->type() == QPaintEngine::OpenGL2) { - qt_save_gl_state(); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - } p = new QPainter(this); } @@ -4459,11 +4454,8 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, delete p; setAutoBufferSwap(auto_swap); d->disable_clear_on_painter_begin = false; - if (engine->type() == QPaintEngine::OpenGL2) - qt_restore_gl_state(); } - if (engine->type() == QPaintEngine::OpenGL2) - static_cast(engine)->setRenderTextActive(false); + qgl_engine_selector()->setPreferredPaintEngine(oldEngineType); #else // QT_OPENGL_ES Q_UNUSED(x); Q_UNUSED(y); @@ -4511,9 +4503,9 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con &win_x, &win_y, &win_z); win_y = height - win_y; // y is inverted + QPaintEngine::Type oldEngineType = qgl_engine_selector()->preferredPaintEngine(); + qgl_engine_selector()->setPreferredPaintEngine(QPaintEngine::OpenGL); QPaintEngine *engine = paintEngine(); - if (engine->type() == QPaintEngine::OpenGL2) - static_cast(engine)->setRenderTextActive(true); QPainter *p; bool reuse_painter = false; bool use_depth_testing = glIsEnabled(GL_DEPTH_TEST); @@ -4527,8 +4519,6 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con setAutoBufferSwap(false); // disable glClear() as a result of QPainter::begin() d->disable_clear_on_painter_begin = true; - if (engine->type() == QPaintEngine::OpenGL2) - qt_save_gl_state(); p = new QPainter(this); } @@ -4557,13 +4547,10 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con } else { p->end(); delete p; - if (engine->type() == QPaintEngine::OpenGL2) - qt_restore_gl_state(); setAutoBufferSwap(auto_swap); d->disable_clear_on_painter_begin = false; } - if (engine->type() == QPaintEngine::OpenGL2) - static_cast(engine)->setRenderTextActive(false); + qgl_engine_selector()->setPreferredPaintEngine(oldEngineType); #else // QT_OPENGL_ES Q_UNUSED(x); Q_UNUSED(y); -- cgit v0.12 From f005fb5b15eb387edb1a0d1da91639ac4cc1e67b Mon Sep 17 00:00:00 2001 From: jianliang79 Date: Wed, 30 Dec 2009 13:58:22 +0100 Subject: fix a memory leak in QGLEngineSharedShaders Merge-request: 412 Reviewed-by: Tom Cooksey --- src/opengl/gl2paintengineex/qglengineshadermanager.cpp | 7 +++++++ src/opengl/gl2paintengineex/qglengineshadermanager_p.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index da33eb3..b026e29 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -218,6 +218,13 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) } +QGLEngineSharedShaders::~QGLEngineSharedShaders() +{ + QList::iterator itr; + for (itr = cachedPrograms.begin(); itr != cachedPrograms.end(); ++itr) + delete *itr; +} + #if defined (QT_DEBUG) QByteArray QGLEngineSharedShaders::snippetNameStr(SnippetName name) { diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h index a132e1b..a3464d4 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h @@ -344,6 +344,7 @@ public: */ QGLEngineSharedShaders(const QGLContext *context); + ~QGLEngineSharedShaders(); QGLShaderProgram *simpleProgram() { return simpleShaderProg; } QGLShaderProgram *blitProgram() { return blitShaderProg; } -- cgit v0.12 From f953b7c40c28a5728125ba72b091d8b384e8858a Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 30 Dec 2009 14:32:58 +0100 Subject: Also delete blitShader & simpleShader in ~QGLEngineSharedShaders Reviewed-By: Trustme --- src/opengl/gl2paintengineex/qglengineshadermanager.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index b026e29..326ea1f 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -223,6 +223,16 @@ QGLEngineSharedShaders::~QGLEngineSharedShaders() QList::iterator itr; for (itr = cachedPrograms.begin(); itr != cachedPrograms.end(); ++itr) delete *itr; + + if (blitShaderProg) { + delete blitShaderProg; + blitShaderProg = 0; + } + + if (simpleShaderProg) { + delete simpleShaderProg; + simpleShaderProg = 0; + } } #if defined (QT_DEBUG) -- cgit v0.12 From 51c4571caf5d5ffb2545106df47d7c399b3e228b Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Wed, 30 Dec 2009 14:38:59 +0100 Subject: Fix background brush for character format when writing to ODF document. Task-number: QTBUG-7047 Reviewed-by: Benjamin Poulain --- src/gui/text/qtextodfwriter.cpp | 9 ++++++++- tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp index 1bd4dd6..5822d92 100644 --- a/src/gui/text/qtextodfwriter.cpp +++ b/src/gui/text/qtextodfwriter.cpp @@ -484,6 +484,10 @@ void QTextOdfWriter::writeBlockFormat(QXmlStreamWriter &writer, QTextBlockFormat if (format.pageBreakPolicy() & QTextFormat::PageBreak_AlwaysAfter) writer.writeAttribute(foNS, QString::fromLatin1("break-after"), QString::fromLatin1("page")); } + if (format.hasProperty(QTextFormat::BackgroundBrush)) { + QBrush brush = format.background(); + writer.writeAttribute(foNS, QString::fromLatin1("background-color"), brush.color().name()); + } if (format.hasProperty(QTextFormat::BlockNonBreakableLines)) writer.writeAttribute(foNS, QString::fromLatin1("keep-together"), format.nonBreakableLines() ? QString::fromLatin1("true") : QString::fromLatin1("false")); @@ -610,9 +614,12 @@ void QTextOdfWriter::writeCharacterFormat(QXmlStreamWriter &writer, QTextCharFor } if (format.hasProperty(QTextFormat::ForegroundBrush)) { QBrush brush = format.foreground(); - // TODO writer.writeAttribute(foNS, QString::fromLatin1("color"), brush.color().name()); } + if (format.hasProperty(QTextFormat::BackgroundBrush)) { + QBrush brush = format.background(); + writer.writeAttribute(foNS, QString::fromLatin1("background-color"), brush.color().name()); + } writer.writeEndElement(); // style } diff --git a/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp b/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp index cfcbcfb..a61de99 100644 --- a/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp +++ b/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp @@ -175,6 +175,10 @@ void tst_QTextOdfWriter::testWriteStyle1_data() ""; QTest::newRow("bold+italic") << text1 << 25 << ""; + QString colorText = " Color Text "; + QTest::newRow("green/red") << colorText << 3 << + ""; + } void tst_QTextOdfWriter::testWriteStyle1() -- cgit v0.12 From cd63a4c50ecfca56bb7685fc40b084f830156c02 Mon Sep 17 00:00:00 2001 From: Michael Fairman Date: Wed, 30 Dec 2009 15:05:59 +0100 Subject: Fix configure's error message to report correct OpenGL qmake vars e.g. QMAKE_INCDIR_OPENGL_ES2 Merge-request: 2279 Reviewed-by: Tom Cooksey --- configure | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 22e6bd4..cf9f06a 100755 --- a/configure +++ b/configure @@ -5107,7 +5107,7 @@ if [ "$PLATFORM_X11" = "yes" ]; then if [ $? != "0" ]; then echo "The OpenGL ES 1.x Common Lite Profile functionality test failed!" echo " You might need to modify the include and library search paths by editing" - echo " QMAKE_INCDIR_OPENGL, QMAKE_LIBDIR_OPENGL and QMAKE_LIBS_OPENGL in" + echo " QMAKE_INCDIR_OPENGL_ES1CL, QMAKE_LIBDIR_OPENGL_ES1CL and QMAKE_LIBS_OPENGL_ES1CL in" echo " ${XQMAKESPEC}." exit 1 fi @@ -5117,7 +5117,7 @@ if [ "$PLATFORM_X11" = "yes" ]; then if [ $? != "0" ]; then echo "The OpenGL ES 1.x functionality test failed!" echo " You might need to modify the include and library search paths by editing" - echo " QMAKE_INCDIR_OPENGL, QMAKE_LIBDIR_OPENGL and QMAKE_LIBS_OPENGL in" + echo " QMAKE_INCDIR_OPENGL_ES1, QMAKE_LIBDIR_OPENGL_ES1 and QMAKE_LIBS_OPENGL_ES1 in" echo " ${XQMAKESPEC}." exit 1 fi @@ -5127,7 +5127,7 @@ if [ "$PLATFORM_X11" = "yes" ]; then if [ $? != "0" ]; then echo "The OpenGL ES 2.0 functionality test failed!" echo " You might need to modify the include and library search paths by editing" - echo " QMAKE_INCDIR_OPENGL, QMAKE_LIBDIR_OPENGL and QMAKE_LIBS_OPENGL in" + echo " QMAKE_INCDIR_OPENGL_ES2, QMAKE_LIBDIR_OPENGL_ES2 and QMAKE_LIBS_OPENGL_ES2 in" echo " ${XQMAKESPEC}." exit 1 fi -- cgit v0.12 From fbccab463a8bd77d66adb9f96a67037f73f0019d Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 4 Jan 2010 11:15:52 +1000 Subject: Reset the OpenVG scissor after a native painting call-out Task-number: QTBUG-7051 Reviewed-by: Daniel Pope --- src/openvg/qpaintengine_vg.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index 04fee08..c6ff627 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -200,6 +200,7 @@ public: QRegion scissorRegion; // Currently active scissor region. bool scissorActive; // True if scissor region is active. + bool scissorDirty; // True if scissor is dirty after native painting. QPaintEngine::DirtyFlags dirty; @@ -357,6 +358,7 @@ void QVGPaintEnginePrivate::init() rawVG = false; scissorActive = false; + scissorDirty = false; dirty = 0; @@ -2083,6 +2085,7 @@ void QVGPaintEngine::updateScissor() // so there is no point doing any scissoring. vgSeti(VG_SCISSORING, VG_FALSE); d->scissorActive = false; + d->scissorDirty = false; return; } } else @@ -2100,6 +2103,7 @@ void QVGPaintEngine::updateScissor() // so there is no point doing any scissoring. vgSeti(VG_SCISSORING, VG_FALSE); d->scissorActive = false; + d->scissorDirty = false; return; } } else @@ -2109,11 +2113,12 @@ void QVGPaintEngine::updateScissor() if (region.isEmpty()) { vgSeti(VG_SCISSORING, VG_FALSE); d->scissorActive = false; + d->scissorDirty = false; return; } } - if (d->scissorActive && region == d->scissorRegion) + if (d->scissorActive && region == d->scissorRegion && !d->scissorDirty) return; QVector rects = region.rects(); @@ -2131,6 +2136,7 @@ void QVGPaintEngine::updateScissor() vgSetiv(VG_SCISSOR_RECTS, count * 4, params.data()); vgSeti(VG_SCISSORING, VG_TRUE); + d->scissorDirty = false; d->scissorActive = true; d->scissorRegion = region; } @@ -3333,6 +3339,7 @@ void QVGPaintEngine::endNativePainting() d->brushType = (VGPaintType)0; d->clearColor = QColor(); d->fillPaint = d->brushPaint; + d->scissorDirty = true; restoreState(QPaintEngine::AllDirty); d->dirty = dirty; d->rawVG = false; @@ -3666,15 +3673,17 @@ void QVGCompositionHelper::setScissor(const QRegion& region) vgSetiv(VG_SCISSOR_RECTS, count * 4, params.data()); vgSeti(VG_SCISSORING, VG_TRUE); + d->scissorDirty = false; d->scissorActive = true; d->scissorRegion = region; } void QVGCompositionHelper::clearScissor() { - if (d->scissorActive) { + if (d->scissorActive || d->scissorDirty) { vgSeti(VG_SCISSORING, VG_FALSE); d->scissorActive = false; + d->scissorDirty = false; } } -- cgit v0.12 From b0e7ef2aa62a123b51920b8f0a08af07a9cd9d09 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 4 Jan 2010 11:32:37 +1000 Subject: Avoid deep QImage copies in the OpenVG paint engine Task-number: QTBUG-7015 Reviewed-by: Daniel Pope --- src/openvg/qpaintengine_vg.cpp | 19 +++++++++++-------- src/openvg/qpixmapdata_vg.cpp | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index c6ff627..117c910 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -986,6 +986,9 @@ static QImage colorizeBitmap(const QImage &image, const QColor &color) return dest; } +// defined in qpixmapdata_vg.cpp. +const uchar *qt_vg_imageBits(const QImage& image); + static VGImage toVGImage (const QImage & image, Qt::ImageConversionFlags flags = Qt::AutoColor) { @@ -1019,7 +1022,7 @@ static VGImage toVGImage break; } - const uchar *pixels = img.bits(); + const uchar *pixels = qt_vg_imageBits(img); VGImage vgImg = QVGImagePool::instance()->createPermanentImage (format, img.width(), img.height(), VG_IMAGE_QUALITY_FASTER); @@ -1063,7 +1066,7 @@ static VGImage toVGImageSubRect break; } - const uchar *pixels = img.bits() + bpp * sr.x() + + const uchar *pixels = qt_vg_imageBits(img) + bpp * sr.x() + img.bytesPerLine() * sr.y(); VGImage vgImg = QVGImagePool::instance()->createPermanentImage @@ -1085,7 +1088,7 @@ static VGImage toVGImageWithOpacity(const QImage & image, qreal opacity) painter.drawImage(0, 0, image); painter.end(); - const uchar *pixels = img.bits(); + const uchar *pixels = qt_vg_imageBits(img); VGImage vgImg = QVGImagePool::instance()->createPermanentImage (VG_sARGB_8888_PRE, img.width(), img.height(), VG_IMAGE_QUALITY_FASTER); @@ -1107,7 +1110,7 @@ static VGImage toVGImageWithOpacitySubRect painter.drawImage(QPoint(0, 0), image, sr); painter.end(); - const uchar *pixels = img.bits(); + const uchar *pixels = qt_vg_imageBits(img); VGImage vgImg = QVGImagePool::instance()->createPermanentImage (VG_sARGB_8888_PRE, img.width(), img.height(), VG_IMAGE_QUALITY_FASTER); @@ -3172,15 +3175,15 @@ void QVGFontGlyphCache::cacheGlyphs if (!scaledImage.isNull()) { // Not a space character if (scaledImage.format() == QImage::Format_Indexed8) { vgImage = vgCreateImage(VG_A_8, scaledImage.width(), scaledImage.height(), VG_IMAGE_QUALITY_FASTER); - vgImageSubData(vgImage, scaledImage.bits(), scaledImage.bytesPerLine(), VG_A_8, 0, 0, scaledImage.width(), scaledImage.height()); + vgImageSubData(vgImage, qt_vg_imageBits(scaledImage), scaledImage.bytesPerLine(), VG_A_8, 0, 0, scaledImage.width(), scaledImage.height()); } else if (scaledImage.format() == QImage::Format_Mono) { QImage img = scaledImage.convertToFormat(QImage::Format_Indexed8); vgImage = vgCreateImage(VG_A_8, img.width(), img.height(), VG_IMAGE_QUALITY_FASTER); - vgImageSubData(vgImage, img.bits(), img.bytesPerLine(), VG_A_8, 0, 0, img.width(), img.height()); + vgImageSubData(vgImage, qt_vg_imageBits(img), img.bytesPerLine(), VG_A_8, 0, 0, img.width(), img.height()); } else { QImage img = scaledImage.convertToFormat(QImage::Format_ARGB32_Premultiplied); vgImage = vgCreateImage(VG_sARGB_8888_PRE, img.width(), img.height(), VG_IMAGE_QUALITY_FASTER); - vgImageSubData(vgImage, img.bits(), img.bytesPerLine(), VG_sARGB_8888_PRE, 0, 0, img.width(), img.height()); + vgImageSubData(vgImage, qt_vg_imageBits(img), img.bytesPerLine(), VG_sARGB_8888_PRE, 0, 0, img.width(), img.height()); } } origin[0] = -metrics.x.toReal() + 0.5f; @@ -3647,7 +3650,7 @@ void QVGCompositionHelper::drawCursorPixmap if (vgImage == VG_INVALID_HANDLE) return; vgImageSubData - (vgImage, img.bits() + img.bytesPerLine() * (img.height() - 1), + (vgImage, qt_vg_imageBits(img) + img.bytesPerLine() * (img.height() - 1), -(img.bytesPerLine()), VG_sARGB_8888_PRE, 0, 0, img.width(), img.height()); diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp index 358ec4d..7de2212 100644 --- a/src/openvg/qpixmapdata_vg.cpp +++ b/src/openvg/qpixmapdata_vg.cpp @@ -232,7 +232,7 @@ QPaintEngine* QVGPixmapData::paintEngine() const // This function works around QImage::bits() making a deep copy if the // QImage is not const. We force it to be const and then get the bits. // XXX: Should add a QImage::constBits() in the future to replace this. -static inline const uchar *qt_vg_imageBits(const QImage& image) +const uchar *qt_vg_imageBits(const QImage& image) { return image.bits(); } -- cgit v0.12 From eb94abb952114e826e02ba4562d9048e77f46644 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 30 Dec 2009 16:16:59 -0800 Subject: Set serial number in QX11PixmapData::transformed QX11PixmapData::transformed initializes a new QX11PixmapData object but doesn't set its serial number. Reviewed-by: Donald Carr --- src/gui/image/qpixmap_x11.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/image/qpixmap_x11.cpp b/src/gui/image/qpixmap_x11.cpp index 7008fbd..f3947ff 100644 --- a/src/gui/image/qpixmap_x11.cpp +++ b/src/gui/image/qpixmap_x11.cpp @@ -1932,6 +1932,8 @@ QPixmap QX11PixmapData::transformed(const QTransform &transform, x11Data->hd = (Qt::HANDLE)XCreatePixmap(X11->display, RootWindow(X11->display, xinfo.screen()), w, h, d); + x11Data->setSerialNumber(++qt_pixmap_serial); + #ifndef QT_NO_XRENDER if (X11->use_xrender) { XRenderPictFormat *format = x11Data->d == 32 -- cgit v0.12 From d1846e00155a1555baf9927a66e7f5de9fc08940 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Sat, 2 Jan 2010 17:05:45 +0100 Subject: New lance test for checking aliased vs antialiased rendering This test renders various primitives with anti-aliasing both on and off. It then repeats the render at several non-integer offsets. Note: The reference image was generated with the raster engine, which seems to have off-by-one errors on fills when rendering aliased (It seems to ceil the coords rather than round them). Reviewed-By: Trustme --- tests/arthur/data/qps/aliasing.qps | 156 +++++++++++++++++++++++++++++++++ tests/arthur/data/qps/aliasing_qps.png | Bin 0 -> 30531 bytes 2 files changed, 156 insertions(+) create mode 100644 tests/arthur/data/qps/aliasing.qps create mode 100644 tests/arthur/data/qps/aliasing_qps.png diff --git a/tests/arthur/data/qps/aliasing.qps b/tests/arthur/data/qps/aliasing.qps new file mode 100644 index 0000000..59878f9 --- /dev/null +++ b/tests/arthur/data/qps/aliasing.qps @@ -0,0 +1,156 @@ + +path_moveTo convexPath 25 0 +path_lineTo convexPath 50 50 +path_lineTo convexPath 25 25 +path_lineTo convexPath 0 50 +path_closeSubpath convexPath + +pixmap_load border.png pixmap + +setRenderHint LineAntialiasing false +translate 10 10 + +begin_block drawing + setPen black 1 + setBrush 7f7fff + drawPath convexPath + + setFont "monospace" 8 + setPen black + drawText 0 68 "QwErTy@" + + + setPen black 1 + setBrush 7f7fff + drawRect 0 80 10 5 + + setPen black 1 + setBrush noBrush + drawRect 20 80 10 5 + + setPen noPen + setBrush 7f7fff + drawRect 40 80 10 5 + + + setPen black 2 + setBrush 7f7fff + drawRect 0 90 10 5 + + setPen black 2 + setBrush noBrush + drawRect 20 90 10 5 + + setPen noPen + setBrush 7f7fff + drawRect 40 90 10 5 + + + setPen black 3 + setBrush 7f7fff + drawRect 0 100 10 5 + + setPen black 3 + setBrush noBrush + drawRect 20 100 10 5 + + setPen noPen + setBrush 7f7fff + drawRect 40 100 10 5 + + + setPen black 1 + setBrush noBrush + drawLine 10 110 20 120 + drawLine 30 120 40 110 + + setPen black 2 + setBrush noBrush + drawLine 10 120 20 130 + drawLine 30 130 40 120 + + setPen black 3 + setBrush noBrush + drawLine 10 130 20 140 + drawLine 30 140 40 130 + + drawPixmap pixmap 0 150 + + setRenderHint SmoothPixmapTransform false + drawPixmap pixmap 20 150 15 15 0 0 10 10 + +end_block + +translate 0 180 +setRenderHint LineAntialiasing true +repeat_block drawing +drawText 15 185 "0.0" + +resetMatrix +translate 70.2 10.2 +setRenderHint LineAntialiasing false +repeat_block drawing +translate 0 180 +setRenderHint LineAntialiasing true +repeat_block drawing +translate -0.2 -0.2 +drawText 15 185 "0.2" + + +resetMatrix +translate 130.4 10.4 +setRenderHint LineAntialiasing false +repeat_block drawing +translate 0 180 +setRenderHint LineAntialiasing true +repeat_block drawing +translate -0.4 -0.4 +drawText 15 185 "0.4" + + +resetMatrix +translate 190.5 10.5 +setRenderHint LineAntialiasing false +repeat_block drawing +translate 0 180 +setRenderHint LineAntialiasing true +repeat_block drawing +translate -0.5 -0.5 +drawText 15 185 "0.5" + + +resetMatrix +translate 250.6 10.6 +setRenderHint LineAntialiasing false +repeat_block drawing +translate 0 180 +setRenderHint LineAntialiasing true +repeat_block drawing +translate -0.6 -0.6 +drawText 15 185 "0.6" + + +resetMatrix +translate 310.8 10.8 +setRenderHint LineAntialiasing false +repeat_block drawing +translate 0 180 +setRenderHint LineAntialiasing true +repeat_block drawing +translate -0.8 -0.8 +drawText 15 185 "0.8" + + +resetMatrix +translate 371 11 +setRenderHint LineAntialiasing false +repeat_block drawing +translate 0 180 +setRenderHint LineAntialiasing true +repeat_block drawing +drawText 15 185 "1.0" + + +resetMatrix +drawText 430 95 "Aliased" +drawText 430 275 "Anti-Aliased" \ No newline at end of file diff --git a/tests/arthur/data/qps/aliasing_qps.png b/tests/arthur/data/qps/aliasing_qps.png new file mode 100644 index 0000000..183129b Binary files /dev/null and b/tests/arthur/data/qps/aliasing_qps.png differ -- cgit v0.12 From e3e0a7acd42101a9abeb1dab53d4e03940bcebaa Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 30 Dec 2009 16:24:45 -0800 Subject: Set serial number in QDFBPixmapData::transformed QDirectFBPixmapData::transformed initializes a new QDirectFBPixmapData object but doesn't set its serial number. Reviewed-by: Donald Carr --- src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index b15888b..e78966c 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -470,6 +470,7 @@ QPixmap QDirectFBPixmapData::transformed(const QTransform &transform, return QPixmap(); QDirectFBPixmapData *data = new QDirectFBPixmapData(screen, QPixmapData::PixmapType); + data->setSerialNumber(++global_ser_no); DFBSurfaceBlittingFlags flags = DSBLIT_NOFX; data->alpha = alpha; if (alpha) { -- cgit v0.12 From cdebdfc7964df6b19f8bd520335a8645c1a125e6 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Sun, 3 Jan 2010 12:56:16 -0800 Subject: Make stretchblit an opt-out option in DirectFB Certain boards are not support StretchBlit very well. This patch enables them to define QT_NO_DIRECTFB_STRETCHBLIT to fall back to the raster engine for stretchblits. Reviewed-by: Donald Carr --- src/gui/embedded/directfb.pri | 1 + .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 36 +++++++++++++++------- src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 3 ++ 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/gui/embedded/directfb.pri b/src/gui/embedded/directfb.pri index 84253b5..bd1d947 100644 --- a/src/gui/embedded/directfb.pri +++ b/src/gui/embedded/directfb.pri @@ -14,6 +14,7 @@ #DEFINES += QT_NO_DIRECTFB_KEYBOARD #DEFINES += QT_DIRECTFB_TIMING #DEFINES += QT_NO_DIRECTFB_OPAQUE_DETECTION +#DEFINES += QT_NO_DIRECTFB_STRETCHBLIT #DIRECTFB_DRAWINGOPERATIONS=DRAW_RECTS|DRAW_LINES|DRAW_IMAGE|DRAW_PIXMAP|DRAW_TILED_PIXMAP|STROKE_PATH|DRAW_PATH|DRAW_POINTS|DRAW_ELLIPSE|DRAW_POLYGON|DRAW_TEXT|FILL_PATH|FILL_RECT|DRAW_COLORSPANS|DRAW_ROUNDED_RECT #DEFINES += \"QT_DIRECTFB_WARN_ON_RASTERFALLBACKS=$$DIRECTFB_DRAWINGOPERATIONS\" #DEFINES += \"QT_DIRECTFB_DISABLE_RASTERFALLBACKS=$$DIRECTFB_DRAWINGOPERATIONS\" diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index c86af73..47b8786 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -103,6 +103,8 @@ public: void drawTiledPixmap(const QRectF &dest, const QPixmap &pixmap, const QPointF &pos); void blit(const QRectF &dest, IDirectFBSurface *surface, const QRectF &src); + inline bool supportsStretchBlit() const; + inline void updateClip(); virtual void systemStateChanged(); @@ -526,11 +528,12 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image, #if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) - || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip + || (d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) + || (!d->supportsStretchBlit() && state()->matrix.mapRect(r).size() != sr.size()) #ifndef QT_DIRECTFB_IMAGECACHE - || QDirectFBScreen::getSurfacePixelFormat(image.format()) == DSPF_UNKNOWN + || (QDirectFBScreen::getSurfacePixelFormat(image.format()) == DSPF_UNKNOWN) #elif defined QT_NO_DIRECTFB_PREALLOCATED - || QDirectFBPaintEnginePrivate::cacheCost(image) > imageCache.maxCost() + || (QDirectFBPaintEnginePrivate::cacheCost(image) > imageCache.maxCost()) #endif ) #endif @@ -573,10 +576,9 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); QDirectFBPixmapData *dfbData = static_cast(data); if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) - || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) - || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip - || (state()->renderHints & QPainter::SmoothPixmapTransform - && state()->matrix.mapRect(r).size() != sr.size())) { + || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) + || (d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) + || (!d->supportsStretchBlit() && state()->matrix.mapRect(r).size() != sr.size())) { RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); const QImage *img = dfbData->buffer(); d->lock(); @@ -606,8 +608,8 @@ void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r, QRasterPaintEngine::drawTiledPixmap(r, pixmap, offset); } else if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) - || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip - || (state()->renderHints & QPainter::SmoothPixmapTransform && state()->matrix.isScaling())) { + || (d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) + || (!d->supportsStretchBlit() && state()->matrix.isScaling())) { RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), offset); QPixmapData *pixmapData = pixmap.pixmapData(); Q_ASSERT(pixmapData->classId() == QPixmapData::DirectFBClass); @@ -732,7 +734,7 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) case Qt::TexturePattern: { if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) - || (state()->renderHints & QPainter::SmoothPixmapTransform && state()->matrix.isScaling())) { + || (!d->supportsStretchBlit() && state()->matrix.isScaling())) { break; } @@ -757,7 +759,7 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color) return; Q_D(QDirectFBPaintEngine); if ((d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported) - || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip + || (d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) || !d->testCompositionMode(0, 0, &color)) { RASTERFALLBACK(FILL_RECT, rect, color, VOID_ARG()); d->lock(); @@ -1049,6 +1051,7 @@ void QDirectFBPaintEnginePrivate::blit(const QRectF &dest, IDirectFBSurface *s, if (dr.size() == sr.size()) { result = surface->Blit(surface, s, &sRect, dr.x(), dr.y()); } else { + Q_ASSERT(supportsStretchBlit()); const DFBRectangle dRect = { dr.x(), dr.y(), dr.width(), dr.height() }; result = surface->StretchBlit(surface, s, &sRect, &dRect); } @@ -1096,6 +1099,7 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPix const QSize pixmapSize = dfbData->size(); IDirectFBSurface *sourceSurface = dfbData->directFBSurface(); if (transform.isScaling()) { + Q_ASSERT(supportsStretchBlit()); Q_ASSERT(qMin(transform.m11(), transform.m22()) >= 0); offset.rx() *= transform.m11(); offset.ry() *= transform.m22(); @@ -1184,6 +1188,16 @@ void QDirectFBPaintEnginePrivate::updateClip() } } +bool QDirectFBPaintEnginePrivate::supportsStretchBlit() const +{ +#ifdef QT_DIRECTFB_STRETCHBLIT + return !(q->state()->renderHints & QPainter::SmoothPixmapTransform); +#else + return false; +#endif +} + + void QDirectFBPaintEnginePrivate::systemStateChanged() { QRasterPaintEnginePrivate::systemStateChanged(); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index 6330582..61d9cf1 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -69,6 +69,9 @@ QT_MODULE(Gui) #if !defined QT_NO_DIRECTFB_IMAGEPROVIDER && !defined QT_DIRECTFB_IMAGEPROVIDER #define QT_DIRECTFB_IMAGEPROVIDER #endif +#if !defined QT_NO_DIRECTFB_STRETCHBLIT && !defined QT_DIRECTFB_STRETCHBLIT +#define QT_DIRECTFB_STRETCHBLIT +#endif #if !defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE && !defined QT_NO_DIRECTFB_IMAGEPROVIDER_KEEPALIVE #define QT_NO_DIRECTFB_IMAGEPROVIDER_KEEPALIVE #endif -- cgit v0.12 From 1a1f781e7f6be2e62be91b082ee798b8854ad920 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 14 Dec 2009 14:31:24 +0100 Subject: fixed typo in qpainter docs --- src/gui/painting/qpainter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 8ed126f..fd67f96 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -1329,7 +1329,7 @@ void QPainterPrivate::updateState(QPainterState *newState) of composition modes, brushes, clipping, transformation, etc, is close to an impossible task because of the number of permutations. As a compromise we have selected a subset of the - QPainter API and backends, were performance is guaranteed to be as + QPainter API and backends, where performance is guaranteed to be as good as we can sensibly get it for the given combination of hardware and software. -- cgit v0.12 From 1e7922262c29ba29a70226cf8894645f46df3ca2 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Sun, 3 Jan 2010 15:35:53 +0100 Subject: Introduce new "snapToPixelGrid" flag to GL2 engine for drawText When we're rendering text, the glyphs need to be aligned to the pixel grid otherwise we get strange artifacts. Normally text is drawn at integer coordinates, however it is still possible to have a transform which translates by a non-integer offset. This patch adds a flag to the engine which can be used to snap any translate to the pixel grid. Task-number: QTBUG-7094 Reviewed-By: Kim --- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 47 +++++++++++++++++++--- .../gl2paintengineex/qpaintengineex_opengl2_p.h | 2 + 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 0f8e945..a41d439 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -589,19 +589,28 @@ void QGL2PaintEngineExPrivate::updateMatrix() const GLfloat wfactor = 2.0f / width; const GLfloat hfactor = -2.0f / height; + GLfloat dx = transform.dx(); + GLfloat dy = transform.dy(); + + // Non-integer translates can have strange effects for some rendering operations such as + // anti-aliased text rendering. In such cases, we snap the translate to the pixel grid. + if (snapToPixelGrid && transform.type() == QTransform::TxTranslate) { + // 0.50 needs to rounded down to 0.0 for consistency with raster engine: + dx = ceilf(dx - 0.5f); + dy = ceilf(dy - 0.5f); + } if (addOffset) { - pmvMatrix[2][0] = (wfactor * (transform.dx() + 0.49f)) - transform.m33(); - pmvMatrix[2][1] = (hfactor * (transform.dy() + 0.49f)) + transform.m33(); - } else { - pmvMatrix[2][0] = (wfactor * transform.dx()) - transform.m33(); - pmvMatrix[2][1] = (hfactor * transform.dy()) + transform.m33(); + dx += 0.49f; + dy += 0.49f; } pmvMatrix[0][0] = (wfactor * transform.m11()) - transform.m13(); pmvMatrix[1][0] = (wfactor * transform.m21()) - transform.m23(); + pmvMatrix[2][0] = (wfactor * dx) - transform.m33(); pmvMatrix[0][1] = (hfactor * transform.m12()) + transform.m13(); pmvMatrix[1][1] = (hfactor * transform.m22()) + transform.m23(); + pmvMatrix[2][1] = (hfactor * dy) + transform.m33(); pmvMatrix[0][2] = transform.m13(); pmvMatrix[1][2] = transform.m23(); pmvMatrix[2][2] = transform.m33(); @@ -699,6 +708,11 @@ void QGL2PaintEngineExPrivate::drawTexture(const QGLRect& dest, const QGLRect& s matrixDirty = true; } + if (snapToPixelGrid) { + snapToPixelGrid = false; + matrixDirty = true; + } + if (prepareForDraw(opaque)) shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::ImageTexture), QT_IMAGE_TEXTURE_UNIT); @@ -856,6 +870,11 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) matrixDirty = true; } + if (snapToPixelGrid) { + snapToPixelGrid = false; + matrixDirty = true; + } + // Might need to call updateMatrix to re-calculate inverseScale if (matrixDirty) updateMatrix(); @@ -1249,6 +1268,11 @@ void QGL2PaintEngineExPrivate::stroke(const QVectorPath &path, const QPen &pen) matrixDirty = true; } + if (snapToPixelGrid) { + snapToPixelGrid = false; + matrixDirty = true; + } + const Qt::PenStyle penStyle = qpen_style(pen); const QBrush &penBrush = qpen_brush(pen); const bool opaque = penBrush.isOpaque() && s->opacity > 0.99; @@ -1519,6 +1543,10 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, QFontEngineGly addOffset = false; matrixDirty = true; } + if (!snapToPixelGrid) { + snapToPixelGrid = true; + matrixDirty = true; + } QBrush pensBrush = q->state()->pen.brush(); setBrush(pensBrush); @@ -1637,6 +1665,11 @@ void QGL2PaintEngineExPrivate::drawPixmaps(const QDrawPixmaps::Data *drawingData matrixDirty = true; } + if (snapToPixelGrid) { + snapToPixelGrid = false; + matrixDirty = true; + } + bool allOpaque = true; for (int i = 0; i < dataCount; ++i) { @@ -1918,6 +1951,10 @@ void QGL2PaintEngineExPrivate::writeClip(const QVectorPath &path, uint value) addOffset = false; matrixDirty = true; } + if (snapToPixelGrid) { + snapToPixelGrid = false; + matrixDirty = true; + } if (matrixDirty) updateMatrix(); diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 9a5c447..7d5cb52 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -167,6 +167,7 @@ public: width(0), height(0), ctx(0), useSystemClip(true), + snapToPixelGrid(false), addOffset(false), inverseScale(1) { } @@ -260,6 +261,7 @@ public: GLfloat staticVertexCoordinateArray[8]; GLfloat staticTextureCoordinateArray[8]; + bool snapToPixelGrid; bool addOffset; // When enabled, adds a 0.49,0.49 offset to matrix in updateMatrix GLfloat pmvMatrix[3][3]; GLfloat inverseScale; -- cgit v0.12 From 8f9b2a042fedda687f4ae87e3be09de20bce6354 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 4 Jan 2010 12:03:54 +0100 Subject: Mac: qcolordialog autotest fails. I removed a line as an optimization a while ago. Luckily, the autotest cought a failure doing so. So we put the line back in. Reviewed-by: Prasanth --- src/gui/dialogs/qcolordialog_mac.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/dialogs/qcolordialog_mac.mm b/src/gui/dialogs/qcolordialog_mac.mm index 5753954..a350be1 100644 --- a/src/gui/dialogs/qcolordialog_mac.mm +++ b/src/gui/dialogs/qcolordialog_mac.mm @@ -347,6 +347,7 @@ QT_USE_NAMESPACE } } + QAbstractEventDispatcher::instance()->interrupt(); if (mResultCode == NSCancelButton) mPriv->colorDialog()->reject(); else -- cgit v0.12 From f46115cb9ea10ee9abdbebff71cf8d6694f9fde9 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 4 Jan 2010 12:26:16 +0100 Subject: do not accumulate messages Task-number: QTBUG-6588 --- tools/linguist/lrelease/main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/linguist/lrelease/main.cpp b/tools/linguist/lrelease/main.cpp index b8e8eb2..2ab4a5e 100644 --- a/tools/linguist/lrelease/main.cpp +++ b/tools/linguist/lrelease/main.cpp @@ -111,6 +111,7 @@ static bool loadTsFile(Translator &tor, const QString &tsFileName, bool /* verbo if (!cd.errors().isEmpty()) printOut(cd.error()); } + cd.clearErrors(); return ok; } @@ -141,11 +142,11 @@ static bool releaseTranslator(Translator &tor, const QString &qmFileName, if (!ok) { qWarning("lrelease error: cannot save '%s': %s\n", qPrintable(qmFileName), qPrintable(cd.error())); - return false; } else if (!cd.errors().isEmpty()) { printOut(cd.error()); } - return true; + cd.clearErrors(); + return ok; } static bool releaseTsFile(const QString& tsFileName, -- cgit v0.12 From 5b0945acef6895d4147b81dcda7cdce89c3a981a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 4 Jan 2010 12:39:25 +0100 Subject: Designer: Selection handles disappear when using style sheet on form. ... that has a white background color. The selection handles inherited the form's stylesheet. Fix by parenting them on the (internal) form container widget. Reviewed-by: Jarek Kobus Task-number: QTBUG-6757 --- tools/designer/src/components/formeditor/widgetselection.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/designer/src/components/formeditor/widgetselection.cpp b/tools/designer/src/components/formeditor/widgetselection.cpp index 484e3a9..35f1509 100644 --- a/tools/designer/src/components/formeditor/widgetselection.cpp +++ b/tools/designer/src/components/formeditor/widgetselection.cpp @@ -86,7 +86,7 @@ static inline Layout *managedLayoutOf(const QDesignerFormEditorInterface *core, // ----------- WidgetHandle WidgetHandle::WidgetHandle(FormWindow *parent, WidgetHandle::Type t, WidgetSelection *s) : - InvisibleWidget(parent->mainContainer()), + InvisibleWidget(parent->formContainer()), m_widget(0), m_type(t), m_formWindow( parent), @@ -638,7 +638,7 @@ void WidgetSelection::updateGeometry() return; QPoint p = m_widget->parentWidget()->mapToGlobal(m_widget->pos()); - p = m_formWindow->mapFromGlobal(p); + p = m_formWindow->formContainer()->mapFromGlobal(p); const QRect r(p, m_widget->size()); const int w = 6; -- cgit v0.12 From 0e4c54809a8195a199d85b143e042b0f5e53fb4c Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 4 Jan 2010 12:46:14 +0100 Subject: doc: Removed a const from a declaration in the example. Task-number: QTBUG-7092 --- src/corelib/statemachine/qsignaltransition.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/statemachine/qsignaltransition.cpp b/src/corelib/statemachine/qsignaltransition.cpp index f55f634..d35c12e 100644 --- a/src/corelib/statemachine/qsignaltransition.cpp +++ b/src/corelib/statemachine/qsignaltransition.cpp @@ -76,7 +76,7 @@ QT_BEGIN_NAMESPACE CheckedTransition(QCheckBox *check) : QSignalTransition(check, SIGNAL(stateChanged(int))) {} protected: - bool eventTest(QEvent *e) const { + bool eventTest(QEvent *e) { if (!QSignalTransition::eventTest(e)) return false; QStateMachine::SignalEvent *se = static_cast(e); -- cgit v0.12 From 4cfb341b0cc38f32fb6fba134bfeb96197337867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 21 Dec 2009 14:22:27 +0100 Subject: Slight performance improvement in comp_func_SourceOver. We should check for the fully opaque and fully transparent special cases, like we do in the dedicated image blend functions. Reveiewed-by: Gunnar Sletta --- src/gui/painting/qdrawhelper.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 84cf5cc..9bb4486 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -1364,7 +1364,10 @@ static void QT_FASTCALL comp_func_SourceOver(uint *dest, const uint *src, int le for (int i = 0; i < length; ++i) { PRELOAD_COND2(dest, src) uint s = src[i]; - dest[i] = s + BYTE_MUL(dest[i], qAlpha(~s)); + if (s >= 0xff000000) + dest[i] = s; + else if (s != 0) + dest[i] = s + BYTE_MUL(dest[i], qAlpha(~s)); } } else { for (int i = 0; i < length; ++i) { -- cgit v0.12 From 00db09c55f60f160e625c3488784b0965ab636b4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 4 Jan 2010 14:29:34 +0100 Subject: Designer: Enable seconds editing for Q[Date]TimeEdit's properties. on UNIX, for which QLocale's ShortFormat does not include seconds. Move format creation into browser utilities and use consistently for display and editing. Reviewed-by: Jarek Kobus Task-number: QTBUG-6965 --- tools/shared/qtpropertybrowser/qteditorfactory.cpp | 3 ++ .../qtpropertybrowser/qtpropertybrowserutils.cpp | 21 ++++++++++ .../qtpropertybrowser/qtpropertybrowserutils_p.h | 3 ++ .../shared/qtpropertybrowser/qtpropertymanager.cpp | 45 +++++++++++++--------- 4 files changed, 53 insertions(+), 19 deletions(-) diff --git a/tools/shared/qtpropertybrowser/qteditorfactory.cpp b/tools/shared/qtpropertybrowser/qteditorfactory.cpp index 17c5be8..ed74439 100644 --- a/tools/shared/qtpropertybrowser/qteditorfactory.cpp +++ b/tools/shared/qtpropertybrowser/qteditorfactory.cpp @@ -1158,6 +1158,7 @@ QWidget *QtDateEditFactory::createEditor(QtDatePropertyManager *manager, QtPrope QWidget *parent) { QDateEdit *editor = d_ptr->createEditor(property, parent); + editor->setDisplayFormat(QtPropertyBrowserUtils::dateFormat()); editor->setCalendarPopup(true); editor->setDateRange(manager->minimum(property), manager->maximum(property)); editor->setDate(manager->value(property)); @@ -1272,6 +1273,7 @@ QWidget *QtTimeEditFactory::createEditor(QtTimePropertyManager *manager, QtPrope QWidget *parent) { QTimeEdit *editor = d_ptr->createEditor(property, parent); + editor->setDisplayFormat(QtPropertyBrowserUtils::timeFormat()); editor->setTime(manager->value(property)); connect(editor, SIGNAL(timeChanged(QTime)), @@ -1385,6 +1387,7 @@ QWidget *QtDateTimeEditFactory::createEditor(QtDateTimePropertyManager *manager, QtProperty *property, QWidget *parent) { QDateTimeEdit *editor = d_ptr->createEditor(property, parent); + editor->setDisplayFormat(QtPropertyBrowserUtils::dateTimeFormat()); editor->setDateTime(manager->value(property)); connect(editor, SIGNAL(dateTimeChanged(QDateTime)), diff --git a/tools/shared/qtpropertybrowser/qtpropertybrowserutils.cpp b/tools/shared/qtpropertybrowser/qtpropertybrowserutils.cpp index 9e0421f..63e4a63 100644 --- a/tools/shared/qtpropertybrowser/qtpropertybrowserutils.cpp +++ b/tools/shared/qtpropertybrowser/qtpropertybrowserutils.cpp @@ -47,6 +47,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -208,6 +209,26 @@ QString QtPropertyBrowserUtils::fontValueText(const QFont &f) .arg(f.pointSize()); } +QString QtPropertyBrowserUtils::dateFormat() +{ + QLocale loc; + return loc.dateFormat(QLocale::ShortFormat); +} + +QString QtPropertyBrowserUtils::timeFormat() +{ + QLocale loc; + // ShortFormat is missing seconds on UNIX. + return loc.timeFormat(QLocale::LongFormat); +} + +QString QtPropertyBrowserUtils::dateTimeFormat() +{ + QString format = dateFormat(); + format += QLatin1Char(' '); + format += timeFormat(); + return format; +} QtBoolEdit::QtBoolEdit(QWidget *parent) : QWidget(parent), diff --git a/tools/shared/qtpropertybrowser/qtpropertybrowserutils_p.h b/tools/shared/qtpropertybrowser/qtpropertybrowserutils_p.h index 09d29ae..358f9f4 100644 --- a/tools/shared/qtpropertybrowser/qtpropertybrowserutils_p.h +++ b/tools/shared/qtpropertybrowser/qtpropertybrowserutils_p.h @@ -94,6 +94,9 @@ public: static QPixmap fontValuePixmap(const QFont &f); static QIcon fontValueIcon(const QFont &f); static QString fontValueText(const QFont &f); + static QString dateFormat(); + static QString timeFormat(); + static QString dateTimeFormat(); }; class QtBoolEdit : public QWidget { diff --git a/tools/shared/qtpropertybrowser/qtpropertymanager.cpp b/tools/shared/qtpropertybrowser/qtpropertymanager.cpp index a26dcda..fbad0ca 100644 --- a/tools/shared/qtpropertybrowser/qtpropertymanager.cpp +++ b/tools/shared/qtpropertybrowser/qtpropertymanager.cpp @@ -1553,6 +1553,7 @@ class QtDatePropertyManagerPrivate QtDatePropertyManager *q_ptr; Q_DECLARE_PUBLIC(QtDatePropertyManager) public: + explicit QtDatePropertyManagerPrivate(QtDatePropertyManager *q); struct Data { @@ -1573,6 +1574,12 @@ public: QMap m_values; }; +QtDatePropertyManagerPrivate::QtDatePropertyManagerPrivate(QtDatePropertyManager *q) : + q_ptr(q), + m_format(QtPropertyBrowserUtils::dateFormat()) +{ +} + /*! \class QtDatePropertyManager \internal @@ -1622,12 +1629,8 @@ public: Creates a manager with the given \a parent. */ QtDatePropertyManager::QtDatePropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent), d_ptr(new QtDatePropertyManagerPrivate) + : QtAbstractPropertyManager(parent), d_ptr(new QtDatePropertyManagerPrivate(this)) { - d_ptr->q_ptr = this; - - QLocale loc; - d_ptr->m_format = loc.dateFormat(QLocale::ShortFormat); } /*! @@ -1786,13 +1789,20 @@ class QtTimePropertyManagerPrivate QtTimePropertyManager *q_ptr; Q_DECLARE_PUBLIC(QtTimePropertyManager) public: + explicit QtTimePropertyManagerPrivate(QtTimePropertyManager *q); - QString m_format; + const QString m_format; typedef QMap PropertyValueMap; PropertyValueMap m_values; }; +QtTimePropertyManagerPrivate::QtTimePropertyManagerPrivate(QtTimePropertyManager *q) : + q_ptr(q), + m_format(QtPropertyBrowserUtils::timeFormat()) +{ +} + /*! \class QtTimePropertyManager \internal @@ -1825,12 +1835,8 @@ public: Creates a manager with the given \a parent. */ QtTimePropertyManager::QtTimePropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent), d_ptr(new QtTimePropertyManagerPrivate) + : QtAbstractPropertyManager(parent), d_ptr(new QtTimePropertyManagerPrivate(this)) { - d_ptr->q_ptr = this; - - QLocale loc; - d_ptr->m_format = loc.timeFormat(QLocale::ShortFormat); } /*! @@ -1903,13 +1909,20 @@ class QtDateTimePropertyManagerPrivate QtDateTimePropertyManager *q_ptr; Q_DECLARE_PUBLIC(QtDateTimePropertyManager) public: + explicit QtDateTimePropertyManagerPrivate(QtDateTimePropertyManager *q); - QString m_format; + const QString m_format; typedef QMap PropertyValueMap; PropertyValueMap m_values; }; +QtDateTimePropertyManagerPrivate::QtDateTimePropertyManagerPrivate(QtDateTimePropertyManager *q) : + q_ptr(q), + m_format(QtPropertyBrowserUtils::dateTimeFormat()) +{ +} + /*! \class QtDateTimePropertyManager \internal \inmodule QtDesigner @@ -1938,14 +1951,8 @@ public: Creates a manager with the given \a parent. */ QtDateTimePropertyManager::QtDateTimePropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent), d_ptr(new QtDateTimePropertyManagerPrivate) + : QtAbstractPropertyManager(parent), d_ptr(new QtDateTimePropertyManagerPrivate(this)) { - d_ptr->q_ptr = this; - - QLocale loc; - d_ptr->m_format = loc.dateFormat(QLocale::ShortFormat); - d_ptr->m_format += QLatin1Char(' '); - d_ptr->m_format += loc.timeFormat(QLocale::ShortFormat); } /*! -- cgit v0.12 From a47e2de1a3958c52eef1997c448bf89d3aba63e5 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 4 Jan 2010 14:32:39 +0100 Subject: Remove TEST_QNETWORK_PROXY define from the tests We always test the proxies now. Reviewed-by: Thiago --- tests/auto/qftp/tst_qftp.cpp | 5 ----- tests/auto/qhttp/tst_qhttp.cpp | 5 ----- tests/auto/qsslsocket/tst_qsslsocket.cpp | 11 ----------- tests/auto/qtcpserver/test/test.pro | 2 -- tests/auto/qtcpserver/tst_qtcpserver.cpp | 24 +----------------------- tests/auto/qtcpsocket/test/test.pro | 2 -- tests/auto/qtcpsocket/tst_qtcpsocket.cpp | 24 ++---------------------- tests/auto/qudpsocket/test/test.pro | 1 - tests/auto/qudpsocket/tst_qudpsocket.cpp | 18 +----------------- 9 files changed, 4 insertions(+), 88 deletions(-) diff --git a/tests/auto/qftp/tst_qftp.cpp b/tests/auto/qftp/tst_qftp.cpp index 27c2e13..9c1670d 100644 --- a/tests/auto/qftp/tst_qftp.cpp +++ b/tests/auto/qftp/tst_qftp.cpp @@ -51,9 +51,6 @@ #include #include -#ifndef TEST_QNETWORK_PROXY -#define TEST_QNETWORK_PROXY -#endif #include "../network-settings.h" //TESTED_CLASS= @@ -202,11 +199,9 @@ void tst_QFtp::initTestCase_data() QTest::addColumn("proxyType"); QTest::newRow("WithoutProxy") << false << 0; -#ifdef TEST_QNETWORK_PROXY QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy); //### doesn't work well yet. //QTest::newRow("WithHttpProxy") << true << int(QNetworkProxy::HttpProxy); -#endif } void tst_QFtp::initTestCase() diff --git a/tests/auto/qhttp/tst_qhttp.cpp b/tests/auto/qhttp/tst_qhttp.cpp index b4b6ceb..92ab3d8 100644 --- a/tests/auto/qhttp/tst_qhttp.cpp +++ b/tests/auto/qhttp/tst_qhttp.cpp @@ -57,9 +57,6 @@ # include #endif -#ifndef TEST_QNETWORK_PROXY -#define TEST_QNETWORK_PROXY -#endif #include "../network-settings.h" //TESTED_CLASS= @@ -198,9 +195,7 @@ void tst_QHttp::initTestCase_data() QTest::addColumn("proxyType"); QTest::newRow("WithoutProxy") << false << 0; -#ifdef TEST_QNETWORK_PROXY QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy); -#endif } void tst_QHttp::initTestCase() diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index 169a688..09c8c5f 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -51,13 +51,8 @@ #include #include -#ifndef TEST_QNETWORK_PROXY -#define TEST_QNETWORK_PROXY -#endif -#ifdef TEST_QNETWORK_PROXY #include #include -#endif #include "../network-settings.h" @@ -253,7 +248,6 @@ void tst_QSslSocket::initTestCase_data() QTest::addColumn("proxyType"); QTest::newRow("WithoutProxy") << false << 0; -#ifdef TEST_QNETWORK_PROXY QTest::newRow("WithSocks5Proxy") << true << int(Socks5Proxy); QTest::newRow("WithSocks5ProxyAuth") << true << int(Socks5Proxy | AuthBasic); @@ -261,14 +255,12 @@ void tst_QSslSocket::initTestCase_data() QTest::newRow("WithHttpProxyBasicAuth") << true << int(HttpProxy | AuthBasic); // uncomment the line below when NTLM works // QTest::newRow("WithHttpProxyNtlmAuth") << true << int(HttpProxy | AuthNtlm); -#endif } void tst_QSslSocket::init() { QFETCH_GLOBAL(bool, setProxy); if (setProxy) { -#ifdef TEST_QNETWORK_PROXY QFETCH_GLOBAL(int, proxyType); QString fluke = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first().toString(); QNetworkProxy proxy; @@ -295,15 +287,12 @@ void tst_QSslSocket::init() break; } QNetworkProxy::setApplicationProxy(proxy); -#endif } } void tst_QSslSocket::cleanup() { -#ifdef TEST_QNETWORK_PROXY QNetworkProxy::setApplicationProxy(QNetworkProxy::DefaultProxy); -#endif } #ifndef QT_NO_OPENSSL diff --git a/tests/auto/qtcpserver/test/test.pro b/tests/auto/qtcpserver/test/test.pro index bdeaa92..123c79e 100644 --- a/tests/auto/qtcpserver/test/test.pro +++ b/tests/auto/qtcpserver/test/test.pro @@ -32,7 +32,5 @@ QT = core network MOC_DIR=tmp -DEFINES += TEST_QNETWORK_PROXY - diff --git a/tests/auto/qtcpserver/tst_qtcpserver.cpp b/tests/auto/qtcpserver/tst_qtcpserver.cpp index 8b86111..8575bd2 100644 --- a/tests/auto/qtcpserver/tst_qtcpserver.cpp +++ b/tests/auto/qtcpserver/tst_qtcpserver.cpp @@ -66,11 +66,9 @@ #include #include -#ifdef TEST_QNETWORK_PROXY -# include +#include Q_DECLARE_METATYPE(QNetworkProxy) Q_DECLARE_METATYPE(QList) -#endif #include "../network-settings.h" @@ -106,12 +104,10 @@ private slots: void listenWhileListening(); void addressReusable(); void setNewSocketDescriptorBlocking(); -#ifdef TEST_QNETWORK_PROXY void invalidProxy_data(); void invalidProxy(); void proxyFactory_data(); void proxyFactory(); -#endif }; // Testing get/set functions @@ -143,29 +139,23 @@ void tst_QTcpServer::initTestCase_data() QTest::addColumn("proxyType"); QTest::newRow("WithoutProxy") << false << 0; -#ifdef TEST_QNETWORK_PROXY QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy); -#endif } void tst_QTcpServer::init() { QFETCH_GLOBAL(bool, setProxy); if (setProxy) { -#ifdef TEST_QNETWORK_PROXY QFETCH_GLOBAL(int, proxyType); if (proxyType == QNetworkProxy::Socks5Proxy) { QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080)); } -#endif } } void tst_QTcpServer::cleanup() { -#ifdef TEST_QNETWORK_PROXY QNetworkProxy::setApplicationProxy(QNetworkProxy::DefaultProxy); -#endif } //---------------------------------------------------------------------------------- @@ -423,12 +413,10 @@ void tst_QTcpServer::maxPendingConnections() { QFETCH_GLOBAL(bool, setProxy); if (setProxy) { -#ifdef TEST_QNETWORK_PROXY QFETCH_GLOBAL(int, proxyType); if (proxyType == QNetworkProxy::Socks5Proxy) { QSKIP("With socks5 only 1 connection is allowed ever", SkipAll); } -#endif } //### sees to fail sometimes ... a timing issue with the test on windows QTcpServer server; @@ -464,12 +452,10 @@ void tst_QTcpServer::listenError() { QFETCH_GLOBAL(bool, setProxy); if (setProxy) { -#ifdef TEST_QNETWORK_PROXY QFETCH_GLOBAL(int, proxyType); if (proxyType == QNetworkProxy::Socks5Proxy) { QSKIP("With socks5 we can not make hard requirements on the address or port", SkipAll); } -#endif } QTcpServer server; QVERIFY(!server.listen(QHostAddress("1.2.3.4"), 0)); @@ -513,12 +499,10 @@ void tst_QTcpServer::waitForConnectionTest() QFETCH_GLOBAL(bool, setProxy); if (setProxy) { -#ifdef TEST_QNETWORK_PROXY QFETCH_GLOBAL(int, proxyType); if (proxyType == QNetworkProxy::Socks5Proxy) { QSKIP("Localhost servers don't work well with SOCKS5", SkipAll); } -#endif } QTcpSocket findLocalIpSocket; @@ -624,12 +608,10 @@ void tst_QTcpServer::addressReusable() QFETCH_GLOBAL(bool, setProxy); if (setProxy) { -#ifdef TEST_QNETWORK_PROXY QFETCH_GLOBAL(int, proxyType); if (proxyType == QNetworkProxy::Socks5Proxy) { QSKIP("With socks5 this test does not make senans at the momment", SkipAll); } -#endif } #if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) QString signalName = QString::fromLatin1("/test_signal.txt"); @@ -667,12 +649,10 @@ void tst_QTcpServer::setNewSocketDescriptorBlocking() { QFETCH_GLOBAL(bool, setProxy); if (setProxy) { -#ifdef TEST_QNETWORK_PROXY QFETCH_GLOBAL(int, proxyType); if (proxyType == QNetworkProxy::Socks5Proxy) { QSKIP("With socks5 we can not make the socket descripter blocking", SkipAll); } -#endif } SeverWithBlockingSockets server; QVERIFY(server.listen()); @@ -683,7 +663,6 @@ void tst_QTcpServer::setNewSocketDescriptorBlocking() QVERIFY(server.ok); } -#ifdef TEST_QNETWORK_PROXY void tst_QTcpServer::invalidProxy_data() { QTest::addColumn("type"); @@ -838,7 +817,6 @@ void tst_QTcpServer::proxyFactory() // Sometimes, error codes change for the better QTEST(int(server.serverError()), "expectedError"); } -#endif QTEST_MAIN(tst_QTcpServer) #include "tst_qtcpserver.moc" diff --git a/tests/auto/qtcpsocket/test/test.pro b/tests/auto/qtcpsocket/test/test.pro index 0f93def..c4369df 100644 --- a/tests/auto/qtcpsocket/test/test.pro +++ b/tests/auto/qtcpsocket/test/test.pro @@ -13,8 +13,6 @@ vxworks:QT -= gui symbian: TARGET.EPOCHEAPSIZE="0x100 0x1000000" -#DEFINES += TEST_QNETWORK_PROXY - TARGET = tst_qtcpsocket win32 { diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp index 863b8f5..c6d39ba 100644 --- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp @@ -82,9 +82,6 @@ #include #include #include -#ifndef TEST_QNETWORK_PROXY -#define TEST_QNETWORK_PROXY -#endif // RVCT compiles also unused inline methods # include @@ -194,12 +191,11 @@ private slots: void increaseReadBufferSize(); void taskQtBug5799ConnectionErrorWaitForConnected(); void taskQtBug5799ConnectionErrorEventLoop(); -#ifdef TEST_QNETWORK_PROXY + void invalidProxy_data(); void invalidProxy(); void proxyFactory_data(); void proxyFactory(); -#endif protected slots: void nonBlockingIMAP_hostFound(); @@ -270,17 +266,15 @@ void tst_QTcpSocket::initTestCase_data() qDebug() << QtNetworkSettings::serverName(); QTest::newRow("WithoutProxy") << false << 0 << false; -#ifdef TEST_QNETWORK_PROXY QTest::newRow("WithSocks5Proxy") << true << int(Socks5Proxy) << false; QTest::newRow("WithSocks5ProxyAuth") << true << int(Socks5Proxy | AuthBasic) << false; QTest::newRow("WithHttpProxy") << true << int(HttpProxy) << false; QTest::newRow("WithHttpProxyBasicAuth") << true << int(HttpProxy | AuthBasic) << false; // QTest::newRow("WithHttpProxyNtlmAuth") << true << int(HttpProxy | AuthNtlm) << false; -#endif + #ifndef QT_NO_OPENSSL QTest::newRow("WithoutProxy SSL") << false << 0 << true; -#ifdef TEST_QNETWORK_PROXY QTest::newRow("WithSocks5Proxy SSL") << true << int(Socks5Proxy) << true; QTest::newRow("WithSocks5AuthProxy SSL") << true << int(Socks5Proxy | AuthBasic) << true; @@ -288,14 +282,12 @@ void tst_QTcpSocket::initTestCase_data() QTest::newRow("WithHttpProxyBasicAuth SSL") << true << int(HttpProxy | AuthBasic) << true; // QTest::newRow("WithHttpProxyNtlmAuth SSL") << true << int(HttpProxy | AuthNtlm) << true; #endif -#endif } void tst_QTcpSocket::init() { QFETCH_GLOBAL(bool, setProxy); if (setProxy) { -#ifdef TEST_QNETWORK_PROXY QFETCH_GLOBAL(int, proxyType); QString fluke = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first().toString(); QNetworkProxy proxy; @@ -322,7 +314,6 @@ void tst_QTcpSocket::init() break; } QNetworkProxy::setApplicationProxy(proxy); -#endif } } @@ -345,9 +336,7 @@ QTcpSocket *tst_QTcpSocket::newSocket() const void tst_QTcpSocket::cleanup() { -#ifdef TEST_QNETWORK_PROXY QNetworkProxy::setApplicationProxy(QNetworkProxy::DefaultProxy); -#endif } void tst_QTcpSocket::proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *auth) @@ -1322,9 +1311,7 @@ void tst_QTcpSocket::synchronousApi() void tst_QTcpSocket::dontCloseOnTimeout() { QTcpServer server; -#ifdef TEST_QNETWORK_PROXY server.setProxy(QNetworkProxy(QNetworkProxy::NoProxy)); -#endif QVERIFY(server.listen()); QHostAddress serverAddress = QHostAddress::LocalHost; @@ -1793,9 +1780,6 @@ void tst_QTcpSocket::readyReadSignalsAfterWaitForReadyRead() QCOMPARE(readyReadSpy.count(), 1); QString s = socket->readLine(); -#ifdef TEST_QNETWORK_PROXY - QNetworkProxy::ProxyType proxyType = QNetworkProxy::applicationProxy().type(); -#endif QCOMPARE(s.toLatin1().constData(), QtNetworkSettings::expectedReplyIMAP().constData()); QCOMPARE(socket->bytesAvailable(), qint64(0)); @@ -2252,9 +2236,6 @@ void tst_QTcpSocket::taskQtBug5799ConnectionErrorEventLoop() QString("Could not reach server: %1").arg(socket.errorString()).toLocal8Bit()); } - - -#ifdef TEST_QNETWORK_PROXY void tst_QTcpSocket::invalidProxy_data() { QTest::addColumn("type"); @@ -2433,7 +2414,6 @@ void tst_QTcpSocket::proxyFactory() delete socket; } -#endif QTEST_MAIN(tst_QTcpSocket) diff --git a/tests/auto/qudpsocket/test/test.pro b/tests/auto/qudpsocket/test/test.pro index 2e0a020..44d3d30 100644 --- a/tests/auto/qudpsocket/test/test.pro +++ b/tests/auto/qudpsocket/test/test.pro @@ -3,7 +3,6 @@ SOURCES += ../tst_qudpsocket.cpp QT = core network MOC_DIR=tmp -DEFINES += TEST_QNETWORK_PROXY win32 { CONFIG(debug, debug|release) { diff --git a/tests/auto/qudpsocket/tst_qudpsocket.cpp b/tests/auto/qudpsocket/tst_qudpsocket.cpp index 160d74c..e3ab9bc 100644 --- a/tests/auto/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/qudpsocket/tst_qudpsocket.cpp @@ -49,10 +49,7 @@ #include #include #include -#ifdef TEST_QNETWORK_PROXY -# include -#endif - +#include #include #include "../network-settings.h" @@ -118,32 +115,23 @@ void tst_QUdpSocket::initTestCase_data() QTest::addColumn("proxyType"); QTest::newRow("WithoutProxy") << false << 0; -#ifdef TEST_QNETWORK_PROXY QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy); -#endif } void tst_QUdpSocket::init() { QFETCH_GLOBAL(bool, setProxy); if (setProxy) { -#ifdef TEST_QNETWORK_PROXY QFETCH_GLOBAL(int, proxyType); if (proxyType == QNetworkProxy::Socks5Proxy) { QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080)); } -#endif } } void tst_QUdpSocket::cleanup() { - QFETCH_GLOBAL(bool, setProxy); - if (setProxy) { -#ifdef TEST_QNETWORK_PROXY QNetworkProxy::setApplicationProxy(QNetworkProxy::DefaultProxy); -#endif - } } @@ -204,12 +192,10 @@ void tst_QUdpSocket::broadcasting() { QFETCH_GLOBAL(bool, setProxy); if (setProxy) { -#ifdef TEST_QNETWORK_PROXY QFETCH_GLOBAL(int, proxyType); if (proxyType == QNetworkProxy::Socks5Proxy) { QSKIP("With socks5 Broadcast is not supported.", SkipSingle); } -#endif } #ifdef Q_OS_AIX QSKIP("Broadcast does not work on darko", SkipAll); @@ -539,12 +525,10 @@ void tst_QUdpSocket::bindMode() { QFETCH_GLOBAL(bool, setProxy); if (setProxy) { -#ifdef TEST_QNETWORK_PROXY QFETCH_GLOBAL(int, proxyType); if (proxyType == QNetworkProxy::Socks5Proxy) { QSKIP("With socks5 explicit port binding is not supported.", SkipAll); } -#endif } QUdpSocket socket; -- cgit v0.12 From 44f7b73940c67b8e81f52dfc6370453ff07d3aa2 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 4 Jan 2010 15:56:37 +0200 Subject: Updated sis file names and related content in Symbian installation docs Task-number: QTBUG-6348 Reviewed-by: Janne Koskinen --- doc/src/getting-started/installation.qdoc | 34 ++++++++++++++++--------- doc/src/snippets/code/doc_src_installation.qdoc | 2 ++ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/doc/src/getting-started/installation.qdoc b/doc/src/getting-started/installation.qdoc index b052c3c..939e2e8 100644 --- a/doc/src/getting-started/installation.qdoc +++ b/doc/src/getting-started/installation.qdoc @@ -511,19 +511,27 @@ in the \l{Qt for the Symbian platform Requirements} document. \note Qt must be installed on the same drive as the Symbian SDK you are using, and the install path must not contain any spaces. + \o Install Qt into a device + + To run Qt applications on a device, \c{qt_installer.sis} found + in the Qt installation directory must be first installed into the device. + \c{Qt_installer.sis} contains Qt libraries and Open C libraries all in one + convenient package. + Begin installation by connecting your device via USB cable to a computer that + has the \l{http://www.nokia.com/pcsuite}{Nokia PC Suite} installed. + On the device, select "PC Suite mode". In Windows Explorer right click + on the \c{qt_installer.sis} file, select "Install with Nokia Application + Installer" and follow the instructions. + \o Running Qt demos We've included a subset of the Qt demos in this package for you to try out. An excellent starting point is the "fluidlauncher" - demo. To run the demo on a real device, you first have to install - \c{qt.sis} and \c{fluidlauncher.sis} found in the Qt installation - directory. Also, check if the device needs additional - \l{Qt for the Symbian platform Requirements}{requirements}. - Begin by connecting your device via USB cable to a computer that has - the \l{http://www.nokia.com/pcsuite}{Nokia PC Suite} installed. - On the device, select "PC Suite mode". In Windows Explorer right click - on the \c{.sis} files, select "Install with Nokia Application Installer" - and follow the instructions. + demo. + + To run the demo on a real device, install \c{fluidlauncher.sis} + found in the Qt installation directory to a device that already has Qt installed. + After installation, you can find fluidlauncher in the applications folder of the device. To run the demos and examples on the emulator, you need to build them first. Open the "Qt for the Symbian platform Command Prompt" from the Start menu and type: @@ -1013,15 +1021,17 @@ If you are using pre-built binaries, follow the instructions given in the which is not available free of charge. \endlist - Running Qt on real device requires the following packages to be installed on your device. - The packages can be found in the Symbian SDK where you installed Open C/C++: + Running Qt on real device requires the Open C to be installed on the device. + The Open C installation packages are embedded into \c{qt_installer.sis}, which is included in + Qt for Symbian binary package. If you are building Qt from scratch, you can find the + required packages in the Symbian SDK where you installed Open C/C++: \list \o \c{nokia_plugin\openc\s60opencsis\pips_s60_.sis} \o \c{nokia_plugin\openc\s60opencsis\openc_ssl_s60_.sis} \o \c{nokia_plugin\opencpp\s60opencppsis\stdcpp_s60_.sis} \endlist - We recommend you to take a look of \l{http://developer.symbian.org/wiki/index.php/Qt_Quick_Start}{Symbian Foundation - Qt Quick Start} + We recommend you to take a look at \l{http://developer.symbian.org/wiki/index.php/Qt_Quick_Start}{Symbian Foundation - Qt Quick Start} to get more information about how to setup the development environment. \sa {Known Issues in %VERSION%} diff --git a/doc/src/snippets/code/doc_src_installation.qdoc b/doc/src/snippets/code/doc_src_installation.qdoc index c810706..bc61702 100644 --- a/doc/src/snippets/code/doc_src_installation.qdoc +++ b/doc/src/snippets/code/doc_src_installation.qdoc @@ -198,6 +198,8 @@ make release-armv5 //! [29] cd src\s60installs make sis QT_SIS_OPTIONS=-i QT_SIS_CERTIFICATE= QT_SIS_KEY= +cd ..\3rdparty\webkit\WebCore +make sis QT_SIS_OPTIONS=-i QT_SIS_CERTIFICATE= QT_SIS_KEY= //! [29] //! [30] -- cgit v0.12 From 5153767a8e4c9b01eef05bf25881eab44a7cd725 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 18 Dec 2009 11:14:29 +0100 Subject: Cocoa: added release pool Fix warning given by cocoa (cherry picked from commit 875afab977005b03d307040fb3be15c7524a37ff) --- src/gui/kernel/qwidget_mac.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 0213af9..69f1353 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -3671,6 +3671,7 @@ void QWidgetPrivate::raise_sys() return; #if QT_MAC_USE_COCOA + QMacCocoaAutoReleasePool pool; if (isRealWindow()) { // Calling orderFront shows the window on Cocoa too. if (!q->testAttribute(Qt::WA_DontShowOnScreen) && q->isVisible()) { -- cgit v0.12 From bc1ca85d59e680d6b4f5374775a7a7278650c8a9 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 4 Jan 2010 15:02:29 +0100 Subject: tst_qtcpserver: Move benchmarks Move benchmarks into tests/benchmarks directory. Reviewed-by: Thiago --- tests/auto/qtcpserver/tst_qtcpserver.cpp | 156 -------------- tests/benchmarks/benchmarks.pro | 1 + tests/benchmarks/qtcpserver/qtcpserver.pro | 13 ++ tests/benchmarks/qtcpserver/tst_qtcpserver.cpp | 277 +++++++++++++++++++++++++ 4 files changed, 291 insertions(+), 156 deletions(-) create mode 100644 tests/benchmarks/qtcpserver/qtcpserver.pro create mode 100644 tests/benchmarks/qtcpserver/tst_qtcpserver.cpp diff --git a/tests/auto/qtcpserver/tst_qtcpserver.cpp b/tests/auto/qtcpserver/tst_qtcpserver.cpp index 8575bd2..4567435 100644 --- a/tests/auto/qtcpserver/tst_qtcpserver.cpp +++ b/tests/auto/qtcpserver/tst_qtcpserver.cpp @@ -93,9 +93,6 @@ private slots: void constructing(); void clientServerLoop(); void ipv6Server(); - void ipv4LoopbackPerformanceTest(); - void ipv6LoopbackPerformanceTest(); - void ipv4PerformanceTest(); void crashTests(); void maxPendingConnections(); void listenError(); @@ -248,159 +245,6 @@ void tst_QTcpServer::ipv6Server() } //---------------------------------------------------------------------------------- -void tst_QTcpServer::ipv4LoopbackPerformanceTest() -{ - QFETCH_GLOBAL(bool, setProxy); - if (setProxy) - return; - - QTcpServer server; - QVERIFY(server.listen(QHostAddress::LocalHost)); - - QVERIFY(server.isListening()); - - QTcpSocket clientA; - clientA.connectToHost(QHostAddress::LocalHost, server.serverPort()); - QVERIFY(clientA.waitForConnected(5000)); - QVERIFY(clientA.state() == QAbstractSocket::ConnectedState); - - QVERIFY(server.waitForNewConnection()); - QTcpSocket *clientB = server.nextPendingConnection(); - QVERIFY(clientB); - - QByteArray buffer(16384, '@'); - QTime stopWatch; - stopWatch.start(); - qlonglong totalWritten = 0; - while (stopWatch.elapsed() < 5000) { - QVERIFY(clientA.write(buffer.data(), buffer.size()) > 0); - clientA.flush(); - totalWritten += buffer.size(); - while (clientB->waitForReadyRead(100)) { - if (clientB->bytesAvailable() == 16384) - break; - } - clientB->read(buffer.data(), buffer.size()); - clientB->write(buffer.data(), buffer.size()); - clientB->flush(); - totalWritten += buffer.size(); - while (clientA.waitForReadyRead(100)) { - if (clientA.bytesAvailable() == 16384) - break; - } - clientA.read(buffer.data(), buffer.size()); - } - - qDebug("\t\t%s: %.1fMB/%.1fs: %.1fMB/s", - server.serverAddress().toString().toLatin1().constData(), - totalWritten / (1024.0 * 1024.0), - stopWatch.elapsed() / 1000.0, - (totalWritten / (stopWatch.elapsed() / 1000.0)) / (1024 * 1024)); - - delete clientB; -} - -//---------------------------------------------------------------------------------- -void tst_QTcpServer::ipv6LoopbackPerformanceTest() -{ -#if defined(Q_OS_SYMBIAN) - QSKIP("Symbian: IPv6 is not yet supported", SkipAll); -#endif - QTcpServer server; - if (!server.listen(QHostAddress::LocalHostIPv6, 0)) { - QVERIFY(server.serverError() == QAbstractSocket::UnsupportedSocketOperationError); - } else { - QTcpSocket clientA; - clientA.connectToHost(server.serverAddress(), server.serverPort()); - QVERIFY(clientA.waitForConnected(5000)); - - QVERIFY(server.waitForNewConnection(5000)); - QTcpSocket *clientB = server.nextPendingConnection(); - QVERIFY(clientB); - - QByteArray buffer(16384, '@'); - QTime stopWatch; - stopWatch.start(); - qlonglong totalWritten = 0; - while (stopWatch.elapsed() < 5000) { - clientA.write(buffer.data(), buffer.size()); - clientA.flush(); - totalWritten += buffer.size(); - while (clientB->waitForReadyRead(100)) { - if (clientB->bytesAvailable() == 16384) - break; - } - clientB->read(buffer.data(), buffer.size()); - clientB->write(buffer.data(), buffer.size()); - clientB->flush(); - totalWritten += buffer.size(); - while (clientA.waitForReadyRead(100)) { - if (clientA.bytesAvailable() == 16384) - break; - } - clientA.read(buffer.data(), buffer.size()); - } - - qDebug("\t\t%s: %.1fMB/%.1fs: %.1fMB/s", - server.serverAddress().toString().toLatin1().constData(), - totalWritten / (1024.0 * 1024.0), - stopWatch.elapsed() / 1000.0, - (totalWritten / (stopWatch.elapsed() / 1000.0)) / (1024 * 1024)); - delete clientB; - } -} - -//---------------------------------------------------------------------------------- -void tst_QTcpServer::ipv4PerformanceTest() -{ - QTcpSocket probeSocket; - probeSocket.connectToHost(QtNetworkSettings::serverName(), 143); - QVERIFY(probeSocket.waitForConnected(5000)); - - QTcpServer server; - QVERIFY(server.listen(probeSocket.localAddress(), 0)); - - QTcpSocket clientA; - clientA.connectToHost(server.serverAddress(), server.serverPort()); - QVERIFY(clientA.waitForConnected(5000)); - - QVERIFY(server.waitForNewConnection(5000)); - QTcpSocket *clientB = server.nextPendingConnection(); - QVERIFY(clientB); - - QByteArray buffer(16384, '@'); - QTime stopWatch; - stopWatch.start(); - qlonglong totalWritten = 0; - while (stopWatch.elapsed() < 5000) { - qlonglong writtenA = clientA.write(buffer.data(), buffer.size()); - clientA.flush(); - totalWritten += buffer.size(); - while (clientB->waitForReadyRead(100)) { - if (clientB->bytesAvailable() == writtenA) - break; - } - clientB->read(buffer.data(), buffer.size()); - qlonglong writtenB = clientB->write(buffer.data(), buffer.size()); - clientB->flush(); - totalWritten += buffer.size(); - while (clientA.waitForReadyRead(100)) { - if (clientA.bytesAvailable() == writtenB) - break; - } - clientA.read(buffer.data(), buffer.size()); - } - - qDebug("\t\t%s: %.1fMB/%.1fs: %.1fMB/s", - probeSocket.localAddress().toString().toLatin1().constData(), - totalWritten / (1024.0 * 1024.0), - stopWatch.elapsed() / 1000.0, - (totalWritten / (stopWatch.elapsed() / 1000.0)) / (1024 * 1024)); - - delete clientB; -} - -//---------------------------------------------------------------------------------- void tst_QTcpServer::crashTests() { QTcpServer server; diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro index 0f760a1..7bb4bb1 100644 --- a/tests/benchmarks/benchmarks.pro +++ b/tests/benchmarks/benchmarks.pro @@ -37,6 +37,7 @@ SUBDIRS = containers-associative \ qstringbuilder \ qstylesheetstyle \ qsvgrenderer \ + qtcpserver \ qtableview \ qthreadstorage diff --git a/tests/benchmarks/qtcpserver/qtcpserver.pro b/tests/benchmarks/qtcpserver/qtcpserver.pro new file mode 100644 index 0000000..e7bf13a --- /dev/null +++ b/tests/benchmarks/qtcpserver/qtcpserver.pro @@ -0,0 +1,13 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_qtcpserver +DEPENDPATH += . +INCLUDEPATH += . + +QT -= gui +QT += network + +CONFIG += release + +# Input +SOURCES += tst_qtcpserver.cpp diff --git a/tests/benchmarks/qtcpserver/tst_qtcpserver.cpp b/tests/benchmarks/qtcpserver/tst_qtcpserver.cpp new file mode 100644 index 0000000..07640b8 --- /dev/null +++ b/tests/benchmarks/qtcpserver/tst_qtcpserver.cpp @@ -0,0 +1,277 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// Just to get Q_OS_SYMBIAN +#include + +#include + + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +Q_DECLARE_METATYPE(QNetworkProxy) +Q_DECLARE_METATYPE(QList) + +#include "../../auto/network-settings.h" + +//TESTED_CLASS= +//TESTED_FILES= + +class tst_QTcpServer : public QObject +{ + Q_OBJECT + +public: + tst_QTcpServer(); + virtual ~tst_QTcpServer(); + + +public slots: + void initTestCase_data(); + void init(); + void cleanup(); +private slots: + void ipv4LoopbackPerformanceTest(); + void ipv6LoopbackPerformanceTest(); + void ipv4PerformanceTest(); +}; + +tst_QTcpServer::tst_QTcpServer() +{ + Q_SET_DEFAULT_IAP +} + +tst_QTcpServer::~tst_QTcpServer() +{ +} + +void tst_QTcpServer::initTestCase_data() +{ + QTest::addColumn("setProxy"); + QTest::addColumn("proxyType"); + + QTest::newRow("WithoutProxy") << false << 0; + QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy); +} + +void tst_QTcpServer::init() +{ + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) { + QFETCH_GLOBAL(int, proxyType); + if (proxyType == QNetworkProxy::Socks5Proxy) { + QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080)); + } + } +} + +void tst_QTcpServer::cleanup() +{ + QNetworkProxy::setApplicationProxy(QNetworkProxy::DefaultProxy); +} + +//---------------------------------------------------------------------------------- +void tst_QTcpServer::ipv4LoopbackPerformanceTest() +{ + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) + return; + + QTcpServer server; + QVERIFY(server.listen(QHostAddress::LocalHost)); + + QVERIFY(server.isListening()); + + QTcpSocket clientA; + clientA.connectToHost(QHostAddress::LocalHost, server.serverPort()); + QVERIFY(clientA.waitForConnected(5000)); + QVERIFY(clientA.state() == QAbstractSocket::ConnectedState); + + QVERIFY(server.waitForNewConnection()); + QTcpSocket *clientB = server.nextPendingConnection(); + QVERIFY(clientB); + + QByteArray buffer(16384, '@'); + QTime stopWatch; + stopWatch.start(); + qlonglong totalWritten = 0; + while (stopWatch.elapsed() < 5000) { + QVERIFY(clientA.write(buffer.data(), buffer.size()) > 0); + clientA.flush(); + totalWritten += buffer.size(); + while (clientB->waitForReadyRead(100)) { + if (clientB->bytesAvailable() == 16384) + break; + } + clientB->read(buffer.data(), buffer.size()); + clientB->write(buffer.data(), buffer.size()); + clientB->flush(); + totalWritten += buffer.size(); + while (clientA.waitForReadyRead(100)) { + if (clientA.bytesAvailable() == 16384) + break; + } + clientA.read(buffer.data(), buffer.size()); + } + + qDebug("\t\t%s: %.1fMB/%.1fs: %.1fMB/s", + server.serverAddress().toString().toLatin1().constData(), + totalWritten / (1024.0 * 1024.0), + stopWatch.elapsed() / 1000.0, + (totalWritten / (stopWatch.elapsed() / 1000.0)) / (1024 * 1024)); + + delete clientB; +} + +//---------------------------------------------------------------------------------- +void tst_QTcpServer::ipv6LoopbackPerformanceTest() +{ + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) + return; + +#if defined(Q_OS_SYMBIAN) + QSKIP("Symbian: IPv6 is not yet supported", SkipAll); +#endif + QTcpServer server; + if (!server.listen(QHostAddress::LocalHostIPv6, 0)) { + QVERIFY(server.serverError() == QAbstractSocket::UnsupportedSocketOperationError); + } else { + QTcpSocket clientA; + clientA.connectToHost(server.serverAddress(), server.serverPort()); + QVERIFY(clientA.waitForConnected(5000)); + + QVERIFY(server.waitForNewConnection(5000)); + QTcpSocket *clientB = server.nextPendingConnection(); + QVERIFY(clientB); + + QByteArray buffer(16384, '@'); + QTime stopWatch; + stopWatch.start(); + qlonglong totalWritten = 0; + while (stopWatch.elapsed() < 5000) { + clientA.write(buffer.data(), buffer.size()); + clientA.flush(); + totalWritten += buffer.size(); + while (clientB->waitForReadyRead(100)) { + if (clientB->bytesAvailable() == 16384) + break; + } + clientB->read(buffer.data(), buffer.size()); + clientB->write(buffer.data(), buffer.size()); + clientB->flush(); + totalWritten += buffer.size(); + while (clientA.waitForReadyRead(100)) { + if (clientA.bytesAvailable() == 16384) + break; + } + clientA.read(buffer.data(), buffer.size()); + } + + qDebug("\t\t%s: %.1fMB/%.1fs: %.1fMB/s", + server.serverAddress().toString().toLatin1().constData(), + totalWritten / (1024.0 * 1024.0), + stopWatch.elapsed() / 1000.0, + (totalWritten / (stopWatch.elapsed() / 1000.0)) / (1024 * 1024)); + delete clientB; + } +} + +//---------------------------------------------------------------------------------- +void tst_QTcpServer::ipv4PerformanceTest() +{ + QTcpSocket probeSocket; + probeSocket.connectToHost(QtNetworkSettings::serverName(), 143); + QVERIFY(probeSocket.waitForConnected(5000)); + + QTcpServer server; + QVERIFY(server.listen(probeSocket.localAddress(), 0)); + + QTcpSocket clientA; + clientA.connectToHost(server.serverAddress(), server.serverPort()); + QVERIFY(clientA.waitForConnected(5000)); + + QVERIFY(server.waitForNewConnection(5000)); + QTcpSocket *clientB = server.nextPendingConnection(); + QVERIFY(clientB); + + QByteArray buffer(16384, '@'); + QTime stopWatch; + stopWatch.start(); + qlonglong totalWritten = 0; + while (stopWatch.elapsed() < 5000) { + qlonglong writtenA = clientA.write(buffer.data(), buffer.size()); + clientA.flush(); + totalWritten += buffer.size(); + while (clientB->waitForReadyRead(100)) { + if (clientB->bytesAvailable() == writtenA) + break; + } + clientB->read(buffer.data(), buffer.size()); + qlonglong writtenB = clientB->write(buffer.data(), buffer.size()); + clientB->flush(); + totalWritten += buffer.size(); + while (clientA.waitForReadyRead(100)) { + if (clientA.bytesAvailable() == writtenB) + break; + } + clientA.read(buffer.data(), buffer.size()); + } + + qDebug("\t\t%s: %.1fMB/%.1fs: %.1fMB/s", + probeSocket.localAddress().toString().toLatin1().constData(), + totalWritten / (1024.0 * 1024.0), + stopWatch.elapsed() / 1000.0, + (totalWritten / (stopWatch.elapsed() / 1000.0)) / (1024 * 1024)); + + delete clientB; +} + +QTEST_MAIN(tst_QTcpServer) +#include "tst_qtcpserver.moc" -- cgit v0.12 From 22bc54c21cc63b781be736de71d27836c67dc4ff Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 4 Jan 2010 15:19:29 +0100 Subject: doc: Fixed remaining qdoc errors Added a missing \class command, some missing enum values, etc. --- src/xmlpatterns/api/qcoloroutput.cpp | 117 ++++++++++++++++++++++------------- 1 file changed, 73 insertions(+), 44 deletions(-) diff --git a/src/xmlpatterns/api/qcoloroutput.cpp b/src/xmlpatterns/api/qcoloroutput.cpp index 4f27fd5..abfa656 100644 --- a/src/xmlpatterns/api/qcoloroutput.cpp +++ b/src/xmlpatterns/api/qcoloroutput.cpp @@ -153,51 +153,56 @@ const char *const ColorOutputPrivate::backgrounds[] = }; /*! - \since 4.4 - \nonreentrant - \brief Outputs colored messages to \c stderr. - \internal - - ColorOutput is a convenience class for outputting messages to \c stderr - using color escape codes, as mandated in ECMA-48. ColorOutput will only - color output when it is detected to be suitable. For instance, if \c stderr is - detected to be attached to a file instead of a TTY, no coloring will be done. - - ColorOutput does its best attempt. but it is generally undefined what coloring - or effect the various coloring flags has. It depends strongly on what terminal - software that is being used. - - When using `echo -e 'my escape sequence'`, \033 works as an initiator but not - when printing from a C++ program, despite having escaped the backslash. - That's why we below use characters with value 0x1B. - - It can be convenient to subclass ColorOutput with a private scope, such that the - functions are directly available in the class using it. - - \section1 Usage - - To output messages, call write() or writeUncolored(). write() takes as second - argument an integer, which ColorOutput uses as a lookup key to find the color - it should color the text in. The mapping from keys to colors is done using - insertMapping(). Typically this is used by having enums for the various kinds - of messages, which subsequently are registered. - - \code - enum MyMessage - { + \class ColorOutput + \since 4.4 + \nonreentrant + \brief Outputs colored messages to \c stderr. + \internal + + ColorOutput is a convenience class for outputting messages to \c + stderr using color escape codes, as mandated in ECMA-48. ColorOutput + will only color output when it is detected to be suitable. For + instance, if \c stderr is detected to be attached to a file instead + of a TTY, no coloring will be done. + + ColorOutput does its best attempt. but it is generally undefined + what coloring or effect the various coloring flags has. It depends + strongly on what terminal software that is being used. + + When using `echo -e 'my escape sequence'`, \c{\033} works as an + initiator but not when printing from a C++ program, despite having + escaped the backslash. That's why we below use characters with + value 0x1B. + + It can be convenient to subclass ColorOutput with a private scope, + such that the functions are directly available in the class using + it. + + \section1 Usage + + To output messages, call write() or writeUncolored(). write() takes + as second argument an integer, which ColorOutput uses as a lookup + key to find the color it should color the text in. The mapping from + keys to colors is done using insertMapping(). Typically this is used + by having enums for the various kinds of messages, which + subsequently are registered. + + \code + enum MyMessage + { Error, Important - }; + }; - ColorOutput output; - output.insertMapping(Error, ColorOutput::RedForeground); - output.insertMapping(Import, ColorOutput::BlueForeground); + ColorOutput output; + output.insertMapping(Error, ColorOutput::RedForeground); + output.insertMapping(Import, ColorOutput::BlueForeground); - output.write("This is important", Important); - output.write("Jack, I'm only the selected official!", Error); - \endcode + output.write("This is important", Important); + output.write("Jack, I'm only the selected official!", Error); + \endcode - \sa {http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html} {Bash Prompt HOWTO, 6.1. Colours} + \sa {http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html} {Bash Prompt HOWTO, 6.1. Colours} {http://linuxgazette.net/issue51/livingston-blade.html} {Linux Gazette, Tweaking Eterm, Edward Livingston-Blade} {http://www.ecma-international.org/publications/standards/Ecma-048.htm} {Standard ECMA-48, Control Functions for Coded Character Sets, ECMA International}, {http://en.wikipedia.org/wiki/ANSI_escape_code} {Wikipedia, ANSI escape code} @@ -205,10 +210,34 @@ const char *const ColorOutputPrivate::backgrounds[] = */ /*! - \enum ColorOutput::ColorCode - - \value DefaultColor ColorOutput performs no coloring. This typically means black on white - or white on black, depending on the settings of the user's terminal. + \enum ColorOutput::ColorCodeComponent + \value BlackForeground + \value BlueForeground + \value GreenForeground + \value CyanForeground + \value RedForeground + \value PurpleForeground + \value BrownForeground + \value LightGrayForeground + \value DarkGrayForeground + \value LightBlueForeground + \value LightGreenForeground + \value LightCyanForeground + \value LightRedForeground + \value LightPurpleForeground + \value YellowForeground + \value WhiteForeground + \value BlackBackground + \value BlueBackground + \value GreenBackground + \value CyanBackground + \value RedBackground + \value PurpleBackground + \value BrownBackground + + \value DefaultColor ColorOutput performs no coloring. This typically + means black on white or white on black, depending + on the settings of the user's terminal. */ /*! -- cgit v0.12 From 0e94349de0b602f1b6af747b66ef03b22133cc3a Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 22 Dec 2009 16:14:59 +0000 Subject: Deal with test cases that crash or hang Added an optional timeout to runonphone - the application will be killed after this time. Used when autotesting unattended, as some tests can hang. Handled the just in time debug halting the application when it is about to crash, by terminating the application. In future, we could capture a call stack or something here. Also added quiet/verbose options to control the amount of output from runonphone. Reviewed-by: Janne Koskinen --- qmake/generators/symbian/symmake.cpp | 2 +- tools/runonphone/main.cpp | 82 +++++++++++++++++++++++------ tools/runonphone/trk/launcher.cpp | 20 +++++++ tools/runonphone/trk/launcher.h | 2 + tools/runonphone/trksignalhandler.cpp | 98 +++++++++++++++++++++++++++++------ tools/runonphone/trksignalhandler.h | 12 +++++ 6 files changed, 183 insertions(+), 33 deletions(-) diff --git a/qmake/generators/symbian/symmake.cpp b/qmake/generators/symbian/symmake.cpp index ddda848..f3339af 100644 --- a/qmake/generators/symbian/symmake.cpp +++ b/qmake/generators/symbian/symmake.cpp @@ -1866,7 +1866,7 @@ void SymbianMakefileGenerator::generateExecutionTargets(QTextStream& t, const QS t << "else" << endl; } t << "run: sis" << endl; - t << "\trunonphone --sis " << fixedTarget << "_$(QT_SIS_TARGET).sis " << fixedTarget << ".exe " << "$(QT_RUN_OPTIONS)" << endl; + t << "\trunonphone $(QT_RUN_ON_PHONE_OPTIONS) --sis " << fixedTarget << "_$(QT_SIS_TARGET).sis " << fixedTarget << ".exe " << "$(QT_RUN_OPTIONS)" << endl; if (platforms.contains("winscw")) { t << "endif" << endl; } diff --git a/tools/runonphone/main.cpp b/tools/runonphone/main.cpp index 58d8c3b..e2f6758 100644 --- a/tools/runonphone/main.cpp +++ b/tools/runonphone/main.cpp @@ -40,9 +40,10 @@ ****************************************************************************/ #include -#include +#include #include #include +#include #include "trkutils.h" #include "trkdevice.h" #include "launcher.h" @@ -50,12 +51,15 @@ #include "trksignalhandler.h" #include "serenum.h" -void printUsage() +void printUsage(QTextStream& outstream) { - qDebug() << "runtest [options] [program arguments]" << endl + outstream << "runtest [options] [program arguments]" << endl << "-s, --sis specify sis file to install" << endl << "-p, --portname specify COM port to use by device name" << endl << "-f, --portfriendlyname specify COM port to use by friendly name" << endl + << "-t, --timeout terminate test if timeout occurs" << endl + << "-v, --verbose show debugging output" << endl + << "-q, --quiet hide progress messages" << endl << endl << "USB COM ports can usually be autodetected" << endl; } @@ -70,26 +74,51 @@ int main(int argc, char *argv[]) QString exeFile; QString cmdLine; QStringList args = QCoreApplication::arguments(); + QTextStream outstream(stdout); + QTextStream errstream(stderr); + int loglevel=1; + int timeout=0; for (int i=1;i 0) + outstream << "Detecting serial ports" << endl; QList ports = enumerateSerialPorts(); foreach(SerialPortId id, ports) { - qDebug() << "Port Name: " << id.portName << ", " + if(loglevel > 0) + outstream << "Port Name: " << id.portName << ", " << "Friendly Name:" << id.friendlyName << endl; if(serialPortName.isEmpty()) { - if(id.friendlyName.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; } @@ -129,20 +162,25 @@ int main(int argc, char *argv[]) if(sisFile.isEmpty()) { launcher.reset(new trk::Launcher(trk::Launcher::ActionCopyRun)); launcher->setCopyFileName(exeFile, QString("c:\\sys\\bin\\") + exeFile); - qDebug() << "System TRK required to copy EXE, use --sis if using Application TRK" << endl; + errstream << "System TRK required to copy EXE, use --sis if using Application TRK" << endl; } else { launcher.reset(new trk::Launcher(trk::Launcher::ActionCopyInstallRun)); launcher->addStartupActions(trk::Launcher::ActionInstall); launcher->setCopyFileName(sisFile, "c:\\data\\testtemp.sis"); launcher->setInstallFileName("c:\\data\\testtemp.sis"); } - qDebug() << "Connecting to target via " << serialPortName << endl; + if(loglevel > 0) + outstream << "Connecting to target via " << serialPortName << endl; launcher->setTrkServerName(QString("\\\\.\\") + serialPortName); launcher->setFileName(QString("c:\\sys\\bin\\") + exeFile); launcher->setCommandLineArgs(cmdLine); + if(loglevel > 1) + launcher->setVerbose(1); + TrkSignalHandler handler; + handler.setLogLevel(loglevel); QObject::connect(launcher.data(), SIGNAL(copyingStarted()), &handler, SLOT(copyingStarted())); QObject::connect(launcher.data(), SIGNAL(canNotConnect(const QString &)), &handler, SLOT(canNotConnect(const QString &))); @@ -158,11 +196,21 @@ int main(int argc, char *argv[]) QObject::connect(launcher.data(), SIGNAL(applicationOutputReceived(const QString &)), &handler, SLOT(applicationOutputReceived(const QString &))); QObject::connect(launcher.data(), SIGNAL(copyProgress(int)), &handler, SLOT(copyProgress(int))); QObject::connect(launcher.data(), SIGNAL(stateChanged(int)), &handler, SLOT(stateChanged(int))); + QObject::connect(launcher.data(), SIGNAL(stopped(uint,uint,uint,QString)), &handler, SLOT(stopped(uint,uint,uint,QString))); + QObject::connect(&handler, SIGNAL(resume(uint,uint)), launcher.data(), SLOT(resume(uint,uint))); + QObject::connect(&handler, SIGNAL(terminate()), launcher.data(), SLOT(terminate())); QObject::connect(launcher.data(), SIGNAL(finished()), &handler, SLOT(finished())); + QTimer timer; + timer.setSingleShot(true); + QObject::connect(&timer, SIGNAL(timeout()), &handler, SLOT(timeout())); + if (timeout > 0) { + timer.start(timeout); + } + QString errorMessage; if(!launcher->startServer(&errorMessage)) { - qWarning() << errorMessage; + errstream << errorMessage << endl; return 1; } diff --git a/tools/runonphone/trk/launcher.cpp b/tools/runonphone/trk/launcher.cpp index 90ad602..a5d173a 100644 --- a/tools/runonphone/trk/launcher.cpp +++ b/tools/runonphone/trk/launcher.cpp @@ -317,6 +317,18 @@ void Launcher::handleResult(const TrkResult &result) case TrkNotifyStopped: { // Notified Stopped logMessage(prefix + "NOTE: STOPPED " + str); // 90 01 78 6a 40 40 00 00 07 23 00 00 07 24 00 00 + QString reason; + if (result.data.size() >= 14) { + uint pc = extractInt(result.data.mid(0,4).constData()); + uint pid = extractInt(result.data.mid(4,4).constData()); + uint tid = extractInt(result.data.mid(8,4).constData()); + ushort len = extractShort(result.data.mid(12,2).constData()); + if(len > 0) + reason = result.data.mid(14, len); + emit(stopped(pc, pid, tid, reason)); + } else { + emit(stopped(0, 0, 0, reason)); + } //const char *data = result.data.data(); // uint addr = extractInt(data); //code address: 4 bytes; code base address for the library // uint pid = extractInt(data + 4); // ProcessID: 4 bytes; @@ -692,4 +704,12 @@ void Launcher::startInferiorIfNeeded() } d->m_device->sendTrkMessage(TrkCreateItem, TrkCallback(this, &Launcher::handleCreateProcess), ba); // Create Item } + +void Launcher::resume(uint pid, uint tid) +{ + QByteArray ba; + appendInt(&ba, pid, BigEndian); + appendInt(&ba, tid, BigEndian); + d->m_device->sendTrkMessage(TrkContinue, TrkCallback(), ba, "CONTINUE"); +} } // namespace trk diff --git a/tools/runonphone/trk/launcher.h b/tools/runonphone/trk/launcher.h index 29ee967..3a0c3ef 100644 --- a/tools/runonphone/trk/launcher.h +++ b/tools/runonphone/trk/launcher.h @@ -125,9 +125,11 @@ signals: void applicationOutputReceived(const QString &output); void copyProgress(int percent); void stateChanged(int); + void stopped(uint pc, uint pid, uint tid, const QString& reason); public slots: void terminate(); + void resume(uint pid, uint tid); private slots: void handleResult(const trk::TrkResult &data); diff --git a/tools/runonphone/trksignalhandler.cpp b/tools/runonphone/trksignalhandler.cpp index afb1918..099be7a 100644 --- a/tools/runonphone/trksignalhandler.cpp +++ b/tools/runonphone/trksignalhandler.cpp @@ -41,81 +41,149 @@ #include #include +#include #include "trksignalhandler.h" +class TrkSignalHandlerPrivate +{ + friend class TrkSignalHandler; +public: + TrkSignalHandlerPrivate(); + ~TrkSignalHandlerPrivate(); +private: + QTextStream out; + QTextStream err; + int loglevel; +}; + void TrkSignalHandler::copyingStarted() { - qDebug() << "Copying...\n"; + if(d->loglevel > 0) + d->out << "Copying..." << endl; } void TrkSignalHandler::canNotConnect(const QString &errorMessage) { - qWarning() << "Cannot Connect - " << errorMessage; + d->err << "Cannot Connect - " << errorMessage << endl; } void TrkSignalHandler::canNotCreateFile(const QString &filename, const QString &errorMessage) { - qWarning() << "Cannot create file (" << filename << ") - " << errorMessage << "\n"; + d->err << "Cannot create file (" << filename << ") - " << errorMessage << endl; } void TrkSignalHandler::canNotWriteFile(const QString &filename, const QString &errorMessage) { - qWarning() << "Cannot write file (" << filename << ") - " << errorMessage << "\n"; + d->err << "Cannot write file (" << filename << ") - " << errorMessage << endl; } void TrkSignalHandler::canNotCloseFile(const QString &filename, const QString &errorMessage) { - qWarning() << "Cannot close file (" << filename << ") - " << errorMessage << "\n"; + d->err << "Cannot close file (" << filename << ") - " << errorMessage << endl; } void TrkSignalHandler::installingStarted() { - qDebug() << "Installing...\n"; + if(d->loglevel > 0) + d->out << "Installing..." << endl; } void TrkSignalHandler::canNotInstall(const QString &packageFilename, const QString &errorMessage) { - qWarning() << "Cannot install file (" << packageFilename << ") - " << errorMessage << "\n"; + d->err << "Cannot install file (" << packageFilename << ") - " << errorMessage << endl; } void TrkSignalHandler::installingFinished() { - qDebug() << "Installing finished\n"; + if(d->loglevel > 0) + d->out << "Installing finished" << endl; } void TrkSignalHandler::startingApplication() { - qDebug() << "Starting app...\n"; + if(d->loglevel > 0) + d->out << "Starting app..." << endl; } void TrkSignalHandler::applicationRunning(uint pid) { - qDebug() << "Running...\n"; + if(d->loglevel > 0) + d->out << "Running..." << endl; } void TrkSignalHandler::canNotRun(const QString &errorMessage) { - qWarning() << "Cannot run - " << errorMessage << "\n"; + d->err << "Cannot run - " << errorMessage << endl; } void TrkSignalHandler::finished() { - qDebug() << "Done.\n"; + if(d->loglevel > 0) + d->out << "Done." << endl; QCoreApplication::quit(); } void TrkSignalHandler::applicationOutputReceived(const QString &output) { - qDebug() << "> " << output; + d->out << output; } void TrkSignalHandler::copyProgress(int percent) { - qDebug() << percent << "%"; + if(d->loglevel > 0) { + d->out << percent << "% "; + d->out.flush(); + if(percent==100) + d->out << endl; + } } void TrkSignalHandler::stateChanged(int state) { - qDebug() << "State" << state; + if(d->loglevel > 1) + d->out << "State" << state << endl; +} + +void TrkSignalHandler::setLogLevel(int level) +{ + d->loglevel = level; +} + +void TrkSignalHandler::stopped(uint pc, uint pid, uint tid, const QString& reason) +{ + d->err << "STOPPED: pc=" << hex << pc << " pid=" << pid + << " tid=" << tid << dec << " - " << reason << endl; + // if it was a breakpoint, then we could continue with "emit resume(pid, tid);" + // since we have set no breakpoints, it will be a just in time debug of a panic / exception + emit terminate(); +} + +void TrkSignalHandler::timeout() +{ + d->err << "FAILED: stopping test due to timeout" << endl; + emit terminate(); } +TrkSignalHandlerPrivate::TrkSignalHandlerPrivate() : + out(stdout), + err(stderr), + loglevel(0) +{ + +} + +TrkSignalHandlerPrivate::~TrkSignalHandlerPrivate() +{ + out.flush(); + err.flush(); +} + +TrkSignalHandler::TrkSignalHandler() +{ + d = new TrkSignalHandlerPrivate(); +} + +TrkSignalHandler::~TrkSignalHandler() +{ + delete d; +} diff --git a/tools/runonphone/trksignalhandler.h b/tools/runonphone/trksignalhandler.h index 2b3f3a0..818aa56 100644 --- a/tools/runonphone/trksignalhandler.h +++ b/tools/runonphone/trksignalhandler.h @@ -44,6 +44,7 @@ #include #include +class TrkSignalHandlerPrivate; class TrkSignalHandler : public QObject { Q_OBJECT @@ -63,6 +64,17 @@ public slots: void applicationOutputReceived(const QString &output); void copyProgress(int percent); void stateChanged(int); + void stopped(uint pc, uint pid, uint tid, const QString& reason); + void timeout(); +signals: + void resume(uint pid, uint tid); + void terminate(); +public: + TrkSignalHandler(); + ~TrkSignalHandler(); + void setLogLevel(int); +private: + TrkSignalHandlerPrivate *d; }; #endif // TRKSIGNALHANDLER_H -- cgit v0.12 From 10ca680e00fe514c32eb6364c4cca3ce46814076 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 4 Jan 2010 16:17:29 +0100 Subject: tst_qhostinfo benchmark: Fix license header For some reason, I got it wrong. Reviewed-by: TrustMe --- tests/benchmarks/qhostinfo/main.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tests/benchmarks/qhostinfo/main.cpp b/tests/benchmarks/qhostinfo/main.cpp index 389443b..80d0fd8 100644 --- a/tests/benchmarks/qhostinfo/main.cpp +++ b/tests/benchmarks/qhostinfo/main.cpp @@ -7,11 +7,11 @@ ** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -25,19 +25,21 @@ ** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** ** If you have questions regarding the use of this file, please contact ** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ + + #include #include #include -- cgit v0.12 From 2a988be53a60156cc5210b251e7a9904426c823c Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 4 Jan 2010 16:34:00 +0100 Subject: Fix typo in QFSFileEnginePrivate::canonicalized Reviewed-by: TrustMe --- src/corelib/io/qfsfileengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index e4c4e3f..c064d5a 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -144,7 +144,7 @@ QString QFSFileEnginePrivate::canonicalized(const QString &path) return path; #endif // Mac OS X 10.5.x doesn't support the realpath(X,0) extenstion we use here. -#if defined(Q_OS_LINIX) || defined(Q_OS_SYMBIAN) +#if defined(Q_OS_LINUX) || defined(Q_OS_SYMBIAN) char *ret = realpath(path.toLocal8Bit().constData(), (char*)0); if (ret) { QString canonicalPath = QDir::cleanPath(QString::fromLocal8Bit(ret)); -- cgit v0.12 From 5c2d319ce56fa7914afe52ae13f1a24c03608629 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Mon, 4 Jan 2010 17:25:38 +0100 Subject: Make the ShowDirsOnly option work in QFileDialog. This option was simply not implemented at all so it didn't work. Task-number:QTBUG-6558 Reviewed-by:ogoffart --- src/gui/dialogs/qfiledialog.cpp | 3 ++ tests/auto/qfiledialog2/tst_qfiledialog2.cpp | 68 ++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index 45a410f..d952c34 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -669,6 +669,9 @@ void QFileDialog::setOptions(Options options) } if (changed & HideNameFilterDetails) setNameFilters(d->nameFilters); + + if (changed & ShowDirsOnly) + setFilter((options & ShowDirsOnly) ? filter() & ~QDir::Files : filter() | QDir::Files); } QFileDialog::Options QFileDialog::options() const diff --git a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp index 83ddd39..83380a5 100644 --- a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp @@ -130,6 +130,7 @@ private slots: void task259105_filtersCornerCases(); void QTBUG4419_lineEditSelectAll(); + void QTBUG6558_showDirsOnly(); private: QByteArray userSettings; @@ -1040,5 +1041,72 @@ void tst_QFiledialog::QTBUG4419_lineEditSelectAll() QCOMPARE(tempPath + QChar('/') + lineEdit->selectedText(), t->fileName()); } +void tst_QFiledialog::QTBUG6558_showDirsOnly() +{ + const QString tempPath = QDir::tempPath(); + QDir dirTemp(tempPath); + const QString tempName = QLatin1String("showDirsOnly.") + QString::number(qrand()); + dirTemp.mkdir(tempName); + dirTemp.cd(tempName); + QTRY_VERIFY(dirTemp.exists()); + + const QString dirPath = dirTemp.absolutePath(); + QDir dir(dirPath); + + //We create two dirs + dir.mkdir("a"); + dir.mkdir("b"); + + //Create a file + QFile tempFile(dirPath + "/plop.txt"); + tempFile.open(QIODevice::WriteOnly | QIODevice::Text); + QTextStream out(&tempFile); + out << "The magic number is: " << 49 << "\n"; + tempFile.close(); + + QNonNativeFileDialog fd(0, "TestFileDialog"); + + fd.setDirectory(dir.absolutePath()); + fd.setViewMode(QFileDialog::List); + fd.setAcceptMode(QFileDialog::AcceptSave); + fd.setOption(QFileDialog::ShowDirsOnly, true); + fd.show(); + + QApplication::setActiveWindow(&fd); + QTest::qWaitForWindowShown(&fd); + QTRY_COMPARE(fd.isVisible(), true); + QTRY_COMPARE(QApplication::activeWindow(), static_cast(&fd)); + + QFileSystemModel *model = qFindChild(&fd, "qt_filesystem_model"); + QTRY_COMPARE(model->rowCount(model->index(dir.absolutePath())), 2); + + fd.setOption(QFileDialog::ShowDirsOnly, false); + QTRY_COMPARE(model->rowCount(model->index(dir.absolutePath())), 3); + + fd.setOption(QFileDialog::ShowDirsOnly, true); + QTRY_COMPARE(model->rowCount(model->index(dir.absolutePath())), 2); + + fd.setFileMode(QFileDialog::DirectoryOnly); + QTRY_COMPARE(model->rowCount(model->index(dir.absolutePath())), 2); + QTRY_COMPARE(bool(fd.options() & QFileDialog::ShowDirsOnly), true); + + fd.setFileMode(QFileDialog::AnyFile); + QTRY_COMPARE(model->rowCount(model->index(dir.absolutePath())), 3); + QTRY_COMPARE(bool(fd.options() & QFileDialog::ShowDirsOnly), false); + + fd.setDirectory(QDir::homePath()); + + //We remove the dirs + dir.rmdir("a"); + dir.rmdir("b"); + + //we delete the file + tempFile.remove(); + + dirTemp.cdUp(); + dirTemp.rmdir(tempName); + QTRY_VERIFY(!dir.exists()); +} + QTEST_MAIN(tst_QFiledialog) #include "tst_qfiledialog2.moc" -- cgit v0.12 From f019f3cf807e3c804bba3ef5598ea69adbb39e8b Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 5 Jan 2010 07:50:44 +1000 Subject: BitsPerSample should default to 1 in TIFF files. Task-number: QTBUG-6870 Reviewed-by: Lorn Potter --- src/plugins/imageformats/tiff/qtiffhandler.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/plugins/imageformats/tiff/qtiffhandler.cpp b/src/plugins/imageformats/tiff/qtiffhandler.cpp index 9538745..7ac9722 100644 --- a/src/plugins/imageformats/tiff/qtiffhandler.cpp +++ b/src/plugins/imageformats/tiff/qtiffhandler.cpp @@ -192,11 +192,10 @@ bool QTiffHandler::read(QImage *image) return false; } + // BitsPerSample defaults to 1 according to the TIFF spec. uint16 bitPerSample; - if (!TIFFGetField(tiff, TIFFTAG_BITSPERSAMPLE, &bitPerSample)) { - TIFFClose(tiff); - return false; - } + if (!TIFFGetField(tiff, TIFFTAG_BITSPERSAMPLE, &bitPerSample)) + bitPerSample = 1; bool grayscale = photometric == PHOTOMETRIC_MINISBLACK || photometric == PHOTOMETRIC_MINISWHITE; if (grayscale && bitPerSample == 1) { -- cgit v0.12 From 619392c059326c11c24c1092ab62dd091114a0ab Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 4 Jan 2010 14:08:37 +1000 Subject: Remove QGLShareRegister and transfer its functionality to QGLContextGroup Task-number: QT-2600 Reviewed-by: Samuel --- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 15 ++++++---- src/opengl/qgl.cpp | 28 +++++++++--------- src/opengl/qgl.h | 2 +- src/opengl/qgl_egl.cpp | 2 +- src/opengl/qgl_mac.mm | 2 +- src/opengl/qgl_p.h | 25 ++++++---------- src/opengl/qgl_win.cpp | 2 +- src/opengl/qgl_x11.cpp | 2 +- src/opengl/qglpixelbuffer.cpp | 2 +- tests/auto/qgl/tst_qgl.cpp | 33 +--------------------- 10 files changed, 40 insertions(+), 73 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index a41d439..7655971 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -124,17 +124,20 @@ public: public Q_SLOTS: void contextDestroyed(const QGLContext *context) { if (context == ctx) { - QList shares = qgl_share_reg()->shares(ctx); - if (shares.isEmpty()) { - glDeleteFramebuffers(1, &m_fbo); - if (m_width || m_height) - glDeleteTextures(1, &m_texture); + const QGLContext *nextCtx = qt_gl_transfer_context(ctx); + if (!nextCtx) { + // the context may not be current, so we cannot directly + // destroy the fbo and texture here, but since the context + // is about to be destroyed, the GL server will do the + // clean up for us anyway + m_fbo = 0; + m_texture = 0; ctx = 0; } else { // since the context holding the texture is shared, and // about to be destroyed, we have to transfer ownership // of the texture to one of the share contexts - ctx = const_cast((ctx == shares.at(0)) ? shares.at(1) : shares.at(0)); + ctx = const_cast(nextCtx); } } } diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index f5e46de..c3e4a2e 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1436,6 +1436,18 @@ void QGLContextGroup::removeGuard(QGLSharedResourceGuard *guard) m_guards = guard->m_next; } +const QGLContext *qt_gl_transfer_context(const QGLContext *ctx) +{ + if (!ctx) + return 0; + QList shares + (QGLContextPrivate::contextGroup(ctx)->shares()); + if (shares.size() >= 2) + return (ctx == shares.at(0)) ? shares.at(1) : shares.at(0); + else + return 0; +} + QGLContextPrivate::~QGLContextPrivate() { if (!group->m_refs.deref()) { @@ -1731,12 +1743,6 @@ struct DDSFormat { #define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 #endif -Q_GLOBAL_STATIC(QGLShareRegister, _qgl_share_reg) -Q_OPENGL_EXPORT QGLShareRegister* qgl_share_reg() -{ - return _qgl_share_reg(); -} - /*! \class QGLContext \brief The QGLContext class encapsulates an OpenGL rendering context. @@ -2985,7 +2991,7 @@ bool QGLContext::create(const QGLContext* shareContext) wd->usesDoubleBufferedGLContext = d->glFormat.doubleBuffer(); } if (d->sharing) // ok, we managed to share - qgl_share_reg()->addShare(this, shareContext); + QGLContextGroup::addShare(this, shareContext); return d->valid; } @@ -4971,7 +4977,7 @@ Q_OPENGL_EXPORT const QString qt_gl_library_name() } #endif -void QGLShareRegister::addShare(const QGLContext *context, const QGLContext *share) { +void QGLContextGroup::addShare(const QGLContext *context, const QGLContext *share) { Q_ASSERT(context && share); if (context->d_ptr->group == share->d_ptr->group) return; @@ -4992,11 +4998,7 @@ void QGLShareRegister::addShare(const QGLContext *context, const QGLContext *sha group->m_shares.append(context); } -QList QGLShareRegister::shares(const QGLContext *context) { - return context->d_ptr->group->m_shares; -} - -void QGLShareRegister::removeShare(const QGLContext *context) { +void QGLContextGroup::removeShare(const QGLContext *context) { // Remove the context from the group. QGLContextGroup *group = context->d_ptr->group; if (group->m_shares.isEmpty()) diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index b6cd128..932ea7e 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -398,7 +398,7 @@ private: friend class QGLPixmapData; friend class QGLPixmapFilterBase; friend class QGLTextureGlyphCache; - friend class QGLShareRegister; + friend class QGLContextGroup; friend class QGLSharedResourceGuard; friend class QGLPixmapBlurFilter; friend QGLFormat::OpenGLVersionFlags QGLFormat::openGLVersionFlags(); diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp index 839e8eb..084db32 100644 --- a/src/opengl/qgl_egl.cpp +++ b/src/opengl/qgl_egl.cpp @@ -152,7 +152,7 @@ void QGLContext::reset() d->valid = false; d->transpColor = QColor(); d->initDone = false; - qgl_share_reg()->removeShare(this); + QGLContextGroup::removeShare(this); } void QGLContext::makeCurrent() diff --git a/src/opengl/qgl_mac.mm b/src/opengl/qgl_mac.mm index 4dd822d..8ecc48b 100644 --- a/src/opengl/qgl_mac.mm +++ b/src/opengl/qgl_mac.mm @@ -476,7 +476,7 @@ void QGLContext::reset() d->valid = false; d->transpColor = QColor(); d->initDone = false; - qgl_share_reg()->removeShare(this); + QGLContextGroup::removeShare(this); } void QGLContext::makeCurrent() diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 834ff96..fcfe791 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -222,9 +222,8 @@ class QGLSharedResourceGuard; typedef QHash QGLDDSCache; // QGLContextPrivate has the responsibility of creating context groups. -// QGLContextPrivate and QGLShareRegister will both maintain the reference counter and destroy +// QGLContextPrivate maintains the reference counter and destroys // context groups when needed. -// QGLShareRegister has the responsibility of keeping the context pointer up to date. class QGLContextGroup { public: @@ -233,9 +232,13 @@ public: QGLExtensionFuncs &extensionFuncs() {return m_extensionFuncs;} const QGLContext *context() const {return m_context;} bool isSharing() const { return m_shares.size() >= 2; } + QList shares() const { return m_shares; } void addGuard(QGLSharedResourceGuard *guard); void removeGuard(QGLSharedResourceGuard *guard); + + static void addShare(const QGLContext *context, const QGLContext *share); + static void removeShare(const QGLContext *context); private: QGLContextGroup(const QGLContext *context) : m_context(context), m_guards(0), m_refs(1) { } @@ -249,12 +252,15 @@ private: void cleanupResources(const QGLContext *ctx); - friend class QGLShareRegister; friend class QGLContext; friend class QGLContextPrivate; friend class QGLContextResource; }; +// Get the context that resources for "ctx" will transfer to once +// "ctx" is destroyed. Returns null if nothing is sharing with ctx. +Q_OPENGL_EXPORT const QGLContext *qt_gl_transfer_context(const QGLContext *); + class QGLTexture; // This probably needs to grow to GL_MAX_VERTEX_ATTRIBS, but 3 is ok for now as that's @@ -404,19 +410,6 @@ public: Q_DECLARE_OPERATORS_FOR_FLAGS(QGLExtensions::Extensions) -class Q_OPENGL_EXPORT QGLShareRegister -{ -public: - QGLShareRegister() {} - ~QGLShareRegister() {} - - void addShare(const QGLContext *context, const QGLContext *share); - QList shares(const QGLContext *context); - void removeShare(const QGLContext *context); -}; - -extern Q_OPENGL_EXPORT QGLShareRegister* qgl_share_reg(); - // Temporarily make a context current if not already current or // shared with the current contex. The previous context is made // current when the object goes out of scope. diff --git a/src/opengl/qgl_win.cpp b/src/opengl/qgl_win.cpp index 5b5820a..f80025d 100644 --- a/src/opengl/qgl_win.cpp +++ b/src/opengl/qgl_win.cpp @@ -1145,7 +1145,7 @@ void QGLContext::reset() delete d->cmap; d->cmap = 0; d->initDone = false; - qgl_share_reg()->removeShare(this); + QGLContextGroup::removeShare(this); } // diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp index 9c3fc79..8173bec 100644 --- a/src/opengl/qgl_x11.cpp +++ b/src/opengl/qgl_x11.cpp @@ -825,7 +825,7 @@ void QGLContext::reset() d->valid = false; d->transpColor = QColor(); d->initDone = false; - qgl_share_reg()->removeShare(this); + QGLContextGroup::removeShare(this); } diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp index 7c97ebb..fab6efc 100644 --- a/src/opengl/qglpixelbuffer.cpp +++ b/src/opengl/qglpixelbuffer.cpp @@ -127,7 +127,7 @@ void QGLPixelBufferPrivate::common_init(const QSize &size, const QGLFormat &form qctx = new QGLContext(format); qctx->d_func()->sharing = (shareWidget != 0); if (shareWidget != 0 && shareWidget->d_func()->glcx) { - qgl_share_reg()->addShare(qctx, shareWidget->d_func()->glcx); + QGLContextGroup::addShare(qctx, shareWidget->d_func()->glcx); shareWidget->d_func()->glcx->d_func()->sharing = true; } diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index 532e550..a61eb8d 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -1824,17 +1824,12 @@ Q_GLOBAL_STATIC_WITH_ARGS(QGLContextResource, qt_shared_test, (qt_shared_test_fr void tst_QGL::shareRegister() { #ifdef QT_BUILD_INTERNAL - QGLShareRegister *shareReg = qgl_share_reg(); - QVERIFY(shareReg != 0); - // Create a context. QGLWidget *glw1 = new QGLWidget(); glw1->makeCurrent(); // Nothing should be sharing with glw1's context yet. - QList list; - list = shareReg->shares(glw1->context()); - QCOMPARE(list.size(), 0); + QVERIFY(!glw1->isSharing()); // Create a guard for the first context. QGLSharedResourceGuard guard(glw1->context()); @@ -1867,16 +1862,6 @@ void tst_QGL::shareRegister() QVERIFY(guard.context() == glw1->context()); QVERIFY(guard.id() == 3); - // Now there are two items in the share lists. - list = shareReg->shares(glw1->context()); - QCOMPARE(list.size(), 2); - QVERIFY(list.contains(glw1->context())); - QVERIFY(list.contains(glw2->context())); - list = shareReg->shares(glw2->context()); - QCOMPARE(list.size(), 2); - QVERIFY(list.contains(glw1->context())); - QVERIFY(list.contains(glw2->context())); - // Check the sharing relationships. QVERIFY(QGLContext::areSharing(glw1->context(), glw1->context())); QVERIFY(QGLContext::areSharing(glw2->context(), glw2->context())); @@ -1902,18 +1887,6 @@ void tst_QGL::shareRegister() QVERIFY(qt_shared_test()->value(glw2->context()) == res1); QVERIFY(qt_shared_test()->value(glw3->context()) == res3); - // First two should still be sharing, but third is in its own list. - list = shareReg->shares(glw1->context()); - QCOMPARE(list.size(), 2); - QVERIFY(list.contains(glw1->context())); - QVERIFY(list.contains(glw2->context())); - list = shareReg->shares(glw2->context()); - QCOMPARE(list.size(), 2); - QVERIFY(list.contains(glw1->context())); - QVERIFY(list.contains(glw2->context())); - list = shareReg->shares(glw3->context()); - QCOMPARE(list.size(), 0); - // Check the sharing relationships again. QVERIFY(QGLContext::areSharing(glw1->context(), glw1->context())); QVERIFY(QGLContext::areSharing(glw2->context(), glw2->context())); @@ -1951,10 +1924,6 @@ void tst_QGL::shareRegister() QVERIFY(guard3.context() == glw3->context()); QVERIFY(guard3.id() == 5); - // Re-check the share list for the second context (should be empty now). - list = shareReg->shares(glw2->context()); - QCOMPARE(list.size(), 0); - // Clean up and check that the resources are properly deleted. delete glw2; QCOMPARE(tst_QGLResource::deletions, 1); -- cgit v0.12 From 4520a644f3bb82c650db8280a812fcd67ad815bf Mon Sep 17 00:00:00 2001 From: Bill King Date: Tue, 5 Jan 2010 11:47:40 +1000 Subject: (ODBC) Handle drivers that return SQL_NO_DATA for exec success. Most drivers return SQL_SUCCESS when executing a delete statement for example, but FreeTDS returns SQL_NO_DATA, which is technically correct, but doesn't follow the practice of other drivers. Task-number: QTBUG-4896 Reviewed-by: Justin McPherson --- src/sql/drivers/odbc/qsql_odbc.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index fdf0c2c..55f0696 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -888,12 +888,17 @@ bool QODBCResult::reset (const QString& query) (SQLCHAR*) query8.constData(), (SQLINTEGER) query8.length()); #endif - if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) { + if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO && r!= SQL_NO_DATA) { setLastError(qMakeError(QCoreApplication::translate("QODBCResult", "Unable to execute statement"), QSqlError::StatementError, d)); return false; } + if(r == SQL_NO_DATA) { + setSelect(false); + return true; + } + SQLINTEGER isScrollable, bufferLength; r = SQLGetStmtAttr(d->hStmt, SQL_ATTR_CURSOR_SCROLLABLE, &isScrollable, SQL_IS_INTEGER, &bufferLength); if(r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) -- cgit v0.12 From d307ecedc046e2f4a5dd51d67da21309781c4964 Mon Sep 17 00:00:00 2001 From: Bill King Date: Tue, 5 Jan 2010 13:42:10 +1000 Subject: (mysql) Add test to the system so it's there for use later. The test passes/doesn't fail, but is a useful test nonetheless, so adding it to the testsystem anyway. Task-number: QTBUG-6852 --- tests/auto/qsqlquery/tst_qsqlquery.cpp | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp index 2a55c32..5b6da30 100644 --- a/tests/auto/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp @@ -203,6 +203,8 @@ private slots: void QTBUG_6421(); void QTBUG_6618_data() { generic_data("QODBC"); } void QTBUG_6618(); + void QTBUG_6852_data() { generic_data("QMYSQL"); } + void QTBUG_6852(); private: // returns all database connections @@ -2985,5 +2987,41 @@ void tst_QSqlQuery::QTBUG_6618() QVERIFY(q.lastError().text().contains(errorString)); } +void tst_QSqlQuery::QTBUG_6852() +{ + QFETCH( QString, dbName ); + QSqlDatabase db = QSqlDatabase::database( dbName ); + CHECK_DATABASE( db ); + if ( tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 0 ).toInt()<5 ) + QSKIP( "Test requires MySQL >= 5.0", SkipSingle ); + + QSqlQuery q(db); + QString tableName(qTableName(QLatin1String("bug6421"))), procName(qTableName(QLatin1String("bug6421_proc"))); + + QVERIFY_SQL(q, exec("DROP PROCEDURE IF EXISTS "+procName)); + tst_Databases::safeDropTable(db, tableName); + QVERIFY_SQL(q, exec("CREATE TABLE "+tableName+"(\n" + "MainKey INT NOT NULL,\n" + "OtherTextCol VARCHAR(45) NOT NULL,\n" + "PRIMARY KEY(`MainKey`))")); + QVERIFY_SQL(q, exec("INSERT INTO "+tableName+" VALUES(0, \"Disabled\")")); + QVERIFY_SQL(q, exec("INSERT INTO "+tableName+" VALUES(5, \"Error Only\")")); + QVERIFY_SQL(q, exec("INSERT INTO "+tableName+" VALUES(10, \"Enabled\")")); + QVERIFY_SQL(q, exec("INSERT INTO "+tableName+" VALUES(15, \"Always\")")); + QVERIFY_SQL(q, exec("CREATE PROCEDURE "+procName+"()\n" + "READS SQL DATA\n" + "BEGIN\n" + " SET @st = 'SELECT MainKey, OtherTextCol from "+tableName+"';\n" + " PREPARE stmt from @st;\n" + " EXECUTE stmt;\n" + "END;")); + + QVERIFY_SQL(q, exec("CALL "+procName+"()")); + QVERIFY_SQL(q, next()); + QCOMPARE(q.value(0).toInt(), 0); + QCOMPARE(q.value(1).toString(), QLatin1String("Disabled")); +} + + QTEST_MAIN( tst_QSqlQuery ) #include "tst_qsqlquery.moc" -- cgit v0.12 From 6893e329aa640b3baf156dbcedfc8706f6f9a450 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Mon, 4 Jan 2010 15:48:31 +0100 Subject: Move QGLTextureGlyphCache into it's own file Reviewed-By: Samuel --- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 239 +-------------------- .../gl2paintengineex/qpaintengineex_opengl2_p.h | 6 + .../gl2paintengineex/qtextureglyphcache_gl.cpp | 216 +++++++++++++++++++ .../gl2paintengineex/qtextureglyphcache_gl_p.h | 123 +++++++++++ src/opengl/opengl.pro | 6 +- 5 files changed, 350 insertions(+), 240 deletions(-) create mode 100644 src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp create mode 100644 src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 7655971..b3b5fe1 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -75,15 +75,14 @@ #include #include #include -#include #include #include #include "qglgradientcache_p.h" #include "qglengineshadermanager_p.h" #include "qgl2pexvertexarray_p.h" - #include "qtriangulatingstroker_p.h" +#include "qtextureglyphcache_gl_p.h" #include @@ -91,240 +90,6 @@ QT_BEGIN_NAMESPACE //#define QT_GL_NO_SCISSOR_TEST -static const GLuint GL_STENCIL_HIGH_BIT = 0x80; -static const GLuint QT_BRUSH_TEXTURE_UNIT = 0; -static const GLuint QT_IMAGE_TEXTURE_UNIT = 0; //Can be the same as brush texture unit -static const GLuint QT_MASK_TEXTURE_UNIT = 1; -static const GLuint QT_BACKGROUND_TEXTURE_UNIT = 2; - -#ifdef Q_WS_WIN -extern Q_GUI_EXPORT bool qt_cleartype_enabled; -#endif - -class QGLTextureGlyphCache : public QObject, public QTextureGlyphCache -{ - Q_OBJECT -public: - QGLTextureGlyphCache(QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix); - ~QGLTextureGlyphCache(); - - virtual void createTextureData(int width, int height); - virtual void resizeTextureData(int width, int height); - virtual void fillTexture(const Coord &c, glyph_t glyph); - virtual int glyphMargin() const; - - inline GLuint texture() const { return m_texture; } - - inline int width() const { return m_width; } - inline int height() const { return m_height; } - - inline void setPaintEnginePrivate(QGL2PaintEngineExPrivate *p) { pex = p; } - - -public Q_SLOTS: - void contextDestroyed(const QGLContext *context) { - if (context == ctx) { - const QGLContext *nextCtx = qt_gl_transfer_context(ctx); - if (!nextCtx) { - // the context may not be current, so we cannot directly - // destroy the fbo and texture here, but since the context - // is about to be destroyed, the GL server will do the - // clean up for us anyway - m_fbo = 0; - m_texture = 0; - ctx = 0; - } else { - // since the context holding the texture is shared, and - // about to be destroyed, we have to transfer ownership - // of the texture to one of the share contexts - ctx = const_cast(nextCtx); - } - } - } - -private: - QGLContext *ctx; - - QGL2PaintEngineExPrivate *pex; - - GLuint m_texture; - GLuint m_fbo; - - int m_width; - int m_height; - - QGLShaderProgram *m_program; -}; - -QGLTextureGlyphCache::QGLTextureGlyphCache(QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix) - : QTextureGlyphCache(type, matrix) - , ctx(context) - , m_width(0) - , m_height(0) -{ - glGenFramebuffers(1, &m_fbo); - connect(QGLSignalProxy::instance(), SIGNAL(aboutToDestroyContext(const QGLContext*)), - SLOT(contextDestroyed(const QGLContext*))); -} - -QGLTextureGlyphCache::~QGLTextureGlyphCache() -{ - if (ctx) { - QGLShareContextScope scope(ctx); - glDeleteFramebuffers(1, &m_fbo); - - if (m_width || m_height) - glDeleteTextures(1, &m_texture); - } -} - -void QGLTextureGlyphCache::createTextureData(int width, int height) -{ - glGenTextures(1, &m_texture); - glBindTexture(GL_TEXTURE_2D, m_texture); - - m_width = width; - m_height = height; - - QVarLengthArray data(width * height); - for (int i = 0; i < data.size(); ++i) - data[i] = 0; - - if (m_type == QFontEngineGlyphCache::Raster_RGBMask) - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, &data[0]); - else - glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, &data[0]); - - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); -} - -void QGLTextureGlyphCache::resizeTextureData(int width, int height) -{ - // ### the QTextureGlyphCache API needs to be reworked to allow - // ### resizeTextureData to fail - - int oldWidth = m_width; - int oldHeight = m_height; - - GLuint oldTexture = m_texture; - createTextureData(width, height); - - glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_fbo); - - GLuint tmp_texture; - glGenTextures(1, &tmp_texture); - glBindTexture(GL_TEXTURE_2D, tmp_texture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, oldWidth, oldHeight, 0, - GL_RGBA, GL_UNSIGNED_BYTE, NULL); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glBindTexture(GL_TEXTURE_2D, 0); - glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, - GL_TEXTURE_2D, tmp_texture, 0); - - glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); - glBindTexture(GL_TEXTURE_2D, oldTexture); - - pex->transferMode(BrushDrawingMode); - - glDisable(GL_STENCIL_TEST); - glDisable(GL_DEPTH_TEST); - glDisable(GL_SCISSOR_TEST); - glDisable(GL_BLEND); - - glViewport(0, 0, oldWidth, oldHeight); - - float vertexCoordinateArray[] = { -1, -1, 1, -1, 1, 1, -1, 1 }; - float textureCoordinateArray[] = { 0, 0, 1, 0, 1, 1, 0, 1 }; - - glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, vertexCoordinateArray); - glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray); - - pex->shaderManager->useBlitProgram(); - pex->shaderManager->blitProgram()->setUniformValue("imageTexture", QT_IMAGE_TEXTURE_UNIT); - - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - - glBindTexture(GL_TEXTURE_2D, m_texture); - -#ifdef QT_OPENGL_ES_2 - QDataBuffer buffer(4*oldWidth*oldHeight); - buffer.resize(4*oldWidth*oldHeight); - glReadPixels(0, 0, oldWidth, oldHeight, GL_RGBA, GL_UNSIGNED_BYTE, buffer.data()); - - // do an in-place conversion from GL_RGBA to GL_ALPHA - for (int i=0; id_ptr->current_fbo); - - glViewport(0, 0, pex->width, pex->height); - pex->updateClipScissorTest(); -} - -void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph) -{ - QImage mask = textureMapForGlyph(glyph); - const int maskWidth = mask.width(); - const int maskHeight = mask.height(); - - if (mask.format() == QImage::Format_Mono) { - mask = mask.convertToFormat(QImage::Format_Indexed8); - for (int y = 0; y < maskHeight; ++y) { - uchar *src = (uchar *) mask.scanLine(y); - for (int x = 0; x < maskWidth; ++x) - src[x] = -src[x]; // convert 0 and 1 into 0 and 255 - } - } - - - glBindTexture(GL_TEXTURE_2D, m_texture); - if (mask.format() == QImage::Format_RGB32) { - glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, GL_BGRA, GL_UNSIGNED_BYTE, mask.bits()); - } else { -#ifdef QT_OPENGL_ES2 - glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, GL_ALPHA, GL_UNSIGNED_BYTE, mask.bits()); -#else - // glTexSubImage2D() might cause some garbage to appear in the texture if the mask width is - // not a multiple of four bytes. The bug appeared on a computer with 32-bit Windows Vista - // and nVidia GeForce 8500GT. GL_UNPACK_ALIGNMENT is set to four bytes, 'mask' has a - // multiple of four bytes per line, and most of the glyph shows up correctly in the - // texture, which makes me think that this is a driver bug. - // One workaround is to make sure the mask width is a multiple of four bytes, for instance - // by converting it to a format with four bytes per pixel. Another is to copy one line at a - // time. - - for (int i = 0; i < maskHeight; ++i) - glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y + i, maskWidth, 1, GL_ALPHA, GL_UNSIGNED_BYTE, mask.scanLine(i)); -#endif - } -} - -int QGLTextureGlyphCache::glyphMargin() const -{ -#if defined(Q_WS_MAC) - return 2; -#elif defined (Q_WS_X11) - return 0; -#else - return m_type == QFontEngineGlyphCache::Raster_RGBMask ? 2 : 0; -#endif -} - extern QImage qt_imageForBrush(int brushStyle, bool invert); ////////////////////////////////// Private Methods ////////////////////////////////////////// @@ -2261,5 +2026,3 @@ QOpenGL2PaintEngineState::~QOpenGL2PaintEngineState() } QT_END_NAMESPACE - -#include "qpaintengineex_opengl2.moc" diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 7d5cb52..eaae187 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -73,6 +73,12 @@ enum EngineMode { QT_BEGIN_NAMESPACE +#define GL_STENCIL_HIGH_BIT GLuint(0x80) +#define QT_BRUSH_TEXTURE_UNIT GLuint(0) +#define QT_IMAGE_TEXTURE_UNIT GLuint(0) //Can be the same as brush texture unit +#define QT_MASK_TEXTURE_UNIT GLuint(1) +#define QT_BACKGROUND_TEXTURE_UNIT GLuint(2) + class QGL2PaintEngineExPrivate; diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp new file mode 100644 index 0000000..047876f --- /dev/null +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp @@ -0,0 +1,216 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenGL module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qtextureglyphcache_gl_p.h" +#include "qpaintengineex_opengl2_p.h" + +#ifdef Q_WS_WIN +extern Q_GUI_EXPORT bool qt_cleartype_enabled; +#endif + +QGLTextureGlyphCache::QGLTextureGlyphCache(QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix) + : QTextureGlyphCache(type, matrix) + , ctx(context) + , m_width(0) + , m_height(0) +{ + glGenFramebuffers(1, &m_fbo); + connect(QGLSignalProxy::instance(), SIGNAL(aboutToDestroyContext(const QGLContext*)), + SLOT(contextDestroyed(const QGLContext*))); +} + +QGLTextureGlyphCache::~QGLTextureGlyphCache() +{ + if (ctx) { + QGLShareContextScope scope(ctx); + glDeleteFramebuffers(1, &m_fbo); + + if (m_width || m_height) + glDeleteTextures(1, &m_texture); + } +} + +void QGLTextureGlyphCache::createTextureData(int width, int height) +{ + glGenTextures(1, &m_texture); + glBindTexture(GL_TEXTURE_2D, m_texture); + + m_width = width; + m_height = height; + + QVarLengthArray data(width * height); + for (int i = 0; i < data.size(); ++i) + data[i] = 0; + + if (m_type == QFontEngineGlyphCache::Raster_RGBMask) + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, &data[0]); + else + glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, &data[0]); + + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); +} + +void QGLTextureGlyphCache::resizeTextureData(int width, int height) +{ + // ### the QTextureGlyphCache API needs to be reworked to allow + // ### resizeTextureData to fail + + int oldWidth = m_width; + int oldHeight = m_height; + + GLuint oldTexture = m_texture; + createTextureData(width, height); + + glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_fbo); + + GLuint tmp_texture; + glGenTextures(1, &tmp_texture); + glBindTexture(GL_TEXTURE_2D, tmp_texture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, oldWidth, oldHeight, 0, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glBindTexture(GL_TEXTURE_2D, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, + GL_TEXTURE_2D, tmp_texture, 0); + + glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); + glBindTexture(GL_TEXTURE_2D, oldTexture); + + pex->transferMode(BrushDrawingMode); + + glDisable(GL_STENCIL_TEST); + glDisable(GL_DEPTH_TEST); + glDisable(GL_SCISSOR_TEST); + glDisable(GL_BLEND); + + glViewport(0, 0, oldWidth, oldHeight); + + float vertexCoordinateArray[] = { -1, -1, 1, -1, 1, 1, -1, 1 }; + float textureCoordinateArray[] = { 0, 0, 1, 0, 1, 1, 0, 1 }; + + glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, vertexCoordinateArray); + glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray); + + pex->shaderManager->useBlitProgram(); + pex->shaderManager->blitProgram()->setUniformValue("imageTexture", QT_IMAGE_TEXTURE_UNIT); + + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + + glBindTexture(GL_TEXTURE_2D, m_texture); + +#ifdef QT_OPENGL_ES_2 + QDataBuffer buffer(4*oldWidth*oldHeight); + buffer.resize(4*oldWidth*oldHeight); + glReadPixels(0, 0, oldWidth, oldHeight, GL_RGBA, GL_UNSIGNED_BYTE, buffer.data()); + + // do an in-place conversion from GL_RGBA to GL_ALPHA + for (int i=0; id_ptr->current_fbo); + + glViewport(0, 0, pex->width, pex->height); + pex->updateClipScissorTest(); +} + +void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph) +{ + QImage mask = textureMapForGlyph(glyph); + const int maskWidth = mask.width(); + const int maskHeight = mask.height(); + + if (mask.format() == QImage::Format_Mono) { + mask = mask.convertToFormat(QImage::Format_Indexed8); + for (int y = 0; y < maskHeight; ++y) { + uchar *src = (uchar *) mask.scanLine(y); + for (int x = 0; x < maskWidth; ++x) + src[x] = -src[x]; // convert 0 and 1 into 0 and 255 + } + } + + + glBindTexture(GL_TEXTURE_2D, m_texture); + if (mask.format() == QImage::Format_RGB32) { + glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, GL_BGRA, GL_UNSIGNED_BYTE, mask.bits()); + } else { +#ifdef QT_OPENGL_ES2 + glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, GL_ALPHA, GL_UNSIGNED_BYTE, mask.bits()); +#else + // glTexSubImage2D() might cause some garbage to appear in the texture if the mask width is + // not a multiple of four bytes. The bug appeared on a computer with 32-bit Windows Vista + // and nVidia GeForce 8500GT. GL_UNPACK_ALIGNMENT is set to four bytes, 'mask' has a + // multiple of four bytes per line, and most of the glyph shows up correctly in the + // texture, which makes me think that this is a driver bug. + // One workaround is to make sure the mask width is a multiple of four bytes, for instance + // by converting it to a format with four bytes per pixel. Another is to copy one line at a + // time. + + for (int i = 0; i < maskHeight; ++i) + glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y + i, maskWidth, 1, GL_ALPHA, GL_UNSIGNED_BYTE, mask.scanLine(i)); +#endif + } +} + +int QGLTextureGlyphCache::glyphMargin() const +{ +#if defined(Q_WS_MAC) + return 2; +#elif defined (Q_WS_X11) + return 0; +#else + return m_type == QFontEngineGlyphCache::Raster_RGBMask ? 2 : 0; +#endif +} diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h new file mode 100644 index 0000000..393893c --- /dev/null +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenGL module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTEXTUREGLYPHCACHE_GL_P_H +#define QTEXTUREGLYPHCACHE_GL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the QLibrary class. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + + +QT_BEGIN_NAMESPACE + +class QGL2PaintEngineExPrivate; + +class QGLTextureGlyphCache : public QObject, public QTextureGlyphCache +{ + Q_OBJECT +public: + QGLTextureGlyphCache(QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix); + ~QGLTextureGlyphCache(); + + virtual void createTextureData(int width, int height); + virtual void resizeTextureData(int width, int height); + virtual void fillTexture(const Coord &c, glyph_t glyph); + virtual int glyphMargin() const; + + inline GLuint texture() const { return m_texture; } + + inline int width() const { return m_width; } + inline int height() const { return m_height; } + + inline void setPaintEnginePrivate(QGL2PaintEngineExPrivate *p) { pex = p; } + + +public Q_SLOTS: + void contextDestroyed(const QGLContext *context) { + if (context == ctx) { + const QGLContext *nextCtx = qt_gl_transfer_context(ctx); + if (!nextCtx) { + // the context may not be current, so we cannot directly + // destroy the fbo and texture here, but since the context + // is about to be destroyed, the GL server will do the + // clean up for us anyway + m_fbo = 0; + m_texture = 0; + ctx = 0; + } else { + // since the context holding the texture is shared, and + // about to be destroyed, we have to transfer ownership + // of the texture to one of the share contexts + ctx = const_cast(nextCtx); + } + } + } + +private: + QGLContext *ctx; + + QGL2PaintEngineExPrivate *pex; + + GLuint m_texture; + GLuint m_fbo; + + int m_width; + int m_height; + + QGLShaderProgram *m_program; +}; + +QT_END_NAMESPACE + +#endif + diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index b2474ed..6076891 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -54,7 +54,8 @@ SOURCES += qgl.cpp \ gl2paintengineex/qpaintengineex_opengl2_p.h \ gl2paintengineex/qglengineshadersource_p.h \ gl2paintengineex/qglcustomshaderstage_p.h \ - gl2paintengineex/qtriangulatingstroker_p.h + gl2paintengineex/qtriangulatingstroker_p.h \ + gl2paintengineex/qtextureglyphcache_gl_p.h SOURCES += qglshaderprogram.cpp \ qglpixmapfilter.cpp \ @@ -67,7 +68,8 @@ SOURCES += qgl.cpp \ gl2paintengineex/qgl2pexvertexarray.cpp \ gl2paintengineex/qpaintengineex_opengl2.cpp \ gl2paintengineex/qglcustomshaderstage.cpp \ - gl2paintengineex/qtriangulatingstroker.cpp + gl2paintengineex/qtriangulatingstroker.cpp \ + gl2paintengineex/qtextureglyphcache_gl.cpp } -- cgit v0.12 From 617773f717e590b7945ccf0635e2ff64303135cc Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 5 Jan 2010 08:56:04 +0100 Subject: fix compilation in GL2 paint engine for Windows --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index b3b5fe1..bd067f9 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1567,6 +1567,7 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) #if !defined(QT_OPENGL_ES_2) #if defined(Q_WS_WIN) + extern Q_GUI_EXPORT bool qt_cleartype_enabled; if (qt_cleartype_enabled) #endif d->glyphCacheType = QFontEngineGlyphCache::Raster_RGBMask; -- cgit v0.12 From 049f65b4d07587e26c69602e6e59682e82948bd2 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 5 Jan 2010 09:01:47 +0100 Subject: doc: Clarified next and previous activation order. Task-number: QTBUG-6992 --- src/gui/widgets/qmdiarea.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/gui/widgets/qmdiarea.cpp b/src/gui/widgets/qmdiarea.cpp index f3dbe34..a4a4cb2 100644 --- a/src/gui/widgets/qmdiarea.cpp +++ b/src/gui/widgets/qmdiarea.cpp @@ -1853,11 +1853,11 @@ void QMdiArea::closeAllSubWindows() } /*! - Gives the keyboard focus to the next window in the list of child - windows. The windows are activated in the order in which they are - created (CreationOrder). + Gives the keyboard focus to another window in the list of child + windows. The window activated will be the next one determined + by the current \l{QMdiArea::WindowOrder} {activation order}. - \sa activatePreviousSubWindow() + \sa activatePreviousSubWindow(), QMdiArea::WindowOrder */ void QMdiArea::activateNextSubWindow() { @@ -1871,11 +1871,11 @@ void QMdiArea::activateNextSubWindow() } /*! - Gives the keyboard focus to the previous window in the list of - child windows. The windows are activated in the order in which - they are created (CreationOrder). + Gives the keyboard focus to another window in the list of child + windows. The window activated will be the previous one determined + by the current \l{QMdiArea::WindowOrder} {activation order}. - \sa activateNextSubWindow() + \sa activateNextSubWindow(), QMdiArea::WindowOrder */ void QMdiArea::activatePreviousSubWindow() { -- cgit v0.12 From dc50ba5885d27aff99d62ced52081eda851552e7 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 5 Jan 2010 09:09:42 +0100 Subject: Updated WebKit from /home/shausman/src/webkit/trunk to qtwebkit/qtwebkit-4.6 ( 5d691a1c283938dfbdf891883d8cff8a6ef040bf ) Changes in WebKit/qt since the last update: * Prospective build fix for IA64 Task: QTBUG-6948 --- src/3rdparty/webkit/JavaScriptCore/ChangeLog | 10 ++++++++++ src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h | 12 +++++++++++- src/3rdparty/webkit/VERSION | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/webkit/JavaScriptCore/ChangeLog b/src/3rdparty/webkit/JavaScriptCore/ChangeLog index 50cff63..a559d9b 100644 --- a/src/3rdparty/webkit/JavaScriptCore/ChangeLog +++ b/src/3rdparty/webkit/JavaScriptCore/ChangeLog @@ -1,3 +1,13 @@ +2009-12-08 Gustavo Noronha Silva + + Reviewed by Darin Adler. + + Make WebKit build correctly on FreeBSD, IA64, and Alpha. + Based on work by Petr Salinger , + and Colin Watson . + + * wtf/Platform.h: + 2009-12-18 Yongjun Zhang Reviewed by Simon Hausmann. diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h b/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h index cb6c9b9..3e1093b 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h @@ -347,6 +347,16 @@ #define WTF_PLATFORM_X86_64 1 #endif +/* PLATFORM(IA64) */ +#if defined(__ia64__) +#define WTF_PLATFORM_IA64 1 +#endif + +/* PLATFORM(ALPHA) */ +#if defined(__alpha__) +#define WTF_PLATFORM_ALPHA 1 +#endif + /* PLATFORM(SH4) */ #if defined(__SH4__) #define WTF_PLATFORM_SH4 1 @@ -709,7 +719,7 @@ #endif #if !defined(WTF_USE_JSVALUE64) && !defined(WTF_USE_JSVALUE32) && !defined(WTF_USE_JSVALUE32_64) -#if PLATFORM(X86_64) && (PLATFORM(DARWIN) || PLATFORM(LINUX) || PLATFORM(WIN_OS)) +#if (PLATFORM(X86_64) && (PLATFORM(UNIX) || PLATFORM(WIN_OS))) || PLATFORM(IA64) || PLATFORM(ALPHA) #define WTF_USE_JSVALUE64 1 #elif PLATFORM(ARM) || PLATFORM(PPC64) #define WTF_USE_JSVALUE32 1 diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index daa3be7..d36e419 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -8,4 +8,4 @@ The commit imported was from the and has the sha1 checksum - 70b5989bdeea2f73bd950099fc0f0e954550ef54 + 5d691a1c283938dfbdf891883d8cff8a6ef040bf -- cgit v0.12 From c08789f4540ac934ac4a20feaac205837fb0cf6f Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 5 Jan 2010 10:14:51 +0100 Subject: doc: Clarified which values were added in Qt 4.4. Task-number: QTBUG-7118 --- src/gui/image/qimage.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index ec8dd88..be1190b 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -696,7 +696,9 @@ bool QImageData::checkForAlphaPixels() const /*! \enum QImage::Format - The following image formats are available in all versions of Qt: + The following image formats are available in Qt. Values greater + than QImage::Format_RGB16 were added in Qt 4.4. See the notes + after the table. \value Format_Invalid The image is invalid. \value Format_Mono The image is stored using 1-bit per pixel. Bytes are @@ -705,17 +707,12 @@ bool QImageData::checkForAlphaPixels() const packed with the less significant bit (LSB) first. \value Format_Indexed8 The image is stored using 8-bit indexes - into a colormap. \warning Drawing into a - QImage with Indexed8 format is not - supported. + into a colormap. \value Format_RGB32 The image is stored using a 32-bit RGB format (0xffRRGGBB). \value Format_ARGB32 The image is stored using a 32-bit ARGB - format (0xAARRGGBB). \warning Do not - render into ARGB32 images using - QPainter. Format_ARGB32_Premultiplied is - significantly faster. + format (0xAARRGGBB). \value Format_ARGB32_Premultiplied The image is stored using a premultiplied 32-bit ARGB format (0xAARRGGBB), i.e. the red, @@ -744,6 +741,12 @@ bool QImageData::checkForAlphaPixels() const \value Format_ARGB4444_Premultiplied The image is stored using a premultiplied 16-bit ARGB format (4-4-4-4). + \note Drawing into a QImage with QImage::Format_Indexed8 is not + supported. + + \note Do not render into ARGB32 images using QPainter. Using + QImage::Format_ARGB32_Premultiplied is significantly faster. + \sa format(), convertToFormat() */ -- cgit v0.12 From fee4ec0c8f507fae4f6795f43dca1333f46c9922 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 5 Jan 2010 10:27:28 +0100 Subject: doc: Fixed typo. Task-number: QTBUG-6978 --- doc/src/development/designer-manual.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/development/designer-manual.qdoc b/doc/src/development/designer-manual.qdoc index bfd8066..d7666f6 100644 --- a/doc/src/development/designer-manual.qdoc +++ b/doc/src/development/designer-manual.qdoc @@ -371,7 +371,7 @@ {setValue()} slot. To do this, you have to switch to \gui{Edit Signals/Slots} mode, either by - pressing \key{F4} or something \gui{Edit Signals/Slots} from the \gui{Edit} + pressing \key{F4} or selecting \gui{Edit Signals/Slots} from the \gui{Edit} menu. \table -- cgit v0.12 From 0dc7587b4333ae201b960be01517ad9911fcb3e2 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 5 Jan 2010 11:27:15 +0200 Subject: Minor logic fix to Symbian generator in qmake The include meant to be under restore_build was getting included always. This is actually how it should work, so removed the empty restore_build target entirely. Reviewed-by: Janne Anttila --- qmake/generators/symbian/symmake.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/qmake/generators/symbian/symmake.cpp b/qmake/generators/symbian/symmake.cpp index f3339af..b2709d1 100644 --- a/qmake/generators/symbian/symmake.cpp +++ b/qmake/generators/symbian/symmake.cpp @@ -91,7 +91,6 @@ #define OK_SIS_TARGET "ok_sis" #define FAIL_SIS_NOPKG_TARGET "fail_sis_nopkg" #define FAIL_SIS_NOCACHE_TARGET "fail_sis_nocache" -#define RESTORE_BUILD_TARGET "restore_build" #define PRINT_FILE_CREATE_ERROR(filename) fprintf(stderr, "Error: Could not create '%s'\n", qPrintable(filename)); @@ -1762,7 +1761,10 @@ void SymbianMakefileGenerator::removeSpecialCharacters(QString& str) void SymbianMakefileGenerator::writeSisTargets(QTextStream &t) { - t << SIS_TARGET ": " RESTORE_BUILD_TARGET << endl; + t << "-include " MAKE_CACHE_NAME << endl; + t << endl; + + t << SIS_TARGET ":" << endl; QString siscommand = QString("\t$(if $(wildcard %1_template.%2),$(if $(wildcard %3)," \ "$(MAKE) -s -f $(MAKEFILE) %4," \ "$(if $(QT_SIS_TARGET),$(MAKE) -s -f $(MAKEFILE) %4," \ @@ -1793,11 +1795,6 @@ void SymbianMakefileGenerator::writeSisTargets(QTextStream &t) t << FAIL_SIS_NOCACHE_TARGET ":" << endl; t << "\t$(error Project has to be built or QT_SIS_TARGET environment variable has to be set before calling 'SIS' target)" << endl; t << endl; - - - t << RESTORE_BUILD_TARGET ":" << endl; - t << "-include " MAKE_CACHE_NAME << endl; - t << endl; } void SymbianMakefileGenerator::generateDistcleanTargets(QTextStream& t) -- cgit v0.12 From d14ac9914753220e54f3b5cd94d122325d499776 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 5 Jan 2010 11:05:30 +0100 Subject: Implement QScript::QObjectDelegate::getOwnPropertyDescriptor This is needed for the fix for QTBUG-5749 that follow Reviewed-by: Kent Hansen Task-number: QTBUG-5749 --- src/script/bridge/qscriptobject.cpp | 17 +++++ src/script/bridge/qscriptobject_p.h | 4 + src/script/bridge/qscriptqobject.cpp | 140 ++++++++++++++++++++++++++++++++++- src/script/bridge/qscriptqobject_p.h | 4 + 4 files changed, 164 insertions(+), 1 deletion(-) diff --git a/src/script/bridge/qscriptobject.cpp b/src/script/bridge/qscriptobject.cpp index 2d71c43..6942eb6 100644 --- a/src/script/bridge/qscriptobject.cpp +++ b/src/script/bridge/qscriptobject.cpp @@ -61,6 +61,15 @@ bool QScriptObject::getOwnPropertySlot(JSC::ExecState* exec, return d->delegate->getOwnPropertySlot(this, exec, propertyName, slot); } +bool QScriptObject::getOwnPropertyDescriptor(JSC::ExecState* exec, + const JSC::Identifier& propertyName, + JSC::PropertyDescriptor& descriptor) +{ + if (!d || !d->delegate) + return JSC::JSObject::getOwnPropertyDescriptor(exec, propertyName, descriptor); + return d->delegate->getOwnPropertyDescriptor(this, exec, propertyName, descriptor); +} + void QScriptObject::put(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSValue value, JSC::PutPropertySlot& slot) { @@ -164,6 +173,14 @@ bool QScriptObjectDelegate::getOwnPropertySlot(QScriptObject* object, JSC::ExecS return object->JSC::JSObject::getOwnPropertySlot(exec, propertyName, slot); } +bool QScriptObjectDelegate::getOwnPropertyDescriptor(QScriptObject* object, JSC::ExecState* exec, + const JSC::Identifier& propertyName, + JSC::PropertyDescriptor& descriptor) +{ + return object->JSC::JSObject::getOwnPropertyDescriptor(exec, propertyName, descriptor); +} + + void QScriptObjectDelegate::put(QScriptObject* object, JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSValue value, JSC::PutPropertySlot& slot) diff --git a/src/script/bridge/qscriptobject_p.h b/src/script/bridge/qscriptobject_p.h index a4faa06..f4b7140 100644 --- a/src/script/bridge/qscriptobject_p.h +++ b/src/script/bridge/qscriptobject_p.h @@ -63,6 +63,7 @@ public: virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); virtual void put(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&); virtual bool deleteProperty(JSC::ExecState*, @@ -121,6 +122,9 @@ public: virtual bool getOwnPropertySlot(QScriptObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + virtual bool getOwnPropertyDescriptor(QScriptObject*, JSC::ExecState*, + const JSC::Identifier& propertyName, + JSC::PropertyDescriptor&); virtual void put(QScriptObject*, JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&); virtual bool deleteProperty(QScriptObject*, JSC::ExecState*, diff --git a/src/script/bridge/qscriptqobject.cpp b/src/script/bridge/qscriptqobject.cpp index 63ba9ec..b51cb68 100644 --- a/src/script/bridge/qscriptqobject.cpp +++ b/src/script/bridge/qscriptqobject.cpp @@ -1173,6 +1173,7 @@ bool QObjectDelegate::getOwnPropertySlot(QScriptObject *object, JSC::ExecState * const JSC::Identifier &propertyName, JSC::PropertySlot &slot) { + //Note: this has to be kept in sync with getOwnPropertyDescriptor #ifndef QT_NO_PROPERTIES QByteArray name = QString(propertyName.ustring()).toLatin1(); QObject *qobject = data->value; @@ -1285,6 +1286,142 @@ bool QObjectDelegate::getOwnPropertySlot(QScriptObject *object, JSC::ExecState * #endif //QT_NO_PROPERTIES } + +bool QObjectDelegate::getOwnPropertyDescriptor(QScriptObject *object, JSC::ExecState *exec, + const JSC::Identifier &propertyName, + JSC::PropertyDescriptor &descriptor) +{ + //Note: this has to be kept in sync with getOwnPropertySlot abd getPropertyAttributes +#ifndef QT_NO_PROPERTIES + QByteArray name = QString(propertyName.ustring()).toLatin1(); + QObject *qobject = data->value; + if (!qobject) { + QString message = QString::fromLatin1("cannot access member `%0' of deleted QObject") + .arg(QString::fromLatin1(name)); + descriptor.setValue(JSC::throwError(exec, JSC::GeneralError, message)); + return true; + } + + const QScriptEngine::QObjectWrapOptions &opt = data->options; + + const QMetaObject *meta = qobject->metaObject(); + { + QHash::const_iterator it = data->cachedMembers.constFind(name); + if (it != data->cachedMembers.constEnd()) { + int index; + if (GeneratePropertyFunctions && ((index = meta->indexOfProperty(name)) != -1)) { + QMetaProperty prop = meta->property(index); + descriptor.setAccessorDescriptor(it.value(), it.value(), flagsForMetaProperty(prop)); + if (!prop.isWritable()) + descriptor.setWritable(false); + } else { + unsigned attributes = QObjectMemberAttribute; + if (opt & QScriptEngine::SkipMethodsInEnumeration) + attributes |= JSC::DontEnum; + descriptor.setDescriptor(it.value(), attributes); + } + return true; + } + } + + QScriptEnginePrivate *eng = scriptEngineFromExec(exec); + int index = -1; + if (name.contains('(')) { + QByteArray normalized = QMetaObject::normalizedSignature(name); + if (-1 != (index = meta->indexOfMethod(normalized))) { + QMetaMethod method = meta->method(index); + if (hasMethodAccess(method, index, opt)) { + if (!(opt & QScriptEngine::ExcludeSuperClassMethods) + || (index >= meta->methodOffset())) { + QtFunction *fun = new (exec)QtFunction( + object, index, /*maybeOverloaded=*/false, + &exec->globalData(), eng->originalGlobalObject()->functionStructure(), + propertyName); + data->cachedMembers.insert(name, fun); + unsigned attributes = QObjectMemberAttribute; + if (opt & QScriptEngine::SkipMethodsInEnumeration) + attributes |= JSC::DontEnum; + descriptor.setDescriptor(fun, attributes); + return true; + } + } + } + } + + index = meta->indexOfProperty(name); + if (index != -1) { + QMetaProperty prop = meta->property(index); + if (prop.isScriptable()) { + if (!(opt & QScriptEngine::ExcludeSuperClassProperties) + || (index >= meta->propertyOffset())) { + unsigned attributes = flagsForMetaProperty(prop); + if (GeneratePropertyFunctions) { + QtPropertyFunction *fun = new (exec)QtPropertyFunction( + meta, index, &exec->globalData(), + eng->originalGlobalObject()->functionStructure(), + propertyName); + data->cachedMembers.insert(name, fun); + descriptor.setAccessorDescriptor(fun, fun, attributes); + if (attributes & JSC::ReadOnly) + descriptor.setWritable(false); + } else { + JSC::JSValue val; + if (!prop.isValid()) + val = JSC::jsUndefined(); + else + val = eng->jscValueFromVariant(prop.read(qobject)); + descriptor.setDescriptor(val, attributes); + } + return true; + } + } + } + + index = qobject->dynamicPropertyNames().indexOf(name); + if (index != -1) { + JSC::JSValue val = eng->jscValueFromVariant(qobject->property(name)); + descriptor.setDescriptor(val, QObjectMemberAttribute); + return true; + } + + const int offset = (opt & QScriptEngine::ExcludeSuperClassMethods) + ? meta->methodOffset() : 0; + for (index = meta->methodCount() - 1; index >= offset; --index) { + QMetaMethod method = meta->method(index); + if (hasMethodAccess(method, index, opt) + && (methodName(method) == name)) { + QtFunction *fun = new (exec)QtFunction( + object, index, /*maybeOverloaded=*/true, + &exec->globalData(), eng->originalGlobalObject()->functionStructure(), + propertyName); + unsigned attributes = QObjectMemberAttribute; + if (opt & QScriptEngine::SkipMethodsInEnumeration) + attributes |= JSC::DontEnum; + descriptor.setDescriptor(fun, attributes); + data->cachedMembers.insert(name, fun); + return true; + } + } + + if (!(opt & QScriptEngine::ExcludeChildObjects)) { + QList children = qobject->children(); + for (index = 0; index < children.count(); ++index) { + QObject *child = children.at(index); + if (child->objectName() == QString(propertyName.ustring())) { + QScriptEngine::QObjectWrapOptions opt = QScriptEngine::PreferExistingWrapperObject; + QScriptValue tmp = QScriptEnginePrivate::get(eng)->newQObject(child, QScriptEngine::QtOwnership, opt); + descriptor.setDescriptor(eng->scriptValueToJSCValue(tmp), JSC::ReadOnly | JSC::DontDelete | JSC::DontEnum); + return true; + } + } + } + + return QScriptObjectDelegate::getOwnPropertyDescriptor(object, exec, propertyName, descriptor); +#else //QT_NO_PROPERTIES + return false; +#endif //QT_NO_PROPERTIES +} + void QObjectDelegate::put(QScriptObject *object, JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSValue value, JSC::PutPropertySlot &slot) @@ -1437,7 +1574,7 @@ bool QObjectDelegate::getPropertyAttributes(const QScriptObject *object, unsigned &attributes) const { #ifndef QT_NO_PROPERTIES - // ### try to avoid duplicating logic from getOwnPropertySlot() + //Note: this has to be kept in sync with getOwnPropertyDescriptor and getOwnPropertySlot QByteArray name = ((QString)propertyName.ustring()).toLatin1(); QObject *qobject = data->value; if (!qobject) @@ -1688,6 +1825,7 @@ QObjectPrototype::QObjectPrototype(JSC::ExecState* exec, WTF::PassRefPtrpropertyNames().toString, qobjectProtoFuncToString), JSC::DontEnum); putDirectFunction(exec, new (exec) JSC::PrototypeFunction(exec, prototypeFunctionStructure, /*length=*/1, JSC::Identifier(exec, "findChild"), qobjectProtoFuncFindChild), JSC::DontEnum); putDirectFunction(exec, new (exec) JSC::PrototypeFunction(exec, prototypeFunctionStructure, /*length=*/1, JSC::Identifier(exec, "findChildren"), qobjectProtoFuncFindChildren), JSC::DontEnum); + this->structure()->setHasGetterSetterProperties(true); } const JSC::ClassInfo QMetaObjectWrapperObject::info = { "QMetaObject", 0, 0, 0 }; diff --git a/src/script/bridge/qscriptqobject_p.h b/src/script/bridge/qscriptqobject_p.h index 41900b5..0e7748d 100644 --- a/src/script/bridge/qscriptqobject_p.h +++ b/src/script/bridge/qscriptqobject_p.h @@ -78,6 +78,10 @@ public: virtual bool getOwnPropertySlot(QScriptObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + virtual bool getOwnPropertyDescriptor(QScriptObject*, JSC::ExecState*, + const JSC::Identifier& propertyName, + JSC::PropertyDescriptor&); + virtual void put(QScriptObject*, JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&); -- cgit v0.12 From e715a7f4cfad454b9c966fa2938cbe9a92ce49fb Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 5 Jan 2010 11:09:33 +0100 Subject: QScript: Lookup the native setter from the prototype Usefull if we have 'native' properties with setter in a prototype This happen if you use a QObject wrapper as a prototype. Use getPropertyDescriptor that look up the prototype in order to know if we have a setter. Note that we cannot relly on PropertDescriptor::isAccessorDescriptor as the Getter or Setter attributes are not necesserly updated correctly when updating properties. (See the workaround QScriptValuePrivate::propertyFlags, and tst_QScriptValue::getSetProperty with object7) Task-number: QTBUG-5749 (also need the previous patch) Reviewed-by: Kent Hansen --- .../javascriptcore/JavaScriptCore/runtime/JSObject.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSObject.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSObject.cpp index d7f5344..01f74ac 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSObject.cpp +++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSObject.cpp @@ -115,9 +115,17 @@ void JSObject::put(ExecState* exec, const Identifier& propertyName, JSValue valu return; for (JSObject* obj = this; ; obj = asObject(prototype)) { +#ifdef QT_BUILD_SCRIPT_LIB + PropertyDescriptor descriptor; + if (obj->getPropertyDescriptor(exec, propertyName, descriptor)) { + JSObject* setterFunc; + if ((descriptor.isAccessorDescriptor() && ((setterFunc = asObject(descriptor.setter())), true)) + || (descriptor.value().isGetterSetter() && ((setterFunc = asGetterSetter(descriptor.value())->setter()), true))) { +#else if (JSValue gs = obj->getDirect(propertyName)) { if (gs.isGetterSetter()) { - JSObject* setterFunc = asGetterSetter(gs)->setter(); + JSObject* setterFunc = asGetterSetter(gs)->setter(); +#endif if (!setterFunc) { throwSetterError(exec); return; -- cgit v0.12 From 553e0cafa578ece64c07afa11571eca4c7b9444c Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 5 Jan 2010 11:35:09 +0100 Subject: doc: Replaced usses of rootState() with state machine pointer. The root state of a QStateMachine is now the state machine itself. Task-number: QTBUG-6907 --- doc/src/frameworks-technologies/animation.qdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/frameworks-technologies/animation.qdoc b/doc/src/frameworks-technologies/animation.qdoc index cd6e304..77cc8dc 100644 --- a/doc/src/frameworks-technologies/animation.qdoc +++ b/doc/src/frameworks-technologies/animation.qdoc @@ -352,11 +352,11 @@ QStateMachine *machine = new QStateMachine; - QState *state1 = new QState(machine->rootState()); + QState *state1 = new QState(machine); state1->assignProperty(button, "geometry", QRect(0, 0, 100, 30)); machine->setInitialState(state1); - QState *state2 = new QState(machine->rootState()); + QState *state2 = new QState(machine); state2->assignProperty(button, "geometry", QRect(250, 250, 100, 30)); QSignalTransition *transition1 = state1->addTransition(button, -- cgit v0.12 From 3f8eaba6caaf5b97f4834e6ff206b779479becdc Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Tue, 5 Jan 2010 11:39:28 +0100 Subject: Fix auto-test failure on Windows Reviewed-by: Olivier --- tests/auto/qfiledialog2/tst_qfiledialog2.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp index 83380a5..9757fa0 100644 --- a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp @@ -1105,7 +1105,6 @@ void tst_QFiledialog::QTBUG6558_showDirsOnly() dirTemp.cdUp(); dirTemp.rmdir(tempName); - QTRY_VERIFY(!dir.exists()); } QTEST_MAIN(tst_QFiledialog) -- cgit v0.12 From 1ae7c8d8f549cadda4780835d85235085cc5583c Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 5 Jan 2010 12:15:00 +0200 Subject: Fixed "run" makefile target documentation for Symbian "run" target no longer is just for running emulator targets. Also added TRK for optional requirements. Reviewed-by: axis --- doc/src/getting-started/installation.qdoc | 9 +++++++++ doc/src/platforms/symbian-introduction.qdoc | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/doc/src/getting-started/installation.qdoc b/doc/src/getting-started/installation.qdoc index 939e2e8..73d3709 100644 --- a/doc/src/getting-started/installation.qdoc +++ b/doc/src/getting-started/installation.qdoc @@ -1031,6 +1031,15 @@ If you are using pre-built binaries, follow the instructions given in the \o \c{nokia_plugin\opencpp\s60opencppsis\stdcpp_s60_.sis} \endlist + If you wish to do hardware debugging with Carbide or run applications in real devices using "make run" command, + TRK must be installed to the device. \bold{Note:} TRK is not required if you just want to install and run + applications manually on the device. + \list + \o \l{http://tools.ext.nokia.com/trk/}{Application TRK}. Choose the correct + installation package based on the S60 version of your device (S60__app_trk_.sisx). + \endlist + + We recommend you to take a look at \l{http://developer.symbian.org/wiki/index.php/Qt_Quick_Start}{Symbian Foundation - Qt Quick Start} to get more information about how to setup the development environment. diff --git a/doc/src/platforms/symbian-introduction.qdoc b/doc/src/platforms/symbian-introduction.qdoc index c0c4fb3..477e629 100644 --- a/doc/src/platforms/symbian-introduction.qdoc +++ b/doc/src/platforms/symbian-introduction.qdoc @@ -124,7 +124,12 @@ \row \o \c release-gcce \o Build release binaries for hardware using GCCE. \row \o \c debug-armv5 \o Build debug binaries for hardware using RVCT. \row \o \c release-armv5 \o Build release binaries for hardware using RVCT. - \row \o \c run \o Run the emulator binaries from the build directory. + \row \o \c run \o Run the application. Environment variable + \c QT_SIS_TARGET (see below) can be used to specify which + build target is run. By default it is the last build target. + Note that running the application on real device + using this command requires \c TRK application to be running + on the device. \row \o \c sis \o Create signed \c .sis file for project. \endtable -- cgit v0.12 From 547e117e7463db85651d910d5a627806388b9afc Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 5 Jan 2010 12:20:06 +0100 Subject: Changelog: Added Designer/uic entries for 4.6.1 --- dist/changes-4.6.1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dist/changes-4.6.1 b/dist/changes-4.6.1 index 5efa0e2..2397228 100644 --- a/dist/changes-4.6.1 +++ b/dist/changes-4.6.1 @@ -148,7 +148,14 @@ Qt for Windows CE **************************************************************************** - Designer - * foo + * [QTBUG-6863] Fixed static linking on Mac. + * [QTBUG-6760] Fixed display of action shortcut in action editor. + * [QTBUG-6505] Fixed handling of QHeaderView properties. + * [QTBUG-5335] Fixed handling of layout margins of custom containers. + + - uic + * [QTBUG-5824] Fixed code generation to generate a call to + QMainWindow::setCentralWidget() for promoted widgets as well. - qdoc3 * bar -- cgit v0.12 From ea55f9b52479fd2cdb6d6deb740df5f495145cd1 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 5 Jan 2010 12:32:29 +0100 Subject: Fix test: The bug is now fixed --- tests/auto/qscriptable/tst_qscriptable.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/auto/qscriptable/tst_qscriptable.cpp b/tests/auto/qscriptable/tst_qscriptable.cpp index c0945d8..7ed0a8a 100644 --- a/tests/auto/qscriptable/tst_qscriptable.cpp +++ b/tests/auto/qscriptable/tst_qscriptable.cpp @@ -332,7 +332,6 @@ void tst_QScriptable::thisObject() { QVERIFY(!m_scriptable.oofThisObject().isValid()); m_engine.evaluate("o.oof = 123"); - QEXPECT_FAIL("", "QTBUG-5749: Setter doesn't get called when it's in the prototype", Continue); QVERIFY(m_scriptable.oofThisObject().strictlyEquals(m_engine.evaluate("o"))); } { -- cgit v0.12 From 3c6d15423693bbb370cd47dadfbfe7194dafc668 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Tue, 5 Jan 2010 12:29:27 +0100 Subject: Removed temporary QGLWidget created during QGLWidget/X11 initialization. ..and replace it with a much lighter, internal QGLTempContext. Reviewed-by: Samuel --- src/opengl/qgl_x11.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp index 8173bec..9fca28c 100644 --- a/src/opengl/qgl_x11.cpp +++ b/src/opengl/qgl_x11.cpp @@ -1132,6 +1132,72 @@ void *QGLContext::getProcAddress(const QString &proc) const return glXGetProcAddressARB(reinterpret_cast(proc.toLatin1().data())); } +// +// This class is used to create a temporary, minimal GL context, which is used +// to retrive GL version and extension info. It's significantly faster to +// construct than a QGLWidget, and it doesn't have the recursive creation +// problem that QGLWidget would have. E.g. creating a temporary QGLWidget to +// retrieve GL info as part of the QGLWidget initialization. +// +class QGLTempContext +{ +public: + QGLTempContext(int screen = 0) : + initialized(false), + old_drawable(0), + old_context(0) + { + int attribs[] = {GLX_RGBA, XNone}; + XVisualInfo *vi = glXChooseVisual(X11->display, screen, attribs); + if (!vi) { + qWarning("QGLTempContext: No GL capable X visuals available."); + return; + } + + int useGL; + glXGetConfig(X11->display, vi, GLX_USE_GL, &useGL); + if (!useGL) { + XFree(vi); + return; + } + + old_drawable = glXGetCurrentDrawable(); + old_context = glXGetCurrentContext(); + + XSetWindowAttributes a; + a.colormap = qt_gl_choose_cmap(X11->display, vi); + drawable = XCreateWindow(X11->display, RootWindow(X11->display, screen), + 0, 0, 1, 1, 0, + vi->depth, InputOutput, vi->visual, + CWColormap, &a); + context = glXCreateContext(X11->display, vi, 0, True); + if (context && glXMakeCurrent(X11->display, drawable, context)) { + initialized = true; + } else { + qWarning("QGLTempContext: Unable to create GL context."); + XDestroyWindow(X11->display, drawable); + } + XFree(vi); + } + + ~QGLTempContext() { + if (initialized) { + glXMakeCurrent(X11->display, 0, 0); + glXDestroyContext(X11->display, context); + XDestroyWindow(X11->display, drawable); + } + if (old_drawable && old_context) + glXMakeCurrent(X11->display, old_drawable, old_context); + } + +private: + bool initialized; + Window drawable; + GLXContext context; + GLXDrawable old_drawable; + GLXContext old_context; +}; + /***************************************************************************** QGLOverlayWidget (Internal overlay class for X11) *****************************************************************************/ @@ -1574,8 +1640,7 @@ void QGLExtensions::init() return; init_done = true; - QGLWidget dmy; - dmy.makeCurrent(); + QGLTempContext context; init_extensions(); // nvidia 9x.xx unix drivers contain a bug which requires us to call glFinish before releasing an fbo -- cgit v0.12 From 190f45bcc7383bdc68a904e7dd5780372d00afba Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 5 Jan 2010 12:39:22 +0100 Subject: doc: Added note explaining grabMouse() for Cocoa and Carbon. Task-number: QTBUG-6810 --- src/gui/kernel/qwidget.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 81f38ec..5c4cc74 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -11871,16 +11871,20 @@ void QWidget::ungrabGesture(Qt::GestureType gesture) mouse when a mouse button is pressed and keeps it until the last button is released. - Note that only visible widgets can grab mouse input. If - isVisible() returns false for a widget, that widget cannot call - grabMouse(). + \note Only visible widgets can grab mouse input. If isVisible() + returns false for a widget, that widget cannot call grabMouse(). + + \note \bold{(Mac OS X developers)} For \e Cocoa, calling + grabMouse() on a widget only works when the mouse is inside the + frame of that widget. For \e Carbon, it works outside the widget's + frame as well, like for Windows and X11. \sa releaseMouse() grabKeyboard() releaseKeyboard() */ /*! \fn void QWidget::grabMouse(const QCursor &cursor) - \overload + \overload grabMouse() Grabs the mouse input and changes the cursor shape. @@ -11890,6 +11894,8 @@ void QWidget::ungrabGesture(Qt::GestureType gesture) \warning Grabbing the mouse might lock the terminal. + \note \bold{(Mac OS X developers)} See the note in QWidget::grabMouse(). + \sa releaseMouse(), grabKeyboard(), releaseKeyboard(), setCursor() */ -- cgit v0.12 From d03475b69aa552a490e32fb2b7ad4dfaeacecf93 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 4 Jan 2010 17:16:07 +0100 Subject: Small optimization in QIODevice::readAll() .. and more testcases Reviewed-by: joao --- src/corelib/io/qiodevice.cpp | 12 ++++++++++-- tests/auto/qfile/tst_qfile.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 0e5a2de..8dcccb4 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -965,7 +965,15 @@ QByteArray QIODevice::readAll() QByteArray result; qint64 readBytes = 0; - if (d->isSequential() || (readBytes = size()) == 0) { + + // flush internal read buffer + if (!(d->openMode & Text) && !d->buffer.isEmpty()) { + result = d->buffer.readAll(); + readBytes = result.size(); + } + + qint64 theSize; + if (d->isSequential() || (theSize = size()) == 0) { // Size is unknown, read incrementally. qint64 readResult; do { @@ -977,7 +985,7 @@ QByteArray QIODevice::readAll() } else { // Read it all in one go. // If resize fails, don't read anything. - result.resize(int(readBytes - d->pos)); + result.resize(int(theSize - d->pos)); readBytes = read(result.data(), result.size()); } diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index 2b2f431..e88c222 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -129,6 +129,8 @@ private slots: void readLine(); void readLine2(); void readLineNullInLine(); + void readAll_data(); + void readAll(); void readAllStdin(); void readLineStdin(); void readLineStdin_lineByLine(); @@ -752,6 +754,45 @@ void tst_QFile::readLineNullInLine() QCOMPARE(file.readLine(), QByteArray()); } +void tst_QFile::readAll_data() +{ + QTest::addColumn("textMode"); + QTest::addColumn("fileName"); + QTest::newRow( "TextMode unixfile" ) << true << SRCDIR "testfile.txt"; + QTest::newRow( "BinaryMode unixfile" ) << false << SRCDIR "testfile.txt"; + QTest::newRow( "TextMode dosfile" ) << true << SRCDIR "dosfile.txt"; + QTest::newRow( "BinaryMode dosfile" ) << false << SRCDIR "dosfile.txt"; + QTest::newRow( "TextMode bigfile" ) << true << SRCDIR "tst_qfile.cpp"; + QTest::newRow( "BinaryMode bigfile" ) << false << SRCDIR "tst_qfile.cpp"; + QVERIFY(QFile(SRCDIR "tst_qfile.cpp").size() > 64*1024); +} + +void tst_QFile::readAll() +{ + QFETCH( bool, textMode ); + QFETCH( QString, fileName ); + + QFile file(fileName); + if (textMode) + QVERIFY(file.open(QFile::Text | QFile::ReadOnly)); + else + QVERIFY(file.open(QFile::ReadOnly)); + + QByteArray a = file.readAll(); + file.reset(); + QVERIFY(file.pos() == 0); + + QVERIFY(file.bytesAvailable() > 7); + QByteArray b = file.read(1); + char x; + file.getChar(&x); + b.append(x); + b.append(file.read(5)); + b.append(file.readAll()); + + QCOMPARE(a, b); +} + void tst_QFile::readAllStdin() { #if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) -- cgit v0.12 From 94c2fce09c34b629a6fcb5a9576c4646a1ac24a8 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 5 Jan 2010 13:26:12 +0100 Subject: doc: Added some missing macro descriptions. Task-number: QTBUG-6769 --- src/corelib/global/qglobal.cpp | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 0c94482..dfe610c 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1226,7 +1226,7 @@ bool qSharedBuild() Defined on Mac OS X. - \sa Q_WS_WIN, Q_WS_X11, Q_WS_QWS + \sa Q_WS_WIN, Q_WS_X11, Q_WS_QWS, Q_WS_S60 */ /*! @@ -1235,7 +1235,7 @@ bool qSharedBuild() Defined on Windows. - \sa Q_WS_MAC, Q_WS_X11, Q_WS_QWS + \sa Q_WS_MAC, Q_WS_X11, Q_WS_QWS, Q_WS_S60 */ /*! @@ -1244,7 +1244,7 @@ bool qSharedBuild() Defined on X11. - \sa Q_WS_MAC, Q_WS_WIN, Q_WS_QWS + \sa Q_WS_MAC, Q_WS_WIN, Q_WS_QWS, Q_WS_S60 */ /*! @@ -1253,7 +1253,7 @@ bool qSharedBuild() Defined on Qt for Embedded Linux. - \sa Q_WS_MAC, Q_WS_WIN, Q_WS_X11 + \sa Q_WS_MAC, Q_WS_WIN, Q_WS_X11, Q_WS_S60 */ /*! @@ -1599,6 +1599,29 @@ bool qSharedBuild() Optimizing C++ Compilers. */ +/*! + \macro Q_OS_MAC + \relates + + Defined on MAC OS (synonym for Darwin). + */ + +/*! + \macro Q_OS_SYMBIAN + \relates + + Defined on Symbian. + */ + +/*! + \macro Q_WS_S60 + \relates + + Defined on S60. + + \sa Q_WS_MAC, Q_WS_WIN, Q_WS_X11, Q_WS_QWS + */ + #if defined(QT_BUILD_QMAKE) // needed to bootstrap qmake static const unsigned int qt_one = 1; -- cgit v0.12 From 66275bc468339ec2599ba660b728304858e30b39 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 5 Jan 2010 14:37:42 +0200 Subject: Fixed Symbian application deployment instructions Obsolete sis files were referenced. Task-number: QTBUG-6601 Reviewed-by: Janne Koskinen --- doc/src/deployment/deployment.qdoc | 4 ++-- doc/src/snippets/code/doc_src_deployment.qdoc | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/doc/src/deployment/deployment.qdoc b/doc/src/deployment/deployment.qdoc index 6a1760e..f2038b2 100644 --- a/doc/src/deployment/deployment.qdoc +++ b/doc/src/deployment/deployment.qdoc @@ -1567,12 +1567,12 @@ By default \c .pkg file generated by \c qmake adds support for all S60 3rd edition FP1, S60 3rd edition FP2 and S60 5th edition devices. - As a last step we will embed the Open C, Open C++ and Qt \c .sis files to the Wiggly + As a last step we will embed the \c qt_installer.sis file to the Wiggly deployment file: \snippet doc/src/snippets/code/doc_src_deployment.qdoc 58 - By embedding all dependencies to the application deployment file, the + When \c qt_installer.sis is embedded to the application deployment file, the end-user does not need to download and install all dependencies separately. The drawback of \c .sis embedding is that the application \c .sis file size becomes big. To address these problems Forum Nokia is planning to release a smart installer diff --git a/doc/src/snippets/code/doc_src_deployment.qdoc b/doc/src/snippets/code/doc_src_deployment.qdoc index 2d6a78f..8211abe 100644 --- a/doc/src/snippets/code/doc_src_deployment.qdoc +++ b/doc/src/snippets/code/doc_src_deployment.qdoc @@ -476,12 +476,8 @@ default_deployment.pkg_prerules += supported_platforms //! [58] embedded_deployments = \ - "; Embed Open C dependencies" \ - "@\"$${EPOCROOT}nokia_plugin/openc/s60opencsis/pips_s60_1_6_SS.sis\",(0x20013851)" \ - "@\"$${EPOCROOT}nokia_plugin/openc/s60opencsis/openc_ssl_s60_1_6_SS.sis\",(0x200110CB)" \ - "@\"$${EPOCROOT}nokia_plugin/opencpp/s60opencppsis/STDCPP_s60_1_6_SS.sis\",(0x2000F866)" \ "; Embed Qt dependencies" \ - "@\"$$[QT_INSTALL_PREFIX]/qt_rndsigned.sis\",(0x2001E61C)" + "@\"$$[QT_INSTALL_PREFIX]/qt_installer.sis\",(0x2001E62D)" default_deployment.pkg_prerules += embedded_deployments //! [58] -- cgit v0.12 From bb3428531e31ac30a6b04ecc7e3192909108e6a7 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 5 Jan 2010 14:25:47 +0100 Subject: Compile with QT_NO_DOCKWIDGET Task-number: QTBUG-7133 --- src/gui/widgets/qmainwindow.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/widgets/qmainwindow.h b/src/gui/widgets/qmainwindow.h index 8ee0507..316bbb8 100644 --- a/src/gui/widgets/qmainwindow.h +++ b/src/gui/widgets/qmainwindow.h @@ -102,8 +102,10 @@ public: Qt::ToolButtonStyle toolButtonStyle() const; void setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle); +#ifndef QT_NO_DOCKWIDGET bool isAnimated() const; bool isDockNestingEnabled() const; +#endif #ifndef QT_NO_TABBAR bool documentMode() const; -- cgit v0.12 From b8f7adab5a146bea04d598299c04570fe95caedc Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Tue, 5 Jan 2010 13:24:44 +0100 Subject: Make unit test more robust Make sure that on systems that have a default font of "Sans Serif" (or another not really existing font name) the unit test doesn't fail. Reviewed-By: Simon Hausmann Reviewed-By: Olivier --- tests/auto/qfontcombobox/tst_qfontcombobox.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/auto/qfontcombobox/tst_qfontcombobox.cpp b/tests/auto/qfontcombobox/tst_qfontcombobox.cpp index 657be06..73dfe076 100644 --- a/tests/auto/qfontcombobox/tst_qfontcombobox.cpp +++ b/tests/auto/qfontcombobox/tst_qfontcombobox.cpp @@ -123,9 +123,11 @@ void tst_QFontComboBox::currentFont_data() QTest::addColumn("currentFont"); // Normalize the names QFont defaultFont; + QFontInfo fi(defaultFont); + defaultFont = QFont(fi.family()); // make sure we have a real font name and not something like 'Sans Serif'. QTest::newRow("default") << defaultFont; defaultFont.setPointSize(defaultFont.pointSize() + 10); - QTest::newRow("default") << defaultFont; + QTest::newRow("default2") << defaultFont; QFontDatabase db; QStringList list = db.families(); for (int i = 0; i < list.count(); ++i) { -- cgit v0.12 From 43a9da5339b38ca2b4e507efe2d4fa72df6b2ff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Tue, 5 Jan 2010 14:17:05 +0100 Subject: Fixed a bug with distribution of spans. If a span required more size than the rows/columns it spanned, the size of the span was not distributed to the rows it spanned. The result was that the size hints of the layout was not correct, causing the layout to be potentially smaller than the spanning item. Task: QT-2261 Reviewed-by: Alexis --- src/gui/graphicsview/qgridlayoutengine.cpp | 4 +- .../tst_qgraphicsgridlayout.cpp | 382 ++++++++++++--------- 2 files changed, 224 insertions(+), 162 deletions(-) diff --git a/src/gui/graphicsview/qgridlayoutengine.cpp b/src/gui/graphicsview/qgridlayoutengine.cpp index 9497a2f..1fece7a 100644 --- a/src/gui/graphicsview/qgridlayoutengine.cpp +++ b/src/gui/graphicsview/qgridlayoutengine.cpp @@ -182,9 +182,9 @@ void QGridLayoutRowData::distributeMultiCells() QVarLengthArray newSizes(span); for (int j = 0; j < NSizes; ++j) { - qreal extra = compare(totalBox, box, j); + qreal extra = compare(box, totalBox, j); if (extra > 0.0) { - calculateGeometries(start, end, totalBox.q_sizes(j), dummy.data(), newSizes.data(), + calculateGeometries(start, end, box.q_sizes(j), dummy.data(), newSizes.data(), 0, totalBox); for (int k = 0; k < span; ++k) diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index cd1eedd..3d95f92 100644 --- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -108,6 +108,157 @@ private slots: void task236367_maxSizeHint(); }; +class RectWidget : public QGraphicsWidget +{ +public: + RectWidget(QGraphicsItem *parent = 0) : QGraphicsWidget(parent){} + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) + { + Q_UNUSED(option); + Q_UNUSED(widget); + painter->drawRoundRect(rect()); + painter->drawLine(rect().topLeft(), rect().bottomRight()); + painter->drawLine(rect().bottomLeft(), rect().topRight()); + } + + QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const + { + if (m_sizeHints[which].isValid()) { + return m_sizeHints[which]; + } + return QGraphicsWidget::sizeHint(which, constraint); + } + + void setSizeHint(Qt::SizeHint which, const QSizeF &size) { + m_sizeHints[which] = size; + updateGeometry(); + } + + QSizeF m_sizeHints[Qt::NSizeHints]; +}; + +struct ItemDesc +{ + ItemDesc(int row, int col) + : m_pos(qMakePair(row, col)), + m_rowSpan(1), + m_colSpan(1), + m_sizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)), + m_align(0) + { + } + + ItemDesc &rowSpan(int span) { + m_rowSpan = span; + return (*this); + } + + ItemDesc &colSpan(int span) { + m_colSpan = span; + return (*this); + } + + ItemDesc &sizePolicy(const QSizePolicy &sp) { + m_sizePolicy = sp; + return (*this); + } + + ItemDesc &sizePolicy(QSizePolicy::Policy horAndVer) { + m_sizePolicy = QSizePolicy(horAndVer, horAndVer); + return (*this); + } + + ItemDesc &sizePolicyH(QSizePolicy::Policy hor) { + m_sizePolicy.setHorizontalPolicy(hor); + return (*this); + } + + ItemDesc &sizePolicyV(QSizePolicy::Policy ver) { + m_sizePolicy.setVerticalPolicy(ver); + return (*this); + } + + ItemDesc &sizePolicy(QSizePolicy::Policy hor, QSizePolicy::Policy ver) { + m_sizePolicy = QSizePolicy(hor, ver); + return (*this); + } + + ItemDesc &sizeHint(Qt::SizeHint which, const QSizeF &sh) { + m_sizeHints[which] = sh; + return (*this); + } + + ItemDesc &preferredSizeHint(const QSizeF &sh) { + m_sizeHints[Qt::PreferredSize] = sh; + return (*this); + } + + ItemDesc &minSize(const QSizeF &sz) { + m_sizes[Qt::MinimumSize] = sz; + return (*this); + } + ItemDesc &preferredSize(const QSizeF &sz) { + m_sizes[Qt::PreferredSize] = sz; + return (*this); + } + ItemDesc &maxSize(const QSizeF &sz) { + m_sizes[Qt::MaximumSize] = sz; + return (*this); + } + + ItemDesc &alignment(Qt::Alignment alignment) { + m_align = alignment; + return (*this); + } + + void apply(QGraphicsGridLayout *layout, QGraphicsWidget *item) { + item->setSizePolicy(m_sizePolicy); + for (int i = 0; i < Qt::NSizeHints; ++i) { + if (!m_sizes[i].isValid()) + continue; + switch ((Qt::SizeHint)i) { + case Qt::MinimumSize: + item->setMinimumSize(m_sizes[i]); + break; + case Qt::PreferredSize: + item->setPreferredSize(m_sizes[i]); + break; + case Qt::MaximumSize: + item->setMaximumSize(m_sizes[i]); + break; + default: + qWarning("not implemented"); + break; + } + } + layout->addItem(item, m_pos.first, m_pos.second, m_rowSpan, m_colSpan); + layout->setAlignment(item, m_align); + } + + void apply(QGraphicsGridLayout *layout, RectWidget *item) { + for (int i = 0; i < Qt::NSizeHints; ++i) + item->setSizeHint((Qt::SizeHint)i, m_sizeHints[i]); + apply(layout, static_cast(item)); + } + +//private: + QPair m_pos; // row,col + int m_rowSpan; + int m_colSpan; + QSizePolicy m_sizePolicy; + QSizeF m_sizeHints[Qt::NSizeHints]; + QSizeF m_sizes[Qt::NSizeHints]; + Qt::Alignment m_align; +}; + +typedef QList ItemList; +Q_DECLARE_METATYPE(ItemList); + +typedef QList SizeList; +Q_DECLARE_METATYPE(SizeList); + + // This will be called before the first test function is executed. // It is only called once. void tst_QGraphicsGridLayout::initTestCase() @@ -190,36 +341,6 @@ void tst_QGraphicsGridLayout::qgraphicsgridlayout() layout.verticalSpacing(); } -class RectWidget : public QGraphicsWidget -{ -public: - RectWidget(QGraphicsItem *parent = 0) : QGraphicsWidget(parent){} - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) - { - Q_UNUSED(option); - Q_UNUSED(widget); - painter->drawRoundRect(rect()); - painter->drawLine(rect().topLeft(), rect().bottomRight()); - painter->drawLine(rect().bottomLeft(), rect().topRight()); - } - - QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const - { - if (m_sizeHints[which].isValid()) { - return m_sizeHints[which]; - } - return QGraphicsWidget::sizeHint(which, constraint); - } - - void setSizeHint(Qt::SizeHint which, const QSizeF &size) { - m_sizeHints[which] = size; - updateGeometry(); - } - - QSizeF m_sizeHints[Qt::NSizeHints]; -}; - static void populateLayout(QGraphicsGridLayout *gridLayout, int width, int height) { for (int y = 0; y < height; ++y) { @@ -1144,7 +1265,7 @@ void tst_QGraphicsGridLayout::setColumnSpacing() } void tst_QGraphicsGridLayout::setGeometry_data() -{ +{ QTest::addColumn("rect"); QTest::newRow("null") << QRectF(); QTest::newRow("normal") << QRectF(0,0, 50, 50); @@ -1233,28 +1354,84 @@ void tst_QGraphicsGridLayout::setSpacing() void tst_QGraphicsGridLayout::sizeHint_data() { + QTest::addColumn("itemDescriptions"); + QTest::addColumn("expectedMinimumSizeHint"); + QTest::addColumn("expectedPreferredSizeHint"); + QTest::addColumn("expectedMaximumSizeHint"); + + QTest::newRow("rowSpan_larger_than_rows") << (ItemList() + << ItemDesc(0,0) + .minSize(QSizeF(50,300)) + .maxSize(QSizeF(50,300)) + .rowSpan(2) + << ItemDesc(0,1) + .minSize(QSizeF(50,0)) + .preferredSize(QSizeF(50,50)) + .maxSize(QSize(50, 1000)) + << ItemDesc(1,1) + .minSize(QSizeF(50,0)) + .preferredSize(QSizeF(50,50)) + .maxSize(QSize(50, 1000)) + ) + << QSizeF(100, 300) + << QSizeF(100, 300) + << QSizeF(100, 2000); + + QTest::newRow("rowSpan_smaller_than_rows") << (ItemList() + << ItemDesc(0,0) + .minSize(QSizeF(50, 0)) + .preferredSize(QSizeF(50, 50)) + .maxSize(QSizeF(50, 300)) + .rowSpan(2) + << ItemDesc(0,1) + .minSize(QSizeF(50, 50)) + .preferredSize(QSizeF(50, 50)) + .maxSize(QSize(50, 50)) + << ItemDesc(1,1) + .minSize(QSizeF(50, 50)) + .preferredSize(QSizeF(50, 50)) + .maxSize(QSize(50, 50)) + ) + << QSizeF(100, 100) + << QSizeF(100, 100) + << QSizeF(100, 100); - /* - QTest::addColumn("which"); - QTest::addColumn("constraint"); - QTest::addColumn("sizeHint"); - QTest::newRow("null") << 0; - */ } // public QSizeF sizeHint(Qt::SizeHint which, QSizeF const& constraint = QSizeF()) const void tst_QGraphicsGridLayout::sizeHint() { - /* - QFETCH(Qt::SizeHint, which); - QFETCH(QSizeF, constraint); - QFETCH(QSizeF, sizeHint); + QFETCH(ItemList, itemDescriptions); + QFETCH(QSizeF, expectedMinimumSizeHint); + QFETCH(QSizeF, expectedPreferredSizeHint); + QFETCH(QSizeF, expectedMaximumSizeHint); - QGraphicsGridLayout layout; + QGraphicsScene scene; + QGraphicsView view(&scene); + QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); + QGraphicsGridLayout *layout = new QGraphicsGridLayout; + scene.addItem(widget); + widget->setLayout(layout); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0.0); + widget->setContentsMargins(0, 0, 0, 0); + + int i; + for (i = 0; i < itemDescriptions.count(); ++i) { + ItemDesc desc = itemDescriptions.at(i); + RectWidget *item = new RectWidget(widget); + desc.apply(layout, item); + } + + QApplication::sendPostedEvents(0, 0); + + widget->show(); + view.show(); + view.resize(400,300); + QCOMPARE(layout->sizeHint(Qt::MinimumSize), expectedMinimumSizeHint); + QCOMPARE(layout->sizeHint(Qt::PreferredSize), expectedPreferredSizeHint); + QCOMPARE(layout->sizeHint(Qt::MaximumSize), expectedMaximumSizeHint); - layout.sizeHint(); - */ - QSKIP("Test unimplemented", SkipSingle); } void tst_QGraphicsGridLayout::verticalSpacing_data() @@ -1373,121 +1550,6 @@ void tst_QGraphicsGridLayout::removeLayout() QCOMPARE(pushButton->geometry(), r2); } -struct ItemDesc -{ - ItemDesc(int row, int col) - : m_pos(qMakePair(row, col)), - m_rowSpan(1), - m_colSpan(1), - m_sizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)), - m_align(0) - { - } - - ItemDesc &rowSpan(int span) { - m_rowSpan = span; - return (*this); - } - - ItemDesc &colSpan(int span) { - m_colSpan = span; - return (*this); - } - - ItemDesc &sizePolicy(const QSizePolicy &sp) { - m_sizePolicy = sp; - return (*this); - } - - ItemDesc &sizePolicy(QSizePolicy::Policy horAndVer) { - m_sizePolicy = QSizePolicy(horAndVer, horAndVer); - return (*this); - } - - ItemDesc &sizePolicyH(QSizePolicy::Policy hor) { - m_sizePolicy.setHorizontalPolicy(hor); - return (*this); - } - - ItemDesc &sizePolicyV(QSizePolicy::Policy ver) { - m_sizePolicy.setVerticalPolicy(ver); - return (*this); - } - - ItemDesc &sizePolicy(QSizePolicy::Policy hor, QSizePolicy::Policy ver) { - m_sizePolicy = QSizePolicy(hor, ver); - return (*this); - } - - ItemDesc &sizeHint(Qt::SizeHint which, const QSizeF &sh) { - m_sizeHints[which] = sh; - return (*this); - } - - ItemDesc &preferredSizeHint(const QSizeF &sh) { - m_sizeHints[Qt::PreferredSize] = sh; - return (*this); - } - - ItemDesc &minSize(const QSizeF &sz) { - m_sizes[Qt::MinimumSize] = sz; - return (*this); - } - ItemDesc &preferredSize(const QSizeF &sz) { - m_sizes[Qt::PreferredSize] = sz; - return (*this); - } - ItemDesc &maxSize(const QSizeF &sz) { - m_sizes[Qt::MaximumSize] = sz; - return (*this); - } - - ItemDesc &alignment(Qt::Alignment alignment) { - m_align = alignment; - return (*this); - } - - void apply(QGraphicsGridLayout *layout, RectWidget *item) { - item->setSizePolicy(m_sizePolicy); - for (int i = 0; i < Qt::NSizeHints; ++i) { - item->setSizeHint((Qt::SizeHint)i, m_sizeHints[i]); - if (!m_sizes[i].isValid()) - continue; - switch ((Qt::SizeHint)i) { - case Qt::MinimumSize: - item->setMinimumSize(m_sizes[i]); - break; - case Qt::PreferredSize: - item->setPreferredSize(m_sizes[i]); - break; - case Qt::MaximumSize: - item->setMaximumSize(m_sizes[i]); - break; - default: - qWarning("not implemented"); - break; - } - } - layout->addItem(item, m_pos.first, m_pos.second, m_rowSpan, m_colSpan); - layout->setAlignment(item, m_align); - } - -//private: - QPair m_pos; // row,col - int m_rowSpan; - int m_colSpan; - QSizePolicy m_sizePolicy; - QSizeF m_sizeHints[Qt::NSizeHints]; - QSizeF m_sizes[Qt::NSizeHints]; - Qt::Alignment m_align; -}; - -typedef QList ItemList; -Q_DECLARE_METATYPE(ItemList); - -typedef QList SizeList; -Q_DECLARE_METATYPE(SizeList); - void tst_QGraphicsGridLayout::defaultStretchFactors_data() { QTest::addColumn("itemDescriptions"); -- cgit v0.12 From 884c729545c49e3f21559c8eb397508ab9fe6e6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Tue, 5 Jan 2010 15:06:58 +0100 Subject: Fix typo in autotest testcase name. --- tests/auto/qpauseanimation/tst_qpauseanimation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qpauseanimation/tst_qpauseanimation.cpp b/tests/auto/qpauseanimation/tst_qpauseanimation.cpp index 4d0a7a7..a421228 100644 --- a/tests/auto/qpauseanimation/tst_qpauseanimation.cpp +++ b/tests/auto/qpauseanimation/tst_qpauseanimation.cpp @@ -99,7 +99,7 @@ private slots: void changeDirectionWhileRunning(); void noTimerUpdates_data(); void noTimerUpdates(); - void mulitplePauseAnimations(); + void multiplePauseAnimations(); void pauseAndPropertyAnimations(); void pauseResume(); void sequentialPauseGroup(); @@ -169,7 +169,7 @@ void tst_QPauseAnimation::noTimerUpdates() QCOMPARE(animation.m_updateCurrentTimeCount, 1 + loopCount); } -void tst_QPauseAnimation::mulitplePauseAnimations() +void tst_QPauseAnimation::multiplePauseAnimations() { EnableConsistentTiming enabled; -- cgit v0.12 From f72165460d27860cabd51691f4d935fd74b50f80 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 5 Jan 2010 13:42:49 +0100 Subject: Prevent a crash when creating an inputContext from the QApplication dtor. When accessing the global input context from the QWidget destructor access it directly instead of calling a helper function. Don't even bother to create an input context if QApplication is being destroyed (just in case if the user is calling the QApplication::inputContext manually from the destructor). Task-number: QTBUG-7105 Reviewed-by: Simon Hausmann --- src/gui/kernel/qapplication.cpp | 2 ++ src/gui/kernel/qwidget_x11.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 4165c95..cdd0c1b 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -5230,6 +5230,8 @@ QInputContext *QApplication::inputContext() const { Q_D(const QApplication); Q_UNUSED(d);// only static members being used. + if (QApplicationPrivate::is_app_closing) + return d->inputContext; #ifdef Q_WS_X11 if (!X11) return 0; diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp index 0bc9cbc..f9db485 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -1084,7 +1084,7 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows) } else { // release previous focus information participating with // preedit preservation of qic - QInputContext *qic = inputContext(); + QInputContext *qic = QApplicationPrivate::inputContext; if (qic) qic->widgetDestroyed(this); } -- cgit v0.12 From b167c8b31c6da7b3eb5083396c447c679f1a591a Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Tue, 5 Jan 2010 16:43:24 +0100 Subject: Display broken symlinks in the filesystem model. A broken symlink has a -1 size so we need to special case that. Task-number:QTBUG-7119 Reviewed-by:olivier --- src/gui/dialogs/qfilesystemmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/gui/dialogs/qfilesystemmodel.cpp index 8e78503..21cb737 100644 --- a/src/gui/dialogs/qfilesystemmodel.cpp +++ b/src/gui/dialogs/qfilesystemmodel.cpp @@ -1779,7 +1779,7 @@ void QFileSystemModelPrivate::_q_fileSystemChanged(const QString &path, const QL node->fileName = fileName; } - if (info.size() == -1) { + if (info.size() == -1 && !info.isSymLink()) { removeNode(parentNode, fileName); continue; } -- cgit v0.12 From 522660346023c025d14bfa029f70c88d18eb609d Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 5 Jan 2010 17:10:24 +0100 Subject: uic3/uic: Ignore buttonGroupId property when there is no parent QButtonGroup The uic from Qt3 did the same. And otherwise uic3/uic generates a radiobutton->setButtonGroupId(val) line, which does not compile. Reviewed-by: Friedemann Kleint --- src/tools/uic/cpp/cppwriteinitialization.cpp | 7 +- tests/auto/uic/baseline/config_fromuic3.ui | 1647 ++++++++++++++++++++++++++ tests/auto/uic/baseline/config_fromuic3.ui.h | 715 +++++++++++ tests/auto/uic3/baseline/config.ui | 11 + tests/auto/uic3/baseline/config.ui.4 | 10 + 5 files changed, 2387 insertions(+), 3 deletions(-) create mode 100644 tests/auto/uic/baseline/config_fromuic3.ui create mode 100644 tests/auto/uic/baseline/config_fromuic3.ui.h diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 88dfa98..3bc56ae 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -1221,9 +1221,10 @@ void WriteInitialization::writeProperties(const QString &varName, const DomRect *r = p->elementRect(); m_output << m_indent << varName << "->resize(" << r->elementWidth() << ", " << r->elementHeight() << ");\n"; continue; - } else if (propertyName == QLatin1String("buttonGroupId") && buttonGroupWidget) { // Q3ButtonGroup support - m_output << m_indent << m_driver->findOrInsertWidget(buttonGroupWidget) << "->insert(" - << varName << ", " << p->elementNumber() << ");\n"; + } else if (propertyName == QLatin1String("buttonGroupId")) { // Q3ButtonGroup support + if (buttonGroupWidget) + m_output << m_indent << m_driver->findOrInsertWidget(buttonGroupWidget) << "->insert(" + << varName << ", " << p->elementNumber() << ");\n"; continue; } else if (propertyName == QLatin1String("currentRow") // QListWidget::currentRow && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QListWidget"))) { diff --git a/tests/auto/uic/baseline/config_fromuic3.ui b/tests/auto/uic/baseline/config_fromuic3.ui new file mode 100644 index 0000000..0bd6256 --- /dev/null +++ b/tests/auto/uic/baseline/config_fromuic3.ui @@ -0,0 +1,1647 @@ + + + + ********************************************************************* +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +********************************************************************* + + Config + + + + 0 + 0 + 481 + 645 + + + + Configure + + + logo.png + + + true + + + + 11 + + + 6 + + + + + Depth + + + + + 11 + 19 + 229 + 19 + + + + 1 bit monochrome + + + + + + 11 + 44 + 229 + 19 + + + + 4 bit grayscale + + + + + + 11 + 69 + 229 + 19 + + + + 8 bit + + + + + + 11 + 94 + 229 + 19 + + + + 12 (16) bit + + + + + + 11 + 119 + 229 + 19 + + + + 16 bit + + + + + + 11 + 144 + 229 + 19 + + + + 32 bit + + + + + + + + 0 + + + 6 + + + + + + 20 + 20 + + + + QSizePolicy::Expanding + + + Qt::Horizontal + + + + + + + &OK + + + true + + + true + + + + + + + &Cancel + + + true + + + + + + + + + Emulate touch screen (no mouse move). + + + + + + + Gamma + + + + 11 + + + 6 + + + + + Blue + + + false + + + + + + + + + + 0 + 0 + 0 + + + 0 + 0 + 255 + + + 127 + 127 + 255 + + + 63 + 63 + 255 + + + 0 + 0 + 127 + + + 0 + 0 + 170 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 220 + 220 + 220 + + + 0 + 0 + 0 + + + 10 + 95 + 137 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + + 0 + 0 + 0 + + + 0 + 0 + 255 + + + 127 + 127 + 255 + + + 38 + 38 + 255 + + + 0 + 0 + 127 + + + 0 + 0 + 170 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 220 + 220 + 220 + + + 0 + 0 + 0 + + + 10 + 95 + 137 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + + 128 + 128 + 128 + + + 0 + 0 + 255 + + + 127 + 127 + 255 + + + 38 + 38 + 255 + + + 0 + 0 + 127 + + + 0 + 0 + 170 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 128 + 128 + 128 + + + 255 + 255 + 255 + + + 220 + 220 + 220 + + + 0 + 0 + 0 + + + 10 + 95 + 137 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + + + 400 + + + 100 + + + Qt::Horizontal + + + + + + + 1.0 + + + false + + + + + + + + 20 + 20 + + + + QSizePolicy::Expanding + + + Qt::Vertical + + + + + + + Green + + + false + + + + + + + + + + 0 + 0 + 0 + + + 0 + 255 + 0 + + + 127 + 255 + 127 + + + 63 + 255 + 63 + + + 0 + 127 + 0 + + + 0 + 170 + 0 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 220 + 220 + 220 + + + 0 + 0 + 0 + + + 10 + 95 + 137 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + + 0 + 0 + 0 + + + 0 + 255 + 0 + + + 127 + 255 + 127 + + + 38 + 255 + 38 + + + 0 + 127 + 0 + + + 0 + 170 + 0 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 220 + 220 + 220 + + + 0 + 0 + 0 + + + 10 + 95 + 137 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + + 128 + 128 + 128 + + + 0 + 255 + 0 + + + 127 + 255 + 127 + + + 38 + 255 + 38 + + + 0 + 127 + 0 + + + 0 + 170 + 0 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 128 + 128 + 128 + + + 255 + 255 + 255 + + + 220 + 220 + 220 + + + 0 + 0 + 0 + + + 10 + 95 + 137 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + + + 400 + + + 100 + + + Qt::Horizontal + + + + + + + 1.0 + + + false + + + + + + + All + + + false + + + + + + + 1.0 + + + false + + + + + + + + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 255 + 255 + 255 + + + 255 + 255 + 255 + + + 127 + 127 + 127 + + + 170 + 170 + 170 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 220 + 220 + 220 + + + 0 + 0 + 0 + + + 10 + 95 + 137 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 255 + 255 + 255 + + + 255 + 255 + 255 + + + 127 + 127 + 127 + + + 170 + 170 + 170 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 220 + 220 + 220 + + + 0 + 0 + 0 + + + 10 + 95 + 137 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + + 128 + 128 + 128 + + + 255 + 255 + 255 + + + 255 + 255 + 255 + + + 255 + 255 + 255 + + + 127 + 127 + 127 + + + 170 + 170 + 170 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 128 + 128 + 128 + + + 255 + 255 + 255 + + + 220 + 220 + 220 + + + 0 + 0 + 0 + + + 10 + 95 + 137 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + + + 400 + + + 100 + + + Qt::Horizontal + + + + + + + Red + + + false + + + + + + + 1.0 + + + false + + + + + + + + + + 0 + 0 + 0 + + + 255 + 0 + 0 + + + 255 + 127 + 127 + + + 255 + 63 + 63 + + + 127 + 0 + 0 + + + 170 + 0 + 0 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 220 + 220 + 220 + + + 0 + 0 + 0 + + + 10 + 95 + 137 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + + 0 + 0 + 0 + + + 255 + 0 + 0 + + + 255 + 127 + 127 + + + 255 + 38 + 38 + + + 127 + 0 + 0 + + + 170 + 0 + 0 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 220 + 220 + 220 + + + 0 + 0 + 0 + + + 10 + 95 + 137 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + + 128 + 128 + 128 + + + 255 + 0 + 0 + + + 255 + 127 + 127 + + + 255 + 38 + 38 + + + 127 + 0 + 0 + + + 170 + 0 + 0 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 128 + 128 + 128 + + + 255 + 255 + 255 + + + 220 + 220 + 220 + + + 0 + 0 + 0 + + + 10 + 95 + 137 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + + + 400 + + + 100 + + + Qt::Horizontal + + + + + + + + 20 + 20 + + + + QSizePolicy::Expanding + + + Qt::Vertical + + + + + + + + 20 + 20 + + + + QSizePolicy::Expanding + + + Qt::Vertical + + + + + + + Set all to 1.0 + + + + + + + + + + + 20 + 20 + + + + QSizePolicy::Expanding + + + Qt::Vertical + + + + + + + + + + + 5 + 5 + 0 + 0 + + + + Size + + + + 11 + + + 6 + + + + + 240x320 "PDA" + + + + + + + 320x240 "TV" + + + + + + + 640x480 "VGA" + + + + + + + 0 + + + 6 + + + + + Custom + + + + + + + 1280 + + + 1 + + + 16 + + + 400 + + + + + + + 1024 + + + 1 + + + 16 + + + 300 + + + + + + + + + 0 + + + 6 + + + + + + 0 + 0 + 0 + 0 + + + + Skin + + + + + + + + 5 + 0 + 0 + 0 + + + + + pda.skin + + + + + ipaq.skin + + + + + qpe.skin + + + + + cassiopeia.skin + + + + + other.skin + + + + + + + + + + + + + <p>Note that any applications using the virtual framebuffer will be terminated if you change the Size or Depth <i>above</i>. You may freely modify the Gamma <i>below</i>. + + + false + + + + + + + Test + + + 1 + + + + + + + + + GammaView + QWidget +
gammaview.h
+ + 64 + 64 + + 0 + + 3 + 3 + + image0 +
+
+ + + 789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758 + + + + + buttonOk + clicked() + Config + accept() + + + buttonCancel + clicked() + Config + reject() + + +
diff --git a/tests/auto/uic/baseline/config_fromuic3.ui.h b/tests/auto/uic/baseline/config_fromuic3.ui.h new file mode 100644 index 0000000..ec20d05 --- /dev/null +++ b/tests/auto/uic/baseline/config_fromuic3.ui.h @@ -0,0 +1,715 @@ +/* +********************************************************************* +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +********************************************************************* +*/ + +/******************************************************************************** +** Form generated from reading UI file 'config_fromuic3.ui' +** +** Created: Thu Dec 17 12:48:42 2009 +** by: Qt User Interface Compiler version 4.6.1 +** +** WARNING! All changes made in this file will be lost when recompiling UI file! +********************************************************************************/ + +#ifndef CONFIG_FROMUIC3_H +#define CONFIG_FROMUIC3_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "gammaview.h" + +QT_BEGIN_NAMESPACE + +class Ui_Config +{ +public: + QGridLayout *gridLayout; + Q3ButtonGroup *ButtonGroup2; + QRadioButton *depth_1; + QRadioButton *depth_4gray; + QRadioButton *depth_8; + QRadioButton *depth_12; + QRadioButton *depth_16; + QRadioButton *depth_32; + QHBoxLayout *hboxLayout; + QSpacerItem *Horizontal_Spacing2; + QPushButton *buttonOk; + QPushButton *buttonCancel; + QCheckBox *touchScreen; + Q3GroupBox *GroupBox1; + QGridLayout *gridLayout1; + QLabel *TextLabel3; + QSlider *bslider; + QLabel *blabel; + QSpacerItem *Spacer3; + QLabel *TextLabel2; + QSlider *gslider; + QLabel *glabel; + QLabel *TextLabel7; + QLabel *TextLabel8; + QSlider *gammaslider; + QLabel *TextLabel1_2; + QLabel *rlabel; + QSlider *rslider; + QSpacerItem *Spacer2; + QSpacerItem *Spacer4; + QPushButton *PushButton3; + GammaView *MyCustomWidget1; + QSpacerItem *Spacer5; + Q3ButtonGroup *ButtonGroup1; + QVBoxLayout *vboxLayout; + QRadioButton *size_240_320; + QRadioButton *size_320_240; + QRadioButton *size_640_480; + QHBoxLayout *hboxLayout1; + QRadioButton *size_custom; + QSpinBox *size_width; + QSpinBox *size_height; + QHBoxLayout *hboxLayout2; + QRadioButton *size_skin; + QComboBox *skin; + QLabel *TextLabel1; + QRadioButton *test_for_useless_buttongroupId; + + void setupUi(QDialog *Config) + { + if (Config->objectName().isEmpty()) + Config->setObjectName(QString::fromUtf8("Config")); + Config->resize(481, 645); + Config->setWindowIcon(QPixmap(QString::fromUtf8("logo.png"))); + Config->setSizeGripEnabled(true); + gridLayout = new QGridLayout(Config); + gridLayout->setSpacing(6); + gridLayout->setContentsMargins(11, 11, 11, 11); + gridLayout->setObjectName(QString::fromUtf8("gridLayout")); + ButtonGroup2 = new Q3ButtonGroup(Config); + ButtonGroup2->setObjectName(QString::fromUtf8("ButtonGroup2")); + depth_1 = new QRadioButton(ButtonGroup2); + depth_1->setObjectName(QString::fromUtf8("depth_1")); + depth_1->setGeometry(QRect(11, 19, 229, 19)); + depth_4gray = new QRadioButton(ButtonGroup2); + depth_4gray->setObjectName(QString::fromUtf8("depth_4gray")); + depth_4gray->setGeometry(QRect(11, 44, 229, 19)); + depth_8 = new QRadioButton(ButtonGroup2); + depth_8->setObjectName(QString::fromUtf8("depth_8")); + depth_8->setGeometry(QRect(11, 69, 229, 19)); + depth_12 = new QRadioButton(ButtonGroup2); + depth_12->setObjectName(QString::fromUtf8("depth_12")); + depth_12->setGeometry(QRect(11, 94, 229, 19)); + depth_16 = new QRadioButton(ButtonGroup2); + depth_16->setObjectName(QString::fromUtf8("depth_16")); + depth_16->setGeometry(QRect(11, 119, 229, 19)); + depth_32 = new QRadioButton(ButtonGroup2); + depth_32->setObjectName(QString::fromUtf8("depth_32")); + depth_32->setGeometry(QRect(11, 144, 229, 19)); + + gridLayout->addWidget(ButtonGroup2, 0, 1, 1, 1); + + hboxLayout = new QHBoxLayout(); + hboxLayout->setSpacing(6); + hboxLayout->setContentsMargins(0, 0, 0, 0); + hboxLayout->setObjectName(QString::fromUtf8("hboxLayout")); + Horizontal_Spacing2 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + + hboxLayout->addItem(Horizontal_Spacing2); + + buttonOk = new QPushButton(Config); + buttonOk->setObjectName(QString::fromUtf8("buttonOk")); + buttonOk->setAutoDefault(true); + buttonOk->setDefault(true); + + hboxLayout->addWidget(buttonOk); + + buttonCancel = new QPushButton(Config); + buttonCancel->setObjectName(QString::fromUtf8("buttonCancel")); + buttonCancel->setAutoDefault(true); + + hboxLayout->addWidget(buttonCancel); + + + gridLayout->addLayout(hboxLayout, 4, 0, 1, 2); + + touchScreen = new QCheckBox(Config); + touchScreen->setObjectName(QString::fromUtf8("touchScreen")); + + gridLayout->addWidget(touchScreen, 2, 0, 1, 2); + + GroupBox1 = new Q3GroupBox(Config); + GroupBox1->setObjectName(QString::fromUtf8("GroupBox1")); + GroupBox1->setColumnLayout(0, Qt::Vertical); + GroupBox1->layout()->setSpacing(6); + GroupBox1->layout()->setContentsMargins(11, 11, 11, 11); + gridLayout1 = new QGridLayout(); + QBoxLayout *boxlayout = qobject_cast(GroupBox1->layout()); + if (boxlayout) + boxlayout->addLayout(gridLayout1); + gridLayout1->setAlignment(Qt::AlignTop); + gridLayout1->setObjectName(QString::fromUtf8("gridLayout1")); + TextLabel3 = new QLabel(GroupBox1); + TextLabel3->setObjectName(QString::fromUtf8("TextLabel3")); + TextLabel3->setWordWrap(false); + + gridLayout1->addWidget(TextLabel3, 6, 0, 1, 1); + + bslider = new QSlider(GroupBox1); + bslider->setObjectName(QString::fromUtf8("bslider")); + QPalette palette; + palette.setColor(QPalette::Active, static_cast(0), QColor(0, 0, 0)); + palette.setColor(QPalette::Active, static_cast(1), QColor(0, 0, 255)); + palette.setColor(QPalette::Active, static_cast(2), QColor(127, 127, 255)); + palette.setColor(QPalette::Active, static_cast(3), QColor(63, 63, 255)); + palette.setColor(QPalette::Active, static_cast(4), QColor(0, 0, 127)); + palette.setColor(QPalette::Active, static_cast(5), QColor(0, 0, 170)); + palette.setColor(QPalette::Active, static_cast(6), QColor(0, 0, 0)); + palette.setColor(QPalette::Active, static_cast(7), QColor(255, 255, 255)); + palette.setColor(QPalette::Active, static_cast(8), QColor(0, 0, 0)); + palette.setColor(QPalette::Active, static_cast(9), QColor(255, 255, 255)); + palette.setColor(QPalette::Active, static_cast(10), QColor(220, 220, 220)); + palette.setColor(QPalette::Active, static_cast(11), QColor(0, 0, 0)); + palette.setColor(QPalette::Active, static_cast(12), QColor(10, 95, 137)); + palette.setColor(QPalette::Active, static_cast(13), QColor(255, 255, 255)); + palette.setColor(QPalette::Active, static_cast(14), QColor(0, 0, 0)); + palette.setColor(QPalette::Active, static_cast(15), QColor(0, 0, 0)); + palette.setColor(QPalette::Inactive, static_cast(0), QColor(0, 0, 0)); + palette.setColor(QPalette::Inactive, static_cast(1), QColor(0, 0, 255)); + palette.setColor(QPalette::Inactive, static_cast(2), QColor(127, 127, 255)); + palette.setColor(QPalette::Inactive, static_cast(3), QColor(38, 38, 255)); + palette.setColor(QPalette::Inactive, static_cast(4), QColor(0, 0, 127)); + palette.setColor(QPalette::Inactive, static_cast(5), QColor(0, 0, 170)); + palette.setColor(QPalette::Inactive, static_cast(6), QColor(0, 0, 0)); + palette.setColor(QPalette::Inactive, static_cast(7), QColor(255, 255, 255)); + palette.setColor(QPalette::Inactive, static_cast(8), QColor(0, 0, 0)); + palette.setColor(QPalette::Inactive, static_cast(9), QColor(255, 255, 255)); + palette.setColor(QPalette::Inactive, static_cast(10), QColor(220, 220, 220)); + palette.setColor(QPalette::Inactive, static_cast(11), QColor(0, 0, 0)); + palette.setColor(QPalette::Inactive, static_cast(12), QColor(10, 95, 137)); + palette.setColor(QPalette::Inactive, static_cast(13), QColor(255, 255, 255)); + palette.setColor(QPalette::Inactive, static_cast(14), QColor(0, 0, 0)); + palette.setColor(QPalette::Inactive, static_cast(15), QColor(0, 0, 0)); + palette.setColor(QPalette::Disabled, static_cast(0), QColor(128, 128, 128)); + palette.setColor(QPalette::Disabled, static_cast(1), QColor(0, 0, 255)); + palette.setColor(QPalette::Disabled, static_cast(2), QColor(127, 127, 255)); + palette.setColor(QPalette::Disabled, static_cast(3), QColor(38, 38, 255)); + palette.setColor(QPalette::Disabled, static_cast(4), QColor(0, 0, 127)); + palette.setColor(QPalette::Disabled, static_cast(5), QColor(0, 0, 170)); + palette.setColor(QPalette::Disabled, static_cast(6), QColor(0, 0, 0)); + palette.setColor(QPalette::Disabled, static_cast(7), QColor(255, 255, 255)); + palette.setColor(QPalette::Disabled, static_cast(8), QColor(128, 128, 128)); + palette.setColor(QPalette::Disabled, static_cast(9), QColor(255, 255, 255)); + palette.setColor(QPalette::Disabled, static_cast(10), QColor(220, 220, 220)); + palette.setColor(QPalette::Disabled, static_cast(11), QColor(0, 0, 0)); + palette.setColor(QPalette::Disabled, static_cast(12), QColor(10, 95, 137)); + palette.setColor(QPalette::Disabled, static_cast(13), QColor(255, 255, 255)); + palette.setColor(QPalette::Disabled, static_cast(14), QColor(0, 0, 0)); + palette.setColor(QPalette::Disabled, static_cast(15), QColor(0, 0, 0)); + bslider->setPalette(palette); + bslider->setMaximum(400); + bslider->setValue(100); + bslider->setOrientation(Qt::Horizontal); + + gridLayout1->addWidget(bslider, 6, 1, 1, 1); + + blabel = new QLabel(GroupBox1); + blabel->setObjectName(QString::fromUtf8("blabel")); + blabel->setWordWrap(false); + + gridLayout1->addWidget(blabel, 6, 2, 1, 1); + + Spacer3 = new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding); + + gridLayout1->addItem(Spacer3, 5, 1, 1, 1); + + TextLabel2 = new QLabel(GroupBox1); + TextLabel2->setObjectName(QString::fromUtf8("TextLabel2")); + TextLabel2->setWordWrap(false); + + gridLayout1->addWidget(TextLabel2, 4, 0, 1, 1); + + gslider = new QSlider(GroupBox1); + gslider->setObjectName(QString::fromUtf8("gslider")); + QPalette palette1; + palette1.setColor(QPalette::Active, static_cast(0), QColor(0, 0, 0)); + palette1.setColor(QPalette::Active, static_cast(1), QColor(0, 255, 0)); + palette1.setColor(QPalette::Active, static_cast(2), QColor(127, 255, 127)); + palette1.setColor(QPalette::Active, static_cast(3), QColor(63, 255, 63)); + palette1.setColor(QPalette::Active, static_cast(4), QColor(0, 127, 0)); + palette1.setColor(QPalette::Active, static_cast(5), QColor(0, 170, 0)); + palette1.setColor(QPalette::Active, static_cast(6), QColor(0, 0, 0)); + palette1.setColor(QPalette::Active, static_cast(7), QColor(255, 255, 255)); + palette1.setColor(QPalette::Active, static_cast(8), QColor(0, 0, 0)); + palette1.setColor(QPalette::Active, static_cast(9), QColor(255, 255, 255)); + palette1.setColor(QPalette::Active, static_cast(10), QColor(220, 220, 220)); + palette1.setColor(QPalette::Active, static_cast(11), QColor(0, 0, 0)); + palette1.setColor(QPalette::Active, static_cast(12), QColor(10, 95, 137)); + palette1.setColor(QPalette::Active, static_cast(13), QColor(255, 255, 255)); + palette1.setColor(QPalette::Active, static_cast(14), QColor(0, 0, 0)); + palette1.setColor(QPalette::Active, static_cast(15), QColor(0, 0, 0)); + palette1.setColor(QPalette::Inactive, static_cast(0), QColor(0, 0, 0)); + palette1.setColor(QPalette::Inactive, static_cast(1), QColor(0, 255, 0)); + palette1.setColor(QPalette::Inactive, static_cast(2), QColor(127, 255, 127)); + palette1.setColor(QPalette::Inactive, static_cast(3), QColor(38, 255, 38)); + palette1.setColor(QPalette::Inactive, static_cast(4), QColor(0, 127, 0)); + palette1.setColor(QPalette::Inactive, static_cast(5), QColor(0, 170, 0)); + palette1.setColor(QPalette::Inactive, static_cast(6), QColor(0, 0, 0)); + palette1.setColor(QPalette::Inactive, static_cast(7), QColor(255, 255, 255)); + palette1.setColor(QPalette::Inactive, static_cast(8), QColor(0, 0, 0)); + palette1.setColor(QPalette::Inactive, static_cast(9), QColor(255, 255, 255)); + palette1.setColor(QPalette::Inactive, static_cast(10), QColor(220, 220, 220)); + palette1.setColor(QPalette::Inactive, static_cast(11), QColor(0, 0, 0)); + palette1.setColor(QPalette::Inactive, static_cast(12), QColor(10, 95, 137)); + palette1.setColor(QPalette::Inactive, static_cast(13), QColor(255, 255, 255)); + palette1.setColor(QPalette::Inactive, static_cast(14), QColor(0, 0, 0)); + palette1.setColor(QPalette::Inactive, static_cast(15), QColor(0, 0, 0)); + palette1.setColor(QPalette::Disabled, static_cast(0), QColor(128, 128, 128)); + palette1.setColor(QPalette::Disabled, static_cast(1), QColor(0, 255, 0)); + palette1.setColor(QPalette::Disabled, static_cast(2), QColor(127, 255, 127)); + palette1.setColor(QPalette::Disabled, static_cast(3), QColor(38, 255, 38)); + palette1.setColor(QPalette::Disabled, static_cast(4), QColor(0, 127, 0)); + palette1.setColor(QPalette::Disabled, static_cast(5), QColor(0, 170, 0)); + palette1.setColor(QPalette::Disabled, static_cast(6), QColor(0, 0, 0)); + palette1.setColor(QPalette::Disabled, static_cast(7), QColor(255, 255, 255)); + palette1.setColor(QPalette::Disabled, static_cast(8), QColor(128, 128, 128)); + palette1.setColor(QPalette::Disabled, static_cast(9), QColor(255, 255, 255)); + palette1.setColor(QPalette::Disabled, static_cast(10), QColor(220, 220, 220)); + palette1.setColor(QPalette::Disabled, static_cast(11), QColor(0, 0, 0)); + palette1.setColor(QPalette::Disabled, static_cast(12), QColor(10, 95, 137)); + palette1.setColor(QPalette::Disabled, static_cast(13), QColor(255, 255, 255)); + palette1.setColor(QPalette::Disabled, static_cast(14), QColor(0, 0, 0)); + palette1.setColor(QPalette::Disabled, static_cast(15), QColor(0, 0, 0)); + gslider->setPalette(palette1); + gslider->setMaximum(400); + gslider->setValue(100); + gslider->setOrientation(Qt::Horizontal); + + gridLayout1->addWidget(gslider, 4, 1, 1, 1); + + glabel = new QLabel(GroupBox1); + glabel->setObjectName(QString::fromUtf8("glabel")); + glabel->setWordWrap(false); + + gridLayout1->addWidget(glabel, 4, 2, 1, 1); + + TextLabel7 = new QLabel(GroupBox1); + TextLabel7->setObjectName(QString::fromUtf8("TextLabel7")); + TextLabel7->setWordWrap(false); + + gridLayout1->addWidget(TextLabel7, 0, 0, 1, 1); + + TextLabel8 = new QLabel(GroupBox1); + TextLabel8->setObjectName(QString::fromUtf8("TextLabel8")); + TextLabel8->setWordWrap(false); + + gridLayout1->addWidget(TextLabel8, 0, 2, 1, 1); + + gammaslider = new QSlider(GroupBox1); + gammaslider->setObjectName(QString::fromUtf8("gammaslider")); + QPalette palette2; + palette2.setColor(QPalette::Active, static_cast(0), QColor(0, 0, 0)); + palette2.setColor(QPalette::Active, static_cast(1), QColor(255, 255, 255)); + palette2.setColor(QPalette::Active, static_cast(2), QColor(255, 255, 255)); + palette2.setColor(QPalette::Active, static_cast(3), QColor(255, 255, 255)); + palette2.setColor(QPalette::Active, static_cast(4), QColor(127, 127, 127)); + palette2.setColor(QPalette::Active, static_cast(5), QColor(170, 170, 170)); + palette2.setColor(QPalette::Active, static_cast(6), QColor(0, 0, 0)); + palette2.setColor(QPalette::Active, static_cast(7), QColor(255, 255, 255)); + palette2.setColor(QPalette::Active, static_cast(8), QColor(0, 0, 0)); + palette2.setColor(QPalette::Active, static_cast(9), QColor(255, 255, 255)); + palette2.setColor(QPalette::Active, static_cast(10), QColor(220, 220, 220)); + palette2.setColor(QPalette::Active, static_cast(11), QColor(0, 0, 0)); + palette2.setColor(QPalette::Active, static_cast(12), QColor(10, 95, 137)); + palette2.setColor(QPalette::Active, static_cast(13), QColor(255, 255, 255)); + palette2.setColor(QPalette::Active, static_cast(14), QColor(0, 0, 0)); + palette2.setColor(QPalette::Active, static_cast(15), QColor(0, 0, 0)); + palette2.setColor(QPalette::Inactive, static_cast(0), QColor(0, 0, 0)); + palette2.setColor(QPalette::Inactive, static_cast(1), QColor(255, 255, 255)); + palette2.setColor(QPalette::Inactive, static_cast(2), QColor(255, 255, 255)); + palette2.setColor(QPalette::Inactive, static_cast(3), QColor(255, 255, 255)); + palette2.setColor(QPalette::Inactive, static_cast(4), QColor(127, 127, 127)); + palette2.setColor(QPalette::Inactive, static_cast(5), QColor(170, 170, 170)); + palette2.setColor(QPalette::Inactive, static_cast(6), QColor(0, 0, 0)); + palette2.setColor(QPalette::Inactive, static_cast(7), QColor(255, 255, 255)); + palette2.setColor(QPalette::Inactive, static_cast(8), QColor(0, 0, 0)); + palette2.setColor(QPalette::Inactive, static_cast(9), QColor(255, 255, 255)); + palette2.setColor(QPalette::Inactive, static_cast(10), QColor(220, 220, 220)); + palette2.setColor(QPalette::Inactive, static_cast(11), QColor(0, 0, 0)); + palette2.setColor(QPalette::Inactive, static_cast(12), QColor(10, 95, 137)); + palette2.setColor(QPalette::Inactive, static_cast(13), QColor(255, 255, 255)); + palette2.setColor(QPalette::Inactive, static_cast(14), QColor(0, 0, 0)); + palette2.setColor(QPalette::Inactive, static_cast(15), QColor(0, 0, 0)); + palette2.setColor(QPalette::Disabled, static_cast(0), QColor(128, 128, 128)); + palette2.setColor(QPalette::Disabled, static_cast(1), QColor(255, 255, 255)); + palette2.setColor(QPalette::Disabled, static_cast(2), QColor(255, 255, 255)); + palette2.setColor(QPalette::Disabled, static_cast(3), QColor(255, 255, 255)); + palette2.setColor(QPalette::Disabled, static_cast(4), QColor(127, 127, 127)); + palette2.setColor(QPalette::Disabled, static_cast(5), QColor(170, 170, 170)); + palette2.setColor(QPalette::Disabled, static_cast(6), QColor(0, 0, 0)); + palette2.setColor(QPalette::Disabled, static_cast(7), QColor(255, 255, 255)); + palette2.setColor(QPalette::Disabled, static_cast(8), QColor(128, 128, 128)); + palette2.setColor(QPalette::Disabled, static_cast(9), QColor(255, 255, 255)); + palette2.setColor(QPalette::Disabled, static_cast(10), QColor(220, 220, 220)); + palette2.setColor(QPalette::Disabled, static_cast(11), QColor(0, 0, 0)); + palette2.setColor(QPalette::Disabled, static_cast(12), QColor(10, 95, 137)); + palette2.setColor(QPalette::Disabled, static_cast(13), QColor(255, 255, 255)); + palette2.setColor(QPalette::Disabled, static_cast(14), QColor(0, 0, 0)); + palette2.setColor(QPalette::Disabled, static_cast(15), QColor(0, 0, 0)); + gammaslider->setPalette(palette2); + gammaslider->setMaximum(400); + gammaslider->setValue(100); + gammaslider->setOrientation(Qt::Horizontal); + + gridLayout1->addWidget(gammaslider, 0, 1, 1, 1); + + TextLabel1_2 = new QLabel(GroupBox1); + TextLabel1_2->setObjectName(QString::fromUtf8("TextLabel1_2")); + TextLabel1_2->setWordWrap(false); + + gridLayout1->addWidget(TextLabel1_2, 2, 0, 1, 1); + + rlabel = new QLabel(GroupBox1); + rlabel->setObjectName(QString::fromUtf8("rlabel")); + rlabel->setWordWrap(false); + + gridLayout1->addWidget(rlabel, 2, 2, 1, 1); + + rslider = new QSlider(GroupBox1); + rslider->setObjectName(QString::fromUtf8("rslider")); + QPalette palette3; + palette3.setColor(QPalette::Active, static_cast(0), QColor(0, 0, 0)); + palette3.setColor(QPalette::Active, static_cast(1), QColor(255, 0, 0)); + palette3.setColor(QPalette::Active, static_cast(2), QColor(255, 127, 127)); + palette3.setColor(QPalette::Active, static_cast(3), QColor(255, 63, 63)); + palette3.setColor(QPalette::Active, static_cast(4), QColor(127, 0, 0)); + palette3.setColor(QPalette::Active, static_cast(5), QColor(170, 0, 0)); + palette3.setColor(QPalette::Active, static_cast(6), QColor(0, 0, 0)); + palette3.setColor(QPalette::Active, static_cast(7), QColor(255, 255, 255)); + palette3.setColor(QPalette::Active, static_cast(8), QColor(0, 0, 0)); + palette3.setColor(QPalette::Active, static_cast(9), QColor(255, 255, 255)); + palette3.setColor(QPalette::Active, static_cast(10), QColor(220, 220, 220)); + palette3.setColor(QPalette::Active, static_cast(11), QColor(0, 0, 0)); + palette3.setColor(QPalette::Active, static_cast(12), QColor(10, 95, 137)); + palette3.setColor(QPalette::Active, static_cast(13), QColor(255, 255, 255)); + palette3.setColor(QPalette::Active, static_cast(14), QColor(0, 0, 0)); + palette3.setColor(QPalette::Active, static_cast(15), QColor(0, 0, 0)); + palette3.setColor(QPalette::Inactive, static_cast(0), QColor(0, 0, 0)); + palette3.setColor(QPalette::Inactive, static_cast(1), QColor(255, 0, 0)); + palette3.setColor(QPalette::Inactive, static_cast(2), QColor(255, 127, 127)); + palette3.setColor(QPalette::Inactive, static_cast(3), QColor(255, 38, 38)); + palette3.setColor(QPalette::Inactive, static_cast(4), QColor(127, 0, 0)); + palette3.setColor(QPalette::Inactive, static_cast(5), QColor(170, 0, 0)); + palette3.setColor(QPalette::Inactive, static_cast(6), QColor(0, 0, 0)); + palette3.setColor(QPalette::Inactive, static_cast(7), QColor(255, 255, 255)); + palette3.setColor(QPalette::Inactive, static_cast(8), QColor(0, 0, 0)); + palette3.setColor(QPalette::Inactive, static_cast(9), QColor(255, 255, 255)); + palette3.setColor(QPalette::Inactive, static_cast(10), QColor(220, 220, 220)); + palette3.setColor(QPalette::Inactive, static_cast(11), QColor(0, 0, 0)); + palette3.setColor(QPalette::Inactive, static_cast(12), QColor(10, 95, 137)); + palette3.setColor(QPalette::Inactive, static_cast(13), QColor(255, 255, 255)); + palette3.setColor(QPalette::Inactive, static_cast(14), QColor(0, 0, 0)); + palette3.setColor(QPalette::Inactive, static_cast(15), QColor(0, 0, 0)); + palette3.setColor(QPalette::Disabled, static_cast(0), QColor(128, 128, 128)); + palette3.setColor(QPalette::Disabled, static_cast(1), QColor(255, 0, 0)); + palette3.setColor(QPalette::Disabled, static_cast(2), QColor(255, 127, 127)); + palette3.setColor(QPalette::Disabled, static_cast(3), QColor(255, 38, 38)); + palette3.setColor(QPalette::Disabled, static_cast(4), QColor(127, 0, 0)); + palette3.setColor(QPalette::Disabled, static_cast(5), QColor(170, 0, 0)); + palette3.setColor(QPalette::Disabled, static_cast(6), QColor(0, 0, 0)); + palette3.setColor(QPalette::Disabled, static_cast(7), QColor(255, 255, 255)); + palette3.setColor(QPalette::Disabled, static_cast(8), QColor(128, 128, 128)); + palette3.setColor(QPalette::Disabled, static_cast(9), QColor(255, 255, 255)); + palette3.setColor(QPalette::Disabled, static_cast(10), QColor(220, 220, 220)); + palette3.setColor(QPalette::Disabled, static_cast(11), QColor(0, 0, 0)); + palette3.setColor(QPalette::Disabled, static_cast(12), QColor(10, 95, 137)); + palette3.setColor(QPalette::Disabled, static_cast(13), QColor(255, 255, 255)); + palette3.setColor(QPalette::Disabled, static_cast(14), QColor(0, 0, 0)); + palette3.setColor(QPalette::Disabled, static_cast(15), QColor(0, 0, 0)); + rslider->setPalette(palette3); + rslider->setMaximum(400); + rslider->setValue(100); + rslider->setOrientation(Qt::Horizontal); + + gridLayout1->addWidget(rslider, 2, 1, 1, 1); + + Spacer2 = new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding); + + gridLayout1->addItem(Spacer2, 3, 1, 1, 1); + + Spacer4 = new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding); + + gridLayout1->addItem(Spacer4, 1, 1, 1, 1); + + PushButton3 = new QPushButton(GroupBox1); + PushButton3->setObjectName(QString::fromUtf8("PushButton3")); + + gridLayout1->addWidget(PushButton3, 8, 0, 1, 3); + + MyCustomWidget1 = new GammaView(GroupBox1); + MyCustomWidget1->setObjectName(QString::fromUtf8("MyCustomWidget1")); + + gridLayout1->addWidget(MyCustomWidget1, 0, 3, 9, 1); + + Spacer5 = new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding); + + gridLayout1->addItem(Spacer5, 7, 1, 1, 1); + + + gridLayout->addWidget(GroupBox1, 3, 0, 1, 2); + + ButtonGroup1 = new Q3ButtonGroup(Config); + ButtonGroup1->setObjectName(QString::fromUtf8("ButtonGroup1")); + QSizePolicy sizePolicy(static_cast(5), static_cast(5)); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + sizePolicy.setHeightForWidth(ButtonGroup1->sizePolicy().hasHeightForWidth()); + ButtonGroup1->setSizePolicy(sizePolicy); + ButtonGroup1->setColumnLayout(0, Qt::Vertical); + ButtonGroup1->layout()->setSpacing(6); + ButtonGroup1->layout()->setContentsMargins(11, 11, 11, 11); + vboxLayout = new QVBoxLayout(); + QBoxLayout *boxlayout1 = qobject_cast(ButtonGroup1->layout()); + if (boxlayout1) + boxlayout1->addLayout(vboxLayout); + vboxLayout->setAlignment(Qt::AlignTop); + vboxLayout->setObjectName(QString::fromUtf8("vboxLayout")); + size_240_320 = new QRadioButton(ButtonGroup1); + size_240_320->setObjectName(QString::fromUtf8("size_240_320")); + + vboxLayout->addWidget(size_240_320); + + size_320_240 = new QRadioButton(ButtonGroup1); + size_320_240->setObjectName(QString::fromUtf8("size_320_240")); + + vboxLayout->addWidget(size_320_240); + + size_640_480 = new QRadioButton(ButtonGroup1); + size_640_480->setObjectName(QString::fromUtf8("size_640_480")); + + vboxLayout->addWidget(size_640_480); + + hboxLayout1 = new QHBoxLayout(); + hboxLayout1->setSpacing(6); + hboxLayout1->setContentsMargins(0, 0, 0, 0); + hboxLayout1->setObjectName(QString::fromUtf8("hboxLayout1")); + size_custom = new QRadioButton(ButtonGroup1); + size_custom->setObjectName(QString::fromUtf8("size_custom")); + + hboxLayout1->addWidget(size_custom); + + size_width = new QSpinBox(ButtonGroup1); + size_width->setObjectName(QString::fromUtf8("size_width")); + size_width->setMaximum(1280); + size_width->setMinimum(1); + size_width->setSingleStep(16); + size_width->setValue(400); + + hboxLayout1->addWidget(size_width); + + size_height = new QSpinBox(ButtonGroup1); + size_height->setObjectName(QString::fromUtf8("size_height")); + size_height->setMaximum(1024); + size_height->setMinimum(1); + size_height->setSingleStep(16); + size_height->setValue(300); + + hboxLayout1->addWidget(size_height); + + + vboxLayout->addLayout(hboxLayout1); + + hboxLayout2 = new QHBoxLayout(); + hboxLayout2->setSpacing(6); + hboxLayout2->setContentsMargins(0, 0, 0, 0); + hboxLayout2->setObjectName(QString::fromUtf8("hboxLayout2")); + size_skin = new QRadioButton(ButtonGroup1); + size_skin->setObjectName(QString::fromUtf8("size_skin")); + QSizePolicy sizePolicy1(static_cast(0), static_cast(0)); + sizePolicy1.setHorizontalStretch(0); + sizePolicy1.setVerticalStretch(0); + sizePolicy1.setHeightForWidth(size_skin->sizePolicy().hasHeightForWidth()); + size_skin->setSizePolicy(sizePolicy1); + + hboxLayout2->addWidget(size_skin); + + skin = new QComboBox(ButtonGroup1); + skin->setObjectName(QString::fromUtf8("skin")); + QSizePolicy sizePolicy2(static_cast(5), static_cast(0)); + sizePolicy2.setHorizontalStretch(0); + sizePolicy2.setVerticalStretch(0); + sizePolicy2.setHeightForWidth(skin->sizePolicy().hasHeightForWidth()); + skin->setSizePolicy(sizePolicy2); + + hboxLayout2->addWidget(skin); + + + vboxLayout->addLayout(hboxLayout2); + + + gridLayout->addWidget(ButtonGroup1, 0, 0, 1, 1); + + TextLabel1 = new QLabel(Config); + TextLabel1->setObjectName(QString::fromUtf8("TextLabel1")); + TextLabel1->setWordWrap(false); + + gridLayout->addWidget(TextLabel1, 1, 0, 1, 2); + + test_for_useless_buttongroupId = new QRadioButton(Config); + test_for_useless_buttongroupId->setObjectName(QString::fromUtf8("test_for_useless_buttongroupId")); + + gridLayout->addWidget(test_for_useless_buttongroupId, 0, 0, 1, 1); + + + retranslateUi(Config); + QObject::connect(buttonOk, SIGNAL(clicked()), Config, SLOT(accept())); + QObject::connect(buttonCancel, SIGNAL(clicked()), Config, SLOT(reject())); + + QMetaObject::connectSlotsByName(Config); + } // setupUi + + void retranslateUi(QDialog *Config) + { + Config->setWindowTitle(QApplication::translate("Config", "Configure", 0, QApplication::UnicodeUTF8)); + ButtonGroup2->setTitle(QApplication::translate("Config", "Depth", 0, QApplication::UnicodeUTF8)); + depth_1->setText(QApplication::translate("Config", "1 bit monochrome", 0, QApplication::UnicodeUTF8)); + depth_4gray->setText(QApplication::translate("Config", "4 bit grayscale", 0, QApplication::UnicodeUTF8)); + depth_8->setText(QApplication::translate("Config", "8 bit", 0, QApplication::UnicodeUTF8)); + depth_12->setText(QApplication::translate("Config", "12 (16) bit", 0, QApplication::UnicodeUTF8)); + depth_16->setText(QApplication::translate("Config", "16 bit", 0, QApplication::UnicodeUTF8)); + depth_32->setText(QApplication::translate("Config", "32 bit", 0, QApplication::UnicodeUTF8)); + buttonOk->setText(QApplication::translate("Config", "&OK", 0, QApplication::UnicodeUTF8)); + buttonCancel->setText(QApplication::translate("Config", "&Cancel", 0, QApplication::UnicodeUTF8)); + touchScreen->setText(QApplication::translate("Config", "Emulate touch screen (no mouse move).", 0, QApplication::UnicodeUTF8)); + GroupBox1->setTitle(QApplication::translate("Config", "Gamma", 0, QApplication::UnicodeUTF8)); + TextLabel3->setText(QApplication::translate("Config", "Blue", 0, QApplication::UnicodeUTF8)); + blabel->setText(QApplication::translate("Config", "1.0", 0, QApplication::UnicodeUTF8)); + TextLabel2->setText(QApplication::translate("Config", "Green", 0, QApplication::UnicodeUTF8)); + glabel->setText(QApplication::translate("Config", "1.0", 0, QApplication::UnicodeUTF8)); + TextLabel7->setText(QApplication::translate("Config", "All", 0, QApplication::UnicodeUTF8)); + TextLabel8->setText(QApplication::translate("Config", "1.0", 0, QApplication::UnicodeUTF8)); + TextLabel1_2->setText(QApplication::translate("Config", "Red", 0, QApplication::UnicodeUTF8)); + rlabel->setText(QApplication::translate("Config", "1.0", 0, QApplication::UnicodeUTF8)); + PushButton3->setText(QApplication::translate("Config", "Set all to 1.0", 0, QApplication::UnicodeUTF8)); + ButtonGroup1->setTitle(QApplication::translate("Config", "Size", 0, QApplication::UnicodeUTF8)); + size_240_320->setText(QApplication::translate("Config", "240x320 \"PDA\"", 0, QApplication::UnicodeUTF8)); + size_320_240->setText(QApplication::translate("Config", "320x240 \"TV\"", 0, QApplication::UnicodeUTF8)); + size_640_480->setText(QApplication::translate("Config", "640x480 \"VGA\"", 0, QApplication::UnicodeUTF8)); + size_custom->setText(QApplication::translate("Config", "Custom", 0, QApplication::UnicodeUTF8)); + size_skin->setText(QApplication::translate("Config", "Skin", 0, QApplication::UnicodeUTF8)); + skin->clear(); + skin->insertItems(0, QStringList() + << QApplication::translate("Config", "pda.skin", 0, QApplication::UnicodeUTF8) + << QApplication::translate("Config", "ipaq.skin", 0, QApplication::UnicodeUTF8) + << QApplication::translate("Config", "qpe.skin", 0, QApplication::UnicodeUTF8) + << QApplication::translate("Config", "cassiopeia.skin", 0, QApplication::UnicodeUTF8) + << QApplication::translate("Config", "other.skin", 0, QApplication::UnicodeUTF8) + ); + TextLabel1->setText(QApplication::translate("Config", "

Note that any applications using the virtual framebuffer will be terminated if you change the Size or Depth above. You may freely modify the Gamma below.", 0, QApplication::UnicodeUTF8)); + test_for_useless_buttongroupId->setText(QApplication::translate("Config", "Test", 0, QApplication::UnicodeUTF8)); + } // retranslateUi + + +protected: + enum IconID + { + image0_ID, + unknown_ID + }; + static QPixmap qt_get_icon(IconID id) + { + static const char* const image0_data[] = { +"22 22 2 1", +". c None", +"# c #a4c610", +"........######........", +".....###########......", +"....##############....", +"...################...", +"..######......######..", +"..#####........#####..", +".#####.......#..#####.", +".####.......###..####.", +"####.......#####..####", +"####......#####...####", +"####....#######...####", +"####....######....####", +"####...########...####", +".####.##########..####", +".####..####.#########.", +".#####..##...########.", +"..#####.......#######.", +"..######......######..", +"...###################", +"....##################", +"......###########.###.", +"........######.....#.."}; + + + switch (id) { + case image0_ID: return QPixmap((const char**)image0_data); + default: return QPixmap(); + } // switch + } // icon + +}; + +namespace Ui { + class Config: public Ui_Config {}; +} // namespace Ui + +QT_END_NAMESPACE + +#endif // CONFIG_FROMUIC3_H diff --git a/tests/auto/uic3/baseline/config.ui b/tests/auto/uic3/baseline/config.ui index 1ffeab3..dc02682 100644 --- a/tests/auto/uic3/baseline/config.ui +++ b/tests/auto/uic3/baseline/config.ui @@ -1648,6 +1648,17 @@ <p>Note that any applications using the virtual framebuffer will be terminated if you change the Size or Depth <i>above</i>. You may freely modify the Gamma <i>below</i>. + + + test_for_useless_buttongroupId + + + Test + + + 1 + + diff --git a/tests/auto/uic3/baseline/config.ui.4 b/tests/auto/uic3/baseline/config.ui.4 index 17e6a7c..0bd6256 100644 --- a/tests/auto/uic3/baseline/config.ui.4 +++ b/tests/auto/uic3/baseline/config.ui.4 @@ -1595,6 +1595,16 @@ + + + + Test + + + 1 + + + -- cgit v0.12 From f124538ef4840c3d24b4c7e9e7221adb52bdee2c Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Wed, 6 Jan 2010 10:16:02 +1000 Subject: Added setChannelCount() to QAudioFormat. Added setChannelCount() and updated docs/examples/tests to use it instead of setChannels(). Reviewed-by:Justin McPherson --- doc/src/snippets/audio/main.cpp | 2 +- examples/multimedia/audiodevices/audiodevices.cpp | 4 ++-- examples/multimedia/audioinput/audioinput.cpp | 2 +- examples/multimedia/audiooutput/audiooutput.cpp | 2 +- src/multimedia/audio/qaudio_mac.cpp | 2 +- src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp | 6 +++--- src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp | 2 +- src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp | 4 ++-- src/multimedia/audio/qaudioformat.cpp | 9 +++++++++ src/multimedia/audio/qaudioformat.h | 1 + src/multimedia/audio/qaudioinput.cpp | 2 +- src/multimedia/audio/qaudiooutput.cpp | 2 +- tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp | 2 +- tests/auto/qaudioformat/tst_qaudioformat.cpp | 10 +++++----- tests/auto/qaudioinput/tst_qaudioinput.cpp | 2 +- tests/auto/qaudiooutput/tst_qaudiooutput.cpp | 2 +- 16 files changed, 32 insertions(+), 22 deletions(-) diff --git a/doc/src/snippets/audio/main.cpp b/doc/src/snippets/audio/main.cpp index 0910865..1e6242d 100644 --- a/doc/src/snippets/audio/main.cpp +++ b/doc/src/snippets/audio/main.cpp @@ -91,7 +91,7 @@ private: QAudioFormat format; format.setFrequency(44100); //![1] - format.setChannels(2); + format.setChannelCount(2); format.setSampleSize(16); format.setCodec("audio/pcm"); format.setByteOrder(QAudioFormat::LittleEndian); diff --git a/examples/multimedia/audiodevices/audiodevices.cpp b/examples/multimedia/audiodevices/audiodevices.cpp index e205e03..4f4a95f 100644 --- a/examples/multimedia/audiodevices/audiodevices.cpp +++ b/examples/multimedia/audiodevices/audiodevices.cpp @@ -172,7 +172,7 @@ void AudioTest::deviceChanged(int idx) for(int i = 0; i < chz.size(); ++i) channelsBox->addItem(QString("%1").arg(chz.at(i))); if(chz.size()) - settings.setChannels(chz.at(0)); + settings.setChannelCount(chz.at(0)); codecsBox->clear(); QStringList codecz = deviceInfo.supportedCodecs(); @@ -234,7 +234,7 @@ void AudioTest::freqChanged(int idx) void AudioTest::channelChanged(int idx) { - settings.setChannels(channelsBox->itemText(idx).toInt()); + settings.setChannelCount(channelsBox->itemText(idx).toInt()); } void AudioTest::codecChanged(int idx) diff --git a/examples/multimedia/audioinput/audioinput.cpp b/examples/multimedia/audioinput/audioinput.cpp index 75bddd6..e6ebe95 100644 --- a/examples/multimedia/audioinput/audioinput.cpp +++ b/examples/multimedia/audioinput/audioinput.cpp @@ -196,7 +196,7 @@ InputTest::InputTest() pullMode = true; format.setFrequency(8000); - format.setChannels(1); + format.setChannelCount(1); format.setSampleSize(16); format.setSampleType(QAudioFormat::SignedInt); format.setByteOrder(QAudioFormat::LittleEndian); diff --git a/examples/multimedia/audiooutput/audiooutput.cpp b/examples/multimedia/audiooutput/audiooutput.cpp index b6047db..e822064 100644 --- a/examples/multimedia/audiooutput/audiooutput.cpp +++ b/examples/multimedia/audiooutput/audiooutput.cpp @@ -165,7 +165,7 @@ AudioTest::AudioTest() gen->start(); settings.setFrequency(SYSTEM_FREQ); - settings.setChannels(1); + settings.setChannelCount(1); settings.setSampleSize(16); settings.setCodec("audio/pcm"); settings.setByteOrder(QAudioFormat::LittleEndian); diff --git a/src/multimedia/audio/qaudio_mac.cpp b/src/multimedia/audio/qaudio_mac.cpp index 1cd9225..635377c 100644 --- a/src/multimedia/audio/qaudio_mac.cpp +++ b/src/multimedia/audio/qaudio_mac.cpp @@ -65,7 +65,7 @@ QAudioFormat toQAudioFormat(AudioStreamBasicDescription const& sf) QAudioFormat audioFormat; audioFormat.setFrequency(sf.mSampleRate); - audioFormat.setChannels(sf.mChannelsPerFrame); + audioFormat.setChannelCount(sf.mChannelsPerFrame); audioFormat.setSampleSize(sf.mBitsPerChannel); audioFormat.setCodec(QString::fromLatin1("audio/pcm")); audioFormat.setByteOrder(sf.mFormatFlags & kLinearPCMFormatFlagIsBigEndian != 0 ? QAudioFormat::BigEndian : QAudioFormat::LittleEndian); diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp index f58f5be..3bcf05b 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp @@ -79,19 +79,19 @@ QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const QAudioFormat nearest; if(mode == QAudio::AudioOutput) { nearest.setFrequency(44100); - nearest.setChannels(2); + nearest.setChannelCount(2); nearest.setByteOrder(QAudioFormat::LittleEndian); nearest.setSampleType(QAudioFormat::SignedInt); nearest.setSampleSize(16); nearest.setCodec(QLatin1String("audio/pcm")); } else { nearest.setFrequency(8000); - nearest.setChannels(1); + nearest.setChannelCount(1); nearest.setSampleType(QAudioFormat::UnSignedInt); nearest.setSampleSize(8); nearest.setCodec(QLatin1String("audio/pcm")); if(!testSettings(nearest)) { - nearest.setChannels(2); + nearest.setChannelCount(2); nearest.setSampleSize(16); nearest.setSampleType(QAudioFormat::SignedInt); } diff --git a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp index 8905119..c8b0196 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp @@ -147,7 +147,7 @@ QAudioFormat QAudioDeviceInfoInternal::nearestFormat(const QAudioFormat& format) if (rc.frequency() != target.frequency()) rc.setFrequency(target.frequency()); if (rc.channels() != target.channels()) - rc.setChannels(target.channels()); + rc.setChannelCount(target.channels()); if (rc.sampleSize() != target.sampleSize()) rc.setSampleSize(target.sampleSize()); if (rc.byteOrder() != target.byteOrder()) diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp index 33af022..3c5b129 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp @@ -95,14 +95,14 @@ QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const QAudioFormat nearest; if(mode == QAudio::AudioOutput) { nearest.setFrequency(44100); - nearest.setChannels(2); + nearest.setChannelCount(2); nearest.setByteOrder(QAudioFormat::LittleEndian); nearest.setSampleType(QAudioFormat::SignedInt); nearest.setSampleSize(16); nearest.setCodec(QLatin1String("audio/pcm")); } else { nearest.setFrequency(11025); - nearest.setChannels(1); + nearest.setChannelCount(1); nearest.setByteOrder(QAudioFormat::LittleEndian); nearest.setSampleType(QAudioFormat::SignedInt); nearest.setSampleSize(8); diff --git a/src/multimedia/audio/qaudioformat.cpp b/src/multimedia/audio/qaudioformat.cpp index b2bbe14..b8e0851 100644 --- a/src/multimedia/audio/qaudioformat.cpp +++ b/src/multimedia/audio/qaudioformat.cpp @@ -245,6 +245,15 @@ int QAudioFormat::frequency() const Sets the channels to \a channels. */ +void QAudioFormat::setChannelCount(int channels) +{ + d->channels = channels; +} + +/*! + \internal +*/ + void QAudioFormat::setChannels(int channels) { d->channels = channels; diff --git a/src/multimedia/audio/qaudioformat.h b/src/multimedia/audio/qaudioformat.h index 7e92c2f..88241df 100644 --- a/src/multimedia/audio/qaudioformat.h +++ b/src/multimedia/audio/qaudioformat.h @@ -76,6 +76,7 @@ public: void setFrequency(int frequency); int frequency() const; + void setChannelCount(int channels); void setChannels(int channels); int channels() const; diff --git a/src/multimedia/audio/qaudioinput.cpp b/src/multimedia/audio/qaudioinput.cpp index d81df7a..0d43ce4 100644 --- a/src/multimedia/audio/qaudioinput.cpp +++ b/src/multimedia/audio/qaudioinput.cpp @@ -89,7 +89,7 @@ QT_BEGIN_NAMESPACE QAudioFormat format; // set up the format you want, eg. format.setFrequency(8000); - format.setChannels(1); + format.setChannelCount(1); format.setSampleSize(8); format.setCodec("audio/pcm"); format.setByteOrder(QAudioFormat::LittleEndian); diff --git a/src/multimedia/audio/qaudiooutput.cpp b/src/multimedia/audio/qaudiooutput.cpp index 1c7b617..2f1ad3b 100644 --- a/src/multimedia/audio/qaudiooutput.cpp +++ b/src/multimedia/audio/qaudiooutput.cpp @@ -84,7 +84,7 @@ QT_BEGIN_NAMESPACE QAudioFormat format; // Set up the format, eg. format.setFrequency(8000); - format.setChannels(1); + format.setChannelCount(1); format.setSampleSize(8); format.setCodec("audio/pcm"); format.setByteOrder(QAudioFormat::LittleEndian); diff --git a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp index 715f219..14cf6b3 100644 --- a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp +++ b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp @@ -170,7 +170,7 @@ void tst_QAudioDeviceInfo::isformat() if(available) { QAudioFormat format; format.setFrequency(44100); - format.setChannels(2); + format.setChannelCount(2); format.setSampleType(QAudioFormat::SignedInt); format.setByteOrder(QAudioFormat::LittleEndian); format.setSampleSize(16); diff --git a/tests/auto/qaudioformat/tst_qaudioformat.cpp b/tests/auto/qaudioformat/tst_qaudioformat.cpp index 0778a8e..2742dd7 100644 --- a/tests/auto/qaudioformat/tst_qaudioformat.cpp +++ b/tests/auto/qaudioformat/tst_qaudioformat.cpp @@ -78,7 +78,7 @@ void tst_QAudioFormat::checkNull() QVERIFY(!audioFormat1.isValid()); audioFormat0.setFrequency(44100); - audioFormat0.setChannels(2); + audioFormat0.setChannelCount(2); audioFormat0.setSampleSize(16); audioFormat0.setCodec("audio/pcm"); audioFormat0.setSampleType(QAudioFormat::SignedInt); @@ -95,7 +95,7 @@ void tst_QAudioFormat::checkFrequency() void tst_QAudioFormat::checkChannels() { QAudioFormat audioFormat; - audioFormat.setChannels(2); + audioFormat.setChannelCount(2); QVERIFY(audioFormat.channels() == 2); } @@ -138,14 +138,14 @@ void tst_QAudioFormat::checkEquality() // on filled formats audioFormat0.setFrequency(8000); - audioFormat0.setChannels(1); + audioFormat0.setChannelCount(1); audioFormat0.setSampleSize(8); audioFormat0.setCodec("audio/pcm"); audioFormat0.setByteOrder(QAudioFormat::LittleEndian); audioFormat0.setSampleType(QAudioFormat::UnSignedInt); audioFormat1.setFrequency(8000); - audioFormat1.setChannels(1); + audioFormat1.setChannelCount(1); audioFormat1.setSampleSize(8); audioFormat1.setCodec("audio/pcm"); audioFormat1.setByteOrder(QAudioFormat::LittleEndian); @@ -165,7 +165,7 @@ void tst_QAudioFormat::checkAssignment() QAudioFormat audioFormat1; audioFormat0.setFrequency(8000); - audioFormat0.setChannels(1); + audioFormat0.setChannelCount(1); audioFormat0.setSampleSize(8); audioFormat0.setCodec("audio/pcm"); audioFormat0.setByteOrder(QAudioFormat::LittleEndian); diff --git a/tests/auto/qaudioinput/tst_qaudioinput.cpp b/tests/auto/qaudioinput/tst_qaudioinput.cpp index 744ce38..40bf01f 100644 --- a/tests/auto/qaudioinput/tst_qaudioinput.cpp +++ b/tests/auto/qaudioinput/tst_qaudioinput.cpp @@ -69,7 +69,7 @@ private: void tst_QAudioInput::initTestCase() { format.setFrequency(8000); - format.setChannels(1); + format.setChannelCount(1); format.setSampleSize(8); format.setCodec("audio/pcm"); format.setByteOrder(QAudioFormat::LittleEndian); diff --git a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp index 26694cc..f3feec1 100644 --- a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp +++ b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp @@ -72,7 +72,7 @@ private: void tst_QAudioOutput::initTestCase() { format.setFrequency(8000); - format.setChannels(1); + format.setChannelCount(1); format.setSampleSize(8); format.setCodec("audio/pcm"); format.setByteOrder(QAudioFormat::LittleEndian); -- cgit v0.12 From 80d4a4945d3273a4b2ce91e34597533f661af320 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Wed, 6 Jan 2010 13:45:05 +1000 Subject: Frequency to SampleRate and channels to channelCount. -Added channelCount(), changed everything to use this instead of channels() in QAudioFormat class. -Added setSampleRate() and sampleRate(), changed everthing to use these instead of setFrequency() and frequency() in QAudioFormat class. -Added supportedSampleRates() and supportedChannelCounts(), changed everything to use these instead of supportedFrequencies() and supportedChannels() in QAudioDeviceInfo class. Reviewed-by:Justin McPherson --- doc/src/snippets/audio/main.cpp | 2 +- examples/multimedia/audiodevices/audiodevices.cpp | 12 +++---- examples/multimedia/audioinput/audioinput.cpp | 2 +- examples/multimedia/audiooutput/audiooutput.cpp | 2 +- src/multimedia/audio/qaudio_mac.cpp | 10 +++--- src/multimedia/audio/qaudiodeviceinfo.cpp | 26 ++++++++++++--- src/multimedia/audio/qaudiodeviceinfo.h | 2 ++ src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp | 20 ++++++------ src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp | 8 ++--- src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp | 10 +++--- src/multimedia/audio/qaudioformat.cpp | 37 +++++++++++++++++++--- src/multimedia/audio/qaudioformat.h | 5 +++ src/multimedia/audio/qaudioinput.cpp | 2 +- src/multimedia/audio/qaudioinput_alsa_p.cpp | 8 ++--- src/multimedia/audio/qaudioinput_mac_p.cpp | 2 +- src/multimedia/audio/qaudioinput_win32_p.cpp | 14 ++++---- src/multimedia/audio/qaudiooutput.cpp | 2 +- src/multimedia/audio/qaudiooutput_alsa_p.cpp | 6 ++-- src/multimedia/audio/qaudiooutput_mac_p.cpp | 6 ++-- src/multimedia/audio/qaudiooutput_win32_p.cpp | 14 ++++---- .../auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp | 14 ++++---- tests/auto/qaudioformat/tst_qaudioformat.cpp | 16 +++++----- tests/auto/qaudioinput/tst_qaudioinput.cpp | 6 ++-- tests/auto/qaudiooutput/tst_qaudiooutput.cpp | 6 ++-- 24 files changed, 142 insertions(+), 90 deletions(-) diff --git a/doc/src/snippets/audio/main.cpp b/doc/src/snippets/audio/main.cpp index 1e6242d..bf4b145 100644 --- a/doc/src/snippets/audio/main.cpp +++ b/doc/src/snippets/audio/main.cpp @@ -89,7 +89,7 @@ private: { //![1] QAudioFormat format; - format.setFrequency(44100); + format.setSampleRate(44100); //![1] format.setChannelCount(2); format.setSampleSize(16); diff --git a/examples/multimedia/audiodevices/audiodevices.cpp b/examples/multimedia/audiodevices/audiodevices.cpp index 4f4a95f..beb31b4 100644 --- a/examples/multimedia/audiodevices/audiodevices.cpp +++ b/examples/multimedia/audiodevices/audiodevices.cpp @@ -108,8 +108,8 @@ void AudioTest::test() } else { QAudioFormat nearest = deviceInfo.nearestFormat(settings); logOutput->append(tr("Failed")); - nearestFreq->setText(QString("%1").arg(nearest.frequency())); - nearestChannel->setText(QString("%1").arg(nearest.channels())); + nearestFreq->setText(QString("%1").arg(nearest.sampleRate())); + nearestChannel->setText(QString("%1").arg(nearest.channelCount())); nearestCodec->setText(nearest.codec()); nearestSampleSize->setText(QString("%1").arg(nearest.sampleSize())); @@ -161,14 +161,14 @@ void AudioTest::deviceChanged(int idx) deviceInfo = deviceBox->itemData(idx).value(); frequencyBox->clear(); - QList freqz = deviceInfo.supportedFrequencies(); + QList freqz = deviceInfo.supportedSampleRates(); for(int i = 0; i < freqz.size(); ++i) frequencyBox->addItem(QString("%1").arg(freqz.at(i))); if(freqz.size()) - settings.setFrequency(freqz.at(0)); + settings.setSampleRate(freqz.at(0)); channelsBox->clear(); - QList chz = deviceInfo.supportedChannels(); + QList chz = deviceInfo.supportedChannelCounts(); for(int i = 0; i < chz.size(); ++i) channelsBox->addItem(QString("%1").arg(chz.at(i))); if(chz.size()) @@ -229,7 +229,7 @@ void AudioTest::deviceChanged(int idx) void AudioTest::freqChanged(int idx) { // freq has changed - settings.setFrequency(frequencyBox->itemText(idx).toInt()); + settings.setSampleRate(frequencyBox->itemText(idx).toInt()); } void AudioTest::channelChanged(int idx) diff --git a/examples/multimedia/audioinput/audioinput.cpp b/examples/multimedia/audioinput/audioinput.cpp index e6ebe95..dbf460b 100644 --- a/examples/multimedia/audioinput/audioinput.cpp +++ b/examples/multimedia/audioinput/audioinput.cpp @@ -195,7 +195,7 @@ InputTest::InputTest() pullMode = true; - format.setFrequency(8000); + format.setSampleRate(8000); format.setChannelCount(1); format.setSampleSize(16); format.setSampleType(QAudioFormat::SignedInt); diff --git a/examples/multimedia/audiooutput/audiooutput.cpp b/examples/multimedia/audiooutput/audiooutput.cpp index e822064..7d60cd4 100644 --- a/examples/multimedia/audiooutput/audiooutput.cpp +++ b/examples/multimedia/audiooutput/audiooutput.cpp @@ -164,7 +164,7 @@ AudioTest::AudioTest() gen->start(); - settings.setFrequency(SYSTEM_FREQ); + settings.setSampleRate(SYSTEM_FREQ); settings.setChannelCount(1); settings.setSampleSize(16); settings.setCodec("audio/pcm"); diff --git a/src/multimedia/audio/qaudio_mac.cpp b/src/multimedia/audio/qaudio_mac.cpp index 635377c..d876745 100644 --- a/src/multimedia/audio/qaudio_mac.cpp +++ b/src/multimedia/audio/qaudio_mac.cpp @@ -48,8 +48,8 @@ QT_BEGIN_NAMESPACE QDebug operator<<(QDebug dbg, const QAudioFormat& audioFormat) { dbg.nospace() << "QAudioFormat(" << - audioFormat.frequency() << "," << - audioFormat.channels() << "," << + audioFormat.sampleRate() << "," << + audioFormat.channelCount() << "," << audioFormat.sampleSize()<< "," << audioFormat.codec() << "," << audioFormat.byteOrder() << "," << @@ -64,7 +64,7 @@ QAudioFormat toQAudioFormat(AudioStreamBasicDescription const& sf) { QAudioFormat audioFormat; - audioFormat.setFrequency(sf.mSampleRate); + audioFormat.setSampleRate(sf.mSampleRate); audioFormat.setChannelCount(sf.mChannelsPerFrame); audioFormat.setSampleSize(sf.mBitsPerChannel); audioFormat.setCodec(QString::fromLatin1("audio/pcm")); @@ -84,9 +84,9 @@ AudioStreamBasicDescription toAudioStreamBasicDescription(QAudioFormat const& au AudioStreamBasicDescription sf; sf.mFormatFlags = kAudioFormatFlagIsPacked; - sf.mSampleRate = audioFormat.frequency(); + sf.mSampleRate = audioFormat.sampleRate(); sf.mFramesPerPacket = 1; - sf.mChannelsPerFrame = audioFormat.channels(); + sf.mChannelsPerFrame = audioFormat.channelCount(); sf.mBitsPerChannel = audioFormat.sampleSize(); sf.mBytesPerFrame = sf.mChannelsPerFrame * (sf.mBitsPerChannel / 8); sf.mBytesPerPacket = sf.mFramesPerPacket * sf.mBytesPerFrame; diff --git a/src/multimedia/audio/qaudiodeviceinfo.cpp b/src/multimedia/audio/qaudiodeviceinfo.cpp index 5e3adcb..226d723 100644 --- a/src/multimedia/audio/qaudiodeviceinfo.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo.cpp @@ -100,13 +100,13 @@ public: You can also query each device for the formats it supports. A format in this context is a set consisting of a specific byte - order, channel, codec, frequency, sample rate, and sample type. A + order, channel, codec, sample rate, sample size and sample type. A format is represented by the QAudioFormat class. The values supported by the the device for each of these parameters can be fetched with supportedByteOrders(), supportedChannels(), supportedCodecs(), - supportedFrequencies(), supportedSampleSizes(), and + supportedSampleRates(), supportedSampleSizes(), and supportedSampleTypes(). The combinations supported are dependent on the platform, audio plugins installed and the audio device capabilities. If you need a specific format, you can check if the device supports it with isFormatSupported(), or fetch a @@ -259,7 +259,16 @@ QStringList QAudioDeviceInfo::supportedCodecs() const } /*! - Returns a list of supported frequencies. + Returns a list of supported sample rates. +*/ + +QList QAudioDeviceInfo::supportedSampleRates() const +{ + return supportedFrequencies(); +} + +/*! + \internal */ QList QAudioDeviceInfo::supportedFrequencies() const @@ -268,7 +277,16 @@ QList QAudioDeviceInfo::supportedFrequencies() const } /*! - Returns a list of supported channels. + Returns a list of supported channel counts. +*/ + +QList QAudioDeviceInfo::supportedChannelCounts() const +{ + return supportedChannels(); +} + +/*! + \internal */ QList QAudioDeviceInfo::supportedChannels() const diff --git a/src/multimedia/audio/qaudiodeviceinfo.h b/src/multimedia/audio/qaudiodeviceinfo.h index 5c7cb98..78b1e69 100644 --- a/src/multimedia/audio/qaudiodeviceinfo.h +++ b/src/multimedia/audio/qaudiodeviceinfo.h @@ -84,7 +84,9 @@ public: QStringList supportedCodecs() const; QList supportedFrequencies() const; + QList supportedSampleRates() const; QList supportedChannels() const; + QList supportedChannelCounts() const; QList supportedSampleSizes() const; QList supportedByteOrders() const; QList supportedSampleTypes() const; diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp index 3bcf05b..9187264 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp @@ -78,14 +78,14 @@ QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const { QAudioFormat nearest; if(mode == QAudio::AudioOutput) { - nearest.setFrequency(44100); + nearest.setSampleRate(44100); nearest.setChannelCount(2); nearest.setByteOrder(QAudioFormat::LittleEndian); nearest.setSampleType(QAudioFormat::SignedInt); nearest.setSampleSize(16); nearest.setCodec(QLatin1String("audio/pcm")); } else { - nearest.setFrequency(8000); + nearest.setSampleRate(8000); nearest.setChannelCount(1); nearest.setSampleType(QAudioFormat::UnSignedInt); nearest.setSampleSize(8); @@ -253,8 +253,8 @@ bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const snd_pcm_hw_params_any( handle, params ); // set the values! - snd_pcm_hw_params_set_channels(handle,params,format.channels()); - snd_pcm_hw_params_set_rate(handle,params,format.frequency(),dir); + snd_pcm_hw_params_set_channels(handle,params,format.channelCount()); + snd_pcm_hw_params_set_rate(handle,params,format.sampleRate(),dir); switch(format.sampleSize()) { case 8: if(format.sampleType() == QAudioFormat::SignedInt) @@ -295,18 +295,18 @@ bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const } else testCodec = true; - if(err>=0 && format.channels() != -1) { - err = snd_pcm_hw_params_test_channels(handle,params,format.channels()); + if(err>=0 && format.channelCount() != -1) { + err = snd_pcm_hw_params_test_channels(handle,params,format.channelCount()); if(err>=0) - err = snd_pcm_hw_params_set_channels(handle,params,format.channels()); + err = snd_pcm_hw_params_set_channels(handle,params,format.channelCount()); if(err>=0) testChannel = true; } - if(err>=0 && format.frequency() != -1) { - err = snd_pcm_hw_params_test_rate(handle,params,format.frequency(),0); + if(err>=0 && format.sampleRate() != -1) { + err = snd_pcm_hw_params_test_rate(handle,params,format.sampleRate(),0); if(err>=0) - err = snd_pcm_hw_params_set_rate(handle,params,format.frequency(),dir); + err = snd_pcm_hw_params_set_rate(handle,params,format.sampleRate(),dir); if(err>=0) testFreq = true; } diff --git a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp index c8b0196..8e19b12 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp @@ -144,10 +144,10 @@ QAudioFormat QAudioDeviceInfoInternal::nearestFormat(const QAudioFormat& format) rc.setCodec(QString::fromLatin1("audio/pcm")); - if (rc.frequency() != target.frequency()) - rc.setFrequency(target.frequency()); - if (rc.channels() != target.channels()) - rc.setChannelCount(target.channels()); + if (rc.sampleRate() != target.sampleRate()) + rc.setSampleRate(target.sampleRate()); + if (rc.channelCount() != target.channelCount()) + rc.setChannelCount(target.channelCount()); if (rc.sampleSize() != target.sampleSize()) rc.setSampleSize(target.sampleSize()); if (rc.byteOrder() != target.byteOrder()) diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp index 3c5b129..739b0d0 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp @@ -94,14 +94,14 @@ QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const { QAudioFormat nearest; if(mode == QAudio::AudioOutput) { - nearest.setFrequency(44100); + nearest.setSampleRate(44100); nearest.setChannelCount(2); nearest.setByteOrder(QAudioFormat::LittleEndian); nearest.setSampleType(QAudioFormat::SignedInt); nearest.setSampleSize(16); nearest.setCodec(QLatin1String("audio/pcm")); } else { - nearest.setFrequency(11025); + nearest.setSampleRate(11025); nearest.setChannelCount(1); nearest.setByteOrder(QAudioFormat::LittleEndian); nearest.setSampleType(QAudioFormat::SignedInt); @@ -181,12 +181,12 @@ bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const if(!format.codec().startsWith(QLatin1String("audio/pcm"))) failed = true; - if(!failed && !(format.channels() == 1 || format.channels() == 2)) + if(!failed && !(format.channelCount() == 1 || format.channelCount() == 2)) failed = true; if(!failed) { - if(!(format.frequency() == 8000 || format.frequency() == 11025 || format.frequency() == 22050 || - format.frequency() == 44100 || format.frequency() == 48000 || format.frequency() == 96000)) + if(!(format.sampleRate() == 8000 || format.sampleRate() == 11025 || format.sampleRate() == 22050 || + format.sampleRate() == 44100 || format.sampleRate() == 48000 || format.sampleRate() == 96000)) failed = true; } diff --git a/src/multimedia/audio/qaudioformat.cpp b/src/multimedia/audio/qaudioformat.cpp index b8e0851..f7867f4 100644 --- a/src/multimedia/audio/qaudioformat.cpp +++ b/src/multimedia/audio/qaudioformat.cpp @@ -144,7 +144,7 @@ public: Values are initialized as follows: \list \o frequency() = -1 - \o channels() = -1 + \o channelCount() = -1 \o sampleSize() = -1 \o byteOrder() = QAudioFormat::Endian(QSysInfo::ByteOrder) \o sampleType() = QAudioFormat::Unknown @@ -224,7 +224,16 @@ bool QAudioFormat::isValid() const } /*! - Sets the frequency to \a frequency. + Sets the sample rate to \a samplerate Hertz. +*/ + +void QAudioFormat::setSampleRate(int samplerate) +{ + d->frequency = samplerate; +} + +/*! + \internal */ void QAudioFormat::setFrequency(int frequency) @@ -233,7 +242,16 @@ void QAudioFormat::setFrequency(int frequency) } /*! - Returns the current frequency value. + Returns the current sample rate in Hertz. +*/ + +int QAudioFormat::sampleRate() const +{ + return d->frequency; +} + +/*! + \internal */ int QAudioFormat::frequency() const @@ -242,7 +260,7 @@ int QAudioFormat::frequency() const } /*! - Sets the channels to \a channels. + Sets the channel count to \a channels. */ void QAudioFormat::setChannelCount(int channels) @@ -260,7 +278,16 @@ void QAudioFormat::setChannels(int channels) } /*! - Returns the current channel value. + Returns the current channel count value. +*/ + +int QAudioFormat::channelCount() const +{ + return d->channels; +} + +/*! + \internal */ int QAudioFormat::channels() const diff --git a/src/multimedia/audio/qaudioformat.h b/src/multimedia/audio/qaudioformat.h index 88241df..efc247f 100644 --- a/src/multimedia/audio/qaudioformat.h +++ b/src/multimedia/audio/qaudioformat.h @@ -76,7 +76,12 @@ public: void setFrequency(int frequency); int frequency() const; + void setSampleRate(int samplerate); + int sampleRate() const; + void setChannelCount(int channels); + int channelCount() const; + void setChannels(int channels); int channels() const; diff --git a/src/multimedia/audio/qaudioinput.cpp b/src/multimedia/audio/qaudioinput.cpp index 0d43ce4..733ff4e 100644 --- a/src/multimedia/audio/qaudioinput.cpp +++ b/src/multimedia/audio/qaudioinput.cpp @@ -88,7 +88,7 @@ QT_BEGIN_NAMESPACE QAudioFormat format; // set up the format you want, eg. - format.setFrequency(8000); + format.setSampleRate(8000); format.setChannelCount(1); format.setSampleSize(8); format.setCodec("audio/pcm"); diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp index 3dbe66c..096b7ca 100644 --- a/src/multimedia/audio/qaudioinput_alsa_p.cpp +++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp @@ -256,7 +256,7 @@ bool QAudioInputPrivate::open() int dir; int err=-1; int count=0; - unsigned int freakuency=settings.frequency(); + unsigned int freakuency=settings.sampleRate(); QString dev = QString(QLatin1String(m_device.constData())); QList devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioInput); @@ -332,7 +332,7 @@ bool QAudioInputPrivate::open() } } if ( !fatal ) { - err = snd_pcm_hw_params_set_channels( handle, hwparams, (unsigned int)settings.channels() ); + err = snd_pcm_hw_params_set_channels( handle, hwparams, (unsigned int)settings.channelCount() ); if ( err < 0 ) { fatal = true; errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_channels: err = %1").arg(err); @@ -505,7 +505,7 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) errorState = QAudio::NoError; deviceState = QAudio::IdleState; } else { - totalTimeValue += snd_pcm_bytes_to_frames(handle, err)*1000000/settings.frequency(); + totalTimeValue += snd_pcm_bytes_to_frames(handle, err)*1000000/settings.sampleRate(); resuming = false; errorState = QAudio::NoError; deviceState = QAudio::ActiveState; @@ -702,7 +702,7 @@ qint64 InputPrivate::readData( char* data, qint64 len) count++; } if(err > 0 && readFrames > 0) { - audioDevice->totalTimeValue += readFrames*1000/audioDevice->settings.frequency()*1000; + audioDevice->totalTimeValue += readFrames*1000/audioDevice->settings.sampleRate()*1000; audioDevice->deviceState = QAudio::ActiveState; return err; } diff --git a/src/multimedia/audio/qaudioinput_mac_p.cpp b/src/multimedia/audio/qaudioinput_mac_p.cpp index d63045f..7c856f4 100644 --- a/src/multimedia/audio/qaudioinput_mac_p.cpp +++ b/src/multimedia/audio/qaudioinput_mac_p.cpp @@ -814,7 +814,7 @@ int QAudioInputPrivate::notifyInterval() const qint64 QAudioInputPrivate::processedUSecs() const { - return totalFrames * 1000000 / audioFormat.frequency(); + return totalFrames * 1000000 / audioFormat.sampleRate(); } qint64 QAudioInputPrivate::elapsedUSecs() const diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp index f50a547..f98ecc6 100644 --- a/src/multimedia/audio/qaudioinput_win32_p.cpp +++ b/src/multimedia/audio/qaudioinput_win32_p.cpp @@ -225,16 +225,16 @@ bool QAudioInputPrivate::open() header = 0; if(buffer_size == 0) { // Default buffer size, 100ms, default period size is 20ms - buffer_size = settings.frequency()*settings.channels()*(settings.sampleSize()/8)*0.1; + buffer_size = settings.sampleRate()*settings.channelCount()*(settings.sampleSize()/8)*0.1; period_size = buffer_size/5; } else { period_size = buffer_size/5; } timeStamp.restart(); elapsedTimeOffset = 0; - wfx.nSamplesPerSec = settings.frequency(); + wfx.nSamplesPerSec = settings.sampleRate(); wfx.wBitsPerSample = settings.sampleSize(); - wfx.nChannels = settings.channels(); + wfx.nChannels = settings.channelCount(); wfx.cbSize = 0; wfx.wFormatTag = WAVE_FORMAT_PCM; @@ -374,8 +374,8 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) } else { totalTimeValue += waveBlocks[header].dwBytesRecorded - /((settings.channels()*settings.sampleSize()/8)) - *10000/settings.frequency()*100; + /((settings.channelCount()*settings.sampleSize()/8)) + *10000/settings.sampleRate()*100; errorState = QAudio::NoError; deviceState = QAudio::ActiveState; resuming = false; @@ -388,8 +388,8 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) qDebug()<<"IN: "< devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioOutput); @@ -354,7 +354,7 @@ bool QAudioOutputPrivate::open() } } if ( !fatal ) { - err = snd_pcm_hw_params_set_channels( handle, hwparams, (unsigned int)settings.channels() ); + err = snd_pcm_hw_params_set_channels( handle, hwparams, (unsigned int)settings.channelCount() ); if ( err < 0 ) { fatal = true; errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_channels: err = %1").arg(err); @@ -494,7 +494,7 @@ qint64 QAudioOutputPrivate::write( const char *data, qint64 len ) err = snd_pcm_writei( handle, data, frames ); } if(err > 0) { - totalTimeValue += err*1000000/settings.frequency(); + totalTimeValue += err*1000000/settings.sampleRate(); resuming = false; errorState = QAudio::NoError; deviceState = QAudio::ActiveState; diff --git a/src/multimedia/audio/qaudiooutput_mac_p.cpp b/src/multimedia/audio/qaudiooutput_mac_p.cpp index e0651bf..2dec43d 100644 --- a/src/multimedia/audio/qaudiooutput_mac_p.cpp +++ b/src/multimedia/audio/qaudiooutput_mac_p.cpp @@ -87,8 +87,8 @@ public: m_device(0) { m_buffer = new QAudioRingBuffer(bufferSize + (bufferSize % maxPeriodSize == 0 ? 0 : maxPeriodSize - (bufferSize % maxPeriodSize))); - m_bytesPerFrame = (audioFormat.sampleSize() / 8) * audioFormat.channels(); - m_periodTime = m_maxPeriodSize / m_bytesPerFrame * 1000 / audioFormat.frequency(); + m_bytesPerFrame = (audioFormat.sampleSize() / 8) * audioFormat.channelCount(); + m_periodTime = m_maxPeriodSize / m_bytesPerFrame * 1000 / audioFormat.sampleRate(); m_fillTimer = new QTimer(this); connect(m_fillTimer, SIGNAL(timeout()), SLOT(fillBuffer())); @@ -546,7 +546,7 @@ int QAudioOutputPrivate::notifyInterval() const qint64 QAudioOutputPrivate::processedUSecs() const { - return totalFrames * 1000000 / audioFormat.frequency(); + return totalFrames * 1000000 / audioFormat.sampleRate(); } qint64 QAudioOutputPrivate::elapsedUSecs() const diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp index 02c8cfe..389aef9 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.cpp +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp @@ -213,7 +213,7 @@ bool QAudioOutputPrivate::open() #endif if(buffer_size == 0) { // Default buffer size, 200ms, default period size is 40ms - buffer_size = settings.frequency()*settings.channels()*(settings.sampleSize()/8)*0.2; + buffer_size = settings.sampleRate()*settings.channelCount()*(settings.sampleSize()/8)*0.2; period_size = buffer_size/5; } else { period_size = buffer_size/5; @@ -232,9 +232,9 @@ bool QAudioOutputPrivate::open() timeStamp.restart(); elapsedTimeOffset = 0; - wfx.nSamplesPerSec = settings.frequency(); + wfx.nSamplesPerSec = settings.sampleRate(); wfx.wBitsPerSample = settings.sampleSize(); - wfx.nChannels = settings.channels(); + wfx.nChannels = settings.channelCount(); wfx.cbSize = 0; wfx.wFormatTag = WAVE_FORMAT_PCM; @@ -289,8 +289,8 @@ void QAudioOutputPrivate::close() return; deviceState = QAudio::StoppedState; - int delay = (buffer_size-bytesFree())*1000/(settings.frequency() - *settings.channels()*(settings.sampleSize()/8)); + int delay = (buffer_size-bytesFree())*1000/(settings.sampleRate() + *settings.channelCount()*(settings.sampleSize()/8)); waveOutReset(hWaveOut); Sleep(delay+10); @@ -386,8 +386,8 @@ qint64 QAudioOutputPrivate::write( const char *data, qint64 len ) LeaveCriticalSection(&waveOutCriticalSection); #endif totalTimeValue += current->dwBufferLength - /(settings.channels()*(settings.sampleSize()/8)) - *1000000/settings.frequency();; + /(settings.channelCount()*(settings.sampleSize()/8)) + *1000000/settings.sampleRate();; waveCurrentBlock++; waveCurrentBlock %= buffer_size/period_size; current = &waveBlocks[waveCurrentBlock]; diff --git a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp index 14cf6b3..2270eb2 100644 --- a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp +++ b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp @@ -128,7 +128,7 @@ void tst_QAudioDeviceInfo::codecs() void tst_QAudioDeviceInfo::channels() { if(available) { - QList avail = device->supportedChannels(); + QList avail = device->supportedChannelCounts(); QVERIFY(avail.size() > 0); } } @@ -160,7 +160,7 @@ void tst_QAudioDeviceInfo::sampleTypes() void tst_QAudioDeviceInfo::frequencies() { if(available) { - QList avail = device->supportedFrequencies(); + QList avail = device->supportedSampleRates(); QVERIFY(avail.size() > 0); } } @@ -169,7 +169,7 @@ void tst_QAudioDeviceInfo::isformat() { if(available) { QAudioFormat format; - format.setFrequency(44100); + format.setSampleRate(44100); format.setChannelCount(2); format.setSampleType(QAudioFormat::SignedInt); format.setByteOrder(QAudioFormat::LittleEndian); @@ -185,8 +185,8 @@ void tst_QAudioDeviceInfo::preferred() { if(available) { QAudioFormat format = device->preferredFormat(); - QVERIFY(format.frequency() == 44100); - QVERIFY(format.channels() == 2); + QVERIFY(format.sampleRate() == 44100); + QVERIFY(format.channelCount() == 2); } } @@ -194,9 +194,9 @@ void tst_QAudioDeviceInfo::nearest() { if(available) { QAudioFormat format1, format2; - format1.setFrequency(8000); + format1.setSampleRate(8000); format2 = device->nearestFormat(format1); - QVERIFY(format2.frequency() == 44100); + QVERIFY(format2.sampleRate() == 44100); } } diff --git a/tests/auto/qaudioformat/tst_qaudioformat.cpp b/tests/auto/qaudioformat/tst_qaudioformat.cpp index 2742dd7..5237dca 100644 --- a/tests/auto/qaudioformat/tst_qaudioformat.cpp +++ b/tests/auto/qaudioformat/tst_qaudioformat.cpp @@ -77,7 +77,7 @@ void tst_QAudioFormat::checkNull() QAudioFormat audioFormat1(audioFormat0); QVERIFY(!audioFormat1.isValid()); - audioFormat0.setFrequency(44100); + audioFormat0.setSampleRate(44100); audioFormat0.setChannelCount(2); audioFormat0.setSampleSize(16); audioFormat0.setCodec("audio/pcm"); @@ -88,15 +88,15 @@ void tst_QAudioFormat::checkNull() void tst_QAudioFormat::checkFrequency() { QAudioFormat audioFormat; - audioFormat.setFrequency(44100); - QVERIFY(audioFormat.frequency() == 44100); + audioFormat.setSampleRate(44100); + QVERIFY(audioFormat.sampleRate() == 44100); } void tst_QAudioFormat::checkChannels() { QAudioFormat audioFormat; audioFormat.setChannelCount(2); - QVERIFY(audioFormat.channels() == 2); + QVERIFY(audioFormat.channelCount() == 2); } void tst_QAudioFormat::checkSampleSize() @@ -137,14 +137,14 @@ void tst_QAudioFormat::checkEquality() QVERIFY(!(audioFormat0 != audioFormat1)); // on filled formats - audioFormat0.setFrequency(8000); + audioFormat0.setSampleRate(8000); audioFormat0.setChannelCount(1); audioFormat0.setSampleSize(8); audioFormat0.setCodec("audio/pcm"); audioFormat0.setByteOrder(QAudioFormat::LittleEndian); audioFormat0.setSampleType(QAudioFormat::UnSignedInt); - audioFormat1.setFrequency(8000); + audioFormat1.setSampleRate(8000); audioFormat1.setChannelCount(1); audioFormat1.setSampleSize(8); audioFormat1.setCodec("audio/pcm"); @@ -154,7 +154,7 @@ void tst_QAudioFormat::checkEquality() QVERIFY(audioFormat0 == audioFormat1); QVERIFY(!(audioFormat0 != audioFormat1)); - audioFormat0.setFrequency(44100); + audioFormat0.setSampleRate(44100); QVERIFY(audioFormat0 != audioFormat1); QVERIFY(!(audioFormat0 == audioFormat1)); } @@ -164,7 +164,7 @@ void tst_QAudioFormat::checkAssignment() QAudioFormat audioFormat0; QAudioFormat audioFormat1; - audioFormat0.setFrequency(8000); + audioFormat0.setSampleRate(8000); audioFormat0.setChannelCount(1); audioFormat0.setSampleSize(8); audioFormat0.setCodec("audio/pcm"); diff --git a/tests/auto/qaudioinput/tst_qaudioinput.cpp b/tests/auto/qaudioinput/tst_qaudioinput.cpp index 40bf01f..994e9ef 100644 --- a/tests/auto/qaudioinput/tst_qaudioinput.cpp +++ b/tests/auto/qaudioinput/tst_qaudioinput.cpp @@ -68,7 +68,7 @@ private: void tst_QAudioInput::initTestCase() { - format.setFrequency(8000); + format.setSampleRate(8000); format.setChannelCount(1); format.setSampleSize(8); format.setCodec("audio/pcm"); @@ -94,8 +94,8 @@ void tst_QAudioInput::settings() // Confirm the setting we added in the init function. QAudioFormat f = audio->format(); - QVERIFY(format.channels() == f.channels()); - QVERIFY(format.frequency() == f.frequency()); + QVERIFY(format.channelCount() == f.channelCount()); + QVERIFY(format.sampleRate() == f.sampleRate()); QVERIFY(format.sampleSize() == f.sampleSize()); QVERIFY(format.codec() == f.codec()); QVERIFY(format.byteOrder() == f.byteOrder()); diff --git a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp index f3feec1..60d0124 100644 --- a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp +++ b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp @@ -71,7 +71,7 @@ private: void tst_QAudioOutput::initTestCase() { - format.setFrequency(8000); + format.setSampleRate(8000); format.setChannelCount(1); format.setSampleSize(8); format.setCodec("audio/pcm"); @@ -95,8 +95,8 @@ void tst_QAudioOutput::settings() // Confirm the setting we added in the init function. QAudioFormat f = audio->format(); - QVERIFY(format.channels() == f.channels()); - QVERIFY(format.frequency() == f.frequency()); + QVERIFY(format.channelCount() == f.channelCount()); + QVERIFY(format.sampleRate() == f.sampleRate()); QVERIFY(format.sampleSize() == f.sampleSize()); QVERIFY(format.codec() == f.codec()); QVERIFY(format.byteOrder() == f.byteOrder()); -- cgit v0.12 From 965d0b477c13e2f92866cecb73064c3f0d722714 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 6 Jan 2010 09:45:11 +0100 Subject: doc: Fixed references to currsor position(). Task-number: QTBUG-6763 --- src/gui/text/qtextcursor.cpp | 55 +++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index ce62834..f1dbf23 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -862,27 +862,28 @@ QTextLayout *QTextCursorPrivate::blockLayout(QTextBlock &block) const{ \ingroup richtext-processing \ingroup shared - - Text cursors are objects that are used to access and modify the contents - and underlying structure of text documents via a programming interface - that mimics the behavior of a cursor in a text editor. QTextCursor contains - information about both the cursor's position within a QTextDocument and any - selection that it has made. + Text cursors are objects that are used to access and modify the + contents and underlying structure of text documents via a + programming interface that mimics the behavior of a cursor in a + text editor. QTextCursor contains information about both the + cursor's position within a QTextDocument and any selection that it + has made. QTextCursor is modeled on the way a text cursor behaves in a text - editor, providing a programmatic means of performing standard actions - through the user interface. A document can be thought of as a - single string of characters with the cursor's position() being \e - between any two characters (or at the very beginning or very end - of the document). Documents can also contain tables, lists, - images, and other objects in addition to text but, from the developer's - point of view, the document can be treated as one long string. - Some portions of that string can be considered to lie within particular - blocks (e.g. paragraphs), or within a table's cell, or a list's item, - or other structural elements. When we refer to "current character" we - mean the character immediately after the cursor position() in the - document; similarly the "current block" is the block that contains the - cursor position(). + editor, providing a programmatic means of performing standard + actions through the user interface. A document can be thought of + as a single string of characters. The cursor's current position() + then is always either \e between two consecutive characters in the + string, or else \e before the very first character or \e after the + very last character in the string. Documents can also contain + tables, lists, images, and other objects in addition to text but, + from the developer's point of view, the document can be treated as + one long string. Some portions of that string can be considered + to lie within particular blocks (e.g. paragraphs), or within a + table's cell, or a list's item, or other structural elements. When + we refer to "current character" we mean the character immediately + \e before the cursor position() in the document. Similarly, the + "current block" is the block that contains the cursor position(). A QTextCursor also has an anchor() position. The text that is between the anchor() and the position() is the selection. If @@ -940,11 +941,12 @@ QTextLayout *QTextCursorPrivate::blockLayout(QTextBlock &block) const{ undo/redo) using beginEditBlock() and endEditBlock(). Cursor movements are limited to valid cursor positions. In Latin - writing this is usually after every character in the text. In some - other writing systems cursor movements are limited to "clusters" - (e.g. a syllable in Devanagari, or a base letter plus diacritics). - Functions such as movePosition() and deleteChar() limit cursor - movement to these valid positions. + writing this is between any two consecutive characters in the + text, before the first character, or after the last character. In + some other writing systems cursor movements are limited to + "clusters" (e.g. a syllable in Devanagari, or a base letter plus + diacritics). Functions such as movePosition() and deleteChar() + limit cursor movement to these valid positions. \sa \link richtext.html Rich Text Processing\endlink @@ -1739,8 +1741,9 @@ void QTextCursor::mergeBlockCharFormat(const QTextCharFormat &modifier) } /*! - Returns the format of the character immediately before the cursor position(). If the cursor is - positioned at the beginning of a text block that is not empty then the format of the character + Returns the format of the character immediately before the cursor + position(). If the cursor is positioned at the beginning of a text + block that is not empty then the format of the character immediately after the cursor is returned. \sa insertText(), blockFormat() -- cgit v0.12 From 1f46cf2aa1a0a1c0d60cfaea63b572bd8a65a0cd Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Wed, 6 Jan 2010 10:05:09 +0100 Subject: QAbstractSocket: Warn when wrong QHostInfo was received Let's see if this happens. Reviewed-by: Thiago --- src/network/socket/qabstractsocket.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 8b4f364..0d35f2d 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -873,6 +873,10 @@ void QAbstractSocketPrivate::_q_startConnecting(const QHostInfo &hostInfo) if (state != QAbstractSocket::HostLookupState) return; + if (hostLookupId != -1 && hostLookupId != hostInfo.lookupId()) { + qWarning("QAbstractSocketPrivate::_q_startConnecting() received hostInfo for wrong lookup ID %d expected %d", hostInfo.lookupId(), hostLookupId); + } + addresses = hostInfo.addresses(); #if defined(QABSTRACTSOCKET_DEBUG) -- cgit v0.12 From 65bbfb089672b5919c6c7f52956743ec0578af1c Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Wed, 6 Jan 2010 10:08:32 +0100 Subject: QAbstractSocket: Fix warnings when compiling with QABSTRACTSOCKET_DEBUG --- src/network/socket/qabstractsocket.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 0d35f2d..fda47bd 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -520,13 +520,13 @@ bool QAbstractSocketPrivate::initSocketLayer(QAbstractSocket::NetworkLayerProtoc Q_Q(QAbstractSocket); #if defined (QABSTRACTSOCKET_DEBUG) QString typeStr; - if (q->socketType() == QAbstractSocket::TcpSocket) typeStr = "TcpSocket"; - else if (q->socketType() == QAbstractSocket::UdpSocket) typeStr = "UdpSocket"; - else typeStr = "UnknownSocketType"; + if (q->socketType() == QAbstractSocket::TcpSocket) typeStr = QLatin1String("TcpSocket"); + else if (q->socketType() == QAbstractSocket::UdpSocket) typeStr = QLatin1String("UdpSocket"); + else typeStr = QLatin1String("UnknownSocketType"); QString protocolStr; - if (protocol == QAbstractSocket::IPv4Protocol) protocolStr = "IPv4Protocol"; - else if (protocol == QAbstractSocket::IPv6Protocol) protocolStr = "IPv6Protocol"; - else protocolStr = "UnknownNetworkLayerProtocol"; + if (protocol == QAbstractSocket::IPv4Protocol) protocolStr = QLatin1String("IPv4Protocol"); + else if (protocol == QAbstractSocket::IPv6Protocol) protocolStr = QLatin1String("IPv6Protocol"); + else protocolStr = QLatin1String("UnknownNetworkLayerProtocol"); #endif resetSocketLayer(); @@ -880,12 +880,12 @@ void QAbstractSocketPrivate::_q_startConnecting(const QHostInfo &hostInfo) addresses = hostInfo.addresses(); #if defined(QABSTRACTSOCKET_DEBUG) - QString s = "{"; + QString s = QLatin1String("{"); for (int i = 0; i < addresses.count(); ++i) { - if (i != 0) s += ", "; + if (i != 0) s += QLatin1String(", "); s += addresses.at(i).toString(); } - s += '}'; + s += QLatin1Char('}'); qDebug("QAbstractSocketPrivate::_q_startConnecting(hostInfo == %s)", s.toLatin1().constData()); #endif -- cgit v0.12 From 9cdeb6ca14713891a14f24e97adb59b0d3b682fd Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 6 Jan 2010 10:31:31 +0100 Subject: doc: Clarified that the scene owns its items and destroys them. Task-number: QTBUG-6637 --- src/gui/graphicsview/qgraphicsscene.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 182a3f5..c80b314 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -1561,7 +1561,10 @@ QGraphicsScene::QGraphicsScene(qreal x, qreal y, qreal width, qreal height, QObj } /*! - Destroys the QGraphicsScene object. + Removes and deletes all items from the scene object + before destroying the scene object. The scene object + is removed from the application's global scene list, + and it is removed from all associated views. */ QGraphicsScene::~QGraphicsScene() { @@ -2443,23 +2446,26 @@ void QGraphicsScene::destroyItemGroup(QGraphicsItemGroup *group) } /*! - Adds or moves the item \a item and all its childen to the scene. + Adds or moves the \a item and all its childen to this scene. + This scene takes ownership of the \a item. If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop. - If the item is already in a different scene, it will first be removed from - its old scene, and then added to this scene as a top-level. + If the item is already in a different scene, it will first be + removed from its old scene, and then added to this scene as a + top-level. - QGraphicsScene will send ItemSceneChange notifications to \a item while - it is added to the scene. If item does not currently belong to a scene, only one - notification is sent. If it does belong to scene already (i.e., it is - moved to this scene), QGraphicsScene will send an addition notification as - the item is removed from its previous scene. + QGraphicsScene will send ItemSceneChange notifications to \a item + while it is added to the scene. If item does not currently belong + to a scene, only one notification is sent. If it does belong to + scene already (i.e., it is moved to this scene), QGraphicsScene + will send an addition notification as the item is removed from its + previous scene. - If the item is a panel, the scene is active, and there is no active panel - in the scene, then the item will be activated. + If the item is a panel, the scene is active, and there is no + active panel in the scene, then the item will be activated. \sa removeItem(), addEllipse(), addLine(), addPath(), addPixmap(), addRect(), addText(), addWidget(), {QGraphicsItem#Sorting}{Sorting} -- cgit v0.12 From 3062035b9b38457196869b93650929f95cbd709f Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 15 Oct 2009 10:05:12 +0200 Subject: Document the QGraphicsView::IndirectPainting flag And that the QGraphics{View,Scene}::drawItems function are now obsolete. Reviewed-by: Alexis --- src/gui/graphicsview/qgraphicsscene.cpp | 4 ++++ src/gui/graphicsview/qgraphicsview.cpp | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 182a3f5..bc9d87a 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -5089,6 +5089,10 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool \snippet doc/src/snippets/graphicssceneadditemsnippet.cpp 0 + \obsolete Since Qt 4.6, this function is not called anymore unless + the QGraphicsView::IndirectPainting flag is given as an Optimization + flag. + \sa drawBackground(), drawForeground() */ void QGraphicsScene::drawItems(QPainter *painter, diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index 1569078..c8f2c7c 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -217,7 +217,9 @@ static const int QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS = 503; // largest prime < common side effect is that items that do draw with antialiasing can leave painting traces behind on the scene as they are moved. - \omitvalue IndirectPainting + \value IndirectPainting Since Qt 4.6, restore the old painting algorithm + that calls QGraphicsView::drawItems() and QGraphicsScene::drawItems(). + To be used only for compatibility with old code. */ /*! @@ -3616,6 +3618,10 @@ void QGraphicsView::drawForeground(QPainter *painter, const QRectF &rect) The default implementation calls the scene's drawItems() function. + \obsolete Since Qt 4.6, this function is not called anymore unless + the QGraphicsView::IndirectPainting flag is given as an Optimization + flag. + \sa drawForeground(), drawBackground(), QGraphicsScene::drawItems() */ void QGraphicsView::drawItems(QPainter *painter, int numItems, -- cgit v0.12 From 9bb45b19789910aff5e2a972a1ced758814fac31 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 6 Jan 2010 10:51:18 +0100 Subject: doc: Clarified that .lnk files are System files on Windows. Task-number: QTBUG-6615 --- src/corelib/io/qdir.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 59db9a6..bac508a 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -1125,10 +1125,11 @@ QDir::Filters QDir::filter() const execute access. The Executable value needs to be combined with Dirs or Files. \value Modified Only list files that have been modified (ignored - under Unix). - \value Hidden List hidden files (on Unix, files starting with a .). + on Unix). + \value Hidden List hidden files (on Unix, files starting with a "."). \value System List system files (on Unix, FIFOs, sockets and - device files) + device files are included; on Windows, \c {.lnk} + files are included) \value CaseSensitive The filter should be case sensitive. \omitvalue DefaultFilter -- cgit v0.12 From 0252964248915130f96c2ef9af6149ef5a5da5be Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Wed, 6 Jan 2010 10:19:23 +0100 Subject: QHttpSocketEngine: Remove unneeded code There was a buffer that is always empty since it was only used for parsing the HTTP proxy protocol, not the actual socket data. Reviewed-by: Peter Hartmann --- src/network/socket/qhttpsocketengine.cpp | 20 +++----------------- src/network/socket/qhttpsocketengine_p.h | 2 +- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp index 5c28318..635a0c6 100644 --- a/src/network/socket/qhttpsocketengine.cpp +++ b/src/network/socket/qhttpsocketengine.cpp @@ -212,28 +212,14 @@ qint64 QHttpSocketEngine::bytesAvailable() const qint64 QHttpSocketEngine::read(char *data, qint64 maxlen) { Q_D(QHttpSocketEngine); - qint64 bytesRead = 0; - - if (!d->readBuffer.isEmpty()) { - // Read as much from the buffer as we can. - bytesRead = qMin((qint64)d->readBuffer.size(), maxlen); - memcpy(data, d->readBuffer.constData(), bytesRead); - data += bytesRead; - maxlen -= bytesRead; - d->readBuffer = d->readBuffer.mid(bytesRead); - } - - qint64 bytesReadFromSocket = d->socket->read(data, maxlen); + qint64 bytesRead = d->socket->read(data, maxlen); if (d->socket->state() == QAbstractSocket::UnconnectedState && d->socket->bytesAvailable() == 0) { emitReadNotification(); } - if (bytesReadFromSocket > 0) { - // Add to what we read so far. - bytesRead += bytesReadFromSocket; - } else if (bytesRead == 0 && bytesReadFromSocket == -1) { + if (bytesRead == -1) { // If nothing has been read so far, and the direct socket read // failed, return the socket's error. Otherwise, fall through and // return as much as we read so far. @@ -560,7 +546,7 @@ void QHttpSocketEngine::slotSocketReadNotification() } QHttpResponseHeader responseHeader(QString::fromLatin1(d->readBuffer)); - d->readBuffer.clear(); + d->readBuffer.clear(); // we parsed the proxy protocol response. from now on direct socket reading will be done int statusCode = responseHeader.statusCode(); if (statusCode == 200) { diff --git a/src/network/socket/qhttpsocketengine_p.h b/src/network/socket/qhttpsocketengine_p.h index 76430db..1432bfb 100644 --- a/src/network/socket/qhttpsocketengine_p.h +++ b/src/network/socket/qhttpsocketengine_p.h @@ -162,7 +162,7 @@ public: QNetworkProxy proxy; QString peerName; QTcpSocket *socket; - QByteArray readBuffer; + QByteArray readBuffer; // only used for parsing the proxy response QHttpSocketEngine::HttpState state; QAuthenticator authenticator; bool readNotificationEnabled; -- cgit v0.12 From 86e656cccf7555fc4d2f52c79a8f2031cf8d320c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Wed, 6 Jan 2010 10:58:35 +0100 Subject: Improved initial startup time for a QGLWidget ontop of EGL/X11. Exchanged the temporary QGLWidget with a lightweight internal class. Measured on a device it can be upto 20 ms faster to construct. Reviewed-by: Tom Cooksey --- src/opengl/qgl_x11egl.cpp | 116 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 111 insertions(+), 5 deletions(-) diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index 19026b3..271f4de 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -52,6 +52,116 @@ QT_BEGIN_NAMESPACE + +bool qt_egl_setup_x11_visual(XVisualInfo &vi, EGLDisplay display, EGLConfig config, + const QX11Info &x11Info, bool useArgbVisual); +// +// QGLTempContext is a lass for creating a temporary GL context (which is +// needed during QGLWidget initialization to retrieve GL extension info). +// Faster to construct than a full QGLWidget. +// +class QGLTempContext +{ +public: + QGLTempContext(int screen = 0) : + initialized(false), + window(0), + context(0), + surface(0) + { + display = eglGetDisplay(EGLNativeDisplayType(X11->display)); + + if (!eglInitialize(display, NULL, NULL)) { + qWarning("QGLTempContext: Unable to initialize EGL display."); + return; + } + + EGLConfig config; + int numConfigs = 0; + EGLint attribs[] = { + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, +#ifdef QT_OPENGL_ES_2 + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, +#endif + EGL_NONE + }; + + eglChooseConfig(display, attribs, &config, 1, &numConfigs); + if (!numConfigs) { + qWarning("QGLTempContext: No EGL configurations available."); + return; + } + + XVisualInfo visualInfo; + XVisualInfo *vi; + int numVisuals; + EGLint id = 0; + + eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &id); + if (id == 0) { + // EGL_NATIVE_VISUAL_ID is optional and might not be supported + // on some implementations - we'll have to do it the hard way + QX11Info xinfo; + qt_egl_setup_x11_visual(visualInfo, display, config, xinfo, false); + } else { + visualInfo.visualid = id; + } + vi = XGetVisualInfo(X11->display, VisualIDMask, &visualInfo, &numVisuals); + if (!vi || numVisuals < 1) { + qWarning("QGLTempContext: Unable to get X11 visual info id."); + return; + } + + window = XCreateWindow(X11->display, RootWindow(X11->display, screen), + 0, 0, 1, 1, 0, + vi->depth, InputOutput, vi->visual, + 0, 0); + + surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType) window, NULL); + + if (surface == EGL_NO_SURFACE) { + qWarning("QGLTempContext: Error creating EGL surface."); + XFree(vi); + XDestroyWindow(X11->display, window); + return; + } + + EGLint contextAttribs[] = { +#ifdef QT_OPENGL_ES_2 + EGL_CONTEXT_CLIENT_VERSION, 2, +#endif + EGL_NONE + }; + context = eglCreateContext(display, config, 0, contextAttribs); + if (context != EGL_NO_CONTEXT + && eglMakeCurrent(display, surface, surface, context)) + { + initialized = true; + } else { + qWarning("QGLTempContext: Error creating EGL context."); + eglDestroySurface(display, surface); + XDestroyWindow(X11->display, window); + } + XFree(vi); + } + + ~QGLTempContext() { + if (initialized) { + eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + eglDestroyContext(display, context); + eglDestroySurface(display, surface); + XDestroyWindow(X11->display, window); + } + } + +private: + bool initialized; + Window window; + EGLContext context; + EGLSurface surface; + EGLDisplay display; +}; + bool QGLFormat::hasOpenGLOverlays() { return false; @@ -446,12 +556,8 @@ void QGLExtensions::init() init_done = true; // We need a context current to initialize the extensions. - QGLWidget tmpWidget; - tmpWidget.makeCurrent(); - + QGLTempContext context; init_extensions(); - - tmpWidget.doneCurrent(); } // Re-creates the EGL surface if the window ID has changed or if force is true -- cgit v0.12 From fac8aa652775424ae890cb428267c155f8e48b9b Mon Sep 17 00:00:00 2001 From: David Boddie Date: Wed, 6 Jan 2010 11:21:41 +0100 Subject: Doc: Improved the advice about deployment of plugins. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Recommended deploying all plugins, excluding only those that are not required. Included accessibility plugins in the list of example plugins that users may need. Reviewed-by: Jan-Arve Sæther --- doc/src/deployment/deployment.qdoc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/src/deployment/deployment.qdoc b/doc/src/deployment/deployment.qdoc index 6a1760e..1459e6a 100644 --- a/doc/src/deployment/deployment.qdoc +++ b/doc/src/deployment/deployment.qdoc @@ -110,6 +110,7 @@ \o \l {QtXmlPatterns} \o \l {Phonon Module}{Phonon} \o \l {Qt3Support} + \o \endtable Since Qt is not a system library, it has to be redistributed along @@ -117,10 +118,15 @@ of the libraries used by the application. Using static linking, however, the Qt run-time is compiled into the executable. - In particular, you will need to deploy Qt plugins, such as - JPEG support or SQL drivers. For more information about plugins, - see the \l {plugins-howto.html}{How to Create Qt Plugins} - documentation. + In general, you should deploy all plugins that your build of Qt uses, + excluding only those that you have identified as being unnecessary + for your application and its users. + + For instance, you may need to deploy plugins for JPEG support and + SQL drivers, but you should also deploy plugins that your users may + require, including those for accessibility. + For more information about plugins, see the + \l{plugins-howto.html}{How to Create Qt Plugins} documentation. When deploying an application using the shared library approach you must ensure that the Qt libraries will use the correct path to -- cgit v0.12 From b13ede364f15a7237dbc67491c9edf65546ad01d Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Wed, 6 Jan 2010 21:00:19 +1000 Subject: Fix license check failure. Reviewed-by: Trust Me --- src/s60main/qts60main.cpp | 27 ++++++++++++++------------- src/s60main/qts60main_mcrt0.cpp | 27 ++++++++++++++------------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/s60main/qts60main.cpp b/src/s60main/qts60main.cpp index 8923fb9..de7d0be 100644 --- a/src/s60main/qts60main.cpp +++ b/src/s60main/qts60main.cpp @@ -15,24 +15,25 @@ ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor ** the names of its contributors may be used to endorse or promote ** products derived from this software without specific prior written ** permission. ** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -** IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -** THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/s60main/qts60main_mcrt0.cpp b/src/s60main/qts60main_mcrt0.cpp index b9a720b..18c09e5 100644 --- a/src/s60main/qts60main_mcrt0.cpp +++ b/src/s60main/qts60main_mcrt0.cpp @@ -15,24 +15,25 @@ ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor ** the names of its contributors may be used to endorse or promote ** products derived from this software without specific prior written ** permission. ** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -** IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -** THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** $QT_END_LICENSE$ ** ****************************************************************************/ -- cgit v0.12 From 53817ebe67158d642fd5d85dfdcf4d96e91b093b Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 6 Jan 2010 12:19:34 +0100 Subject: Updated WebKit from /home/shausman/src/webkit/trunk to qtwebkit/qtwebkit-4.6 ( 865abd2871c801c1d3d0f4eebd985b2daab89ebe ) Changes in WebKit/qt since the last update: --- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/ChangeLog | 20 ++++++++++++++++++++ .../WebCore/html/canvas/CanvasRenderingContext2D.cpp | 1 - .../graphics/qt/MediaPlayerPrivatePhonon.cpp | 8 +++----- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index d36e419..70913ca 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -8,4 +8,4 @@ The commit imported was from the and has the sha1 checksum - 5d691a1c283938dfbdf891883d8cff8a6ef040bf + 865abd2871c801c1d3d0f4eebd985b2daab89ebe diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index 03bb1fb..e72293d 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,23 @@ +2010-01-06 Simon Hausmann + + Unreviewed trivial Qt build fix. + + Prefix the phonon includes with phonon/ to avoid conflicts with the S60 + audio routing API ( http://wiki.forum.nokia.com/index.php/Audio_Routing_API ). + + * platform/graphics/qt/MediaPlayerPrivatePhonon.cpp: + +2009-12-31 Laszlo Gombos + + Reviewed by Kenneth Rohde Christiansen. + + Do not include Frame.h under WebCore/html/canvas + https://bugs.webkit.org/show_bug.cgi?id=33082 + + No new tests, as there is no new functionality. + + * html/canvas/CanvasRenderingContext2D.cpp: + 2009-12-30 Janne Koskinen Reviewed by Simon Hausmann. diff --git a/src/3rdparty/webkit/WebCore/html/canvas/CanvasRenderingContext2D.cpp b/src/3rdparty/webkit/WebCore/html/canvas/CanvasRenderingContext2D.cpp index 3341901..848771b 100644 --- a/src/3rdparty/webkit/WebCore/html/canvas/CanvasRenderingContext2D.cpp +++ b/src/3rdparty/webkit/WebCore/html/canvas/CanvasRenderingContext2D.cpp @@ -42,7 +42,6 @@ #include "Document.h" #include "ExceptionCode.h" #include "FloatConversion.h" -#include "Frame.h" #include "GraphicsContext.h" #include "HTMLCanvasElement.h" #include "HTMLImageElement.h" diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp index 9faa234..7a78391 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp @@ -38,12 +38,10 @@ #include #include -#if defined (__SYMBIAN32__) #include -#endif -#include -#include -#include +#include +#include +#include using namespace Phonon; -- cgit v0.12 From 59a2ed52a780afea84c118054fb7de2440a5d17f Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 6 Jan 2010 12:50:58 +0100 Subject: Don't write out fo:word-spacing if its the default value. the property fo:word-spacing is still not in an official ODF spec so a strict schema check will fail in any doc that uses it. Lets make sure we limit the writing of that property to only those usecases where the property was really set by the user. Task-number: QTBUG-5725 --- src/gui/text/qtextodfwriter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp index 5822d92..dcc2e7d 100644 --- a/src/gui/text/qtextodfwriter.cpp +++ b/src/gui/text/qtextodfwriter.cpp @@ -556,8 +556,8 @@ void QTextOdfWriter::writeCharacterFormat(QXmlStreamWriter &writer, QTextCharFor } if (format.hasProperty(QTextFormat::FontLetterSpacing)) writer.writeAttribute(foNS, QString::fromLatin1("letter-spacing"), pixelToPoint(format.fontLetterSpacing())); - if (format.hasProperty(QTextFormat::FontWordSpacing)) - writer.writeAttribute(foNS, QString::fromLatin1("word-spacing"), pixelToPoint(format.fontWordSpacing())); + if (format.hasProperty(QTextFormat::FontWordSpacing) && format.fontWordSpacing() != 0) + writer.writeAttribute(foNS, QString::fromLatin1("word-spacing"), pixelToPoint(format.fontWordSpacing())); if (format.hasProperty(QTextFormat::FontUnderline)) writer.writeAttribute(styleNS, QString::fromLatin1("text-underline-type"), format.fontUnderline() ? QString::fromLatin1("single") : QString::fromLatin1("none")); -- cgit v0.12 From e8b3defc466fff9110ee00b6e730d405cde52abc Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Wed, 6 Jan 2010 13:08:25 +0100 Subject: Fix QT_NO_CONTEXTMENU Task-number: QTBUG-6474 --- src/gui/statemachine/qguistatemachine.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/statemachine/qguistatemachine.cpp b/src/gui/statemachine/qguistatemachine.cpp index 4f7806f..c3a9228 100644 --- a/src/gui/statemachine/qguistatemachine.cpp +++ b/src/gui/statemachine/qguistatemachine.cpp @@ -186,8 +186,10 @@ static QEvent *cloneEvent(QEvent *e) case QEvent::DeactivateControl: return new QEvent(*e); +#ifndef QT_NO_CONTEXTMENU case QEvent::ContextMenu: return new QContextMenuEvent(*static_cast(e)); +#endif case QEvent::InputMethod: return new QInputMethodEvent(*static_cast(e)); case QEvent::AccessibilityPrepare: -- cgit v0.12 From 982cffb529f65c7d0c401844ef9af1925e550ffb Mon Sep 17 00:00:00 2001 From: David Boddie Date: Wed, 6 Jan 2010 13:44:17 +0100 Subject: Doc: Made coding style changes to the Audio Input and Output examples. Reviewed-by: Trust Me --- examples/multimedia/audioinput/audioinput.cpp | 75 +++++++++++++------------ examples/multimedia/audioinput/audioinput.h | 35 ++++++------ examples/multimedia/audiooutput/audiooutput.cpp | 26 ++++----- 3 files changed, 70 insertions(+), 66 deletions(-) diff --git a/examples/multimedia/audioinput/audioinput.cpp b/examples/multimedia/audioinput/audioinput.cpp index 75bddd6..4d54776 100644 --- a/examples/multimedia/audioinput/audioinput.cpp +++ b/examples/multimedia/audioinput/audioinput.cpp @@ -52,8 +52,8 @@ #define BUFFER_SIZE 4096 -AudioInfo::AudioInfo(QObject* parent, QAudioInput* device) - :QIODevice( parent ) +AudioInfo::AudioInfo(QObject *parent, QAudioInput *device) + :QIODevice(parent) { input = device; @@ -90,21 +90,24 @@ qint64 AudioInfo::writeData(const char *data, qint64 len) m_maxValue = 0; - qint16* s = (qint16*)data; + qint16 *s = (qint16*)data; // sample format is S16LE, only! - for(int i=0;i m_maxValue) m_maxValue = abs(sample); + if (abs(sample) > m_maxValue) m_maxValue = abs(sample); } // check for clipping - if(m_maxValue>=(maxAmp-1)) clipping = true; + if (m_maxValue >= (maxAmp - 1)) + clipping = true; float value = ((float)m_maxValue/(float)maxAmp); - if(clipping) m_maxValue = 100; - else m_maxValue = (int)(value*100); + if (clipping) + m_maxValue = 100; + else + m_maxValue = (int)(value*100); emit update(); @@ -132,25 +135,25 @@ void RenderArea::paintEvent(QPaintEvent * /* event */) QPainter painter(this); painter.setPen(Qt::black); - painter.drawRect(QRect(painter.viewport().left()+10, painter.viewport().top()+10, - painter.viewport().right()-20, painter.viewport().bottom()-20)); - - if(level == 0) + painter.drawRect(QRect(painter.viewport().left()+10, + painter.viewport().top()+10, + painter.viewport().right()-20, + painter.viewport().bottom()-20)); + if (level == 0) return; painter.setPen(Qt::red); int pos = ((painter.viewport().right()-20)-(painter.viewport().left()+11))*level/100; - int x1,y1,x2,y2; - for(int i=0;i<10;i++) { - x1 = painter.viewport().left()+11; - y1 = painter.viewport().top()+10+i; - x2 = painter.viewport().left()+20+pos; - y2 = painter.viewport().top()+10+i; - if(x2 < painter.viewport().left()+10) + for (int i = 0; i < 10; ++i) { + int x1 = painter.viewport().left()+11; + int y1 = painter.viewport().top()+10+i; + int x2 = painter.viewport().left()+20+pos; + int y2 = painter.viewport().top()+10+i; + if (x2 < painter.viewport().left()+10) x2 = painter.viewport().left()+10; - painter.drawLine(QPoint(x1,y1),QPoint(x2,y2)); + painter.drawLine(QPoint(x1, y1),QPoint(x2, y2)); } } @@ -171,20 +174,20 @@ InputTest::InputTest() deviceBox = new QComboBox(this); QList devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput); - for(int i = 0; i < devices.size(); ++i) { + for(int i = 0; i < devices.size(); ++i) deviceBox->addItem(devices.at(i).deviceName(), qVariantFromValue(devices.at(i))); - } - connect(deviceBox,SIGNAL(activated(int)),SLOT(deviceChanged(int))); + + connect(deviceBox, SIGNAL(activated(int)), SLOT(deviceChanged(int))); layout->addWidget(deviceBox); button = new QPushButton(this); button->setText(tr("Click for Push Mode")); - connect(button,SIGNAL(clicked()),SLOT(toggleMode())); + connect(button, SIGNAL(clicked()), SLOT(toggleMode())); layout->addWidget(button); button2 = new QPushButton(this); button2->setText(tr("Click To Suspend")); - connect(button2,SIGNAL(clicked()),SLOT(toggleSuspend())); + connect(button2, SIGNAL(clicked()), SLOT(toggleSuspend())); layout->addWidget(button2); window->setLayout(layout); @@ -214,10 +217,10 @@ InputTest::InputTest() } audioInput = new QAudioInput(format,this); - connect(audioInput,SIGNAL(notify()),SLOT(status())); - connect(audioInput,SIGNAL(stateChanged(QAudio::State)),SLOT(state(QAudio::State))); + connect(audioInput, SIGNAL(notify()), SLOT(status())); + connect(audioInput, SIGNAL(stateChanged(QAudio::State)), SLOT(state(QAudio::State))); audioinfo = new AudioInfo(this,audioInput); - connect(audioinfo,SIGNAL(update()),SLOT(refreshDisplay())); + connect(audioinfo, SIGNAL(update()), SLOT(refreshDisplay())); audioinfo->start(); audioInput->start(audioinfo); } @@ -250,7 +253,7 @@ void InputTest::toggleMode() if (pullMode) { button->setText(tr("Click for Pull Mode")); input = audioInput->start(); - connect(input,SIGNAL(readyRead()),SLOT(readMore())); + connect(input, SIGNAL(readyRead()), SLOT(readMore())); pullMode = false; } else { button->setText(tr("Click for Push Mode")); @@ -263,25 +266,25 @@ void InputTest::toggleSuspend() { // toggle suspend/resume if(audioInput->state() == QAudio::SuspendedState) { - qWarning()<<"status: Suspended, resume()"; + qWarning() << "status: Suspended, resume()"; audioInput->resume(); button2->setText("Click To Suspend"); } else if (audioInput->state() == QAudio::ActiveState) { - qWarning()<<"status: Active, suspend()"; + qWarning() << "status: Active, suspend()"; audioInput->suspend(); button2->setText("Click To Resume"); } else if (audioInput->state() == QAudio::StoppedState) { - qWarning()<<"status: Stopped, resume()"; + qWarning() << "status: Stopped, resume()"; audioInput->resume(); button2->setText("Click To Suspend"); } else if (audioInput->state() == QAudio::IdleState) { - qWarning()<<"status: IdleState"; + qWarning() << "status: IdleState"; } } void InputTest::state(QAudio::State state) { - qWarning()<<" state="<state() == QAudio::SuspendedState) { + qWarning() << "status: Suspended, resume()"; audioOutput->resume(); button2->setText("Click To Suspend"); } else if (audioOutput->state() == QAudio::ActiveState) { - qWarning()<<"status: Active, suspend()"; + qWarning() << "status: Active, suspend()"; audioOutput->suspend(); button2->setText("Click To Resume"); } else if (audioOutput->state() == QAudio::StoppedState) { - qWarning()<<"status: Stopped, resume()"; + qWarning() << "status: Stopped, resume()"; audioOutput->resume(); button2->setText("Click To Suspend"); } else if (audioOutput->state() == QAudio::IdleState) { - qWarning()<<"status: IdleState"; + qWarning() << "status: IdleState"; } } void AudioTest::state(QAudio::State state) { - qWarning()<<" state="<text(),QLatin1String("blah")); + delete dialog; } void tst_QFiledialog::viewMode() diff --git a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp index 9757fa0..c3f88c4 100644 --- a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp @@ -131,6 +131,7 @@ private slots: void QTBUG4419_lineEditSelectAll(); void QTBUG6558_showDirsOnly(); + void QTBUG4842_selectFilterWithHideNameFilterDetails(); private: QByteArray userSettings; @@ -1107,5 +1108,45 @@ void tst_QFiledialog::QTBUG6558_showDirsOnly() dirTemp.rmdir(tempName); } +void tst_QFiledialog::QTBUG4842_selectFilterWithHideNameFilterDetails() +{ + QStringList filtersStr; + filtersStr << "Images (*.png *.xpm *.jpg)" << "Text files (*.txt)" << "XML files (*.xml)"; + QString chosenFilterString("Text files (*.txt)"); + + QNonNativeFileDialog fd(0, "TestFileDialog"); + fd.setAcceptMode(QFileDialog::AcceptSave); + fd.setOption(QFileDialog::HideNameFilterDetails, true); + fd.setNameFilters(filtersStr); + fd.selectNameFilter(chosenFilterString); + fd.show(); + + QApplication::setActiveWindow(&fd); + QTest::qWaitForWindowShown(&fd