From a590f7941caeb4f5c687992ddbbc6f02733b12fc Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 3 May 2010 09:22:23 +0200 Subject: Updated WebKit to 8941bee5706ef2171ed5def63834deefc7440d11 Fixes integrated: || || [Qt] QWebPage::userAgentForUrl is terrible API || || || [Qt] GraphicsLayer: animation incorrect when scrolling || || || Make it possible to distinguish between NPAPI plugins and Application plugins || || || [Qt] QtWebKit 2.0 library version needs to be maintained in WebCore.pro || --- src/3rdparty/webkit/.tag | 2 +- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/ChangeLog | 22 ++ src/3rdparty/webkit/WebCore/WebCore.pro | 6 +- .../webkit/WebKit/qt/Api/qgraphicswebview.cpp | 1 + src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp | 348 +++++++++++---------- src/3rdparty/webkit/WebKit/qt/ChangeLog | 52 +++ src/3rdparty/webkit/WebKit/qt/qtwebkit_version.pri | 4 + .../WebKit/qt/tests/qwebpage/tst_qwebpage.cpp | 35 +++ 9 files changed, 304 insertions(+), 168 deletions(-) create mode 100644 src/3rdparty/webkit/WebKit/qt/qtwebkit_version.pri diff --git a/src/3rdparty/webkit/.tag b/src/3rdparty/webkit/.tag index c750e67..7c2b233 100644 --- a/src/3rdparty/webkit/.tag +++ b/src/3rdparty/webkit/.tag @@ -1 +1 @@ -8941bee5706ef2171ed5def63834deefc7440d11 +3f0f51f4c87e65bfe04165c6af4c00934b0ca1e2 diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 23cae67..ddaaf50 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -4,4 +4,4 @@ This is a snapshot of the Qt port of WebKit from and has the sha1 checksum - 540ae4ccd25609e1bfe1673195ce126255e36774 + 8941bee5706ef2171ed5def63834deefc7440d11 diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index b8825bd..22315fe 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,25 @@ +2010-05-03 Thomas Zander + + Reviewed by Simon Hausmann. + + [Qt] Fix library infix usage when compiling inside of Qt + + Don't apply the infix when building inside Qt, as that's done through the + inclusion of qbase.pri. + + * WebCore.pro: + +2010-04-29 Janne Koskinen + + Reviewed by Simon Hausmann. + + [Qt] QtWebKit versioning added + https://bugs.webkit.org/show_bug.cgi?id=37207 + + QtWebkit releases separated from Qt release cycle. + + * WebCore.pro: + 2010-03-27 Robert Hogan Reviewed by nobody, fix typo in previous commit. diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index 2a64982..626e050 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -69,13 +69,13 @@ CONFIG(standalone_package) { CONFIG(QTDIR_build) { include($$QT_SOURCE_TREE/src/qbase.pri) - # Qt will set the version for us when building in Qt's tree } else { - VERSION = $${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION} DESTDIR = $$OUTPUT_DIR/lib !static: DEFINES += QT_MAKEDLL - symbian: TARGET +=$${QT_LIBINFIX} + symbian: TARGET += $${QT_LIBINFIX} } +include($$PWD/../WebKit/qt/qtwebkit_version.pri) +VERSION = $${QT_WEBKIT_MAJOR_VERSION}.$${QT_WEBKIT_MINOR_VERSION}.$${QT_WEBKIT_PATCH_VERSION} unix { QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtNetwork diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp index 3c86770..1efae16 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp @@ -292,6 +292,7 @@ void QGraphicsWebViewPrivate::update(const QRect & dirtyRect) if (overlay) overlay->update(QRectF(dirtyRect)); #if USE(ACCELERATED_COMPOSITING) + updateCompositingScrollPosition(); syncLayers(); #endif } diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp index f28524a..b8b50b7 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp @@ -3191,233 +3191,255 @@ QWebPluginFactory *QWebPage::pluginFactory() const \o %AppVersion% expands to QCoreApplication::applicationName()/QCoreApplication::applicationVersion() if they're set; otherwise defaulting to Qt and the current Qt version. \endlist */ -QString QWebPage::userAgentForUrl(const QUrl& url) const +QString QWebPage::userAgentForUrl(const QUrl&) const { - Q_UNUSED(url) - QString ua = QLatin1String("Mozilla/5.0 (" + // splitting the string in three and user QStringBuilder is better than using QString::arg() + static QString firstPart; + static QString secondPart; + static QString thirdPart; + + if (firstPart.isNull() || secondPart.isNull() || thirdPart.isNull()) { + QString firstPartTemp; + firstPartTemp.reserve(150); + firstPartTemp += QString::fromLatin1("Mozilla/5.0 (" // Platform #ifdef Q_WS_MAC - "Macintosh" + "Macintosh" #elif defined Q_WS_QWS - "QtEmbedded" + "QtEmbedded" #elif defined Q_WS_WIN - "Windows" + "Windows" #elif defined Q_WS_X11 - "X11" + "X11" #elif defined Q_OS_SYMBIAN - "SymbianOS" + "SymbianOS" #else - "Unknown" + "Unknown" #endif - // Placeholder for Platform Version - "%1; " + ); + + firstPartTemp += QString::fromLatin1("; "); - // Placeholder for security strength (N or U) - "%2; " + // SSL support +#if !defined(QT_NO_OPENSSL) + // we could check QSslSocket::supportsSsl() here, but this makes + // OpenSSL, certificates etc being loaded in all cases were QWebPage + // is used. This loading is not needed for non-https. + firstPartTemp += QString::fromLatin1("U; "); + // this may lead to a false positive: We indicate SSL since it is + // compiled in even though supportsSsl() might return false +#else + firstPartTemp += QString::fromLatin1("N; "); +#endif - // Subplatform" + // Operating system #ifdef Q_OS_AIX - "AIX" + firstPartTemp += QString::fromLatin1("AIX"); #elif defined Q_OS_WIN32 - "%3" + + switch (QSysInfo::WindowsVersion) { + case QSysInfo::WV_32s: + firstPartTemp += QString::fromLatin1("Windows 3.1"); + break; + case QSysInfo::WV_95: + firstPartTemp += QString::fromLatin1("Windows 95"); + break; + case QSysInfo::WV_98: + firstPartTemp += QString::fromLatin1("Windows 98"); + break; + case QSysInfo::WV_Me: + firstPartTemp += QString::fromLatin1("Windows 98; Win 9x 4.90"); + break; + case QSysInfo::WV_NT: + firstPartTemp += QString::fromLatin1("WinNT4.0"); + break; + case QSysInfo::WV_2000: + firstPartTemp += QString::fromLatin1("Windows NT 5.0"); + break; + case QSysInfo::WV_XP: + firstPartTemp += QString::fromLatin1("Windows NT 5.1"); + break; + case QSysInfo::WV_2003: + firstPartTemp += QString::fromLatin1("Windows NT 5.2"); + break; + case QSysInfo::WV_VISTA: + firstPartTemp += QString::fromLatin1("Windows NT 6.0"); + break; + case QSysInfo::WV_WINDOWS7: + firstPartTemp += QString::fromLatin1("Windows NT 6.1"); + break; + case QSysInfo::WV_CE: + firstPartTemp += QString::fromLatin1("Windows CE"); + break; + case QSysInfo::WV_CENET: + firstPartTemp += QString::fromLatin1("Windows CE .NET"); + break; + case QSysInfo::WV_CE_5: + firstPartTemp += QString::fromLatin1("Windows CE 5.x"); + break; + case QSysInfo::WV_CE_6: + firstPartTemp += QString::fromLatin1("Windows CE 6.x"); + break; + } + #elif defined Q_OS_DARWIN #ifdef __i386__ || __x86_64__ - "Intel Mac OS X" + firstPartTemp += QString::fromLatin1("Intel Mac OS X"); #else - "PPC Mac OS X" + firstPartTemp += QString::fromLatin1("PPC Mac OS X"); #endif #elif defined Q_OS_BSDI - "BSD" + firstPartTemp += QString::fromLatin1("BSD"); #elif defined Q_OS_BSD4 - "BSD Four" + firstPartTemp += QString::fromLatin1("BSD Four"); #elif defined Q_OS_CYGWIN - "Cygwin" + firstPartTemp += QString::fromLatin1("Cygwin"); #elif defined Q_OS_DGUX - "DG/UX" + firstPartTemp += QString::fromLatin1("DG/UX"); #elif defined Q_OS_DYNIX - "DYNIX/ptx" + firstPartTemp += QString::fromLatin1("DYNIX/ptx"); #elif defined Q_OS_FREEBSD - "FreeBSD" + firstPartTemp += QString::fromLatin1("FreeBSD"); #elif defined Q_OS_HPUX - "HP-UX" + firstPartTemp += QString::fromLatin1("HP-UX"); #elif defined Q_OS_HURD - "GNU Hurd" + firstPartTemp += QString::fromLatin1("GNU Hurd"); #elif defined Q_OS_IRIX - "SGI Irix" + firstPartTemp += QString::fromLatin1("SGI Irix"); #elif defined Q_OS_LINUX - "Linux" + +#if defined(__x86_64__) + firstPartTemp += QString::fromLatin1("Linux x86_64"); +#elif defined(__i386__) + firstPartTemp += QString::fromLatin1("Linux i686"); +#else + firstPartTemp += QString::fromLatin1("Linux"); +#endif + #elif defined Q_OS_LYNX - "LynxOS" + firstPartTemp += QString::fromLatin1("LynxOS"); #elif defined Q_OS_NETBSD - "NetBSD" + firstPartTemp += QString::fromLatin1("NetBSD"); #elif defined Q_OS_OS2 - "OS/2" + firstPartTemp += QString::fromLatin1("OS/2"); #elif defined Q_OS_OPENBSD - "OpenBSD" + firstPartTemp += QString::fromLatin1("OpenBSD"); #elif defined Q_OS_OS2EMX - "OS/2" + firstPartTemp += QString::fromLatin1("OS/2"); #elif defined Q_OS_OSF - "HP Tru64 UNIX" + firstPartTemp += QString::fromLatin1("HP Tru64 UNIX"); #elif defined Q_OS_QNX6 - "QNX RTP Six" + firstPartTemp += QString::fromLatin1("QNX RTP Six"); #elif defined Q_OS_QNX - "QNX" + firstPartTemp += QString::fromLatin1("QNX"); #elif defined Q_OS_RELIANT - "Reliant UNIX" + firstPartTemp += QString::fromLatin1("Reliant UNIX"); #elif defined Q_OS_SCO - "SCO OpenServer" + firstPartTemp += QString::fromLatin1("SCO OpenServer"); #elif defined Q_OS_SOLARIS - "Sun Solaris" + firstPartTemp += QString::fromLatin1("Sun Solaris"); #elif defined Q_OS_ULTRIX - "DEC Ultrix" -#elif defined Q_WS_S60 - "Series60" -#elif defined Q_OS_UNIX - "UNIX BSD/SYSV system" -#elif defined Q_OS_UNIXWARE - "UnixWare Seven, Open UNIX Eight" -#else - "Unknown" -#endif - // Placeholder for SubPlatform Version - "%4; "); - - // Platform Version - QString osVer; -#ifdef Q_OS_SYMBIAN - QSysInfo::SymbianVersion symbianVersion = QSysInfo::symbianVersion(); - switch (symbianVersion) { - case QSysInfo::SV_9_2: - osVer = "/9.2"; - break; - case QSysInfo::SV_9_3: - osVer = "/9.3"; - break; - case QSysInfo::SV_9_4: - osVer = "/9.4"; - break; - default: - osVer = "Unknown"; - } -#endif - ua = ua.arg(osVer); - - QChar securityStrength(QLatin1Char('N')); -#if !defined(QT_NO_OPENSSL) - // we could check QSslSocket::supportsSsl() here, but this makes - // OpenSSL, certificates etc being loaded in all cases were QWebPage - // is used. This loading is not needed for non-https. - securityStrength = QLatin1Char('U'); - // this may lead to a false positive: We indicate SSL since it is - // compiled in even though supportsSsl() might return false -#endif - ua = ua.arg(securityStrength); - -#if defined Q_OS_WIN32 - QString ver; - switch (QSysInfo::WindowsVersion) { - case QSysInfo::WV_32s: - ver = "Windows 3.1"; - break; - case QSysInfo::WV_95: - ver = "Windows 95"; - break; - case QSysInfo::WV_98: - ver = "Windows 98"; - break; - case QSysInfo::WV_Me: - ver = "Windows 98; Win 9x 4.90"; - break; - case QSysInfo::WV_NT: - ver = "WinNT4.0"; + firstPartTemp += QString::fromLatin1("DEC Ultrix"); +#elif defined Q_OS_SYMBIAN + firstPartTemp += QString::fromLatin1("SymbianOS"); + QSysInfo::SymbianVersion symbianVersion = QSysInfo::symbianVersion(); + switch (symbianVersion) { + case QSysInfo::SV_9_2: + firstPartTemp += QString::fromLatin1("/9.2"); break; - case QSysInfo::WV_2000: - ver = "Windows NT 5.0"; + case QSysInfo::SV_9_3: + firstPartTemp += QString::fromLatin1("/9.3"); break; - case QSysInfo::WV_XP: - ver = "Windows NT 5.1"; + case QSysInfo::SV_9_4: + firstPartTemp += QString::fromLatin1("/9.4"); break; - case QSysInfo::WV_2003: - ver = "Windows NT 5.2"; + default: + firstPartTemp += QString::fromLatin1("/Unknown"); + } + +#if defined Q_WS_S60 + firstPartTemp += QLatin1Char(' '); + firstPartTemp += QString::fromLatin1("Series60"); + QSysInfo::S60Version s60Version = QSysInfo::s60Version(); + switch (s60Version) { + case QSysInfo::SV_S60_3_1: + firstPartTemp += QString::fromLatin1("/3.1"); break; - case QSysInfo::WV_VISTA: - ver = "Windows NT 6.0"; + case QSysInfo::SV_S60_3_2: + firstPartTemp += QString::fromLatin1("/3.2"); break; -#if QT_VERSION > 0x040500 - case QSysInfo::WV_WINDOWS7: - ver = "Windows NT 6.1"; + case QSysInfo::SV_S60_5_0: + firstPartTemp += QString::fromLatin1("/5.0"); break; + default: + firstPartTemp += QString::fromLatin1("/Unknown"); + } #endif - case QSysInfo::WV_CE: - ver = "Windows CE"; - break; - case QSysInfo::WV_CENET: - ver = "Windows CE .NET"; - break; - case QSysInfo::WV_CE_5: - ver = "Windows CE 5.x"; - break; - case QSysInfo::WV_CE_6: - ver = "Windows CE 6.x"; - break; - } - ua = QString(ua).arg(ver); + +#elif defined Q_OS_UNIX + firstPartTemp += QString::fromLatin1("UNIX BSD/SYSV system"); +#elif defined Q_OS_UNIXWARE + firstPartTemp += QString::fromLatin1("UnixWare Seven, Open UNIX Eight"); +#else + firstPartTemp += QString::fromLatin1("Unknown"); #endif - // SubPlatform Version - QString subPlatformVer; -#ifdef Q_OS_SYMBIAN - QSysInfo::S60Version s60Version = QSysInfo::s60Version(); - switch (s60Version) { - case QSysInfo::SV_S60_3_1: - subPlatformVer = "/3.1"; - break; - case QSysInfo::SV_S60_3_2: - subPlatformVer = "/3.2"; - break; - case QSysInfo::SV_S60_5_0: - subPlatformVer = "/5.0"; - break; - default: - subPlatformVer = " Unknown"; - } + // language is the split + firstPartTemp += QString::fromLatin1("; "); + firstPartTemp.squeeze(); + firstPart = firstPartTemp; + + QString secondPartTemp; + secondPartTemp.reserve(150); + secondPartTemp += QString::fromLatin1(") "); + + // webkit/qt version + secondPartTemp += QString::fromLatin1("AppleWebKit/"); + secondPartTemp += qWebKitVersion(); + secondPartTemp += QString::fromLatin1(" (KHTML, like Gecko) "); + + + // Application name split the third part + secondPartTemp.squeeze(); + secondPart = secondPartTemp; + + QString thirdPartTemp; + thirdPartTemp.reserve(150); +#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) + thirdPartTemp + QLatin1String(" Mobile Safari/"); +#else + thirdPartTemp += QLatin1String(" Safari/"); #endif - ua = ua.arg(subPlatformVer); + thirdPartTemp += qWebKitVersion(); + thirdPartTemp.squeeze(); + thirdPart = thirdPartTemp; + Q_ASSERT(!firstPart.isNull()); + Q_ASSERT(!secondPart.isNull()); + Q_ASSERT(!thirdPart.isNull()); + } // Language - QLocale locale; + QString languageName; if (d->client && d->client->ownerWidget()) - locale = d->client->ownerWidget()->locale(); - QString name = locale.name(); - name[2] = QLatin1Char('-'); - ua.append(name); - ua.append(QLatin1String(") ")); - - // webkit/qt version - ua.append(QString(QLatin1String("AppleWebKit/%1 (KHTML, like Gecko) ")) - .arg(QString(qWebKitVersion()))); + languageName = d->client->ownerWidget()->locale().name(); + else + languageName = QLocale().name(); + languageName[2] = QLatin1Char('-'); // Application name/version QString appName = QCoreApplication::applicationName(); if (!appName.isEmpty()) { - ua.append(appName); QString appVer = QCoreApplication::applicationVersion(); if (!appVer.isEmpty()) - ua.append(QLatin1Char('/') + appVer); + appName.append(QLatin1Char('/') + appVer); } else { // Qt version - ua.append(QLatin1String("Qt/")); - ua.append(QLatin1String(qVersion())); + appName = QString::fromLatin1("Qt/") + QString::fromLatin1(qVersion()); } -#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) - ua.append(QString(QLatin1String(" Mobile Safari/%1")).arg(qWebKitVersion())); -#else - ua.append(QString(QLatin1String(" Safari/%1")).arg(qWebKitVersion())); -#endif - return ua; + return firstPart + languageName + secondPart + appName + thirdPart; } diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index 8594f09..6e450c2 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,55 @@ +2010-04-29 Janne Koskinen + + Reviewed by Simon Hausmann. + + [Qt] QtWebKit versioning added + https://bugs.webkit.org/show_bug.cgi?id=37207 + + QtWebkit releases separated from Qt release cycle. + + * qtwebkit_version.pri: Added. + +2010-05-02 Benjamin Poulain + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] QWebPage::userAgentForUrl is terrible API + https://bugs.webkit.org/show_bug.cgi?id=33875 + + Simplify the creation of the user agent string to avoid some + overhead for each loaded url. + + The static part of the user agent is cached so it only have + to be made once. + This creation has been made in order to simplify the code. + + The two variable: application name and current language are + set dynamically when needed. + The default locale is non longer created if the widget locale + is used. + + * Api/qwebpage.cpp: + (QWebPage::userAgentForUrl): + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::userAgentApplicationName): + (tst_QWebPage::userAgentLocaleChange): + +2010-05-02 Noam Rosenthal + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] GraphicsLayer: animation incorrect when scrolling + https://bugs.webkit.org/show_bug.cgi?id=38371 + + This is a regression introduced with the invalidate-on-scroll code path, that uses QGraphicsWebViewPrivate::update() + instead of QGraphicsWebViewPrivate::scroll(). The patch makes sure that the scrolling position is correct on + each content update - this shouldn't have a performance impact - the only overhead is an additional value-test on each update. + + Tested by http://www.the-art-of-web.com/css/css-animation/ + + * Api/qgraphicswebview.cpp: + (QGraphicsWebViewPrivate::update): + 2010-04-29 Andreas Kling Reviewed by Simon Hausmann. diff --git a/src/3rdparty/webkit/WebKit/qt/qtwebkit_version.pri b/src/3rdparty/webkit/WebKit/qt/qtwebkit_version.pri new file mode 100644 index 0000000..ffd192c --- /dev/null +++ b/src/3rdparty/webkit/WebKit/qt/qtwebkit_version.pri @@ -0,0 +1,4 @@ +QT_WEBKIT_VERSION = 4.7.0 +QT_WEBKIT_MAJOR_VERSION = 4 +QT_WEBKIT_MINOR_VERSION = 7 +QT_WEBKIT_PATCH_VERSION = 0 diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp index 85d4b60..f7eddd5 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -106,6 +107,8 @@ private slots: void errorPageExtension(); void errorPageExtensionInIFrames(); void errorPageExtensionInFrameset(); + void userAgentApplicationName(); + void userAgentLocaleChange(); void crashTests_LazyInitializationOfMainFrame(); @@ -1748,6 +1751,38 @@ void tst_QWebPage::errorPageExtensionInFrameset() m_view->setPage(0); } +class FriendlyWebPage : public QWebPage +{ +public: + friend class tst_QWebPage; +}; + +void tst_QWebPage::userAgentApplicationName() +{ + const QString oldApplicationName = QCoreApplication::applicationName(); + FriendlyWebPage page; + + const QString applicationNameMarker = QString::fromUtf8("StrangeName\342\210\236"); + QCoreApplication::setApplicationName(applicationNameMarker); + QVERIFY(page.userAgentForUrl(QUrl()).contains(applicationNameMarker)); + + QCoreApplication::setApplicationName(oldApplicationName); +} + +void tst_QWebPage::userAgentLocaleChange() +{ + FriendlyWebPage page; + m_view->setPage(&page); + + const QString markerString = QString::fromLatin1(" nn-NO)"); + + if (page.userAgentForUrl(QUrl()).contains(markerString)) + QSKIP("marker string already present", SkipSingle); + + m_view->setLocale(QLocale(QString::fromLatin1("nn_NO"))); + QVERIFY(page.userAgentForUrl(QUrl()).contains(markerString)); +} + void tst_QWebPage::crashTests_LazyInitializationOfMainFrame() { { -- cgit v0.12 From a2ed290c33f7c087b71a4da53a4baa891f35751a Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 3 May 2010 16:21:20 +0200 Subject: Updated WebKit to 3f0f51f4c87e65bfe04165c6af4c00934b0ca1e2 * Integrated http://trac.webkit.org/changeset/58673 -- Fix qtlibraryinfix not to contain space --- src/3rdparty/webkit/.tag | 2 +- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/ChangeLog | 11 +++++++++++ src/3rdparty/webkit/WebCore/WebCore.pro | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/3rdparty/webkit/.tag b/src/3rdparty/webkit/.tag index 7c2b233..b6feeb1 100644 --- a/src/3rdparty/webkit/.tag +++ b/src/3rdparty/webkit/.tag @@ -1 +1 @@ -3f0f51f4c87e65bfe04165c6af4c00934b0ca1e2 +992e57ee469bd8c6a2afef6b15896a161ab8aeb3 diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index ddaaf50..c3d6314 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -4,4 +4,4 @@ This is a snapshot of the Qt port of WebKit from and has the sha1 checksum - 8941bee5706ef2171ed5def63834deefc7440d11 + 3f0f51f4c87e65bfe04165c6af4c00934b0ca1e2 diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index 22315fe..05fc2af 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,14 @@ +2010-05-03 Janne Koskinen + + Reviewed by Simon Hausmann. + + [Qt] Fix qtlibraryinfix not to contain space + + List catenation with += adds whitespace cutting the infix + from the final target. + + * WebCore.pro: + 2010-05-03 Thomas Zander Reviewed by Simon Hausmann. diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index 626e050..3d57562 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -72,7 +72,7 @@ CONFIG(QTDIR_build) { } else { DESTDIR = $$OUTPUT_DIR/lib !static: DEFINES += QT_MAKEDLL - symbian: TARGET += $${QT_LIBINFIX} + symbian: TARGET =$$TARGET$${QT_LIBINFIX} } include($$PWD/../WebKit/qt/qtwebkit_version.pri) VERSION = $${QT_WEBKIT_MAJOR_VERSION}.$${QT_WEBKIT_MINOR_VERSION}.$${QT_WEBKIT_PATCH_VERSION} -- cgit v0.12 From 56dcdada14f1a499da5a458bdada2127e73dc630 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Tue, 4 May 2010 11:13:24 +1000 Subject: Doc improvements --- doc/src/declarative/dynamicobjects.qdoc | 48 ++++++++------------- doc/src/snippets/declarative/dynamicObjects.qml | 30 +++++++++++++ .../snippets/declarative/flickableScrollbar.qml | 26 +++++++++++ .../graphicsitems/qdeclarativeflickable.cpp | 50 ++++++++++++---------- 4 files changed, 102 insertions(+), 52 deletions(-) create mode 100644 doc/src/snippets/declarative/dynamicObjects.qml create mode 100644 doc/src/snippets/declarative/flickableScrollbar.qml diff --git a/doc/src/declarative/dynamicobjects.qdoc b/doc/src/declarative/dynamicobjects.qdoc index 5cdd768..dc0277d 100644 --- a/doc/src/declarative/dynamicobjects.qdoc +++ b/doc/src/declarative/dynamicobjects.qdoc @@ -132,36 +132,24 @@ do not have an id in QML. \section1 Deleting Objects Dynamically -You should generally avoid dynamically deleting objects that you did not -dynamically create. In many UIs, it is sufficient to set the opacity to 0 or -to move the item off of the edge of the screen. If you have lots of dynamically -created items however, deleting them when they are no longer used will provide -a worthwhile performance benefit. Note that you should never manually delete -items which were dynamically created by QML Elements such as \l{Loader}. - -To manually delete a QML item, call its destroy method. This method has one -argument, which is an approximate delay in milliseconds and which defaults to zero. This -allows you to wait until the completion of an animation or transition. An example: - -\code - Component { - id: fadesOut - Rectangle{ - id: rect - width: 40; height: 40; - NumberAnimation on opacity { from:1; to:0; duration: 1000 } - Component.onCompleted: rect.destroy(1000); - } - } - function createFadesOut(parentItem) - { - var object = fadesOut.createObject(); - object.parent = parentItem; - } -\endcode - -In the above example, the dynamically created rectangle calls destroy as soon as it is created, - but delays long enough for its fade out animation to be played. +In many user interfaces, it is sufficient to set an item's opacity to 0 or +to move the item off the screen instead of deleting the item. If you have +lots of dynamically created items, however, you may receive a worthwhile +performance benefit if unused items are deleted. + +Note that you should never manually delete items that were dynamically created +by QML elements (such as \l Loader). Also, you should generally avoid deleting +items that you did not dynamically create yourself. + +Items can be deleted using the \c destroy() method. This method has an optional +argument (which defaults to 0) that specifies the approximate delay in milliseconds +before the object is to be destroyed. This allows you to wait until the completion of +an animation or transition. An example: + +\snippet doc/src/snippets/declarative/dynamicObjects.qml 0 + +Here, \c Rectangle objects are destroyed one second after they are created, which is long +enough for the \c NumberAnimation to be played before the object is destroyed. */ diff --git a/doc/src/snippets/declarative/dynamicObjects.qml b/doc/src/snippets/declarative/dynamicObjects.qml new file mode 100644 index 0000000..dd55d78 --- /dev/null +++ b/doc/src/snippets/declarative/dynamicObjects.qml @@ -0,0 +1,30 @@ +import Qt 4.7 + +//![0] +Rectangle { + id: rootItem + width: 300 + height: 300 + + Component { + id: rectComponent + + Rectangle { + id: rect + width: 40; height: 40; + color: "red" + + NumberAnimation on opacity { from: 1; to: 0; duration: 1000 } + + Component.onCompleted: rect.destroy(1000); + } + } + + function createRectangle() { + var object = rectComponent.createObject(); + object.parent = rootItem; + } + + Component.onCompleted: createRectangle() +} +//![0] diff --git a/doc/src/snippets/declarative/flickableScrollbar.qml b/doc/src/snippets/declarative/flickableScrollbar.qml new file mode 100644 index 0000000..147751a --- /dev/null +++ b/doc/src/snippets/declarative/flickableScrollbar.qml @@ -0,0 +1,26 @@ +import Qt 4.7 + +//![0] +Rectangle { + width: 200; height: 200 + + Flickable { + id: flickable +//![0] + anchors.fill: parent + contentWidth: image.width; contentHeight: image.height + + Image { id: image; source: "pics/qt.png" } +//![1] + } + + Rectangle { + id: scrollbar + anchors.right: flickable.right + y: flickable.visibleArea.yPosition * flickable.height + width: 10 + height: flickable.visibleArea.heightRatio * flickable.height + color: "black" + } +} +//![1] diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index b462443..35aa0f8 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -345,19 +345,21 @@ void QDeclarativeFlickablePrivate::updateBeginningEnd() \code Flickable { - width: 200; height: 200; contentWidth: image.width; contentHeight: image.height - Image { id: image; source: "bigimage.png" } + width: 200; height: 200 + contentWidth: image.width; contentHeight: image.height + + Image { id: image; source: "bigImage.png" } } \endcode \image flickable.gif - \note Flickable does not automatically clip its contents. If - it is not full-screen it is likely that \c clip should be set - to true. + Flickable does not automatically clip its contents. If + it is not full-screen it is likely that \l {Item::clip}{clip} should be set + to \c true. - \note Due to an implementation detail items placed inside a flickable cannot anchor to it by - id, use 'parent' instead. + \note Due to an implementation detail, items placed inside a Flickable cannot anchor to it by + \c id. Use \c parent instead. */ /*! @@ -400,18 +402,17 @@ void QDeclarativeFlickablePrivate::updateBeginningEnd() These properties describe the position and size of the currently viewed area. The size is defined as the percentage of the full view currently visible, scaled to 0.0 - 1.0. The page position is usually in the range 0.0 (beginning) to - 1.0 minus size ratio (end), i.e. yPosition is in the range 0.0 to 1.0-heightRatio. + 1.0 minus size ratio (end), i.e. \c yPosition is in the range 0.0 to 1.0-\c heightRatio. However, it is possible for the contents to be dragged outside of the normal range, resulting in the page positions also being outside the normal range. - These properties are typically used to draw a scrollbar, for example: - \code - Rectangle { - opacity: 0.5; anchors.right: MyListView.right-2; width: 6 - y: MyListView.visibleArea.yPosition * MyListView.height - height: MyListView.visibleArea.heightRatio * MyListView.height - } - \endcode + These properties are typically used to draw a scrollbar. For example: + + \snippet doc/src/snippets/declarative/flickableScrollbar.qml 0 + \dots 4 + \snippet doc/src/snippets/declarative/flickableScrollbar.qml 1 + + \sa {declarative/scrollbar}{scrollbar example} */ QDeclarativeFlickable::QDeclarativeFlickable(QDeclarativeItem *parent) @@ -479,11 +480,12 @@ void QDeclarativeFlickable::setContentY(qreal pos) /*! \qmlproperty bool Flickable::interactive - A user cannot drag or flick a Flickable that is not interactive. + This property holds whether the user can interact with the Flickable. A user + cannot drag or flick a Flickable that is not interactive. This property is useful for temporarily disabling flicking. This allows special interaction with Flickable's children: for example, you might want to - freeze a flickable map while viewing detailed information on a location popup that is a child of the Flickable. + freeze a flickable map while scrolling through a pop-up dialog that is a child of the Flickable. */ bool QDeclarativeFlickable::isInteractive() const { @@ -1026,7 +1028,7 @@ void QDeclarativeFlickable::setOverShoot(bool o) This enables the feeling that the edges of the view are soft, rather than a hard physical boundary. - boundsBehavior can be one of: + The \c boundsBehavior can be one of: \list \o \e StopAtBounds - the contents can not be dragged beyond the boundary @@ -1059,12 +1061,16 @@ void QDeclarativeFlickable::setBoundsBehavior(BoundsBehavior b) \qmlproperty int Flickable::contentHeight The dimensions of the content (the surface controlled by Flickable). Typically this - should be set to the combined size of the items placed in the Flickable. + should be set to the combined size of the items placed in the Flickable. Note this + can be set automatically using \l {Item::childrenRect.width}{childrenRect.width} + and \l {Item::childrenRect.height}{childrenRect.height}. For example: \code Flickable { - width: 320; height: 480; contentWidth: image.width; contentHeight: image.height - Image { id: image; source: "bigimage.png" } + width: 320; height: 480 + contentWidth: childrenRect.width; contentHeight: childrenRect.height + + Image { id: image; source: "bigImage.png" } } \endcode */ -- cgit v0.12 From b5957435b36500e92d7ae9a6d01e9cdffa657275 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 4 May 2010 11:55:26 +1000 Subject: Remove obsolete doc groupings. --- .../graphicsitems/qdeclarativeanchors.cpp | 1 - .../graphicsitems/qdeclarativeflipable.cpp | 2 -- .../graphicsitems/qdeclarativeimage.cpp | 2 -- src/declarative/graphicsitems/qdeclarativeitem.cpp | 39 ---------------------- .../graphicsitems/qdeclarativemousearea.cpp | 2 -- src/declarative/graphicsitems/qdeclarativepath.cpp | 7 ---- .../graphicsitems/qdeclarativepositioners.cpp | 5 --- src/declarative/graphicsitems/qdeclarativetext.cpp | 1 - .../graphicsitems/qdeclarativetextedit.cpp | 1 - src/declarative/util/qdeclarativebind.cpp | 1 - src/declarative/util/qdeclarativefontloader.cpp | 1 - src/declarative/util/qdeclarativestate.cpp | 1 - src/declarative/util/qdeclarativesystempalette.cpp | 1 - src/declarative/util/qdeclarativetimeline.cpp | 2 -- src/declarative/util/qdeclarativetransition.cpp | 4 +-- 15 files changed, 1 insertion(+), 69 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeanchors.cpp b/src/declarative/graphicsitems/qdeclarativeanchors.cpp index f15316b..ef07cbb 100644 --- a/src/declarative/graphicsitems/qdeclarativeanchors.cpp +++ b/src/declarative/graphicsitems/qdeclarativeanchors.cpp @@ -128,7 +128,6 @@ static qreal adjustedPosition(QGraphicsObject *item, QDeclarativeAnchorLine::Anc \internal \class QDeclarativeAnchors \since 4.7 - \ingroup group_layouts \brief The QDeclarativeAnchors class provides a way to lay out items relative to other items. \warning Currently, only anchoring to siblings or parent is supported. diff --git a/src/declarative/graphicsitems/qdeclarativeflipable.cpp b/src/declarative/graphicsitems/qdeclarativeflipable.cpp index 57045f1..85f40c3 100644 --- a/src/declarative/graphicsitems/qdeclarativeflipable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflipable.cpp @@ -94,8 +94,6 @@ public: \class QDeclarativeFlipable \brief The Flipable item provides a surface that can be flipped. - \ingroup group_widgets - Flipable is an item that can be visibly "flipped" between its front and back sides. */ diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp index 3937778..1c32b45 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp @@ -134,8 +134,6 @@ QT_BEGIN_NAMESPACE \class QDeclarativeImage Image \brief The QDeclarativeImage class provides an image item that you can add to a QDeclarativeView. - \ingroup group_coreitems - Example: \qml Image { source: "pics/star.png" } diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index dc34725..e5faa42 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -219,46 +219,9 @@ QT_BEGIN_NAMESPACE The angle to rotate, in degrees clockwise. */ - -/*! - \group group_animation - \title Animation -*/ - -/*! - \group group_coreitems - \title Basic Items -*/ - -/*! - \group group_layouts - \title Layouts -*/ - -/*! - \group group_states - \title States and Transitions -*/ - -/*! - \group group_utility - \title Utility -*/ - -/*! - \group group_views - \title Views -*/ - -/*! - \group group_widgets - \title Widgets -*/ - /*! \internal \class QDeclarativeContents - \ingroup group_utility \brief The QDeclarativeContents class gives access to the height and width of an item's contents. */ @@ -1258,8 +1221,6 @@ QDeclarativeKeysAttached *QDeclarativeKeysAttached::qmlAttachedProperties(QObjec changes. For many properties in Item or Item derivatives this can be used to add a touch of imperative logic to your application (when absolutely necessary). - - \ingroup group_coreitems */ /*! diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp index c7b209a..d178107 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp +++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp @@ -292,8 +292,6 @@ QDeclarativeMouseAreaPrivate::~QDeclarativeMouseAreaPrivate() \class QDeclarativeMouseArea \brief The QDeclarativeMouseArea class provides a simple mouse handling abstraction for use within Qml. - \ingroup group_coreitems - All QDeclarativeItem derived classes can do mouse handling but the QDeclarativeMouseArea class exposes mouse handling data as properties and tracks flicking and dragging of the mouse. diff --git a/src/declarative/graphicsitems/qdeclarativepath.cpp b/src/declarative/graphicsitems/qdeclarativepath.cpp index e867a52..4d8b619 100644 --- a/src/declarative/graphicsitems/qdeclarativepath.cpp +++ b/src/declarative/graphicsitems/qdeclarativepath.cpp @@ -63,7 +63,6 @@ QT_BEGIN_NAMESPACE /*! \internal \class QDeclarativePathElement - \ingroup group_utility */ /*! @@ -86,7 +85,6 @@ QT_BEGIN_NAMESPACE /*! \internal \class QDeclarativePath - \ingroup group_utility \brief The QDeclarativePath class defines a path. \sa QDeclarativePathView */ @@ -513,7 +511,6 @@ void QDeclarativeCurve::setY(qreal y) /*! \internal \class QDeclarativePathAttribute - \ingroup group_utility \brief The QDeclarativePathAttribute class allows to set the value of an attribute at a given position in the path. \sa QDeclarativePath @@ -586,7 +583,6 @@ void QDeclarativePathAttribute::setValue(qreal value) /*! \internal \class QDeclarativePathLine - \ingroup group_utility \brief The QDeclarativePathLine class defines a straight line. \sa QDeclarativePath @@ -630,7 +626,6 @@ void QDeclarativePathLine::addToPath(QPainterPath &path) /*! \internal \class QDeclarativePathQuad - \ingroup group_utility \brief The QDeclarativePathQuad class defines a quadratic Bezier curve with a control point. \sa QDeclarativePath @@ -718,7 +713,6 @@ void QDeclarativePathQuad::addToPath(QPainterPath &path) /*! \internal \class QDeclarativePathCubic - \ingroup group_utility \brief The QDeclarativePathCubic class defines a cubic Bezier curve with two control points. \sa QDeclarativePath @@ -844,7 +838,6 @@ void QDeclarativePathCubic::addToPath(QPainterPath &path) /*! \internal \class QDeclarativePathPercent - \ingroup group_utility \brief The QDeclarativePathPercent class manipulates the way a path is interpreted. QDeclarativePathPercent allows you to bunch up items (or spread out items) along various diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp index c1ef04d..7e4549f 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp +++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp @@ -76,7 +76,6 @@ void QDeclarativeBasePositionerPrivate::unwatchChanges(QDeclarativeItem* other) /*! \internal \class QDeclarativeBasePositioner - \ingroup group_layouts \brief The QDeclarativeBasePositioner class provides a base for QDeclarativeGraphics layouts. To create a QDeclarativeGraphics Positioner, simply subclass QDeclarativeBasePositioner and implement @@ -404,7 +403,6 @@ Column { \internal \class QDeclarativeColumn \brief The QDeclarativeColumn class lines up items vertically. - \ingroup group_positioners */ QDeclarativeColumn::QDeclarativeColumn(QDeclarativeItem *parent) : QDeclarativeBasePositioner(Vertical, parent) @@ -547,7 +545,6 @@ Row { \internal \class QDeclarativeRow \brief The QDeclarativeRow class lines up items horizontally. - \ingroup group_positioners */ QDeclarativeRow::QDeclarativeRow(QDeclarativeItem *parent) : QDeclarativeBasePositioner(Horizontal, parent) @@ -698,8 +695,6 @@ Grid { \internal \class QDeclarativeGrid \brief The QDeclarativeGrid class lays out items in a grid. - \ingroup group_layouts - */ QDeclarativeGrid::QDeclarativeGrid(QDeclarativeItem *parent) : QDeclarativeBasePositioner(Both, parent), m_rows(-1), m_columns(-1), m_flow(LeftToRight) diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index 37a63eb..eeff0c3 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -142,7 +142,6 @@ QSet QTextDocumentWithImageResources::errors; \internal \class QDeclarativeText \qmlclass Text - \ingroup group_coreitems \brief The QDeclarativeText class provides a formatted text item that you can add to a QDeclarativeView. diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 31ed418..762640c 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -85,7 +85,6 @@ TextEdit { \internal \class QDeclarativeTextEdit \qmlclass TextEdit - \ingroup group_coreitems \brief The QDeclarativeTextEdit class provides an editable formatted text item that you can add to a QDeclarativeView. diff --git a/src/declarative/util/qdeclarativebind.cpp b/src/declarative/util/qdeclarativebind.cpp index 1f528e8..5fab631 100644 --- a/src/declarative/util/qdeclarativebind.cpp +++ b/src/declarative/util/qdeclarativebind.cpp @@ -98,7 +98,6 @@ public: /*! \internal \class QDeclarativeBind - \ingroup group_utility \brief The QDeclarativeBind class allows arbitrary property bindings to be created. Simple bindings are usually earier to do in-place rather than creating a diff --git a/src/declarative/util/qdeclarativefontloader.cpp b/src/declarative/util/qdeclarativefontloader.cpp index 4115193..f98ce8b 100644 --- a/src/declarative/util/qdeclarativefontloader.cpp +++ b/src/declarative/util/qdeclarativefontloader.cpp @@ -78,7 +78,6 @@ public: /*! \qmlclass FontLoader QDeclarativeFontLoader \since 4.7 - \ingroup group_utility \brief This item allows using fonts by name or url. Example: diff --git a/src/declarative/util/qdeclarativestate.cpp b/src/declarative/util/qdeclarativestate.cpp index 861cbc8..ea209aa 100644 --- a/src/declarative/util/qdeclarativestate.cpp +++ b/src/declarative/util/qdeclarativestate.cpp @@ -149,7 +149,6 @@ QDeclarativeStateOperation::QDeclarativeStateOperation(QObjectPrivate &dd, QObje \class QDeclarativeState \brief The QDeclarativeState class allows you to define configurations of objects and properties. - \ingroup group_states QDeclarativeState allows you to specify a state as a set of batched changes from the default configuration. diff --git a/src/declarative/util/qdeclarativesystempalette.cpp b/src/declarative/util/qdeclarativesystempalette.cpp index 9bb3f69..6c62446 100644 --- a/src/declarative/util/qdeclarativesystempalette.cpp +++ b/src/declarative/util/qdeclarativesystempalette.cpp @@ -59,7 +59,6 @@ public: /*! \qmlclass SystemPalette QDeclarativeSystemPalette \since 4.7 - \ingroup group_utility \brief The SystemPalette item gives access to the Qt palettes. \sa QPalette diff --git a/src/declarative/util/qdeclarativetimeline.cpp b/src/declarative/util/qdeclarativetimeline.cpp index 291b2f3..0258b3c 100644 --- a/src/declarative/util/qdeclarativetimeline.cpp +++ b/src/declarative/util/qdeclarativetimeline.cpp @@ -255,7 +255,6 @@ qreal QDeclarativeTimeLinePrivate::value(const Op &op, int time, qreal base, boo /*! \internal \class QDeclarativeTimeLine - \ingroup group_animation \brief The QDeclarativeTimeLine class provides a timeline for controlling animations. QDeclarativeTimeLine is similar to QTimeLine except: @@ -875,7 +874,6 @@ void QDeclarativeTimeLine::remove(QDeclarativeTimeLineObject *v) /*! \internal \class QDeclarativeTimeLineValue - \ingroup group_animation \brief The QDeclarativeTimeLineValue class provides a value that can be modified by QDeclarativeTimeLine. */ diff --git a/src/declarative/util/qdeclarativetransition.cpp b/src/declarative/util/qdeclarativetransition.cpp index f284156..ab8b116 100644 --- a/src/declarative/util/qdeclarativetransition.cpp +++ b/src/declarative/util/qdeclarativetransition.cpp @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE /*! \qmlclass Transition QDeclarativeTransition - \since 4.7 + \since 4.7 \brief The Transition element defines animated transitions that occur on state changes. \sa {qmlstates}{States}, {state-transitions}{Transitions}, {QtDeclarative} @@ -63,8 +63,6 @@ QT_BEGIN_NAMESPACE \internal \class QDeclarativeTransition \brief The QDeclarativeTransition class allows you to define animated transitions that occur on state changes. - - \ingroup group_states */ //ParallelAnimationWrapper allows us to do a "callback" when the animation finishes, rather than connecting -- cgit v0.12 From b23f371b5908a507f0eafcc5070b756b17672d71 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 4 May 2010 13:19:59 +1000 Subject: Optimize childrenRect. --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 115 ++++++++++++++------- src/declarative/graphicsitems/qdeclarativeitem_p.h | 15 ++- 2 files changed, 87 insertions(+), 43 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index e5faa42..04c1f85 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -230,62 +230,93 @@ QDeclarativeContents::QDeclarativeContents() : m_x(0), m_y(0), m_width(0), m_hei { } +QDeclarativeContents::~QDeclarativeContents() +{ + QList children = m_item->childItems(); + for (int i = 0; i < children.count(); ++i) { + QDeclarativeItem *child = qobject_cast(children.at(i)); + if(!child)//### Should this be ignoring non-QDeclarativeItem graphicsobjects? + continue; + QDeclarativeItemPrivate::get(child)->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry); + } +} + QRectF QDeclarativeContents::rectF() const { return QRectF(m_x, m_y, m_width, m_height); } -//TODO: optimization: only check sender(), if there is one -void QDeclarativeContents::calcHeight() +void QDeclarativeContents::calcHeight(QDeclarativeItem *changed) { qreal oldy = m_y; qreal oldheight = m_height; - qreal top = FLT_MAX; - qreal bottom = 0; - - QList children = m_item->childItems(); - for (int i = 0; i < children.count(); ++i) { - QDeclarativeItem *child = qobject_cast(children.at(i)); - if(!child)//### Should this be ignoring non-QDeclarativeItem graphicsobjects? - continue; - qreal y = child->y(); - if (y + child->height() > bottom) - bottom = y + child->height(); + if (changed) { + qreal top = oldy; + qreal bottom = oldy + oldheight; + qreal y = changed->y(); + if (y + changed->height() > bottom) + bottom = y + changed->height(); if (y < top) top = y; - } - if (!children.isEmpty()) m_y = top; - m_height = qMax(bottom - top, qreal(0.0)); + m_height = bottom - top; + } else { + qreal top = FLT_MAX; + qreal bottom = 0; + QList children = m_item->childItems(); + for (int i = 0; i < children.count(); ++i) { + QDeclarativeItem *child = qobject_cast(children.at(i)); + if(!child)//### Should this be ignoring non-QDeclarativeItem graphicsobjects? + continue; + qreal y = child->y(); + if (y + child->height() > bottom) + bottom = y + child->height(); + if (y < top) + top = y; + } + if (!children.isEmpty()) + m_y = top; + m_height = qMax(bottom - top, qreal(0.0)); + } if (m_height != oldheight || m_y != oldy) emit rectChanged(rectF()); } -//TODO: optimization: only check sender(), if there is one -void QDeclarativeContents::calcWidth() +void QDeclarativeContents::calcWidth(QDeclarativeItem *changed) { qreal oldx = m_x; qreal oldwidth = m_width; - qreal left = FLT_MAX; - qreal right = 0; - - QList children = m_item->childItems(); - for (int i = 0; i < children.count(); ++i) { - QDeclarativeItem *child = qobject_cast(children.at(i)); - if(!child)//### Should this be ignoring non-QDeclarativeItem graphicsobjects? - continue; - qreal x = child->x(); - if (x + child->width() > right) - right = x + child->width(); + if (changed) { + qreal left = oldx; + qreal right = oldx + oldwidth; + qreal x = changed->x(); + if (x + changed->width() > right) + right = x + changed->width(); if (x < left) left = x; - } - if (!children.isEmpty()) m_x = left; - m_width = qMax(right - left, qreal(0.0)); + m_width = right - left; + } else { + qreal left = FLT_MAX; + qreal right = 0; + QList children = m_item->childItems(); + for (int i = 0; i < children.count(); ++i) { + QDeclarativeItem *child = qobject_cast(children.at(i)); + if(!child)//### Should this be ignoring non-QDeclarativeItem graphicsobjects? + continue; + qreal x = child->x(); + if (x + child->width() > right) + right = x + child->width(); + if (x < left) + left = x; + } + if (!children.isEmpty()) + m_x = left; + m_width = qMax(right - left, qreal(0.0)); + } if (m_width != oldwidth || m_x != oldx) emit rectChanged(rectF()); @@ -294,23 +325,31 @@ void QDeclarativeContents::calcWidth() void QDeclarativeContents::setItem(QDeclarativeItem *item) { m_item = item; + //### optimize + connect(this, SIGNAL(rectChanged(QRectF)), m_item, SIGNAL(childrenRectChanged(QRectF))); QList children = m_item->childItems(); for (int i = 0; i < children.count(); ++i) { QDeclarativeItem *child = qobject_cast(children.at(i)); if(!child)//### Should this be ignoring non-QDeclarativeItem graphicsobjects? continue; - connect(child, SIGNAL(heightChanged()), this, SLOT(calcHeight())); - connect(child, SIGNAL(yChanged()), this, SLOT(calcHeight())); - connect(child, SIGNAL(widthChanged()), this, SLOT(calcWidth())); - connect(child, SIGNAL(xChanged()), this, SLOT(calcWidth())); - connect(this, SIGNAL(rectChanged(QRectF)), m_item, SIGNAL(childrenRectChanged(QRectF))); + QDeclarativeItemPrivate::get(child)->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); + //###what about changes to visibility? } + //### defer until componentComplete calcHeight(); calcWidth(); } +void QDeclarativeContents::itemGeometryChanged(QDeclarativeItem *changed, const QRectF &newGeometry, const QRectF &oldGeometry) +{ + if (newGeometry.width() != oldGeometry.width()) + calcWidth(changed); + if (newGeometry.height() != oldGeometry.height()) + calcHeight(changed); +} + QDeclarativeItemKeyFilter::QDeclarativeItemKeyFilter(QDeclarativeItem *item) : m_next(0) { @@ -1349,6 +1388,7 @@ QDeclarativeItem::~QDeclarativeItem() delete d->_anchorLines; d->_anchorLines = 0; delete d->_anchors; d->_anchors = 0; delete d->_stateGroup; d->_stateGroup = 0; + delete d->_contents; d->_contents = 0; } /*! @@ -1589,7 +1629,6 @@ QRectF QDeclarativeItem::childrenRect() Q_D(QDeclarativeItem); if (!d->_contents) { d->_contents = new QDeclarativeContents; - QDeclarative_setParent_noEvent(d->_contents, this); d->_contents->setItem(this); } return d->_contents->rectF(); diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h index b4dd60a..467d58a 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem_p.h +++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h @@ -79,24 +79,29 @@ class QNetworkReply; class QDeclarativeItemKeyFilter; //### merge into private? -class QDeclarativeContents : public QObject +class QDeclarativeContents : public QObject, public QDeclarativeItemChangeListener { Q_OBJECT public: QDeclarativeContents(); + ~QDeclarativeContents(); QRectF rectF() const; void setItem(QDeclarativeItem *item); -public Q_SLOTS: - void calcHeight(); - void calcWidth(); - Q_SIGNALS: void rectChanged(QRectF); +protected: + void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry); + //void itemDestroyed(QDeclarativeItem *item); + //void itemVisibilityChanged(QDeclarativeItem *item) + private: + void calcHeight(QDeclarativeItem *changed = 0); + void calcWidth(QDeclarativeItem *changed = 0); + QDeclarativeItem *m_item; qreal m_x; qreal m_y; -- cgit v0.12 From 1e3a6ac738b54c4ea3652b9f6ede665a1fafc72c Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 4 May 2010 14:03:01 +1000 Subject: Update childrenRect when children are added or removed. Task-number: QT-714 --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 38 ++++++++++++++++++++-- src/declarative/graphicsitems/qdeclarativeitem_p.h | 5 ++- .../qdeclarativeitem/data/childrenRect.qml | 27 +++++++++++++++ .../qdeclarativeitem/tst_qdeclarativeitem.cpp | 28 ++++++++++++++++ 4 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativeitem/data/childrenRect.qml diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 04c1f85..14f6b4a 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -237,7 +237,7 @@ QDeclarativeContents::~QDeclarativeContents() QDeclarativeItem *child = qobject_cast(children.at(i)); if(!child)//### Should this be ignoring non-QDeclarativeItem graphicsobjects? continue; - QDeclarativeItemPrivate::get(child)->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry); + QDeclarativeItemPrivate::get(child)->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry | QDeclarativeItemPrivate::Destroyed); } } @@ -333,7 +333,7 @@ void QDeclarativeContents::setItem(QDeclarativeItem *item) QDeclarativeItem *child = qobject_cast(children.at(i)); if(!child)//### Should this be ignoring non-QDeclarativeItem graphicsobjects? continue; - QDeclarativeItemPrivate::get(child)->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); + QDeclarativeItemPrivate::get(child)->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry | QDeclarativeItemPrivate::Destroyed); //###what about changes to visibility? } @@ -350,6 +350,30 @@ void QDeclarativeContents::itemGeometryChanged(QDeclarativeItem *changed, const calcHeight(changed); } +void QDeclarativeContents::itemDestroyed(QDeclarativeItem *item) +{ + if (item) + QDeclarativeItemPrivate::get(item)->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry | QDeclarativeItemPrivate::Destroyed); + calcWidth(); + calcHeight(); +} + +void QDeclarativeContents::childRemoved(QDeclarativeItem *item) +{ + if (item) + QDeclarativeItemPrivate::get(item)->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry | QDeclarativeItemPrivate::Destroyed); + calcWidth(); + calcHeight(); +} + +void QDeclarativeContents::childAdded(QDeclarativeItem *item) +{ + if (item) + QDeclarativeItemPrivate::get(item)->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry | QDeclarativeItemPrivate::Destroyed); + calcWidth(item); + calcHeight(item); +} + QDeclarativeItemKeyFilter::QDeclarativeItemKeyFilter(QDeclarativeItem *item) : m_next(0) { @@ -2551,6 +2575,16 @@ QVariant QDeclarativeItem::itemChange(GraphicsItemChange change, } } break; + case ItemChildAddedChange: + if (d->_contents) + d->_contents->childAdded(qobject_cast( + value.value())); + break; + case ItemChildRemovedChange: + if (d->_contents) + d->_contents->childRemoved(qobject_cast( + value.value())); + break; default: break; } diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h index 467d58a..516d6d0 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem_p.h +++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h @@ -90,12 +90,15 @@ public: void setItem(QDeclarativeItem *item); + void childRemoved(QDeclarativeItem *item); + void childAdded(QDeclarativeItem *item); + Q_SIGNALS: void rectChanged(QRectF); protected: void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry); - //void itemDestroyed(QDeclarativeItem *item); + void itemDestroyed(QDeclarativeItem *item); //void itemVisibilityChanged(QDeclarativeItem *item) private: diff --git a/tests/auto/declarative/qdeclarativeitem/data/childrenRect.qml b/tests/auto/declarative/qdeclarativeitem/data/childrenRect.qml new file mode 100644 index 0000000..f351b53 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeitem/data/childrenRect.qml @@ -0,0 +1,27 @@ +import Qt 4.7 + +Rectangle { + width: 400 + height: 400 + + property int childCount: 0; + + Item { + objectName: "testItem" + width: childrenRect.width + height: childrenRect.height + + Repeater { + id: repeater + model: childCount + delegate: Rectangle { + x: index*10 + y: index*20 + width: 10 + height: 20 + + color: "red" + } + } + } +} diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index d2c328e..e0ca746 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -63,6 +63,7 @@ private slots: void propertyChanges(); void transforms(); void transforms_data(); + void childrenRect(); void childrenProperty(); void resourcesProperty(); @@ -537,6 +538,33 @@ void tst_QDeclarativeItem::propertyChanges() delete canvas; } +void tst_QDeclarativeItem::childrenRect() +{ + QDeclarativeView *canvas = new QDeclarativeView(0); + canvas->setFixedSize(240,320); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/childrenRect.qml")); + canvas->show(); + + QGraphicsObject *o = canvas->rootObject(); + QDeclarativeItem *item = o->findChild("testItem"); + QCOMPARE(item->width(), qreal(0)); + QCOMPARE(item->height(), qreal(0)); + + o->setProperty("childCount", 1); + QCOMPARE(item->width(), qreal(10)); + QCOMPARE(item->height(), qreal(20)); + + o->setProperty("childCount", 5); + QCOMPARE(item->width(), qreal(50)); + QCOMPARE(item->height(), qreal(100)); + + o->setProperty("childCount", 0); + QCOMPARE(item->width(), qreal(0)); + QCOMPARE(item->height(), qreal(0)); + + delete o; +} + template T *tst_QDeclarativeItem::findItem(QGraphicsObject *parent, const QString &objectName) { -- cgit v0.12 From a5aadcea4c12c7926bf3b4d218ce476723cd7e10 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 4 May 2010 15:13:59 +1000 Subject: Optimization for QDeclarativePaintedItem. --- .../graphicsitems/qdeclarativepainteditem.cpp | 27 +++++++++++++--------- .../graphicsitems/qdeclarativepainteditem_p.h | 5 +++- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp index f52636f..5dd7e5d 100644 --- a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp +++ b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp @@ -59,8 +59,8 @@ QT_BEGIN_NAMESPACE \brief The QDeclarativePaintedItem class is an abstract base class for QDeclarativeView items that want cached painting. \internal - This is a convenience class for implementing items that paint their contents - using a QPainter. The contents of the item are cached behind the scenes. + This is a convenience class for implementing items that cache their painting. + The contents of the item are cached behind the scenes. The dirtyCache() function should be called if the contents change to ensure the cache is refreshed the next time painting occurs. @@ -184,7 +184,6 @@ void QDeclarativePaintedItem::setContentsScale(qreal scale) QDeclarativePaintedItem::QDeclarativePaintedItem(QDeclarativeItem *parent) : QDeclarativeItem(*(new QDeclarativePaintedItemPrivate), parent) { - init(); } /*! @@ -195,7 +194,6 @@ QDeclarativePaintedItem::QDeclarativePaintedItem(QDeclarativeItem *parent) QDeclarativePaintedItem::QDeclarativePaintedItem(QDeclarativePaintedItemPrivate &dd, QDeclarativeItem *parent) : QDeclarativeItem(dd, parent) { - init(); } /*! @@ -206,14 +204,21 @@ QDeclarativePaintedItem::~QDeclarativePaintedItem() clearCache(); } -/*! - \internal -*/ -void QDeclarativePaintedItem::init() +void QDeclarativePaintedItem::geometryChanged(const QRectF &newGeometry, + const QRectF &oldGeometry) { - connect(this,SIGNAL(widthChanged()),this,SLOT(clearCache())); - connect(this,SIGNAL(heightChanged()),this,SLOT(clearCache())); - connect(this,SIGNAL(visibleChanged()),this,SLOT(clearCache())); + if (newGeometry.width() != oldGeometry.width() || + newGeometry.height() != oldGeometry.height()) + clearCache(); +} + +QVariant QDeclarativePaintedItem::itemChange(GraphicsItemChange change, + const QVariant &value) +{ + if (change == ItemVisibleHasChanged) + clearCache(); + + return QDeclarativeItem::itemChange(change, value); } void QDeclarativePaintedItem::setCacheFrozen(bool frozen) diff --git a/src/declarative/graphicsitems/qdeclarativepainteditem_p.h b/src/declarative/graphicsitems/qdeclarativepainteditem_p.h index cc616af..8d08ba2 100644 --- a/src/declarative/graphicsitems/qdeclarativepainteditem_p.h +++ b/src/declarative/graphicsitems/qdeclarativepainteditem_p.h @@ -87,6 +87,10 @@ protected: QDeclarativePaintedItem(QDeclarativePaintedItemPrivate &dd, QDeclarativeItem *parent); virtual void drawContents(QPainter *p, const QRect &) = 0; + virtual void geometryChanged(const QRectF &newGeometry, + const QRectF &oldGeometry); + virtual QVariant itemChange(GraphicsItemChange change, + const QVariant &value); void setCacheFrozen(bool); @@ -100,7 +104,6 @@ protected Q_SLOTS: void clearCache(); private: - void init(); Q_DISABLE_COPY(QDeclarativePaintedItem) Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativePaintedItem) }; -- cgit v0.12 From 3b3ec6bc4114db82462eef812a47db420d4505c2 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Wed, 5 May 2010 10:19:40 +1000 Subject: Fix a crash with null objects returned from a Q_INVOKABLE Task-number: QTBUG-10412 Reviewed-by: Aaron Kennedy --- src/declarative/qml/qdeclarativeobjectscriptclass.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp index 03366f0..170f440 100644 --- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp +++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp @@ -775,7 +775,8 @@ QScriptDeclarativeClass::Value MetaCallArgument::toValue(QDeclarativeEngine *e) return QScriptDeclarativeClass::Value(engine, *((QString *)&data)); } else if (type == QMetaType::QObjectStar) { QObject *object = *((QObject **)&data); - QDeclarativeData::get(object, true)->setImplicitDestructible(); + if (object) + QDeclarativeData::get(object, true)->setImplicitDestructible(); QDeclarativeEnginePrivate *priv = QDeclarativeEnginePrivate::get(e); return QScriptDeclarativeClass::Value(engine, priv->objectClass->newQObject(object)); } else if (type == qMetaTypeId >()) { -- cgit v0.12 From 4982b883c31874206aaa05268852fbcee81a8a39 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 5 May 2010 11:49:20 +1000 Subject: Enable states to be activated via their 'when' clause even if unnamed. Autogenerate a name for unnamed states: "anonymousState1", etc. Task-number: QTBUG-10352 Reviewed-by: Aaron Kennedy --- src/declarative/util/qdeclarativestategroup.cpp | 10 +++++++++- .../qdeclarativestates/data/unnamedWhen.qml | 14 ++++++++++++++ .../qdeclarativestates/tst_qdeclarativestates.cpp | 20 ++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tests/auto/declarative/qdeclarativestates/data/unnamedWhen.qml diff --git a/src/declarative/util/qdeclarativestategroup.cpp b/src/declarative/util/qdeclarativestategroup.cpp index 5b51495..9b042d7 100644 --- a/src/declarative/util/qdeclarativestategroup.cpp +++ b/src/declarative/util/qdeclarativestategroup.cpp @@ -47,6 +47,7 @@ #include #include +#include #include #include @@ -62,7 +63,7 @@ class QDeclarativeStateGroupPrivate : public QObjectPrivate public: QDeclarativeStateGroupPrivate() : nullState(0), componentComplete(true), - ignoreTrans(false), applyingState(false) {} + ignoreTrans(false), applyingState(false), unnamedCount(0) {} QString currentState; QDeclarativeState *nullState; @@ -78,6 +79,7 @@ public: bool componentComplete; bool ignoreTrans; bool applyingState; + int unnamedCount; QDeclarativeTransition *findTransition(const QString &from, const QString &to); void setCurrentStateInternal(const QString &state, bool = false); @@ -259,6 +261,12 @@ void QDeclarativeStateGroup::componentComplete() Q_D(QDeclarativeStateGroup); d->componentComplete = true; + for (int ii = 0; ii < d->states.count(); ++ii) { + QDeclarativeState *state = d->states.at(ii); + if (state->name().isEmpty()) + state->setName(QLatin1String("anonymousState") % QString::number(++d->unnamedCount)); + } + if (d->updateAutoState()) { return; } else if (!d->currentState.isEmpty()) { diff --git a/tests/auto/declarative/qdeclarativestates/data/unnamedWhen.qml b/tests/auto/declarative/qdeclarativestates/data/unnamedWhen.qml new file mode 100644 index 0000000..a70840c --- /dev/null +++ b/tests/auto/declarative/qdeclarativestates/data/unnamedWhen.qml @@ -0,0 +1,14 @@ +import Qt 4.7 + +Rectangle { + id: theRect + property bool triggerState: false + property string stateString: "" + states: State { + when: triggerState + PropertyChanges { + target: theRect + stateString: "inState" + } + } +} diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp index d384d26..13992ad 100644 --- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp +++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp @@ -110,6 +110,7 @@ private slots: void illegalObjectCreation(); void whenOrdering(); void urlResolution(); + void unnamedWhen(); }; void tst_qdeclarativestates::initTestCase() @@ -1049,6 +1050,25 @@ void tst_qdeclarativestates::urlResolution() QCOMPARE(image3->source(), resolved); } +void tst_qdeclarativestates::unnamedWhen() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, SRCDIR "/data/unnamedWhen.qml"); + QDeclarativeRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + + QCOMPARE(rectPrivate->state(), QLatin1String("")); + QCOMPARE(rect->property("stateString").toString(), QLatin1String("")); + rect->setProperty("triggerState", true); + QCOMPARE(rectPrivate->state(), QLatin1String("anonymousState1")); + QCOMPARE(rect->property("stateString").toString(), QLatin1String("inState")); + rect->setProperty("triggerState", false); + QCOMPARE(rectPrivate->state(), QLatin1String("")); + QCOMPARE(rect->property("stateString").toString(), QLatin1String("")); +} + QTEST_MAIN(tst_qdeclarativestates) #include "tst_qdeclarativestates.moc" -- cgit v0.12 From 326dab74ba8df7707d1054ca5e0280c5f131c148 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 5 May 2010 12:51:02 +1000 Subject: Null objects should appear as JS null --- src/declarative/qml/qdeclarativeobjectscriptclass.cpp | 3 ++- tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml | 4 ++-- .../declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp index 170f440..8b64e0e 100644 --- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp +++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp @@ -104,7 +104,8 @@ QScriptValue QDeclarativeObjectScriptClass::newQObject(QObject *object, int type QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine); if (!object) - return newObject(scriptEngine, this, new ObjectData(object, type)); + return scriptEngine->nullValue(); +// return newObject(scriptEngine, this, new ObjectData(object, type)); if (QObjectPrivate::get(object)->wasDeleted) return scriptEngine->undefinedValue(); diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml b/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml index 72b59ae..2337e44 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml @@ -19,7 +19,7 @@ QtObject { myObject.deleteOnSet = 1; - test3 = myObject.value == undefined; - test4 = obj.value == undefined; + test3 = myObject == null + test4 = obj == null } } diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 6d39be2..8c9290f 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -1104,7 +1104,7 @@ void tst_qdeclarativeecmascript::exceptionClearsOnReeval() QDeclarativeComponent component(&engine, TEST_FILE("exceptionClearsOnReeval.qml")); QString url = component.url().toString(); - QString warning = url + ":4: TypeError: Result of expression 'objectProperty.objectProperty' [undefined] is not an object."; + QString warning = url + ":4: TypeError: Result of expression 'objectProperty' [null] is not an object."; QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); MyQmlObject *object = qobject_cast(component.create()); -- cgit v0.12 From dcee637a9f7a024803f0e5cc1bf57d878dca2ac3 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Wed, 5 May 2010 09:50:53 +1000 Subject: Doc improvements, simplify example code --- doc/src/declarative/advtutorial.qdoc | 50 +++++++++++++++---- doc/src/declarative/tutorial.qdoc | 15 +++--- .../declarative/tutorials/helloworld/tutorial1.qml | 3 +- .../declarative/tutorials/helloworld/tutorial2.qml | 3 +- .../declarative/tutorials/helloworld/tutorial3.qml | 3 +- .../tutorials/samegame/samegame1/Block.qml | 2 +- .../tutorials/samegame/samegame1/Button.qml | 17 +++++-- .../tutorials/samegame/samegame1/samegame.qml | 7 ++- .../tutorials/samegame/samegame2/Block.qml | 2 +- .../tutorials/samegame/samegame2/Button.qml | 17 +++++-- .../tutorials/samegame/samegame2/samegame.qml | 5 +- .../tutorials/samegame/samegame3/Button.qml | 17 +++++-- .../tutorials/samegame/samegame3/Dialog.qml | 33 ++++++------- .../tutorials/samegame/samegame3/samegame.js | 9 ++-- .../tutorials/samegame/samegame3/samegame.qml | 14 +++--- .../samegame/samegame4/content/Button.qml | 17 +++++-- .../samegame/samegame4/content/Dialog.qml | 57 ++++++++++++++++------ .../samegame/samegame4/content/samegame.js | 17 ++++--- .../tutorials/samegame/samegame4/samegame.qml | 38 +++++---------- 19 files changed, 208 insertions(+), 118 deletions(-) diff --git a/doc/src/declarative/advtutorial.qdoc b/doc/src/declarative/advtutorial.qdoc index 42ce246..7d2967e 100644 --- a/doc/src/declarative/advtutorial.qdoc +++ b/doc/src/declarative/advtutorial.qdoc @@ -109,12 +109,16 @@ Notice the anchors for the \c Item, \c Button and \c Text elements are set using \section2 Adding \c Button and \c Block components -The \c Button item in the code above is defined in a separate file named \c Button.qml. +The \c Button item in the code above is defined in a separate component file named \c Button.qml. To create a functional button, we use the QML elements \l Text and \l MouseArea inside a \l Rectangle. Here is the \c Button.qml code: \snippet declarative/tutorials/samegame/samegame1/Button.qml 0 +This essentially defines a rectangle that contains text and can be clicked. The \l MouseArea +has an \c onClicked() handler that is implemented to emit the \c clicked() signal of the +\c container when the area is clicked. + In Same Game, the screen is filled with small blocks when the game begins. Each block is just an item that contains an image. The block code is defined in a separate \c Block.qml file: @@ -226,14 +230,14 @@ until it is won or lost. To do this, we have added the following functions to \c samegame.js: \list -\o function \c{handleClick(x,y)} -\o function \c{floodFill(xIdx,yIdx,type)} -\o function \c{shuffleDown()} -\o function \c{victoryCheck()} -\o function \c{floodMoveCheck(xIdx, yIdx, type)} +\o \c{handleClick(x,y)} +\o \c{floodFill(xIdx,yIdx,type)} +\o \c{shuffleDown()} +\o \c{victoryCheck()} +\o \c{floodMoveCheck(xIdx, yIdx, type)} \endlist -As this is a tutorial about QML, not game design, we will only discuss \c handleClick() and \c victoryCheck() below since they interface directly with the QML elements. Note that although the game logic here is written in JavaScript, it could have been written in C++ and then exposed to JavaScript. +As this is a tutorial about QML, not game design, we will only discuss \c handleClick() and \c victoryCheck() below since they interface directly with the QML elements. Note that although the game logic here is written in JavaScript, it could have been written in C++ and then exposed to QML. \section3 Enabling mouse click interaction @@ -269,6 +273,8 @@ And this is how it is used in the main \c samegame.qml file: \snippet declarative/tutorials/samegame/samegame3/samegame.qml 2 +We give the dialog a \l {Item::z}{z} value of 100 to ensure it is displayed on top of our other components. The default \c z value for an item is 0. + \section3 A dash of color @@ -383,15 +389,41 @@ The theme change here is produced simply by replacing the block images. This can Another feature we might want to add to the game is a method of storing and retrieving high scores. -In \c samegame.qml we now pop up a dialog when the game is over and requests the player's name so it can be added to a High Scores table. The dialog is created using \c Dialog.qml: +To do this, we will show a dialog when the game is over to request the player's name and add it to a High Scores table. +This requires a few changes to \c Dialog.qml. In addition to a \c Text element, it now has a +\c TextInput child item for receiving keyboard text input: + +\snippet declarative/tutorials/samegame/samegame4/content/Dialog.qml 0 +\dots 4 +\snippet declarative/tutorials/samegame/samegame4/content/Dialog.qml 2 +\dots 4 +\snippet declarative/tutorials/samegame/samegame4/content/Dialog.qml 3 + +We'll also add a \c showWithInput() function. The text input will only be visible if this function +is called instead of \c show(). When the dialog is closed, it emits a \c closed() signal, and +other elements can retrieve the text entered by the user through an \c inputText property: + +\snippet declarative/tutorials/samegame/samegame4/content/Dialog.qml 0 +\snippet declarative/tutorials/samegame/samegame4/content/Dialog.qml 1 +\dots 4 +\snippet declarative/tutorials/samegame/samegame4/content/Dialog.qml 3 + +Now the dialog can be used in \c samegame.qml: \snippet declarative/tutorials/samegame/samegame4/samegame.qml 0 -When the dialog is closed, we call the new \c saveHighScore() function in \c samegame.js, which stores the high score locally in an SQL database and also send the score to an online database if possible. +When the dialog emits the \c closed signal, we call the new \c saveHighScore() function in \c samegame.js, which stores the high score locally in an SQL database and also send the score to an online database if possible. +The \c nameInputDialog is activated in the \c victoryCheck() function in \c samegame.js: + +\snippet declarative/tutorials/samegame/samegame4/content/samegame.js 3 +\dots 4 +\snippet declarative/tutorials/samegame/samegame4/content/samegame.js 4 \section3 Storing high scores offline +Now we need to implement the functionality to actually save the High Scores table. + Here is the \c saveHighScore() function in \c samegame.js: \snippet declarative/tutorials/samegame/samegame4/content/samegame.js 2 diff --git a/doc/src/declarative/tutorial.qdoc b/doc/src/declarative/tutorial.qdoc index 1a93d05..4cfb999 100644 --- a/doc/src/declarative/tutorial.qdoc +++ b/doc/src/declarative/tutorial.qdoc @@ -86,7 +86,7 @@ Here is the QML code for the application: \section2 Import First, we need to import the types that we need for this example. Most QML files will import the built-in QML -types (like \l{Rectangle}, \l{Image}, ...) that come with Qt with: +types (like \l{Rectangle}, \l{Image}, ...) that come with Qt, using: \snippet examples/declarative/tutorials/helloworld/tutorial1.qml 3 @@ -95,7 +95,7 @@ types (like \l{Rectangle}, \l{Image}, ...) that come with Qt with: \snippet examples/declarative/tutorials/helloworld/tutorial1.qml 1 We declare a root element of type \l{Rectangle}. It is one of the basic building blocks you can use to create an application in QML. -We give it an \c{id} to be able to refer to it later. In this case, we call it \e page. +We give it an \c{id} to be able to refer to it later. In this case, we call it "page". We also set the \c width, \c height and \c color properties. The \l{Rectangle} element contains many other properties (such as \c x and \c y), but these are left at their default values. @@ -103,15 +103,16 @@ The \l{Rectangle} element contains many other properties (such as \c x and \c y) \snippet examples/declarative/tutorials/helloworld/tutorial1.qml 2 -We add a \l Text element as a child of our root element that will display the text 'Hello world!'. +We add a \l Text element as a child of the root Rectangle element that displays the text 'Hello world!'. The \c y property is used to position the text vertically at 30 pixels from the top of its parent. -The \c font.pointSize and \c font.bold properties are related to fonts and use the \l{dot properties}{dot notation}. - The \c anchors.horizontalCenter property refers to the horizontal center of an element. In this case, we specify that our text element should be horizontally centered in the \e page element (see \l{anchor-layout}{Anchor-based Layout}). +The \c font.pointSize and \c font.bold properties are related to fonts and use the \l{dot properties}{dot notation}. + + \section2 Viewing the example To view what you have created, run the \l{Qt Declarative UI Runtime}{qml} tool (located in the \c bin directory) with your filename as the first argument. @@ -134,10 +135,10 @@ This chapter adds a color picker to change the color of the text. \image declarative-tutorial2.png Our color picker is made of six cells with different colors. -To avoid writing the same code multiple times, we first create a new \c Cell component. +To avoid writing the same code multiple times for each cell, we create a new \c Cell component. A component provides a way of defining a new type that we can re-use in other QML files. A QML component is like a black-box and interacts with the outside world through properties, signals and slots and is generally -defined in its own QML file (for more details, see \l {Defining new Components}). +defined in its own QML file. (For more details, see \l {Defining new Components}). The component's filename must always start with a capital letter. Here is the QML code for \c Cell.qml: diff --git a/examples/declarative/tutorials/helloworld/tutorial1.qml b/examples/declarative/tutorials/helloworld/tutorial1.qml index 5e27b45..04cd155 100644 --- a/examples/declarative/tutorials/helloworld/tutorial1.qml +++ b/examples/declarative/tutorials/helloworld/tutorial1.qml @@ -14,8 +14,9 @@ Rectangle { Text { id: helloText text: "Hello world!" + y: 30 + anchors.horizontalCenter: page.horizontalCenter font.pointSize: 24; font.bold: true - y: 30; anchors.horizontalCenter: page.horizontalCenter } //![2] } diff --git a/examples/declarative/tutorials/helloworld/tutorial2.qml b/examples/declarative/tutorials/helloworld/tutorial2.qml index 085efa4..66be509 100644 --- a/examples/declarative/tutorials/helloworld/tutorial2.qml +++ b/examples/declarative/tutorials/helloworld/tutorial2.qml @@ -9,8 +9,9 @@ Rectangle { Text { id: helloText text: "Hello world!" + y: 30 + anchors.horizontalCenter: page.horizontalCenter font.pointSize: 24; font.bold: true - y: 30; anchors.horizontalCenter: page.horizontalCenter } Grid { diff --git a/examples/declarative/tutorials/helloworld/tutorial3.qml b/examples/declarative/tutorials/helloworld/tutorial3.qml index 4bf4970..041d9a9 100644 --- a/examples/declarative/tutorials/helloworld/tutorial3.qml +++ b/examples/declarative/tutorials/helloworld/tutorial3.qml @@ -9,8 +9,9 @@ Rectangle { Text { id: helloText text: "Hello world!" + y: 30 + anchors.horizontalCenter: page.horizontalCenter font.pointSize: 24; font.bold: true - y: 30; anchors.horizontalCenter: page.horizontalCenter //![1] MouseArea { id: mouseArea; anchors.fill: parent } diff --git a/examples/declarative/tutorials/samegame/samegame1/Block.qml b/examples/declarative/tutorials/samegame/samegame1/Block.qml index a23654b..11fd844 100644 --- a/examples/declarative/tutorials/samegame/samegame1/Block.qml +++ b/examples/declarative/tutorials/samegame/samegame1/Block.qml @@ -7,7 +7,7 @@ Item { Image { id: img anchors.fill: parent - source: "../shared/pics/redStone.png"; + source: "../shared/pics/redStone.png" } } //![0] diff --git a/examples/declarative/tutorials/samegame/samegame1/Button.qml b/examples/declarative/tutorials/samegame/samegame1/Button.qml index e84b1ce..96a80eb 100644 --- a/examples/declarative/tutorials/samegame/samegame1/Button.qml +++ b/examples/declarative/tutorials/samegame/samegame1/Button.qml @@ -8,9 +8,9 @@ Rectangle { signal clicked - width: buttonLabel.width + 20; height: buttonLabel.height + 6 - smooth: true + width: buttonLabel.width + 20; height: buttonLabel.height + 5 border { width: 1; color: Qt.darker(activePalette.button) } + smooth: true radius: 8 // color the button with a gradient @@ -27,8 +27,17 @@ Rectangle { GradientStop { position: 1.0; color: activePalette.button } } - MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() } + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: container.clicked(); + } - Text { id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText } + Text { + id: buttonLabel + anchors.centerIn: container + color: activePalette.buttonText + text: container.text + } } //![0] diff --git a/examples/declarative/tutorials/samegame/samegame1/samegame.qml b/examples/declarative/tutorials/samegame/samegame1/samegame.qml index b6e01fd..f2974be 100644 --- a/examples/declarative/tutorials/samegame/samegame1/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame1/samegame.qml @@ -22,21 +22,20 @@ Rectangle { Rectangle { id: toolBar - width: parent.width; height: 32 + width: parent.width; height: 30 color: activePalette.window anchors.bottom: screen.bottom Button { - anchors { left: parent.left; leftMargin: 3; verticalCenter: parent.verticalCenter } + anchors { left: parent.left; verticalCenter: parent.verticalCenter } text: "New Game" onClicked: console.log("This doesn't do anything yet...") } Text { id: score - anchors { right: parent.right; rightMargin: 3; verticalCenter: parent.verticalCenter } + anchors { right: parent.right; verticalCenter: parent.verticalCenter } text: "Score: Who knows?" - font.bold: true } } } diff --git a/examples/declarative/tutorials/samegame/samegame2/Block.qml b/examples/declarative/tutorials/samegame/samegame2/Block.qml index 4e71e60..39da84e 100644 --- a/examples/declarative/tutorials/samegame/samegame2/Block.qml +++ b/examples/declarative/tutorials/samegame/samegame2/Block.qml @@ -6,6 +6,6 @@ Item { Image { id: img anchors.fill: parent - source: "../shared/pics/redStone.png"; + source: "../shared/pics/redStone.png" } } diff --git a/examples/declarative/tutorials/samegame/samegame2/Button.qml b/examples/declarative/tutorials/samegame/samegame2/Button.qml index 737d886..4ed856b 100644 --- a/examples/declarative/tutorials/samegame/samegame2/Button.qml +++ b/examples/declarative/tutorials/samegame/samegame2/Button.qml @@ -7,9 +7,9 @@ Rectangle { signal clicked - width: buttonLabel.width + 20; height: buttonLabel.height + 6 - smooth: true + width: buttonLabel.width + 20; height: buttonLabel.height + 5 border { width: 1; color: Qt.darker(activePalette.button) } + smooth: true radius: 8 // color the button with a gradient @@ -26,7 +26,16 @@ Rectangle { GradientStop { position: 1.0; color: activePalette.button } } - MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() } + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: container.clicked(); + } - Text { id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText } + Text { + id: buttonLabel + anchors.centerIn: container + color: activePalette.buttonText + text: container.text + } } diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame.qml b/examples/declarative/tutorials/samegame/samegame2/samegame.qml index a7d1fba..9b4d4d5 100644 --- a/examples/declarative/tutorials/samegame/samegame2/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame2/samegame.qml @@ -30,7 +30,7 @@ Rectangle { //![1] Button { - anchors { left: parent.left; leftMargin: 3; verticalCenter: parent.verticalCenter } + anchors { left: parent.left; verticalCenter: parent.verticalCenter } text: "New Game" onClicked: SameGame.startNewGame() } @@ -38,9 +38,8 @@ Rectangle { Text { id: score - anchors { right: parent.right; rightMargin: 3; verticalCenter: parent.verticalCenter } + anchors { right: parent.right; verticalCenter: parent.verticalCenter } text: "Score: Who knows?" - font.bold: true } } } diff --git a/examples/declarative/tutorials/samegame/samegame3/Button.qml b/examples/declarative/tutorials/samegame/samegame3/Button.qml index 737d886..4ed856b 100644 --- a/examples/declarative/tutorials/samegame/samegame3/Button.qml +++ b/examples/declarative/tutorials/samegame/samegame3/Button.qml @@ -7,9 +7,9 @@ Rectangle { signal clicked - width: buttonLabel.width + 20; height: buttonLabel.height + 6 - smooth: true + width: buttonLabel.width + 20; height: buttonLabel.height + 5 border { width: 1; color: Qt.darker(activePalette.button) } + smooth: true radius: 8 // color the button with a gradient @@ -26,7 +26,16 @@ Rectangle { GradientStop { position: 1.0; color: activePalette.button } } - MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() } + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: container.clicked(); + } - Text { id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText } + Text { + id: buttonLabel + anchors.centerIn: container + color: activePalette.buttonText + text: container.text + } } diff --git a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml index 15b3b2f..3efed2f 100644 --- a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml +++ b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml @@ -2,31 +2,30 @@ import Qt 4.7 Rectangle { - id: page + id: container - signal closed - - function forceClose() { - page.closed(); - page.opacity = 0; + function show(text) { + dialogText.text = text; + container.opacity = 1; } - function show(txt) { - dialogText.text = txt; - page.opacity = 1; + function hide() { + container.opacity = 0; } - width: dialogText.width + 20; height: dialogText.height + 20 - color: "white" - border.width: 1 + width: dialogText.width + 20 + height: dialogText.height + 20 opacity: 0 - Behavior on opacity { - NumberAnimation { duration: 1000 } + Text { + id: dialogText + anchors.centerIn: parent + text: "" } - Text { id: dialogText; anchors.centerIn: parent; text: "Hello World!" } - - MouseArea { anchors.fill: parent; onClicked: forceClose(); } + MouseArea { + anchors.fill: parent + onClicked: hide(); + } } //![0] diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.js b/examples/declarative/tutorials/samegame/samegame3/samegame.js index 4256aee..84439fc 100644 --- a/examples/declarative/tutorials/samegame/samegame3/samegame.js +++ b/examples/declarative/tutorials/samegame/samegame3/samegame.js @@ -17,7 +17,7 @@ function startNewGame() { maxIndex = maxRow * maxColumn; //Close dialogs - dialog.forceClose(); + dialog.hide(); //Initialize Board board = new Array(maxIndex); @@ -59,10 +59,9 @@ function createBlock(column, row) { return true; } -var fillFound; -//Set after a floodFill call to the number of blocks found -var floodBoard; -//Set to 1 if the floodFill reaches off that node +var fillFound; //Set after a floodFill call to the number of blocks found +var floodBoard; //Set to 1 if the floodFill reaches off that node + //![1] function handleClick(xPos, yPos) { var column = Math.floor(xPos / gameCanvas.blockSize); diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.qml b/examples/declarative/tutorials/samegame/samegame3/samegame.qml index 50f9d5d..ac93eb1 100644 --- a/examples/declarative/tutorials/samegame/samegame3/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame3/samegame.qml @@ -30,7 +30,6 @@ Rectangle { width: parent.width - (parent.width % blockSize) height: parent.height - (parent.height % blockSize) anchors.centerIn: parent - z: 20 MouseArea { anchors.fill: parent @@ -41,26 +40,29 @@ Rectangle { } //![2] - Dialog { id: dialog; anchors.centerIn: parent; z: 21 } + Dialog { + id: dialog + anchors.centerIn: parent + z: 100 + } //![2] Rectangle { id: toolBar - width: parent.width; height: 32 + width: parent.width; height: 30 color: activePalette.window anchors.bottom: screen.bottom Button { - anchors { left: parent.left; leftMargin: 3; verticalCenter: parent.verticalCenter } + anchors { left: parent.left; verticalCenter: parent.verticalCenter } text: "New Game" onClicked: SameGame.startNewGame() } Text { id: score - anchors { right: parent.right; rightMargin: 3; verticalCenter: parent.verticalCenter } + anchors { right: parent.right; verticalCenter: parent.verticalCenter } text: "Score: Who knows?" - font.bold: true } } } diff --git a/examples/declarative/tutorials/samegame/samegame4/content/Button.qml b/examples/declarative/tutorials/samegame/samegame4/content/Button.qml index 737d886..4ed856b 100644 --- a/examples/declarative/tutorials/samegame/samegame4/content/Button.qml +++ b/examples/declarative/tutorials/samegame/samegame4/content/Button.qml @@ -7,9 +7,9 @@ Rectangle { signal clicked - width: buttonLabel.width + 20; height: buttonLabel.height + 6 - smooth: true + width: buttonLabel.width + 20; height: buttonLabel.height + 5 border { width: 1; color: Qt.darker(activePalette.button) } + smooth: true radius: 8 // color the button with a gradient @@ -26,7 +26,16 @@ Rectangle { GradientStop { position: 1.0; color: activePalette.button } } - MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() } + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: container.clicked(); + } - Text { id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText } + Text { + id: buttonLabel + anchors.centerIn: container + color: activePalette.buttonText + text: container.text + } } diff --git a/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml b/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml index 6848534..2f45362 100644 --- a/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml +++ b/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml @@ -1,30 +1,59 @@ import Qt 4.7 +//![0] Rectangle { - id: page + id: container +//![0] +//![1] + property string inputText: textInput.text signal closed - function forceClose() { - page.closed(); - page.opacity = 0; + function show(text) { + dialogText.text = text; + container.opacity = 1; + textInput.opacity = 0; } - function show(txt) { - dialogText.text = txt; - page.opacity = 1; + function showWithInput(text) { + show(text); + textInput.opacity = 1; + textInput.text = "" } - width: dialogText.width + 20; height: dialogText.height + 20 - color: "white" - border.width: 1 + function hide() { + container.opacity = 0; + container.closed(); + } +//![1] + + width: dialogText.width + textInput.width + 20 + height: dialogText.height + 20 opacity: 0 - Behavior on opacity { - NumberAnimation { duration: 1000 } + Text { + id: dialogText + anchors { verticalCenter: parent.verticalCenter; left: parent.left; leftMargin: 10 } + text: "" + } + +//![2] + TextInput { + id: textInput + anchors { verticalCenter: parent.verticalCenter; left: dialogText.right } + width: 80 + focus: true + text: "" + + onAccepted: container.hide() // close dialog when Enter is pressed } +//![2] - Text { id: dialogText; anchors.centerIn: parent; text: "Hello World!" } + MouseArea { + anchors.fill: parent + onClicked: hide(); + } - MouseArea { anchors.fill: parent; onClicked: forceClose(); } +//![3] } +//![3] diff --git a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js index 961cd66..06d21e6 100755 --- a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js +++ b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js @@ -25,8 +25,8 @@ function startNewGame() { maxIndex = maxRow * maxColumn; //Close dialogs - nameInputDialog.forceClose(); - dialog.forceClose(); + nameInputDialog.hide(); + dialog.hide(); //Initialize Board board = new Array(maxIndex); @@ -72,10 +72,9 @@ function createBlock(column, row) { return true; } -var fillFound; -//Set after a floodFill call to the number of blocks found -var floodBoard; -//Set to 1 if the floodFill reaches off that node +var fillFound; //Set after a floodFill call to the number of blocks found +var floodBoard; //Set to 1 if the floodFill reaches off that node + function handleClick(xPos, yPos) { var column = Math.floor(xPos / gameCanvas.blockSize); var row = Math.floor(yPos / gameCanvas.blockSize); @@ -157,7 +156,9 @@ function shuffleDown() { } } +//![3] function victoryCheck() { +//![3] //Award bonus points if no blocks left var deservesBonus = true; for (var column = maxColumn - 1; column >= 0; column--) @@ -166,12 +167,14 @@ function victoryCheck() { if (deservesBonus) gameCanvas.score += 500; +//![4] //Check whether game has finished if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) { gameDuration = new Date() - gameDuration; - nameInputDialog.show("You won! Please enter your name: "); + nameInputDialog.showWithInput("You won! Please enter your name: "); } } +//![4] //only floods up and right, to see if it can find adjacent same-typed blocks function floodMoveCheck(column, row, type) { diff --git a/examples/declarative/tutorials/samegame/samegame4/samegame.qml b/examples/declarative/tutorials/samegame/samegame4/samegame.qml index 404af0a..feb61fd 100644 --- a/examples/declarative/tutorials/samegame/samegame4/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame4/samegame.qml @@ -25,7 +25,7 @@ Rectangle { property int score: 0 property int blockSize: 40 - z: 20; anchors.centerIn: parent + anchors.centerIn: parent width: parent.width - (parent.width % blockSize); height: parent.height - (parent.height % blockSize); @@ -35,53 +35,41 @@ Rectangle { } } - Dialog { id: dialog; anchors.centerIn: parent; z: 21 } + Dialog { + id: dialog + anchors.centerIn: parent + z: 100 + } //![0] Dialog { id: nameInputDialog - anchors.centerIn: parent - z: 22 + z: 100 - Text { - id: dialogText - opacity: 0 - text: " You won! Please enter your name:" - } - - TextInput { - id: nameInput - width: 72 - anchors { verticalCenter: parent.verticalCenter; left: dialogText.right } - focus: true - - onAccepted: { - if (nameInputDialog.opacity == 1 && nameInput.text != "") - SameGame.saveHighScore(nameInput.text); - nameInputDialog.forceClose(); - } + onClosed: { + if (nameInputDialog.inputText != "") + SameGame.saveHighScore(nameInputDialog.inputText); } } //![0] Rectangle { id: toolBar - width: parent.width; height: 32 + width: parent.width; height: 30 color: activePalette.window anchors.bottom: screen.bottom Button { - anchors { left: parent.left; leftMargin: 3; verticalCenter: parent.verticalCenter } + anchors { left: parent.left; verticalCenter: parent.verticalCenter } text: "New Game" onClicked: SameGame.startNewGame() } Text { id: score - anchors { right: parent.right; rightMargin: 3; verticalCenter: parent.verticalCenter } + anchors { right: parent.right; verticalCenter: parent.verticalCenter } text: "Score: " + gameCanvas.score - font.bold: true } } } -- cgit v0.12