diff options
author | Liang Qi <liang.qi@nokia.com> | 2011-10-07 12:21:59 (GMT) |
---|---|---|
committer | Liang Qi <liang.qi@nokia.com> | 2011-10-07 12:21:59 (GMT) |
commit | 7cf9030bd7a50b6d98d454510417c6ecc3f33d49 (patch) | |
tree | 7c5c562ba490e217d8cef81ff1fd5958a0cacccb | |
parent | 7f3cd2949ccb16b1b611c05bf6ab7274cf04a0f8 (diff) | |
parent | 96fcfc720aa1c6d0b6d741f8169cd37ea9fcd9a9 (diff) | |
download | Qt-7cf9030bd7a50b6d98d454510417c6ecc3f33d49.zip Qt-7cf9030bd7a50b6d98d454510417c6ecc3f33d49.tar.gz Qt-7cf9030bd7a50b6d98d454510417c6ecc3f33d49.tar.bz2 |
Merge remote-tracking branch 'origin/4.7' into qt-4.8-from-4.7
Conflicts:
doc/src/getting-started/installation.qdoc
doc/src/platforms/platform-notes.qdoc
src/corelib/tools/qlocale_symbian.cpp
src/gui/kernel/qwidget_p.h
src/network/access/qnetworkaccesshttpbackend.cpp
src/opengl/qgl.cpp
src/plugins/bearer/symbian/qnetworksession_impl.cpp
21 files changed, 607 insertions, 55 deletions
diff --git a/src/declarative/qml/qdeclarativeimport.cpp b/src/declarative/qml/qdeclarativeimport.cpp index bf261ef..c2f0086 100644 --- a/src/declarative/qml/qdeclarativeimport.cpp +++ b/src/declarative/qml/qdeclarativeimport.cpp @@ -46,6 +46,7 @@ #include <QtCore/qfileinfo.h> #include <QtCore/qpluginloader.h> #include <QtCore/qlibraryinfo.h> +#include <QtCore/qalgorithms.h> #include <QtDeclarative/qdeclarativeextensioninterface.h> #include <private/qdeclarativeglobal_p.h> #include <private/qdeclarativetypenamecache_p.h> @@ -734,8 +735,12 @@ QDeclarativeImportDatabase::QDeclarativeImportDatabase(QDeclarativeEngine *e) } RFs& fs = qt_s60GetRFs(); TPtrC tempPathPtr(reinterpret_cast<const TText*> (tempPath.constData())); + // Symbian searches should start from Y:. Fix start drive otherwise TFindFile starts from the session drive + _LIT(KStartDir, "Y:"); + TFileName dirPath(KStartDir); + dirPath.Append(tempPathPtr); TFindFile finder(fs); - TInt err = finder.FindByDir(tempPathPtr, tempPathPtr); + TInt err = finder.FindByDir(tempPathPtr, dirPath); while (err == KErrNone) { QString foundDir(reinterpret_cast<const QChar *>(finder.File().Ptr()), finder.File().Length()); @@ -743,6 +748,9 @@ QDeclarativeImportDatabase::QDeclarativeImportDatabase(QDeclarativeEngine *e) addImportPath(foundDir); err = finder.Find(); } + // TFindFile found the directories in the order we want, but addImportPath reverses it. + // Reverse the order again to get it right. + QAlgorithmsPrivate::qReverse(fileImportPath.begin(), fileImportPath.end()); } else { addImportPath(installImportsPath); } diff --git a/src/declarative/qml/qdeclarativepropertycache_p.h b/src/declarative/qml/qdeclarativepropertycache_p.h index 581f519..c648d25 100644 --- a/src/declarative/qml/qdeclarativepropertycache_p.h +++ b/src/declarative/qml/qdeclarativepropertycache_p.h @@ -111,7 +111,7 @@ public: int relatedIndex; // When IsFunction }; uint overrideIndexIsProperty : 1; - int overrideIndex : 31; + signed int overrideIndex : 31; int revision; int metaObjectOffset; diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp index 2a37d45..6fe1c8c 100644 --- a/src/gui/egl/qegl.cpp +++ b/src/gui/egl/qegl.cpp @@ -684,6 +684,37 @@ EGLSurface QEgl::createSurface(QPaintDevice *device, EGLConfig cfg, const QEglPr else props = 0; EGLSurface surf; +#ifdef Q_OS_SYMBIAN + // On Symbian there might be situations (especially on 32MB GPU devices) + // where Qt is trying to create EGL surface while some other application + // is still holding all available GPU memory but is about to release it + // soon. For an example when exiting native video recorder and going back to + // Qt application behind it. Video stack tear down takes some time and Qt + // app might be too quick in reserving its EGL surface and thus running out + // of GPU memory right away. So if EGL surface creation fails due to bad + // alloc, let's try recreating it four times within ~1 second if needed. + // This strategy gives some time for video recorder to tear down its stack + // and a chance to Qt for creating a valid surface. + int tries = 4; + while(tries--) { + if (devType == QInternal::Widget) + surf = eglCreateWindowSurface(QEgl::display(), cfg, windowDrawable, props); + else + surf = eglCreatePixmapSurface(QEgl::display(), cfg, pixmapDrawable, props); + if (surf == EGL_NO_SURFACE) { + EGLint error = eglGetError(); + if (error == EGL_BAD_ALLOC) { + if (tries) { + User::After(1000 * 250); // 250ms + continue; + } + } + qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", error); + } else { + break; + } + } +#else if (devType == QInternal::Widget) surf = eglCreateWindowSurface(QEgl::display(), cfg, windowDrawable, props); else @@ -691,6 +722,7 @@ EGLSurface QEgl::createSurface(QPaintDevice *device, EGLConfig cfg, const QEglPr if (surf == EGL_NO_SURFACE) { qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", eglGetError()); } +#endif return surf; } #endif diff --git a/src/gui/kernel/qcursor_win.cpp b/src/gui/kernel/qcursor_win.cpp index cef83f5..a68472c 100644 --- a/src/gui/kernel/qcursor_win.cpp +++ b/src/gui/kernel/qcursor_win.cpp @@ -477,7 +477,7 @@ void QCursorData::update() QPixmap pixmap = QApplicationPrivate::instance()->getPixmapCursor(cshape); hcurs = create32BitCursor(pixmap, hx, hy); } - break; + return; default: qWarning("QCursor::update: Invalid cursor shape %d", cshape); return; diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 0aa1dfa..9b5a283 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -2260,10 +2260,16 @@ void QWidgetPrivate::updateIsOpaque() #endif #ifdef Q_WS_S60 - if (q->windowType() == Qt::Dialog && q->testAttribute(Qt::WA_TranslucentBackground) - && S60->avkonComponentsSupportTransparency) { - setOpaque(false); - return; + if (q->testAttribute(Qt::WA_TranslucentBackground)) { + if (q->windowType() & Qt::Dialog || q->windowType() & Qt::Popup) { + if (S60->avkonComponentsSupportTransparency) { + setOpaque(false); + return; + } + } else { + setOpaque(false); + return; + } } #endif @@ -2283,11 +2289,16 @@ void QWidgetPrivate::updateIsOpaque() } if (q->isWindow() && !q->testAttribute(Qt::WA_NoSystemBackground)) { +#ifdef Q_WS_S60 + setOpaque(true); + return; +#else const QBrush &windowBrush = q->palette().brush(QPalette::Window); if (windowBrush.style() != Qt::NoBrush && windowBrush.isOpaque()) { setOpaque(true); return; } +#endif } setOpaque(false); } @@ -10948,11 +10959,14 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) } break; case Qt::WA_TranslucentBackground: +#if defined(Q_OS_SYMBIAN) + setAttribute(Qt::WA_NoSystemBackground, on); +#else if (on) { setAttribute(Qt::WA_NoSystemBackground); d->updateIsTranslucent(); } - +#endif break; case Qt::WA_AcceptTouchEvents: #if defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN) diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index aefffb6..9ac9479 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -233,6 +233,7 @@ struct QTLWExtra { uint inExpose : 1; // Prevents drawing recursion uint nativeWindowTransparencyEnabled : 1; // Tracks native window transparency uint forcedToRaster : 1; + uint noSystemRotationDisabled : 1; #elif defined(Q_WS_QPA) QPlatformWindow *platformWindow; QPlatformWindowFormat platformWindowFormat; diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index e06b625..00661ae 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -804,19 +804,12 @@ void QWidgetPrivate::setConstraints_sys() void QWidgetPrivate::s60UpdateIsOpaque() { Q_Q(QWidget); - if (!q->testAttribute(Qt::WA_WState_Created)) return; - const bool writeAlpha = extraData()->nativePaintMode == QWExtra::BlitWriteAlpha; - if (!q->testAttribute(Qt::WA_TranslucentBackground) && !writeAlpha) - return; const bool requireAlphaChannel = !isOpaque || writeAlpha; - createTLExtra(); - RWindow *const window = static_cast<RWindow *>(q->effectiveWinId()->DrawableWindow()); - #ifdef Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE if (QApplicationPrivate::instance()->useTranslucentEGLSurfaces && !extra->topextra->forcedToRaster) { @@ -825,25 +818,47 @@ void QWidgetPrivate::s60UpdateIsOpaque() return; } #endif + const bool recreateBackingStore = extra->topextra->backingStore.data() && ( + QApplicationPrivate::graphics_system_name == QLatin1String("openvg") || + QApplicationPrivate::graphics_system_name == QLatin1String("opengl") + ); if (requireAlphaChannel) { - const TDisplayMode displayMode = static_cast<TDisplayMode>(window->SetRequiredDisplayMode(EColor16MA)); - if (window->SetTransparencyAlphaChannel() == KErrNone) { + window->SetRequiredDisplayMode(EColor16MA); + if (window->SetTransparencyAlphaChannel() == KErrNone) window->SetBackgroundColor(TRgb(255, 255, 255, 0)); - extra->topextra->nativeWindowTransparencyEnabled = 1; - if (extra->topextra->backingStore.data() && ( - QApplicationPrivate::graphics_system_name == QLatin1String("openvg") - || QApplicationPrivate::graphics_system_name == QLatin1String("opengl"))) { - // Semi-transparent EGL surfaces aren't supported. We need to - // recreate backing store to get translucent surface (raster surface). - extra->topextra->backingStore.create(q); - extra->topextra->backingStore.registerWidget(q); - // FixNativeOrientation() will not work without an EGL surface. + } else { + if (recreateBackingStore) { + // Clear the UI surface to ensure that the EGL surface content is visible + CWsScreenDevice *screenDevice = S60->screenDevice(q); + QScopedPointer<CWindowGc> gc(new CWindowGc(screenDevice)); + const int err = gc->Construct(); + if (!err) { + gc->Activate(*window); + window->BeginRedraw(); + gc->SetDrawMode(CWindowGc::EDrawModeWriteAlpha); + gc->SetBrushColor(TRgb(0, 0, 0, 0)); + gc->Clear(TRect(0, 0, q->width(), q->height())); + window->EndRedraw(); + } + } + if (extra->topextra->nativeWindowTransparencyEnabled) + window->SetTransparentRegion(TRegionFix<1>()); + } + extra->topextra->nativeWindowTransparencyEnabled = requireAlphaChannel; + if (recreateBackingStore) { + extra->topextra->backingStore.create(q); + extra->topextra->backingStore.registerWidget(q); + bool noSystemRotationDisabled = false; + if (requireAlphaChannel) { + if (q->testAttribute(Qt::WA_SymbianNoSystemRotation)) { + // FixNativeOrientation() will not work without an EGL surface q->setAttribute(Qt::WA_SymbianNoSystemRotation, false); + noSystemRotationDisabled = true; } + } else { + q->setAttribute(Qt::WA_SymbianNoSystemRotation, extra->topextra->noSystemRotationDisabled); } - } else if (extra->topextra->nativeWindowTransparencyEnabled) { - window->SetTransparentRegion(TRegionFix<1>()); - extra->topextra->nativeWindowTransparencyEnabled = 0; + extra->topextra->noSystemRotationDisabled = noSystemRotationDisabled; } } @@ -1004,6 +1019,7 @@ void QWidgetPrivate::createTLSysExtra() extra->topextra->inExpose = 0; extra->topextra->nativeWindowTransparencyEnabled = 0; extra->topextra->forcedToRaster = 0; + extra->topextra->noSystemRotationDisabled = 0; } void QWidgetPrivate::deleteTLSysExtra() diff --git a/src/gui/painting/qgraphicssystemex_symbian.cpp b/src/gui/painting/qgraphicssystemex_symbian.cpp index 4469704..32e040f 100644 --- a/src/gui/painting/qgraphicssystemex_symbian.cpp +++ b/src/gui/painting/qgraphicssystemex_symbian.cpp @@ -46,31 +46,108 @@ #include <e32property.h> +#ifdef Q_SYMBIAN_SUPPORTS_SURFACES +#include "private/qegl_p.h" +#endif + QT_BEGIN_NAMESPACE static bool bcm2727Initialized = false; static bool bcm2727 = false; +#ifdef Q_SYMBIAN_SUPPORTS_SURFACES +typedef EGLBoolean (*NOK_resource_profiling)(EGLDisplay, EGLint, EGLint*, EGLint, EGLint*); +#define EGL_PROF_TOTAL_MEMORY_NOK 0x3070 +#endif + +// Detect if Qt is running on BCM2727 chip. +// BCM2727 is a special case on Symbian because +// it has only 32MB GPU memory which exposes +// significant limitations to hw accelerated UI. bool QSymbianGraphicsSystemEx::hasBCM2727() { if (bcm2727Initialized) return bcm2727; - const TUid KIvePropertyCat = {0x2726beef}; - enum TIvePropertyChipType { - EVCBCM2727B1 = 0x00000000, - EVCBCM2763A0 = 0x04000100, - EVCBCM2763B0 = 0x04000102, - EVCBCM2763C0 = 0x04000103, - EVCBCM2763C1 = 0x04000104, - EVCBCMUnknown = 0x7fffffff - }; - - TInt chipType = EVCBCMUnknown; - if (RProperty::Get(KIvePropertyCat, 0, chipType) == KErrNone) { - if (chipType == EVCBCM2727B1) +#ifdef Q_SYMBIAN_SUPPORTS_SURFACES + EGLDisplay display = QEgl::display(); +#if 1 + // Hacky but fast ~0ms. + const char* vendor = eglQueryString(display, EGL_VENDOR); + if (strstr(vendor, "Broadcom")) { + const TUid KIvePropertyCat = {0x2726beef}; + enum TIvePropertyChipType { + EVCBCM2727B1 = 0x00000000, + EVCBCM2763A0 = 0x04000100, + EVCBCM2763B0 = 0x04000102, + EVCBCM2763C0 = 0x04000103, + EVCBCM2763C1 = 0x04000104, + EVCBCMUnknown = 0x7fffffff + }; + + // Broadcom driver publishes KIvePropertyCat PS key on + // devices which are running on BCM2727 chip and post Anna Symbian. + TInt chipType = EVCBCMUnknown; + if (RProperty::Get(KIvePropertyCat, 0, chipType) == KErrNone) { + if (chipType == EVCBCM2727B1) + bcm2727 = true; + } else if (QSysInfo::symbianVersion() <= QSysInfo::SV_SF_3) { + // Device is running on Symbian Anna or older Symbian^3 in which + // KIvePropertyCat is not published. These ones are always 32MB devices. + bcm2727 = true; + } else { + // We have some other Broadcom chip on post Anna Symbian. + // Should have > 32MB GPU memory. + } + } +#else + // Fool proof but takes 15-20ms and we don't want this delay on app startup... + + // All devices with <= 32MB GPU memory should be + // dealed in similar manner to BCM2727 + // So let's query max GPU memory amount. + NOK_resource_profiling eglQueryProfilingData = (NOK_resource_profiling)eglGetProcAddress("eglQueryProfilingDataNOK"); + if (eglQueryProfilingData) { + EGLint dataCount; + eglQueryProfilingData(display, + EGL_PROF_QUERY_GLOBAL_BIT_NOK | + EGL_PROF_QUERY_MEMORY_USAGE_BIT_NOK, + NULL, + 0, + (EGLint*)&dataCount); + + // Allocate room for the profiling data + EGLint* profData = (EGLint*)malloc(dataCount * sizeof(EGLint)); + memset(profData,0,dataCount * sizeof(EGLint)); + + // Retrieve the profiling data + eglQueryProfilingData(display, + EGL_PROF_QUERY_GLOBAL_BIT_NOK | + EGL_PROF_QUERY_MEMORY_USAGE_BIT_NOK, + profData, + dataCount, + (EGLint*)&dataCount); + + int totalMemory; + EGLint i = 0; + while (profData && i < dataCount) { + switch (profData[i++]) { + case EGL_PROF_TOTAL_MEMORY_NOK: + totalMemory = profData[i++]; + break; + default: + i++; + } + } + + // ok, hasBCM2727() naming is a bit misleading but Qt must + // behave the same on all chips like BCM2727 (<= 32MB GPU memory) + // and our code (and others) are already using this function. + if (totalMemory <= 33554432) bcm2727 = true; } +#endif +#endif // Q_SYMBIAN_SUPPORTS_SURFACES bcm2727Initialized = true; @@ -80,7 +157,9 @@ bool QSymbianGraphicsSystemEx::hasBCM2727() void QSymbianGraphicsSystemEx::releaseCachedGpuResources() { // Do nothing here - // This is implemented in graphics system specific plugin + + // This virtual function should be implemented in graphics system specific + // plugin } void QSymbianGraphicsSystemEx::releaseAllGpuResources() diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index d58da37..0af2e59 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -445,6 +445,8 @@ void QLineControl::moveCursor(int pos, bool mark) void QLineControl::processInputMethodEvent(QInputMethodEvent *event) { int priorState = 0; + int originalSelectionStart = m_selstart; + int originalSelectionEnd = m_selend; bool isGettingInput = !event->commitString().isEmpty() || event->preeditString() != preeditAreaText() || event->replacementLength() > 0; @@ -523,6 +525,8 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event) } m_textLayout.setAdditionalFormats(formats); updateDisplayText(/*force*/ true); + if (originalSelectionStart != m_selstart || originalSelectionEnd != m_selend) + emit selectionChanged(); if (cursorPositionChanged) emitCursorPositionChanged(); else if (m_preeditCursor != oldPreeditCursor) diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp index 1a02200..6173b39 100644 --- a/src/network/access/qhttpnetworkreply.cpp +++ b/src/network/access/qhttpnetworkreply.cpp @@ -891,7 +891,7 @@ bool QHttpNetworkReplyPrivate::expectContent() || statusCode == 204 || statusCode == 304) return false; if (request.operation() == QHttpNetworkRequest::Head) - return !shouldEmitSignals(); + return false; // no body expected for HEAD request qint64 expectedContentLength = contentLength(); if (expectedContentLength == 0) return false; diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index 0b568d4..6f2daec 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -471,6 +471,7 @@ bool QNetworkReplyImplPrivate::isCachingEnabled() const void QNetworkReplyImplPrivate::setCachingEnabled(bool enable) { + Q_Q(QNetworkReplyImpl); if (!enable && !cacheEnabled) return; // nothing to do if (enable && cacheEnabled) @@ -493,15 +494,27 @@ void QNetworkReplyImplPrivate::setCachingEnabled(bool enable) networkCache()->remove(url); cacheSaveDevice = 0; cacheEnabled = false; + QObject::disconnect(networkCache(), SIGNAL(destroyed()), q, SLOT(_q_cacheDestroyed())); } } +void QNetworkReplyImplPrivate::_q_cacheDestroyed() +{ + //destruction of cache invalidates cacheSaveDevice + cacheSaveDevice = 0; + cacheEnabled = false; +} + void QNetworkReplyImplPrivate::completeCacheSave() { - if (cacheEnabled && errorCode != QNetworkReplyImpl::NoError) { - networkCache()->remove(url); - } else if (cacheEnabled && cacheSaveDevice) { - networkCache()->insert(cacheSaveDevice); + Q_Q(QNetworkReplyImpl); + if (cacheEnabled) { + if (errorCode != QNetworkReplyImpl::NoError) { + networkCache()->remove(url); + } else if (cacheSaveDevice) { + networkCache()->insert(cacheSaveDevice); + } + QObject::disconnect(networkCache(), SIGNAL(destroyed()), q, SLOT(_q_cacheDestroyed())); } cacheSaveDevice = 0; cacheEnabled = false; @@ -561,6 +574,8 @@ void QNetworkReplyImplPrivate::initCacheSaveDevice() networkCache()->remove(url); cacheSaveDevice = 0; cacheEnabled = false; + } else { + q->connect(networkCache(), SIGNAL(destroyed()), SLOT(_q_cacheDestroyed())); } } diff --git a/src/network/access/qnetworkreplyimpl_p.h b/src/network/access/qnetworkreplyimpl_p.h index 089c87e..286d8ea 100644 --- a/src/network/access/qnetworkreplyimpl_p.h +++ b/src/network/access/qnetworkreplyimpl_p.h @@ -104,6 +104,7 @@ public: Q_PRIVATE_SLOT(d_func(), void _q_networkSessionConnected()) Q_PRIVATE_SLOT(d_func(), void _q_networkSessionFailed()) #endif + Q_PRIVATE_SLOT(d_func(), void _q_cacheDestroyed()) }; class QNetworkReplyImplPrivate: public QNetworkReplyPrivate @@ -140,6 +141,7 @@ public: void _q_networkSessionConnected(); void _q_networkSessionFailed(); #endif + void _q_cacheDestroyed(); void setup(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *outgoingData); diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index cedccaa..423fa08 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -103,6 +103,7 @@ #ifdef Q_OS_SYMBIAN #include <private/qgltexturepool_p.h> +#include <private/qeglcontext_p.h> #endif // #define QT_GL_CONTEXT_RESOURCE_DEBUG @@ -3432,8 +3433,25 @@ const QGLContext* QGLContext::currentContext() return 0; #else QGLThreadContext *threadContext = qgl_context_storage.localData(); - if (threadContext) + if (threadContext) { +#ifdef Q_OS_SYMBIAN + // Query the current context and return null if it is different. + // This is needed to support mixed VG-GL rendering. + // QtOpenVG is free to make a QEglContext current at any time and + // QGLContext gets no notification that its underlying QEglContext is + // not current anymore. We query directly from EGL to be thread-safe. + // QEglContext does not store all the contexts per-thread. + if (threadContext->context) { + QEglContext *eglcontext = threadContext->context->d_func()->eglContext; + if (eglcontext) { + EGLContext ctx = eglcontext->context(); + if (ctx != eglGetCurrentContext()) + return 0; + } + } +#endif return threadContext->context; + } return 0; #endif //Q_WS_QPA } diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp index 2cc2971..96bea68 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp @@ -43,6 +43,7 @@ #include <QtDeclarative/qdeclarativeengine.h> #include <QtDeclarative/qdeclarativecomponent.h> #include <QDebug> +#include <QtCore/qlibraryinfo.h> #include "../shared/testhttpserver.h" #include "../../../shared/util.h" @@ -70,6 +71,7 @@ private slots: void remoteImportWithUnquotedUri(); void versionNotInstalled(); void versionNotInstalled_data(); + void importPath(); }; #ifdef Q_OS_SYMBIAN @@ -308,6 +310,29 @@ void tst_qdeclarativemoduleplugin::versionNotInstalled() VERIFY_ERRORS(errorFile.toLatin1().constData()); } +void tst_qdeclarativemoduleplugin::importPath() +{ +#ifndef Q_OS_SYMBIAN + QSKIP("Import path order testing for Symbian only", SkipAll); +#else + QDeclarativeEngine engine; + QStringList imports = engine.importPathList(); + QString installImportsPath = QDir::cleanPath(QLibraryInfo::location(QLibraryInfo::ImportsPath)); + QString driveOrder(QLatin1String("ZABCDEFGHIJKLMNOPQRSTUVWXY")); + int lastOrder = 30; + foreach(QString import, imports) + { + if (import.endsWith(installImportsPath)) + { + int order = driveOrder.indexOf(import[0]); + QVERIFY(order < lastOrder); + lastOrder = order; + } + } + QVERIFY(lastOrder != 30); +#endif +} + QTEST_MAIN(tst_qdeclarativemoduleplugin) #include "tst_qdeclarativemoduleplugin.moc" diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 33f74a9..4d8bd0b 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -156,6 +156,7 @@ private slots: void inputContextMouseHandler(); void inputMethodComposing(); void cursorRectangleSize(); + void deselect(); private: void simulateKey(QDeclarativeView *, int key, Qt::KeyboardModifiers modifiers = 0); @@ -2699,6 +2700,120 @@ void tst_qdeclarativetextedit::cursorRectangleSize() QCOMPARE(microFocusFromScene.size(), cursorRect.size()); QCOMPARE(microFocusFromApp.size(), cursorRect.size()); } + +void tst_qdeclarativetextedit::deselect() +{ + QDeclarativeView *canvas = createView(SRCDIR "/data/CursorRect.qml"); + QVERIFY(canvas->rootObject() != 0); + canvas->show(); + canvas->setFocus(); + QApplication::setActiveWindow(canvas); + QTest::qWaitForWindowShown(canvas); + + QDeclarativeTextEdit *textEdit = qobject_cast<QDeclarativeTextEdit *>(canvas->rootObject()); + QVERIFY(textEdit != 0); + + textEdit->setText("Select"); + + QSignalSpy selectionStartSpy(textEdit, SIGNAL(selectionStartChanged())); + QSignalSpy selectionEndSpy(textEdit, SIGNAL(selectionEndChanged())); + QSignalSpy selectionSpy(textEdit, SIGNAL(selectionChanged())); + + textEdit->select(5, 6); + + QCOMPARE(selectionStartSpy.count(), 1); + QCOMPARE(selectionEndSpy.count(), 1); + QCOMPARE(selectionSpy.count(), 1); + QCOMPARE(textEdit->selectionStart(), 5); + QCOMPARE(textEdit->selectionEnd(), 6); + QCOMPARE(textEdit->selectedText(), QLatin1String("t")); + QCOMPARE(textEdit->cursorPosition(), 6); + + textEdit->deselect(); + + QCOMPARE(selectionStartSpy.count(), 2); + QCOMPARE(selectionEndSpy.count(), 1); + QCOMPARE(selectionSpy.count(), 2); + QCOMPARE(textEdit->selectionStart(), textEdit->cursorPosition()); + QCOMPARE(textEdit->selectionEnd(), textEdit->cursorPosition()); + QCOMPARE(textEdit->selectedText(), QLatin1String("")); + QCOMPARE(textEdit->cursorPosition(), 6); + + textEdit->select(5, 6); + + QCOMPARE(selectionStartSpy.count(), 3); + QCOMPARE(selectionEndSpy.count(), 1); + QCOMPARE(selectionSpy.count(), 3); + QCOMPARE(textEdit->selectionStart(), 5); + QCOMPARE(textEdit->selectionEnd(), 6); + QCOMPARE(textEdit->selectedText(), QLatin1String("t")); + QCOMPARE(textEdit->cursorPosition(), 6); + + QKeyEvent leftArrowPress(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier); + QKeyEvent leftArrowRelese(QEvent::KeyRelease, Qt::Key_Left, Qt::NoModifier); + QApplication::sendEvent(canvas, &leftArrowPress); + QApplication::sendEvent(canvas, &leftArrowRelese); + + QCOMPARE(selectionStartSpy.count(), 3); + QCOMPARE(selectionEndSpy.count(), 2); + QCOMPARE(selectionSpy.count(), 4); + QCOMPARE(textEdit->selectionStart(), textEdit->cursorPosition()); + QCOMPARE(textEdit->selectionEnd(), textEdit->cursorPosition()); + QCOMPARE(textEdit->selectedText(), QLatin1String("")); + QCOMPARE(textEdit->cursorPosition(), 5); + + textEdit->select(5, 6); + + QCOMPARE(selectionStartSpy.count(), 3); + QCOMPARE(selectionEndSpy.count(), 3); + QCOMPARE(selectionSpy.count(), 5); + QCOMPARE(textEdit->selectionStart(), 5); + QCOMPARE(textEdit->selectionEnd(), 6); + QCOMPARE(textEdit->selectedText(), QLatin1String("t")); + QCOMPARE(textEdit->cursorPosition(), 6); + + QList<QInputMethodEvent::Attribute> attributes; + attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 0, QVariant()); + QInputMethodEvent event(QLatin1String(""), attributes); + QApplication::sendEvent(canvas, &event); + + QCOMPARE(selectionStartSpy.count(), 4); + QCOMPARE(selectionEndSpy.count(), 4); + QCOMPARE(selectionSpy.count(), 6); + QCOMPARE(textEdit->selectionStart(), textEdit->cursorPosition()); + QCOMPARE(textEdit->selectionEnd(), textEdit->cursorPosition()); + QCOMPARE(textEdit->selectedText(), QLatin1String("")); + QCOMPARE(textEdit->cursorPosition(), 0); + + textEdit->setCursorPosition(1); + + QCOMPARE(selectionStartSpy.count(), 5); + QCOMPARE(selectionEndSpy.count(), 5); + QCOMPARE(selectionSpy.count(), 6); + + QKeyEvent leftArrowShiftPress(QEvent::KeyPress, Qt::Key_Left, Qt::ShiftModifier); + QKeyEvent leftArrowShiftRelese(QEvent::KeyRelease, Qt::Key_Left, Qt::ShiftModifier); + QApplication::sendEvent(canvas, &leftArrowShiftPress); + QApplication::sendEvent(canvas, &leftArrowShiftRelese); + + QCOMPARE(selectionStartSpy.count(), 6); + QCOMPARE(selectionEndSpy.count(), 5); + QCOMPARE(selectionSpy.count(), 7); + QCOMPARE(textEdit->selectionStart(), 0); + QCOMPARE(textEdit->selectionEnd(), 1); + QCOMPARE(textEdit->selectedText(), QLatin1String("S")); + QCOMPARE(textEdit->cursorPosition(), 0); + + QApplication::sendEvent(canvas, &event); + + QCOMPARE(selectionStartSpy.count(), 6); + QCOMPARE(selectionEndSpy.count(), 6); + QCOMPARE(selectionSpy.count(), 8); + QCOMPARE(textEdit->selectionStart(), textEdit->cursorPosition()); + QCOMPARE(textEdit->selectionEnd(), textEdit->cursorPosition()); + QCOMPARE(textEdit->selectedText(), QLatin1String("")); + QCOMPARE(textEdit->cursorPosition(), 0); +} QTEST_MAIN(tst_qdeclarativetextedit) #include "tst_qdeclarativetextedit.moc" diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index bb895bf..b077670 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -147,6 +147,7 @@ private slots: void inputContextMouseHandler(); void inputMethodComposing(); void cursorRectangleSize(); + void deselect(); private: void simulateKey(QDeclarativeView *, int key); @@ -2367,7 +2368,7 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus() QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled)); // input method should not be enabled - // if TextEdit is read only. + // if TextInput is read only. input.setReadOnly(true); ic.openInputPanelReceived = false; input.setFocus(true); @@ -2815,6 +2816,120 @@ void tst_qdeclarativetextinput::cursorRectangleSize() QCOMPARE(microFocusFromApp.size(), cursorRect.size()); } +void tst_qdeclarativetextinput::deselect() +{ + QDeclarativeView *canvas = createView(SRCDIR "/data/positionAt.qml"); + QVERIFY(canvas->rootObject() != 0); + canvas->show(); + canvas->setFocus(); + QApplication::setActiveWindow(canvas); + QTest::qWaitForWindowShown(canvas); + + QDeclarativeTextInput *textInput = qobject_cast<QDeclarativeTextInput *>(canvas->rootObject()); + QVERIFY(textInput != 0); + + textInput->setText("Select"); + + QSignalSpy selectionStartSpy(textInput, SIGNAL(selectionStartChanged())); + QSignalSpy selectionEndSpy(textInput, SIGNAL(selectionEndChanged())); + QSignalSpy selectedTextSpy(textInput, SIGNAL(selectedTextChanged())); + + textInput->select(5, 6); + + QCOMPARE(selectionStartSpy.count(), 1); + QCOMPARE(selectionEndSpy.count(), 0); + QCOMPARE(selectedTextSpy.count(), 1); + QCOMPARE(textInput->selectionStart(), 5); + QCOMPARE(textInput->selectionEnd(), 6); + QCOMPARE(textInput->selectedText(), QLatin1String("t")); + QCOMPARE(textInput->cursorPosition(), 6); + + textInput->deselect(); + + QCOMPARE(selectionStartSpy.count(), 2); + QCOMPARE(selectionEndSpy.count(), 1); + QCOMPARE(selectedTextSpy.count(), 2); + QCOMPARE(textInput->selectionStart(), textInput->cursorPosition()); + QCOMPARE(textInput->selectionEnd(), textInput->cursorPosition()); + QCOMPARE(textInput->selectedText(), QLatin1String("")); + QCOMPARE(textInput->cursorPosition(), 6); + + textInput->select(5, 6); + + QCOMPARE(selectionStartSpy.count(), 3); + QCOMPARE(selectionEndSpy.count(), 1); + QCOMPARE(selectedTextSpy.count(), 3); + QCOMPARE(textInput->selectionStart(), 5); + QCOMPARE(textInput->selectionEnd(), 6); + QCOMPARE(textInput->selectedText(), QLatin1String("t")); + QCOMPARE(textInput->cursorPosition(), 6); + + QKeyEvent leftArrowPress(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier); + QKeyEvent leftArrowRelese(QEvent::KeyRelease, Qt::Key_Left, Qt::NoModifier); + QApplication::sendEvent(canvas, &leftArrowPress); + QApplication::sendEvent(canvas, &leftArrowRelese); + + QCOMPARE(selectionStartSpy.count(), 4); + QCOMPARE(selectionEndSpy.count(), 2); + QCOMPARE(selectedTextSpy.count(), 4); + QCOMPARE(textInput->selectionStart(), textInput->cursorPosition()); + QCOMPARE(textInput->selectionEnd(), textInput->cursorPosition()); + QCOMPARE(textInput->selectedText(), QLatin1String("")); + QCOMPARE(textInput->cursorPosition(), 5); + + textInput->select(5, 6); + + QCOMPARE(selectionStartSpy.count(), 4); + QCOMPARE(selectionEndSpy.count(), 3); + QCOMPARE(selectedTextSpy.count(), 5); + QCOMPARE(textInput->selectionStart(), 5); + QCOMPARE(textInput->selectionEnd(), 6); + QCOMPARE(textInput->selectedText(), QLatin1String("t")); + QCOMPARE(textInput->cursorPosition(), 6); + + QList<QInputMethodEvent::Attribute> attributes; + attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 0, QVariant()); + QInputMethodEvent event(QLatin1String(""), attributes); + QApplication::sendEvent(canvas, &event); + + QCOMPARE(selectionStartSpy.count(), 5); + QCOMPARE(selectionEndSpy.count(), 4); + QCOMPARE(selectedTextSpy.count(), 6); + QCOMPARE(textInput->selectionStart(), textInput->cursorPosition()); + QCOMPARE(textInput->selectionEnd(), textInput->cursorPosition()); + QCOMPARE(textInput->selectedText(), QLatin1String("")); + QCOMPARE(textInput->cursorPosition(), 0); + + textInput->setCursorPosition(1); + + QCOMPARE(selectionStartSpy.count(), 6); + QCOMPARE(selectionEndSpy.count(), 5); + QCOMPARE(selectedTextSpy.count(), 6); + + QKeyEvent leftArrowShiftPress(QEvent::KeyPress, Qt::Key_Left, Qt::ShiftModifier); + QKeyEvent leftArrowShiftRelese(QEvent::KeyRelease, Qt::Key_Left, Qt::ShiftModifier); + QApplication::sendEvent(canvas, &leftArrowShiftPress); + QApplication::sendEvent(canvas, &leftArrowShiftRelese); + + QCOMPARE(selectionStartSpy.count(), 7); + QCOMPARE(selectionEndSpy.count(), 5); + QCOMPARE(selectedTextSpy.count(), 7); + QCOMPARE(textInput->selectionStart(), 0); + QCOMPARE(textInput->selectionEnd(), 1); + QCOMPARE(textInput->selectedText(), QLatin1String("S")); + QCOMPARE(textInput->cursorPosition(), 0); + + QApplication::sendEvent(canvas, &event); + + QCOMPARE(selectionStartSpy.count(), 8); + QCOMPARE(selectionEndSpy.count(), 6); + QCOMPARE(selectedTextSpy.count(), 8); + QCOMPARE(textInput->selectionStart(), textInput->cursorPosition()); + QCOMPARE(textInput->selectionEnd(), textInput->cursorPosition()); + QCOMPARE(textInput->selectedText(), QLatin1String("")); + QCOMPARE(textInput->cursorPosition(), 0); +} + QTEST_MAIN(tst_qdeclarativetextinput) #include "tst_qdeclarativetextinput.moc" diff --git a/tests/auto/qnetworkreply/.gitattributes b/tests/auto/qnetworkreply/.gitattributes index 80252cf..7fa30e3 100644 --- a/tests/auto/qnetworkreply/.gitattributes +++ b/tests/auto/qnetworkreply/.gitattributes @@ -1,3 +1,4 @@ rfc3252.txt -crlf bigfile -crlf resource -crlf +index.html -crlf diff --git a/tests/auto/qnetworkreply/index.html b/tests/auto/qnetworkreply/index.html new file mode 100644 index 0000000..135db79 --- /dev/null +++ b/tests/auto/qnetworkreply/index.html @@ -0,0 +1,3 @@ +<h1>Welcome to qt-test-server</h1> +<img src="gif/fluke.gif" alt="fluke"> +<p>This is a network test server. It serves as a cacheing ftp and http proxy, transparent http/socks5 proxy, imap, ftp and http server, plus more.</p> diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 70287a9..3d1e35e 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -197,6 +197,8 @@ private Q_SLOTS: void getFromHttp(); void getErrors_data(); void getErrors(); + void headFromHttp_data(); + void headFromHttp(); void putToFile_data(); void putToFile(); void putToFtp_data(); @@ -1610,6 +1612,65 @@ void tst_QNetworkReply::getFromHttp() QCOMPARE(reply->readAll(), reference.readAll()); } +void tst_QNetworkReply::headFromHttp_data() +{ + QTest::addColumn<qint64>("referenceSize"); + QTest::addColumn<QUrl>("url"); + QTest::addColumn<QString>("contentType"); + QTest::addColumn<QNetworkProxy>("proxy"); + + qint64 rfcsize = QFileInfo(SRCDIR "/rfc3252.txt").size(); + qint64 bigfilesize = QFileInfo(SRCDIR "/bigfile").size(); + qint64 indexsize = QFileInfo(SRCDIR "/index.html").size(); + + //testing proxies, mainly for the 407 response from http proxy + for (int i = 0; i < proxies.count(); ++i) { + QTest::newRow("rfc" + proxies.at(i).tag) << rfcsize << QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt") << "text/plain" << proxies.at(i).proxy; + QTest::newRow("bigfile" + proxies.at(i).tag) << bigfilesize << QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/bigfile") << "text/plain" << proxies.at(i).proxy; + QTest::newRow("index" + proxies.at(i).tag) << indexsize << QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/") << "text/html" << proxies.at(i).proxy; + QTest::newRow("with-authentication" + proxies.at(i).tag) << rfcsize << QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/rfcs-auth/rfc3252.txt") << "text/plain" << proxies.at(i).proxy; + QTest::newRow("cgi" + proxies.at(i).tag) << (qint64)-1 << QUrl("http://qt-test-server/qtest/cgi-bin/httpcachetest_expires500.cgi") << "text/html" << proxies.at(i).proxy; + } +} + +void tst_QNetworkReply::headFromHttp() +{ + QFETCH(qint64, referenceSize); + QFETCH(QUrl, url); + QFETCH(QString, contentType); + QFETCH(QNetworkProxy, proxy); + + QNetworkRequest request(url); + QNetworkReplyPtr reply; + + QElapsedTimer time; + time.start(); + + manager.setProxy(proxy); + connect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), + SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*))); + connect(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), + SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); + + RUN_REQUEST(runSimpleRequest(QNetworkAccessManager::HeadOperation, request, reply)); + + manager.disconnect(SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), + this, SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*))); + manager.disconnect(SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), + this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); + + QVERIFY(time.elapsed() < 8000); //check authentication didn't wait for the server to timeout the http connection (15s on qt test server) + + QCOMPARE(reply->url(), request.url()); + QCOMPARE(reply->error(), QNetworkReply::NoError); + QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); + // only compare when the header is set. + if (reply->header(QNetworkRequest::ContentLengthHeader).isValid() && referenceSize >= 0) + QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), referenceSize); + if (reply->header(QNetworkRequest::ContentTypeHeader).isValid()) + QCOMPARE(reply->header(QNetworkRequest::ContentTypeHeader).toString(), contentType); +} + void tst_QNetworkReply::getErrors_data() { QTest::addColumn<QString>("url"); diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index ee06b53..a881583 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -397,6 +397,9 @@ private slots: void minimizedWindowModeTransitions(); void normalWindowModeTransitions(); void focusSwitchClosesPopupMenu(); +#if !defined(Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE) + void opacityChangeCausesBackingStoreRecreation(); +#endif #endif void focusProxyAndInputMethods(); @@ -10334,7 +10337,47 @@ void tst_QWidget::focusSwitchClosesPopupMenu() mainWindow.activateWindow(); QVERIFY(!CEikonEnv::Static()->AppUiFactory()->MenuBar()->IsDisplayed()); } -#endif + +#if !defined(Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE) +class OpacityChangeWidget : public QWidget +{ +public: + OpacityChangeWidget() : m_paintEngineType(QPaintEngine::MaxUser) { } + void paintEvent(QPaintEvent *) + { + QPainter painter(this); + m_paintEngineType = painter.paintEngine()->type(); + } + QPaintEngine::Type paintEngineType() const { return m_paintEngineType; } +private: + QPaintEngine::Type m_paintEngineType; +}; + +void tst_QWidget::opacityChangeCausesBackingStoreRecreation() +{ + OpacityChangeWidget w; + w.show(); + QTest::qWaitForWindowShown(&w); + const QPaintEngine::Type type = w.paintEngineType(); + if (QPaintEngine::OpenGL != type && QPaintEngine::OpenVG != type) { + QSKIP("Test case is only valid when using opengl or openvg graphics system", SkipAll); + } else { + if (QApplicationPrivate::instance()->useTranslucentEGLSurfaces) { + QSKIP("Test case is only valid when EGL surface transparency is not supported", SkipAll); + } else { + // Making window transparent should force switch to raster graphics system + w.setAttribute(Qt::WA_TranslucentBackground, true); + w.repaint(); + QCOMPARE(w.paintEngineType(), QPaintEngine::Raster); + // Making window opaque should cause switch back to previous graphics system + w.setAttribute(Qt::WA_TranslucentBackground, false); + w.repaint(); + QCOMPARE(w.paintEngineType(), type); + } + } +} +#endif // !Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE +#endif // Q_OS_SYMBIAN class InputContextTester : public QInputContext { diff --git a/translations/qt_ko.ts b/translations/qt_ko.ts index c7ab8e3..b9e30f5 100644 --- a/translations/qt_ko.ts +++ b/translations/qt_ko.ts @@ -6328,11 +6328,11 @@ Do you want to overwrite it?</source> </message> <message> <source>Touroku</source> - <translation type="unfinished"></translation> + <translation>단어 등록</translation> </message> <message> <source>Massyo</source> - <translation type="unfinished"></translation> + <translation>단어 지움</translation> </message> <message> <source>Kana Lock</source> @@ -6344,11 +6344,11 @@ Do you want to overwrite it?</source> </message> <message> <source>Eisu Shift</source> - <translation type="unfinished"></translation> + <translation>한자 Shift</translation> </message> <message> <source>Eisu toggle</source> - <translation type="unfinished"></translation> + <translation>한자 반전</translation> </message> <message> <source>Code input</source> |